Examples of IMemento


Examples of org.eclipse.ui.IMemento

    final String schemeId = scheme.getId();
    final String defaultSchemeId = store
        .getDefaultString(IWorkbenchPreferenceConstants.KEY_CONFIGURATION_ID);
    if ((defaultSchemeId == null) ? (schemeId != null) : (!defaultSchemeId
        .equals(schemeId))) {
      final IMemento child = memento
          .createChild(TAG_ACTIVE_KEY_CONFIGURATION);
      child.putString(ATT_KEY_CONFIGURATION_ID, schemeId);
    }
  }
View Full Code Here

Examples of org.eclipse.ui.IMemento

   * @param binding
   *            The binding to write; must not be <code>null</code>.
   */
  private static final void writeBindingToPreferences(final IMemento parent,
      final Binding binding) {
    final IMemento element = parent.createChild(TAG_KEY_BINDING);
    element.putString(ATT_CONTEXT_ID, binding.getContextId());
    final ParameterizedCommand parameterizedCommand = binding
        .getParameterizedCommand();
    final String commandId = (parameterizedCommand == null) ? null
        : parameterizedCommand.getId();
    element.putString(ATT_COMMAND_ID, commandId);
    element.putString(ATT_KEY_CONFIGURATION_ID, binding.getSchemeId());
    element.putString(ATT_KEY_SEQUENCE, binding.getTriggerSequence()
        .toString());
    element.putString(ATT_LOCALE, binding.getLocale());
    element.putString(ATT_PLATFORM, binding.getPlatform());
    if (parameterizedCommand != null) {
      final Map parameterizations = parameterizedCommand
          .getParameterMap();
      final Iterator parameterizationItr = parameterizations.entrySet()
          .iterator();
      while (parameterizationItr.hasNext()) {
        final Map.Entry entry = (Map.Entry) parameterizationItr.next();
        final String id = (String) entry.getKey();
        final String value = (String) entry.getValue();
        final IMemento parameterElement = element
            .createChild(TAG_PARAMETER);
        parameterElement.putString(ATT_ID, id);
        parameterElement.putString(ATT_VALUE, value);
      }
    }
  }
View Full Code Here

Examples of org.eclipse.ui.IMemento

    // Create the preference memento.
    final IPreferenceStore store = WorkbenchPlugin.getDefault()
        .getPreferenceStore();
    final String preferenceString = store.getString(EXTENSION_COMMANDS);
    IMemento preferenceMemento = null;
    if ((preferenceString != null) && (preferenceString.length() > 0)) {
      final Reader reader = new StringReader(preferenceString);
      try {
        preferenceMemento = XMLMemento.createReadRoot(reader);
      } catch (final WorkbenchException e) {
View Full Code Here

Examples of org.eclipse.ui.IMemento

        String tooltip = Util.safeString(memento
                .getString(IWorkbenchConstants.TAG_TOOLTIP));
        String partName = memento
                .getString(IWorkbenchConstants.TAG_PART_NAME);

        IMemento propBag = memento.getChild(IWorkbenchConstants.TAG_PROPERTIES);
    if (propBag != null) {
      IMemento[] props = propBag
          .getChildren(IWorkbenchConstants.TAG_PROPERTY);
      for (int i = 0; i < props.length; i++) {
        propertyCache.put(props[i].getID(), props[i].getTextData());
      }
    }

    // For compatibility set the part name to the title if not found
        if (partName == null) {
            partName = title;
        }

        // Get the editor descriptor.
        EditorDescriptor desc = null;
        if (id != null) {
            desc = getDescriptor(id);
        }
        // desc may be null if id is null or desc is not found, but findImage below handles this
        String location = memento.getString(IWorkbenchConstants.TAG_PATH);
        IPath path = location == null ? null : new Path(location);
        ImageDescriptor iDesc = this.manager.findImage(desc, path);

        this.name = memento.getString(IWorkbenchConstants.TAG_NAME);
        if (this.name == null) {
            this.name = title;
        }
        setPinned("true".equals(memento.getString(IWorkbenchConstants.TAG_PINNED))); //$NON-NLS-1$

        IMemento inputMem = memento.getChild(IWorkbenchConstants.TAG_INPUT);
        if (inputMem != null) {
            this.factoryId = inputMem
                    .getString(IWorkbenchConstants.TAG_FACTORY_ID);
        }

        init(id, title, tooltip, iDesc, partName, ""); //$NON-NLS-1$
    }
View Full Code Here

Examples of org.eclipse.ui.IMemento

        if (restoredInput != null) {
            return restoredInput;
        }
       
        // Get the input factory.
        IMemento editorMem = getMemento();
        if (editorMem == null) {
            throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_no_persisted_state, getId(), getName()));
        }
        IMemento inputMem = editorMem
                .getChild(IWorkbenchConstants.TAG_INPUT);
        String factoryID = null;
        if (inputMem != null) {
            factoryID = inputMem
                    .getString(IWorkbenchConstants.TAG_FACTORY_ID);
        }
        if (factoryID == null) {
            throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_no_input_factory_ID, getId(), getName()));
        }
View Full Code Here

Examples of org.eclipse.ui.IMemento

                    .next();
            if (!info.isPersistable()) {
        iter.remove();
      }
        }
        IMemento editorsMem = memento
                .createChild(IWorkbenchConstants.TAG_EDITORS);
        for (Iterator iter = editors.iterator(); iter.hasNext();) {
            NavigationHistoryEditorInfo info = (NavigationHistoryEditorInfo) iter
                    .next();
            info.saveState(editorsMem
                    .createChild(IWorkbenchConstants.TAG_EDITOR));
        }

        ArrayList list = new ArrayList(history.size());
        int size = history.size();
        for (int i = 0; i < size; i++) {
            NavigationHistoryEntry entry = (NavigationHistoryEntry) history
                    .get(i);
            if (entry.editorInfo.isPersistable()) {
        list.add(entry);
      }
        }
        size = list.size();
        for (int i = 0; i < size; i++) {
            NavigationHistoryEntry entry = (NavigationHistoryEntry) list.get(i);
            IMemento childMem = memento
                    .createChild(IWorkbenchConstants.TAG_ITEM);
            if (entry == cEntry) {
        childMem.putString(IWorkbenchConstants.TAG_ACTIVE, "true"); //$NON-NLS-1$
      }
            entry.saveState(childMem, list);
            childMem.putInteger(IWorkbenchConstants.TAG_INDEX, editors
                    .indexOf(entry.editorInfo));
        }
    }
View Full Code Here

Examples of org.eclipse.ui.IMemento

    /**
     * Restore the state of this history from the memento.
     */
    void restoreState(IMemento memento) {
        IMemento editorsMem = memento.getChild(IWorkbenchConstants.TAG_EDITORS);
        IMemento items[] = memento.getChildren(IWorkbenchConstants.TAG_ITEM);
        if (items.length == 0 || editorsMem == null) {
            if (page.getActiveEditor() != null) {
        markLocation(page.getActiveEditor());
      }
            return;
        }

        IMemento children[] = editorsMem
                .getChildren(IWorkbenchConstants.TAG_EDITOR);
        NavigationHistoryEditorInfo editorsInfo[] = new NavigationHistoryEditorInfo[children.length];
        for (int i = 0; i < editorsInfo.length; i++) {
            editorsInfo[i] = new NavigationHistoryEditorInfo(children[i]);
            editors.add(editorsInfo[i]);
        }

        for (int i = 0; i < items.length; i++) {
            IMemento item = items[i];
            int index = item.getInteger(IWorkbenchConstants.TAG_INDEX)
                    .intValue();
            NavigationHistoryEditorInfo info = editorsInfo[index];
            info.refCount++;
            NavigationHistoryEntry entry = new NavigationHistoryEntry(info,
                    page, null, null);
            history.add(entry);
            entry.restoreState(item);
            if (item.getString(IWorkbenchConstants.TAG_ACTIVE) != null) {
        activeEntry = i;
      }
        }

        final NavigationHistoryEntry entry = getEntry(activeEntry);
View Full Code Here

Examples of org.eclipse.ui.IMemento

        IMemento[] children = memento.getChildren(IWorkbenchConstants.TAG_PAGE);
        if (children != null) {
            // Loop through the page elements.
            for (int i = 0; i < children.length; i++) {
                // Get the info details.
                IMemento childMem = children[i];
                String partID = childMem
                        .getString(IWorkbenchConstants.TAG_CONTENT);

                // Create the part.
                LayoutPart part = new PartPlaceholder(partID);
                part.setContainer(this);
                add(part);
                //1FUN70C: ITPUI:WIN - Shouldn't set Container when not active
                //part.setContainer(this);
                if (partID.equals(activeTabID)) {
                    setSelection(part);
                    // Mark this as the active part.
                    //current = part;
                }
            }
        }

        IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
        boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
        final Integer expanded = memento.getInteger(IWorkbenchConstants.TAG_EXPANDED);
        if (useNewMinMax && expanded != null) {
            StartupThreading.runWithoutExceptions(new StartupRunnable() {
          public void runWithException() throws Throwable {               
                setState((expanded == null || expanded.intValue() != IStackPresentationSite.STATE_MINIMIZED) ? IStackPresentationSite.STATE_RESTORED
                        : IStackPresentationSite.STATE_MINIMIZED);
          }
            });
        }
        else {
          setState((expanded == null || expanded.intValue() != IStackPresentationSite.STATE_MINIMIZED) ? IStackPresentationSite.STATE_RESTORED
                  : IStackPresentationSite.STATE_MINIMIZED);
        }

        Integer appearance = memento
                .getInteger(IWorkbenchConstants.TAG_APPEARANCE);
        if (appearance != null) {
            this.appearance = appearance.intValue();
        }

        // Determine if the presentation has saved any info here
        savedPresentationState = null;
        IMemento[] presentationMementos = memento
                .getChildren(IWorkbenchConstants.TAG_PRESENTATION);

        for (int idx = 0; idx < presentationMementos.length; idx++) {
            IMemento child = presentationMementos[idx];

            String id = child.getString(IWorkbenchConstants.TAG_ID);

            if (Util.equals(id, getFactory().getId())) {
                savedPresentationState = child;
                break;
            }
        }

        IMemento propertiesState = memento.getChild(IWorkbenchConstants.TAG_PROPERTIES);
        if (propertiesState != null) {
            IMemento[] props = propertiesState.getChildren(IWorkbenchConstants.TAG_PROPERTY);
            for (int i = 0; i < props.length; i++) {
                properties.put(props[i].getID(), props[i].getTextData());
            }
        }
               
View Full Code Here

Examples of org.eclipse.ui.IMemento

        Set cachedIds = new HashSet();
        Iterator ppIter = getPresentableParts().iterator();
        while (ppIter.hasNext()) {
            PresentablePart presPart = (PresentablePart) ppIter.next();

            IMemento childMem = memento
                    .createChild(IWorkbenchConstants.TAG_PAGE);
            PartPane part = presPart.getPane();
            String tabText = part.getPartReference().getPartName();

            childMem.putString(IWorkbenchConstants.TAG_LABEL, tabText);
            childMem.putString(IWorkbenchConstants.TAG_CONTENT, presPart.getPane().getPlaceHolderId());
           
            // Cache the id so we don't write it out later
            cachedIds.add(presPart.getPane().getPlaceHolderId());
        }

        Iterator iter = children.iterator();
        while (iter.hasNext()) {
            LayoutPart next = (LayoutPart) iter.next();

            PartPane part = null;
            if (next instanceof PartPane) {
              // Have we already written it out?
              if (cachedIds.contains(((PartPane)next).getPlaceHolderId()))
                continue;
             
                part = (PartPane)next;
            }

            IMemento childMem = memento
                    .createChild(IWorkbenchConstants.TAG_PAGE);

            String tabText = "LabelNotFound"; //$NON-NLS-1$
            if (part != null) {
                tabText = part.getPartReference().getPartName();
            }
            childMem.putString(IWorkbenchConstants.TAG_LABEL, tabText);
            childMem.putString(IWorkbenchConstants.TAG_CONTENT, next
                    .getCompoundId());
        }

        IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
        boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
        if (useNewMinMax) {
            memento.putInteger(IWorkbenchConstants.TAG_EXPANDED, presentationSite.getState());
        }
        else {
            memento
            .putInteger(
                    IWorkbenchConstants.TAG_EXPANDED,
                    (presentationSite.getState() == IStackPresentationSite.STATE_MINIMIZED) ? IStackPresentationSite.STATE_MINIMIZED
                            : IStackPresentationSite.STATE_RESTORED);
        }

        memento.putInteger(IWorkbenchConstants.TAG_APPEARANCE, appearance);

        savePresentationState();

        if (savedPresentationState != null) {
            IMemento presentationState = memento
                    .createChild(IWorkbenchConstants.TAG_PRESENTATION);
            presentationState.putMemento(savedPresentationState);
        }
       
        if (!properties.isEmpty()) {
            IMemento propertiesState = memento.createChild(IWorkbenchConstants.TAG_PROPERTIES);
            Set ids = properties.keySet();
            for (Iterator iterator = ids.iterator(); iterator.hasNext();) {  
                String id = (String)iterator.next();
               
                if (properties.get(id) == null) continue;
               
                IMemento prop = propertiesState.createChild(IWorkbenchConstants.TAG_PROPERTY, id);
                prop.putTextData((String)properties.get(id));
            }
        }
       

        return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
View Full Code Here

Examples of org.eclipse.ui.IMemento

 
  /* (non-Javadoc)
   * @see org.eclipse.ui.internal.IStickyViewManager#save(org.eclipse.ui.IMemento)
   */
  public void save(IMemento memento) {
    IMemento stickyState = memento.createChild(IWorkbenchConstants.TAG_STICKY_STATE);
    Iterator itr = stickyPerspectives.entrySet().iterator();
    while (itr.hasNext()) {
      Map.Entry entry = (Map.Entry) itr.next();
      String perspectiveId = (String) entry.getKey();
      Set activatedViewIds = (Set) entry.getValue();
      IMemento perspectiveState = stickyState.createChild(
          IWorkbenchConstants.TAG_PERSPECTIVE, perspectiveId);
      for (Iterator i = activatedViewIds.iterator(); i.hasNext();) {
        String viewId = (String) i.next();
        perspectiveState.createChild(IWorkbenchConstants.TAG_VIEW,
            viewId);
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.