Search in sources :

Example 21 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 22 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 23 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 24 with FileDialog

use of org.eclipse.swt.widgets.FileDialog in project GT by Tencent.

the class SMAPSView method makeActions.

/**
	 * 初始化各种Action
	 */
private void makeActions() {
    openLogAction = new Action() {

        public void run() {
            FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.OPEN);
            //设置初始路径
            dialog.setFilterPath(Constant.SMAPS_LOG_PATH_ON_PC);
            //返回的全路径(路径+文件名)
            String fileName = dialog.open();
            if (fileName == null) {
                return;
            }
            Object smapsdata = SmapsUtil.getSmapsShowDataFromFile(fileName);
            if (smapsdata == null) {
                APTConsoleFactory.getInstance().APTPrint(Constant.APTCONSOLE_LOG_TAGS[Constant.APTCONSOLE_LOG_TAG_ERR] + "解析smaps文件失败");
                MessageDialog.openInformation(Display.getDefault().getActiveShell(), "提示", "解析smaps文件失败");
                return;
            }
            openSmapsDataInSMAPSView(smapsdata, fileName);
        }
    };
    openLogAction.setText("打开smaps文件");
    openLogAction.setToolTipText("打开smaps文件");
    openLogAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/open_pc.png"));
}
Also used : Action(org.eclipse.jface.action.Action) FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 25 with FileDialog

use of org.eclipse.swt.widgets.FileDialog in project GT by Tencent.

the class PMAPView method makeActions.

/**
	 * 初始化Action
	 */
private void makeActions() {
    openLogAction = new Action() {

        public void run() {
            FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.OPEN | SWT.MULTI);
            //设置初始路径
            dialog.setFilterPath(Constant.LOG_FOLDER_ON_PC);
            //返回的全路径(路径+文件名)
            String fileName = dialog.open();
            if (fileName == null) {
                return;
            }
            String path = dialog.getFilterPath();
            String[] fileNames = dialog.getFileNames();
            int fileNum = fileNames.length;
            if (fileNum > 2) {
                MessageDialog.openInformation(Display.getDefault().getActiveShell(), "提示", "不支持同时打开超过2个pmap文件");
                return;
            }
            PMAPFileParse parse = new PMAPFileParse();
            if (fileNum == 1) {
                Map<String, Integer> pmapResult = null;
                if ((pmapResult = parse.parse(fileName)) == null) {
                    return;
                }
                createCTabItem(fileNames[0], pmapResult);
            } else {
                String file1 = path + File.separator + fileNames[0];
                String file2 = path + File.separator + fileNames[1];
                Map<String, Integer> file1Map = parse.parse(file1);
                Map<String, Integer> file2Map = parse.parse(file2);
                if (file1Map == null || file2Map == null) {
                    return;
                }
                Map<String, Integer> pmapResult = MapUtil.sub(file2Map, file1Map);
                createCTabItem(fileNames[0], file1Map);
                createCTabItem(fileNames[1], file2Map);
                createCTabItem(getMergeFileName(fileNames[0], fileNames[1]), pmapResult);
            }
        }
    };
    openLogAction.setText("打开pmap文件");
    openLogAction.setToolTipText("打开pmap文件");
    openLogAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/open_pc.png"));
}
Also used : Action(org.eclipse.jface.action.Action) FileDialog(org.eclipse.swt.widgets.FileDialog) PMAPFileParse(com.tencent.wstt.apt.util.PMAPFileParse) Map(java.util.Map)

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