本文整理匯總了Java中org.eclipse.ui.dialogs.ElementTreeSelectionDialog.setComparator方法的典型用法代碼示例。如果您正苦於以下問題:Java ElementTreeSelectionDialog.setComparator方法的具體用法?Java ElementTreeSelectionDialog.setComparator怎麽用?Java ElementTreeSelectionDialog.setComparator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.ui.dialogs.ElementTreeSelectionDialog
的用法示例。
在下文中一共展示了ElementTreeSelectionDialog.setComparator方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: chooseWorkspace
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
protected void chooseWorkspace ()
{
final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog ( getShell (), new WorkbenchLabelProvider (), new WorkbenchContentProvider () );
dialog.setTitle ( "Select driver exporter configuration file" );
dialog.setMessage ( "Choose a driver exporter file for the configuration" );
dialog.setInput ( ResourcesPlugin.getWorkspace ().getRoot () );
dialog.setComparator ( new ResourceComparator ( ResourceComparator.NAME ) );
dialog.setAllowMultiple ( true );
dialog.setDialogBoundsSettings ( getDialogBoundsSettings ( HiveTab.WORKSPACE_SELECTION_DIALOG ), Dialog.DIALOG_PERSISTSIZE );
if ( dialog.open () == IDialogConstants.OK_ID )
{
final IResource resource = (IResource)dialog.getFirstResult ();
if ( resource != null )
{
final String arg = resource.getFullPath ().toString ();
final String fileLoc = VariablesPlugin.getDefault ().getStringVariableManager ().generateVariableExpression ( "workspace_loc", arg ); //$NON-NLS-1$
this.fileText.setText ( fileLoc );
makeDirty ();
}
}
}
示例2: chooseWorkspaceDirectory
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
private String chooseWorkspaceDirectory(String prompt) {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
new WorkbenchContentProvider());
dialog.setTitle("Selecting directory");
dialog.setMessage(prompt);
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == IDialogConstants.OK_ID) {
IResource resource = (IResource)dialog.getFirstResult();
if (resource != null) {
String path = resource.getFullPath().toString();
String fileLoc = VariablesPlugin.getDefault().getStringVariableManager()
.generateVariableExpression("workspace_loc", path);
return fileLoc;
}
}
return null;
}
示例3: handleManifestfileBrowse
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
/**
* Uses the standard container selection dialog to choose the new value for
* the container field.
*/
private void handleManifestfileBrowse() {
String manifestFilename = getManifestfile();
ILabelProvider lp = new WorkbenchLabelProvider();
ITreeContentProvider cp = new WorkbenchContentProvider();
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
dialog.setValidator(null);
dialog.setAllowMultiple(false);
dialog.setTitle("Select Manifest File"); //$NON-NLS-1$
// dialog.setMessage("msg?"); //$NON-NLS-1$
// dialog.addFilter(filter);
// dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.setInput(jproject.getProject());
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == ElementTreeSelectionDialog.OK) {
Object[] elements = dialog.getResult();
if (elements.length == 1) {
manifestFilename = ((IResource) elements[0]).getFullPath().toOSString();
int n = manifestFilename.indexOf(File.separatorChar, 1);
if (n != -1)
manifestFilename = manifestFilename.substring(n + 1);
manifestfileText.setText(manifestFilename);
}
}
}
示例4: selectWorkspaceDir
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
private String selectWorkspaceDir() {
String result = null;
ILabelProvider lp = new WorkbenchLabelProvider();
ITreeContentProvider cp = new WorkbenchContentProvider();
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
getShell(), lp, cp);
dialog.setValidator(null);
dialog.setAllowMultiple(false);
dialog.setTitle("Select base directory to add"); //$NON-NLS-1$
dialog.setMessage("msg?"); //$NON-NLS-1$
ViewerFilter filter = new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement,
Object element) {
boolean ok = (element instanceof Folder)
|| (element instanceof Project);
return ok;
}
};
dialog.addFilter(filter);
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == ElementTreeSelectionDialog.OK) {
Object[] elements = dialog.getResult();
if (elements.length == 1) {
result = ((IResource) elements[0]).getFullPath().toOSString();
}
}
return result;
}
示例5: handleManifestfileBrowse
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
/**
* Uses the standard container selection dialog to
* choose the new value for the container field.
*/
private void handleManifestfileBrowse() {
String manifestFilename = getManifestfile();
ILabelProvider lp= new WorkbenchLabelProvider();
ITreeContentProvider cp= new WorkbenchContentProvider();
ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(
getShell(), lp, cp);
dialog.setValidator(null);
dialog.setAllowMultiple(false);
dialog.setTitle("Select Manifest File"); //$NON-NLS-1$
// dialog.setMessage("msg?"); //$NON-NLS-1$
//dialog.addFilter(filter);
// dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
//TODO: Validate Input, Make project list IAdaptable
// dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.setInput(jproject.getProject());
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == ElementTreeSelectionDialog.OK) {
Object[] elements= dialog.getResult();
if (elements.length == 1) {
manifestFilename = ((IResource)elements[0]).getLocation().toOSString();
// int n = manifestFilename.indexOf(File.separatorChar,1);
// if (n!=-1)
// manifestFilename = manifestFilename.substring(n+1);
manifestfileText.setText(manifestFilename);
}
}
}
示例6: selectWorkspaceDir
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
private String selectWorkspaceDir() {
String result = null;
ILabelProvider lp= new WorkbenchLabelProvider();
ITreeContentProvider cp= new WorkbenchContentProvider();
ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(
getShell(), lp, cp);
dialog.setValidator(null);
dialog.setAllowMultiple(false);
dialog.setTitle("Select base directory to add"); //$NON-NLS-1$
dialog.setMessage("msg?"); //$NON-NLS-1$
ViewerFilter filter = new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) {
boolean ok = (element instanceof Folder) || (element instanceof Project);
return ok;
}
};
dialog.addFilter(filter);
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == ElementTreeSelectionDialog.OK) {
Object[] elements= dialog.getResult();
if (elements.length == 1) {
result = ((IResource)elements[0]).getFullPath().toOSString();
}
}
return result;
}
示例7: createWorkspaceFileSelectionDialog
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
/**
* 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;
}
示例8: chooseInternal
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
private String chooseInternal() {
String initSelection= fPathField.getText();
ILabelProvider lp= new WorkbenchLabelProvider();
ITreeContentProvider cp= new WorkbenchContentProvider();
Class<?>[] acceptedClasses= new Class[] { IProject.class, IFolder.class };
TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, true);
ViewerFilter filter= new TypedViewerFilter(acceptedClasses);
IResource initSel= null;
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
if (initSelection.length() > 0) {
initSel= root.findMember(new Path(initSelection));
}
if (initSel == null) {
initSel= root.findMember(fEntry.getPath());
}
ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(fShell, lp, cp);
dialog.setAllowMultiple(false);
dialog.setValidator(validator);
dialog.addFilter(filter);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
dialog.setTitle(NewWizardMessages.NativeLibrariesDialog_intfiledialog_title);
dialog.setMessage(NewWizardMessages.NativeLibrariesDialog_intfiledialog_message);
dialog.setInput(root);
dialog.setInitialSelection(initSel);
dialog.setHelpAvailable(false);
if (dialog.open() == Window.OK) {
IResource res= (IResource) dialog.getFirstResult();
return res.getFullPath().makeRelative().toString();
}
return null;
}
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:35,代碼來源:NativeLibrariesConfigurationBlock.java
示例9: chooseFolder
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
private IFolder chooseFolder(String title, String message, IPath initialPath) {
Class<?>[] acceptedClasses= new Class[] { IFolder.class };
ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
ViewerFilter filter= new TypedViewerFilter(acceptedClasses, null);
ILabelProvider lp= new WorkbenchLabelProvider();
ITreeContentProvider cp= new WorkbenchContentProvider();
IProject currProject= fCurrJProject.getProject();
ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp);
dialog.setValidator(validator);
dialog.setTitle(title);
dialog.setMessage(message);
dialog.addFilter(filter);
dialog.setInput(currProject);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
IResource res= currProject.findMember(initialPath);
if (res != null) {
dialog.setInitialSelection(res);
}
if (dialog.open() == Window.OK) {
return (IFolder) dialog.getFirstResult();
}
return null;
}
示例10: chooseFolder
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
private IFolder chooseFolder(String title, String message, IPath initialPath) {
Class<?>[] acceptedClasses= new Class[] { IFolder.class };
ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
ViewerFilter filter= new TypedViewerFilter(acceptedClasses, null);
ILabelProvider lp= new WorkbenchLabelProvider();
ITreeContentProvider cp= new WorkbenchContentProvider();
IProject currProject= fNewElement.getJavaProject().getProject();
ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp) {
@Override
protected Control createDialogArea(Composite parent) {
Control result= super.createDialogArea(parent);
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IJavaHelpContextIds.BP_CHOOSE_EXISTING_FOLDER_TO_MAKE_SOURCE_FOLDER);
return result;
}
};
dialog.setValidator(validator);
dialog.setTitle(title);
dialog.setMessage(message);
dialog.addFilter(filter);
dialog.setInput(currProject);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
IResource res= currProject.findMember(initialPath);
if (res != null) {
dialog.setInitialSelection(res);
}
if (dialog.open() == Window.OK) {
return (IFolder) dialog.getFirstResult();
}
return null;
}
示例11: openProgramPathDialog
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
public static String openProgramPathDialog(IProject project, Button button) throws OperationCancellation {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
button.getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setTitle(LangUIMessages.ProgramPathDialog_title);
dialog.setMessage(LangUIMessages.ProgramPathDialog_message);
dialog.setInput(project);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if(dialog.open() == IDialogConstants.OK_ID) {
IResource resource = (IResource) dialog.getFirstResult();
return resource.getProjectRelativePath().toPortableString();
}
throw new OperationCancellation();
}
示例12: addMultipleEntries
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
private void addMultipleEntries(ListDialogField field) {
Class[] acceptedClasses = new Class[] { IFolder.class, IFile.class };
ISelectionStatusValidator validator = new TypedElementSelectionValidator(
acceptedClasses, true);
ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
ILabelProvider lp = new WorkbenchLabelProvider();
ITreeContentProvider cp = new WorkbenchContentProvider();
String title, message;
if (isExclusion(field)) {
title = "Exclusion Pattern Selection";
message = "&Choose folders or files to exclude:";
} else {
title = "Inclusion Pattern Selection";
message = "&Choose folders or files to include:";
}
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
lp, cp);
dialog.setTitle(title);
dialog.setValidator(validator);
dialog.setMessage(message);
dialog.addFilter(filter);
dialog.setInput(currSourceFolder);
dialog.setInitialSelection(null);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == Window.OK) {
Object[] objects = dialog.getResult();
int existingSegments = currSourceFolder.getFullPath().segmentCount();
for (int i = 0; i < objects.length; i++) {
IResource curr = (IResource) objects[i];
IPath path = curr.getFullPath().removeFirstSegments(existingSegments)
.makeRelative();
String res;
if (curr instanceof IContainer) {
res = path.addTrailingSeparator().toString();
} else {
res = path.toString();
}
field.addElement(res);
}
}
}
示例13: openFileDialog
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
private IPath openFileDialog(IPath path) {
Class[] acceptedClasses = new Class[] { IFile.class, IFolder.class,
IProject.class };
ISelectionStatusValidator validator = new TypedElementSelectionValidator(
acceptedClasses, false) {
@Override
public IStatus validate(Object[] elements) {
if (elements.length > 1 || elements.length == 0
|| !(elements[0] instanceof IFile)) {
return errorStatus;
}
return okStatus;
}
};
IProject[] allProjects = workspaceRoot.getProjects();
ArrayList rejectedElements = new ArrayList(allProjects.length);
for (int i = 0; i < allProjects.length; i++) {
if (!allProjects[i].equals(project)) {
rejectedElements.add(allProjects[i]);
}
}
ViewerFilter filter = new TypedViewerFilter(acceptedClasses, rejectedElements
.toArray());
ILabelProvider lp = new WorkbenchLabelProvider();
ITreeContentProvider cp = new WorkbenchContentProvider();
IResource initSelection = null;
if (path != null) {
initSelection = project.findMember(path);
}
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
lp, cp);
dialog.setTitle("Variables");
dialog.setValidator(validator);
dialog.setMessage("Select file with variables definition");
dialog.addFilter(filter);
dialog.setInput(workspaceRoot);
dialog.setInitialSelection(initSelection);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == Window.OK) {
return ((IFile) dialog.getFirstResult()).getProjectRelativePath();
}
return null;
}
示例14: chooseExclusionPattern
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
private IPath chooseExclusionPattern() {
Class[] acceptedClasses = new Class[] { IFolder.class, IFile.class };
ISelectionStatusValidator validator = new TypedElementSelectionValidator(
acceptedClasses, false);
ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
ILabelProvider lp = new WorkbenchLabelProvider();
ITreeContentProvider cp = new WorkbenchContentProvider();
IPath initialPath = new Path(exclPatternDialog.getText());
IResource initialElement = null;
IContainer curr = currSourceFolder;
int nSegments = initialPath.segmentCount();
for (int i = 0; i < nSegments; i++) {
IResource elem = curr.findMember(initialPath.segment(i));
if (elem != null) {
initialElement = elem;
}
if (elem instanceof IContainer) {
curr = (IContainer) elem;
} else {
break;
}
}
String title, message;
if (isExclusion) {
title = "Exclusion Pattern Selection";
message = "&Choose a folder or file to exclude:";
} else {
title = "Inclusion Pattern Selection";
message = "&Choose a folder or file to include:";
}
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
getShell(), lp, cp);
dialog.setTitle(title);
dialog.setValidator(validator);
dialog.setMessage(message);
dialog.addFilter(filter);
dialog.setInput(currSourceFolder);
dialog.setInitialSelection(initialElement);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == Window.OK) {
IResource res = (IResource) dialog.getFirstResult();
IPath path = res.getFullPath().removeFirstSegments(
currSourceFolder.getFullPath().segmentCount())
.makeRelative();
if (res instanceof IContainer) {
return path.addTrailingSeparator();
}
return path;
}
return null;
}
示例15: createPackageDialog
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
/**
* 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;
}