Search in sources :

Example 26 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 27 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 28 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 29 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 30 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)214 File (java.io.File)91 Button (org.eclipse.swt.widgets.Button)61 SelectionEvent (org.eclipse.swt.events.SelectionEvent)58 GridLayout (org.eclipse.swt.layout.GridLayout)57 GridData (org.eclipse.swt.layout.GridData)56 Composite (org.eclipse.swt.widgets.Composite)55 Text (org.eclipse.swt.widgets.Text)50 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)48 Label (org.eclipse.swt.widgets.Label)47 IOException (java.io.IOException)31 Group (org.eclipse.swt.widgets.Group)24 Shell (org.eclipse.swt.widgets.Shell)23 ModifyListener (org.eclipse.swt.events.ModifyListener)21 ArrayList (java.util.ArrayList)19 ModifyEvent (org.eclipse.swt.events.ModifyEvent)19 IPath (org.eclipse.core.runtime.IPath)18 Path (org.eclipse.core.runtime.Path)16 Combo (org.eclipse.swt.widgets.Combo)16 SelectionListener (org.eclipse.swt.events.SelectionListener)15