use of org.eclipse.ui.views.navigator.ResourceComparator in project tdq-studio-se by Talend.
the class CreateSqlFileWizardPage method openFolderSelectionDialog.
protected void openFolderSelectionDialog(IFolder inputFolder) {
assert inputFolder != null;
FolderSelectionDialog dialog = new FolderSelectionDialog(getShell());
// $NON-NLS-1$
dialog.setTitle(DefaultMessagesImpl.getString("MetadataWizardPage.selectFolder"));
// $NON-NLS-1$
dialog.setMessage(DefaultMessagesImpl.getString("MetadataWizardPage.selectFolderItem"));
dialog.setInput(inputFolder);
dialog.addFilter(new DQFolderFilter());
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == Window.OK) {
if (dialog.getResult() == null || dialog.getResult().length == 0) {
return;
}
Object elements = dialog.getResult()[0];
IResource elem = (IResource) elements;
if (elem instanceof IFolder) {
pathText.setText(elem.getFullPath().toString());
parameter.getFolderProvider().setFolderResource((IFolder) elem);
}
}
}
use of org.eclipse.ui.views.navigator.ResourceComparator in project whole by wholeplatform.
the class OperationLauncherRegistry method openJavaSourceFoldersDialog.
public static IContainer[] openJavaSourceFoldersDialog(Shell shell, boolean allowMultipleSelection) {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setValidator(new JavaSourceFolderValidator());
dialog.setTitle("Java Source Folder Selection");
dialog.setMessage("Choose a destination folder for generated code");
dialog.addFilter(new JavaSourceFolderFilter());
dialog.setInput(JDTUtils.getWorkspaceRoot());
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
dialog.setAllowMultiple(allowMultipleSelection);
if (dialog.open() == Window.OK) {
Object[] elements = dialog.getResult();
IContainer[] containers = new IContainer[elements.length];
for (int i = 0; i < containers.length; i++) containers[i] = (IContainer) elements[i];
return containers;
}
return new IContainer[0];
}
use of org.eclipse.ui.views.navigator.ResourceComparator in project usbdm-eclipse-plugins by podonoghue.
the class Utility method browseWorkspaceButtonSelected.
/**
* Browse workspace for binary file
*
* @param title Title for dialogue
* @param textControl Text control to be updated
* @return null - cancelled or failed, else path accepted
*/
public static String browseWorkspaceButtonSelected(Shell shell, String title, Text textControl) {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new org.eclipse.ui.model.BaseWorkbenchContentProvider());
dialog.setTitle(title);
dialog.setMessage("File brows");
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
String filePath = null;
if (dialog.open() == IDialogConstants.OK_ID) {
IResource resource = (IResource) dialog.getFirstResult();
String arg = resource.getFullPath().toOSString();
// $NON-NLS-1$
filePath = VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression("workspace_loc", arg);
textControl.setText(filePath);
textControl.setToolTipText(filePath);
}
return filePath;
}
use of org.eclipse.ui.views.navigator.ResourceComparator in project jbosstools-hibernate by jbosstools.
the class DialogSelectionHelper method chooseFileEntries.
/**
* Shows the UI to select new JAR or ZIP archive entries located in the workspace.
* The dialog returns the selected entries or <code>null</code> if the dialog has
* been cancelled. The dialog does not apply any changes.
* @param shell The parent shell for the dialog.
* @param initialSelection The path of the element (container or archive) to initially select or <code>null</code> to not select an entry.
* @param usedEntries An array of paths that are already on the classpath and therefore should not be
* selected again.
* @param fileExtensions An array of file extensions.
* @param allowMultiple allow multiple selections.
* @param allowFiles TODO
* @param acceptedTypes TODO
*
* @return Returns the new classpath container entry paths or <code>null</code> if the dialog has
* been cancelled by the user.
*
* Inspired by BuildPathDialogAccess.chooseJAREntries from jdt.ui.wizards
*/
public static IPath[] chooseFileEntries(Shell shell, IPath initialSelection, IPath[] usedEntries, String title, String description, String[] fileExtensions, boolean allowMultiple, boolean allowDirectories, boolean allowFiles) {
if (usedEntries == null) {
throw new IllegalArgumentException(HibernateConsoleMessages.DialogSelectionHelper_used_entries_must_be_notnull);
}
List<Class<?>> clazzes = new ArrayList<Class<?>>();
if (allowDirectories) {
clazzes.add(IFolder.class);
clazzes.add(IProject.class);
}
if (allowFiles) {
clazzes.add(IFile.class);
}
Class<?>[] acceptedClasses = clazzes.toArray(new Class[clazzes.size()]);
TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, true);
List<IResource> usedFiles = new ArrayList<IResource>(usedEntries.length);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
for (int i = 0; i < usedEntries.length; i++) {
IResource resource = root.findMember(usedEntries[i]);
if (resource instanceof IFile) {
usedFiles.add(resource);
}
}
IResource focus = initialSelection != null ? root.findMember(initialSelection) : null;
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setValidator(validator);
dialog.setAllowMultiple(allowMultiple);
dialog.setTitle(title);
dialog.setMessage(description);
dialog.addFilter(new FileFilter(fileExtensions, usedFiles, true, allowDirectories));
dialog.setInput(root);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
dialog.setInitialSelection(focus);
if (dialog.open() == Window.OK) {
Object[] elements = dialog.getResult();
IPath[] res = new IPath[elements.length];
for (int i = 0; i < res.length; i++) {
IResource elem = (IResource) elements[i];
res[i] = elem.getFullPath();
}
return res;
}
return null;
}
use of org.eclipse.ui.views.navigator.ResourceComparator in project jbosstools-hibernate by jbosstools.
the class DialogSelectionHelper method chooseFolderEntries.
public static IPath[] chooseFolderEntries(Shell shell, IPath initialSelection, String title, String description, boolean allowMultiple) {
List<Class<?>> clazzes = new ArrayList<Class<?>>();
clazzes.add(IFolder.class);
clazzes.add(IProject.class);
Class<?>[] acceptedClasses = clazzes.toArray(new Class[clazzes.size()]);
TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, true);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource focus = initialSelection != null ? root.findMember(initialSelection) : null;
ElementTreeSelectionDialog dialog = null;
dialog = new FolderSelectionDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setValidator(validator);
dialog.setAllowMultiple(allowMultiple);
dialog.setTitle(title);
dialog.setMessage(description);
dialog.setInput(root);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
dialog.setInitialSelection(focus);
if (dialog.open() == Window.OK) {
Object[] elements = dialog.getResult();
IPath[] res = new IPath[elements.length];
for (int i = 0; i < res.length; i++) {
IResource elem = (IResource) elements[i];
res[i] = elem.getFullPath();
}
return res;
}
return null;
}
Aggregations