當前位置: 首頁>>代碼示例>>Java>>正文


Java ElementTreeSelectionDialog.getResult方法代碼示例

本文整理匯總了Java中org.eclipse.ui.dialogs.ElementTreeSelectionDialog.getResult方法的典型用法代碼示例。如果您正苦於以下問題:Java ElementTreeSelectionDialog.getResult方法的具體用法?Java ElementTreeSelectionDialog.getResult怎麽用?Java ElementTreeSelectionDialog.getResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.ui.dialogs.ElementTreeSelectionDialog的用法示例。


在下文中一共展示了ElementTreeSelectionDialog.getResult方法的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());
    }
}
 
開發者ID:apache,項目名稱:ant-ivyde,代碼行數:25,代碼來源:PathEditor.java

示例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;
}
 
開發者ID:cntoplolicon,項目名稱:seasar2-assistant,代碼行數:21,代碼來源:Seasar2AssistantPropertyPage.java

示例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);
			}
		}
	}
}
 
開發者ID:angelozerr,項目名稱:angular-eclipse,代碼行數:35,代碼來源:NgGenerateBlueprintWizardPage.java

示例4: 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);
		}
	}
}
 
開發者ID:thahn0720,項目名稱:agui_eclipse_plugin,代碼行數:33,代碼來源:FJExportWizardConfigPage.java

示例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;
	}
 
開發者ID:thahn0720,項目名稱:agui_eclipse_plugin,代碼行數:34,代碼來源:FJExportWizardFilesSelectPage.java

示例6: 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);
            }
        }
    }
 
開發者ID:thahn0720,項目名稱:agui_eclipse_plugin,代碼行數:37,代碼來源:ConfigPage.java

示例7: 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;
    }
 
開發者ID:thahn0720,項目名稱:agui_eclipse_plugin,代碼行數:32,代碼來源:FilesSelectPage.java

示例8: 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();
  }
}
 
開發者ID:mhevery,項目名稱:testability-explorer,代碼行數:36,代碼來源:TestabilityLaunchConfigurationTab.java

示例9: handleManifestFileBrowseButtonPressed

import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
protected void handleManifestFileBrowseButtonPressed() {
	ElementTreeSelectionDialog dialog= createWorkspaceFileSelectionDialog(JarPackagerMessages.JarManifestWizardPage_manifestSelectionDialog_title, JarPackagerMessages.JarManifestWizardPage_manifestSelectionDialog_message);
	if (fJarPackage.isManifestAccessible())
		dialog.setInitialSelections(new IResource[] {fJarPackage.getManifestFile()});
	if (dialog.open() ==  Window.OK) {
		Object[] resources= dialog.getResult();
		if (resources.length != 1)
			setErrorMessage(JarPackagerMessages.JarManifestWizardPage_error_onlyOneManifestMustBeSelected);
		else {
			setErrorMessage(""); //$NON-NLS-1$
			fJarPackage.setManifestLocation(((IResource)resources[0]).getFullPath());
			fManifestFileText.setText(fJarPackage.getManifestLocation().toString());
		}
	}
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:16,代碼來源:JarManifestWizardPage.java

示例10: 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 + "}");
        }
    }
}
 
開發者ID:apache,項目名稱:ant-ivyde,代碼行數:30,代碼來源:PathEditor.java

示例11: createFileBrowseAdapter

import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
/**
 * Creates a selection adaptor for a file browse button.
 * 
 * @param text the text control.
 * @param fileExtension the file extension.
 * @param title the title for a dialog to select a file.
 * @return a selection adaptor.
 */
private SelectionAdapter createFileBrowseAdapter(final Text text,
        final String fileExtension, final String title) {
    return new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {

            // create a tree selection dialog and initializes it.
            ElementTreeSelectionDialog fileDialog = new ElementTreeSelectionDialog(
                    getShell(), new DecoratingLabelProvider(
                            new WorkbenchLabelProvider(), PlatformUI
                                    .getWorkbench().getDecoratorManager()
                                    .getLabelDecorator()),
                    new FileExtensionRestrictTreeContentProvider(fileExtension));

            // set projects from workspace.
            fileDialog.setInput(ResourcesPlugin.getWorkspace().getRoot()
                    .getProjects());

            fileDialog.setAllowMultiple(false);
            fileDialog.setBlockOnOpen(true);
            fileDialog.setTitle(title);

            fileDialog.open();

            Object[] results = fileDialog.getResult();
            if (results != null && results.length == 1
                    && results[0] instanceof IResource) {
                text.setText(((IResource) results[0]).getFullPath()
                        .toString());
            }
        }
    };
}
 
開發者ID:d-case,項目名稱:d-case_editor,代碼行數:41,代碼來源:AbstractXmlConversionWizardPage.java

示例12: showDialogAndGetDiagramFile

import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
/**
 * Shows a dialog to select a diagram file to compare.
 * 
 * @return selected diagram file.
 */
private IFile showDialogAndGetDiagramFile() {
    ElementTreeSelectionDialog fileDialog = new ElementTreeSelectionDialog(
            DcaseEditorUtil.getActiveWindowShell(),
            new DecoratingLabelProvider(new WorkbenchLabelProvider(),
                    PlatformUI.getWorkbench().getDecoratorManager()
                            .getLabelDecorator()),
            new FileExtensionRestrictTreeContentProvider(PropertyUtil
                    .getSystemProperty(DIAGRAM_FILE_EXTENSION)));

    fileDialog.setInput(ResourcesPlugin.getWorkspace().getRoot()
            .getProjects());
    fileDialog.setAllowMultiple(false);
    fileDialog.setBlockOnOpen(true);
    // sets validator that tests whether a file is selected.
    fileDialog.setValidator(new FileSelectionStatusValidator());
    fileDialog.setTitle(Messages.CompareDcaseFileSelectionAdapter_1);

    fileDialog.open();

    Object[] results = fileDialog.getResult();

    if (results == null) {
        return null;
    }
    return (IFile) results[0];
}
 
開發者ID:d-case,項目名稱:d-case_editor,代碼行數:32,代碼來源:CompareDcaseFileSelectionAdapter.java

示例13: 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);
        }
    }
}
 
開發者ID:iloveeclipse,項目名稱:filesync4eclipse,代碼行數:46,代碼來源:InclusionExclusionDialog.java

示例14: chooseExclusionPattern

import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
public static IPath[] chooseExclusionPattern(Shell shell, IContainer currentSourceFolder, String title, String message, IPath initialPath, boolean multiSelection) {
	Class<?>[] acceptedClasses= new Class[] { IFolder.class, IFile.class };
	ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, multiSelection);
	ViewerFilter filter= new TypedViewerFilter(acceptedClasses);


	ILabelProvider lp= new WorkbenchLabelProvider();
	ITreeContentProvider cp= new WorkbenchContentProvider();

	IResource initialElement= null;
	if (initialPath != null) {
		IContainer curr= currentSourceFolder;
		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;
			}
		}
	}

	ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(shell, lp, cp);
	dialog.setTitle(title);
	dialog.setValidator(validator);
	dialog.setMessage(message);
	dialog.addFilter(filter);
	dialog.setInput(currentSourceFolder);
	dialog.setInitialSelection(initialElement);
	dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
	dialog.setHelpAvailable(false);

	if (dialog.open() == Window.OK) {
		Object[] objects= dialog.getResult();
		int existingSegments= currentSourceFolder.getFullPath().segmentCount();

		IPath[] resArr= new IPath[objects.length];
		for (int i= 0; i < objects.length; i++) {
			IResource currRes= (IResource) objects[i];
			IPath path= currRes.getFullPath().removeFirstSegments(existingSegments).makeRelative();
			if (currRes instanceof IContainer) {
				path= path.addTrailingSeparator();
			}
			resArr[i]= path;
		}
		return resArr;
	}
	return null;
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:54,代碼來源:ExclusionInclusionEntryDialog.java

示例15: selectAttachmentFromWS

import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
/**
 * Select the attachment from the workspace.
 * 
 * @param parent the parent.
 * @param currentAttachment the original attachment.
 * @return the selected attachment.
 */
private String selectAttachmentFromWS(Shell parent, String currentAttachment) {
            
            IFile selectedFile = null;
            if (currentAttachment != null && currentAttachment.length() > 0) {
                selectedFile = FileUtil.getWorksapceFileFromPath(currentAttachment);
            }

            // creates tree and initializes it to show files in the workspace.
            
            ElementTreeSelectionDialog fileDialog = new ElementTreeSelectionDialog(
                    parent, new DecoratingLabelProvider(
                            new WorkbenchLabelProvider(), PlatformUI
                                    .getWorkbench().getDecoratorManager()
                                    .getLabelDecorator()),
                    //new FileExtensionRestrictTreeContentProvider(null)
                    new WorkbenchContentProvider());

            // sets projects to the tree selection dialog.
            fileDialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
            fileDialog.setAllowMultiple(false);
            fileDialog.setBlockOnOpen(true);
            // sets the validator.
            fileDialog.setValidator(new FileSelectionStatusValidator());
            fileDialog.setTitle(TermsMessages.SelectAttachmentHandler_0);

            if (selectedFile != null) {
                fileDialog.setInitialSelection(selectedFile);
            }
            fileDialog.open();

            Object[] results = fileDialog.getResult();

            // sets the value of the attachment attribute.
            if (results != null && results.length == 1
                    && results[0] instanceof IResource) {
                String diagramPath = ((IResource) results[0]).getFullPath()
                        .toString();

                return diagramPath;
            }
            return null;
}
 
開發者ID:d-case,項目名稱:d-case_editor,代碼行數:50,代碼來源:SelectAttachmentFromWSHandler.java


注:本文中的org.eclipse.ui.dialogs.ElementTreeSelectionDialog.getResult方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。