List of usage examples for org.eclipse.jface.dialogs IDialogSettings save
void save(String fileName) throws IOException;
From source file:at.bestsolution.efxclipse.tooling.fxgraph.ui.wizards.NewFXGraphWizard.java
License:Open Source License
@Override public boolean performFinish() { boolean finish = super.performFinish(); if (finish && getDialogSettings() != null) { IDialogSettings settings = getDialogSettings(); String typeName = getDomainClass().getRootElement().getFullyQualifiedName(); String[] elements = settings.getArray(KEY_LAST_SELECTIONS); if (elements == null) { settings.put(KEY_LAST_SELECTIONS, new String[] { typeName }); } else {/*from ww w . j a v a 2 s .c o m*/ List<String> ar = new ArrayList<String>(Arrays.asList(elements)); ar.remove(typeName); ar.add(0, typeName); // If the list gets too long we'll remove the last entry if (ar.size() > MAX_HISTORY_SIZE) { while (ar.size() > MAX_HISTORY_SIZE) { ar.remove(MAX_HISTORY_SIZE); } } settings.put(KEY_LAST_SELECTIONS, ar.toArray(new String[0])); } try { settings.save(SETTINGS_FILE); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return finish; }
From source file:at.bestsolution.efxclipse.tooling.fxml.wizards.NewFXMLWizard.java
License:Open Source License
@Override public boolean performFinish() { boolean finish = super.performFinish(); if (finish && getDialogSettings() != null) { IFile propFile = getPropertiesFile(); if (!propFile.exists()) { InputStream in = getClass().getClassLoader().getResourceAsStream("tpl_fxml-preview.properties"); if (in != null) { try { propFile.create(in, true, null); } catch (CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); }/*from www .j ava 2 s.co m*/ try { in.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } IDialogSettings settings = getDialogSettings(); String typeName = getDomainClass().getRootElement().getFullyQualifiedName(); String[] elements = settings.getArray(KEY_LAST_SELECTIONS); if (elements == null) { settings.put(KEY_LAST_SELECTIONS, new String[] { typeName }); } else { List<String> ar = new ArrayList<String>(Arrays.asList(elements)); ar.remove(typeName); ar.add(0, typeName); // If the list gets too long we'll remove the last entry if (ar.size() > MAX_HISTORY_SIZE) { while (ar.size() > MAX_HISTORY_SIZE) { ar.remove(MAX_HISTORY_SIZE); } } settings.put(KEY_LAST_SELECTIONS, ar.toArray(new String[0])); } try { settings.save(SETTINGS_FILE); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return finish; }
From source file:com.nokia.carbide.cpp.internal.pi.wizards.ui.NewPIWizard.java
License:Open Source License
/** * This method is called when 'Finish' button is pressed in the wizard. We * will create an operation and run it using wizard as execution context. *//*w w w . j a va2 s .c o m*/ public boolean performFinish() { Display.getDefault().asyncExec(new Runnable() { public void run() { //DialogSettings dialogSettings = (DialogSettings) WizardsPlugin.getDefault().getDialogSettings(); IDialogSettings dialogSettings = getDialogSettings(); if (dialogSettings != null) { NewPIWizardSettings.getInstance().saveState(dialogSettings); setDialogSettings(dialogSettings); try { dialogSettings.save(DIALOG_SETTING_FILE); } catch (IOException e) { // saving last session is not that important e.printStackTrace(); } } createNewProject(); } }); return true; }
From source file:gov.nasa.ensemble.common.ui.DialogUtils.java
License:Open Source License
public static void saveDialogSettingsToPreferences(IDialogSettings settings, IPreferenceStore store) { StringWriter writer = new StringWriter(); try {//from w w w. jav a 2 s .co m settings.save(writer); } catch (IOException e) { Logger.getLogger(DialogUtils.class) .error("Couldn't save settings to preferences: " + settings.getName()); return; } store.setValue(settings.getName(), writer.toString()); }
From source file:gov.nasa.ensemble.common.ui.PickListSetEditor.java
License:Open Source License
@Override protected void doStore() { try {//from w w w .j a v a 2s . co m int index = combo.getSelectionIndex(); IDialogSettings settings = new DialogSettings(getPreferenceName()); settings.put(P_SET_KEYS, combo.getItems()); settings.put(P_SELECTED_SET, combo.getItem(index)); for (int i = 0; i < combo.getItemCount(); i++) { String key = combo.getItem(i); if (key.equals(ITEM_NEW)) { continue; } PickListSet set = setsByName.get(key); if (i == index) { set = new PickListSet(key, Arrays.asList(pickListEditor.getSelectedListControl().getItems())); setsByName.put(key, set); } settings.addSection(set.getSettings()); } StringWriter w = new StringWriter(); settings.save(w); getPreferenceStore().putValue(getPreferenceName(), w.toString()); } catch (Exception e) { trace.error(e.getMessage(), e); } }
From source file:gov.nasa.ensemble.core.plan.editor.merge.preferences.MergeEditorPreferenceInitializer.java
License:Open Source License
private String getDefaultColumnSets() { IDialogSettings settings = PickListSetEditor.buildSettings( MergeEditorPreferencePage.P_MERGE_EDITOR_COLUMN_SETS, Arrays.asList(new PickListSet[] { new PickListSet("Default", getDefaultColumns()), new PickListSet("Empty", new ArrayList<String>()) })); settings.put(PickListSetEditor.P_SELECTED_SET, "Default"); try {//from w ww . ja v a 2 s.c om StringWriter w = new StringWriter(); settings.save(w); return w.toString(); } catch (Exception e) { trace.error(e.getMessage(), e); } return null; }
From source file:org.bbaw.pdr.ae.export.internal.DialogSettingsRegistry.java
License:Open Source License
/** * save settings for this pluginId under the specified directory * @param pluginId//from w w w . ja va 2 s .c o m * @param directory * @throws IOException */ public void savePluginSettings(String pluginId, String directory) throws IOException { IDialogSettings settings = getSection(pluginId); settings.save(directory + AEConstants.FS + pluginId + ".conf"); }
From source file:org.eclipse.emf.search.ecore.ocl.ui.areas.EcoreOCLModelSearchQueryArea.java
License:Open Source License
public void storeDialogSettings() { // Dialog settings for Query Tab IDialogSettings settings = Activator.getDefault().getDialogSettings(); IDialogSettings oclQuerySectionDialogSettings = settings .getSection(OCL_MODEL_SEARCH_AREA_DIALOG_SECTION_ID); int comboSelectionIndex = metaElementsClassifiersComboViewer.getCombo().getSelectionIndex(); String oclExpression = oclExpressionWidget.getExpression(); if (oclExpressionWidget.getTargetMetamodel().equals(TargetMetamodel.Ecore)) { // Target MetaModel : Ecore lastEcoreOCLExpressions = lastEcoreOCLExpressions == null ? new String[metaElementsClassifiersComboViewer.getCombo().getItemCount()] : lastEcoreOCLExpressions; if (comboSelectionIndex >= 0 && lastEcoreOCLExpressions.length >= comboSelectionIndex) { lastEcoreOCLExpressions[comboSelectionIndex] = oclExpression; }//from w ww .jav a 2 s . c o m oclQuerySectionDialogSettings.put(ECORE_CONTEXT_SELECTION_INDEX_DIALOG_SETTINGS_ID, "" + comboSelectionIndex); oclQuerySectionDialogSettings.put(ECORE_QUERY_EXPRESSION_LIST_DIALOG_SETTINGS_ID, lastEcoreOCLExpressions); } else if (oclExpressionWidget.getTargetMetamodel().equals(TargetMetamodel.UML)) { // Target MetaModel : UML2 lastUML2OCLExpressions = lastUML2OCLExpressions == null ? new String[metaElementsClassifiersComboViewer.getCombo().getItemCount()] : lastUML2OCLExpressions; if (comboSelectionIndex >= 0 && lastUML2OCLExpressions.length >= comboSelectionIndex) { lastUML2OCLExpressions[comboSelectionIndex] = oclExpression; } oclQuerySectionDialogSettings.put(UML2_CONTEXT_SELECTION_INDEX_DIALOG_SETTINGS_ID, "" + comboSelectionIndex); oclQuerySectionDialogSettings.put(UML2_QUERY_EXPRESSION_LIST_DIALOG_SETTINGS_ID, lastUML2OCLExpressions); } currentTargetMetaModelID = currentTargetMetaModelID == null ? EcorePackage.eINSTANCE.getNsURI() : currentTargetMetaModelID; oclQuerySectionDialogSettings.put(OCL_TARGET_META_MODEL_NS_URI_DIALOG_SETTINGS_ID, currentTargetMetaModelID); String settingsPath = Activator.getDefault().getStateLocation() .append(getDataMap().get("SETTINGS_PREFIX") + "_" + getClass().getSimpleName() + SETTINGS_EXT) .toOSString(); File settingsFile = new File(settingsPath); if (!settingsFile.exists() || settingsFile.canWrite()) { try { settings.save(settingsPath); } catch (IOException e) { Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, Messages.getString("EcoreTextModelSearchQueryArea.dialogSettingsSaveErrorMessage"), e)); //$NON-NLS-1$ } } }
From source file:org.eclipse.emf.search.ecore.ui.areas.EcoreTextualModelSearchQueryArea.java
License:Open Source License
public void storeDialogSettings() { //Dialog settings for Query Tab IDialogSettings settings = Activator.getDefault().getDialogSettings(); 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); }/*from w w w . java 2 s . c om*/ ecoreTextQuerySectionDialogSettings.put(QUERY_LAST_SEARCHES_LIST_DIALOG_SETTINGS_ID, lastQueriesList.toArray(new String[0])); ecoreTextQuerySectionDialogSettings.put(REGEX_CHECKBOX_DIALOG_SETTINGS_ID, searchRegularExpressionCheckBox.getSelection()); ecoreTextQuerySectionDialogSettings.put(CASE_SENSISTIVE_CHECKBOX_DIALOG_SETTINGS_ID, searchCaseSensitiveCheckBox.getSelection()); 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() || settingsFile.canWrite()) { try { settings.save(settingsPath); } catch (IOException e) { Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, Messages.getString("EcoreTextModelSearchQueryArea.dialogSettingsSaveErrorMessage"), e)); //$NON-NLS-1$ } } }
From source file:org.eclipse.emf.search.ui.areas.AbstractModelSearchParticipantArea.java
License:Open Source License
/** * {@inheritDoc}// w w w . j a v a2s . com */ public void storeDialogSettings() { // Dialog settings for Participant Tab IDialogSettings settings = Activator.getDefault().getDialogSettings(); IDialogSettings participantListSectionDialogSettings; if ((participantListSectionDialogSettings = settings.getSection(getClass().getCanonicalName())) == null) { participantListSectionDialogSettings = settings.addNewSection(getClass().getCanonicalName()); } List<String> metaElementSelectionCanonicalNamesList = new ArrayList<String>(); for (Object o : ((CheckboxTreeViewer) metaElementParticipantFilterCheckedTreeViewer.getViewer()) .getCheckedElements()) { if (o instanceof EClassifier) { metaElementSelectionCanonicalNamesList.add(((EClassifier) o).getClassifierID() + ""); //$NON-NLS-1$ } } participantListSectionDialogSettings.put(META_ELEMENTS_PARTICIPANT_LIST_SETTINGS_ID, metaElementSelectionCanonicalNamesList.toArray(new String[0])); 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() || settingsFile.canWrite()) { try { settings.save(settingsPath); } catch (IOException e) { Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, Messages.getString("AbstractModelSearchParticipantArea.saveDialogSettingsError"), e)); //$NON-NLS-1$ } } }