本文整理匯總了Java中org.eclipse.ui.dialogs.ElementTreeSelectionDialog.setInitialSelection方法的典型用法代碼示例。如果您正苦於以下問題:Java ElementTreeSelectionDialog.setInitialSelection方法的具體用法?Java ElementTreeSelectionDialog.setInitialSelection怎麽用?Java ElementTreeSelectionDialog.setInitialSelection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.ui.dialogs.ElementTreeSelectionDialog
的用法示例。
在下文中一共展示了ElementTreeSelectionDialog.setInitialSelection方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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
示例2: 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;
}
示例3: 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;
}
示例4: configureDialog
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
private void configureDialog(ElementTreeSelectionDialog diag, String title, String message, Object selection) {
diag.setTitle(title);
diag.setMessage("Select Folder");
diag.setAllowMultiple(false);
diag.setHelpAvailable(false);
diag.setInput(project);
if (selection != null) {
diag.setInitialSelection(selection);
}
}
示例5: 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);
}
}
}
示例6: 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;
}
示例7: 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;
}
示例8: internalChooseArchivePath
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入方法依賴的package包/類
private String internalChooseArchivePath() {
ZipFile zipFile= null;
try {
if (fWorkspaceRadio.isSelected()) {
IResource resource= ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(fArchiveField.getText()));
if (resource != null) {
IPath location= resource.getLocation();
if (location != null) {
zipFile= new ZipFile(location.toOSString());
}
}
} else {
zipFile= new ZipFile(fArchiveField.getText());
}
if (zipFile == null) {
return null;
}
ZipFileStructureProvider provider= new ZipFileStructureProvider(zipFile);
ILabelProvider lp= new ZipDialogLabelProvider(provider);
ZipDialogContentProvider cp= new ZipDialogContentProvider(provider);
ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(fShell, lp, cp);
dialog.setAllowMultiple(false);
dialog.setValidator(new ZipDialogValidator());
dialog.setTitle(PreferencesMessages.JavadocConfigurationBlock_browse_jarorzip_path_title);
dialog.setMessage(PreferencesMessages.JavadocConfigurationBlock_location_in_jarorzip_message);
dialog.setComparator(new ViewerComparator());
String init= fArchivePathField.getText();
if (init.length() == 0) {
init= "docs/api"; //$NON-NLS-1$
}
dialog.setInitialSelection(cp.findElement(new Path(init)));
dialog.setInput(this);
if (dialog.open() == Window.OK) {
String name= provider.getFullPath(dialog.getFirstResult());
return new Path(name).removeTrailingSeparator().toString();
}
} catch (IOException e) {
JavaPlugin.log(e);
} finally {
if (zipFile != null) {
try {
zipFile.close();
} catch (IOException e1) {
// ignore
}
}
}
return null;
}
示例9: 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
示例10: 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;
}