本文整理匯總了Java中org.eclipse.ui.dialogs.ElementTreeSelectionDialog.addFilter方法的典型用法代碼示例。如果您正苦於以下問題:Java ElementTreeSelectionDialog.addFilter方法的具體用法?Java ElementTreeSelectionDialog.addFilter怎麽用?Java ElementTreeSelectionDialog.addFilter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.ui.dialogs.ElementTreeSelectionDialog
的用法示例。
在下文中一共展示了ElementTreeSelectionDialog.addFilter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: selectInProject
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
private void selectInProject() {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
dialog.setTitle("Select a file in the project:");
dialog.setMessage("Select a file in the project:");
// Filter to the project
dialog.addFilter(new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IProject) {
return ((IProject) element).getName().equals(project.getName());
}
// we want a folder
return defaultExtension != null || element instanceof IContainer;
}
});
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
// TODO try to preselect the current file
dialog.open();
Object[] results = dialog.getResult();
if ((results != null) && (results.length > 0) && (results[0] instanceof IResource)) {
IPath path = ((IResource) results[0]).getFullPath();
setProjectLoc(path.removeFirstSegments(1).makeRelative().toString());
}
}
示例2: selectFolderInProject
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
private IFolder selectFolderInProject() {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getControl().getShell(),
new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
dialog.setTitle("Select View Root");
dialog.setMessage("select the view root:");
dialog.setInput(getProject());
dialog.addFilter(new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) {
return element instanceof IFolder && ((IFolder) element).isAccessible();
}
});
if (Window.OK == dialog.open()) {
Object[] result = dialog.getResult();
if (result.length > 0) {
return (IFolder) result[0];
}
}
return null;
}
示例3: handleLocationBrowseButtonPressed
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
private void handleLocationBrowseButtonPressed() {
IContainer folder = getFolder();
String initialFolder = folder != null ? folder.getProjectRelativePath().toString() : null;
final IProject project = folder != null ? folder.getProject() : null;
ElementTreeSelectionDialog dialog = DialogUtils.createFolderDialog(initialFolder, project, project == null,
true, getShell());
dialog.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IProject) {
// Show only project which are angular-cli project
IProject p = (IProject) element;
return AngularCLIProject.isAngularCLIProject(p);
} else if (element instanceof IContainer) {
// Check if the given container is included in the
// angular-cli root-path
IContainer container = (IContainer) element;
return isValidAppsLocation(container, true);
}
return false;
}
});
dialog.setTitle(AngularCLIMessages.NgGenerateBlueprintWizardPage_browse_location_title);
if (dialog.open() == Window.OK) {
Object[] result = dialog.getResult();
if (result.length == 1) {
Object selectedFolder = result[0];
if (selectedFolder instanceof IContainer) {
setFolder((IContainer) selectedFolder, true);
}
}
}
}
示例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: 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;
}
示例6: setUpWhitelistPackagesDialog
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
private void setUpWhitelistPackagesDialog() {
IJavaProject project = getSelectedProject();
ElementTreeSelectionDialog dialog =
new ElementTreeSelectionDialog(getControl().getShell(),
new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_BASICS),
new JavaPackageElementContentProvider());
dialog.setInput(project);
dialog.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IPackageFragment) {
return !((IPackageFragment) element).getElementName().equals("");
}
if (element instanceof ICompilationUnit) {
return false;
}
return true;
}
});
dialog.setMessage("Choose packages to whitelist:");
if (dialog.open() == Window.OK) {
Object[] results = dialog.getResult();
String[] stringArray = new String[results.length];
for (int i = 0; i < results.length; i++) {
if (results[i] instanceof IJavaElement) {
stringArray[i] = ((IJavaElement) results[i]).getElementName();
}
}
whiteListList.add(stringArray);
setTabDirty();
}
}
示例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: createFolderDialog
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
private ElementTreeSelectionDialog createFolderDialog(String title, Object selection) {
ElementTreeSelectionDialog diag = new ElementTreeSelectionDialog(getShell(),
new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
diag.addFilter(new TypedViewerFilter(new Class[]{IFolder.class}));
configureDialog(diag, title, "Select Folder", selection);
return diag;
}
示例12: selectInWorkspace
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
private void selectInWorkspace() {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
dialog.setTitle("Select a file in the workspace:");
dialog.setMessage("Select a file in the workspace:");
// Filter closed projects
dialog.addFilter(new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IProject) {
return ((IProject) element).isAccessible();
}
// we want a folder
return defaultExtension != null || element instanceof IContainer;
}
});
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
// TODO try to preselect the current file
dialog.open();
Object[] results = dialog.getResult();
if (results != null && results.length > 0 && results[0] instanceof IResource) {
IPath path = ((IResource) results[0]).getFullPath();
if (project != null && path.segment(0).equals(project.getProject().getName())) {
setProjectLoc(path.removeFirstSegments(1).makeRelative().toString());
} else {
String containerName = path.makeRelative().toString();
setWorkspaceLoc("${workspace_loc:" + containerName + "}");
}
}
}
示例13: openXtpScriptSelectionDialog
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
/**
* Opens a dialog which prompts for a dLabPro script (extension
* <code>*.?tp</code>)
*
* @param iShell the parent shell for the dialog
* @return the selected resource or <code>null</code> if the dialog was
* canceled
*/
public static IFile openXtpScriptSelectionDialog(Shell iShell)
{
ResourcePatternFilter iXtpFilter = new ResourcePatternFilter()
{
public boolean select(Viewer viewer, Object parentElement, Object element)
{
if (element instanceof IFile)
{
return !super.select(viewer, parentElement, element);
}
else
{
return true;
}
}
};
iXtpFilter.setPatterns(new String[] { "*.?tp" });
WorkbenchLabelProvider iLp = new WorkbenchLabelProvider();
WorkbenchContentProvider iCp = new WorkbenchContentProvider();
ElementTreeSelectionDialog iDlg = new ElementTreeSelectionDialog(iShell,
iLp,iCp);
iDlg.setInput(ResourcesPlugin.getWorkspace().getRoot());
iDlg.setTitle("Script Selection");
iDlg.setMessage("Choose a dLabPro script");
iDlg.addFilter(iXtpFilter);
if (iDlg.open() == Window.OK)
return (IFile)iDlg.getFirstResult();
else
return null;
}
示例14: openElementTreeSelectionDialog
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
/**
* 트리에서 요소 선택하는 다이얼로그 열기
*
* @param isSelectAnalysisModel
* void
*/
private void openElementTreeSelectionDialog(boolean isSelectAnalysisModel) {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
new ProjectItemLabelProvider(),
new ProjectItemTreeContentProvider(1));
dialog.setTitle(UMLMessage.LABEL_USECASE_TRACE_MATRIX_CREATION);
if (isSelectAnalysisModel) {
dialog.setMessage(UMLMessage.MESSAGE_SELECT_ANALYSIS_MODEL_FOR_CREATE_USECASE_TRACE_MATRIX);
} else {
dialog.setMessage(UMLMessage.MESSAGE_SELECT_DESIGN_MODEL_FOR_CREATE_USECASE_TRACE_MATRIX);
}
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.addFilter(new ViewerFilter() {
/**
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer,
* java.lang.Object, java.lang.Object)
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IProject) {
return true;
} else if (parentElement instanceof IFolder && element instanceof Model) {
return true;
} else if (element instanceof IResource) {
if (((IResource) element).getName().startsWith(UICoreConstant.PROJECT_CONSTANTS__DOT)) {
return false;
}
return true;
}
return false;
}
});
if (dialog.open() != Window.OK) {
return;
}
if (!(dialog.getFirstResult() instanceof Model)) {
return;
}
if (isSelectAnalysisModel) {
if (getSelectedDesignModel() != null) {
if (getSelectedDesignModel().equals(dialog.getFirstResult())) {
MessageDialog.openWarning(getShell(),
UMLMessage.LABEL_USECASE_TRACE_MATRIX_CREATION,
UMLMessage.MESSAGE_WARNING_DO_NOT_SELECT_SAME_MODEL);
return;
}
}
} else {
if (getSelectedAnalysisModel() != null) {
if (getSelectedAnalysisModel().equals(dialog.getFirstResult())) {
MessageDialog.openWarning(getShell(),
UMLMessage.LABEL_USECASE_TRACE_MATRIX_CREATION,
UMLMessage.MESSAGE_WARNING_DO_NOT_SELECT_SAME_MODEL);
return;
}
}
}
if (isSelectAnalysisModel) {
setSelectedAnalysisModel((Model) dialog.getFirstResult());
analysisText.setText(getSelectedAnalysisModel().getName());
} else {
setSelectedDesignModel((Model) dialog.getFirstResult());
designText.setText(getSelectedDesignModel().getQualifiedName());
}
}
示例15: 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);
}
}
}