Search in sources :

Example 16 with FileDialog

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

the class RTFCleanerDialog method handleFile.

/**
	 * 处理 RTF 文件 ;
	 */
private void handleFile() {
    FileDialog dialog = new FileDialog(getShell(), SWT.MULTI);
    dialog.setText(Messages.getString("dialog.RTFCleanerDialog.dialogTitle"));
    String[] extensions = { "*.rtf", "*" };
    String[] filters = { Messages.getString("dialog.RTFCleanerDialog.filters1"), Messages.getString("dialog.RTFCleanerDialog.filters2") };
    dialog.setFilterExtensions(extensions);
    dialog.setFilterNames(filters);
    dialog.setFilterPath(System.getProperty("user.home"));
    dialog.open();
    String[] arrSource = dialog.getFileNames();
    if (arrSource == null || arrSource.length == 0) {
        return;
    }
    int errors = 0;
    for (int i = 0; i < arrSource.length; i++) {
        //$NON-NLS-1$
        File f = new File(dialog.getFilterPath() + System.getProperty("file.separator") + arrSource[i]);
        Hashtable<String, String> params = new Hashtable<String, String>();
        //$NON-NLS-1$
        params.put("source", f.getAbsolutePath());
        //$NON-NLS-1$
        params.put("output", f.getAbsolutePath());
        Vector<String> result = RTFCleaner.run(params);
        if (!"0".equals(result.get(0))) {
            //$NON-NLS-1$
            String msg = MessageFormat.format(Messages.getString("dialog.RTFCleanerDialog.msg1"), arrSource[i]) + (String) result.get(1);
            MessageDialog.openInformation(getShell(), Messages.getString("dialog.RTFCleanerDialog.msgTitle"), msg);
            errors++;
        }
    }
    if (errors < arrSource.length) {
        MessageDialog.openInformation(getShell(), Messages.getString("dialog.RTFCleanerDialog.msgTitle"), Messages.getString("dialog.RTFCleanerDialog.msg2"));
    }
}
Also used : Hashtable(java.util.Hashtable) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File)

Example 17 with FileDialog

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

the class PluginHelpDialog method openFile.

private void openFile() {
    FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN);
    String[] extensions = { "*.xml", "*.*" };
    String[] filterNames = { Messages.getString("dialog.PluginHelpDialog.filterNames0"), Messages.getString("dialog.PluginHelpDialog.filterNames1") };
    fileDialog.setFilterExtensions(extensions);
    fileDialog.setFilterNames(filterNames);
    fileDialog.setFilterPath(System.getProperty("user.home"));
    String name = fileDialog.open();
    if (name == null) {
        return;
    }
    File file = new File(name);
    getShell().setText(file.getName());
    loadTree(file.getAbsolutePath());
}
Also used : FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File)

Example 18 with FileDialog

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

the class TMX2TXTConverterDialog method selecteTMXFile.

/**
	 * 选择TMX文件
	 */
private void selecteTMXFile() {
    FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
    String[] extensions = { "*.tmx", "*.*" };
    fd.setFilterExtensions(extensions);
    String[] names = { Messages.getString("dialog.TMX2TXTConverterDialog.TMXNames1"), Messages.getString("dialog.TMX2TXTConverterDialog.TMXNames2") };
    fd.setFilterNames(names);
    String file = fd.open();
    if (file != null) {
        tmxTxt.setText(file);
        if (txtTxt.getText().equals("")) {
            txtTxt.setText(file.substring(0, file.lastIndexOf(".")) + ".txt");
        }
    }
}
Also used : FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 19 with FileDialog

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

the class TMX2TXTConverterDialog method selecteTXTFile.

/**
	 * 选择TXT文件 ;
	 */
private void selecteTXTFile() {
    FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
    String[] extensions = { "*.txt", "*.*" };
    fd.setFilterExtensions(extensions);
    String[] names = { Messages.getString("dialog.TMX2TXTConverterDialog.TXTNames1"), Messages.getString("dialog.TMX2TXTConverterDialog.TXTNames2") };
    fd.setFilterNames(names);
    String file = fd.open();
    if (file != null) {
        txtTxt.setText(file);
    }
}
Also used : FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 20 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)

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