Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365181 - [Workbench] XMLMemento method to enumerate all child nodes
Summary: [Workbench] XMLMemento method to enumerate all child nodes
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 4.2 M5   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2011-11-30 07:38 EST by Christian Pontesegger CLA
Modified: 2012-01-24 13:56 EST (History)
1 user (show)

See Also:


Attachments
Patch containing getChildren() Method (1.22 MB, patch)
2012-01-16 06:24 EST, Christian Pontesegger CLA
no flags Details | Diff
adding getChildren() for IMemento (3.87 KB, patch)
2012-01-23 03:51 EST, Christian Pontesegger CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Pontesegger CLA 2011-11-30 07:38:50 EST
Build Identifier: 

It would be great to have a method getChildren() that enumerates all children of a node.

Something like:
public IMemento[] getChildren() {

		final List<IMemento> result = new LinkedList<IMemento>();

		// Get the nodes.
		final NodeList nodes = element.getChildNodes();
		final int size = nodes.getLength();
		if (size == 0) {
			return new IMemento[0];
		}

		// Extract each node with given type.
		for (int nX = 0; nX < size; nX++) {
			final Node node = nodes.item(nX);
			if (node instanceof Element)
				result.add(new EnhancedXMLMemento(factory, (Element) node));
		}

		return result.toArray(new IMemento[result.size()]);
	}


Reproducible: Always
Comment 1 Paul Webster CLA 2011-11-30 14:27:22 EST
If you'd like to add that method I'd consider a patch.  You'd have to add the method in 3 places:

org.eclipse.ui.IMemento
org.eclipse.ui.XMLMemento
org.eclipse.ui.internal.util.ConfigurationElementMemento

They're all in org.eclipse.ui.workbench.  See http://wiki.eclipse.org/Platform_UI/How_to_Contribute for how to contribute.

PW
Comment 2 Remy Suen CLA 2011-11-30 15:23:14 EST
org.eclipse.ui.tests.internal.TestMemento in the org.eclipse.ui.tests bundle will also have to be updated.
Comment 3 Christian Pontesegger CLA 2012-01-16 06:24:20 EST
Created attachment 209545 [details]
Patch containing getChildren() Method

So this is my first patch to eclipse. The file seems rather big. I hope I did this right.
Comment 4 Paul Webster CLA 2012-01-16 07:35:34 EST
(In reply to comment #3)
> Created attachment 209545 [details]
> Patch containing getChildren() Method
> 
> So this is my first patch to eclipse. The file seems rather big. I hope I did
> this right.

Unfortunately, no.  That looks like it contains a diff between 2 streams (hence the large file).

Have a look at http://wiki.eclipse.org/Platform-releng/Git_Workflows#Create_a_patch

You should be able to find the commit with only your changes in it in the History view.  Then right-click on that commit and create a patch from that (just take the default, not a git format patch).  It should only contain the changes from your one commit.

Thank you,
PW
Comment 5 Christian Pontesegger CLA 2012-01-17 03:31:26 EST
(In reply to comment #4)
> You should be able to find the commit with only your changes in it in the
> History view.  Then right-click on that commit and create a patch from that
> (just take the default, not a git format patch).  It should only contain the
> changes from your one commit.

Did exactly that. I cloned the R3_development branch, added one method to 4 different files, opened history view, found my commit, right click -> create patch.

Do I have to clone a different branch?
Comment 6 Paul Webster CLA 2012-01-17 07:13:17 EST
(In reply to comment #5)
> 
> Did exactly that. I cloned the R3_development branch, added one method to 4
> different files, opened history view, found my commit, right click -> create
> patch.


That's the right pattern (with a commit step between adding the methods and opening the history view).  But the patch should be a small diff file, and yours has unrelated changes in it.

After your commit, try going to the Git Repo Explorer, select your repo, and do Show In>History.  If you create the patch from there, is it as big?

You might have to reset your branch on origin/R3_development, pull, and add your changes back.

> Do I have to clone a different branch?

You're in the right branch.

PW
Comment 7 Christian Pontesegger CLA 2012-01-23 03:51:31 EST
Created attachment 209893 [details]
adding getChildren() for IMemento

(In reply to comment #6)
> After your commit, try going to the Git Repo Explorer, select your repo, and do
> Show In>History.  If you create the patch from there, is it as big?

That did it, Thanks for providing a beginners git guide.
Comment 8 Paul Webster CLA 2012-01-23 12:04:03 EST
Released to master

PW
Comment 9 Paul Webster CLA 2012-01-24 13:56:03 EST
In I20120123-2200
PW