This project has retired. For details please refer to its
Attic page.
RelationshipTable xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.chemistry.opencmis.workbench.details;
20
21 import java.awt.event.MouseEvent;
22
23 import org.apache.chemistry.opencmis.client.api.ObjectId;
24 import org.apache.chemistry.opencmis.client.api.Relationship;
25 import org.apache.chemistry.opencmis.workbench.ClientHelper;
26 import org.apache.chemistry.opencmis.workbench.model.ClientModel;
27
28 public class RelationshipTable extends AbstractDetailsTable {
29
30 private static final long serialVersionUID = 1L;
31
32 private static final String[] COLUMN_NAMES = { "Name", "Type", "Relationship Id", "Source", "Target" };
33 private static final int[] COLUMN_WIDTHS = { 200, 200, 200, 200, 200 };
34
35 public RelationshipTable(ClientModel model) {
36 super();
37 init(model, COLUMN_NAMES, COLUMN_WIDTHS);
38 }
39
40 @Override
41 public void singleClickAction(MouseEvent e, int rowIndex, int colIndex) {
42 if (getColumnClass(colIndex) != ObjectId.class) {
43 return;
44 }
45
46 ObjectId id = (ObjectId) getValueAt(rowIndex, colIndex);
47 if ((id == null) || (id.getId() == null)) {
48 return;
49 }
50
51 try {
52 getClientModel().loadObject(id.getId());
53 setTab(0);
54 } catch (Exception ex) {
55 ClientHelper.showError(this, ex);
56 }
57 }
58
59 @Override
60 public int getDetailRowCount() {
61 if (getObject().getRelationships() == null) {
62 return 0;
63 }
64
65 return getObject().getRelationships().size();
66 }
67
68 @Override
69 public Object getDetailValueAt(int rowIndex, int columnIndex) {
70 Relationship relationship = getObject().getRelationships().get(rowIndex);
71
72 switch (columnIndex) {
73 case 0:
74 return relationship.getName();
75 case 1:
76 return relationship.getType().getId();
77 case 2:
78 return relationship;
79 case 3:
80 return relationship.getSourceId();
81 case 4:
82 return relationship.getTarget();
83 }
84
85 return null;
86 }
87
88 @Override
89 public Class<?> getDetailColumClass(int columnIndex) {
90 if ((columnIndex == 2) || (columnIndex == 3) || (columnIndex == 4)) {
91 return ObjectId.class;
92 }
93
94 return super.getDetailColumClass(columnIndex);
95 }
96 }