Java Code Examples for org.eclipse.ui.IMemento#getChildren()

The following examples show how to use org.eclipse.ui.IMemento#getChildren() . 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: ReferenceManagerPersister.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: UiBinderSubtypeToOwnerIndex.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: UiXmlReferencedFieldIndex.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: UiBinderSubtypeToUiXmlIndex.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example 5
Source File: RealTimeListViewer.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
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 ) );
    }
}
 
Example 6
Source File: CompilationUnitResourceDependencyIndex.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
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);
}
 
Example 7
Source File: InputURLDialog.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
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());
	}
}
 
Example 8
Source File: CustomFiltersActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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]);
}
 
Example 9
Source File: CustomFiltersActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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();
			}
		}
	}
}
 
Example 10
Source File: CustomFiltersActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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);
		}
	}
}
 
Example 11
Source File: JavaBrowsingPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 12
Source File: TmxEditorHistory.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}