Search in sources :

Example 1 with FileDialog

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

the class DefaultInteraction method selectFile.

public File selectFile(boolean forInput, String def, String[] allowedExtensions) {
    FileDialog dialog = selectFileName(forInput ? SWT.OPEN : SWT.SAVE, new String[] { "XML Files (*.xml)" }, allowedExtensions, def);
    if (dialog == null) {
        return null;
    }
    File path = new File(dialog.getFilterPath());
    return new File(path, dialog.getFileName());
}
Also used : FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File)

Example 2 with FileDialog

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

the class DefaultInteraction method selectCSVFileDest.

/**
     * A file selection dialog for selecting .csv files
     * to write to.
     */
public File selectCSVFileDest(String defaultFileName) {
    FileDialog dialog = selectFileName(SWT.SAVE, new String[] { "CSV Files (*.csv)" }, new String[] { "*.csv" }, (defaultFileName + ".csv"));
    if (dialog == null) {
        setStatusMessage(exportCanceledMsg);
        return null;
    }
    File path = new File(dialog.getFilterPath());
    String name = dialog.getFileName();
    if (!name.endsWith(".csv")) {
        name += ".csv";
    }
    File dest = new File(path, name);
    if (dest.exists() && OSUtils.WINDOWS) {
        int choice = shouldReplaceFile(dest);
        if (choice == SWT.NO) {
            return selectCSVFileDest(defaultFileName);
        }
        if (choice == SWT.CANCEL) {
            setStatusMessage(exportCanceledMsg);
            return null;
        }
    }
    return dest;
}
Also used : FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File)

Example 3 with FileDialog

use of org.eclipse.swt.widgets.FileDialog in project otertool by wuntee.

the class GuiWorkshop method selectFile.

public static String selectFile(Shell shell, String[] filters) {
    FileDialog fileDialog = new FileDialog(shell);
    fileDialog.setText("Please select a file");
    fileDialog.setFilterExtensions(filters);
    return (fileDialog.open());
}
Also used : FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 4 with FileDialog

use of org.eclipse.swt.widgets.FileDialog in project otertool by wuntee.

the class GuiWorkshop method selectSaveFile.

public static String selectSaveFile(Shell shell, String[] filters) {
    FileDialog fileDialog = new FileDialog(shell, SWT.SAVE);
    fileDialog.setText("Please select a file");
    fileDialog.setFilterExtensions(filters);
    return (fileDialog.open());
}
Also used : FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 5 with FileDialog

use of org.eclipse.swt.widgets.FileDialog in project tdi-studio-se by Talend.

the class ImportItemWizardPage method handleLocationArchiveButtonPressed.

/**
     * The browse button has been selected. Select the location.
     */
protected void handleLocationArchiveButtonPressed() {
    FileDialog dialog = new FileDialog(archivePathField.getShell());
    dialog.setFilterExtensions(FILE_IMPORT_MASK);
    // dialog.setText(DataTransferMessages.WizardProjectsImportPage_SelectArchiveDialogTitle);
    //$NON-NLS-1$
    dialog.setText(Messages.getString(".WizardProjectsImportPage_SelectArchiveDialogTitle"));
    String fileName = archivePathField.getText().trim();
    if (fileName.length() == 0) {
        fileName = previouslyBrowsedArchive;
    }
    if (fileName.length() == 0) {
        dialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
    } else {
        File path = new File(fileName);
        if (path.exists()) {
            dialog.setFilterPath(new Path(fileName).toOSString());
        }
    }
    String selectedArchive = dialog.open();
    if (selectedArchive != null) {
        previouslyBrowsedArchive = selectedArchive;
        archivePathField.setText(previouslyBrowsedArchive);
        updateItemsList(selectedArchive, false);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) FileDialog(org.eclipse.swt.widgets.FileDialog) ZipFile(java.util.zip.ZipFile) TarFile(org.eclipse.ui.internal.wizards.datatransfer.TarFile) File(java.io.File)

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