Search in sources :

Example 26 with ContainerSelectionDialog

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

the class MavenPomWizardPage method handleBrowse.

/**
 * Uses the standard container selection dialog to choose the new value for the container field.
 */
void handleBrowse() {
    ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), false, Messages.MavenPomWizardPage_dialog_title);
    dialog.showClosedProjects(false);
    if (dialog.open() == Window.OK) {
        Object[] result = dialog.getResult();
        if (result.length == 1) {
            projectText.setText(((Path) result[0]).toString());
        }
    }
// IJavaModel javaModel = JavaCore.create();
// 
// IJavaProject[] projects;
// try {
// projects = javaModel.getJavaProjects();
// } catch(JavaModelException e) {
// log.error(e.getMessage(), e);
// projects = new IJavaProject[0];
// }
// 
// ILabelProvider labelProvider = new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT);
// ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
// dialog.setTitle("Select Project");
// dialog.setMessage("Choose project where POM will be created");
// dialog.setElements(projects);
// 
// String projectName = getProject();
// if(projectName != null && projectName.length() > 0) {
// IJavaProject javaProject = javaModel.getJavaProject(projectName);
// if(javaProject != null) {
// dialog.setInitialSelections(new Object[] {javaProject});
// }
// }
// 
// if(dialog.open() == Window.OK) {
// projectText.setText(((IJavaProject) dialog.getFirstResult()).getProject().getFullPath().toString());
// }
}
Also used : ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog)

Example 27 with ContainerSelectionDialog

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

the class BaseBlock method handleBrowseWorkspace.

protected void handleBrowseWorkspace() {
    ContainerSelectionDialog dialog = new ContainerSelectionDialog(fLocationText.getShell(), getContainer(), true, PDEUIMessages.BaseBlock_relative);
    if (dialog.open() == Window.OK) {
        Object[] result = dialog.getResult();
        if (result.length == 0)
            return;
        IPath path = (IPath) result[0];
        // $NON-NLS-1$ //$NON-NLS-2$
        fLocationText.setText("${workspace_loc:" + path.makeRelative().toString() + "}");
    }
}
Also used : ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog)

Example 28 with ContainerSelectionDialog

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

the class FilesetReferenceWizardFragment method browsePressed.

protected void browsePressed(Button b, Text t) {
    // show the dialog, then set the proper text
    ContainerSelectionDialog d = new ContainerSelectionDialog(b.getShell(), null, false, // $NON-NLS-1$
    "Please select a root folder");
    if (d.open() == Dialog.OK) {
        Object[] o = d.getResult();
        if (o != null && o.length > 0) {
            IPath path = (IPath) o[0];
            t.setText(path.toString());
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog)

Example 29 with ContainerSelectionDialog

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

the class ContainerChooserAdapter method invoke0.

public String invoke0(Control control) {
    String v = getStringValue(true);
    IPath p = v.length() == 0 ? null : new Path(v);
    IResource r = (p == null) ? null : ModelPlugin.getWorkspace().getRoot().findMember(p);
    IContainer c = (r instanceof IContainer) ? (IContainer) r : null;
    ContainerSelectionDialog dialog = new ContainerSelectionDialog(control.getShell(), c, false, null);
    dialog.create();
    if (dialog.open() != 0)
        return null;
    Object[] os = dialog.getResult();
    return os == null || os.length == 0 ? null : os[0].toString();
}
Also used : ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog)

Example 30 with ContainerSelectionDialog

use of org.eclipse.ui.dialogs.ContainerSelectionDialog in project uima-ruta by apache.

the class RutaMainLaunchConfigurationTab method doCreateControl.

@Override
protected void doCreateControl(Composite composite) {
    super.doCreateControl(composite);
    // Input Resource Group
    Group inputResourceGroup = new Group(composite, SWT.None);
    inputResourceGroup.setText("Input Folder:");
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(inputResourceGroup);
    GridLayout inputResourceGroupLayout = new GridLayout(4, false);
    inputResourceGroup.setLayout(inputResourceGroupLayout);
    inputFolderText = new Text(inputResourceGroup, SWT.BORDER);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(3, 1).applyTo(inputFolderText);
    inputFolderText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            updateLaunchConfigurationDialog();
        }
    });
    Button browseInputResource = new Button(inputResourceGroup, SWT.NONE);
    browseInputResource.setText("Browse ...");
    browseInputResource.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
            dialog.setTitle("Select input folder");
            dialog.setMessage("Select input folder");
            dialog.setInput(getProject().getProject());
            dialog.setInitialSelection(getWorkspaceRoot().findMember(inputFolderText.getText()));
            if (dialog.open() == IDialogConstants.OK_ID) {
                IResource resource = (IResource) dialog.getFirstResult();
                if (resource != null) {
                    String fileLoc = resource.getFullPath().toString();
                    inputFolderText.setText(fileLoc);
                }
            }
        }
    });
    recursivelyButton = new Button(inputResourceGroup, SWT.CHECK);
    recursivelyButton.setText("Recursively");
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(recursivelyButton);
    recursivelyButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent event) {
            updateLaunchConfigurationDialog();
        }

        public void widgetDefaultSelected(SelectionEvent event) {
        }
    });
    Label viewLabel = new Label(inputResourceGroup, SWT.NONE);
    viewLabel.setText("View Name:");
    viewText = new Text(inputResourceGroup, SWT.BORDER);
    GridDataFactory.swtDefaults().hint(250, SWT.DEFAULT).align(SWT.LEFT, SWT.CENTER).grab(true, false).applyTo(viewText);
    viewText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            updateLaunchConfigurationDialog();
        }
    });
    Group outputFolderGroup = new Group(composite, SWT.None);
    outputFolderGroup.setText("Output Folder:");
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(outputFolderGroup);
    GridLayout outputFolderGroupLayout = new GridLayout(2, false);
    outputFolderGroup.setLayout(outputFolderGroupLayout);
    outputFolderText = new Text(outputFolderGroup, SWT.BORDER);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(outputFolderText);
    outputFolderText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            updateLaunchConfigurationDialog();
        }
    });
    Button browseOutputFolderButton = new Button(outputFolderGroup, SWT.NONE);
    browseOutputFolderButton.setText("Browse ...");
    browseOutputFolderButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            String currentContainerString = outputFolderText.getText();
            IContainer currentContainer = getContainer(currentContainerString);
            ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), currentContainer, false, "Select output folder");
            dialog.showClosedProjects(false);
            dialog.open();
            Object[] results = dialog.getResult();
            if ((results != null) && (results.length > 0) && (results[0] instanceof IPath)) {
                IPath path = (IPath) results[0];
                String containerName = path.toOSString();
                outputFolderText.setText(containerName);
            }
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) ModifyListener(org.eclipse.swt.events.ModifyListener) IPath(org.eclipse.core.runtime.IPath) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource) SelectionListener(org.eclipse.swt.events.SelectionListener)

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