]> git.argeo.org Git - gpl/argeo-slc.git/blob - cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionOverviewPage.java
Clarify SLC project structure.
[gpl/argeo-slc.git] / cms / org.argeo.slc.client.ui.dist / src / org / argeo / slc / client / ui / dist / editors / ModularDistVersionOverviewPage.java
1 package org.argeo.slc.client.ui.dist.editors;
2
3 import java.net.URL;
4 import java.util.ArrayList;
5 import java.util.HashMap;
6 import java.util.List;
7 import java.util.Map;
8
9 import javax.jcr.Node;
10 import javax.jcr.NodeIterator;
11 import javax.jcr.PropertyType;
12 import javax.jcr.RepositoryException;
13 import javax.jcr.Session;
14 import javax.jcr.query.QueryManager;
15 import javax.jcr.query.QueryResult;
16 import javax.jcr.query.qom.Constraint;
17 import javax.jcr.query.qom.DynamicOperand;
18 import javax.jcr.query.qom.QueryObjectModel;
19 import javax.jcr.query.qom.QueryObjectModelFactory;
20 import javax.jcr.query.qom.Selector;
21 import javax.jcr.query.qom.StaticOperand;
22
23 import org.apache.commons.logging.Log;
24 import org.apache.commons.logging.LogFactory;
25 import org.argeo.cms.ui.workbench.util.CommandUtils;
26 import org.argeo.eclipse.ui.EclipseUiUtils;
27 import org.argeo.jcr.JcrUtils;
28 import org.argeo.slc.SlcException;
29 import org.argeo.slc.SlcNames;
30 import org.argeo.slc.SlcTypes;
31 import org.argeo.slc.client.ui.dist.DistConstants;
32 import org.argeo.slc.client.ui.dist.DistImages;
33 import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
34 import org.argeo.slc.client.ui.dist.utils.DistNodeViewerComparator;
35 import org.argeo.slc.client.ui.dist.utils.HyperlinkAdapter;
36 import org.argeo.slc.repo.RepoConstants;
37 import org.argeo.slc.repo.RepoUtils;
38 import org.argeo.slc.repo.maven.MavenConventionsUtils;
39 import org.eclipse.aether.artifact.Artifact;
40 import org.eclipse.aether.artifact.DefaultArtifact;
41 import org.eclipse.jface.dialogs.IMessageProvider;
42 import org.eclipse.jface.viewers.ColumnLabelProvider;
43 import org.eclipse.jface.viewers.DoubleClickEvent;
44 import org.eclipse.jface.viewers.IDoubleClickListener;
45 import org.eclipse.jface.viewers.IStructuredContentProvider;
46 import org.eclipse.jface.viewers.IStructuredSelection;
47 import org.eclipse.jface.viewers.TableViewer;
48 import org.eclipse.jface.viewers.TableViewerColumn;
49 import org.eclipse.jface.viewers.Viewer;
50 import org.eclipse.swt.SWT;
51 import org.eclipse.swt.events.ModifyEvent;
52 import org.eclipse.swt.events.ModifyListener;
53 import org.eclipse.swt.events.SelectionAdapter;
54 import org.eclipse.swt.events.SelectionEvent;
55 import org.eclipse.swt.layout.FillLayout;
56 import org.eclipse.swt.layout.GridData;
57 import org.eclipse.swt.layout.GridLayout;
58 import org.eclipse.swt.widgets.Button;
59 import org.eclipse.swt.widgets.Composite;
60 import org.eclipse.swt.widgets.Label;
61 import org.eclipse.swt.widgets.Table;
62 import org.eclipse.swt.widgets.Text;
63 import org.eclipse.ui.PlatformUI;
64 import org.eclipse.ui.browser.IWebBrowser;
65 import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
66 import org.eclipse.ui.forms.IManagedForm;
67 import org.eclipse.ui.forms.editor.FormEditor;
68 import org.eclipse.ui.forms.editor.FormPage;
69 import org.eclipse.ui.forms.events.HyperlinkEvent;
70 import org.eclipse.ui.forms.widgets.FormToolkit;
71 import org.eclipse.ui.forms.widgets.Hyperlink;
72 import org.eclipse.ui.forms.widgets.ScrolledForm;
73
74 /**
75 * Show all modules contained in a given modular distribution as filter-able
76 * table
77 */
78 public class ModularDistVersionOverviewPage extends FormPage implements
79 SlcNames {
80
81 private final static Log log = LogFactory
82 .getLog(ModularDistVersionOverviewPage.class);
83
84 final static String PAGE_ID = "ModularDistVersionOverviewPage";
85
86 // Business Objects
87 private Node modularDistribution;
88 // private Node modularDistributionBase;
89
90 // This page widgets
91 private DistNodeViewerComparator comparator;
92 private TableViewer viewer;
93 private FormToolkit tk;
94 private Text filterTxt;
95 private final static String FILTER_HELP_MSG = "Enter filter criterion separated by a space";
96
97 public ModularDistVersionOverviewPage(FormEditor formEditor, String title,
98 Node modularDistribution) {
99 super(formEditor, PAGE_ID, title);
100 this.modularDistribution = modularDistribution;
101 }
102
103 @Override
104 protected void createFormContent(IManagedForm managedForm) {
105 // General settings for this page
106 ScrolledForm form = managedForm.getForm();
107 tk = managedForm.getToolkit();
108 Composite body = form.getBody();
109
110 GridLayout layout = new GridLayout(1, false);
111 layout.marginWidth = 5;
112 layout.marginRight = 15;
113 layout.verticalSpacing = 0;
114 body.setLayout(layout);
115 try {
116 form.setText(modularDistribution.hasProperty(SlcNames.SLC_NAME) ? modularDistribution
117 .getProperty(SlcNames.SLC_NAME).getString() : "");
118 form.setMessage(
119 modularDistribution
120 .hasProperty(DistConstants.SLC_BUNDLE_DESCRIPTION) ? modularDistribution
121 .getProperty(DistConstants.SLC_BUNDLE_DESCRIPTION)
122 .getString() : "", IMessageProvider.NONE);
123 } catch (RepositoryException re) {
124 throw new SlcException("Unable to get bundle name for node "
125 + modularDistribution, re);
126 }
127
128 // Main layout
129 Composite header = tk.createComposite(body);
130 header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
131 populateHeaderPart(header);
132
133 Composite moduleTablePart = tk.createComposite(body);
134 moduleTablePart.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
135 true));
136 populateModuleTablePart(moduleTablePart);
137 }
138
139 private void populateHeaderPart(Composite parent) {
140 GridLayout layout = new GridLayout(6, false);
141 layout.horizontalSpacing = 10;
142 parent.setLayout(layout);
143 try {
144 // 1st Line: Category, name version
145 createLT(
146 parent,
147 "Category",
148 modularDistribution.hasProperty(SlcNames.SLC_CATEGORY) ? modularDistribution
149 .getProperty(SlcNames.SLC_CATEGORY).getString()
150 : "");
151 createLT(
152 parent,
153 "Name",
154 modularDistribution.hasProperty(SlcNames.SLC_NAME) ? modularDistribution
155 .getProperty(SlcNames.SLC_NAME).getString() : "");
156 createLT(
157 parent,
158 "Version",
159 modularDistribution.hasProperty(SlcNames.SLC_VERSION) ? modularDistribution
160 .getProperty(SlcNames.SLC_VERSION).getString() : "");
161
162 // 2nd Line: Vendor, licence, sources
163 createLT(
164 parent,
165 "Vendor",
166 modularDistribution
167 .hasProperty(DistConstants.SLC_BUNDLE_VENDOR) ? modularDistribution
168 .getProperty(DistConstants.SLC_BUNDLE_VENDOR)
169 .getString() : "N/A");
170
171 createHyperlink(parent, "Licence", DistConstants.SLC_BUNDLE_LICENCE);
172 addSourceSourcesLink(parent);
173 } catch (RepositoryException re) {
174 throw new SlcException("Unable to get bundle name for node "
175 + modularDistribution, re);
176 }
177
178 }
179
180 private Text createLT(Composite parent, String labelValue, String textValue) {
181 Label label = tk.createLabel(parent, labelValue, SWT.RIGHT);
182 // label.setFont(EclipseUiUtils.getBoldFont(parent));
183 label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
184
185 // Add a trailing space to workaround a display glitch in RAP 1.3
186 Text text = new Text(parent, SWT.LEFT);
187 text.setText(textValue + " ");
188 text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
189 text.setEditable(false);
190 return text;
191 }
192
193 private void createHyperlink(Composite parent, String label,
194 String jcrPropName) throws RepositoryException {
195 tk.createLabel(parent, label, SWT.NONE);
196 if (modularDistribution.hasProperty(jcrPropName)) {
197 final Hyperlink link = tk.createHyperlink(parent,
198 modularDistribution.getProperty(jcrPropName).getString(),
199 SWT.NONE);
200 link.addHyperlinkListener(new HyperlinkAdapter() {
201 @Override
202 public void linkActivated(HyperlinkEvent e) {
203 try {
204 IWorkbenchBrowserSupport browserSupport = PlatformUI
205 .getWorkbench().getBrowserSupport();
206 IWebBrowser browser = browserSupport
207 .createBrowser(
208 IWorkbenchBrowserSupport.LOCATION_BAR
209 | IWorkbenchBrowserSupport.NAVIGATION_BAR,
210 "SLC Distribution browser",
211 "SLC Distribution browser",
212 "A tool tip");
213 browser.openURL(new URL(link.getText()));
214 } catch (Exception ex) {
215 throw new SlcException("error opening browser", ex); //$NON-NLS-1$
216 }
217 }
218 });
219 } else
220 tk.createLabel(parent, "N/A", SWT.NONE);
221 }
222
223 // helper to check if sources are available
224 private void addSourceSourcesLink(Composite parent) {
225 try {
226 String srcPath = RepoUtils.relatedPdeSourcePath(
227 RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH,
228 modularDistribution);
229 if (!modularDistribution.getSession().nodeExists(srcPath)) {
230 createLT(parent, "Sources", "N/A");
231 } else {
232 final Node sourcesNode = modularDistribution.getSession()
233 .getNode(srcPath);
234
235 String srcName = null;
236 if (sourcesNode.hasProperty(SlcNames.SLC_SYMBOLIC_NAME))
237 srcName = sourcesNode.getProperty(
238 SlcNames.SLC_SYMBOLIC_NAME).getString();
239 else
240 srcName = sourcesNode.getName();
241 Label label = tk.createLabel(parent, "Sources", SWT.RIGHT);
242 label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
243 false));
244 Hyperlink link = tk.createHyperlink(parent, srcName, SWT.NONE);
245 link.addHyperlinkListener(new OpenFileLinkListener(sourcesNode
246 .getPath()));
247 }
248 } catch (RepositoryException e) {
249 throw new SlcException("Unable to configure sources link for "
250 + modularDistribution, e);
251 }
252 }
253
254 private class OpenFileLinkListener extends HyperlinkAdapter {
255 final private String path;
256
257 public OpenFileLinkListener(String path) {
258 this.path = path;
259 }
260
261 @Override
262 public void linkActivated(HyperlinkEvent e) {
263 log.warn("File download must be implemented. Cannot provide access to "
264 + path);
265
266 // try {
267 // ModuleEditorInput editorInput = (ModuleEditorInput)
268 // getEditorInput();
269 // Map<String, String> params = new HashMap<String, String>();
270 // params.put(OpenJcrFile.PARAM_REPO_NODE_PATH,
271 // editorInput.getRepoNodePath());
272 // params.put(OpenJcrFile.PARAM_REPO_URI, editorInput.getUri());
273 // params.put(OpenJcrFile.PARAM_WORKSPACE_NAME,
274 // editorInput.getWorkspaceName());
275 // params.put(OpenJcrFile.PARAM_FILE_PATH, path);
276 //
277 // String cmdId = (new OpenJcrFileCmdId()).getCmdId();
278 // CommandUtils.callCommand(cmdId, params);
279 // } catch (Exception ex) {
280 // throw new SlcException("error opening browser", ex); //$NON-NLS-1$
281 // }
282 }
283 }
284
285 private void populateModuleTablePart(Composite parent) {
286 GridLayout layout = new GridLayout(1, false);
287 layout.marginWidth = layout.horizontalSpacing = 0;
288 layout.verticalSpacing = 5;
289 layout.marginTop = 15;
290 parent.setLayout(layout);
291 // A sub title
292 Label label = tk.createLabel(parent,
293 "Modules included in the current distribution", SWT.NONE);
294 label.setFont(EclipseUiUtils.getBoldFont(parent));
295
296 // Add the filter section
297 Composite filterPart = tk.createComposite(parent);
298 filterPart.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
299 createFilterPart(filterPart);
300
301 // Add the table
302 Composite tablePart = tk.createComposite(parent);
303 tablePart.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
304 createTableViewer(tablePart);
305 // populate it on first pass.
306 refresh();
307 }
308
309 private void createFilterPart(Composite parent) {
310 GridLayout layout = new GridLayout(2, false);
311 layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0;
312 layout.horizontalSpacing = 5;
313 parent.setLayout(layout);
314
315 // Text Area to filter
316 filterTxt = tk.createText(parent, "", SWT.BORDER | SWT.SINGLE
317 | SWT.SEARCH | SWT.CANCEL);
318 filterTxt.setMessage(FILTER_HELP_MSG);
319 filterTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
320 filterTxt.addModifyListener(new ModifyListener() {
321 private static final long serialVersionUID = -276152321986407726L;
322
323 public void modifyText(ModifyEvent event) {
324 refresh();
325 }
326 });
327
328 Button resetBtn = tk.createButton(parent, null, SWT.PUSH);
329 resetBtn.setImage(DistImages.IMG_CLEAR);
330 resetBtn.addSelectionListener(new SelectionAdapter() {
331 private static final long serialVersionUID = -3549303742841670919L;
332
333 public void widgetSelected(SelectionEvent e) {
334 filterTxt.setText("");
335 filterTxt.setMessage(FILTER_HELP_MSG);
336 }
337 });
338 }
339
340 private void createTableViewer(Composite parent) {
341 parent.setLayout(new FillLayout());
342 // helpers to enable sorting by column
343 List<String> propertiesList = new ArrayList<String>();
344 List<Integer> propertyTypesList = new ArrayList<Integer>();
345
346 // Define the TableViewer
347 viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
348 | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
349
350 // Name
351 TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
352 col.getColumn().setWidth(220);
353 col.getColumn().setText("Category");
354 col.setLabelProvider(new ColumnLabelProvider() {
355 private static final long serialVersionUID = 5875398301711336875L;
356
357 @Override
358 public String getText(Object element) {
359 return JcrUtils.get((Node) element, SlcNames.SLC_CATEGORY);
360 }
361 });
362 col.getColumn().addSelectionListener(getSelectionAdapter(0));
363 propertiesList.add(SlcNames.SLC_CATEGORY);
364 propertyTypesList.add(PropertyType.STRING);
365
366 // Symbolic name
367 col = new TableViewerColumn(viewer, SWT.NONE);
368 col.getColumn().setWidth(220);
369 col.getColumn().setText("Name");
370 col.setLabelProvider(new ColumnLabelProvider() {
371 private static final long serialVersionUID = 3880240676256465072L;
372
373 @Override
374 public String getText(Object element) {
375 return JcrUtils.get((Node) element, SLC_NAME);
376 }
377 });
378 col.getColumn().addSelectionListener(getSelectionAdapter(1));
379 propertiesList.add(SLC_NAME);
380 propertyTypesList.add(PropertyType.STRING);
381
382 // Version
383 col = new TableViewerColumn(viewer, SWT.NONE);
384 col.getColumn().setWidth(160);
385 col.getColumn().setText("Version");
386 col.setLabelProvider(new ColumnLabelProvider() {
387 private static final long serialVersionUID = -4706438113850571784L;
388
389 @Override
390 public String getText(Object element) {
391 return JcrUtils.get((Node) element, SLC_VERSION);
392 }
393 });
394 col.getColumn().addSelectionListener(getSelectionAdapter(2));
395 propertiesList.add(SLC_VERSION);
396 propertyTypesList.add(DistNodeViewerComparator.VERSION_TYPE);
397
398 // Exists in workspace
399 col = new TableViewerColumn(viewer, SWT.NONE);
400 col.getColumn().setWidth(160);
401 col.getColumn().setText("Exists in workspace");
402 col.setLabelProvider(new ColumnLabelProvider() {
403 private static final long serialVersionUID = 8190063212920414300L;
404
405 @Override
406 public String getText(Object element) {
407 return getRealizedModule((Node) element) != null ? "Yes" : "No";
408 // return JcrUtils.get((Node) element, SLC_VERSION);
409 }
410 });
411 // col.getColumn().addSelectionListener(getSelectionAdapter(2));
412 // propertiesList.add(SLC_VERSION);
413 // propertyTypesList.add(PropertyType.STRING);
414
415 final Table table = viewer.getTable();
416 table.setHeaderVisible(true);
417 table.setLinesVisible(true);
418
419 viewer.setContentProvider(new DistributionsContentProvider());
420 getSite().setSelectionProvider(viewer);
421
422 comparator = new DistNodeViewerComparator(2,
423 DistNodeViewerComparator.ASCENDING, propertiesList,
424 propertyTypesList);
425 viewer.setComparator(comparator);
426
427 // // Context Menu
428 // MenuManager menuManager = new MenuManager();
429 // Menu menu = menuManager.createContextMenu(viewer.getTable());
430 // menuManager.addMenuListener(new IMenuListener() {
431 // public void menuAboutToShow(IMenuManager manager) {
432 // contextMenuAboutToShow(manager);
433 // }
434 // });
435 // viewer.getTable().setMenu(menu);
436 // getSite().registerContextMenu(menuManager, viewer);
437
438 // Double click
439 viewer.addDoubleClickListener(new DoubleClickListener());
440 }
441
442 private Node getRealizedModule(Node moduleCoordinates) {
443 try {
444 String category = JcrUtils.get(moduleCoordinates, SLC_CATEGORY);
445 String name = JcrUtils.get(moduleCoordinates, SLC_NAME);
446 String version = JcrUtils.get(moduleCoordinates, SLC_VERSION);
447 Artifact artifact = new DefaultArtifact(category + ":" + name + ":"
448 + version);
449 String parentPath = MavenConventionsUtils.artifactParentPath(
450 RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH, artifact);
451
452 Session session = modularDistribution.getSession();
453 if (session.nodeExists(parentPath)) {
454 Node parent = session.getNode(parentPath);
455 NodeIterator nit = parent.getNodes();
456 while (nit.hasNext()) {
457 Node currN = nit.nextNode();
458 if (currN.isNodeType(SlcTypes.SLC_ARTIFACT))
459 return currN;
460 }
461 }
462 } catch (RepositoryException re) {
463 throw new SlcException(
464 "unable to retrieve realized module with coordinates "
465 + moduleCoordinates, re);
466 }
467 return null;
468 }
469
470 private void refresh() {
471 final List<Node> result = JcrUtils
472 .nodeIteratorToList(listBundleArtifacts());
473 viewer.setInput(result);
474 }
475
476 /** Build repository request */
477 private NodeIterator listBundleArtifacts() {
478 try {
479 Session session = modularDistribution.getSession();
480 QueryManager queryManager = session.getWorkspace()
481 .getQueryManager();
482 QueryObjectModelFactory factory = queryManager.getQOMFactory();
483
484 Selector source = factory.selector(SlcTypes.SLC_MODULE_COORDINATES,
485 SlcTypes.SLC_MODULE_COORDINATES);
486
487 // Create a dynamic operand for each property on which we want to
488 // filter
489 DynamicOperand catDO = factory.propertyValue(
490 source.getSelectorName(), SlcNames.SLC_CATEGORY);
491 DynamicOperand nameDO = factory.propertyValue(
492 source.getSelectorName(), SlcNames.SLC_NAME);
493 DynamicOperand versionDO = factory.propertyValue(
494 source.getSelectorName(), SlcNames.SLC_VERSION);
495
496 String path = modularDistribution.getPath() + "/"
497 + SlcNames.SLC_MODULES;
498
499 // Default Constraint: correct children
500 Constraint defaultC = factory.descendantNode(
501 source.getSelectorName(), path);
502
503 String filter = filterTxt.getText();
504
505 // Build constraints based the textArea content
506 if (filter != null && !"".equals(filter.trim())) {
507 // Parse the String
508 String[] strs = filter.trim().split(" ");
509 for (String token : strs) {
510 token = token.replace('*', '%');
511 StaticOperand so = factory.literal(session
512 .getValueFactory().createValue("%" + token + "%"));
513
514 Constraint currC = factory.comparison(catDO,
515 QueryObjectModelFactory.JCR_OPERATOR_LIKE, so);
516 currC = factory.or(currC, factory.comparison(versionDO,
517 QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
518 currC = factory.or(currC, factory.comparison(nameDO,
519 QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
520
521 defaultC = factory.and(defaultC, currC);
522 }
523 }
524
525 QueryObjectModel query = factory.createQuery(source, defaultC,
526 null, null);
527 QueryResult result = query.execute();
528 return result.getNodes();
529 } catch (RepositoryException re) {
530 throw new SlcException("Unable to refresh module list for node "
531 + modularDistribution, re);
532 }
533 }
534
535 @Override
536 public void setFocus() {
537 viewer.getTable().setFocus();
538 }
539
540 // /** Programmatically configure the context menu */
541 // protected void contextMenuAboutToShow(IMenuManager menuManager) {
542 // IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
543 // .getActiveWorkbenchWindow();
544 // // Build conditions
545 // // Delete selected artifacts
546 // // CommandUtils.refreshCommand(menuManager, window, DeleteArtifacts.ID,
547 // // DeleteArtifacts.DEFAULT_LABEL, DeleteArtifacts.DEFAULT_ICON,
548 // // true);
549 // }
550
551 private SelectionAdapter getSelectionAdapter(final int index) {
552 SelectionAdapter selectionAdapter = new SelectionAdapter() {
553 private static final long serialVersionUID = 1260801795934660840L;
554
555 @Override
556 public void widgetSelected(SelectionEvent e) {
557 Table table = viewer.getTable();
558 comparator.setColumn(index);
559 int dir = table.getSortDirection();
560 if (table.getSortColumn() == table.getColumn(index)) {
561 dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
562 } else {
563 dir = SWT.DOWN;
564 }
565 table.setSortDirection(dir);
566 table.setSortColumn(table.getColumn(index));
567 viewer.refresh();
568 }
569 };
570 return selectionAdapter;
571 }
572
573 /* LOCAL CLASSES */
574 private class DistributionsContentProvider implements
575 IStructuredContentProvider {
576 private static final long serialVersionUID = 8385338190908823791L;
577 // we keep a cache of the Nodes in the content provider to be able to
578 // manage long request
579 private List<Node> nodes;
580
581 public void dispose() {
582 }
583
584 // We expect a list of nodes as a new input
585 @SuppressWarnings("unchecked")
586 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
587 nodes = (List<Node>) newInput;
588 }
589
590 public Object[] getElements(Object arg0) {
591 return nodes.toArray();
592 }
593 }
594
595 private class DoubleClickListener implements IDoubleClickListener {
596
597 public void doubleClick(DoubleClickEvent event) {
598 Object obj = ((IStructuredSelection) event.getSelection())
599 .getFirstElement();
600 if (obj instanceof Node) {
601 Node node = (Node) obj;
602 try {
603 if (node.isNodeType(SlcTypes.SLC_MODULE_COORDINATES)) {
604 Node realizedModule = getRealizedModule(node);
605 if (realizedModule != null) {
606 ModuleEditorInput dwip = (ModuleEditorInput) getEditorInput();
607 Map<String, String> params = new HashMap<String, String>();
608 params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
609 dwip.getRepoNodePath());
610 params.put(OpenModuleEditor.PARAM_REPO_URI,
611 dwip.getUri());
612 params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
613 dwip.getWorkspaceName());
614 String path = realizedModule.getPath();
615 params.put(OpenModuleEditor.PARAM_MODULE_PATH, path);
616 CommandUtils.callCommand(OpenModuleEditor.ID,
617 params);
618 }
619 }
620 } catch (RepositoryException re) {
621 throw new SlcException("Cannot get path for node " + node
622 + " while setting parameters for "
623 + "command OpenModuleEditor", re);
624 }
625 }
626 }
627 }
628 }