本文整理匯總了Java中org.eclipse.ui.dialogs.ElementTreeSelectionDialog類的典型用法代碼示例。如果您正苦於以下問題:Java ElementTreeSelectionDialog類的具體用法?Java ElementTreeSelectionDialog怎麽用?Java ElementTreeSelectionDialog使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ElementTreeSelectionDialog類屬於org.eclipse.ui.dialogs包,在下文中一共展示了ElementTreeSelectionDialog類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: chooseWorkspace
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入依賴的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: main
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入依賴的package包/類
static public void main(String[] arg) throws Exception {
Display display = new Display();
Shell shell = new Shell(display);
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, new PropertyLabelProvider(),
new PropertyContentProvider());
dialog.setInput(loadXmlReader(null));
dialog.open();
try {
loadXmlReader(null);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例3: selectFile
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入依賴的package包/類
/**
* Open a dialog box asking the user to select an existing project under the
* current workspace.
*
* @param parentShell
* @param title
*/
public static IResource selectFile(Shell parentShell, String title) {
ElementTreeSelectionDialog dialog =
new ElementTreeSelectionDialog(
parentShell,
new WorkbenchLabelProvider(),
new WorkbenchContentProvider()
);
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.setTitle(title);
dialog.setAllowMultiple(false);
if(dialog.open() == ElementTreeSelectionDialog.OK) {
return (IResource) dialog.getFirstResult();
}
return null;
}
示例4: openFirstInstructionSelection
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入依賴的package包/類
/**
* Opens the {@link EObject first instruction} selection dialog.
*
* @param shell
* the {@link Shell} to use for display
* @param resourceSet
* the {@link ResourceSet} to get the first instruction from
* @return the selected first instruction {@link URI} if any selected, <code>null</code> otherwise
*/
public static EObject openFirstInstructionSelection(final Shell shell, ResourceSet resourceSet) {
final EObject res;
final ComposedAdapterFactory fatory = new ComposedAdapterFactory(
ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
fatory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
fatory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell,
new AdapterFactoryLabelProvider(fatory), new AdapterFactoryContentProvider(fatory));
dialog.setTitle("Select first instruction");
dialog.setMessage("Select the first instruction:");
dialog.setInput(resourceSet);
if (dialog.open() == Window.OK) {
res = (EObject)dialog.getFirstResult();
} else {
res = null;
}
fatory.dispose();
return res;
}
示例5: createFolderDestination
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入依賴的package包/類
private void createFolderDestination() {
Composite row = new Composite(destRow, SWT.NONE);
row.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
GridLayout gl_folderSource = new GridLayout(2, false);
gl_folderSource.marginRight = -5;
gl_folderSource.marginLeft = -5;
row.setLayout(gl_folderSource);
destFolder = new Text(row, SWT.BORDER | SWT.READ_ONLY);
destFolder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Button destFolderButton = new Button(row, SWT.NONE);
destFolderButton.setImage(folder);
destFolderButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
destFolderButton.setText("Folder");
destFolderButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ElementTreeSelectionDialog diag = createFolderDialog("Destination Folder Selection", entry.getDestination());
if (diag.open() == Dialog.OK) {
setDestination((IFolder)diag.getFirstResult());
}
}
});
}
示例6: 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());
}
}
示例7: run
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入依賴的package包/類
@Override
public void run() {
ElementTreeSelectionDialog isoTreeSelectionDialog = new ElementTreeSelectionDialog(
Display.getDefault().getActiveShell(), new IsoTreeLabelProvider(), new IsoTreeContentProvider());
isoTreeSelectionDialog.setTitle("Iso tree");
isoTreeSelectionDialog.setMessage("Select the destination directory to place the selected files.");
isoTreeSelectionDialog.setInput(IsoExplorerSashForm.getInstance().getIsoDirectoriesTree().getInput());
switch (isoTreeSelectionDialog.open()) {
case Window.OK:
executeAddFiles((ITreeNode) isoTreeSelectionDialog.getFirstResult());
executeAction();
isoTreeSelectionDialog.close();
default:
return;
}
}
示例8: 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;
}
示例9: chooseWorkspaceDirectory
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入依賴的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;
}
示例10: openSiriusModelSelection
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入依賴的package包/類
/**
* Opens the model selection dialog.
*
* @param parent
* the parent {@link Composite}
*/
private void openSiriusModelSelection(final Composite parent) {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(parent.getShell(),
new WorkbenchLabelProvider(), new FilteredFileContentProvider(new String[] {
SiriusUtil.SESSION_RESOURCE_EXTENSION }));
dialog.setTitle("Select model file");
dialog.setMessage("Select the model file to execute:");
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
if (dialog.open() == Window.OK) {
siriusResourceURIText.setText(((IFile)dialog.getFirstResult()).getFullPath().toString());
}
}
示例11: openModelSelection
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入依賴的package包/類
/**
* Opens the model selection dialog.
*
* @param parent
* the parent {@link Composite}
*/
private void openModelSelection(final Composite parent) {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(parent.getShell(),
new WorkbenchLabelProvider(), new FilteredFileContentProvider(extensions));
dialog.setTitle("Select model file");
dialog.setMessage("Select the model file to execute:");
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
if (dialog.open() == Window.OK) {
resourceURIText.setText(((IFile)dialog.getFirstResult()).getFullPath().toString());
}
}
示例12: 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);
}
}
}
}
示例13: createFolderDialog
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入依賴的package包/類
public static ElementTreeSelectionDialog createFolderDialog(String initialFolder, final IProject project,
final boolean showAllProjects, final boolean showFolder, Shell shell) {
ILabelProvider lp = new WorkbenchLabelProvider();
ITreeContentProvider cp = new WorkbenchContentProvider();
FolderSelectionDialog dialog = new FolderSelectionDialog(shell, lp, cp);
// dialog.setTitle(TypeScriptUIMessages.TernModuleOptionsPanel_selectPathDialogTitle);
IContainer folder = StringUtils.isEmpty(initialFolder) ? project
: (project != null ? project.getFolder(initialFolder)
: ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(initialFolder)));
if (folder != null && folder.exists()) {
dialog.setInitialSelection(folder);
}
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
ViewerFilter filter = new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IProject) {
if (showAllProjects)
return true;
IProject p = (IProject) element;
return (p.equals(project));
} else if (element instanceof IContainer) {
IContainer container = (IContainer) element;
if (showFolder && container.getType() == IResource.FOLDER) {
return true;
}
return false;
}
return false;
}
};
dialog.addFilter(filter);
return dialog;
}
示例14: createElementTreeSelectionDialog
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入依賴的package包/類
/**
* Creates a dialog used to select exactly <i>one</i> value from the input
* tree.
*
* @param shell
* The parent shell for the dialog.
* @param labelProvider
* The label provider for the tree.
* @param contentProvider
* The content provider for the tree.
* @return The new dialog.
*/
private ElementTreeSelectionDialog createElementTreeSelectionDialog(
Shell shell, ILabelProvider labelProvider,
ITreeContentProvider contentProvider) {
// Create a custom selection listener to update the selected elements on
// the fly.
final ISelectionChangedListener selectionListener = createSelectionChangedListener();
ElementTreeSelectionDialog treeDialog = new ElementTreeSelectionDialog(
shell, labelProvider, contentProvider) {
/*
* (non-Javadoc)
* @see org.eclipse.ui.dialogs.ElementTreeSelectionDialog#createTreeViewer(org.eclipse.swt.widgets.Composite)
*/
@Override
protected TreeViewer createTreeViewer(Composite parent) {
TreeViewer viewer = super.createTreeViewer(parent);
// Add the selection changed listener.
viewer.addSelectionChangedListener(selectionListener);
return viewer;
}
};
// Do not allow multi-selection here.
treeDialog.setAllowMultiple(false);
return treeDialog;
}
示例15: addAddBtn
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; //導入依賴的package包/類
protected void addAddBtn(final Composite btnComposite) {
Button add = new Button(btnComposite, SWT.FLAT);
GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).applyTo(add);
add.setText("Add...");
add.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(btnComposite.getShell(),
new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
dialog.setValidator(new CheaderBlacklistSelectionStatusValidator());
dialog.setTitle("Add blacklist item");
dialog.setMessage("Select a blacklist item:");
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.addFilter(new CHeaderViewerFilter(getActualProject()));
if (!values.isEmpty())
dialog.setInitialSelection(values.get(values.size() - 1));
dialog.setDialogBoundsSettings(BuilderActivator.getDefault().getDialogSettings(),
Dialog.DIALOG_PERSISTLOCATION);
dialog.open();
Object[] result = dialog.getResult();
if (result != null) {
for (Object selection : result) {
if (selection instanceof IResource) {
values.add((IResource) selection);
}
}
blackListViewer.refresh();
}
}
});
}