Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2012-02-09 09:54:27 +0000
committervlorenzo2012-02-09 09:54:27 +0000
commitb4ba4fed00cffbedbf47bf9d82b168f763ce5bf2 (patch)
tree59b21c751017f1fcea9090222fbfd1f7eb0e517b /sandbox/org.eclipse.papyrus.emf.commandstack
parentef457a584b01109e6ea485c5a109e566665e05ef (diff)
downloadorg.eclipse.papyrus-b4ba4fed00cffbedbf47bf9d82b168f763ce5bf2.tar.gz
org.eclipse.papyrus-b4ba4fed00cffbedbf47bf9d82b168f763ce5bf2.tar.xz
org.eclipse.papyrus-b4ba4fed00cffbedbf47bf9d82b168f763ce5bf2.zip
A save of my work
Diffstat (limited to 'sandbox/org.eclipse.papyrus.emf.commandstack')
-rw-r--r--sandbox/org.eclipse.papyrus.emf.commandstack/META-INF/MANIFEST.MF2
-rw-r--r--sandbox/org.eclipse.papyrus.emf.commandstack/src/org/eclipse/papyrus/emf/commandstack/view/CommandStackView.java100
2 files changed, 70 insertions, 32 deletions
diff --git a/sandbox/org.eclipse.papyrus.emf.commandstack/META-INF/MANIFEST.MF b/sandbox/org.eclipse.papyrus.emf.commandstack/META-INF/MANIFEST.MF
index e20751635cc..03e6b741cc6 100644
--- a/sandbox/org.eclipse.papyrus.emf.commandstack/META-INF/MANIFEST.MF
+++ b/sandbox/org.eclipse.papyrus.emf.commandstack/META-INF/MANIFEST.MF
@@ -7,7 +7,7 @@ Bundle-Activator: org.eclipse.papyrus.emf.commandstack.Activator
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.eclipse.emf.facet.common.ui;bundle-version="0.2.0",
+ org.eclipse.emf.facet.common.ui,
org.eclipse.emf.edit;bundle-version="2.7.1",
org.eclipse.papyrus.sasheditor;bundle-version="0.8.2",
org.eclipse.papyrus.core;bundle-version="0.8.2"
diff --git a/sandbox/org.eclipse.papyrus.emf.commandstack/src/org/eclipse/papyrus/emf/commandstack/view/CommandStackView.java b/sandbox/org.eclipse.papyrus.emf.commandstack/src/org/eclipse/papyrus/emf/commandstack/view/CommandStackView.java
index c4d09b61781..aab36f2c6ad 100644
--- a/sandbox/org.eclipse.papyrus.emf.commandstack/src/org/eclipse/papyrus/emf/commandstack/view/CommandStackView.java
+++ b/sandbox/org.eclipse.papyrus.emf.commandstack/src/org/eclipse/papyrus/emf/commandstack/view/CommandStackView.java
@@ -29,9 +29,12 @@ import org.eclipse.core.commands.operations.IOperationHistoryListener;
import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.core.commands.operations.OperationHistoryEvent;
import org.eclipse.core.commands.operations.OperationHistoryFactory;
+import org.eclipse.emf.common.command.AbstractCommand;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.facet.common.ui.internal.views.AbstractTreeView;
+import org.eclipse.emf.workspace.EMFCommandOperation;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IToolBarManager;
@@ -52,35 +55,46 @@ public class CommandStackView extends AbstractTreeView {
public CommandStackView() {
this.history = OperationHistoryFactory.getOperationHistory();
- this.history.addOperationHistoryListener(new IOperationHistoryListener() {
+ this.history
+ .addOperationHistoryListener(new IOperationHistoryListener() {
+
+ public void historyNotification(
+ final OperationHistoryEvent event) {
+ if (!CommandStackView.this.commandList.contains(event
+ .getOperation())) {
+ if (CommandStackView.this.commandList.size() == CommandStackView.this.maxSize) {
+ CommandStackView.this.commandList
+ .remove(CommandStackView.this.maxSize - 1);
+ }
+ CommandStackView.this.commandList.add(0,
+ event.getOperation());
+ final DateFormat dateFormat = new SimpleDateFormat(
+ "HH:mm:ss");
+ final Calendar cal = Calendar.getInstance();
+ CommandStackView.this.dates.put(
+ event.getOperation(),
+ dateFormat.format(cal.getTime()));
+ refresh(true);
+ }
- public void historyNotification(final OperationHistoryEvent event) {
- if(!CommandStackView.this.commandList.contains(event.getOperation())) {
- if(CommandStackView.this.commandList.size() == CommandStackView.this.maxSize) {
- CommandStackView.this.commandList.remove(CommandStackView.this.maxSize - 1);
}
- CommandStackView.this.commandList.add(0, event.getOperation());
- final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
- final Calendar cal = Calendar.getInstance();
- CommandStackView.this.dates.put(event.getOperation(), dateFormat.format(cal.getTime()));
- refresh(true);
- }
-
- }
- });
+ });
};
@Override
protected void createColumns() {
createNameColumn();
+ createDescriptionColumn();
createCommandTypeColumn();
createTimeColumn();
+
}
@Override
public void createPartControl(final org.eclipse.swt.widgets.Composite parent) {
super.createPartControl(parent);
- final IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager();
+ final IToolBarManager tbm = getViewSite().getActionBars()
+ .getToolBarManager();
tbm.add(new Action() {
@Override
@@ -107,7 +121,6 @@ public class CommandStackView extends AbstractTreeView {
});
}
-
private void createCommandTypeColumn() {
final ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() {
@@ -124,21 +137,38 @@ public class CommandStackView extends AbstractTreeView {
@Override
public String getText(final Object element) {
- if(element instanceof AbstractOperation) {
- return ((AbstractOperation)element).getLabel();
+ if (element instanceof AbstractOperation) {
+ return ((AbstractOperation) element).getLabel();
+ } else if (element instanceof AbstractCommand) {
+ return ((AbstractCommand) element).getLabel();
}
- return "no managed or no named";
+ return "no managed";
}
};
createColumn("Name", "NAME_COLUMN_ID", 200, columnLabelProvider);
}
+
+ protected void createDescriptionColumn() {
+ final ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() {
+
+ @Override
+ public String getText(final Object element) {
+ if (element instanceof AbstractCommand) {
+ return ((AbstractCommand) element).getDescription();
+ }
+ return "no description";
+ }
+ };
+ createColumn("Description", "DESCRIPTION_COLUMN_ID", 200, columnLabelProvider);
+ }
+
protected void createTimeColumn() {
final ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() {
@Override
public String getText(final Object element) {
- if(CommandStackView.this.dates.containsKey(element)) {
+ if (CommandStackView.this.dates.containsKey(element)) {
return CommandStackView.this.dates.get(element);
}
return "";
@@ -152,16 +182,17 @@ public class CommandStackView extends AbstractTreeView {
return new ITreeContentProvider() {
public Object[] getElements(final Object inputElement) {
- if(inputElement instanceof Command) {
- return new Object[]{ inputElement };
- } else if(inputElement instanceof Collection<?>) {
- return ((Collection<?>)inputElement).toArray();
+ if (inputElement instanceof Command) {
+ return new Object[] { inputElement };
+ } else if (inputElement instanceof Collection<?>) {
+ return ((Collection<?>) inputElement).toArray();
}
return new Object[0];
}
- public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
+ public void inputChanged(final Viewer viewer,
+ final Object oldInput, final Object newInput) {
// nothing
}
@@ -178,15 +209,22 @@ public class CommandStackView extends AbstractTreeView {
}
public Object[] getChildren(final Object parentElement) {
- if(parentElement instanceof CompoundCommand) {
- return ((CompoundCommand)parentElement).getCommandList().toArray();
- } else if(parentElement instanceof CompositeCommand) {
+ if (parentElement instanceof CompoundCommand) {
+ return ((CompoundCommand) parentElement).getCommandList()
+ .toArray();
+ } else if (parentElement instanceof CompositeCommand) {
final List<Object> children = new ArrayList<Object>();
- final ListIterator<Object> iter = ((CompositeCommand)parentElement).listIterator();
- while(iter.hasNext()) {
+ final ListIterator<Object> iter = ((CompositeCommand) parentElement)
+ .listIterator();
+ while (iter.hasNext()) {
children.add(iter.next());
}
return children.toArray();
+ } else if (parentElement instanceof EMFCommandOperation) {
+ final List<Object> children = new ArrayList<Object>();
+ children.add(((EMFCommandOperation) parentElement)
+ .getCommand());
+ return children.toArray();
}
return new Object[0];
}
@@ -204,7 +242,7 @@ public class CommandStackView extends AbstractTreeView {
return "Refresh CommandStack View";
}
- private Object result[];//= new Object[1];
+ private Object result[];// = new Object[1];
@Override
protected Object getInput() {

Back to the top