Examples of IMemento


Examples of org.eclipse.ui.IMemento

  /* (non-Javadoc)
   * @see org.eclipse.ui.internal.IStickyViewManager#restore(org.eclipse.ui.IMemento)
   */
  public void restore(IMemento memento) {
    // restore the sticky activation state
    IMemento stickyState = memento
        .getChild(IWorkbenchConstants.TAG_STICKY_STATE);

    if (stickyState != null) {
      IMemento[] stickyPerspMems = stickyState
          .getChildren(IWorkbenchConstants.TAG_PERSPECTIVE);
      for (int i = 0; i < stickyPerspMems.length; i++) {
        String perspectiveId = stickyPerspMems[i].getID();
        Set viewState = new HashSet(7);
        stickyPerspectives.put(perspectiveId, viewState);
View Full Code Here

Examples of org.eclipse.ui.IMemento

  void restoreWorkingSet() {
    IMemento[] itemMementos = workingSetMemento
        .getChildren(IWorkbenchConstants.TAG_ITEM);
    Set items = new HashSet();
    for (int i = 0; i < itemMementos.length; i++) {
      IMemento itemMemento = itemMementos[i];
      String factoryID = itemMemento
          .getString(IWorkbenchConstants.TAG_FACTORY_ID);

      if (factoryID == null) {
        WorkbenchPlugin
            .log("Unable to restore working set item - no factory ID."); //$NON-NLS-1$
View Full Code Here

Examples of org.eclipse.ui.IMemento

      while (iterator.hasNext()) {
        IAdaptable adaptable = (IAdaptable) iterator.next();
        IPersistableElement persistable = (IPersistableElement) Util
            .getAdapter(adaptable, IPersistableElement.class);
        if (persistable != null) {
          IMemento itemMemento = memento
              .createChild(IWorkbenchConstants.TAG_ITEM);

          itemMemento.putString(IWorkbenchConstants.TAG_FACTORY_ID,
              persistable.getFactoryId());
          persistable.saveState(itemMemento);
        }
      }
    }
View Full Code Here

Examples of org.eclipse.ui.IMemento

        final Map mapIDtoPart = new HashMap(children.length);

        // Loop through the info elements.
        for (int i = 0; i < children.length; i++) {
            // Get the info details.
            IMemento childMem = children[i];
            String partID = childMem.getString(IWorkbenchConstants.TAG_PART);
            final String relativeID = childMem
                    .getString(IWorkbenchConstants.TAG_RELATIVE);
            int relationship = 0;
            float ratio = 0.0f;
            int left = 0, right = 0;
            if (relativeID != null) {
                relationship = childMem.getInteger(
                        IWorkbenchConstants.TAG_RELATIONSHIP).intValue();

                // Note: the ratio is used for reading pre-3.0 eclipse workspaces. It should be ignored
                // if "left" and "right" are available.
                Float ratioFloat = childMem
                        .getFloat(IWorkbenchConstants.TAG_RATIO);
                Integer leftInt = childMem
                        .getInteger(IWorkbenchConstants.TAG_RATIO_LEFT);
                Integer rightInt = childMem
                        .getInteger(IWorkbenchConstants.TAG_RATIO_RIGHT);
                if (leftInt != null && rightInt != null) {
                    left = leftInt.intValue();
                    right = rightInt.intValue();
                } else {
                    if (ratioFloat != null) {
                        ratio = ratioFloat.floatValue();
                    }
                }
            }
            String strFolder = childMem
                    .getString(IWorkbenchConstants.TAG_FOLDER);

            // Create the part.
            LayoutPart part = null;
            if (strFolder == null) {
        part = new PartPlaceholder(partID);
      } else {
                ViewStack folder = new ViewStack(page);
                folder.setID(partID);
                result.add(folder.restoreState(childMem
                        .getChild(IWorkbenchConstants.TAG_FOLDER)));
                ContainerPlaceholder placeholder = new ContainerPlaceholder(
                        partID);
                placeholder.setRealContainer(folder);
                part = placeholder;
View Full Code Here

Examples of org.eclipse.ui.IMemento

            //    private LayoutPart part;
            //     private int relationship;
            //     private float ratio;
            //     private LayoutPart relative;
            RelationshipInfo info = relationships[i];
            IMemento childMem = memento
                    .createChild(IWorkbenchConstants.TAG_INFO);
            childMem.putString(IWorkbenchConstants.TAG_PART, info.part.getID());
            if (info.relative != null) {
                childMem.putString(IWorkbenchConstants.TAG_RELATIVE,
                        info.relative.getID());
                childMem.putInteger(IWorkbenchConstants.TAG_RELATIONSHIP,
                        info.relationship);
                childMem.putInteger(IWorkbenchConstants.TAG_RATIO_LEFT,
                        info.left);
                childMem.putInteger(IWorkbenchConstants.TAG_RATIO_RIGHT,
                        info.right);

                // The ratio is only needed for saving workspaces that can be read by old versions
                // of Eclipse. It is not used in newer versions of Eclipse, which use the "left"
                // and "right" attributes instead.
                childMem.putFloat(IWorkbenchConstants.TAG_RATIO, info
                        .getRatio());
            }

            // Is this part a folder or a placeholder for one?
            ViewStack folder = null;
            if (info.part instanceof ViewStack) {
                folder = (ViewStack) info.part;
            } else if (info.part instanceof ContainerPlaceholder) {
                LayoutPart part = ((ContainerPlaceholder) info.part)
                        .getRealContainer();
                if (part instanceof ViewStack) {
          folder = (ViewStack) part;
        }
            }

            // If this is a folder (ViewStack) save the contents.
            if (folder != null) {
                childMem.putString(IWorkbenchConstants.TAG_FOLDER, "true");//$NON-NLS-1$
               
                IMemento folderMem = childMem
                        .createChild(IWorkbenchConstants.TAG_FOLDER);
                result.add(folder.saveState(folderMem));
            }
        }
        return result;
View Full Code Here

Examples of org.eclipse.ui.IMemento

            }
        }
        String key = getKey(id, secondaryId);
        IViewReference ref = (IViewReference) counter.get(key);
        if (ref == null) {
            IMemento memento = (IMemento) mementoTable.get(key);
            ref = new ViewReference(this, id, secondaryId, memento);
            mementoTable.remove(key);
            counter.put(key, ref);
            getWorkbenchPage().partAdded((ViewReference)ref);
        } else {
View Full Code Here

Examples of org.eclipse.ui.IMemento

    
     * @param memento the <code>IMemento</code> to restore from.
     * @return <code>IStatus</code>
     */
    public IStatus restoreState(IMemento memento) {
        IMemento mem[] = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
        for (int i = 0; i < mem.length; i++) {
            //for dynamic UI - add the next line to replace subsequent code that is commented out
            restoreViewState(mem[i]);
        }
        return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
View Full Code Here

Examples of org.eclipse.ui.IMemento

    //  for dynamic UI
    public IMemento saveViewState(IMemento memento, IViewReference ref,
            MultiStatus res) {
        final MultiStatus result = res;
        final IMemento viewMemento = memento
                .createChild(IWorkbenchConstants.TAG_VIEW);
        viewMemento.putString(IWorkbenchConstants.TAG_ID, ViewFactory
                .getKey(ref));
        if (ref instanceof ViewReference) {
            viewMemento.putString(IWorkbenchConstants.TAG_PART_NAME,
                    ((ViewReference) ref).getPartName());
        }
        final IViewReference viewRef = ref;
        final IViewPart view = (IViewPart) ref.getPart(false);
        if (view != null) {
            SafeRunner.run(new SafeRunnable() {
                public void run() {
                  if (view instanceof IWorkbenchPart3) {
            Map properties = ((IWorkbenchPart3) view)
                .getPartProperties();
            if (!properties.isEmpty()) {
              IMemento propBag = viewMemento
                  .createChild(IWorkbenchConstants.TAG_PROPERTIES);
              Iterator i = properties.entrySet().iterator();
              while (i.hasNext()) {
                Map.Entry entry = (Map.Entry) i.next();
                IMemento p = propBag.createChild(
                    IWorkbenchConstants.TAG_PROPERTY,
                    (String) entry.getKey());
                p.putTextData((String) entry.getValue());
              }
            }
          }
                    view.saveState(viewMemento
                            .createChild(IWorkbenchConstants.TAG_VIEW_STATE));
                }

                public void handleException(Throwable e) {
                    result
                            .add(new Status(
                                    IStatus.ERROR,
                                    PlatformUI.PLUGIN_ID,
                                    0,
                                    NLS.bind(WorkbenchMessages.ViewFactory_couldNotSave, viewRef.getTitle() ),
                                    e));
                }
            });
        } else {
          IMemento mem = null;
          IMemento props = null;
         
          // if we've created the reference once, any previous workbench
          // state memento is there.  After once, there is no previous
          // session state, so it should be null.
      if (ref instanceof ViewReference) {
        mem = ((ViewReference) ref).getMemento();
        if (mem!=null) {
          props = mem.getChild(IWorkbenchConstants.TAG_PROPERTIES);
        }
        if (mem!=null) {
          mem = mem.getChild(IWorkbenchConstants.TAG_VIEW_STATE);
        }
      }
      if (props != null) {
        viewMemento.createChild(IWorkbenchConstants.TAG_PROPERTIES)
            .putMemento(props);
      }
      if (mem != null) {
        IMemento child = viewMemento
            .createChild(IWorkbenchConstants.TAG_VIEW_STATE);
        child.putMemento(mem);
      }
        }
        return viewMemento;
    }
View Full Code Here

Examples of org.eclipse.ui.IMemento

        String compoundId = memento.getString(IWorkbenchConstants.TAG_ID);
        mementoTable.put(compoundId, memento);
    }

    IMemento getViewState(String key) {
        IMemento memento = (IMemento) mementoTable.get(key);

        if (memento == null) {
            return null;
        }

        return memento.getChild(IWorkbenchConstants.TAG_VIEW_STATE);
    }
View Full Code Here

Examples of org.eclipse.ui.IMemento

  public void restoreState(IMemento memento) {
    if (memento == null)
      return;

    IMemento dir = memento.getChild("documentSource");
    if (dir != null) {
      String id = dir.getID();
      documentSource.setText(id);
    }

    IMemento dir2 = memento.getChild("documentSink");
    if (dir2 != null) {
      String id = dir2.getID();
      documentSink.setText(id);
    }

    IMemento tsName = memento.getChild("typeSystem");
    if (tsName != null) {
      String id = tsName.getID();
      typeSystem.setText(id);
    }

    for (IMemento eachMemento : memento.getChildren("selectedTypes")) {
      IMemento child = eachMemento.getChild("type");
      if (child != null) {
        selectedTypes.add(child.getID());
      }
    }

  }
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.