]> git.argeo.org Git - gpl/argeo-jcr.git/blob - swt/org.argeo.cms.jcr.ui/src/org/argeo/eclipse/ui/jcr/RowColumnLabelProvider.java
Adapt to changes in Argeo Commons
[gpl/argeo-jcr.git] / swt / org.argeo.cms.jcr.ui / src / org / argeo / eclipse / ui / jcr / RowColumnLabelProvider.java
1 package org.argeo.eclipse.ui.jcr;
2
3 import javax.jcr.RepositoryException;
4 import javax.jcr.query.Row;
5
6 import org.eclipse.jface.viewers.ColumnLabelProvider;
7 import org.eclipse.swt.graphics.Color;
8 import org.eclipse.swt.graphics.Font;
9 import org.eclipse.swt.graphics.Image;
10
11 /** Simplifies writing JCR-based column label provider. */
12 public class RowColumnLabelProvider extends ColumnLabelProvider {
13 private static final long serialVersionUID = -6586692836928505358L;
14
15 protected String getRowText(Row row) throws RepositoryException {
16 return super.getText(row);
17 }
18
19 protected String getRowToolTipText(Row row) throws RepositoryException {
20 return super.getToolTipText(row);
21 }
22
23 protected Image getRowImage(Row row) throws RepositoryException {
24 return super.getImage(row);
25 }
26
27 protected Font getRowFont(Row row) throws RepositoryException {
28 return super.getFont(row);
29 }
30
31 public Color getRowBackground(Row row) throws RepositoryException {
32 return super.getBackground(row);
33 }
34
35 public Color getRowForeground(Row row) throws RepositoryException {
36 return super.getForeground(row);
37 }
38
39 @Override
40 public String getText(Object element) {
41 try {
42 if (element instanceof Row)
43 return getRowText((Row) element);
44 else
45 throw new IllegalArgumentException("Unsupported element type " + element.getClass());
46 } catch (RepositoryException e) {
47 throw new IllegalStateException("Repository exception when accessing " + element, e);
48 }
49 }
50
51 @Override
52 public Image getImage(Object element) {
53 try {
54 if (element instanceof Row)
55 return getRowImage((Row) element);
56 else
57 throw new IllegalArgumentException("Unsupported element type " + element.getClass());
58 } catch (RepositoryException e) {
59 throw new IllegalStateException("Repository exception when accessing " + element, e);
60 }
61 }
62
63 @Override
64 public String getToolTipText(Object element) {
65 try {
66 if (element instanceof Row)
67 return getRowToolTipText((Row) element);
68 else
69 throw new IllegalArgumentException("Unsupported element type " + element.getClass());
70 } catch (RepositoryException e) {
71 throw new IllegalStateException("Repository exception when accessing " + element, e);
72 }
73 }
74
75 @Override
76 public Font getFont(Object element) {
77 try {
78 if (element instanceof Row)
79 return getRowFont((Row) element);
80 else
81 throw new IllegalArgumentException("Unsupported element type " + element.getClass());
82 } catch (RepositoryException e) {
83 throw new IllegalStateException("Repository exception when accessing " + element, e);
84 }
85 }
86
87 @Override
88 public Color getBackground(Object element) {
89 try {
90 if (element instanceof Row)
91 return getRowBackground((Row) element);
92 else
93 throw new IllegalArgumentException("Unsupported element type " + element.getClass());
94 } catch (RepositoryException e) {
95 throw new IllegalStateException("Repository exception when accessing " + element, e);
96 }
97 }
98
99 @Override
100 public Color getForeground(Object element) {
101 try {
102 if (element instanceof Row)
103 return getRowForeground((Row) element);
104 else
105 throw new IllegalArgumentException("Unsupported element type " + element.getClass());
106 } catch (RepositoryException e) {
107 throw new IllegalStateException("Repository exception when accessing " + element, e);
108 }
109 }
110
111 }