Search in sources :

Example 66 with IPreferenceStore

use of org.eclipse.jface.preference.IPreferenceStore in project translationstudio8 by heartsome.

the class ConverterViewModel method reverseConvert.

/**
	 * 逆向转换
	 * @param sourceItem
	 * @param monitor
	 * @return ;
	 */
private Map<String, String> reverseConvert(IConversionItem sourceItem, IProgressMonitor monitor) throws ConverterException {
    Map<String, String> result = null;
    String sourcePathStr = configBean.getSource();
    String targetFile = ConverterUtil.toLocalPath(configBean.getTarget());
    boolean convertSuccessful = false;
    File target = null;
    try {
        target = new File(targetFile);
        if (!target.exists()) {
            try {
                File parent = target.getParentFile();
                if (!parent.exists()) {
                    parent.mkdirs();
                }
                target.createNewFile();
            } catch (IOException e) {
                if (LOGGER.isErrorEnabled()) {
                    String msg = Messages.getString("model.ConverterViewModel.logger4");
                    Object[] args = { targetFile };
                    LOGGER.error(new MessageFormat(msg).format(args), e);
                }
            }
        }
        Converter converter = getConverter();
        if (converter == null) {
            // Build a message
            String message = Messages.getString("model.ConverterViewModel.msg3") + configBean.getFileType();
            // Build a new IStatus
            IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
            throw new ConverterNotFoundException(status);
        }
        ConverterContext converterContext = new ConverterContext(configBean);
        final Map<String, String> configuration = converterContext.getReverseConvertConfiguraion();
        if (configBean.getFileType().equals("x-msoffice2003")) {
            IPreferenceStore ps = net.heartsome.cat.ts.ui.Activator.getDefault().getPreferenceStore();
            String path = ps.getString(ITranslationPreferenceConstants.PATH_OF_OPENOFFICE);
            String port = ps.getString(ITranslationPreferenceConstants.PORT_OF_OPENOFFICE);
            configuration.put("ooPath", path);
            configuration.put("ooPort", port);
        }
        result = converter.convert(configuration, monitor);
        convertSuccessful = true;
    } catch (OperationCanceledException e) {
        // 捕获用户取消操作的异常
        LOGGER.info(Messages.getString("model.ConverterViewModel.logger2"), e);
        throw e;
    } catch (ConverterNotFoundException e) {
        // Let the StatusManager handle the Status and provide a hint
        StatusManager.getManager().handle(e.getStatus(), StatusManager.LOG | StatusManager.SHOW);
        if (LOGGER.isErrorEnabled()) {
            LOGGER.error(e.getMessage(), e);
        }
        throw e;
    } catch (ConverterException e) {
        if (LOGGER.isErrorEnabled()) {
            LOGGER.error(MessageFormat.format(Messages.getString("model.ConverterViewModel.logger3"), sourcePathStr), e);
        }
        throw e;
    } finally {
        if (!convertSuccessful) {
            // 在转换失败或用户取消转换时,清除目标文件和骨架文件
            if (target != null && target.exists()) {
                target.delete();
            }
        }
        sourceItem.refresh();
    }
    return result;
}
Also used : ValidationStatus(org.eclipse.core.databinding.validation.ValidationStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ConverterException(net.heartsome.cat.converter.ConverterException) IStatus(org.eclipse.core.runtime.IStatus) MessageFormat(java.text.MessageFormat) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IOException(java.io.IOException) Converter(net.heartsome.cat.converter.Converter) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) File(java.io.File)

Example 67 with IPreferenceStore

use of org.eclipse.jface.preference.IPreferenceStore in project AutoRefactor by JnRouvignac.

the class PreferenceInitializer method initializeDefaultPreferences.

@Override
public void initializeDefaultPreferences() {
    // TODO initialize preferences from the JDT preferences like:
    // code style/cleanup/formatting
    final IPreferenceStore store = AutoRefactorPlugin.getDefault().getPreferenceStore();
    for (PreferenceConstants preference : PreferenceConstants.values()) {
        final String name = preference.getName();
        final Object defaultValue = preference.getDefaultValue();
        if (defaultValue instanceof Boolean) {
            store.setDefault(name, (Boolean) defaultValue);
        } else if (defaultValue instanceof Integer) {
            store.setDefault(name, (Integer) defaultValue);
        } else if (defaultValue instanceof Long) {
            store.setDefault(name, (Long) defaultValue);
        } else if (defaultValue instanceof Double) {
            store.setDefault(name, (Double) defaultValue);
        } else if (defaultValue instanceof Float) {
            store.setDefault(name, (Float) defaultValue);
        } else if (defaultValue instanceof String) {
            store.setDefault(name, (String) defaultValue);
        } else {
            throw new NotImplementedException(null, defaultValue);
        }
    }
    for (RefactoringRule refactoringRule : AllRefactoringRules.getAllRefactoringRules()) {
        store.setDefault(refactoringRule.getClass().getCanonicalName(), refactoringRule.isByDefault());
    }
}
Also used : PreferenceConstants(org.autorefactor.preferences.PreferenceConstants) RefactoringRule(org.autorefactor.refactoring.RefactoringRule) NotImplementedException(org.autorefactor.util.NotImplementedException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 68 with IPreferenceStore

use of org.eclipse.jface.preference.IPreferenceStore in project MonjaDB by Kanatoko.

the class PreferenceInitializer method initializeDefaultPreferences.

//--------------------------------------------------------------------------------
public void initializeDefaultPreferences() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    //store.setDefault( BATCH_SIZE, default_batch_size );
    store.setDefault(PREF_MAX_FIND_RESULTS, default_max_results);
//store.setDefault( PORT, _8080 );
/*
store.setDefault( PreferenceConstants.P_BOOLEAN, true );
store.setDefault( PreferenceConstants.P_CHOICE, "choice2" );
store.setDefault( PreferenceConstants.P_STRING, "Default value" );
*/
}
Also used : IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 69 with IPreferenceStore

use of org.eclipse.jface.preference.IPreferenceStore in project gfm_viewer by satyagraha.

the class PreferenceInitializer method initializeDefaultPreferences.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
	 */
@Override
public void initializeDefaultPreferences() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    store.setDefault(P_USE_TEMP_DIR, getConfigDefault().useTempDir());
    store.setDefault(P_API_URL, getConfigDefault().getApiUrl());
    store.setDefault(P_USERNAME, "");
    store.setDefault(P_PASSWORD, "");
    store.setDefault(P_TEMPLATE, "");
    store.setDefault(P_CSS_URL_1, "");
    store.setDefault(P_CSS_URL_2, "");
    store.setDefault(P_CSS_URL_3, "");
    store.setDefault(P_JS_URL_1, "");
    store.setDefault(P_JS_URL_2, "");
    store.setDefault(P_JS_URL_3, "");
    store.setDefault(P_USE_ECLIPSE_CONSOLE, getConfigDefault().useEclipseConsole());
    store.setDefault(P_MARKDOWN_EXTENSIONS, getConfigDefault().getMarkdownExtensions());
}
Also used : IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 70 with IPreferenceStore

use of org.eclipse.jface.preference.IPreferenceStore in project bndtools by bndtools.

the class ExecutableJarWizardPage method loadLastExport.

private void loadLastExport() {
    IPreferenceStore prefs = Plugin.getDefault().getPreferenceStore();
    folder = prefs.getBoolean(PREF_LAST_EXPORT_IS_FOLDER);
    jarPath = prefs.getString(PREF_LAST_EXPORT_JAR_PATH);
    if (jarPath != null)
        txtJarPath.setText(jarPath);
    folderPath = prefs.getString(PREF_LAST_EXPORT_FOLDER_PATH);
    if (folderPath != null)
        txtFolderPath.setText(folderPath);
}
Also used : IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Aggregations

IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)311 ArrayList (java.util.ArrayList)35 Test (org.junit.Test)23 Hashtable (java.util.Hashtable)19 File (java.io.File)18 Before (org.junit.Before)17 List (java.util.List)14 IPath (org.eclipse.core.runtime.IPath)14 InvocationTargetException (java.lang.reflect.InvocationTargetException)13 IOException (java.io.IOException)12 MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)12 IElementParameter (org.talend.core.model.process.IElementParameter)12 CoreException (org.eclipse.core.runtime.CoreException)11 Path (org.eclipse.core.runtime.Path)11 Font (org.eclipse.swt.graphics.Font)11 Point (org.eclipse.swt.graphics.Point)11 Composite (org.eclipse.swt.widgets.Composite)11 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)10 IStatus (org.eclipse.core.runtime.IStatus)10 StyledText (org.eclipse.swt.custom.StyledText)10