commit 0d8040b674e9f099e43de8d75b1a9ebf1d7a2285
Author: Cherian Mathew <c.mathew@bgbm.org>
Date:   Thu Nov 15 15:56:52 2012 +0000

    PolytomousKeyListEditor.java : changed table view for polytomous key nodes added edges column to make it more clear.
    PolytomousKeyListLabelProvider.java : added labels for edges and updated node number function
    RefreshNodeNumberingOperation.java : calls the refreshing node function in PolytomousKeyNode

diff --git a/.gitattributes b/.gitattributes
index 2253a2035..362e8c44f 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -380,6 +380,7 @@ eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/po
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/handler/RefreshNodeNumberingHandler.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/operation/CreateNodeOperation.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/operation/DeleteNodeOperation.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/operation/RefreshNodeNumberingOperation.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditor.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/container/AbstractGroup.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/container/AbstractGroupedContainer.java -text
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListEditor.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListEditor.java
index 22b139305..9d533a832 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListEditor.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListEditor.java
@@ -75,13 +75,13 @@ public class PolytomousKeyListEditor extends EditorPart implements
 		        PolytomousKeyNode node = (PolytomousKeyNode) getTableItem(
                         table, point).getData();
                 
-		        if (selectedColumn == 3) {		
+		        if (selectedColumn == 4) {		
 		            PolytomousKeyNode linkData = getItemLinkData(node);
 		            if (linkData != null) {
 		                viewer.setSelection(new StructuredSelection(linkData), true);
 		            } 
 		        }
-		        if (selectedColumn == 4) {
+		        if (selectedColumn == 5) {
 		            Taxon taxon = getItemTaxon(node);
 		            if (taxon != null) {
 		                try {
@@ -277,8 +277,8 @@ public class PolytomousKeyListEditor extends EditorPart implements
 	// This will create the columns for the table
 	private void createColumns(TableViewer viewer) {
 		Table table = viewer.getTable();
-		String[] titles = { "Node Number", "Question", "Statement", "Link", "Taxon" };
-		int[] bounds = { 50, 200, 200, 100, 200 };
+		String[] titles = { "Node", "Question", "Edge",  "Statement", "Link", "Taxon" };
+		int[] bounds = { 50, 200, 50, 200, 100, 200 };
 
 		for (int i = 0; i < titles.length; i++) {
 			TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListLabelProvider.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListLabelProvider.java
index a79850249..1e42919e7 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListLabelProvider.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListLabelProvider.java
@@ -21,6 +21,7 @@ import org.eclipse.swt.graphics.TextStyle;
 import org.eclipse.swt.widgets.Display;
 
 import eu.etaxonomy.cdm.common.CdmUtils;
+import eu.etaxonomy.cdm.model.common.Language;
 import eu.etaxonomy.cdm.model.description.KeyStatement;
 import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
 import eu.etaxonomy.taxeditor.store.CdmStore;
@@ -56,9 +57,11 @@ public class PolytomousKeyListLabelProvider extends StyledCellLabelProvider {
 
 			String text = getTextForColumnIndex((PolytomousKeyNode) element,
 					columnIndex);
+			
+			
 			cell.setText(text);
 
-			if (columnIndex == 3 || columnIndex == 4) {
+			if (columnIndex == 4 || columnIndex == 5) {
 				StyledString styledString = new StyledString(text, getStyler());
 				StyleRange[] styleRanges;
 				styleRanges = styledString.getStyleRanges();
@@ -74,12 +77,14 @@ public class PolytomousKeyListLabelProvider extends StyledCellLabelProvider {
 		case 0:
 			return getItemNumber(node);
 		case 1:
-			return getItemQuestion(node);
+			return getItemQuestion(node);			
 		case 2:
-			return getItemStatement(node);
+			return getItemEdgeNumber(node);
 		case 3:
-			return getItemLink(node);
+			return getItemStatement(node);
 		case 4:
+			return getItemLink(node);
+		case 5:
             return getItemTaxon(node);
 		}
 		return EMPTY;
@@ -107,27 +112,30 @@ public class PolytomousKeyListLabelProvider extends StyledCellLabelProvider {
 		if (isParentRoot(node)) {
 			return "root";
 		} else {
-			PolytomousKeyNode parent = getParent(node);
-			String itemNumber = parent.getNodeNumber() != null ? parent
-					.getNodeNumber().toString() : EMPTY;
-
-			int index = parent.getChildren().indexOf(node);
-
-			for (int i = 0; i < index; i++) {
-				itemNumber += INCREMENTOR_CHARACTER;
-			}
-
+			
+			String itemNumber = node.getNodeNumber() != null ? node.getNodeNumber().toString() : EMPTY;			
 			return itemNumber;
 		}
 	}
 
+	private String getItemEdgeNumber(PolytomousKeyNode node) {
+		String itemEdgeNumber = node.getNodeNumber() != null ? node.getNodeNumber().toString() : EMPTY;		
+		PolytomousKeyNode parent = getParent(node);
+		int index = parent.getChildren().indexOf(node);
+
+		for (int i = 0; i < index + 1; i++) {
+			itemEdgeNumber += INCREMENTOR_CHARACTER;
+		}
+		return itemEdgeNumber;
+	}
+	
 	private String getItemQuestion(PolytomousKeyNode node) {
 		if (isParentRoot(node)) {
 			return "";
 		} else {
-			KeyStatement question = getParent(node).getQuestion();
-			return question != null ? question.getLabelText(CdmStore
-					.getDefaultLanguage()) : EMPTY;
+			KeyStatement question = getParent(node).getQuestion();					
+			return question != null ? CdmUtils.Nz(question.getLabelText(CdmStore.getDefaultLanguage())) : EMPTY;
+			
 		}
 
 	}
@@ -139,7 +147,7 @@ public class PolytomousKeyListLabelProvider extends StyledCellLabelProvider {
 	}
 
 	private String getItemLink(PolytomousKeyNode node) {
-		String linkString = node.getChildren().isEmpty() ? EMPTY : node.getNodeNumber().toString();
+		String linkString = node.getChildren().isEmpty() ? EMPTY : node.getChildren().get(0).getNodeNumber().toString();
 
 		return linkString;
 	}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/operation/RefreshNodeNumberingOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/operation/RefreshNodeNumberingOperation.java
new file mode 100644
index 000000000..9b05eb364
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/operation/RefreshNodeNumberingOperation.java
@@ -0,0 +1,64 @@
+package eu.etaxonomy.taxeditor.editor.key.polytomous.operation;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+
+/**
+ * Operation responsible for refreshing node numbers of the Polytomous Key Nodes.
+ * The refresh is performed on the entire Key starting from the root.
+ * 
+ * @author c.mathew
+ *
+ */
+public class RefreshNodeNumberingOperation extends AbstractPostOperation {
+
+	PolytomousKeyNode node;
+	private PolytomousKeyNode childNode;
+	
+	public RefreshNodeNumberingOperation(String label,
+			IUndoContext undoContext, 
+			PolytomousKeyNode node, 
+			IPostOperationEnabled postOperationEnabled) {
+		super(label, undoContext, postOperationEnabled);
+		this.node = node;
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+	 */
+	@Override
+	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+			throws ExecutionException {
+
+		node.refreshNodeNumbering();
+		return postExecute(childNode);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+	 */
+	@Override
+	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
+			throws ExecutionException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+	 */
+	@Override
+	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
+			throws ExecutionException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}
