1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package pl.edu.agh.cast.backward.command;
19
20
21 import java.lang.reflect.InvocationTargetException;
22
23 import org.apache.log4j.Logger;
24 import org.eclipse.core.runtime.IProgressMonitor;
25 import org.eclipse.gef.commands.Command;
26 import org.eclipse.jface.operation.IRunnableWithProgress;
27 import org.eclipse.osgi.util.NLS;
28
29 import pl.edu.agh.cast.Activator;
30 import pl.edu.agh.cast.CastApplication;
31 import pl.edu.agh.cast.backward.editor.EditorUtilBackward;
32 import pl.edu.agh.cast.model.base.IDataSet;
33 import pl.edu.agh.cast.model.visual.backward.IDiagram;
34 import pl.edu.agh.cast.ui.util.MsgBoxHelper;
35 import pl.edu.agh.cast.util.IExceptionHandler;
36 import pl.edu.agh.cast.util.Messages;
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 public class EnhanceNodesCommand extends Command {
52
53 private static Logger log = Activator.getLogger();
54
55 private IDiagram diagram;
56
57 private IDataSet dataSet;
58
59
60
61
62
63
64
65
66
67 public EnhanceNodesCommand(IDiagram diagram, IDataSet dataSet) {
68 this.diagram = diagram;
69 this.dataSet = dataSet;
70 }
71
72
73
74
75
76
77
78
79 @Override
80 public boolean canUndo() {
81 return false;
82 }
83
84
85
86
87
88
89 @Override
90 public void execute() {
91 EditorUtilBackward.runWithProgressMonitorInUIThread(new IRunnableWithProgress() {
92 public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
93 diagram.addAttributesFromEntities(dataSet.getEntities(), null, null, null, monitor);
94 }
95 }, new IExceptionHandler() {
96 public void handleException(Exception e) {
97 String message = NLS.bind(Messages.EnhanceNodesCommand_0, dataSet.getId(), diagram.getDisplayName());
98 MsgBoxHelper.showErrorBox(CastApplication.getActiveShell(), Messages.OperationError, message);
99 log.error(message, e);
100 }
101 });
102 }
103
104
105
106
107
108
109 @Override
110 public void undo() {
111
112 }
113
114 }