Search in sources :

Example 86 with FileDialog

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

the class ContainerDataVolumeDialog method onHostFilePath.

private SelectionListener onHostFilePath() {
    return SelectionListener.widgetSelectedAdapter(e -> {
        final FileDialog fileDialog = new FileDialog(getShell());
        final String selectedPath = fileDialog.open();
        if (selectedPath != null) {
            model.setHostPathMount(selectedPath);
        }
    });
}
Also used : FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 87 with FileDialog

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

the class GprofNoGmonDialog method browseFileSystemHandler.

/**
 * Browse file sytem to find gmon.out. Return null if bad input.
 */
private static String browseFileSystemHandler(Shell shell, IProject project) {
    FileDialog dialog = new FileDialog((shell != null) ? shell : new Shell(), SWT.OPEN);
    dialog.setText(GprofLaunchMessages.GprofNoGmonDialog_OpenGmon);
    // Open Project path.
    if (project != null) {
        dialog.setFilterPath(project.getLocation().toOSString());
    }
    // 
    return dialog.open();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 88 with FileDialog

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

the class OpenGmonDialog method handleBrowse.

private void handleBrowse(String msg, Text text) {
    FileDialog dialog = new FileDialog(this.getShell(), SWT.OPEN);
    dialog.setText(msg);
    String t = text.getText();
    IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager();
    try {
        t = mgr.performStringSubstitution(t, false);
    } catch (CoreException e) {
    // do nothing: never occurs
    }
    File f = new File(t);
    t = f.getParent();
    if (t == null || t.length() == 0) {
        t = this.gmonFile.removeLastSegments(1).toOSString();
    }
    dialog.setFilterPath(t);
    String s = dialog.open();
    if (s != null) {
        text.setText(s);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IStringVariableManager(org.eclipse.core.variables.IStringVariableManager) FileDialog(org.eclipse.swt.widgets.FileDialog) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 89 with FileDialog

use of org.eclipse.swt.widgets.FileDialog in project knime-core by knime.

the class ExportPreferencesDialog method createFileSelection.

protected void createFileSelection(final Composite parent) {
    Composite panel = new Composite(parent, SWT.FILL);
    GridData fillBoth = new GridData(GridData.FILL_BOTH);
    panel.setLayoutData(fillBoth);
    panel.setLayout(new GridLayout(1, true));
    Group border = new Group(panel, SWT.SHADOW_IN);
    border.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    border.setLayout(new GridLayout(2, false));
    border.setText("File to store preferences:");
    final Text filenameUI = new Text(border, SWT.FILL | SWT.SINGLE | SWT.BORDER);
    filenameUI.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    filenameUI.addListener(SWT.Modify, new Listener() {

        @Override
        public void handleEvent(final Event event) {
            m_filename = filenameUI.getText().trim();
            validate();
        }
    });
    final Button browse = new Button(border, SWT.PUSH);
    browse.setText("Select...");
    browse.setToolTipText("Opens a file selection dialog.");
    browse.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(final SelectionEvent se) {
            FileDialog fileDialog = new FileDialog(getShell(), SWT.SAVE);
            fileDialog.setFilterExtensions(new String[] { "*.epf", "*.*" });
            fileDialog.setText("Specify the preferences export file.");
            if (m_filename != null) {
                fileDialog.setFileName(m_filename);
            }
            String filePath = fileDialog.open();
            if (filePath != null && filePath.trim().length() > 0) {
                if (filePath.length() < 5 || filePath.lastIndexOf('.') < filePath.length() - 4) {
                    // they have no extension - add .epf
                    filePath += ".epf";
                }
                m_filename = filePath;
                filenameUI.setText(filePath);
                validate();
            }
        }

        @Override
        public void widgetDefaultSelected(final SelectionEvent se) {
            widgetSelected(se);
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) Listener(org.eclipse.swt.widgets.Listener) SelectionListener(org.eclipse.swt.events.SelectionListener) Composite(org.eclipse.swt.widgets.Composite) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FileDialog(org.eclipse.swt.widgets.FileDialog) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 90 with FileDialog

use of org.eclipse.swt.widgets.FileDialog in project knime-core by knime.

the class WorkflowExportPage method handleExportFileBrowse.

/**
 * Uses the standard file selection dialog to choose the export file name.
 */
private void handleExportFileBrowse() {
    FileDialog fileDialog = new FileDialog(getShell(), SWT.SAVE);
    fileDialog.setFilterExtensions(FILTER_EXTENSION);
    fileDialog.setText("Specify export file.");
    if (m_fileText.getText() != null && !m_fileText.getText().trim().isEmpty()) {
        String exportString = m_fileText.getText().trim();
        IPath p = new Path(exportString);
        if (p.segmentCount() > 1) {
            fileDialog.setFilterPath(p.removeLastSegments(1).toOSString());
            fileDialog.setFileName(p.lastSegment());
        }
    }
    String filePath = fileDialog.open();
    if (filePath.trim().length() > 0) {
        // remember the selected path
        // append "zip" extension if not there.
        String extension = filePath.substring(filePath.length() - 4, filePath.length());
        if (!extension.equals(".zip")) {
            filePath = filePath + ".zip";
        }
    }
    m_fileText.setText(filePath);
    setLastSelectedExportLocation();
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) FileDialog(org.eclipse.swt.widgets.FileDialog)

Aggregations

FileDialog (org.eclipse.swt.widgets.FileDialog)512 File (java.io.File)198 SelectionEvent (org.eclipse.swt.events.SelectionEvent)181 Button (org.eclipse.swt.widgets.Button)181 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)160 Label (org.eclipse.swt.widgets.Label)153 Text (org.eclipse.swt.widgets.Text)151 Composite (org.eclipse.swt.widgets.Composite)136 Shell (org.eclipse.swt.widgets.Shell)120 GridData (org.eclipse.swt.layout.GridData)110 ModifyListener (org.eclipse.swt.events.ModifyListener)109 ModifyEvent (org.eclipse.swt.events.ModifyEvent)107 GridLayout (org.eclipse.swt.layout.GridLayout)105 Group (org.eclipse.swt.widgets.Group)90 Event (org.eclipse.swt.widgets.Event)76 Listener (org.eclipse.swt.widgets.Listener)76 Display (org.eclipse.swt.widgets.Display)72 FormAttachment (org.eclipse.swt.layout.FormAttachment)68 FormData (org.eclipse.swt.layout.FormData)68 FormLayout (org.eclipse.swt.layout.FormLayout)68