use of org.eclipse.ui.dialogs.ElementTreeSelectionDialog in project generator by mybatis.
the class AbstractGeneratorComposite method chooseFileFromWorkspace.
protected IResource chooseFileFromWorkspace() {
ElementTreeSelectionDialog esd = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
esd.setTitle(getDialogTitle());
esd.setMessage(getDialogMessage());
esd.setAllowMultiple(false);
esd.setValidator(selectionStatusVerifier);
esd.addFilter(getViewerFilter());
esd.setInput(ResourcesPlugin.getWorkspace().getRoot());
esd.setInitialSelection(getWorkspaceResource());
int rc = esd.open();
if (rc == 0) {
Object[] elements = esd.getResult();
if (elements.length > 0) {
return (IResource) elements[0];
}
}
return null;
}
use of org.eclipse.ui.dialogs.ElementTreeSelectionDialog in project ow by vtst.
the class ResourceListControl method addResource.
private void addResource() {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(null, new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
dialog.setAllowMultiple(false);
dialog.setTitle(messages.getString("FolderListControl_add"));
dialog.setMessage("");
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.addFilter(this.addFilter);
try {
dialog.setInitialSelection(ResourcesPlugin.getWorkspace().getRoot());
}// Raised by new Path(...)
catch (IllegalArgumentException exn) {
}
dialog.setValidator(addValidator);
dialog.open();
T resource = getSelectedResource(dialog.getResult());
if (resource != null) {
addResource((T) resource);
}
}
use of org.eclipse.ui.dialogs.ElementTreeSelectionDialog in project bndtools by bndtools.
the class AddFilesToRepositoryWizardPage method doAdd.
void doAdd() {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setValidator(new ISelectionStatusValidator() {
@Override
public IStatus validate(Object[] selection) {
if (selection.length > 0 && selection[0] instanceof IFile) {
//$NON-NLS-1$
return new Status(IStatus.OK, Plugin.PLUGIN_ID, IStatus.OK, "", null);
}
//$NON-NLS-1$
return new Status(IStatus.ERROR, Plugin.PLUGIN_ID, IStatus.ERROR, "", null);
}
});
dialog.setAllowMultiple(true);
dialog.setTitle("JAR File Selection");
//$NON-NLS-1$
dialog.addFilter(new FileExtensionFilter("jar"));
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
if (dialog.open() == Window.OK) {
Object[] result = dialog.getResult();
List<File> added = new ArrayList<File>(result.length);
for (Object fileObj : result) {
IFile ifile = (IFile) fileObj;
File file = ifile.getLocation().toFile();
analyseFile(file);
files.add(file);
added.add(file);
}
if (!added.isEmpty()) {
viewer.add(added.toArray());
validate();
}
}
}
use of org.eclipse.ui.dialogs.ElementTreeSelectionDialog in project bndtools by bndtools.
the class ProjectLaunchTabPiece method doBrowseBndrun.
void doBrowseBndrun() {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(launchTargetTxt.getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setValidator(new ISelectionStatusValidator() {
@Override
public IStatus validate(Object[] selection) {
if (selection.length > 0 && selection[0] instanceof IFile) {
//$NON-NLS-1$
return new Status(IStatus.OK, Plugin.PLUGIN_ID, IStatus.OK, "", null);
}
//$NON-NLS-1$
return new Status(IStatus.ERROR, Plugin.PLUGIN_ID, IStatus.ERROR, "", null);
}
});
dialog.setAllowMultiple(false);
dialog.setTitle("Run File Selection");
dialog.setMessage("Select the Run File to launch.");
dialog.addFilter(new FileExtensionFilter(LaunchConstants.EXT_BNDRUN));
dialog.setInput(ResourcesPlugin.getWorkspace());
if (dialog.open() == Window.OK) {
Object[] files = dialog.getResult();
if (files != null && files.length == 1) {
IPath path = ((IResource) files[0]).getFullPath().makeRelative();
launchTargetTxt.setText(path.toString());
} else {
launchTargetTxt.setText("");
}
}
}
use of org.eclipse.ui.dialogs.ElementTreeSelectionDialog in project tdi-studio-se by Talend.
the class AddResourceAction method run.
/**
* Prompts for a jar to add.
*
* @see IAction#run()
*/
@Override
public void run() {
// ViewerFilter filter = new ArchiveFilter(getSelectedJars());
ILabelProvider lp = new WorkbenchLabelProvider();
ITreeContentProvider cp = new WorkbenchContentProvider();
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
dialog.setValidator(validator);
//$NON-NLS-1$
dialog.setTitle(Messages.getString("AddResourceAction.JARSecection"));
//$NON-NLS-1$
dialog.setMessage(Messages.getString("AddResourceAction.ChooseResource"));
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot().getProject(PluginConstant.COMPONENT_PROJECT));
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == Window.OK) {
Object[] elements = dialog.getResult();
List<ILibEntry> res = new ArrayList<ILibEntry>();
for (int i = 0; i < elements.length; i++) {
IResource elem = (IResource) elements[i];
String name = elem.getName();
if (name.matches("(?i).*\\.(jar)\\b")) {
//$NON-NLS-1$
res.add(new JarLibEntry(elem));
}
if (name.matches("(?i).*\\.(pm)\\b")) {
//$NON-NLS-1$
res.add(new PmLibEntry(elem));
}
}
if (res.size() > 0) {
ILibEntry[] entries = new ILibEntry[res.size()];
getViewer().addEntries(res.toArray(entries));
}
}
}
Aggregations