Search in sources :

Example 16 with ResourceComparator

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);
        }
    }
}
Also used : ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) FolderSelectionDialog(org.talend.dataprofiler.core.ui.dialog.FolderSelectionDialog) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DQFolderFilter(org.talend.dataprofiler.core.ui.filters.DQFolderFilter) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder)

Example 17 with ResourceComparator

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];
}
Also used : ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) JavaSourceFolderValidator(org.whole.lang.ui.controls.JavaSourceFolderValidator) IContainer(org.eclipse.core.resources.IContainer) JavaSourceFolderFilter(org.whole.lang.ui.controls.JavaSourceFolderFilter)

Example 18 with ResourceComparator

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;
}
Also used : ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) IResource(org.eclipse.core.resources.IResource)

Example 19 with ResourceComparator

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;
}
Also used : ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) FileFilter(org.hibernate.eclipse.console.FileFilter) IResource(org.eclipse.core.resources.IResource)

Example 20 with ResourceComparator

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;
}
Also used : ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IResource(org.eclipse.core.resources.IResource)

Aggregations

ResourceComparator (org.eclipse.ui.views.navigator.ResourceComparator)20 WorkbenchLabelProvider (org.eclipse.ui.model.WorkbenchLabelProvider)19 WorkbenchContentProvider (org.eclipse.ui.model.WorkbenchContentProvider)18 IResource (org.eclipse.core.resources.IResource)17 ElementTreeSelectionDialog (org.eclipse.ui.dialogs.ElementTreeSelectionDialog)17 IPath (org.eclipse.core.runtime.IPath)7 IStatus (org.eclipse.core.runtime.IStatus)7 IContainer (org.eclipse.core.resources.IContainer)6 IFile (org.eclipse.core.resources.IFile)6 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)6 Status (org.eclipse.core.runtime.Status)6 ArrayList (java.util.ArrayList)5 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)4 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)4 SelectionListener (org.eclipse.swt.events.SelectionListener)4 GridData (org.eclipse.swt.layout.GridData)4 Button (org.eclipse.swt.widgets.Button)4 Composite (org.eclipse.swt.widgets.Composite)4 ResourcesPlugin (org.eclipse.core.resources.ResourcesPlugin)3 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)3