Search in sources :

Example 76 with DirectoryDialog

use of org.eclipse.swt.widgets.DirectoryDialog in project linuxtools by eclipse.

the class DockerComposeUpLaunchConfigurationMainTab method onBrowseFileSystemForDirectory.

/**
 * Opens a dialog to browse the file system and select a directory
 *
 * @return
 */
private SelectionListener onBrowseFileSystemForDirectory(final Text pathText) {
    return SelectionListener.widgetSelectedAdapter(e -> {
        final DirectoryDialog dialog = new DirectoryDialog(getShell());
        final String selection = dialog.open();
        if (selection != null) {
            pathText.setText(selection);
            dockerComposeFilePathWorkspaceRelative = false;
        }
    });
}
Also used : DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 77 with DirectoryDialog

use of org.eclipse.swt.widgets.DirectoryDialog in project linuxtools by eclipse.

the class PackageVMPage method onSearchFolder.

/**
 * Opens the folder selection dialog.
 *
 * @return
 */
private SelectionListener onSearchFolder() {
    return SelectionListener.widgetSelectedAdapter(e -> {
        DirectoryDialog fd = new DirectoryDialog(getShell());
        String location = fd.open();
        if (location != null && !location.isEmpty()) {
            model.setBoxFolder(location);
        }
    });
}
Also used : DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 78 with DirectoryDialog

use of org.eclipse.swt.widgets.DirectoryDialog in project linuxtools by eclipse.

the class ContainerCopyFromPage method onBrowseSelect.

private SelectionListener onBrowseSelect() {
    final ContainerCopyFromPage page = this;
    return SelectionListener.widgetSelectedAdapter(e -> {
        DirectoryDialog d = new DirectoryDialog(Activator.getActiveWorkbenchShell());
        String x = d.open();
        if (x != null) {
            page.targetText.setText(x);
        }
    });
}
Also used : DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 79 with DirectoryDialog

use of org.eclipse.swt.widgets.DirectoryDialog in project linuxtools by eclipse.

the class ContainerCopyToPage method handleSourceBrowseButtonPressed.

/**
 * Open an appropriate source browser so that the user can specify a source
 * to import from
 */
protected void handleSourceBrowseButtonPressed() {
    String currentSource = this.sourceNameField.getText();
    DirectoryDialog dialog = new DirectoryDialog(sourceNameField.getShell(), SWT.SAVE | SWT.SHEET);
    dialog.setText(SELECT_SOURCE_TITLE);
    dialog.setMessage(SELECT_SOURCE_MESSAGE);
    dialog.setFilterPath(getSourceDirectoryName(currentSource));
    String selectedDirectory = dialog.open();
    if (selectedDirectory != null) {
        // Just quit if the directory is not valid
        if ((getSourceDirectory(selectedDirectory) == null) || selectedDirectory.equals(currentSource)) {
            return;
        }
        // If it is valid then proceed to populate
        setErrorMessage(null);
        setSourceName(selectedDirectory);
        selectionGroup.setFocus();
    }
}
Also used : DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 80 with DirectoryDialog

use of org.eclipse.swt.widgets.DirectoryDialog in project linuxtools by eclipse.

the class JavaImageTab method createControl.

@Override
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
    Label connLbl = new Label(composite, SWT.NONE);
    connLbl.setText(Messages.ImageSelectionDialog_connection_label);
    connCmb = new ComboViewer(composite, SWT.READ_ONLY);
    connCmb.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
    connCmb.setContentProvider(new IStructuredContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            for (IDockerConnection conn : DockerConnectionManager.getInstance().getAllConnections()) {
                try {
                    ((DockerConnection) conn).open(false);
                } catch (DockerException e) {
                }
            }
            return DockerConnectionManager.getInstance().getAllConnections().stream().filter(c -> c.isOpen()).toArray(size -> new IDockerConnection[size]);
        }
    });
    // $NON-NLS-1$
    connCmb.setInput("place_holder");
    Label imageLbl = new Label(composite, SWT.NONE);
    imageLbl.setText(Messages.ImageSelectionDialog_image_label);
    imageCmb = new ComboViewer(composite, SWT.READ_ONLY);
    imageCmb.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
    imageCmb.setContentProvider(new IStructuredContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            IDockerConnection conn = (IDockerConnection) inputElement;
            if (conn == null || conn.getImages() == null) {
                return new Object[0];
            } else {
                return conn.getImages().stream().filter(// $NON-NLS-1$
                i -> !i.repoTags().get(0).equals("<none>:<none>")).toArray(size -> new IDockerImage[size]);
            }
        }
    });
    imageCmb.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            IDockerImage img = (IDockerImage) element;
            return img.repoTags().get(0);
        }
    });
    imageCmb.setInput(null);
    connCmb.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = event.getStructuredSelection();
            IDockerConnection conn = (IDockerConnection) sel.getFirstElement();
            selectedConnection = conn;
            imageCmb.setInput(conn);
            updateLaunchConfigurationDialog();
        }
    });
    imageCmb.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = event.getStructuredSelection();
            IDockerImage img = (IDockerImage) sel.getFirstElement();
            selectedImage = img;
            updateLaunchConfigurationDialog();
        }
    });
    Group dirGroup = new Group(composite, SWT.NONE);
    dirGroup.setText(Messages.JavaImageTab_additional_dirs);
    dirGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    dirGroup.setLayout(new GridLayout(2, false));
    directoryList = new List(dirGroup, SWT.SINGLE | SWT.V_SCROLL);
    directoryList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
    directoryList.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            removeButton.setEnabled(true);
        }
    });
    addButton = createPushButton(dirGroup, Messages.JavaImageTab_button_add, null);
    addButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    addButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dialog = new DirectoryDialog(getShell());
            String directory = dialog.open();
            if (directory != null && !listContains(directoryList, directory)) {
                directoryList.add(directory);
                updateLaunchConfigurationDialog();
            }
        }
    });
    removeButton = createPushButton(dirGroup, Messages.JavaImageTab_button_remove, null);
    removeButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, true));
    removeButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            int i = directoryList.getSelectionIndex();
            if (i >= 0) {
                directoryList.remove(i);
                updateLaunchConfigurationDialog();
            }
            if (directoryList.getItemCount() == 0) {
                removeButton.setEnabled(false);
            }
        }
    });
    removeButton.setEnabled(false);
    setControl(composite);
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Arrays(java.util.Arrays) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) CoreException(org.eclipse.core.runtime.CoreException) ComboViewer(org.eclipse.jface.viewers.ComboViewer) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) AbstractLaunchConfigurationTab(org.eclipse.debug.ui.AbstractLaunchConfigurationTab) Composite(org.eclipse.swt.widgets.Composite) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) DockerException(org.eclipse.linuxtools.docker.core.DockerException) GridData(org.eclipse.swt.layout.GridData) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Button(org.eclipse.swt.widgets.Button) DockerConnectionManager(org.eclipse.linuxtools.docker.core.DockerConnectionManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) Group(org.eclipse.swt.widgets.Group) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) SWT(org.eclipse.swt.SWT) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) List(org.eclipse.swt.widgets.List) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(org.eclipse.swt.widgets.List) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Aggregations

DirectoryDialog (org.eclipse.swt.widgets.DirectoryDialog)88 SelectionEvent (org.eclipse.swt.events.SelectionEvent)51 Button (org.eclipse.swt.widgets.Button)49 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)48 GridData (org.eclipse.swt.layout.GridData)48 GridLayout (org.eclipse.swt.layout.GridLayout)47 Text (org.eclipse.swt.widgets.Text)47 Composite (org.eclipse.swt.widgets.Composite)42 Label (org.eclipse.swt.widgets.Label)40 Group (org.eclipse.swt.widgets.Group)27 File (java.io.File)25 ModifyListener (org.eclipse.swt.events.ModifyListener)22 ModifyEvent (org.eclipse.swt.events.ModifyEvent)21 Combo (org.eclipse.swt.widgets.Combo)21 FileDialog (org.eclipse.swt.widgets.FileDialog)11 TableViewer (org.eclipse.jface.viewers.TableViewer)8 Table (org.eclipse.swt.widgets.Table)8 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)7 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7