org.eclipse.jdt.ui.JavaElementComparator Java Examples
The following examples show how to use
org.eclipse.jdt.ui.JavaElementComparator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaEditorBreadcrumb.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public void configureDropDownViewer(TreeViewer viewer, Object input) { viewer.setContentProvider(createDropDownContentProvider()); viewer.setLabelProvider(createDropDownLabelProvider()); viewer.setComparator(new JavaElementComparator()); viewer.addFilter(new ViewerFilter() { @Override public boolean select(Viewer viewer1, Object parentElement, Object element) { if (element instanceof IMember) { if (((IMember) element).getElementName().startsWith("<")) { //$NON-NLS-1$ // filter out <clinit> return false; } } return true; } }); if (SHOW_LIBRARIES_NODE) viewer.addFilter(new EmptyLibraryContainerFilter()); JavaUIHelp.setHelp(viewer, IJavaHelpContextIds.JAVA_EDITOR_BREADCRUMB); }
Example #2
Source File: ProjectsWorkbookPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private CPListElement[] addProjectDialog() { try { Object[] selectArr= getNotYetRequiredProjects(); new JavaElementComparator().sort(null, selectArr); ListSelectionDialog dialog= new ListSelectionDialog(getShell(), Arrays.asList(selectArr), new ArrayContentProvider(), new JavaUILabelProvider(), NewWizardMessages.ProjectsWorkbookPage_chooseProjects_message); dialog.setTitle(NewWizardMessages.ProjectsWorkbookPage_chooseProjects_title); dialog.setHelpAvailable(false); if (dialog.open() == Window.OK) { Object[] result= dialog.getResult(); CPListElement[] cpElements= new CPListElement[result.length]; for (int i= 0; i < result.length; i++) { IJavaProject curr= (IJavaProject) result[i]; cpElements[i]= new CPListElement(fCurrJProject, IClasspathEntry.CPE_PROJECT, curr.getPath(), curr.getResource()); } return cpElements; } } catch (JavaModelException e) { return null; } return null; }
Example #3
Source File: ClientBundleResourceSelectionDialog.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private ClientBundleResourceSelectionDialog(Shell shell, IJavaProject javaProject, boolean multiSelection) { super(shell, new JavaElementLabelProvider( JavaElementLabelProvider.SHOW_DEFAULT), new StandardJavaElementContentProvider()); setValidator(new TypedElementSelectionValidator(new Class[] {IFile.class}, multiSelection)); setComparator(new JavaElementComparator()); setTitle("Resource Selection"); String message = MessageFormat.format("Choose {0} to bundle:", (multiSelection ? "one or more resources" : "a resource")); setMessage(message); addFilter(new ViewerFilter(javaProject)); }
Example #4
Source File: ExtractInterfaceWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void addMemberListComposite(Composite result) { Composite composite= new Composite(result, SWT.NONE); GridLayout layout= new GridLayout(); layout.numColumns= 2; layout.marginWidth= 0; layout.marginHeight= 0; composite.setLayout(layout); GridData gd= new GridData(GridData.FILL_BOTH); gd.heightHint= convertHeightInCharsToPixels(12); gd.horizontalSpan= 2; composite.setLayoutData(gd); fTableViewer= CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); fTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); fTableViewer.setLabelProvider(createLabelProvider()); fTableViewer.setContentProvider(new ArrayContentProvider()); try { fTableViewer.setInput(getExtractableMembers()); } catch (JavaModelException e) { ExceptionHandler.handle(e, RefactoringMessages.ExtractInterfaceInputPage_Extract_Interface, RefactoringMessages.ExtractInterfaceInputPage_Internal_Error); fTableViewer.setInput(new IMember[0]); } fTableViewer.addCheckStateListener(new ICheckStateListener(){ public void checkStateChanged(CheckStateChangedEvent event) { ExtractInterfaceInputPage.this.updateUIElementEnablement(); } }); fTableViewer.setComparator(new JavaElementComparator()); fTableViewer.getControl().setEnabled(anyMembersToExtract()); createButtonComposite(composite); }
Example #5
Source File: ReorgUserInputPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private TreeViewer createViewer(Composite parent) { TreeViewer treeViewer= new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); GridData gd= new GridData(GridData.FILL_BOTH); gd.widthHint= convertWidthInCharsToPixels(40); gd.heightHint= convertHeightInCharsToPixels(15); treeViewer.getTree().setLayoutData(gd); treeViewer.setLabelProvider(new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_SMALL_ICONS)); treeViewer.setContentProvider(new DestinationContentProvider(getDestinationValidator())); treeViewer.setComparator(new JavaElementComparator()); treeViewer.setInput(JavaCore.create(ResourcesPlugin.getWorkspace().getRoot())); return treeViewer; }
Example #6
Source File: SourceContainerDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private SourceContainerDialog(Shell shell) { super(shell,new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT),new StandardJavaElementContentProvider()); setValidator(new PackageAndProjectSelectionValidator()); setComparator(new JavaElementComparator()); setTitle(NewWizardMessages.NewContainerWizardPage_ChooseSourceContainerDialog_title); setMessage(NewWizardMessages.NewContainerWizardPage_ChooseSourceContainerDialog_description); addFilter(new JavaTypedViewerFilter()); }
Example #7
Source File: JarManifestWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Creates and returns a dialog to choose an existing workspace file. * @param title the title * @param message the dialog message * @return the dialog */ protected ElementTreeSelectionDialog createWorkspaceFileSelectionDialog(String title, String message) { int labelFlags= JavaElementLabelProvider.SHOW_BASICS | JavaElementLabelProvider.SHOW_OVERLAY_ICONS | JavaElementLabelProvider.SHOW_SMALL_ICONS; final DecoratingLabelProvider provider= new DecoratingLabelProvider(new JavaElementLabelProvider(labelFlags), new ProblemsLabelDecorator(null)); ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), provider, new StandardJavaElementContentProvider()); dialog.setComparator(new JavaElementComparator()); dialog.setAllowMultiple(false); dialog.setValidator(new ISelectionStatusValidator() { public IStatus validate(Object[] selection) { StatusInfo res= new StatusInfo(); // only single selection if (selection.length == 1 && (selection[0] instanceof IFile)) res.setOK(); else res.setError(""); //$NON-NLS-1$ return res; } }); dialog.addFilter(new EmptyInnerPackageFilter()); dialog.addFilter(new LibraryFilter()); dialog.setTitle(title); dialog.setMessage(message); dialog.setStatusLineAboveButtons(true); dialog.setInput(JavaCore.create(JavaPlugin.getWorkspace().getRoot())); return dialog; }
Example #8
Source File: PackageExplorerPart.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void setComparator() { if (getRootMode() == WORKING_SETS_AS_ROOTS) { fViewer.setComparator(new WorkingSetAwareJavaElementSorter()); } else { fViewer.setComparator(new JavaElementComparator()); } }
Example #9
Source File: JavadocTreeWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void createInputGroup(Composite composite) { createLabel(composite, SWT.NONE, JavadocExportMessages.JavadocTreeWizardPage_checkboxtreeandlistgroup_label, createGridData(6)); Composite c= new Composite(composite, SWT.NONE); GridLayout layout= new GridLayout(); layout.numColumns= 1; layout.makeColumnsEqualWidth= true; layout.marginWidth= 0; layout.marginHeight= 0; c.setLayout(layout); c.setLayoutData(createGridData(GridData.FILL_BOTH, 6, 0)); ITreeContentProvider treeContentProvider= new JavadocProjectContentProvider(); ITreeContentProvider listContentProvider= new JavadocMemberContentProvider(); fInputGroup= new CheckboxTreeAndListGroup(c, this, treeContentProvider, new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT), listContentProvider, new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT), SWT.NONE, convertWidthInCharsToPixels(60), convertHeightInCharsToPixels(7)); fInputGroup.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent e) { doValidation(TREESTATUS); } }); fInputGroup.setTreeComparator(new JavaElementComparator()); SWTUtil.setAccessibilityText(fInputGroup.getTree(), JavadocExportMessages.JavadocTreeWizardPage_tree_accessibility_message); SWTUtil.setAccessibilityText(fInputGroup.getTable(), JavadocExportMessages.JavadocTreeWizardPage_table_accessibility_message); IJavaElement[] elements= fStore.getInitialElements(); setTreeChecked(elements); if (elements.length > 0) { fInputGroup.setTreeSelection(new StructuredSelection(elements[0].getJavaProject())); } fInputGroup.aboutToOpen(); }
Example #10
Source File: JavaWorkingSetPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void configureTree(TreeViewer tree) { tree.setContentProvider(new JavaWorkingSetPageContentProvider()); AppearanceAwareLabelProvider javaElementLabelProvider= new AppearanceAwareLabelProvider( AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaElementLabels.P_COMPRESSED, AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | JavaElementImageProvider.SMALL_ICONS ); tree.setLabelProvider(new DecoratingJavaLabelProvider(javaElementLabelProvider)); tree.setComparator(new JavaElementComparator()); tree.addFilter(new EmptyInnerPackageFilter()); tree.setInput(JavaCore.create(ResourcesPlugin.getWorkspace().getRoot())); if (getSelection() == null) return; Object[] selection= getInitialTreeSelection(); if (selection.length > 0) { try { tree.getTree().setRedraw(false); for (int i= 0; i < selection.length; i++) { tree.expandToLevel(selection[i], 0); } tree.setSelection(new StructuredSelection(selection)); } finally { tree.getTree().setRedraw(true); } } }
Example #11
Source File: JavaWorkingSetPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void configureTable(TableViewer table) { AppearanceAwareLabelProvider javaElementLabelProvider= new AppearanceAwareLabelProvider( AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaElementLabels.P_COMPRESSED | JavaElementLabels.ROOT_POST_QUALIFIED | JavaElementLabels.P_POST_QUALIFIED, AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | JavaElementImageProvider.SMALL_ICONS ); table.setLabelProvider(new DecoratingJavaLabelProvider(javaElementLabelProvider)); table.setComparator(new JavaElementComparator()); }
Example #12
Source File: IDEClassPathBlock.java From birt with Eclipse Public License 1.0 | 5 votes |
private IDECPListElement[] addProjectDialog( ) { try { Object[] selectArr = getNotYetRequiredProjects( ); new JavaElementComparator( ).sort( null, selectArr ); ListSelectionDialog dialog = new ListSelectionDialog( getShell( ), Arrays.asList( selectArr ), new ArrayContentProvider( ), new ProjectLabelProvider( ), Messages.getString("IDEClassPathBlock.ProjectDialog_message") ); //$NON-NLS-1$ dialog.setTitle( Messages.getString("IDEClassPathBlock.ProjectDialog_title") ); //$NON-NLS-1$ dialog.setHelpAvailable( false ); if ( dialog.open( ) == Window.OK ) { Object[] result = dialog.getResult( ); IDECPListElement[] cpElements = new IDECPListElement[result.length]; for ( int i = 0; i < result.length; i++ ) { IJavaProject curr = ( (IJavaProject) result[i] ); cpElements[i] = new IDECPListElement( IClasspathEntry.CPE_PROJECT, curr.getPath( ), curr.getResource( ) ); } return cpElements; } } catch ( JavaModelException e ) { return null; } return null; }
Example #13
Source File: AddGetterSetterAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void run(IType type, IField[] preselected, boolean editor) throws CoreException { if (type.isAnnotation()) { MessageDialog.openInformation(getShell(), DIALOG_TITLE, ActionMessages.AddGetterSetterAction_annotation_not_applicable); notifyResult(false); return; } else if (type.isInterface()) { MessageDialog.openInformation(getShell(), DIALOG_TITLE, ActionMessages.AddGetterSetterAction_interface_not_applicable); notifyResult(false); return; } else if (type.getCompilationUnit() == null) { MessageDialog.openInformation(getShell(), DIALOG_TITLE, ActionMessages.AddGetterSetterAction_error_not_in_source_file); notifyResult(false); return; } if (!ElementValidator.check(type, getShell(), DIALOG_TITLE, editor)) { notifyResult(false); return; } if (!ActionUtil.isEditable(getShell(), type)) { notifyResult(false); return; } ILabelProvider lp= new AddGetterSetterLabelProvider(); resetNumEntries(); Map<IField, GetterSetterEntry[]> entries= createGetterSetterMapping(type); if (entries.isEmpty()) { MessageDialog.openInformation(getShell(), DIALOG_TITLE, ActionMessages.AddGettSetterAction_typeContainsNoFields_message); notifyResult(false); return; } AddGetterSetterContentProvider cp= new AddGetterSetterContentProvider(entries); GetterSetterTreeSelectionDialog dialog= new GetterSetterTreeSelectionDialog(getShell(), lp, cp, fEditor, type); dialog.setComparator(new JavaElementComparator()); dialog.setTitle(DIALOG_TITLE); String message= ActionMessages.AddGetterSetterAction_dialog_label; dialog.setMessage(message); dialog.setValidator(createValidator(fNumEntries)); dialog.setContainerMode(true); dialog.setSize(60, 18); dialog.setInput(type); if (preselected.length > 0) { dialog.setInitialSelections(preselected); dialog.setExpandedElements(preselected); } final Set<IField> keySet= new LinkedHashSet<IField>(entries.keySet()); int dialogResult= dialog.open(); if (dialogResult == Window.OK) { Object[] result= dialog.getResult(); if (result == null) { notifyResult(false); return; } fSort= dialog.getSortOrder(); fSynchronized= dialog.getSynchronized(); fFinal= dialog.getFinal(); fVisibility= dialog.getVisibilityModifier(); fGenerateComment= dialog.getGenerateComment(); IField[] getterFields, setterFields, getterSetterFields; if (fSort) { getterFields= getGetterFields(result, keySet); setterFields= getSetterFields(result, keySet); getterSetterFields= new IField[0]; } else { getterFields= getGetterOnlyFields(result, keySet); setterFields= getSetterOnlyFields(result, keySet); getterSetterFields= getGetterSetterFields(result, keySet); } generate(type, getterFields, setterFields, getterSetterFields, new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(type.getCompilationUnit(), true), dialog.getElementPosition()); } notifyResult(dialogResult == Window.OK); }
Example #14
Source File: JarManifestWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Creates a selection dialog that lists all packages under the given package * fragment root. * The caller is responsible for opening the dialog with <code>Window.open</code>, * and subsequently extracting the selected packages (of type * <code>IPackageFragment</code>) via <code>SelectionDialog.getResult</code>. * * @param packageFragments the package fragments * @return a new selection dialog */ protected SelectionDialog createPackageDialog(Set<IJavaElement> packageFragments) { List<IPackageFragment> packages= new ArrayList<IPackageFragment>(packageFragments.size()); for (Iterator<IJavaElement> iter= packageFragments.iterator(); iter.hasNext();) { IPackageFragment fragment= (IPackageFragment)iter.next(); boolean containsJavaElements= false; int kind; try { kind= fragment.getKind(); containsJavaElements= fragment.getChildren().length > 0; } catch (JavaModelException ex) { ExceptionHandler.handle(ex, getContainer().getShell(), JarPackagerMessages.JarManifestWizardPage_error_jarPackageWizardError_title, Messages.format(JarPackagerMessages.JarManifestWizardPage_error_jarPackageWizardError_message, JavaElementLabels.getElementLabel(fragment, JavaElementLabels.ALL_DEFAULT))); continue; } if (kind != IPackageFragmentRoot.K_BINARY && containsJavaElements) packages.add(fragment); } StandardJavaElementContentProvider cp= new StandardJavaElementContentProvider() { @Override public boolean hasChildren(Object element) { // prevent the + from being shown in front of packages return !(element instanceof IPackageFragment) && super.hasChildren(element); } }; final DecoratingLabelProvider provider= new DecoratingLabelProvider(new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT), new ProblemsLabelDecorator(null)); ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getContainer().getShell(), provider, cp); dialog.setDoubleClickSelects(false); dialog.setComparator(new JavaElementComparator()); dialog.setInput(JavaCore.create(JavaPlugin.getWorkspace().getRoot())); dialog.addFilter(new EmptyInnerPackageFilter()); dialog.addFilter(new LibraryFilter()); dialog.addFilter(new SealPackagesFilter(packages)); dialog.setValidator(new ISelectionStatusValidator() { public IStatus validate(Object[] selection) { StatusInfo res= new StatusInfo(); for (int i= 0; i < selection.length; i++) { if (!(selection[i] instanceof IPackageFragment)) { res.setError(JarPackagerMessages.JarManifestWizardPage_error_mustContainPackages); return res; } } res.setOK(); return res; } }); return dialog; }
Example #15
Source File: AbstractHierarchyViewerSorter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public AbstractHierarchyViewerSorter() { fNormalSorter= new JavaElementComparator(); fSourcePositonSorter= new SourcePositionComparator(); }
Example #16
Source File: JavaBrowsingPart.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
protected JavaElementComparator createJavaElementComparator() { return new JavaElementComparator(); }