List of usage examples for org.eclipse.jface.dialogs IDialogSettings load
void load(String fileName) throws IOException;
From source file:com.aljoschability.rendis.ui.runtime.ActivatorImpl.java
License:Open Source License
private IDialogSettings createDialogSettings() { IDialogSettings dialogSettings = new DialogSettings(WORKBENCH); // see bug 69387 IPath path = Platform.getStateLocation(getBundle()); if (path != null) { // try r/w state area in the local file system String readWritePath = path.append(DIALOG_SETTINGS).toOSString(); File settingsFile = new File(readWritePath); if (settingsFile.exists()) { try { dialogSettings.load(readWritePath); } catch (IOException e) { // load failed so ensure we have an empty settings dialogSettings = new DialogSettings(WORKBENCH); }//from w w w. j a v a2s . com return dialogSettings; } } // otherwise look for bundle specific dialog settings URL dsURL = FileLocator.find(getBundle(), new Path(DIALOG_SETTINGS), null); if (dsURL == null) { return dialogSettings; } InputStream is = null; try { is = dsURL.openStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is, ENCODING)); dialogSettings.load(reader); } catch (IOException e) { // load failed so ensure we have an empty settings dialogSettings = new DialogSettings(WORKBENCH); } finally { try { if (is != null) { is.close(); } } catch (IOException e) { // do nothing } } return dialogSettings; }
From source file:com.nokia.carbide.cpp.internal.pi.wizards.ui.NewPIWizard.java
License:Open Source License
/** * Constructor for NewPIWizard./*from w ww .j ava 2 s .co m*/ */ public NewPIWizard() { super(); wizard = this; setNeedsProgressMonitor(true); ICarbideSharedImages carbideImages = CarbideUIPlugin.getDefault().getSharedImages(); setDefaultPageImageDescriptor( carbideImages.getImageDescriptor(carbideImages.IMG_PI_IMPORT_WIZARD_BANNER_75_66)); setWindowTitle(Messages.getString("NewPIWizard.window.title")); //$NON-NLS-1$ //DialogSettings dialogSettings = (DialogSettings) WizardsPlugin.getDefault().getDialogSettings(); IDialogSettings dialogSettings = new DialogSettings("import_wizard"); //$NON-NLS-1$ try { dialogSettings.load(DIALOG_SETTING_FILE); } catch (IOException e) { // saving last session is not that important //e.printStackTrace(); } wizardSettings.clear(); wizardSettings.restoreState(dialogSettings); setDialogSettings(dialogSettings); }
From source file:gov.nasa.ensemble.common.ui.DialogUtils.java
License:Open Source License
public static void loadDialogSettingsFromPreferences(IPreferenceStore store, IDialogSettings settings) { String settingsString = store.getString(settings.getName()); if (settingsString != null) { StringReader reader = new StringReader(settingsString); try {/*from ww w.j a va2s . com*/ settings.load(reader); } catch (IOException e) { Logger.getLogger(DialogUtils.class) .error("Couldn't load settings from preferences: " + settings.getName()); } finally { reader.close(); } } }
From source file:gov.nasa.ensemble.common.ui.PickListSetEditor.java
License:Open Source License
protected void doLoad(String s) { StringReader r = new StringReader(s); IDialogSettings settings = new DialogSettings(getPreferenceName()); try {/* w w w . ja v a 2 s . c om*/ settings.load(r); } catch (IOException e) { trace.error(e.getMessage(), e); } combo.removeAll(); int index = -1; String selection = settings.get(P_SELECTED_SET); String list[] = settings.getArray(P_SET_KEYS); for (int i = 0; list != null && i < list.length; i++) { String key = list[i]; IDialogSettings section = settings.getSection(key); if (section != null) { PickListSet set = new PickListSet(section); setsByName.put(key, set); combo.add(key); if (CommonUtils.equals(selection, key)) { index = i; } } } combo.add(ITEM_NEW); if (index != -1) { combo.select(index); lastSelection = index; } }
From source file:org.eclipse.emf.search.ecore.ocl.ui.areas.EcoreOCLModelSearchQueryArea.java
License:Open Source License
public void loadDialogSettings() { IDialogSettings settings = Activator.getDefault().getDialogSettings(); ////w w w . j a v a2 s .co m // BEGIN: https://bugs.eclipse.org/bugs/show_bug.cgi?id=231988 // String settingsPath = Activator.getDefault().getStateLocation() .append(getDataMap().get("SETTINGS_PREFIX") + "_" + getClass().getSimpleName() + SETTINGS_EXT) .toOSString(); File settingsFile = new File(settingsPath); if (settingsFile.exists()) { try { settings.load(settingsPath); } catch (IOException e) { Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, 0, Messages.getString("EcoreTextModelSearchQueryArea.dialogSettingsLoadErrorMessage"), e)); //$NON-NLS-1$ } } // // END // IDialogSettings oclQuerySectionDialogSettings; if ((oclQuerySectionDialogSettings = settings .getSection(OCL_MODEL_SEARCH_AREA_DIALOG_SECTION_ID)) == null) { oclQuerySectionDialogSettings = settings.addNewSection(OCL_MODEL_SEARCH_AREA_DIALOG_SECTION_ID); } String targetMetaModelNsURI = oclQuerySectionDialogSettings .get(OCL_TARGET_META_MODEL_NS_URI_DIALOG_SETTINGS_ID); targetMetaModelNsURI = targetMetaModelNsURI == null ? (currentTargetMetaModelID == null ? EcorePackage.eINSTANCE.getNsURI() : currentTargetMetaModelID) : targetMetaModelNsURI; TargetMetamodel target = getTargetMetamodelFromNsURI(targetMetaModelNsURI); oclExpressionWidget.setTargetMetamodel(target); metaElementsClassifiersComboViewer.setInput(getContextClassifierListFromNsURI(targetMetaModelNsURI)); // Init Ecore expressions array lastEcoreOCLExpressions = oclQuerySectionDialogSettings .getArray(ECORE_QUERY_EXPRESSION_LIST_DIALOG_SETTINGS_ID); lastEcoreOCLExpressions = lastEcoreOCLExpressions == null ? new String[5000] : lastEcoreOCLExpressions; // Init UML2 expressions array lastUML2OCLExpressions = oclQuerySectionDialogSettings .getArray(UML2_QUERY_EXPRESSION_LIST_DIALOG_SETTINGS_ID); lastUML2OCLExpressions = lastUML2OCLExpressions == null ? new String[5000] : lastUML2OCLExpressions; if (target.equals(TargetMetamodel.Ecore)) { // Target MetaModel : Ecore String lastEcoreOCLCtxIndex = oclQuerySectionDialogSettings .get(ECORE_CONTEXT_SELECTION_INDEX_DIALOG_SETTINGS_ID); lastEcoreOCLCtxIndex = (lastEcoreOCLCtxIndex == null) ? "0" : lastEcoreOCLCtxIndex; lastIndex = Integer.parseInt(lastEcoreOCLCtxIndex); lastIndex = lastIndex >= 0 ? lastIndex : 0; if (lastEcoreOCLExpressions.length >= lastIndex) { oclExpressionWidget.setExpression(lastEcoreOCLExpressions[lastIndex]); } } else if (target.equals(TargetMetamodel.UML)) { // Target MetaModel : UML2 String lastUML2OCLCtxIndex = oclQuerySectionDialogSettings .get(UML2_CONTEXT_SELECTION_INDEX_DIALOG_SETTINGS_ID); lastUML2OCLCtxIndex = (lastUML2OCLCtxIndex == null) ? "0" : lastUML2OCLCtxIndex; lastIndex = Integer.parseInt(lastUML2OCLCtxIndex); lastIndex = lastIndex >= 0 ? lastIndex : 0; if (lastUML2OCLExpressions.length >= lastIndex) { oclExpressionWidget.setExpression(lastUML2OCLExpressions[lastIndex]); } } metaElementsClassifiersComboViewer .addSelectionChangedListener(new MetaElementsClassifiersComboViewerSelectionChangedListener()); if (metaElementsClassifiersComboViewer.getCombo().getItems().length >= lastIndex) { Object object = metaElementsClassifiersComboViewer.getElementAt(lastIndex); metaElementsClassifiersComboViewer.setSelection(new StructuredSelection(object)); } else { int itemCount = metaElementsClassifiersComboViewer.getCombo().getItemCount(); if (itemCount > 0) { Object element = metaElementsClassifiersComboViewer.getElementAt(lastIndex); //metaElementsClassifiersComboViewer.getCombo().indexOf(((ENamedElement)element).getName()); metaElementsClassifiersComboViewer .setSelection(new StructuredSelection(element == null ? new Object[0] : element)); } } }
From source file:org.eclipse.emf.search.ecore.ui.areas.EcoreTextualModelSearchQueryArea.java
License:Open Source License
public void loadDialogSettings() { //Dialog settings for Query Tab IDialogSettings settings = Activator.getDefault().getDialogSettings(); ///* w ww.j a va 2s. com*/ // BEGIN: https://bugs.eclipse.org/bugs/show_bug.cgi?id=231988 // String settingsPath = Activator.getDefault().getStateLocation() .append(getDataMap().get("SETTINGS_PREFIX") + "_" + getClass().getSimpleName() + SETTINGS_EXT) //$NON-NLS-1$//$NON-NLS-2$ .toOSString(); File settingsFile = new File(settingsPath); if (settingsFile.exists()) { try { settings.load(settingsPath); } catch (IOException e) { Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, 0, Messages.getString("EcoreTextModelSearchQueryArea.dialogSettingsLoadErrorMessage"), e)); //$NON-NLS-1$ } } // // END // IDialogSettings ecoreTextQuerySectionDialogSettings; if ((ecoreTextQuerySectionDialogSettings = settings .getSection(ECORE_TEXT_MODEL_SEARCH_AREA_DIALOG_SECTION_ID)) == null) { ecoreTextQuerySectionDialogSettings = settings .addNewSection(ECORE_TEXT_MODEL_SEARCH_AREA_DIALOG_SECTION_ID); } String[] lastQueries = ecoreTextQuerySectionDialogSettings .getArray(QUERY_LAST_SEARCHES_LIST_DIALOG_SETTINGS_ID); lastQueries = lastQueries == null ? new String[0] : lastQueries; searchQueryTextCombo.setItems(lastQueries); lastQueriesList.addAll(Arrays.asList(lastQueries)); if (lastQueries != null && lastQueries.length > 0) { searchQueryTextCombo.select(0); } else { searchQueryTextCombo.setText("*"); //$NON-NLS-1$ } searchQueryTextCombo.setFocus(); boolean regexCheckboxSelection = ecoreTextQuerySectionDialogSettings .getBoolean(REGEX_CHECKBOX_DIALOG_SETTINGS_ID); searchRegularExpressionCheckBox.setSelection(regexCheckboxSelection); boolean caseSensitiveCheckboxSelection = ecoreTextQuerySectionDialogSettings .getBoolean(CASE_SENSISTIVE_CHECKBOX_DIALOG_SETTINGS_ID); searchCaseSensitiveCheckBox.setSelection(caseSensitiveCheckboxSelection); searchCaseSensitiveCheckBox.setEnabled(!regexCheckboxSelection); searchQueryExplanatoryLabel.setText(!regexCheckboxSelection ? EXPLANATORY_SEARCH_JOKERS_TEXT : ""); //$NON-NLS-1$ searchQueryTextCombo.setFocus(); }
From source file:org.eclipse.emf.search.ui.areas.AbstractModelSearchParticipantArea.java
License:Open Source License
/** * {@inheritDoc}//from w w w. ja va2 s . c o m */ // dialog settings public void loadDialogSettings() { // Dialog settings for Query Tab IDialogSettings settings = Activator.getDefault().getDialogSettings(); // // BEGIN: https://bugs.eclipse.org/bugs/show_bug.cgi?id=231988 // String settingsPath = Activator.getDefault().getStateLocation() .append(getDataMap().get("SETTINGS_PREFIX") + "_" + getClass().getSimpleName() + SETTINGS_EXT) //$NON-NLS-1$//$NON-NLS-2$ .toOSString(); File settingsFile = new File(settingsPath); if (settingsFile.exists()) { try { settings.load(settingsPath); } catch (IOException e) { Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, 0, Messages.getString("AbstractModelSearchParticipantArea.loadDialogSettingsError"), e)); //$NON-NLS-1$ } } // // END // IDialogSettings ecoreTextQuerySectionDialogSettings; if ((ecoreTextQuerySectionDialogSettings = settings.getSection(getClass().getCanonicalName())) == null) { ecoreTextQuerySectionDialogSettings = settings.addNewSection(getClass().getCanonicalName()); } String[] previousSelection = ecoreTextQuerySectionDialogSettings .getArray(META_ELEMENTS_PARTICIPANT_LIST_SETTINGS_ID); if (previousSelection != null) { List<String> lastMetaElementsSelectionList = Arrays.asList(previousSelection); for (Object o : metaElementsPartictipantsItemProvider.getElements("$$__ALL_ELEMENTS_$$")) { //$NON-NLS-1$ if (o instanceof EClassifier) { ((CheckboxTreeViewer) metaElementParticipantFilterCheckedTreeViewer.getViewer()).setChecked(o, lastMetaElementsSelectionList.contains(((EClassifier) o).getClassifierID() + "")); //$NON-NLS-1$ } } } Object o = ((IStructuredSelection) metaElementParticipantFilterCheckedTreeViewer.getViewer().getSelection()) .getFirstElement(); if (o instanceof EObject) { handleTargetMetaElementParticipantSelection((EObject) o); } }
From source file:org.eclipse.jpt.common.ui.internal.JptUIPlugin.java
License:Open Source License
/** * @see org.eclipse.ui.plugin.AbstractUIPlugin#loadDialogSettings() *///from w w w. j a v a2 s. c o m protected IDialogSettings buildDialogSettings() { IDialogSettings settings = this.buildDialogSettings_(); String settingsFileName = this.getDialogSettingsFileName(); if (settingsFileName == null) { return settings; } File settingsFile = new File(settingsFileName); if (settingsFile.exists()) { try { settings.load(settingsFileName); } catch (IOException ex) { // if there are problems, return an empty settings container return this.buildDialogSettings_(); } } return settings; }
From source file:org.eclipse.linuxtools.systemtap.ui.editor.internal.RecentFileLog.java
License:Open Source License
public static String getString(String key) { try {//from ww w. j a va2 s. c o m IDialogSettings settings = EditorPlugin.getDefault().getDialogSettings(); settings.load(fileName); return settings.get(key); } catch (IOException e) { } return null; }
From source file:org.eclipse.linuxtools.systemtap.ui.editor.internal.RecentFileLog.java
License:Open Source License
private static boolean setString(String key, String val) { try {/*from ww w. j av a2 s .c o m*/ IDialogSettings settings = EditorPlugin.getDefault().getDialogSettings(); settings.load(fileName); settings.put(key, val); settings.save(fileName); return true; } catch (IOException e) { } return false; }