Search in sources :

Example 46 with IDialogSettings

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

the class ImportDocxDialog 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("ImportDocxDialog.ok.msg0"));
        return;
    }
    IDialogSettings dialogSettings = Activator.getDefault().getDialogSettings();
    dialogSettings.put(STORE_DOCX_PATH, docxPathTxt.getText().trim());
    XLFValidator.resetFlag();
    if (!XLFValidator.validateXliffFile(xliffFullPath)) {
        return;
    }
    XLFValidator.resetFlag();
    final String docxPath = docxPathTxt.getText();
    if (docxPath == null || docxPath.trim().equals("")) {
        MessageDialog.openInformation(getShell(), Messages.getString("all.dialog.ok.title"), Messages.getString("ImportDocxDialog.ok.msg1"));
        return;
    }
    if (!new File(docxPath).exists()) {
        MessageDialog.openWarning(getShell(), Messages.getString("all.dialog.warning"), MessageFormat.format(Messages.getString("ImportDocxDialog.ok.msg2"), new Object[] { docxPath }));
        return;
    }
    // 开始进行处理
    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            try {
                monitor.beginTask(Messages.getString("ImportDocxDialog.ok.monitor.msg0"), 10);
                beginImport(docxPath);
                monitor.done();
            } catch (Exception e) {
                LOGGER.error("", e);
            }
        }
    };
    try {
        new ProgressMonitorDialog(getShell()).run(true, true, runnable);
    } catch (Exception e) {
        LOGGER.error("", e);
    }
    close();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) LocalFile(org.eclipse.core.internal.filesystem.local.LocalFile) IFile(org.eclipse.core.resources.IFile) File(java.io.File) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) FlagErrorException(net.heartsome.cat.ts.ui.docx.common.FlagErrorException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 47 with IDialogSettings

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

the class FindReplaceDialog method writeDialogSettings.

private void writeDialogSettings() {
    IDialogSettings ids = getDialogSettings();
    ids.put("nattable.FindReplaceDialog.direction", backwardButton.getSelection());
    ids.put("nattable.FindReplaceDialog.range", targetButton.getSelection());
    ids.put("nattable.FindReplaceDialog.caseSensitive", caseSensitiveButton.getSelection());
    ids.put("nattable.FindReplaceDialog.wholeWord", wholeWordButton.getSelection());
    ids.put("nattable.FindReplaceDialog.regEx", regExButton.getSelection());
    if (okToUse(cmbFind)) {
        String findString = cmbFind.getText();
        if (findString.length() > 0) {
            lstFindHistory.add(0, findString);
        }
        writeHistory(lstFindHistory, ids, "nattable.FindReplaceDialog.findHistory");
    }
    if (okToUse(cmbReplace)) {
        String replaceString = cmbReplace.getText();
        if (replaceString.length() > 0) {
            lstReplaceHistory.add(0, replaceString);
        }
        writeHistory(lstReplaceHistory, ids, "nattable.FindReplaceDialog.replaceHistory");
    }
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings)

Example 48 with IDialogSettings

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

the class WizardFileSystemResourceExportPage2 method internalSaveWidgetValues.

/**
	 * Hook method for saving widget values for restoration by the next instance of this class.
	 */
protected void internalSaveWidgetValues() {
    // update directory names history
    IDialogSettings settings = getDialogSettings();
    if (settings != null) {
        String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
        if (directoryNames == null) {
            directoryNames = new String[0];
        }
        directoryNames = addToHistory(directoryNames, getDestinationValue());
        settings.put(STORE_DESTINATION_NAMES_ID, directoryNames);
        // options
        if (null != overwriteExistingFilesCheckbox) {
            settings.put(STORE_OVERWRITE_EXISTING_FILES_ID, overwriteExistingFilesCheckbox.getSelection());
        }
        settings.put(STORE_CREATE_STRUCTURE_ID, true);
        settings.put(SELECT_TM_EXPORTED, tmCheck.getSelection());
        settings.put(SELECT_TB_EXPORTED, tbCheck.getSelection());
    }
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings)

Example 49 with IDialogSettings

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

the class FileAnalysisDialog method createFileDataGroup.

/**
	 * @param parent
	 */
public void createFileDataGroup(Composite parent) {
    Composite parentCmp = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().extendedMargins(9, 9, 0, 0).numColumns(1).applyTo(parentCmp);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(parentCmp);
    tableViewer = new TableViewer(parentCmp, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
    final Table table = tableViewer.getTable();
    GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
    tableData.heightHint = 50;
    table.setLayoutData(tableData);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    String[] columnNames = new String[] { Messages.getString("qa.all.dialog.index"), Messages.getString("qa.dialogs.FileAnalysisDialog.xliffFile") };
    int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT };
    for (int i = 0; i < columnNames.length; i++) {
        TableColumn tableColumn = new TableColumn(table, columnAlignments[i]);
        tableColumn.setText(columnNames[i]);
        tableColumn.setWidth(50);
    }
    tableViewer.setLabelProvider(new TableViewerLabelProvider());
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.setInput(getQATableInfo());
    // 让列表列宽动态变化
    table.addListener(SWT.Resize, new Listener() {

        public void handleEvent(Event event) {
            final Table table = ((Table) event.widget);
            final TableColumn[] columns = table.getColumns();
            event.widget.getDisplay().syncExec(new Runnable() {

                public void run() {
                    double[] columnWidths = new double[] { 0.1, 0.8 };
                    for (int i = 0; i < columns.length; i++) columns[i].setWidth((int) (table.getBounds().width * columnWidths[i]));
                }
            });
        }
    });
    // 如果是字数分析
    if (isWordsFa) {
        IDialogSettings dialogSettings = Activator.getDefault().getDialogSettings();
        if (CommonFunction.checkEdition("U")) {
            exter101Btn = new Button(parentCmp, SWT.CHECK);
            exter101Btn.setText(Messages.getString("qa.dialogs.FileAnalysisDialog.lockExter101"));
            exter101Btn.setSelection(dialogSettings.getBoolean(LOCK_EXTER_101));
        }
        exter100Btn = new Button(parentCmp, SWT.CHECK);
        exter100Btn.setText(Messages.getString("qa.dialogs.FileAnalysisDialog.lockExter100"));
        interRepeatBtn = new Button(parentCmp, SWT.CHECK);
        interRepeatBtn.setText(Messages.getString("qa.dialogs.FileAnalysisDialog.lockInterRepeat"));
        exter100Btn.setSelection(dialogSettings.getBoolean(LOCK_EXTER_100));
        interRepeatBtn.setSelection(dialogSettings.getBoolean(LOCK_INTER_REPEAT));
    }
}
Also used : Table(org.eclipse.swt.widgets.Table) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) TableColumn(org.eclipse.swt.widgets.TableColumn) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 50 with IDialogSettings

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

the class FileAnalysisDialog method okPressed.

@Override
protected void okPressed() {
    // 传入要锁定重复文本段的参数
    if (isWordsFa) {
        model.setLockExter101(CommonFunction.checkEdition("U") ? exter101Btn.getSelection() : false);
        model.setLockExter100(exter100Btn.getSelection());
        model.setLockInterRepeat(interRepeatBtn.getSelection());
        IDialogSettings dialogSettings = Activator.getDefault().getDialogSettings();
        dialogSettings.put(LOCK_EXTER_101, CommonFunction.checkEdition("U") ? exter101Btn.getSelection() : false);
        dialogSettings.put(LOCK_EXTER_100, exter100Btn.getSelection());
        dialogSettings.put(LOCK_INTER_REPEAT, interRepeatBtn.getSelection());
    }
    super.okPressed();
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings)

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