Search in sources :

Example 16 with ContainerSelectionDialog

use of org.eclipse.ui.dialogs.ContainerSelectionDialog in project eclipse.platform.ui by eclipse-platform.

the class UIDialogsAuto method testCopyMoveResource.

@Test
public void testCopyMoveResource() {
    Dialog dialog = new ContainerSelectionDialog(getShell(), null, true, "Copy Resources");
    DialogCheck.assertDialogTexts(dialog);
}
Also used : SelectPerspectiveDialog(org.eclipse.ui.internal.dialogs.SelectPerspectiveDialog) ProjectLocationSelectionDialog(org.eclipse.ui.dialogs.ProjectLocationSelectionDialog) TypeFilteringDialog(org.eclipse.ui.dialogs.TypeFilteringDialog) ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog) FileExtensionDialog(org.eclipse.ui.internal.dialogs.FileExtensionDialog) EditorSelectionDialog(org.eclipse.ui.dialogs.EditorSelectionDialog) AboutDialog(org.eclipse.ui.internal.dialogs.AboutDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) SaveAsDialog(org.eclipse.ui.dialogs.SaveAsDialog) AboutPluginsDialog(org.eclipse.ui.internal.dialogs.AboutPluginsDialog) SavePerspectiveDialog(org.eclipse.ui.internal.dialogs.SavePerspectiveDialog) Dialog(org.eclipse.jface.dialogs.Dialog) ListSelectionDialog(org.eclipse.ui.dialogs.ListSelectionDialog) ShowViewDialog(org.eclipse.ui.internal.dialogs.ShowViewDialog) ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog) Test(org.junit.Test)

Example 17 with ContainerSelectionDialog

use of org.eclipse.ui.dialogs.ContainerSelectionDialog in project Pydev by fabioz.

the class PyMoveResourceAction method pyQueryDestinationResource.

private IPath pyQueryDestinationResource() {
    // start traversal at root resource, should probably start at a
    // better location in the tree
    String title;
    if (selected.size() == 1) {
        title = "Choose destination for ''" + selected.get(0).getName() + "'':";
    } else {
        title = "Choose destination for " + selected.size() + " selected resources:";
    }
    ContainerSelectionDialog dialog = new ContainerSelectionDialog(shellProvider.getShell(), selected.get(0).getParent(), true, title);
    dialog.setTitle("Move Resources");
    dialog.setValidator(this);
    dialog.showClosedProjects(false);
    dialog.open();
    Object[] result = dialog.getResult();
    if (result != null && result.length == 1) {
        return (IPath) result[0];
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog)

Example 18 with ContainerSelectionDialog

use of org.eclipse.ui.dialogs.ContainerSelectionDialog in project dbeaver by dbeaver.

the class PrefPageProjectResourceSettings method createContents.

@Override
protected Control createContents(final Composite parent) {
    Composite composite = UIUtils.createComposite(parent, 1);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    {
        UIUtils.createControlLabel(composite, UINavigatorMessages.pref_page_projects_settings_label_resource_location);
        resourceTable = new Table(composite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.widthHint = 400;
        gd.heightHint = 300;
        resourceTable.setLayoutData(gd);
        resourceTable.setHeaderVisible(true);
        resourceTable.setLinesVisible(true);
        UIUtils.createTableColumn(resourceTable, SWT.LEFT, UINavigatorMessages.pref_page_projects_settings_label_resource);
        UIUtils.createTableColumn(resourceTable, SWT.LEFT, UINavigatorMessages.pref_page_projects_settings_label_folder);
        resourceTable.setHeaderVisible(true);
        handlerTableEditor = new TableEditor(resourceTable);
        handlerTableEditor.verticalAlignment = SWT.TOP;
        handlerTableEditor.horizontalAlignment = SWT.RIGHT;
        handlerTableEditor.grabHorizontal = true;
        handlerTableEditor.grabVertical = true;
        resourceTable.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseUp(MouseEvent e) {
                disposeOldEditor();
                final TableItem item = resourceTable.getItem(new Point(0, e.y));
                if (item == null) {
                    return;
                }
                int columnIndex = UIUtils.getColumnAtPos(item, e.x, e.y);
                if (columnIndex <= 0) {
                    return;
                }
                if (columnIndex == 1) {
                    final String resourcePath = item.getText(1);
                    if (project != null) {
                        final IFolder folder = project.getFolder(resourcePath);
                        ContainerSelectionDialog dialog = new ContainerSelectionDialog(resourceTable.getShell(), folder, true, UINavigatorMessages.pref_page_projects_settings_label_select + item.getText(0) + UINavigatorMessages.pref_page_projects_settings_label_root_folder);
                        dialog.showClosedProjects(false);
                        dialog.setValidator(selection -> {
                            if (selection instanceof IPath) {
                                final File file = ((IPath) selection).toFile();
                                if (file.isHidden() || file.getName().startsWith(".")) {
                                    return UINavigatorMessages.pref_page_projects_settings_label_not_use_hidden_folders;
                                }
                                final String[] segments = ((IPath) selection).segments();
                                if (!project.getName().equals(segments[0])) {
                                    return UINavigatorMessages.pref_page_projects_settings_label_not_store_resources_in_another_project;
                                }
                            }
                            return null;
                        });
                        if (dialog.open() == IDialogConstants.OK_ID) {
                            final Object[] result = dialog.getResult();
                            if (result.length == 1 && result[0] instanceof IPath) {
                                final IPath plainPath = ((IPath) result[0]).removeFirstSegments(1).removeTrailingSeparator();
                                item.setText(1, plainPath.toString());
                            }
                        }
                    } else {
                        final Text editor = new Text(resourceTable, SWT.NONE);
                        editor.setText(resourcePath);
                        editor.selectAll();
                        handlerTableEditor.setEditor(editor, item, 1);
                        editor.setFocus();
                        editor.addFocusListener(new FocusAdapter() {

                            @Override
                            public void focusLost(FocusEvent e) {
                                item.setText(1, editor.getText());
                            }
                        });
                    }
                }
            }
        });
        UIUtils.createInfoLabel(composite, UINavigatorMessages.pref_page_projects_settings_label_restart_require_refresh_global_settings);
    }
    performDefaults();
    return composite;
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) MouseEvent(org.eclipse.swt.events.MouseEvent) IPath(org.eclipse.core.runtime.IPath) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Point(org.eclipse.swt.graphics.Point) TableEditor(org.eclipse.swt.custom.TableEditor) FocusEvent(org.eclipse.swt.events.FocusEvent) Point(org.eclipse.swt.graphics.Point) ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog) GridData(org.eclipse.swt.layout.GridData) File(java.io.File) IFolder(org.eclipse.core.resources.IFolder)

Example 19 with ContainerSelectionDialog

use of org.eclipse.ui.dialogs.ContainerSelectionDialog in project bndtools by bndtools.

the class IndexerWizardPage method createControl.

@Override
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);
    setControl(composite);
    // Create controls
    new Label(composite, SWT.NONE).setText(Messages.IndexerWizardPage_baseDir);
    txtBaseDir = new Text(composite, SWT.BORDER);
    newSpacer(composite);
    Composite cmpButtonBar = new Composite(composite, SWT.NONE);
    Button btnBrowseWorkspace = new Button(cmpButtonBar, SWT.PUSH);
    btnBrowseWorkspace.setText(Messages.IndexerWizardPage_browse);
    Button btnBrowseExternal = new Button(cmpButtonBar, SWT.PUSH);
    btnBrowseExternal.setText(Messages.IndexerWizardPage_browseExternal);
    new Label(composite, SWT.NONE).setText(Messages.IndexerWizardPage_resourcePattern);
    txtResourcePattern = new Text(composite, SWT.BORDER);
    ControlDecoration decorResourcePattern = new ControlDecoration(txtResourcePattern, SWT.LEFT | SWT.TOP, composite);
    decorResourcePattern.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
    decorResourcePattern.setMarginWidth(3);
    decorResourcePattern.setDescriptionText(Messages.IndexerWizardPage_resourcePatternHelp);
    decorResourcePattern.setShowHover(true);
    decorResourcePattern.setShowOnlyOnFocus(false);
    Label lblInputs = new Label(composite, SWT.NONE);
    lblInputs.setText(Messages.IndexerWizardPage_inputs);
    Table tblInputs = new Table(composite, SWT.MULTI | SWT.BORDER);
    vwrInputs = new TableViewer(tblInputs);
    vwrInputs.setContentProvider(ArrayContentProvider.getInstance());
    vwrInputs.setLabelProvider(new StyledCellLabelProvider() {

        @Override
        public void update(ViewerCell cell) {
            Object elem = cell.getElement();
            if (elem instanceof Path) {
                cell.setText(elem.toString());
                cell.setImage(imgFile);
            } else if (elem instanceof IStatus) {
                IStatus status = (IStatus) elem;
                cell.setText(status.getMessage());
                if (status.getSeverity() == IStatus.ERROR)
                    cell.setImage(imgError);
                else if (status.getSeverity() == IStatus.WARNING)
                    cell.setImage(imgWarning);
            }
        }
    });
    newSpacer(composite);
    lblInputCount = new Label(composite, SWT.NONE);
    Label lblOutputs = new Label(composite, SWT.NONE);
    lblOutputs.setText(Messages.IndexerWizardPage_output);
    Group grpOutput = new Group(composite, SWT.NONE);
    new Label(grpOutput, SWT.NONE).setText(Messages.IndexerWizardPage_prefix);
    txtOutputPrefix = new Text(grpOutput, SWT.BORDER);
    newSpacer(grpOutput);
    btnOutputPretty = new Button(grpOutput, SWT.RADIO);
    btnOutputPretty.setText(Messages.IndexerWizardPage_prettyPrint);
    newSpacer(grpOutput);
    btnOutputCompressed = new Button(grpOutput, SWT.RADIO);
    btnOutputCompressed.setText(Messages.IndexerWizardPage_compressed);
    newSpacer(grpOutput);
    lblOutputName = new Label(grpOutput, SWT.NONE);
    // LAYOUT
    GridLayout gl;
    GridData gd;
    gl = new GridLayout(2, false);
    gl.horizontalSpacing = 10;
    composite.setLayout(gl);
    txtBaseDir.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    cmpButtonBar.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false));
    gl = new GridLayout(2, false);
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    cmpButtonBar.setLayout(gl);
    btnBrowseWorkspace.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    btnBrowseExternal.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    txtResourcePattern.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    lblInputs.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.heightHint = 120;
    gd.widthHint = 100;
    tblInputs.setLayoutData(gd);
    lblInputCount.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
    lblOutputs.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
    grpOutput.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    grpOutput.setLayout(new GridLayout(2, false));
    txtOutputPrefix.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    btnOutputCompressed.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    btnOutputPretty.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    lblOutputName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    // LOAD DATA
    if (baseDir != null)
        txtBaseDir.setText(baseDir.getAbsolutePath());
    if (resourcePattern != null)
        txtResourcePattern.setText(resourcePattern);
    // $NON-NLS-1$
    txtOutputPrefix.setText("index");
    btnOutputCompressed.setSelection(outputStyle == IndexFormatStyle.COMPRESSED);
    btnOutputPretty.setSelection(outputStyle == IndexFormatStyle.PRETTY_UNCOMPRESSED);
    updateOutputFileName();
    updateInputs();
    // LISTENERS
    txtBaseDir.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent me) {
            String baseDirStr = txtBaseDir.getText();
            baseDir = baseDirStr.isEmpty() ? null : new File(baseDirStr);
            validate();
            updateInputs();
        }
    });
    txtResourcePattern.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent me) {
            resourcePattern = txtResourcePattern.getText();
            updateInputs();
        }
    });
    btnBrowseWorkspace.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
            ContainerSelectionDialog containerDlg = new ContainerSelectionDialog(getShell(), root, false, Messages.IndexerWizardPage_selectBaseDir);
            containerDlg.showClosedProjects(false);
            if (containerDlg.open() == Window.OK) {
                Object[] selection = containerDlg.getResult();
                if (selection != null && selection.length > 0) {
                    IPath workspacePath = (IPath) selection[0];
                    IResource resource = root.findMember(workspacePath);
                    if (resource == null)
                        MessageDialog.openError(getShell(), "Error", "Could not find resource for path " + workspacePath);
                    else
                        txtBaseDir.setText(resource.getLocation().toString());
                }
            }
        }
    });
    btnBrowseExternal.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dirDialog = new DirectoryDialog(getShell());
            dirDialog.setMessage(Messages.IndexerWizardPage_selectBaseDir);
            String selectedPath = dirDialog.open();
            if (selectedPath != null)
                txtBaseDir.setText(selectedPath);
        }
    });
    txtOutputPrefix.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent me) {
            updateOutputFileName();
            validate();
        }
    });
    Listener outputRadioListener = new Listener() {

        @Override
        public void handleEvent(Event ev) {
            outputStyle = btnOutputCompressed.getSelection() ? IndexFormatStyle.COMPRESSED : IndexFormatStyle.PRETTY_UNCOMPRESSED;
            updateOutputFileName();
            validate();
        }
    };
    btnOutputCompressed.addListener(SWT.Selection, outputRadioListener);
    btnOutputPretty.addListener(SWT.Selection, outputRadioListener);
    validate();
}
Also used : Group(org.eclipse.swt.widgets.Group) IStatus(org.eclipse.core.runtime.IStatus) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) IPath(org.eclipse.core.runtime.IPath) Path(java.nio.file.Path) StyledCellLabelProvider(org.eclipse.jface.viewers.StyledCellLabelProvider) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) IPath(org.eclipse.core.runtime.IPath) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) ViewerCell(org.eclipse.jface.viewers.ViewerCell) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog) GridData(org.eclipse.swt.layout.GridData) ModifyEvent(org.eclipse.swt.events.ModifyEvent) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) File(java.io.File) IResource(org.eclipse.core.resources.IResource)

Example 20 with ContainerSelectionDialog

use of org.eclipse.ui.dialogs.ContainerSelectionDialog in project xtext-eclipse by eclipse.

the class NewFileWizardPrimaryPage method createHeader.

private void createHeader(Composite parent) {
    Composite main = new Composite(parent, SWT.NONE);
    main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
    main.setLayout(new GridLayout(3, false));
    Label folderLabel = new Label(main, SWT.NONE);
    folderLabel.setText(Messages.NewFileWizardPrimaryPage_folder_label);
    folderLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    folderText = new Text(main, SWT.SINGLE | SWT.BORDER);
    folderText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Button folderBrowseButton = new Button(main, SWT.PUSH);
    folderBrowseButton.setText(Messages.NewFileWizardPrimaryPage_browse_button);
    folderBrowseButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    Label fileLabel = new Label(main, SWT.NONE);
    fileLabel.setText(Messages.NewFileWizardPrimaryPage_name_label);
    fileLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    fileText = new Text(main, SWT.SINGLE | SWT.BORDER);
    fileText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    fileText.setFocus();
    folderText.setText(initFolderText());
    fileText.setText(initFileText());
    folderText.addModifyListener(e -> validate());
    fileText.addModifyListener(e -> validate());
    folderBrowseButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ContainerSelectionDialog dialog = new ContainerSelectionDialog(Display.getDefault().getActiveShell(), ResourcesPlugin.getWorkspace().getRoot(), false, Messages.NewFileWizardPrimaryPage_selection_description);
            if (dialog.open() == Window.OK) {
                folderText.setText(getFolderFromPath((IPath) dialog.getResult()[0]));
            }
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text)

Aggregations

ContainerSelectionDialog (org.eclipse.ui.dialogs.ContainerSelectionDialog)30 IPath (org.eclipse.core.runtime.IPath)15 GridData (org.eclipse.swt.layout.GridData)11 IProject (org.eclipse.core.resources.IProject)8 File (java.io.File)7 Path (org.eclipse.core.runtime.Path)7 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 GridLayout (org.eclipse.swt.layout.GridLayout)7 Button (org.eclipse.swt.widgets.Button)7 IResource (org.eclipse.core.resources.IResource)6 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 Label (org.eclipse.swt.widgets.Label)6 Text (org.eclipse.swt.widgets.Text)6 IContainer (org.eclipse.core.resources.IContainer)5 Composite (org.eclipse.swt.widgets.Composite)5 IFolder (org.eclipse.core.resources.IFolder)4 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)4 ModifyEvent (org.eclipse.swt.events.ModifyEvent)4 ModifyListener (org.eclipse.swt.events.ModifyListener)4 Group (org.eclipse.swt.widgets.Group)4