本文整理汇总了Java中org.eclipse.ui.dialogs.ISelectionStatusValidator类的典型用法代码示例。如果您正苦于以下问题:Java ISelectionStatusValidator类的具体用法?Java ISelectionStatusValidator怎么用?Java ISelectionStatusValidator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISelectionStatusValidator类属于org.eclipse.ui.dialogs包,在下文中一共展示了ISelectionStatusValidator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openTypeSelectionDialog
import org.eclipse.ui.dialogs.ISelectionStatusValidator; //导入依赖的package包/类
private void openTypeSelectionDialog(){
int elementKinds= IJavaSearchConstants.TYPE;
final IJavaSearchScope scope= createWorkspaceSourceScope();
FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(getShell(), false,
getWizard().getContainer(), scope, elementKinds);
dialog.setTitle(RefactoringMessages.MoveMembersInputPage_choose_Type);
dialog.setMessage(RefactoringMessages.MoveMembersInputPage_dialogMessage);
dialog.setValidator(new ISelectionStatusValidator(){
public IStatus validate(Object[] selection) {
Assert.isTrue(selection.length <= 1);
if (selection.length == 0)
return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, RefactoringMessages.MoveMembersInputPage_Invalid_selection, null);
Object element= selection[0];
if (! (element instanceof IType))
return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, RefactoringMessages.MoveMembersInputPage_Invalid_selection, null);
IType type= (IType)element;
return validateDestinationType(type, type.getElementName());
}
});
dialog.setInitialPattern(createInitialFilter());
if (dialog.open() == Window.CANCEL)
return;
IType firstResult= (IType)dialog.getFirstResult();
fDestinationField.setText(firstResult.getFullyQualifiedName('.'));
}
示例2: init
import org.eclipse.ui.dialogs.ISelectionStatusValidator; //导入依赖的package包/类
private void init() {
FindFileDialog listDialog = this;
// ElementListSelectionDialog listDialog = new ElementListSelectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), labelProvider);
listDialog.setStatusLineAboveButtons(true);
listDialog.setValidator(new ISelectionStatusValidator() {
@Override
public IStatus validate(Object[] selection) {
IResource r = (IResource) selection[0];
return new Status(IStatus.INFO, Activator.PLUGIN_ID, r.getProjectRelativePath().toPortableString());
}
});
listDialog.setMultipleSelection(false);
listDialog.setTitle("ATL files in the workspace");
listDialog.setMessage("");
// listDialog.setElements(list.toArray());
// listDialog.open();
}
示例3: WorkspaceResourceSelectionDialog
import org.eclipse.ui.dialogs.ISelectionStatusValidator; //导入依赖的package包/类
public WorkspaceResourceSelectionDialog(Shell parent, Mode mode) {
super(parent, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
this.mode = mode;
setValidator(new ISelectionStatusValidator() {
public IStatus validate(Object[] selection) {
if (selection.length > 0 && checkMode(selection[0])) {
return new Status(IStatus.OK, TypeScriptUIPlugin.PLUGIN_ID, IStatus.OK, EMPTY_STRING, null);
}
return new Status(IStatus.ERROR, TypeScriptUIPlugin.PLUGIN_ID, IStatus.ERROR, EMPTY_STRING, null);
}
});
setInput(ResourcesPlugin.getWorkspace().getRoot());
}
示例4: FileSelectionDialog
import org.eclipse.ui.dialogs.ISelectionStatusValidator; //导入依赖的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);
}
示例5: chooseException
import org.eclipse.ui.dialogs.ISelectionStatusValidator; //导入依赖的package包/类
private IType chooseException() {
IJavaElement[] elements= new IJavaElement[] { fProject.getJavaProject() };
final IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements);
FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(getShell(), false,
PlatformUI.getWorkbench().getProgressService(), scope, IJavaSearchConstants.CLASS);
dialog.setTitle(RefactoringMessages.ChangeExceptionsControl_choose_title);
dialog.setMessage(RefactoringMessages.ChangeExceptionsControl_choose_message);
dialog.setInitialPattern("*Exception*"); //$NON-NLS-1$
dialog.setValidator(new ISelectionStatusValidator() {
public IStatus validate(Object[] selection) {
if (selection.length == 0)
return new StatusInfo(IStatus.ERROR, ""); //$NON-NLS-1$
try {
return checkException((IType)selection[0]);
} catch (JavaModelException e) {
JavaPlugin.log(e);
return StatusInfo.OK_STATUS;
}
}
});
if (dialog.open() == Window.OK) {
return (IType) dialog.getFirstResult();
}
return null;
}
示例6: createWorkspaceFileSelectionDialog
import org.eclipse.ui.dialogs.ISelectionStatusValidator; //导入依赖的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;
}
示例7: chooseFolder
import org.eclipse.ui.dialogs.ISelectionStatusValidator; //导入依赖的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;
}
示例8: chooseContainer
import org.eclipse.ui.dialogs.ISelectionStatusValidator; //导入依赖的package包/类
private IContainer chooseContainer() {
Class<?>[] acceptedClasses= new Class[] { IProject.class, IFolder.class };
ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
IProject[] allProjects= fWorkspaceRoot.getProjects();
ArrayList<IProject> rejectedElements= new ArrayList<IProject>(allProjects.length);
IProject currProject= fCurrJProject.getProject();
for (int i= 0; i < allProjects.length; i++) {
if (!allProjects[i].equals(currProject)) {
rejectedElements.add(allProjects[i]);
}
}
ViewerFilter filter= new TypedViewerFilter(acceptedClasses, rejectedElements.toArray());
ILabelProvider lp= new WorkbenchLabelProvider();
ITreeContentProvider cp= new WorkbenchContentProvider();
IResource initSelection= null;
if (fOutputLocationPath != null) {
initSelection= fWorkspaceRoot.findMember(fOutputLocationPath);
}
FolderSelectionDialog dialog= new FolderSelectionDialog(getShell(), lp, cp);
dialog.setTitle(NewWizardMessages.BuildPathsBlock_ChooseOutputFolderDialog_title);
dialog.setValidator(validator);
dialog.setMessage(NewWizardMessages.BuildPathsBlock_ChooseOutputFolderDialog_description);
dialog.addFilter(filter);
dialog.setInput(fWorkspaceRoot);
dialog.setInitialSelection(initSelection);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == Window.OK) {
return (IContainer)dialog.getFirstResult();
}
return null;
}
示例9: chooseFolder
import org.eclipse.ui.dialogs.ISelectionStatusValidator; //导入依赖的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;
}
示例10: addMultipleEntries
import org.eclipse.ui.dialogs.ISelectionStatusValidator; //导入依赖的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);
}
}
}
示例11: openFileDialog
import org.eclipse.ui.dialogs.ISelectionStatusValidator; //导入依赖的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;
}
示例12: chooseExclusionPattern
import org.eclipse.ui.dialogs.ISelectionStatusValidator; //导入依赖的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;
}
示例13: getFile
import org.eclipse.ui.dialogs.ISelectionStatusValidator; //导入依赖的package包/类
/**
* Helper to open the file chooser dialog.
*
* @param startingDirectory
* the directory to open the dialog on.
* @return File The File the user selected or <code>null</code> if they do not.
*/
private IFile getFile(IResource resource) {
String project = (baseURI != null ? baseURI.segment(1) : null);
Shell shell = getShell();
WorkspaceLabelProvider labelProvider = new WorkspaceLabelProvider();
WorkbenchContentProvider contentProvider = new WorkbenchContentProvider();
final WorkspaceResourceDialog dialog = new WorkspaceResourceDialog(shell, labelProvider, contentProvider) {
@Override
protected void fileTextModified(String text) {
super.fileTextModified(text);
updateOKStatus();
}
};
dialog.setAllowMultiple(false);
String decodedProject = CommonUtils.decodeUTF8(project);
dialog.setTitle(project != null ? decodedProject : CommonUIPlugin.INSTANCE.getString("_UI_FileSelection_title"));//$NON-NLS-1$
dialog.setMessage(null);
dialog.setShowNewFolderControl(true);
if (style == SWT.SAVE) {
dialog.setShowFileControl(true);
}
dialog.addFilter(dialog.createDefaultViewerFilter(true));
dialog.addFilter(new FilePatternFilter());
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
Object input = (project != null ? root.getProject(decodedProject) : null);
if (input == null) {
input = root;
}
dialog.setValidator(new ISelectionStatusValidator() {
@Override
public IStatus validate(Object[] selection) {
if (selection.length == 0) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, MUST_SELECT_AN_OUTPUT_FOLDER);
} else if (selection.length > 0) {
Object s = selection[0];
if (s instanceof IFile) {
return hasValidExtension(((IFile) s).getName());
}
}
return hasValidExtension(dialog.getFileText());
}
});
dialog.setInput(input);
dialog.setInitialSelection(resource);
if (dialog.open() == Window.OK) {
IFile file = getFileFromDialog(dialog);
if (file != null) {
getTextControl().setFocus();
return file;
}
}
return null;
}
示例14: setValidator
import org.eclipse.ui.dialogs.ISelectionStatusValidator; //导入依赖的package包/类
public void setValidator(ISelectionStatusValidator validator) {
fValidator= validator;
}
示例15: createValidator
import org.eclipse.ui.dialogs.ISelectionStatusValidator; //导入依赖的package包/类
private static ISelectionStatusValidator createValidator(int entries) {
AddGetterSetterSelectionStatusValidator validator= new AddGetterSetterSelectionStatusValidator(entries);
return validator;
}