org.eclipse.ui.XMLMemento Java Examples
The following examples show how to use
org.eclipse.ui.XMLMemento.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompilationUnitResourceDependencyIndex.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
public void saveIndex() { XMLMemento memento = XMLMemento.createWriteRoot(TAG_ROOT); persistIndex(memento); File indexFile = getIndexFile(); FileWriter writer = null; try { try { writer = new FileWriter(indexFile); memento.save(writer); } finally { if (writer != null) { writer.close(); } } } catch (IOException e) { CorePluginLog.logError(e, "Error saving index " + indexName); // Make sure we remove any partially-written file if (indexFile.exists()) { indexFile.delete(); } } }
Example #2
Source File: SwitchPaletteMode.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * Retrieves the root memento from the workspace preferences if there were * existing palette customizations. * * @return the root memento if there were existing customizations; null * otherwise */ private XMLMemento getExistingCustomizations() { if (preferences != null) { String sValue = preferences.getString(PALETTE_CUSTOMIZATIONS_ID); if (sValue != null && sValue.length() != 0) { //$NON-NLS-1$ try { XMLMemento rootMemento = XMLMemento.createReadRoot(new StringReader(sValue)); return rootMemento; } catch (WorkbenchException e) { Trace.catching(GefPlugin.getInstance(), GefDebugOptions.EXCEPTIONS_CATCHING, getClass(), "Problem creating the XML memento when saving the palette customizations.", //$NON-NLS-1$ e); Log.warning(GefPlugin.getInstance(), GefStatusCodes.IGNORED_EXCEPTION_WARNING, "Problem creating the XML memento when saving the palette customizations.", //$NON-NLS-1$ e); } } } return null; }
Example #3
Source File: InfoFactoryTest.java From Pydev with Eclipse Public License 1.0 | 6 votes |
public void testInfoFactory() throws Exception { InfoFactory infoFactory = new InfoFactory(new AdditionalInfoAndIInfo(null, null)); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setFeature("http://xml.org/sax/features/namespaces", false); factory.setFeature("http://xml.org/sax/features/validation", false); factory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); DocumentBuilder documentBuilder = factory.newDocumentBuilder(); Document document = documentBuilder.newDocument(); Element root = document.createElement("root"); IMemento memento = new XMLMemento(document, root); infoFactory.saveState(memento); assertNull(infoFactory.createElement(memento)); ClassInfo info = new ClassInfo(null, null, null, null, null, 0, 0); infoFactory = new InfoFactory(new AdditionalInfoAndIInfo(null, info)); infoFactory.saveState(memento); assertNull(infoFactory.createElement(memento)); }
Example #4
Source File: GlobalsTwoPanelElementSelector2.java From Pydev with Eclipse Public License 1.0 | 6 votes |
@Override protected void restoreDialog(IDialogSettings settings) { super.restoreDialog(settings); String setting = settings.get(WORKINGS_SET_SETTINGS); if (setting != null) { try { IMemento memento = XMLMemento.createReadRoot(new StringReader(setting)); workingSetFilterActionGroup.restoreState(memento); } catch (WorkbenchException e) { StatusManager.getManager().handle( new Status(IStatus.ERROR, AnalysisPlugin.getPluginID(), IStatus.ERROR, "", e)); //$NON-NLS-1$ // don't do anything. Simply don't restore the settings } } addListFilter(workingSetFilter); applyFilter(); }
Example #5
Source File: GlobalsTwoPanelElementSelector2.java From Pydev with Eclipse Public License 1.0 | 6 votes |
@Override protected void storeDialog(IDialogSettings settings) { super.storeDialog(settings); XMLMemento memento = XMLMemento.createWriteRoot("workingSet"); //$NON-NLS-1$ workingSetFilterActionGroup.saveState(memento); workingSetFilterActionGroup.dispose(); StringWriter writer = new StringWriter(); try { memento.save(writer); settings.put(WORKINGS_SET_SETTINGS, writer.getBuffer().toString()); } catch (IOException e) { StatusManager.getManager().handle( new Status(IStatus.ERROR, AnalysisPlugin.getPluginID(), IStatus.ERROR, "", e)); //$NON-NLS-1$ // don't do anything. Simply don't store the settings } }
Example #6
Source File: SQLBuilderDesignState.java From birt with Eclipse Public License 1.0 | 6 votes |
static XMLMemento saveState( final SQLBuilderDesignState sqbState ) { // Save the state of the SQLBuilderStorageEditorInput to a XMLMemento SQLBuilderStorageEditorInput sqbInput = sqbState.getSQBStorageInput(); XMLMemento memento = SQLBuilderEditorInputUtil.saveSQLBuilderStorageEditorInput( sqbInput ); // Save the data set design's preparable query text in the memento, // if it is syntactically different from the query text being edited in SQB String queryText = sqbState.getPreparableSQL(); if( queryText != null && ! SQLQueryUtility.isEquivalentSQL( queryText, sqbInput.getSQL() ) ) { memento.putString( KEY_PREPARABLE_SQL_TEXT, queryText ); } return memento; }
Example #7
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected void storeDialog(IDialogSettings settings) { super.storeDialog(settings); if (! BUG_184693) { settings.put(SHOW_CONTAINER_FOR_DUPLICATES, fShowContainerForDuplicatesAction.isChecked()); } if (fFilterActionGroup != null) { XMLMemento memento= XMLMemento.createWriteRoot("workingSet"); //$NON-NLS-1$ fFilterActionGroup.saveState(memento); fFilterActionGroup.dispose(); StringWriter writer= new StringWriter(); try { memento.save(writer); settings.put(WORKINGS_SET_SETTINGS, writer.getBuffer().toString()); } catch (IOException e) { // don't do anything. Simply don't store the settings JavaPlugin.log(e); } } }
Example #8
Source File: PackageExplorerPart.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); if (memento == null) { String persistedMemento= fDialogSettings.get(TAG_MEMENTO); if (persistedMemento != null) { try { memento= XMLMemento.createReadRoot(new StringReader(persistedMemento)); } catch (WorkbenchException e) { // don't do anything. Simply don't restore the settings } } } fMemento= memento; if (memento != null) { restoreLayoutState(memento); restoreLinkingEnabled(memento); restoreRootMode(memento); } if (getRootMode() == WORKING_SETS_AS_ROOTS) { createWorkingSetModel(); } }
Example #9
Source File: JavaRefIndex.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
private void saveIndex(XMLMemento memento) { for (Entry<IPath, Set<IIndexedJavaRef>> fileEntry : fileIndex.entrySet()) { for (IIndexedJavaRef ref : fileEntry.getValue()) { IMemento refNode = memento.createChild(TAG_JAVA_REF); /* * Embed the Java reference class name into the index. This ends up * making the resulting index file larger than it really needs to be * (around 100 KB for the index containing gwt-user, gwt-lang, and all * the gwt-dev projects), but it still loads in around 50 ms on average * on my system, so it doesn't seem to be a bottleneck. */ String refClassName = ref.getClass().getName(); refNode.putString(TAG_JAVA_REF_CLASS, refClassName); // The implementation of IIndexedJavaRef serializes itself ref.save(refNode); } } }
Example #10
Source File: JavaRefIndex.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
private void saveIndex() { XMLMemento memento = XMLMemento.createWriteRoot(TAG_JAVA_REFS); saveIndex(memento); FileWriter writer = null; try { try { writer = new FileWriter(getIndexFile()); memento.save(writer); } finally { if (writer != null) { writer.close(); } } } catch (IOException e) { GWTPluginLog.logError(e, "Error saving search index"); } }
Example #11
Source File: ProfileManager.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
/** * Read all profiles from the given store to this profile manager * @param ips */ public void readFromStore(IPreferenceStore ips) { int allCount = ips.getInt(idInStore + ID_PROFILES_COUNT); for (int cnt=0; cnt < allCount; ++cnt) { try { String xml = ips.getString(idInStore + ID_PROFILE + cnt); StringReader reader = new StringReader(xml); XMLMemento memento = XMLMemento.createReadRoot(reader); IProfile ip = profileFactory.createFromMemento(memento); if (ip != null) { String name = ip.getName(); IProfile ipOld = getProfile(name); if (ipOld == null) { profiles.add(ip); } else { ipOld.copyFrom(ip); } } } catch (Exception e) { LogHelper.logError(e); } } setActiveProfileName(ips.getString(idInStore + ID_ACTIVE_PROFILE_NAME)); }
Example #12
Source File: IndexedJsniJavaRefTest.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
public void testSave() { XMLMemento memento = XMLMemento.createWriteRoot("JavaRef"); // Set up a test JsniJavaRef to serialize JsniJavaRef ref = JsniJavaRef.parse("@com.hello.Hello::sayHi(Ljava/lang/String;)"); ref.setOffset(25); ref.setSource(new Path("/MyProject/src/com/hello/Hello.java")); IndexedJsniJavaRef indexedRef = new IndexedJsniJavaRef(ref); indexedRef.save(memento); assertEquals("@com.hello.Hello::sayHi(Ljava/lang/String;)", memento.getTextData()); assertEquals(25, memento.getInteger("offset").intValue()); assertEquals("/MyProject/src/com/hello/Hello.java", memento.getString("source")); }
Example #13
Source File: FilteredItemsSelectionDialog.java From tlaplus with MIT License | 6 votes |
/** * Load history elements from memento. * * @param memento * memento from which the history will be retrieved */ public void load(IMemento memento) { XMLMemento historyMemento = (XMLMemento) memento .getChild(rootNodeName); if (historyMemento == null) { return; } IMemento[] mementoElements = historyMemento .getChildren(infoNodeName); for (int i = 0; i < mementoElements.length; ++i) { IMemento mementoElement = mementoElements[i]; Object object = restoreItemFromMemento(mementoElement); if (object != null) { historyList.add(object); } } }
Example #14
Source File: ProfileManager.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
public static IProfile readProfileFromStore(String profName, IPreferenceStore ips, String id, IProfile profileFactory) { int allCount = ips.getInt(id + ID_PROFILES_COUNT); for (int cnt=0; cnt < allCount; ++cnt) { try { String xml = ips.getString(id + ID_PROFILE + cnt); StringReader reader = new StringReader(xml); XMLMemento memento = XMLMemento.createReadRoot(reader); IProfile ip = profileFactory.createFromMemento(memento); if (ip != null && profName.equals(ip.getName())) { return ip; } } catch (Exception e) { LogHelper.logError(e); } } return null; }
Example #15
Source File: BugExplorerView.java From spotbugs with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void dispose() { // XXX see https://bugs.eclipse.org/bugs/show_bug.cgi?id=223068 XMLMemento memento = XMLMemento.createWriteRoot("bugExplorer"); //$NON-NLS-1$ saveState(memento); StringWriter writer = new StringWriter(); try { memento.save(writer); IDialogSettings dialogSettings = FindbugsPlugin.getDefault().getDialogSettings(); dialogSettings.put(TAG_MEMENTO, writer.getBuffer().toString()); } catch (IOException e) { // don't do anything. Simply don't store the settings } if (selectionListener != null) { getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(selectionListener); selectionListener = null; } super.dispose(); }
Example #16
Source File: BugExplorerView.java From spotbugs with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void init(IViewSite site, IMemento memento) throws PartInitException { viewMemento = memento; if (memento == null) { IDialogSettings dialogSettings = FindbugsPlugin.getDefault().getDialogSettings(); String persistedMemento = dialogSettings.get(TAG_MEMENTO); if (persistedMemento == null) { // See bug 2504068. First time user opens a view, no settings // are defined // but we still need to enforce initialisation of content // provider // which can only happen if memento is not null memento = XMLMemento.createWriteRoot("bugExplorer"); } else { try { memento = XMLMemento.createReadRoot(new StringReader(persistedMemento)); } catch (WorkbenchException e) { // don't do anything. Simply don't restore the settings } } } super.init(site, memento); }
Example #17
Source File: SdkManager.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
private SdkRegistry loadSdkRegistry(XMLMemento memento) { List<Sdk> registeredSDKs = new ArrayList<Sdk>(); IMemento[] children = memento.getChildren(TAG_SDK); IPreferenceStore store = XdsCorePlugin.getDefault().getPreferenceStore(); String actSdk = store.getString(KEY_ACTIVE_SDK_NAME); if (StringUtils.isEmpty(actSdk)) { actSdk = null; } SdkRegistry sdkRegistry = new SdkRegistry(actSdk); for (IMemento settingsMemento : children) { Sdk settings = createSdkFor(settingsMemento); if (settings != null) { registeredSDKs.add(settings); } } sdkRegistry.setRegisteredSDKs(registeredSDKs); return sdkRegistry; }
Example #18
Source File: FilteredItemsSelectionDialog.java From tlaplus with MIT License | 6 votes |
/** * Stores dialog settings. * * @param settings * settings used to store dialog */ protected void storeDialog(IDialogSettings settings) { settings.put(SHOW_STATUS_LINE, toggleStatusLineAction.isChecked()); XMLMemento memento = XMLMemento.createWriteRoot(HISTORY_SETTINGS); this.contentProvider.saveHistory(memento); StringWriter writer = new StringWriter(); try { memento.save(writer); settings.put(HISTORY_SETTINGS, writer.getBuffer().toString()); } catch (IOException e) { // Simply don't store the settings StatusManager .getManager() .handle( new Status( IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR, WorkbenchMessages.FilteredItemsSelectionDialog_storeError, e)); } }
Example #19
Source File: InputURLDialog.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
protected void saveMemento() { XMLMemento memento = XMLMemento.createWriteRoot(URLS); saveList(memento); File file = UIEplPlugin.getDefault().getStateLocation().append(URLS).addFileExtension(XML).toFile(); try { FileWriter writer = new FileWriter(file); memento.save(writer); } catch (IOException e) { IdeLog.logError(UIEplPlugin.getDefault(), e); } }
Example #20
Source File: SwitchPaletteMode.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public void save() { if (paletteStates.isEmpty()) { return; } // If there are already existing palette customizations we will add to // them, otherwise, create a new XML memento which makes it easy to save // the customizations in a tree format. XMLMemento rootMemento = getExistingCustomizations(); if (rootMemento == null) { rootMemento = XMLMemento.createWriteRoot(PALETTE_CUSTOMIZATIONS_ID); } for (Iterator<Entry<PaletteEntry, IPaletteState>> iterator = paletteStates.entrySet().iterator(); iterator.hasNext();) { Entry<PaletteEntry, IPaletteState> entry = iterator.next(); IMemento memento = getMementoForEntry(rootMemento, entry.getKey()); if (memento != null) { entry.getValue().storeChangesInMemento(memento); } } StringWriter writer = new StringWriter(); try { rootMemento.save(writer); if (preferences != null) { preferences.setValue(PALETTE_CUSTOMIZATIONS_ID, writer.toString()); } } catch (IOException e) { Trace.catching(GefPlugin.getInstance(), GefDebugOptions.EXCEPTIONS_CATCHING, getClass(), "Problem saving the XML memento when saving the palette customizations.", //$NON-NLS-1$ e); Log.warning(GefPlugin.getInstance(), GefStatusCodes.IGNORED_EXCEPTION_WARNING, "Problem saving the XML memento when saving the palette customizations.", //$NON-NLS-1$ e); } paletteStates.clear(); }
Example #21
Source File: ProfileManager.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
/** * Play export dialog and do the export * * @param prof - null to export all or the given profile * @param pm - profile manager to get profiles from (when 'prof' == null) */ public static void exportProfiles(Shell shell, IProfile prof, ProfileManager pm) { String title = prof==null ? Messages.ProfileManager_ExportProfile : Messages.ProfileManager_ExportProfiles; String s = SWTFactory.browseFile(shell, true, title, new String[]{"*.xml"}, importExportPath); //$NON-NLS-1$ if (s != null) { File f = new File(s); if (f.exists()) { if (!SWTFactory.YesNoQuestion(shell, title, String.format(Messages.ProfileManager_ReplaceQuestion, s))) { return; } } importExportPath = f.getParentFile().getAbsolutePath(); XMLMemento memento = XMLMemento.createWriteRoot("tagExportedFormatterProfiles"); //$NON-NLS-1$ int memNum = 0; int total = prof == null ? pm.size() : 1; for (int num=0; num < total; ++num) { IProfile ip = prof == null ? pm.get(num) : prof; IMemento childMem = memento.createChild(XML_FORMATTER_PROFILE_SECTION + memNum++); ip.toMemento(childMem); } try { f.delete(); FileWriter fw = new FileWriter(f); memento.save(fw); fw.close(); } catch(Exception e) { LogHelper.logError(e); } } }
Example #22
Source File: InstalledUpdatesManager.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public InstalledUpdatesRegistry loadInstalledUpdatesRegistry() throws IOException, WorkbenchException { if (installedUpdatesRegistry == null) { File installedUpdatesRegistryFile = getInstalledUpdatesRegistryFile(); if (installedUpdatesRegistryFile.exists()) { Reader reader = new FileReader(installedUpdatesRegistryFile); XMLMemento memento = XMLMemento.createReadRoot(reader); installedUpdatesRegistry = loadInstalledUpdatesRegistry(memento); } else { installedUpdatesRegistry = new InstalledUpdatesRegistry(new HashMap<String, InstalledUpdate>()); } } return installedUpdatesRegistry; }
Example #23
Source File: InstalledUpdatesManager.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public void saveInstalledUpdatesRegistry(InstalledUpdatesRegistry installedUpdatesRegistry) throws IOException { XMLMemento memento = XMLMemento.createWriteRoot(TAG_INSTALLED_UPDATES); saveInstalledUpdatesRegistry(memento, installedUpdatesRegistry); FileWriter writer = new FileWriter(getInstalledUpdatesRegistryFile()); memento.save(writer); }
Example #24
Source File: InstalledUpdatesManager.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
private void saveInstalledUpdatesRegistry(XMLMemento memento, InstalledUpdatesRegistry installedUpdatesRegistry) { Set<Entry<String, InstalledUpdate>> installedUpdateEntries = installedUpdatesRegistry.getInstalledFile2Descriptor().entrySet(); for (Entry<String, InstalledUpdate> installedUpdateEntry : installedUpdateEntries) { final InstalledUpdate installedUpdate = installedUpdateEntry.getValue(); if (!getActualFile(installedUpdate).exists()) continue; IMemento installedUpdateChild = memento.createChild(TAG_INSTALLED_UPDATE); installedUpdateChild.putString(TAG_FILE_LOCATION, installedUpdate.getFileLocation()); installedUpdateChild.putString(TAG_VERSION, installedUpdate.getFileVersion().toString()); } }
Example #25
Source File: SQLBuilderDesignState.java From birt with Eclipse Public License 1.0 | 5 votes |
public String toString() { if( m_sqbInput == null ) return EMPTY_STRING; // Save the state to a XMLMemento XMLMemento memento = DesignStateMemento.saveState( this ); // Write out memento to a string String sqbState = SQLBuilderEditorInputUtil.writeXMLMementoToString( memento ); return sqbState; }
Example #26
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected void restoreDialog(IDialogSettings settings) { super.restoreDialog(settings); if (! BUG_184693) { boolean showContainer= settings.getBoolean(SHOW_CONTAINER_FOR_DUPLICATES); fShowContainerForDuplicatesAction.setChecked(showContainer); fTypeInfoLabelProvider.setContainerInfo(showContainer); } else { fTypeInfoLabelProvider.setContainerInfo(true); } if (fAllowScopeSwitching) { String setting= settings.get(WORKINGS_SET_SETTINGS); if (setting != null) { try { IMemento memento= XMLMemento.createReadRoot(new StringReader(setting)); fFilterActionGroup.restoreState(memento); } catch (WorkbenchException e) { // don't do anything. Simply don't restore the settings JavaPlugin.log(e); } } IWorkingSet ws= fFilterActionGroup.getWorkingSet(); if (ws == null || (ws.isAggregateWorkingSet() && ws.isEmpty())) { setSearchScope(SearchEngine.createWorkspaceScope()); setSubtitle(null); } else { setSearchScope(JavaSearchScopeFactory.getInstance().createJavaSearchScope(ws, true)); setSubtitle(ws.getLabel()); } } // TypeNameMatch[] types = OpenTypeHistory.getInstance().getTypeInfos(); // // for (int i = 0; i < types.length; i++) { // TypeNameMatch type = types[i]; // accessedHistoryItem(type); // } }
Example #27
Source File: InstalledUpdatesManager.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
private static InstalledUpdatesRegistry loadInstalledUpdatesRegistry(XMLMemento memento) { Map<String, InstalledUpdate> installedFile2Descriptor = new HashMap<String, InstalledUpdate>(); IMemento[] installedUpdateChildren = memento.getChildren(TAG_INSTALLED_UPDATE); for (IMemento installedUpdateChild : installedUpdateChildren) { InstalledUpdate installedUpdate = createInstalledUpdateFor(installedUpdateChild); File file = getActualFile(installedUpdate); if (file.exists()) { installedFile2Descriptor.put(installedUpdate.getFileLocation(), installedUpdate); } } return new InstalledUpdatesRegistry(installedFile2Descriptor); }
Example #28
Source File: PackageExplorerPart.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void dispose() { XMLMemento memento= XMLMemento.createWriteRoot("packageExplorer"); //$NON-NLS-1$ saveState(memento); StringWriter writer= new StringWriter(); try { memento.save(writer); fDialogSettings.put(TAG_MEMENTO, writer.getBuffer().toString()); } catch (IOException e) { // don't do anything. Simply don't store the settings } if (fContextMenu != null && !fContextMenu.isDisposed()) fContextMenu.dispose(); getSite().getPage().removePartListener(fLinkWithEditorListener); // always remove even if we didn't register JavaPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); if (fViewer != null) fViewer.removeTreeListener(fExpansionListener); if (fActionSet != null) fActionSet.dispose(); if (fFilterUpdater != null) ResourcesPlugin.getWorkspace().removeResourceChangeListener(fFilterUpdater); if (fWorkingSetModel != null) fWorkingSetModel.dispose(); super.dispose(); }
Example #29
Source File: SdkManager.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
private void saveSdkRegistry(XMLMemento memento, SdkRegistry sdkRegistry) { String actSdk = (sdkRegistry.getDefaultSdk() != null) ? sdkRegistry.getDefaultSdk().getName() : ""; //$NON-NLS-1$ IPreferenceStore store = XdsCorePlugin.getDefault().getPreferenceStore(); store.setValue(KEY_ACTIVE_SDK_NAME, actSdk); WorkspacePreferencesManager.getInstance().flush(); for (Sdk sdk : sdkRegistry.getRegisteredSDKs()) { IMemento mementoSdk = memento.createChild(TAG_SDK); for (Sdk.Property property: Sdk.Property.values()) { mementoSdk.putString(property.xmlKey, sdk.getPropertyValue(property)); for (Sdk.Tag tag : property.possibleTags) { String val = sdk.getTag(property, tag); if (val != null) { String key = property.xmlKey + "_" + tag.xmlTagName; //$NON-NLS-1$ mementoSdk.putString(key, val); } } } Map<String, String> environmentVariables = sdk.getEnvironmentVariablesRaw(); if (!environmentVariables.isEmpty()) { for (Map.Entry<String, String> entry : environmentVariables.entrySet()) { IMemento mementoEnvVar = mementoSdk.createChild(TAG_ENVIRONMENT_VARIABLE); mementoEnvVar.putString(TAG_ENVIRONMENT_VARIABLE_NAME, entry.getKey()); mementoEnvVar.putString(TAG_ENVIRONMENT_VARIABLE_VALUE, entry.getValue()); } } saveTools(mementoSdk, sdk); } }
Example #30
Source File: TypeSelectionComponent.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void disposeComponent() { if (fFilterActionGroup != null) { XMLMemento memento= XMLMemento.createWriteRoot("workingSet"); //$NON-NLS-1$ fFilterActionGroup.saveState(memento); fFilterActionGroup.dispose(); StringWriter writer= new StringWriter(); try { memento.save(writer); fSettings.put(WORKINGS_SET_SETTINGS, writer.getBuffer().toString()); } catch (IOException e) { // don't do anything. Simply don't store the settings } } }