本文整理汇总了Java中org.eclipse.ui.views.navigator.ResourceComparator类的典型用法代码示例。如果您正苦于以下问题:Java ResourceComparator类的具体用法?Java ResourceComparator怎么用?Java ResourceComparator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourceComparator类属于org.eclipse.ui.views.navigator包,在下文中一共展示了ResourceComparator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: chooseWorkspace
import org.eclipse.ui.views.navigator.ResourceComparator; //导入依赖的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: ResourceTreeSelectionDialog
import org.eclipse.ui.views.navigator.ResourceComparator; //导入依赖的package包/类
/**
* Constructs an instance of <code>ResourceTreeSelectionDialog</code>.
*
* @param parent the parent shell for the dialog
* @param title dialog title
* @param message dialog message
* @param rootResource resource that serves as the root of the tree. This
* resource's descendants are visible in the tree, but the root
* itself is not.
* @param initialResource the initially-selected resource
* @param visibleResourceTypes a set of {@link IResource} types that are
* visible in the tree (e.g.
* <code>IResource.FILE | IResource.FOLDER</code>)
* @param acceptedResourceTypes a set of {@link IResource} types that can be
* selected
* @param multiSelection whether or not to allow selection of multiple
* resources
*/
public ResourceTreeSelectionDialog(Shell parent, String title,
String message, IContainer rootResource, IResource initialResource,
int visibleResourceTypes, int acceptedResourceTypes,
boolean multiSelection) {
super(parent, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
setTitle(title);
setMessage(message);
setHelpAvailable(false);
setInput(rootResource);
if (initialResource != null) {
setInitialSelection(initialResource);
}
setComparator(new ResourceComparator(ResourceComparator.NAME));
setValidator(new ResourceFilter(acceptedResourceTypes, multiSelection));
addFilter(new ResourceFilter(visibleResourceTypes));
}
示例3: createTreeViewer
import org.eclipse.ui.views.navigator.ResourceComparator; //导入依赖的package包/类
/**
* Creates the tree viewer.
*
* @param parent the parent composite
* @return the tree viewer
*/
protected CheckboxTreeViewer createTreeViewer(Composite parent) {
fViewer = new CheckboxTreeViewer(parent, SWT.BORDER);
fViewer.setContentProvider(fContentProvider);
fViewer.setLabelProvider(fLabelProvider);
fViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
updateOKStatus();
}
});
fViewer.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (fFilters != null) {
for (int i = 0; i != fFilters.size(); i++) {
fViewer.addFilter((ViewerFilter) fFilters.get(i));
}
}
fViewer.setInput(fInput);
return fViewer;
}
示例4: createTreeViewer
import org.eclipse.ui.views.navigator.ResourceComparator; //导入依赖的package包/类
/**
* Creates the tree viewer.
*
* @param parent the parent composite
* @return the tree viewer
*/
protected CheckboxTreeViewer createTreeViewer(Composite parent) {
fViewer = new CheckboxTreeViewer(parent, SWT.BORDER);
fViewer.setContentProvider(fContentProvider);
fViewer.setLabelProvider(fLabelProvider);
fViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
updateOKStatus();
}
});
fViewer.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (fFilters != null) {
for (int i = 0; i != fFilters.size(); i++)
fViewer.addFilter(fFilters.get(i));
}
fViewer.setInput(fInput);
return fViewer;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:28,代码来源:MultipleFolderSelectionDialog.java
示例5: chooseWorkspaceDirectory
import org.eclipse.ui.views.navigator.ResourceComparator; //导入依赖的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;
}
示例6: FileSelectionDialog
import org.eclipse.ui.views.navigator.ResourceComparator; //导入依赖的package包/类
public FileSelectionDialog(Shell parent, List<IFile> files, String title,
String message, String filterExtension, String filterMessage) {
super(parent, new WorkbenchLabelProvider(),
new WorkbenchContentProvider());
setTitle(title);
setMessage(message);
fFilter = new FileFilter(files, filterExtension);
fFilterMessage = filterMessage;
setInput(ResourcesPlugin.getWorkspace().getRoot());
setComparator(new ResourceComparator(ResourceComparator.NAME));
ISelectionStatusValidator validator = new ISelectionStatusValidator() {
@Override
public IStatus validate(Object[] selection) {
if (selection.length == 0) {
return new Status(IStatus.ERROR,
JSBuildFileUIPlugin.PLUGIN_ID, 0, "", null);
}
for (int i = 0; i < selection.length; i++) {
if (!(selection[i] instanceof IFile)) {
return new Status(IStatus.ERROR,
JSBuildFileUIPlugin.PLUGIN_ID, 0, "", null);
}
}
return new Status(IStatus.OK, JSBuildFileUIPlugin.PLUGIN_ID, 0,
"", null);
}
};
setValidator(validator);
}
示例7: handleManifestfileBrowse
import org.eclipse.ui.views.navigator.ResourceComparator; //导入依赖的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);
}
}
}
示例8: selectWorkspaceDir
import org.eclipse.ui.views.navigator.ResourceComparator; //导入依赖的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;
}
示例9: handleManifestfileBrowse
import org.eclipse.ui.views.navigator.ResourceComparator; //导入依赖的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);
}
}
}
示例10: selectWorkspaceDir
import org.eclipse.ui.views.navigator.ResourceComparator; //导入依赖的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;
}
示例11: configureJAREntry
import org.eclipse.ui.views.navigator.ResourceComparator; //导入依赖的package包/类
/**
* Shows the UI to configure a JAR or ZIP archive located in the workspace.
* The dialog returns the configured classpath entry path or <code>null</code> if the dialog has
* been canceled. The dialog does not apply any changes.
*
* @param shell The parent shell for the dialog.
* @param initialEntry The path of the initial archive entry
* @param usedEntries An array of paths that are already on the classpath and therefore should not be
* selected again.
* @return Returns the configured JAR path or <code>null</code> if the dialog has
* been canceled by the user.
*/
public static IPath configureJAREntry(Shell shell, IPath initialEntry, IPath[] usedEntries) {
if (initialEntry == null || usedEntries == null) {
throw new IllegalArgumentException();
}
Class<?>[] acceptedClasses= new Class[] { IFile.class };
TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
ArrayList<IResource> usedJars= new ArrayList<IResource>(usedEntries.length);
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
for (int i= 0; i < usedEntries.length; i++) {
IPath curr= usedEntries[i];
if (!curr.equals(initialEntry)) {
IResource resource= root.findMember(usedEntries[i]);
if (resource instanceof IFile) {
usedJars.add(resource);
}
}
}
IResource existing= root.findMember(initialEntry);
FilteredElementTreeSelectionDialog dialog= new FilteredElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setValidator(validator);
dialog.setTitle(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_edit_title);
dialog.setMessage(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_edit_description);
dialog.setInitialFilter(ArchiveFileFilter.JARZIP_FILTER_STRING);
dialog.addFilter(new ArchiveFileFilter(usedJars, true, true));
dialog.setInput(root);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
dialog.setInitialSelection(existing);
if (dialog.open() == Window.OK) {
IResource element= (IResource) dialog.getFirstResult();
return element.getFullPath();
}
return null;
}
示例12: chooseJAREntries
import org.eclipse.ui.views.navigator.ResourceComparator; //导入依赖的package包/类
/**
* Shows the UI to select new JAR or ZIP archive entries located in the workspace.
* The dialog returns the selected entries or <code>null</code> if the dialog has
* been canceled. The dialog does not apply any changes.
*
* @param shell The parent shell for the dialog.
* @param initialSelection The path of the element (container or archive) to initially select or <code>null</code> to not select an entry.
* @param usedEntries An array of paths that are already on the classpath and therefore should not be
* selected again.
* @return Returns the new JAR paths or <code>null</code> if the dialog has
* been canceled by the user.
*/
public static IPath[] chooseJAREntries(Shell shell, IPath initialSelection, IPath[] usedEntries) {
if (usedEntries == null) {
throw new IllegalArgumentException();
}
Class<?>[] acceptedClasses= new Class[] { IFile.class };
TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, true);
ArrayList<IResource> usedJars= new ArrayList<IResource>(usedEntries.length);
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
for (int i= 0; i < usedEntries.length; i++) {
IResource resource= root.findMember(usedEntries[i]);
if (resource instanceof IFile) {
usedJars.add(resource);
}
}
IResource focus= initialSelection != null ? root.findMember(initialSelection) : null;
FilteredElementTreeSelectionDialog dialog= new FilteredElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setHelpAvailable(false);
dialog.setValidator(validator);
dialog.setTitle(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_new_title);
dialog.setMessage(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_new_description);
dialog.setInitialFilter(ArchiveFileFilter.JARZIP_FILTER_STRING);
dialog.addFilter(new ArchiveFileFilter(usedJars, true, true));
dialog.setInput(root);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
dialog.setInitialSelection(focus);
if (dialog.open() == Window.OK) {
Object[] elements= dialog.getResult();
IPath[] res= new IPath[elements.length];
for (int i= 0; i < res.length; i++) {
IResource elem= (IResource)elements[i];
res[i]= elem.getFullPath();
}
return res;
}
return null;
}
示例13: chooseWorkspaceArchive
import org.eclipse.ui.views.navigator.ResourceComparator; //导入依赖的package包/类
private String chooseWorkspaceArchive() {
String initSelection= fArchiveField.getText();
ILabelProvider lp= new WorkbenchLabelProvider();
ITreeContentProvider cp= new WorkbenchContentProvider();
Class<?>[] acceptedClasses= new Class[] { IFile.class };
TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, true);
IResource initSel= null;
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
if (initSelection.length() > 0) {
initSel= root.findMember(new Path(initSelection));
}
FilteredElementTreeSelectionDialog dialog= new FilteredElementTreeSelectionDialog(fShell, lp, cp);
dialog.setInitialFilter(ArchiveFileFilter.JARZIP_FILTER_STRING);
dialog.setAllowMultiple(false);
dialog.setValidator(validator);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
dialog.setTitle(PreferencesMessages.JavadocConfigurationBlock_workspace_archive_selection_dialog_title);
dialog.setMessage(PreferencesMessages.JavadocConfigurationBlock_workspace_archive_selection_dialog_description);
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;
}
示例14: chooseInternal
import org.eclipse.ui.views.navigator.ResourceComparator; //导入依赖的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
示例15: chooseFolder
import org.eclipse.ui.views.navigator.ResourceComparator; //导入依赖的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;
}