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;
}
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());
}
}
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" );
*/
}
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());
}
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);
}
Aggregations