Search in sources :

Example 41 with IDialogSettings

use of org.eclipse.jface.dialogs.IDialogSettings in project cubrid-manager by CUBRID.

the class FindReplaceDialog method readConfiguration.

/**
	 * Initializes itself from the dialog settings with the same state as at the
	 * previous invocation.
	 */
private void readConfiguration() {
    IDialogSettings s = getDialogSettings();
    //$NON-NLS-1$
    btnWrapSearch.setSelection(s.getBoolean("wrap"));
    //$NON-NLS-1$
    btnCaseSenitive.setSelection(s.getBoolean("casesensitive"));
    //$NON-NLS-1$
    btnWholeWord.setSelection(s.getBoolean("wholeword"));
    //$NON-NLS-1$
    btnIncremental.setSelection(s.getBoolean("incremental"));
    //$NON-NLS-1$
    btnRegularExpressions.setSelection(s.getBoolean("isRegEx"));
    //$NON-NLS-1$
    String[] findHistory = s.getArray("findhistory");
    if (findHistory != null) {
        for (int i = 0; i < findHistory.length; i++) {
            if (findHistory[i].trim().length() > 0) {
                findText.add(findHistory[i]);
            }
        }
        if (findHistory.length > 0) {
            findText.setText(findText.getItem(0));
        }
    }
    //$NON-NLS-1$
    String[] replaceHistory = s.getArray("replacehistory");
    if (replaceHistory != null) {
        for (int i = 0; i < replaceHistory.length; i++) {
            if (replaceHistory[i].trim().length() > 0) {
                replaceText.add(replaceHistory[i]);
            }
        }
    }
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) Point(org.eclipse.swt.graphics.Point)

Example 42 with IDialogSettings

use of org.eclipse.jface.dialogs.IDialogSettings in project translationstudio8 by heartsome.

the class TermBaseSearchDialog method getDialogSettings.

private IDialogSettings getDialogSettings() {
    IDialogSettings settings = Activator.getDefault().getDialogSettings();
    IDialogSettings fDialogSettings = settings.getSection(getClass().getName());
    if (fDialogSettings == null)
        fDialogSettings = settings.addNewSection(getClass().getName());
    return fDialogSettings;
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings)

Example 43 with IDialogSettings

use of org.eclipse.jface.dialogs.IDialogSettings in project translationstudio8 by heartsome.

the class ConcordanceSearchDialog method writeDialogSettings.

private void writeDialogSettings() {
    IDialogSettings ids = getDialogSettings();
    if (okToUse(cmbSearch)) {
        String searchString = cmbSearch.getText();
        if (searchString.length() > 0) {
            lstSearchHistory.add(0, searchString);
        }
        writeHistory(lstSearchHistory, ids, "net.heartsome.cat.database.ui.tm.dialog.ConcordanceSearchDialog.searchHistory");
    }
    ids.put("net.heartsome.cat.database.ui.tm.dialog.ConcordanceSearchDialog.caseSensitive", btnIsCaseSensitive.getSelection());
    ids.put("net.heartsome.cat.database.ui.tm.dialog.ConcordanceSearchDialog.ignoreMark", !btnIsIgnoreMark.getSelection());
    ids.put("net.heartsome.cat.database.ui.tm.dialog.ConcordanceSearchDialog.regEx", btnApplyRegularExpression.getSelection());
    ids.put("net.heartsome.cat.database.ui.tm.dialog.ConcordanceSearchDialog.selTB", cmbDatabase.getText());
    List<String> lstTgt = new ArrayList<String>();
    for (MenuItem item : menu.getItems()) {
        if (item.getSelection()) {
            lstTgt.add(item.getText());
        }
    }
    String[] arrTgt = new String[lstTgt.size()];
    lstTgt.toArray(arrTgt);
    ids.put("net.heartsome.cat.database.ui.tm.dialog.ConcordanceSearchDialog.selTgt", arrTgt);
    ids.put("net.heartsome.cat.database.ui.tm.dialog.ConcordanceSearchDialog.isExpandFilter", cmpExpandableFilter.isExpanded());
    ids.put("net.heartsome.cat.database.ui.tm.dialog.ConcordanceSearchDialog.selSrcOrTgt", cmbSrcOrTgt.getSelectionIndex());
    ids.put("net.heartsome.cat.database.ui.tm.dialog.ConcordanceSearchDialog.contain", cmbContain.getSelectionIndex());
    if (okToUse(cmbFilter)) {
        String filterString = cmbFilter.getText();
        if (filterString.length() > 0) {
            lstFilterHistory.add(0, filterString);
        }
        writeHistory(lstFilterHistory, ids, "net.heartsome.cat.database.ui.tm.dialog.ConcordanceSearchDialog.filterHistory");
    }
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) ArrayList(java.util.ArrayList) MenuItem(org.eclipse.swt.widgets.MenuItem)

Example 44 with IDialogSettings

use of org.eclipse.jface.dialogs.IDialogSettings in project translationstudio8 by heartsome.

the class TermBaseSearchDialog method writeDialogSettings.

private void writeDialogSettings() {
    IDialogSettings ids = getDialogSettings();
    ids.put("net.heartsome.cat.database.ui.tb.dialog.TermBaseSearchDialog.caseSensitive", btnIsCaseSensitive.getSelection());
    //	preferenceStore.setDefault(TBPreferenceConstants.TB_CASE_SENSITIVE,btnIsCaseSensitive.getSelection());
    ids.put("net.heartsome.cat.database.ui.tb.dialog.TermBaseSearchDialog.ignoreMark", !btnIsIgnoreMark.getSelection());
    ids.put("net.heartsome.cat.database.ui.tb.dialog.TermBaseSearchDialog.regEx", btnApplyRegularExpression.getSelection());
    ids.put("net.heartsome.cat.database.ui.tb.dialog.TermBaseSearchDialog.matchQuality", spiMatchQuality.getSelection());
    if (okToUse(cmbSearch)) {
        String searchString = cmbSearch.getText();
        if (searchString.length() > 0) {
            lstSearchHistory.add(0, searchString);
        }
        writeHistory(lstSearchHistory, ids, "net.heartsome.cat.database.ui.tb.dialog.TermBaseSearchDialog.searchHistory");
    }
    ids.put("net.heartsome.cat.database.ui.tb.dialog.TermBaseSearchDialog.selTM", cmbDatabase.getText());
    List<String> lstTgt = new ArrayList<String>();
    for (MenuItem item : menu.getItems()) {
        if (item.getSelection()) {
            lstTgt.add(item.getText());
        }
    }
    String[] arrTgt = new String[lstTgt.size()];
    lstTgt.toArray(arrTgt);
    ids.put("net.heartsome.cat.database.ui.tb.dialog.TermBaseSearchDialog.selTgt", arrTgt);
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) ArrayList(java.util.ArrayList) MenuItem(org.eclipse.swt.widgets.MenuItem)

Example 45 with IDialogSettings

use of org.eclipse.jface.dialogs.IDialogSettings in project translationstudio8 by heartsome.

the class ExportDocxDialog method okPressed.

@Override
protected void okPressed() {
    if (xliffPathTxt.getText() == null || xliffPathTxt.getText().trim().equals("")) {
        MessageDialog.openInformation(getShell(), Messages.getString("all.dialog.ok.title"), Messages.getString("ExportDocxDialog.ok.msg0"));
        return;
    }
    String docxPath = docxPathTxt.getText().trim();
    if (docxPath == null || docxPath.length() <= 0) {
        MessageDialog.openInformation(getShell(), Messages.getString("all.dialog.ok.title"), Messages.getString("ExportDocxDialog.ok.msg3"));
        return;
    }
    IDialogSettings dialogSettings = Activator.getDefault().getDialogSettings();
    dialogSettings.put(STORE_DOCX_PATH, docxPath);
    XLFValidator.resetFlag();
    if (!XLFValidator.validateXliffFile(strXliffFullPath)) {
        return;
    }
    XLFValidator.resetFlag();
    // 补全 docx 路径
    docxPath = docxPath + File.separator + new File(strXliffFullPath).getName() + ".docx";
    if (new File(docxPath).exists()) {
        boolean confirm = MessageDialog.openConfirm(getShell(), Messages.getString("all.dialog.confirm"), MessageFormat.format(Messages.getString("ExportDocxDialog.ok.msg5"), "DOCX", docxPath));
        if (confirm) {
            new File(docxPath).delete();
        } else {
            return;
        }
    }
    final boolean commentSelection = commentBtn.getSelection();
    final boolean statusSelection = statusBtn.getSelection();
    // 设置查询每个 tu 的条件,比如排除或者 仅导出
    String expandXpath = "";
    if (excludeBtn.getSelection()) {
        if (excludeLockedBtn.getSelection()) {
            expandXpath += " and not(@translate='no')";
        }
        if (exclude101Btn.getSelection()) {
            expandXpath += " and not(target[@hs:quality='101'])";
        }
        if (exclude100Btn.getSelection()) {
            expandXpath += " and not(target[@hs:quality='100'])";
        }
    } else if (onlyExportBtn.getSelection()) {
        if (onlyExportNoteBtn.getSelection()) {
            expandXpath += " and note/text()!=''";
        } else if (onlyExportReviewBtn.getSelection()) {
            expandXpath += " and @hs:needs-review='yes'";
        }
    }
    final String finalExpandXpath = expandXpath;
    // 这里开始调用导出的方法
    final String finalDocxPath = docxPath;
    Job job = new Job(Messages.getString("ExportDocxDialog.ok.monitor.title")) {

        protected IStatus run(final IProgressMonitor monitor) {
            try {
                // 解析文件花一格。读取 xliff 数据花 1 格,导出花 18 格。
                monitor.beginTask(Messages.getString("ExportDocxDialog.ok.monitor.msg0"), 20);
                beginExport(monitor, finalDocxPath, commentSelection, statusSelection, finalExpandXpath);
                Display.getDefault().syncExec(new Runnable() {

                    @Override
                    public void run() {
                        MessageDialog.openInformation(getShell(), Messages.getString("all.dialog.ok.title"), Messages.getString("ExportDocxDialog.ok.msg4"));
                    }
                });
                monitor.done();
            } catch (OperationCanceledException e) {
            // do nothing
            } catch (final Exception e) {
                Display.getDefault().syncExec(new Runnable() {

                    @Override
                    public void run() {
                        MessageDialog.openError(getShell(), Messages.getString("all.dialog.error"), Messages.getString("ExportDocxDialog.ok.exportError") + "\n" + e.getMessage());
                    }
                });
                LOGGER.error("Export xliff to MS WORD error\n" + e.getMessage(), e);
            }
            return Status.OK_STATUS;
        }
    };
    // 当程序退出时,检测当前 job 是否正常关闭
    CommonFunction.jobCantCancelTip(job);
    job.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void running(IJobChangeEvent event) {
            ProgressIndicatorManager.displayProgressIndicator();
            super.running(event);
        }

        @Override
        public void done(IJobChangeEvent event) {
            ProgressIndicatorManager.hideProgressIndicator();
            super.done(event);
        }
    });
    job.setUser(true);
    job.schedule();
    close();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) Job(org.eclipse.core.runtime.jobs.Job) LocalFile(org.eclipse.core.internal.filesystem.local.LocalFile) IFile(org.eclipse.core.resources.IFile) File(java.io.File) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException)

Aggregations

IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)81 File (java.io.File)9 ArrayList (java.util.ArrayList)6 PersistenceException (org.talend.commons.exception.PersistenceException)6 Point (org.eclipse.swt.graphics.Point)5 Path (org.eclipse.core.runtime.Path)4 MenuItem (org.eclipse.swt.widgets.MenuItem)4 IPath (org.eclipse.core.runtime.IPath)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 GridData (org.eclipse.swt.layout.GridData)3 Combo (org.eclipse.swt.widgets.Combo)3 Composite (org.eclipse.swt.widgets.Composite)3 FileDialog (org.eclipse.swt.widgets.FileDialog)3 Widget (org.eclipse.swt.widgets.Widget)3 LocalFile (org.eclipse.core.internal.filesystem.local.LocalFile)2 IFile (org.eclipse.core.resources.IFile)2 CoreException (org.eclipse.core.runtime.CoreException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)2 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2