Java Code Examples for org.eclipse.ui.XMLMemento#createReadRoot()
The following examples show how to use
org.eclipse.ui.XMLMemento#createReadRoot() .
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: 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 2
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 3
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 4
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 5
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 6
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 7
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 8
Source File: FilteredItemsSelectionDialog.java From tlaplus with MIT License | 5 votes |
/** * Restores dialog using persisted settings. The default implementation * restores the status of the details line and the selection history. * * @param settings * settings used to restore dialog */ protected void restoreDialog(IDialogSettings settings) { boolean toggleStatusLine = true; if (settings.get(SHOW_STATUS_LINE) != null) { toggleStatusLine = settings.getBoolean(SHOW_STATUS_LINE); } toggleStatusLineAction.setChecked(toggleStatusLine); details.setVisible(toggleStatusLine); String setting = settings.get(HISTORY_SETTINGS); if (setting != null) { try { IMemento memento = XMLMemento.createReadRoot(new StringReader( setting)); this.contentProvider.loadHistory(memento); } catch (WorkbenchException e) { // Simply don't restore the settings StatusManager .getManager() .handle( new Status( IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR, WorkbenchMessages.FilteredItemsSelectionDialog_restoreError, e)); } } }
Example 9
Source File: InputURLDialog.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
protected IMemento getMemento() { File file = UIEplPlugin.getDefault().getStateLocation().append(URLS).addFileExtension(XML).toFile(); if (file.exists()) { try { FileReader reader = new FileReader(file); XMLMemento memento = XMLMemento.createReadRoot(reader); return memento; } catch (Exception e) { IdeLog.logError(UIEplPlugin.getDefault(), e); } } return null; }
Example 10
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 11
Source File: IndexedJsniJavaRefTest.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 4 votes |
private static IndexedJsniJavaRef loadRef(String xmlFragment) throws WorkbenchException { StringReader reader = new StringReader(xmlFragment); XMLMemento memento = XMLMemento.createReadRoot(reader); return IndexedJsniJavaRef.load(memento); }
Example 12
Source File: JsniJavaRefParamTypeTest.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 4 votes |
private static JsniJavaRefParamType loadRef(String xmlFragment) throws WorkbenchException { StringReader reader = new StringReader(xmlFragment); XMLMemento memento = XMLMemento.createReadRoot(reader); return JsniJavaRefParamType.load(memento); }
Example 13
Source File: TypeSelectionComponent.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void fillViewMenu(IMenuManager viewMenu) { if (!fMultipleSelection) { ToggleStatusLineAction showStatusLineAction= new ToggleStatusLineAction(); showStatusLineAction.setChecked(fSettings.getBoolean(SHOW_STATUS_LINE)); viewMenu.add(showStatusLineAction); } FullyQualifyDuplicatesAction fullyQualifyDuplicatesAction= new FullyQualifyDuplicatesAction(); fullyQualifyDuplicatesAction.setChecked(fSettings.getBoolean(FULLY_QUALIFY_DUPLICATES)); viewMenu.add(fullyQualifyDuplicatesAction); if (fScope == null) { fFilterActionGroup= new WorkingSetFilterActionGroup(getShell(), JavaPlugin.getActivePage(), new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { IWorkingSet ws= (IWorkingSet)event.getNewValue(); if (ws == null || (ws.isAggregateWorkingSet() && ws.isEmpty())) { fScope= SearchEngine.createWorkspaceScope(); fTitleLabel.setText(null); } else { fScope= JavaSearchScopeFactory.getInstance().createJavaSearchScope(ws, true); fTitleLabel.setText(ws.getLabel()); } fViewer.setSearchScope(fScope, true); } }); String setting= fSettings.get(WORKINGS_SET_SETTINGS); if (setting != null) { try { IMemento memento= XMLMemento.createReadRoot(new StringReader(setting)); fFilterActionGroup.restoreState(memento); } catch (WorkbenchException e) { } } IWorkingSet ws= fFilterActionGroup.getWorkingSet(); if (ws == null || (ws.isAggregateWorkingSet() && ws.isEmpty())) { fScope= SearchEngine.createWorkspaceScope(); fTitleLabel.setText(null); } else { fScope= JavaSearchScopeFactory.getInstance().createJavaSearchScope(ws, true); fTitleLabel.setText(ws.getLabel()); } fFilterActionGroup.fillViewMenu(viewMenu); } }