List of usage examples for org.eclipse.jface.util Policy getComparator
public static Comparator<Object> getComparator()
From source file:eu.artist.migration.modernization.uml2java.repackaged.gen.java.ui.launch.tabs.UML2JavaGeneralLaunchConfigurationTab.java
License:Open Source License
/** * Creates the group containing the Java options of the generation. * /* w w w . j a v a 2s. c om*/ * @param composite * the composite containing the group * @param font * The font used by the parent of the group */ private void createJavaGroup(Composite composite, Font font) { GridData gd; Group javaGroup = createGroup(composite, UML2JavaMessages.getString("UML2JavaGeneralLaunchConfigurationTab.JavaGroupName"), 3, 1, GridData.FILL_HORIZONTAL); Composite comp = new Composite(javaGroup, SWT.NONE); GridLayout layout = new GridLayout(3, false); layout.marginWidth = 0; layout.marginHeight = 0; comp.setLayout(layout); comp.setFont(font); gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 2; comp.setLayoutData(gd); // Default project name Label defaultProjectNameLabel = new Label(comp, SWT.NONE); defaultProjectNameLabel.setText( UML2JavaMessages.getString("UML2JavaGeneralLaunchConfigurationTab.DefaultProjectNameLabel")); this.defaultProjectNameText = new Text(comp, SWT.SINGLE | SWT.BORDER); this.defaultProjectNameText.setFont(composite.getFont()); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 1; this.defaultProjectNameText.setLayoutData(gd); this.defaultProjectNameText.setText(IUML2JavaConstants.Default.DEFAULT_DEFAULT_PROJECT_NAME); this.defaultProjectNameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { update(); } }); createHelpButton(comp, UML2JavaMessages.getString("UML2JavaGeneralLaunchConfigurationTab.DefaultProjectNameHelp")); // Source folder path Label sourceFolderPathLabel = new Label(comp, SWT.NONE); sourceFolderPathLabel .setText(UML2JavaMessages.getString("UML2JavaGeneralLaunchConfigurationTab.SourceFolderPathLabel")); this.sourceFolderPathText = new Text(comp, SWT.SINGLE | SWT.BORDER); this.sourceFolderPathText.setFont(composite.getFont()); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 1; this.sourceFolderPathText.setLayoutData(gd); this.sourceFolderPathText.setText(IUML2JavaConstants.Default.DEFAULT_SOURCE_FOLDER_PATH); this.sourceFolderPathText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { update(); } }); createHelpButton(comp, UML2JavaMessages.getString("UML2JavaGeneralLaunchConfigurationTab.SourceFolderPathHelp")); // Output folder path Label outputFolderPathLabel = new Label(comp, SWT.NONE); outputFolderPathLabel .setText(UML2JavaMessages.getString("UML2JavaGeneralLaunchConfigurationTab.OutputFolderPathLabel")); this.outputFolderPathText = new Text(comp, SWT.SINGLE | SWT.BORDER); this.outputFolderPathText.setFont(composite.getFont()); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 1; this.outputFolderPathText.setLayoutData(gd); this.outputFolderPathText.setText(IUML2JavaConstants.Default.DEFAULT_OUTPUT_FOLDER_PATH); this.outputFolderPathText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { update(); } }); createHelpButton(comp, UML2JavaMessages.getString("UML2JavaGeneralLaunchConfigurationTab.OutputFolderPathHelp")); // JRE Selection Label jreExecutionEnvironmentLabel = new Label(comp, SWT.NONE); jreExecutionEnvironmentLabel.setText( UML2JavaMessages.getString("UML2JavaGeneralLaunchConfigurationTab.JREExecutionEnvironmentLabel")); executionEnvJRECombo = new Combo(comp, SWT.READ_ONLY); executionEnvJRECombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); String selectedItem = this.getLastSelectedEE(); int selectionIndex = executionEnvJRECombo.getSelectionIndex(); IExecutionEnvironment[] fInstalledEEs = JavaRuntime.getExecutionEnvironmentsManager() .getExecutionEnvironments(); Arrays.sort(fInstalledEEs, new Comparator<IExecutionEnvironment>() { @SuppressWarnings("unchecked") public int compare(IExecutionEnvironment arg0, IExecutionEnvironment arg1) { return Policy.getComparator().compare(arg0.getId(), arg1.getId()); } }); // find new index selectionIndex = -1; String[] eeLabels = new String[fInstalledEEs.length]; String[] fEECompliance = new String[fInstalledEEs.length]; for (int i = 0; i < fInstalledEEs.length; i++) { eeLabels[i] = fInstalledEEs[i].getId(); if (selectedItem != null && eeLabels[i].equals(selectedItem)) { selectionIndex = i; } fEECompliance[i] = JavaModelUtil.getExecutionEnvironmentCompliance(fInstalledEEs[i]); } executionEnvJRECombo.setItems(eeLabels); if (selectionIndex == -1) { executionEnvJRECombo.setText(getDefaultEEName()); } else { executionEnvJRECombo.setText(selectedItem); } executionEnvJRECombo.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { update(); } }); executionEnvJRECombo.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { update(); } public void widgetDefaultSelected(SelectionEvent e) { update(); } }); createHelpButton(comp, UML2JavaMessages.getString("UML2JavaGeneralLaunchConfigurationTab.JREExecutionEnvironmentHelp")); }
From source file:net.rim.ejde.internal.ui.wizards.JRESelectionUI.java
License:Open Source License
private void fillInstalledJREs(ComboDialogField comboField) { String selectedItem = getLastSelectedJRE(); int selectionIndex = -1; if (_useProjectRE.isSelected()) { selectionIndex = comboField.getSelectionIndex(); if (selectionIndex != -1) {// paranoia selectedItem = comboField.getItems()[selectionIndex]; }/* w w w. j a v a2 s.c o m*/ } List<IVMInstall> standins = VMUtils.getInstalledBBVMs(); _installedVMs = (standins.toArray(new IVMInstall[standins.size()])); Arrays.sort(_installedVMs, new Comparator<IVMInstall>() { public int compare(IVMInstall arg0, IVMInstall arg1) { String cc0, cc1; if (arg1 instanceof IVMInstall2 && arg0 instanceof IVMInstall2) { cc0 = JavaModelUtil.getCompilerCompliance((IVMInstall2) arg0, JavaCore.VERSION_1_4); cc1 = JavaModelUtil.getCompilerCompliance((IVMInstall2) arg1, JavaCore.VERSION_1_4); int result = cc1.compareTo(cc0); if (result != 0) return result; } return Policy.getComparator().compare(arg0.getName(), arg1.getName()); } }); selectionIndex = -1;// find new index String[] jreLabels = new String[_installedVMs.length]; _RECompliance = new String[_installedVMs.length]; for (int i = 0; i < _installedVMs.length; i++) { jreLabels[i] = _installedVMs[i].getName(); if (selectedItem != null && jreLabels[i].equals(selectedItem)) { selectionIndex = i; } if (_installedVMs[i] instanceof IVMInstall2) { _RECompliance[i] = JavaModelUtil.getCompilerCompliance((IVMInstall2) _installedVMs[i], JavaCore.VERSION_1_4); } else { _RECompliance[i] = JavaCore.VERSION_1_4; } } // don't fire event when setting combobox items. _fireEvent = false; comboField.setItems(jreLabels); if (selectionIndex == -1) { comboField.selectItem(getDefaultBBJRE()); } else { comboField.selectItem(selectedItem); } _fireEvent = true; }
From source file:org.eclipse.acceleo.internal.ide.ui.wizards.project.AcceleoProjectPage.java
License:Open Source License
/** * Fill the project specific combo.//from w w w. j a v a 2s . c o m */ private void fillInstalledJREs() { String selectedItem = getLastSelectedJRE(); int selectionIndex = -1; if (projectSpecificJREButton.getSelection()) { selectionIndex = projectSpecificJRECombo.getSelectionIndex(); // paranoia if (selectionIndex != -1) { selectedItem = projectSpecificJRECombo.getItems()[selectionIndex]; } } fInstalledJVMs = getWorkspaceJREs(); Arrays.sort(fInstalledJVMs, new Comparator<IVMInstall>() { @SuppressWarnings("unchecked") public int compare(IVMInstall i0, IVMInstall i1) { if (i1 instanceof IVMInstall2 && i0 instanceof IVMInstall2) { String cc0 = JavaModelUtil.getCompilerCompliance((IVMInstall2) i0, JavaCore.VERSION_1_4); String cc1 = JavaModelUtil.getCompilerCompliance((IVMInstall2) i1, JavaCore.VERSION_1_4); int result = cc1.compareTo(cc0); if (result != 0) { return result; } } return Policy.getComparator().compare(i0.getName(), i1.getName()); } }); // find new index selectionIndex = -1; String[] jreLabels = new String[fInstalledJVMs.length]; fJRECompliance = new String[fInstalledJVMs.length]; for (int i = 0; i < fInstalledJVMs.length; i++) { jreLabels[i] = fInstalledJVMs[i].getName(); if (selectedItem != null && jreLabels[i].equals(selectedItem)) { selectionIndex = i; } if (fInstalledJVMs[i] instanceof IVMInstall2) { fJRECompliance[i] = JavaModelUtil.getCompilerCompliance((IVMInstall2) fInstalledJVMs[i], JavaCore.VERSION_1_4); } else { fJRECompliance[i] = JavaCore.VERSION_1_4; } } projectSpecificJRECombo.setItems(jreLabels); if (selectionIndex == -1) { projectSpecificJRECombo.setText(getDefaultJVMName()); } else { projectSpecificJRECombo.setText(selectedItem); } }
From source file:org.eclipse.acceleo.internal.ide.ui.wizards.project.AcceleoProjectPage.java
License:Open Source License
/** * Fills the execution environments./* w ww.j a v a2s. c o m*/ */ private void fillExecutionEnvironments() { String selectedItem = getLastSelectedEE(); int selectionIndex = -1; if (executionEnvJREButton.getSelection()) { selectionIndex = executionEnvJRECombo.getSelectionIndex(); // paranoia if (selectionIndex != -1) { selectedItem = executionEnvJRECombo.getItems()[selectionIndex]; } } fInstalledEEs = JavaRuntime.getExecutionEnvironmentsManager().getExecutionEnvironments(); Arrays.sort(fInstalledEEs, new Comparator<IExecutionEnvironment>() { @SuppressWarnings("unchecked") public int compare(IExecutionEnvironment arg0, IExecutionEnvironment arg1) { return Policy.getComparator().compare(arg0.getId(), arg1.getId()); } }); // find new index selectionIndex = -1; String[] eeLabels = new String[fInstalledEEs.length]; fEECompliance = new String[fInstalledEEs.length]; for (int i = 0; i < fInstalledEEs.length; i++) { eeLabels[i] = fInstalledEEs[i].getId(); if (selectedItem != null && eeLabels[i].equals(selectedItem)) { selectionIndex = i; } fEECompliance[i] = JavaModelUtil.getExecutionEnvironmentCompliance(fInstalledEEs[i]); } executionEnvJRECombo.setItems(eeLabels); if (selectionIndex == -1) { executionEnvJRECombo.setText(getDefaultEEName()); } else { executionEnvJRECombo.setText(selectedItem); } }
From source file:org.eclipse.compare.internal.patch.DiffViewerComparator.java
License:Open Source License
protected Comparator getComparator() { return new Comparator() { public int compare(Object arg0, Object arg1) { String label0 = arg0 == null ? "" : arg0.toString(); //$NON-NLS-1$ String label1 = arg1 == null ? "" : arg1.toString(); //$NON-NLS-1$ // see org.eclipse.compare.internal.patch.Hunk.getDescription() String pattern = "\\d+,\\d+ -> \\d+,\\d+.*"; //$NON-NLS-1$ if (Pattern.matches(pattern, label0) && Pattern.matches(pattern, label1)) { int oldStart0 = Integer.parseInt(label0.split(",")[0]); //$NON-NLS-1$ int oldStart1 = Integer.parseInt(label1.split(",")[0]); //$NON-NLS-1$ return oldStart0 - oldStart1; }// w ww. j a va 2 s.com return Policy.getComparator().compare(arg0, arg1); } }; }
From source file:org.eclipse.pde.internal.runtime.logview.LogView.java
License:Open Source License
private Comparator getDefaultComparator() { return Policy.getComparator(); }
From source file:org.eclipse.php.internal.ui.util.TableSorter.java
License:Open Source License
protected Comparator<Object> getComparator() { if (fComparator == null) { fComparator = Policy.getComparator(); } return fComparator; }
From source file:org.eclipse.ui.model.ContributionComparator.java
License:Open Source License
/** * This implementation of {@link Comparator#compare(Object, Object)} does a * blind cast on each element to {@link IComparableContribution}. *///from w w w. j a va 2 s . co m public int compare(Object o1, Object o2) { IComparableContribution c1 = null, c2 = null; if (o1 instanceof IComparableContribution) c1 = (IComparableContribution) o1; if (o2 instanceof IComparableContribution) c2 = (IComparableContribution) o2; // neither are comparable contributions, we need to be consistent if (c1 == null && c2 == null) { String s1 = getComparisonString(o1); String s2 = getComparisonString(o2); return Policy.getComparator().compare(s1, s2); } // if we're in a mixed scenario the comparable contribution wins. if (c1 == null) return 1; if (c2 == null) return -1; return compare(c1, c2); }
From source file:org.eclipse.ui.model.ContributionComparator.java
License:Open Source License
/** * Returns a negative, zero, or positive number depending on whether the * first element is less than, equal to, or greater than the second element. * <p>//from ww w.j a v a2 s. c om * The default implementation of this method is based on comparing the * elements' categories as computed by the <code>category</code> framework * method. Elements within the same category are further subjected to a case * insensitive compare of their label strings. Subclasses may override. * </p> * * @param c1 * the first element * @param c2 * the second element * @return a negative number if the first element is less than the second * element; the value <code>0</code> if the first element is equal * to the second element; and a positive number if the first element * is greater than the second element */ public int compare(IComparableContribution c1, IComparableContribution c2) { int cat1 = category(c1); int cat2 = category(c2); if (cat1 != cat2) { return cat1 - cat2; } String name1 = c1.getLabel(); String name2 = c2.getLabel(); if (name1 == null) { name1 = "";//$NON-NLS-1$ } if (name2 == null) { name2 = "";//$NON-NLS-1$ } // use the comparator to compare the strings return Policy.getComparator().compare(name1, name2); }
From source file:org.eclipse.xtext.xtext.ui.wizard.project.WizardNewXtextProjectCreationPage.java
License:Open Source License
protected void fillBreeCombo(Combo comboToFill) { Set<String> brees = Sets.newHashSet(JREContainerProvider.getDefaultBREE()); Set<String> availableBrees = Sets.newHashSet(); for (IExecutionEnvironment ee : JavaRuntime.getExecutionEnvironmentsManager().getExecutionEnvironments()) { availableBrees.add(ee.getId());/*from w w w . j ava 2 s .c o m*/ } for (JavaVersion supportedVersion : JavaVersion.values()) { if (supportedVersion.isAtLeast(JavaVersion.JAVA6)) { String bree = supportedVersion.getBree(); if (availableBrees.contains(bree)) brees.add(bree); } } String[] array = brees.toArray(new String[] {}); Arrays.sort(array, Policy.getComparator()); String selectionMemento = comboToFill.getText(); comboToFill.setItems(array); int index = comboToFill.indexOf(selectionMemento); if (index < 0) { comboToFill.select(comboToFill.indexOf(JREContainerProvider.getDefaultBREE())); } comboToFill.select(index); }