+
+ /*
+ * VALUES SUBCLASSES
+ */
+ static class ValuesContentProvider implements IStructuredContentProvider {
+
+ public Object[] getElements(Object inputElement) {
+ if (!(inputElement instanceof Node))
+ return new Object[0];
+
+ try {
+ Node realizedFlowNode = (Node) inputElement;
+ List<Node> specAttributes = new ArrayList<Node>();
+ specAttrs: for (NodeIterator nit = realizedFlowNode.getNodes(); nit
+ .hasNext();) {
+ Node specAttrNode = nit.nextNode();
+ if (!specAttrNode
+ .isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE))
+ continue specAttrs;
+ specAttributes.add(specAttrNode);
+ }
+ return specAttributes.toArray();
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot get elements", e);
+ }
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ }
+
+ class ValuesEditingSupport extends EditingSupport {
+ private final TableViewer tableViewer;
+
+ public ValuesEditingSupport(ColumnViewer viewer) {
+ super(viewer);
+ tableViewer = (TableViewer) viewer;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ try {
+ Node specAttrNode = (Node) element;
+ if (specAttrNode
+ .isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE))
+ return new TextCellEditor(tableViewer.getTable());
+ return null;
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot get celle editor", e);
+ }
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ try {
+ Node specAttrNode = (Node) element;
+ return !(specAttrNode.getProperty(SLC_IS_IMMUTABLE)
+ .getBoolean() || specAttrNode.getProperty(
+ SLC_IS_CONSTANT).getBoolean())
+ && specAttrNode
+ .isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE);
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot check canEdit", e);
+ }
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ Node specAttrNode = (Node) element;
+ try {
+ Object value = getAttributeSpecValue(specAttrNode);
+ if (value == null)
+ throw new SlcException("Unsupported attribute " + element);
+ if (specAttrNode
+ .isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE))
+ return value.toString();
+ return value;
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot get value for " + element, e);
+ }
+ }
+
+ @Override
+ protected void setValue(Object element, Object value) {
+ try {
+ Node specAttrNode = (Node) element;
+ if (specAttrNode
+ .isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
+ String type = specAttrNode.getProperty(SLC_TYPE)
+ .getString();
+ SlcJcrUtils.setPrimitiveAsProperty(specAttrNode, SLC_VALUE,
+ type, value);
+ valuesViewer.refresh();
+ formPart.markDirty();
+ }
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot get celle editor", e);
+ }
+ }
+
+ }