Search in sources :

Example 61 with FileDialog

use of org.eclipse.swt.widgets.FileDialog in project translationstudio8 by heartsome.

the class TMXValidatorDialog method openFile.

/**
	 * 打开文件
	 */
private void openFile() {
    FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
    //$NON-NLS-1$ //$NON-NLS-2$
    String[] extensions = { "*.tmx", "*.*" };
    fd.setFilterExtensions(extensions);
    String[] names = { Messages.getString("dialog.TMXValidatorDialog.names1"), Messages.getString("dialog.TMXValidatorDialog.names2") };
    fd.setFilterNames(names);
    String name = fd.open();
    if (name != null) {
        validate(name);
    }
}
Also used : FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 62 with FileDialog

use of org.eclipse.swt.widgets.FileDialog in project translationstudio8 by heartsome.

the class TMXValidatorDialog method cleanCharacters.

private void cleanCharacters() {
    FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
    //$NON-NLS-1$ //$NON-NLS-2$
    String[] extensions = { "*.tmx", "*.*" };
    fd.setFilterExtensions(extensions);
    String[] names = { Messages.getString("dialog.TMXValidatorDialog.names1"), Messages.getString("dialog.TMXValidatorDialog.names2") };
    fd.setFilterNames(names);
    String name = fd.open();
    if (name != null) {
        red = Display.getDefault().getSystemColor(SWT.COLOR_RED);
        styledText.setText("");
        styledText.append(Messages.getString("dialog.TMXValidatorDialog.styledText1"));
        getShell().setCursor(cursorWait);
        try {
        } catch (Exception e) {
            LOGGER.error("", e);
            String errorTip = e.getMessage();
            if (errorTip == null) {
                errorTip = MessageFormat.format(Messages.getString("dialog.TMXValidatorDialog.msg1"), name);
            }
            StyleRange range = new StyleRange(styledText.getText().length(), errorTip.length(), red, null);
            styledText.append(errorTip);
            styledText.setStyleRange(range);
        }
        styledText.append(Messages.getString("dialog.TMXValidatorDialog.styledText2"));
        getShell().setCursor(cursorArrow);
    }
}
Also used : StyleRange(org.eclipse.swt.custom.StyleRange) FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 63 with FileDialog

use of org.eclipse.swt.widgets.FileDialog in project translationstudio8 by heartsome.

the class ExportToExcelCommandHandler method getOutputStream.

/**
	 * Override this to plugin custom OutputStream.
	 */
protected OutputStream getOutputStream(ExportToExcelCommand command) throws IOException {
    FileDialog dialog = new FileDialog(command.getShell(), SWT.SAVE);
    dialog.setFilterPath("/");
    dialog.setOverwrite(true);
    dialog.setFileName("table_export.xls");
    dialog.setFilterExtensions(new String[] { "Microsoft Office Excel Workbook(.xls)" });
    String fileName = dialog.open();
    if (fileName == null) {
        return null;
    }
    return new PrintStream(fileName);
}
Also used : PrintStream(java.io.PrintStream) FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 64 with FileDialog

use of org.eclipse.swt.widgets.FileDialog in project translationstudio8 by heartsome.

the class ImportProjectWizardPage2 method handleBrowseBtnPressed.

protected void handleBrowseBtnPressed() {
    FileDialog dialog = new FileDialog(filePathTxt.getShell(), SWT.SHEET);
    dialog.setFilterExtensions(FILE_IMPORT_MASK);
    dialog.setText(Messages.getString("importProjectWizardPage.SelectArchiveDialogTitle"));
    String fileName = filePathTxt.getText().trim();
    if (fileName.length() == 0) {
        fileName = previouslyBrowsedPath;
    }
    if (fileName.length() == 0) {
        // IDEWorkbenchPlugin.getPluginWorkspace()
        dialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
    } else {
        File path = new File(fileName).getParentFile();
        if (path != null && path.exists()) {
            dialog.setFilterPath(path.toString());
        }
    }
    String selectedArchive = dialog.open();
    if (selectedArchive != null) {
        previouslyBrowsedPath = selectedArchive;
        filePathTxt.setText(previouslyBrowsedPath);
        // 先择新的项目包时,清除重复树中的所有内容
        checkedRepeatElementMap.clear();
        repeatElementTree.refresh(true);
        updateProjectsList(selectedArchive);
        // 初始化时全部初始化
        selectElementTree.expandAll();
        selectElementTreeBtnSelectFunction(true);
    }
}
Also used : FileDialog(org.eclipse.swt.widgets.FileDialog) ZipFile(java.util.zip.ZipFile) TarFile(org.eclipse.ui.internal.wizards.datatransfer.TarFile) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 65 with FileDialog

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

the class AddressBook method saveAs.

private boolean saveAs() {
    FileDialog saveDialog = new FileDialog(shell, SWT.SAVE);
    saveDialog.setFilterExtensions(new String[] { "*.adr;", "*.*" });
    saveDialog.setFilterNames(new String[] { "Address Books (*.adr)", "All Files " });
    saveDialog.open();
    String name = saveDialog.getFileName();
    if (name.isEmpty())
        return false;
    if (name.indexOf(".adr") != name.length() - 4) {
        name += ".adr";
    }
    File file = new File(saveDialog.getFilterPath(), name);
    if (file.exists()) {
        MessageBox box = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO);
        box.setText(resAddressBook.getString("Save_as_title"));
        box.setMessage(resAddressBook.getString("File") + file.getName() + " " + resAddressBook.getString("Query_overwrite"));
        if (box.open() != SWT.YES) {
            return false;
        }
    }
    this.file = file;
    return save();
}
Also used : FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) MessageBox(org.eclipse.swt.widgets.MessageBox)

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