CloneSet22


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
263210.999class_body_declarations[13]
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
1263284
plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/ExternalizeStringsAction.java
2263195
plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindStringsToExternalizeAction.java
Clone Instance
1
Line Count
263
Source Line
284
Source File
plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/ExternalizeStringsAction.java

        private void showResults() {
                if (noStrings())
                        MessageDialog.openInformation(getShell(), getDialogTitle(), ActionMessages.FindStringsToExternalizeAction_noStrings);
                else
                        new NonNLSListDialog(getShell(), fElements, countStrings()).open();
        }

        private boolean noStrings() {
                if (fElements != null) {
                        for (int i = 0; i < fElements.length; i++) {
                                if (fElements[i].count != 0)
                                        return false;
                        }
                }
                return true;
        }

        /*
         * returns List of Strings
         */
        private List analyze(IPackageFragment pack, IProgressMonitor pm) throws CoreException {
                try {
                        if (pack == null)
                                return new ArrayList(0);

                        ICompilationUnit[] cus = pack.getCompilationUnits();

                        pm.beginTask("", cus.length); //$NON-NLS-1$
                        pm.setTaskName(pack.getElementName());

                        List l = new ArrayList(cus.length);
                        for (int i = 0; i < cus.length; i++) {
                                pm.subTask(cus[i].getElementName());
                                NonNLSElement element = analyze(cus[i]);
                                if (element != null)
                                        l.add(element);
                                pm.worked(1);
                                if (pm.isCanceled())
                                        throw new OperationCanceledException();
                        }
                        return l;
                } finally {
                        pm.done();
                  }
        }

        /*
         * returns List of Strings
         */
        private List analyze(IPackageFragmentRoot sourceFolder, IProgressMonitor pm) throws CoreException {
                try {
                        IJavaElement[] children = sourceFolder.getChildren();
                        pm.beginTask("", children.length); //$NON-NLS-1$
                        pm.setTaskName(sourceFolder.getElementName());
                        List result = new ArrayList();
                        for (int i = 0; i < children.length; i++) {
                                IJavaElement iJavaElement = children[i];
                                if (iJavaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
                                        IPackageFragment pack = (IPackageFragment) iJavaElement;
                                        if ( ! pack.isReadOnly())
                                                result.addAll(analyze(pack, new SubProgressMonitor(pm, 1)));
                                        else
                                                pm.worked(1);
                                }
                                else    pm.worked(1);
                        }
                        return result;
                } finally {
                        pm.done();
                  }
        }

        /*
         * returns List of Strings
         */
        private List analyze(IJavaProject project, IProgressMonitor pm) throws CoreException {
                try {
                        IPackageFragment[] packs = project.getPackageFragments();
                        pm.beginTask("", packs.length); //$NON-NLS-1$
                        List result = new ArrayList();
                        for (int i = 0; i < packs.length; i++) {
                                if ( ! packs[i].isReadOnly())
                                        result.addAll(analyze(packs[i], new SubProgressMonitor(pm, 1)));
                                else
                                        pm.worked(1);
                        }
                        return result;
                } finally {
                        pm.done();
                  }
        }

        private int countStrings() {
                int found = 0;
                if (fElements != null) {
                        for (int i = 0; i < fElements.length; i++)
                                found += fElements[i].count;
                }
                return found;
        }

        private NonNLSElement analyze(ICompilationUnit cu) throws CoreException {
                int count = countNonExternalizedStrings(cu);
                if (count == 0)
                        return null;
                else
                        return new NonNLSElement(cu, count);
        }

        private int countNonExternalizedStrings(ICompilationUnit cu) throws CoreException {
                try {
                        NLSLine[] lines = NLSScanner.scan(cu);
                        int result = 0;
                        for (int i = 0; i < lines.length; i++) {
                                result += countNonExternalizedStrings(lines[i]);
                        }
                        return result;
                } catch (InvalidInputException e) {
                        throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.ERROR, 
                                Messages.format(ActionMessages.FindStringsToExternalizeAction_error_cannotBeParsed, cu.getElementName()), 
                                e                         ));
                  }
        }

        private int countNonExternalizedStrings(NLSLine line) {
                int result = 0;
                NLSElement[] elements = line.getElements();
                for (int i = 0; i < elements.length; i++) {
                        if ( ! elements[i].hasTag())
                                result++;
                }
                return result;
        }

        /**
         * returns <code>List</code> of <code>IPackageFragments</code>,  <code>IPackageFragmentRoots</code> or 
         * <code>IJavaProjects</code> (all entries are of the same kind)
         */
        private static List getSelectedElementList(IStructuredSelection selection) {
                if (selection == null)
                        return null;

                return selection.toList();
        }

        //-------private classes --------------

        private static class NonNLSListDialog extends ListDialog {

                private static final int OPEN_BUTTON_ID = IDialogConstants.CLIENT_ID + 1;

                private Button fOpenButton;

                NonNLSListDialog(Shell parent, NonNLSElement[] input, int count) {
                        super(parent);
                        setInput(Arrays.asList(input));
                        setTitle(ActionMessages.ExternalizeStringsAction_dialog_title);
                        setMessage(Messages.format(ActionMessages.FindStringsToExternalizeAction_non_externalized, new Object[] {
                                                                                                                                 new Integer(count)
                                                                                                                                } ));
                        setContentProvider(new ArrayContentProvider());
                        setLabelProvider(createLabelProvider());
                }

                public void create() {
                        setShellStyle(SWT.DIALOG_TRIM|  SWT.RESIZE|  SWT.MIN);
                        super.create();
                }

                protected Point getInitialSize() {
                        return getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
                }

                protected Control createDialogArea(Composite parent) {
                        Composite result = (Composite) super.createDialogArea(parent);
                        getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() {
                                public void selectionChanged(SelectionChangedEvent event) {
                                        if (fOpenButton != null) {
                                                fOpenButton.setEnabled( ! getTableViewer().getSelection().isEmpty());
                                        }
                                }
                                                                     } );
                        getTableViewer().getTable().addSelectionListener(new SelectionAdapter() {
                                public void widgetDefaultSelected(SelectionEvent e) {
                                        NonNLSElement element = (NonNLSElement) e.item.getData();
                                        openWizard(element.cu);
                                }
                                                                         } );
                        getTableViewer().getTable().setFocus();
                        applyDialogFont(result);
                        return result;
                }

                protected void createButtonsForButtonBar(Composite parent) {
                        fOpenButton = createButton(parent, OPEN_BUTTON_ID, ActionMessages.FindStringsToExternalizeAction_button_label, true);
                        fOpenButton.setEnabled(false);

                        //looks like a 'close' but it a 'cancel'
                        createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CLOSE_LABEL, false);
                }

                protected void buttonPressed(int buttonId) {
                        if (buttonId != OPEN_BUTTON_ID) {
                                super.buttonPressed(buttonId);
                                return;
                        }
                        ISelection s = getTableViewer().getSelection();
                        if (s instanceof IStructuredSelection) {
                                IStructuredSelection ss = (IStructuredSelection) s;
                                if (ss.getFirstElement() instanceof NonNLSElement)
                                        openWizard(((NonNLSElement) ss.getFirstElement()).cu);
                        }
                }

                private void openWizard(ICompilationUnit unit) {
                        try {
                                if (unit != null && unit.exists()) {
                                        NLSRefactoring refactoring = NLSRefactoring.create(unit);
                                        if (refactoring != null)
                                                new RefactoringStarter().activate(refactoring, new ExternalizeWizard(refactoring), getShell(), ActionMessages.ExternalizeStringsAction_dialog_title, true);
                                }
                        } catch (JavaModelException e) {
                                ExceptionHandler.handle(e, 
                                        ActionMessages.FindStringsToExternalizeAction_dialog_title, 
                                        ActionMessages.FindStringsToExternalizeAction_error_message);
                          }
                }

                private static LabelProvider createLabelProvider() {
                        return new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT) {
                                public String getText(Object element) {
                                        NonNLSElement nlsel = (NonNLSElement) element;
                                        String elementName = ResourceUtil.getResource(nlsel.cu).getFullPath().toString();
                                        return Messages.format(
                                                ActionMessages.FindStringsToExternalizeAction_foundStrings, 
                                                new Object[] {
                                                              new Integer(nlsel.count), elementName
                                                             } );
                                }

                                public Image getImage(Object element) {
                                        return super.getImage(((NonNLSElement) element).cu);
                                }
                               };
                }

                /*
                 * @see org.eclipse.jface.window.Window#configureShell(Shell)
                 */
                protected void configureShell(Shell newShell) {
                        super.configureShell(newShell);
                        PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.NONNLS_DIALOG);
                }
        }

        private static class NonNLSElement {
                ICompilationUnit cu;

                int count;

                NonNLSElement(ICompilationUnit cu, int count) {
                        this.cu = cu;
                        this.count = count;
                }
        }

        private String getDialogTitle() {
                return ActionMessages.FindStringsToExternalizeAction_dialog_title;
        }


Clone Instance
2
Line Count
263
Source Line
195
Source File
plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindStringsToExternalizeAction.java

        private void showResults() {
                if (noStrings())
                        MessageDialog.openInformation(getShell(), getDialogTitle(), ActionMessages.FindStringsToExternalizeAction_noStrings);
                else
                        new NonNLSListDialog(getShell(), fElements, countStrings()).open();
        }

        private boolean noStrings() {
                if (fElements != null) {
                        for (int i = 0; i < fElements.length; i++) {
                                if (fElements[i].count != 0)
                                        return false;
                        }
                }
                return true;
        }

        /*
         * returns List of Strings
         */
        private List analyze(IPackageFragment pack, IProgressMonitor pm) throws CoreException {
                try {
                        if (pack == null)
                                return new ArrayList(0);

                        ICompilationUnit[] cus = pack.getCompilationUnits();

                        pm.beginTask("", cus.length); //$NON-NLS-1$
                        pm.setTaskName(pack.getElementName());

                        List l = new ArrayList(cus.length);
                        for (int i = 0; i < cus.length; i++) {
                                pm.subTask(cus[i].getElementName());
                                NonNLSElement element = analyze(cus[i]);
                                if (element != null)
                                        l.add(element);
                                pm.worked(1);
                                if (pm.isCanceled())
                                        throw new OperationCanceledException();
                        }
                        return l;
                } finally {
                        pm.done();
                  }
        }

        /*
         * returns List of Strings
         */
        private List analyze(IPackageFragmentRoot sourceFolder, IProgressMonitor pm) throws CoreException {
                try {
                        IJavaElement[] children = sourceFolder.getChildren();
                        pm.beginTask("", children.length); //$NON-NLS-1$
                        pm.setTaskName(sourceFolder.getElementName());
                        List result = new ArrayList();
                        for (int i = 0; i < children.length; i++) {
                                IJavaElement iJavaElement = children[i];
                                if (iJavaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
                                        IPackageFragment pack = (IPackageFragment) iJavaElement;
                                        if ( ! pack.isReadOnly())
                                                result.addAll(analyze(pack, new SubProgressMonitor(pm, 1)));
                                        else
                                                pm.worked(1);
                                }
                                else    pm.worked(1);
                        }
                        return result;
                } finally {
                        pm.done();
                  }
        }

        /*
         * returns List of Strings
         */
        private List analyze(IJavaProject project, IProgressMonitor pm) throws CoreException {
                try {
                        IPackageFragment[] packs = project.getPackageFragments();
                        pm.beginTask("", packs.length); //$NON-NLS-1$
                        List result = new ArrayList();
                        for (int i = 0; i < packs.length; i++) {
                                if ( ! packs[i].isReadOnly())
                                        result.addAll(analyze(packs[i], new SubProgressMonitor(pm, 1)));
                                else
                                        pm.worked(1);
                        }
                        return result;
                } finally {
                        pm.done();
                  }
        }

        private int countStrings() {
                int found = 0;
                if (fElements != null) {
                        for (int i = 0; i < fElements.length; i++)
                                found += fElements[i].count;
                }
                return found;
        }

        private NonNLSElement analyze(ICompilationUnit cu) throws CoreException {
                int count = countNonExternalizedStrings(cu);
                if (count == 0)
                        return null;
                else
                        return new NonNLSElement(cu, count);
        }

        private int countNonExternalizedStrings(ICompilationUnit cu) throws CoreException {
                try {
                        NLSLine[] lines = NLSScanner.scan(cu);
                        int result = 0;
                        for (int i = 0; i < lines.length; i++) {
                                result += countNonExternalizedStrings(lines[i]);
                        }
                        return result;
                } catch (InvalidInputException e) {
                        throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.ERROR, 
                                Messages.format(ActionMessages.FindStringsToExternalizeAction_error_cannotBeParsed, cu.getElementName()), 
                                e                         ));
                  }
        }

        private int countNonExternalizedStrings(NLSLine line) {
                int result = 0;
                NLSElement[] elements = line.getElements();
                for (int i = 0; i < elements.length; i++) {
                        if ( ! elements[i].hasTag())
                                result++;
                }
                return result;
        }

        /**
         * returns <code>List</code> of <code>IPackageFragments</code>,  <code>IPackageFragmentRoots</code> or 
         * <code>IJavaProjects</code> (all entries are of the same kind)
         */
        private static List getSelectedElementList(IStructuredSelection selection) {
                if (selection == null)
                        return null;

                return selection.toList();
        }

        //-------private classes --------------

        private static class NonNLSListDialog extends ListDialog {

                private static final int OPEN_BUTTON_ID = IDialogConstants.CLIENT_ID + 1;

                private Button fOpenButton;

                NonNLSListDialog(Shell parent, NonNLSElement[] input, int count) {
                        super(parent);
                        setInput(Arrays.asList(input));
                        setTitle(ActionMessages.FindStringsToExternalizeAction_dialog_title);
                        setMessage(Messages.format(ActionMessages.FindStringsToExternalizeAction_non_externalized, new Object[] {
                                                                                                                                 new Integer(count)
                                                                                                                                } ));
                        setContentProvider(new ArrayContentProvider());
                        setLabelProvider(createLabelProvider());
                }

                public void create() {
                        setShellStyle(SWT.DIALOG_TRIM|  SWT.RESIZE|  SWT.MIN);
                        super.create();
                }

                protected Point getInitialSize() {
                        return getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
                }

                protected Control createDialogArea(Composite parent) {
                        Composite result = (Composite) super.createDialogArea(parent);
                        getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() {
                                public void selectionChanged(SelectionChangedEvent event) {
                                        if (fOpenButton != null) {
                                                fOpenButton.setEnabled( ! getTableViewer().getSelection().isEmpty());
                                        }
                                }
                                                                     } );
                        getTableViewer().getTable().addSelectionListener(new SelectionAdapter() {
                                public void widgetDefaultSelected(SelectionEvent e) {
                                        NonNLSElement element = (NonNLSElement) e.item.getData();
                                        openWizard(element.cu);
                                }
                                                                         } );
                        getTableViewer().getTable().setFocus();
                        applyDialogFont(result);
                        return result;
                }

                protected void createButtonsForButtonBar(Composite parent) {
                        fOpenButton = createButton(parent, OPEN_BUTTON_ID, ActionMessages.FindStringsToExternalizeAction_button_label, true);
                        fOpenButton.setEnabled(false);

                        //looks like a 'close' but it a 'cancel'
                        createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CLOSE_LABEL, false);
                }

                protected void buttonPressed(int buttonId) {
                        if (buttonId != OPEN_BUTTON_ID) {
                                super.buttonPressed(buttonId);
                                return;
                        }
                        ISelection s = getTableViewer().getSelection();
                        if (s instanceof IStructuredSelection) {
                                IStructuredSelection ss = (IStructuredSelection) s;
                                if (ss.getFirstElement() instanceof NonNLSElement)
                                        openWizard(((NonNLSElement) ss.getFirstElement()).cu);
                        }
                }

                private void openWizard(ICompilationUnit unit) {
                        try {
                                if (unit != null && unit.exists()) {
                                        NLSRefactoring refactoring = NLSRefactoring.create(unit);
                                        if (refactoring != null)
                                                new RefactoringStarter().activate(refactoring, new ExternalizeWizard(refactoring), getShell(), ActionMessages.ExternalizeStringsAction_dialog_title, true);
                                }
                        } catch (JavaModelException e) {
                                ExceptionHandler.handle(e, 
                                        ActionMessages.FindStringsToExternalizeAction_dialog_title, 
                                        ActionMessages.FindStringsToExternalizeAction_error_message);
                          }
                }

                private static LabelProvider createLabelProvider() {
                        return new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT) {
                                public String getText(Object element) {
                                        NonNLSElement nlsel = (NonNLSElement) element;
                                        String elementName = ResourceUtil.getResource(nlsel.cu).getFullPath().toString();
                                        return Messages.format(
                                                ActionMessages.FindStringsToExternalizeAction_foundStrings, 
                                                new Object[] {
                                                              new Integer(nlsel.count), elementName
                                                             } );
                                }

                                public Image getImage(Object element) {
                                        return super.getImage(((NonNLSElement) element).cu);
                                }
                               };
                }

                /*
                 * @see org.eclipse.jface.window.Window#configureShell(Shell)
                 */
                protected void configureShell(Shell newShell) {
                        super.configureShell(newShell);
                        PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.NONNLS_DIALOG);
                }
        }

        private static class NonNLSElement {
                ICompilationUnit cu;

                int count;

                NonNLSElement(ICompilationUnit cu, int count) {
                        this.cu = cu;
                        this.count = count;
                }
        }

        private String getDialogTitle() {
                return ActionMessages.FindStringsToExternalizeAction_dialog_title;
        }


Clone AbstractionParameter Count: 1Parameter Bindings

private void showResults() {
  if (noStrings())
    MessageDialog.openInformation(getShell(), getDialogTitle(), ActionMessages.FindStringsToExternalizeAction_noStrings);
  else
    new NonNLSListDialog(getShell(), fElements, countStrings()).open();
}

private boolean noStrings() {
  if (fElements != null) {
    for (int i = 0; i < fElements.length; i++) {
      if (fElements[i].count != 0)
        return false;
    }
  }
  return true;
}

/*
         * returns List of Strings
         */
private List analyze(IPackageFragment pack, IProgressMonitor pm) throws CoreException {
  try {
    if (pack == null)
      return new ArrayList(0);
    ICompilationUnit[] cus = pack.getCompilationUnits();
    pm.beginTask("", cus.length); //$NON-NLS-1$
    pm.setTaskName(pack.getElementName());
    List l = new ArrayList(cus.length);
    for (int i = 0; i < cus.length; i++) {
      pm.subTask(cus[i].getElementName());
      NonNLSElement element = analyze(cus[i]);
      if (element != null)
        l.add(element);
      pm.worked(1);
      if (pm.isCanceled())
        throw new OperationCanceledException();
    }
    return l;
  }
  finally {
    pm.done();
  }
}

/*
         * returns List of Strings
         */
private List analyze(IPackageFragmentRoot sourceFolder, IProgressMonitor pm) throws CoreException {
  try {
    IJavaElement[] children = sourceFolder.getChildren();
    pm.beginTask("", children.length); //$NON-NLS-1$
    pm.setTaskName(sourceFolder.getElementName());
    List result = new ArrayList();
    for (int i = 0; i < children.length; i++) {
      IJavaElement iJavaElement = children[i];
      if (iJavaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
        IPackageFragment pack = (IPackageFragment) iJavaElement;
        if ( !pack.isReadOnly())
          result.addAll(analyze(pack, new SubProgressMonitor(pm, 1)));
        else
          pm.worked(1);
      }
      else
        pm.worked(1);
    }
    return result;
  }
  finally {
    pm.done();
  }
}

/*
         * returns List of Strings
         */
private List analyze(IJavaProject project, IProgressMonitor pm) throws CoreException {
  try {
    IPackageFragment[] packs = project.getPackageFragments();
    pm.beginTask("", packs.length); //$NON-NLS-1$
    List result = new ArrayList();
    for (int i = 0; i < packs.length; i++) {
      if ( !packs[i].isReadOnly())
        result.addAll(analyze(packs[i], new SubProgressMonitor(pm, 1)));
      else
        pm.worked(1);
    }
    return result;
  }
  finally {
    pm.done();
  }
}

private int countStrings() {
  int found = 0;
  if (fElements != null) {
    for (int i = 0; i < fElements.length; i++)
      found += fElements[i].count;
  }
  return found;
}

private NonNLSElement analyze(ICompilationUnit cu) throws CoreException {
  int count = countNonExternalizedStrings(cu);
  if (count == 0)
    return null;
  else
    return new NonNLSElement(cu, count);
}

private int countNonExternalizedStrings(ICompilationUnit cu) throws CoreException {
  try {
    NLSLine[] lines = NLSScanner.scan(cu);
    int result = 0;
    for (int i = 0; i < lines.length; i++) {
      result += countNonExternalizedStrings(lines[i]);
    }
    return result;
  }
  catch (InvalidInputException e) {
    throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.ERROR, Messages.format(ActionMessages.FindStringsToExternalizeAction_error_cannotBeParsed, cu.getElementName()), e));
  }
}

private int countNonExternalizedStrings(NLSLine line) {
  int result = 0;
  NLSElement[] elements = line.getElements();
  for (int i = 0; i < elements.length; i++) {
    if ( !elements[i].hasTag())
      result++;
  }
  return result;
}

/**
         * returns <code>List</code> of <code>IPackageFragments</code>,  <code>IPackageFragmentRoots</code> or 
         * <code>IJavaProjects</code> (all entries are of the same kind)
         */
private static List getSelectedElementList(IStructuredSelection selection) {
  if (selection == null)
    return null;
  return selection.toList();
}

//-------private classes --------------
private static class NonNLSListDialog extends ListDialog {
  private static final int OPEN_BUTTON_ID = IDialogConstants.CLIENT_ID + 1;

  private Button fOpenButton;

  NonNLSListDialog(Shell parent, NonNLSElement[] input, int count) {
    super(parent);
    setInput(Arrays.asList(input));
    setTitle(ActionMessages. [[#variablec14f49c0]]);
    setMessage(Messages.format(ActionMessages.FindStringsToExternalizeAction_non_externalized, new Object[] {
                                                                                                              new Integer(count)
                                                                                                            } ));
    setContentProvider(new ArrayContentProvider());
    setLabelProvider(createLabelProvider());
  }

  public void create() {
    setShellStyle(SWT.DIALOG_TRIM|SWT.RESIZE|SWT.MIN);
    super.create();
  }

  protected Point getInitialSize() {
    return getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
  }

  protected Control createDialogArea(Composite parent) {
    Composite result = (Composite) super.createDialogArea(parent);
    getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() {
                                                   public void selectionChanged(SelectionChangedEvent event) {
                                                     if (fOpenButton != null) {
                                                       fOpenButton.setEnabled( !getTableViewer().getSelection().isEmpty());
                                                     }
                                                   }
                                                 } );
    getTableViewer().getTable().addSelectionListener(new SelectionAdapter() {
                                                       public void widgetDefaultSelected(SelectionEvent e) {
                                                         NonNLSElement element = (NonNLSElement) e.item.getData();
                                                         openWizard(element.cu);
                                                       }
                                                     } );
    getTableViewer().getTable().setFocus();
    applyDialogFont(result);
    return result;
  }

  protected void createButtonsForButtonBar(Composite parent) {
    fOpenButton = createButton(parent, OPEN_BUTTON_ID, ActionMessages.FindStringsToExternalizeAction_button_label, true);
    fOpenButton.setEnabled(false);
    //looks like a 'close' but it a 'cancel'
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CLOSE_LABEL, false);
  }

  protected void buttonPressed(int buttonId) {
    if (buttonId != OPEN_BUTTON_ID) {
      super.buttonPressed(buttonId);
      return;
    }
    ISelection s = getTableViewer().getSelection();
    if (s instanceof IStructuredSelection) {
      IStructuredSelection ss = (IStructuredSelection) s;
      if (ss.getFirstElement() instanceof NonNLSElement)
        openWizard(((NonNLSElement) ss.getFirstElement()).cu);
    }
  }

  private void openWizard(ICompilationUnit unit) {
    try {
      if (unit != null && unit.exists()) {
        NLSRefactoring refactoring = NLSRefactoring.create(unit);
        if (refactoring != null)
          new RefactoringStarter().activate(refactoring, new ExternalizeWizard(refactoring), getShell(), ActionMessages.ExternalizeStringsAction_dialog_title, true);
      }
    }
    catch (JavaModelException e) {
      ExceptionHandler.handle(e, ActionMessages.FindStringsToExternalizeAction_dialog_title, ActionMessages.FindStringsToExternalizeAction_error_message);
    }
  }

  private static LabelProvider createLabelProvider() {
    return new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT) {
             public String getText(Object element) {
               NonNLSElement nlsel = (NonNLSElement) element;
               String elementName = ResourceUtil.getResource(nlsel.cu).getFullPath().toString();
               return Messages.format(ActionMessages.FindStringsToExternalizeAction_foundStrings, new Object[] {
                                                                                                                 new Integer(nlsel.count),
                                                                                                                 elementName
                                                                                                               } );
             }

             public Image getImage(Object element) {
               return super.getImage(((NonNLSElement) element).cu);
             }
           };
  }

  /*
                   * @see org.eclipse.jface.window.Window#configureShell(Shell)
                   */
  protected void configureShell(Shell newShell) {
    super.configureShell(newShell);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.NONNLS_DIALOG);
  }
}

private static class NonNLSElement {
  ICompilationUnit cu;

  int count;

  NonNLSElement(ICompilationUnit cu, int count) {
    this.cu = cu;
    this.count = count;
  }
}

private String getDialogTitle() {
  return ActionMessages.FindStringsToExternalizeAction_dialog_title;
}
 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#c14f49c0]]
ExternalizeStringsAction_dialog_title 
12[[#c14f49c0]]
FindStringsToExternalizeAction_dialog_title