Search in sources :

Example 31 with DirectoryDialog

use of org.eclipse.swt.widgets.DirectoryDialog in project sling by apache.

the class ChooseArchetypeWizardPage method createControl.

@Override
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 3;
    layout.verticalSpacing = 9;
    useDefaultWorkspaceLocationButton = new Button(container, SWT.CHECK);
    GridData useDefaultWorkspaceLocationButtonData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1);
    useDefaultWorkspaceLocationButton.setLayoutData(useDefaultWorkspaceLocationButtonData);
    useDefaultWorkspaceLocationButton.setText("Use default Workspace location");
    useDefaultWorkspaceLocationButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean inWorkspace = useDefaultWorkspaceLocationButton.getSelection();
            locationLabel.setEnabled(!inWorkspace);
            locationCombo.setEnabled(!inWorkspace);
            dialogChanged();
        }
    });
    useDefaultWorkspaceLocationButton.setSelection(true);
    locationLabel = new Label(container, SWT.NONE);
    GridData locationLabelData = new GridData();
    locationLabelData.horizontalIndent = 10;
    locationLabel.setLayoutData(locationLabelData);
    locationLabel.setText("Location:");
    locationLabel.setEnabled(false);
    locationCombo = new Combo(container, SWT.NONE);
    GridData locationComboData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    locationCombo.setLayoutData(locationComboData);
    locationCombo.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });
    locationCombo.setEnabled(false);
    Button locationBrowseButton = new Button(container, SWT.NONE);
    GridData locationBrowseButtonData = new GridData(SWT.FILL, SWT.CENTER, false, false);
    locationBrowseButton.setLayoutData(locationBrowseButtonData);
    locationBrowseButton.setText("Browse...");
    locationBrowseButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dialog = new DirectoryDialog(getShell());
            dialog.setText("Select Location");
            String path = locationCombo.getText();
            if (path.length() == 0) {
                path = ResourcesPlugin.getWorkspace().getRoot().getLocation().toPortableString();
            }
            dialog.setFilterPath(path);
            String selectedDir = dialog.open();
            if (selectedDir != null) {
                locationCombo.setText(selectedDir);
                useDefaultWorkspaceLocationButton.setSelection(false);
                dialogChanged();
            }
        }
    });
    Label label = new Label(container, SWT.NULL);
    label.setText("&Archetype:");
    knownArchetypes = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    knownArchetypes.setLayoutData(gd);
    knownArchetypes.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            dialogChanged();
        }
    });
    knownArchetypes.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            getContainer().showPage(getNextPage());
        }
    });
    setPageComplete(false);
    MavenPlugin.getIndexManager().addIndexListener(this);
    setControl(container);
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 32 with DirectoryDialog

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

the class ImportBndWorkspaceWizardPageOne method createControl.

@Override
public void createControl(final Composite parent) {
    final Composite container = new Composite(parent, SWT.NONE);
    Label lblFolder = new Label(container, SWT.NONE);
    lblFolder.setText("Root Directory:");
    txtFolder = new Text(container, SWT.BORDER | SWT.SINGLE);
    txtFolder.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent event) {
            getWizard().getContainer().updateButtons();
        }
    });
    //Adding the decorator
    txtFolderErrorDecorator = new ControlDecoration(txtFolder, SWT.TOP | SWT.RIGHT);
    FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
    Image img = fieldDecoration.getImage();
    txtFolderErrorDecorator.setImage(img);
    txtFolderErrorDecorator.setDescriptionText("Selected folder must contain valid Bnd Workspace configuration project.");
    // hiding it initially
    txtFolderErrorDecorator.hide();
    Button btnOpenDialog = new Button(container, SWT.PUSH);
    btnOpenDialog.setText("Browse...");
    btnOpenDialog.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            DirectoryDialog dirDialog = new DirectoryDialog(container.getShell());
            dirDialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
            dirDialog.setText("Select the folder containing the project.");
            txtFolder.setText(dirDialog.open());
            getWizard().getContainer().updateButtons();
        }
    });
    Label lblProjects = new Label(container, SWT.NONE);
    lblProjects.setText("Projects:");
    tableViewer = new TableViewer(container, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    tableViewer.setContentProvider(ArrayContentProvider.getInstance());
    tableViewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            // configuration project always first
            if (e1 instanceof File && e2 instanceof Project) {
                return -1;
            } else if (e1 instanceof Project && e2 instanceof File) {
                return 1;
            }
            Project p1 = (Project) e1;
            Project p2 = (Project) e2;
            return super.compare(viewer, p1.getName(), p2.getName());
        }
    });
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            // Disable selection since the tableviewer should be readonly, but not disabled
            if (!event.getSelection().isEmpty()) {
                tableViewer.setSelection(StructuredSelection.EMPTY);
            }
        }
    });
    TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.NONE);
    column.setLabelProvider(new ProjectsColumnLabelProvider());
    Button refreshButton = new Button(container, SWT.PUSH);
    refreshButton.setText("Refresh");
    refreshButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            getWizard().getContainer().updateButtons();
        }
    });
    deleteButton = new Button(container, SWT.CHECK);
    deleteButton.setText("Delete existing settings");
    inferExecutionEnvironmentButton = new Button(container, SWT.CHECK);
    inferExecutionEnvironmentButton.setSelection(true);
    inferExecutionEnvironmentButton.setText("Infer execution-environment (J2SE and JavaSE).");
    inferExecutionEnvironmentButton.setToolTipText("Uses the 'javac.target' from the Bnd Workspace to infer a Execution Environment to the JRE container. If nothing matches, the default JRE will be used.\nExisting containers will be removed.");
    FormLayout layout = new FormLayout();
    container.setLayout(layout);
    FormData fd_lblFolder = new FormData();
    fd_lblFolder.top = new FormAttachment(0, 10);
    fd_lblFolder.left = new FormAttachment(0, 10);
    lblFolder.setLayoutData(fd_lblFolder);
    FormData fd_txtFolder = new FormData();
    fd_txtFolder.top = new FormAttachment(lblFolder, 0, SWT.CENTER);
    fd_txtFolder.left = new FormAttachment(lblFolder, 10);
    fd_txtFolder.right = new FormAttachment(100, -100);
    txtFolder.setLayoutData(fd_txtFolder);
    FormData fd_btnDialog = new FormData();
    fd_btnDialog.top = new FormAttachment(lblFolder, 0, SWT.CENTER);
    fd_btnDialog.left = new FormAttachment(txtFolder, 10);
    fd_btnDialog.right = new FormAttachment(100, -10);
    btnOpenDialog.setLayoutData(fd_btnDialog);
    FormData fd_lblProjects = new FormData();
    fd_lblProjects.top = new FormAttachment(lblFolder, 20);
    fd_lblProjects.left = new FormAttachment(lblFolder, 0, SWT.LEFT);
    lblProjects.setLayoutData(fd_lblProjects);
    FormData fd_table = new FormData();
    fd_table.top = new FormAttachment(lblProjects, 5);
    fd_table.left = new FormAttachment(lblFolder, 0, SWT.LEFT);
    fd_table.right = new FormAttachment(100, -100);
    fd_table.bottom = new FormAttachment(100, -55);
    tableViewer.getTable().setLayoutData(fd_table);
    FormData fd_btnRefresh = new FormData();
    fd_btnRefresh.top = new FormAttachment(tableViewer.getTable(), 0, SWT.TOP);
    fd_btnRefresh.left = new FormAttachment(btnOpenDialog, 0, SWT.LEFT);
    fd_btnRefresh.right = new FormAttachment(100, -10);
    refreshButton.setLayoutData(fd_btnRefresh);
    FormData fd_btnDelete = new FormData();
    fd_btnDelete.top = new FormAttachment(tableViewer.getTable(), 10);
    fd_btnDelete.left = new FormAttachment(lblFolder, 0, SWT.LEFT);
    deleteButton.setLayoutData(fd_btnDelete);
    FormData fd_btnInfer = new FormData();
    fd_btnInfer.top = new FormAttachment(deleteButton, 10);
    fd_btnInfer.left = new FormAttachment(lblFolder, 0, SWT.LEFT);
    inferExecutionEnvironmentButton.setLayoutData(fd_btnInfer);
    getShell().setMinimumSize(470, 450);
    // required to avoid an error in the system
    setControl(parent);
    setPageComplete(false);
    txtFolder.setText(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) Label(org.eclipse.swt.widgets.Label) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Image(org.eclipse.swt.graphics.Image) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) FormAttachment(org.eclipse.swt.layout.FormAttachment) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Text(org.eclipse.swt.widgets.Text) IProject(org.eclipse.core.resources.IProject) Project(aQute.bnd.build.Project) TableViewer(org.eclipse.jface.viewers.TableViewer) File(java.io.File)

Example 33 with DirectoryDialog

use of org.eclipse.swt.widgets.DirectoryDialog in project azure-tools-for-java by Microsoft.

the class SrvPriSettingsDialog method createDialogArea.

/**
     * Create contents of the dialog.
     * @param parent
     */
@Override
protected Control createDialogArea(Composite parent) {
    setTitle("Create Authentication Files");
    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(GridData.FILL_BOTH));
    Label lblInfo = new Label(container, SWT.WRAP);
    GridData gd_lblInfo = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
    gd_lblInfo.heightHint = 82;
    lblInfo.setLayoutData(gd_lblInfo);
    lblInfo.setText("A new Active Directory service principal representing this IDE will be created as needed and as allowed by your access permissions.\nThe service principal will be granted Contributor-level access to each selected subscription.");
    Label lblNewLabel = new Label(container, SWT.NONE);
    lblNewLabel.setEnabled(true);
    lblNewLabel.setText("Select the subscriptions to create credentials for:");
    table = new Table(container, SWT.BORDER | SWT.CHECK | SWT.FULL_SELECTION);
    table.setEnabled(true);
    GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_table.heightHint = 300;
    table.setLayoutData(gd_table);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableColumn tblclmnSubscriptionName = new TableColumn(table, SWT.NONE);
    tblclmnSubscriptionName.setWidth(250);
    tblclmnSubscriptionName.setText("Subscription Name");
    TableColumn tblclmnSubscriptionId = new TableColumn(table, SWT.NONE);
    tblclmnSubscriptionId.setWidth(300);
    tblclmnSubscriptionId.setText("Subscription ID");
    for (SubscriptionDetail sd : sdl) {
        TableItem item = new TableItem(table, SWT.NULL);
        item.setText(new String[] { sd.getSubscriptionName(), sd.getSubscriptionId() });
        item.setChecked(sd.isSelected());
    }
    Group grpDestinationFolder = new Group(container, SWT.NONE);
    grpDestinationFolder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    grpDestinationFolder.setText("Destination folder:");
    grpDestinationFolder.setLayout(new GridLayout(2, false));
    textDestinationFolderPath = new Text(grpDestinationFolder, SWT.BORDER | SWT.READ_ONLY);
    textDestinationFolderPath.setEditable(false);
    textDestinationFolderPath.setEnabled(true);
    textDestinationFolderPath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    String initDirPath = System.getProperty("user.home");
    textDestinationFolderPath.setText(initDirPath);
    dirDialog = new DirectoryDialog(this.getShell());
    dirDialog.setFilterPath(initDirPath);
    dirDialog.setText("Select Destination Folder");
    Button btnBrowse = new Button(grpDestinationFolder, SWT.NONE);
    btnBrowse.setEnabled(true);
    btnBrowse.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            String path = dirDialog.open();
            if (path == null)
                return;
            textDestinationFolderPath.setText(path);
        }
    });
    btnBrowse.setText("...");
    return area;
}
Also used : Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) TableItem(org.eclipse.swt.widgets.TableItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 34 with DirectoryDialog

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

the class BuildDockerImageLaunchConfigurationMainTab 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);
            buildContextPathWorkspaceRelative = false;
        }
    });
}
Also used : DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 35 with DirectoryDialog

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

the class NewDockerConnectionPage method onBrowseTcpCertPath.

private SelectionListener onBrowseTcpCertPath() {
    return SelectionListener.widgetSelectedAdapter(e -> {
        final DirectoryDialog directoryDialog = new DirectoryDialog(getShell());
        directoryDialog.setFilterPath(model.getTcpCertPath());
        final String selectedPath = directoryDialog.open();
        if (selectedPath != null) {
            model.setTcpCertPath(selectedPath);
        }
    });
}
Also used : 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