org.eclipse.ui.IMemento#getChildren ( )源码实例Demo

下面列出了org.eclipse.ui.IMemento#getChildren ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private static Set<IReference> loadReferences(IMemento memento)
    throws PersistenceException {
  Set<IReference> references = new HashSet<IReference>();

  boolean hadException = false;

  for (IMemento childMemento : memento.getChildren(KEY_REFERENCE)) {
    try {
      IReference loadedReference = loadReference(childMemento);
      if (loadedReference != null) {
        references.add(loadedReference);
      }
    } catch (PersistenceException e) {
      CorePluginLog.logError(e, "Error loading persisted reference.");
      hadException = true;
    }
  }

  if (hadException) {
    throw new PersistenceException(
        "Error loading all the references, check log for more details.");
  }

  return references;
}
 
public static UiBinderSubtypeToOwnerIndex load(IMemento memento)
    throws PersistenceException {
  UiBinderSubtypeToOwnerIndex index = new UiBinderSubtypeToOwnerIndex();

  boolean hadException = false;

  for (IMemento childMemento : memento.getChildren(KEY_UIBINDER_SUBTYPE_AND_OWNER_ENTRY)) {
    try {
      UiBinderSubtypeAndOwner subtypeAndOwner = UiBinderSubtypeAndOwner.load(childMemento);
      if (subtypeAndOwner != null) {
        index.setOwnerType(subtypeAndOwner);
      }
    } catch (PersistenceException e) {
      CorePluginLog.logError(e, "Error loading persisted index entry.");
      hadException = true;
    }
  }

  if (hadException) {
    throw new PersistenceException(
        "Error loading all the references, check log for more details.");
  }

  return index;
}
 
public static UiXmlReferencedFieldIndex load(IMemento memento)
    throws PersistenceException {
  UiXmlReferencedFieldIndex index = new UiXmlReferencedFieldIndex();

  boolean hadException = false;

  for (IMemento childMemento : memento.getChildren(KEY_UI_FIELD_REF)) {
    try {
      loadFieldRef(childMemento, index);
    } catch (PersistenceException e) {
      CorePluginLog.logError(e, "Error loading persisted index entry.");
      hadException = true;
    }
  }

  if (hadException) {
    throw new PersistenceException(
        "Error loading all the references, check log for more details.");
  }

  return index;
}
 
public static UiBinderSubtypeToUiXmlIndex load(IMemento memento)
    throws PersistenceException {
  UiBinderSubtypeToUiXmlIndex index = new UiBinderSubtypeToUiXmlIndex();

  boolean hadException = false;

  for (IMemento childMemento : memento.getChildren(KEY_UIBINDER_SUBTYPE_AND_UI_XML_ENTRY)) {
    try {
      loadEntry(childMemento, index);
    } catch (PersistenceException e) {
      CorePluginLog.logError(e, "Error loading persisted index entry.");
      hadException = true;
    }
  }

  if (hadException) {
    throw new PersistenceException(
        "Error loading all the references, check log for more details.");
  }

  return index;
}
 
源代码5 项目: neoscada   文件: RealTimeListViewer.java
public void loadFrom ( final IMemento memento )
{
    if ( memento == null )
    {
        return;
    }

    try
    {
        {
            this.initialColWidth = new LinkedList<Integer> ();
            final IMemento tableMemento = memento.getChild ( "tableCols" ); //$NON-NLS-1$
            if ( tableMemento != null )
            {
                int i = 0;
                Integer w;
                while ( ( w = tableMemento.getInteger ( "col_" + i ) ) != null ) //$NON-NLS-1$
                {
                    this.initialColWidth.add ( w );
                    i++;
                }
            }
        }

        for ( final IMemento child : memento.getChildren ( "item" ) ) //$NON-NLS-1$
        {
            final Item item = Item.loadFrom ( child );
            if ( item != null )
            {
                this.list.add ( item );
            }
        }
    }
    catch ( final Exception e )
    {
        Activator.getDefault ().getLog ().log ( new Status ( IStatus.ERROR, Activator.PLUGIN_ID, Messages.RealTimeListViewer_ErrorLoadingData, e ) );
    }
}
 
private void loadCuDependencies(IMemento cuNode) {
  String cuHandle = cuNode.getString(ATTR_COMPILATION_UNIT);
  if (cuHandle == null) {
    CorePluginLog.logError("Loading index {0}: Missing attribute {1}",
        indexName, ATTR_COMPILATION_UNIT);
    return;
  }

  ICompilationUnit cu = (ICompilationUnit) JavaCore.create(cuHandle);
  // Verify the compilation unit still exists
  if (cu == null || !cu.exists()) {
    CorePluginLog.logError(
        "Loading index {0}: compilation unit no longer exists ({1})",
        indexName, cuHandle);
    return;
  }

  Set<IPath> resourcePaths = new HashSet<IPath>();
  for (IMemento resNode : cuNode.getChildren(TAG_RESOURCE)) {
    IPath resourcePath = getResourcePath(resNode);
    if (resourcePath == null) {
      CorePluginLog.logError("Loading index {0}: missing attribute {1}",
          indexName, ATTR_RESOURCE_PATH);
      continue;
    }

    resourcePaths.add(resourcePath);
  }

  // Now add these dependencies to the index
  index.putLeftToManyRights(cu, resourcePaths);
}
 
源代码7 项目: APICloud-Studio   文件: InputURLDialog.java
private final void loadList() {
	IMemento memento = getMemento();
	if (memento == null) {
		return;
	}
	IMemento[] list = memento.getChildren(URL);
	for(int i = 0; i < list.length; ++i) {
		combo.add(list[i].getTextData());
	}
}
 
private void restoreUserDefinedPatterns(IMemento memento) {
	IMemento userDefinedPatterns= memento.getChild(TAG_USER_DEFINED_PATTERNS);
	if(userDefinedPatterns != null) {
		IMemento children[]= userDefinedPatterns.getChildren(TAG_CHILD);
		String[] patterns= new String[children.length];
		for (int i = 0; i < children.length; i++)
			patterns[i]= children[i].getString(TAG_PATTERN);

		setUserDefinedPatterns(patterns);
	} else
		setUserDefinedPatterns(new String[0]);
}
 
private void restoreXmlDefinedFilters(IMemento memento) {
	IMemento xmlDefinedFilters= memento.getChild(TAG_XML_DEFINED_FILTERS);
	if(xmlDefinedFilters != null) {
		IMemento[] children= xmlDefinedFilters.getChildren(TAG_CHILD);
		for (int i= 0; i < children.length; i++) {
			String id= children[i].getString(TAG_FILTER_ID);
			Boolean isEnabled= Boolean.valueOf(children[i].getString(TAG_IS_ENABLED));
			FilterItem item= fFilterItems.get(id);
			if (item != null) {
				item.enabled= isEnabled.booleanValue();
			}
		}
	}
}
 
private void restoreLRUFilters(IMemento memento) {
	IMemento lruFilters= memento.getChild(TAG_LRU_FILTERS);
	fLRUFilterIdsStack.clear();
	if(lruFilters != null) {
		IMemento[] children= lruFilters.getChildren(TAG_CHILD);
		for (int i= 0; i < children.length; i++) {
			String id= children[i].getString(TAG_FILTER_ID);
			if (fFilterItems.containsKey(id) && !fLRUFilterIdsStack.contains(id))
				fLRUFilterIdsStack.push(id);
		}
	}
}
 
private ISelection restoreSelectionState(IMemento memento) {
	if (memento == null)
		return null;

	IMemento childMem;
	childMem= memento.getChild(TAG_SELECTED_ELEMENTS);
	if (childMem != null) {
		ArrayList<Object> list= new ArrayList<Object>();
		IMemento[] elementMem= childMem.getChildren(TAG_SELECTED_ELEMENT);
		for (int i= 0; i < elementMem.length; i++) {
			String javaElementHandle= elementMem[i].getString(TAG_SELECTED_ELEMENT_PATH);
			if (javaElementHandle == null) {
				// logical package
				IMemento[] packagesMem= elementMem[i].getChildren(TAG_LOGICAL_PACKAGE);
				LogicalPackage lp= null;
				for (int j= 0; j < packagesMem.length; j++) {
					javaElementHandle= packagesMem[j].getString(TAG_SELECTED_ELEMENT_PATH);
					Object pack= JavaCore.create(javaElementHandle);
					if (pack instanceof IPackageFragment && ((IPackageFragment)pack).exists()) {
						if (lp == null)
							lp= new LogicalPackage((IPackageFragment)pack);
						else
							lp.add((IPackageFragment)pack);
					}
				}
				if (lp != null)
					list.add(lp);
			} else {
				IJavaElement element= JavaCore.create(javaElementHandle);
				if (element != null && element.exists())
					list.add(element);
			}
		}
		return new StructuredSelection(list);
	}
	return null;
}
 
源代码12 项目: tmxeditor8   文件: TmxEditorHistory.java
/**
 * Restore the most-recently-used history from the given memento.
 * @param memento
 *            the memento to restore the mru history from
 */
public IStatus restoreState(IMemento memento) {
	IMemento[] mementos = memento.getChildren(rootTag);
	for (int i = 0; i < mementos.length; i++) {
		TmxEditorHistoryItem item = new TmxEditorHistoryItem(mementos[i]);
		if ((item.getType() == TmxEditorHistoryItem.TYPE_HSTM || item.getType() == TmxEditorHistoryItem.TYPE_TMX)
				&& item.getPath() != null && item.getPath().length() != 0)
			add(item, fifoList.size());
	}
	return Status.OK_STATUS;
}