blob: 8f9008f95db11ccd7599fd7e0b750db64175af1b [file] [log] [blame]
david_williamscfdb2cd2004-11-11 08:37:49 +00001/*******************************************************************************
2 * Copyright (c) 2001, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 * Jens Lukowski/Innoopract - initial renaming/restructuring
11 *
12 *******************************************************************************/
nitindd6e591d2005-03-14 22:21:57 +000013package org.eclipse.wst.dtd.ui.internal.views.properties;
david_williamscfdb2cd2004-11-11 08:37:49 +000014
15import java.util.Stack;
16
17import org.eclipse.ui.views.properties.IPropertyDescriptor;
18import org.eclipse.ui.views.properties.IPropertySource;
nitindd6e591d2005-03-14 22:21:57 +000019import org.eclipse.wst.dtd.core.internal.DTDNode;
david_williams38046012005-04-08 19:04:29 +000020import org.eclipse.wst.dtd.ui.internal.DTDUIMessages;
david_williams4ad020f2005-04-18 08:00:30 +000021import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
22import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
nitindbca26632005-03-30 18:13:32 +000023import org.eclipse.wst.sse.ui.internal.properties.CustomPropertyDescriptor;
david_williamscfdb2cd2004-11-11 08:37:49 +000024
25
26/**
27 * An IPropertySource implementation for a JFace viewer used to display
28 * properties of DOM nodes. Requires an adapter factory to create JFace
29 * adapters for the nodes in the tree.
30 */
31public class DTDPropertySourceAdapter implements INodeAdapter, IPropertySource {
32 protected final static String CATEGORY_ATTRIBUTES = "Attributes"; //$NON-NLS-1$
33
david_williams38046012005-04-08 19:04:29 +000034 private static final String ID_NAME = DTDUIMessages.DTDPropertySourceAdapter_0; //$NON-NLS-1$
35 private static final String ID_TEXT = DTDUIMessages.DTDPropertySourceAdapter_1; //$NON-NLS-1$
david_williamscfdb2cd2004-11-11 08:37:49 +000036
37 protected IPropertyDescriptor[] fDescriptors = null;
38 protected INodeNotifier fNode = null;
39
40 protected Stack fValuesBeingSet = new Stack();
41
42 public DTDPropertySourceAdapter(INodeNotifier target) {
43 super();
44 fNode = target;
45 }
46
47 /**
48 * @return
49 */
50 private IPropertyDescriptor[] createPropertyDescriptors() {
51 CustomPropertyDescriptor nameDescriptor = new CustomPropertyDescriptor(ID_NAME, ID_NAME, null);
david_williams38046012005-04-08 19:04:29 +000052 nameDescriptor.setCategory(DTDUIMessages.DTDPropertySourceAdapter_2); //$NON-NLS-1$
nitindd6e591d2005-03-14 22:21:57 +000053 // CustomPropertyDescriptor contentDescriptor = new
david_williamscfdb2cd2004-11-11 08:37:49 +000054 // CustomPropertyDescriptor(ID_TEXT, ID_TEXT, null);
nitindd6e591d2005-03-14 22:21:57 +000055 // contentDescriptor.setCategory("Attributes");
david_williamscfdb2cd2004-11-11 08:37:49 +000056 return new IPropertyDescriptor[]{nameDescriptor};
57 }
58
59 /**
60 * Returns a value for this Node that can be editted in a property sheet.
61 *
62 * @return a value that can be editted
63 */
64 public Object getEditableValue() {
65 return null;
66 }
67
68 /**
69 * Returns the current collection of property descriptors.
70 *
71 * @return all valid descriptors.
72 */
73 public IPropertyDescriptor[] getPropertyDescriptors() {
74 if (fDescriptors == null || fDescriptors.length == 0) {
75 fDescriptors = createPropertyDescriptors();
nitindd6e591d2005-03-14 22:21:57 +000076 }
77 else {
david_williamscfdb2cd2004-11-11 08:37:49 +000078 updatePropertyDescriptors();
79 }
80 return fDescriptors;
81 }
82
83 /**
84 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
85 */
86 public Object getPropertyValue(Object id) {
87 Object value = null;
88 if (id.equals(ID_NAME) && fNode instanceof DTDNode) {
89 value = ((DTDNode) fNode).getName();
90 }
91 if (id.equals(ID_TEXT) && fNode instanceof DTDNode) {
92 value = ((DTDNode) fNode).getFullNodeText();
93 }
94 return value;
95 }
96
97 /**
98 * Allowing the INodeAdapter to compare itself against the type allows it
99 * to return true in more than one case.
100 */
101 public boolean isAdapterForType(Object type) {
102 return type == IPropertySource.class;
103 }
104
105 /*
106 * (non-Javadoc)
107 *
108 * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
109 */
110 public boolean isPropertySet(Object id) {
111 return false;
112 }
113
114 public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
115 }
116
117 /*
118 * (non-Javadoc)
119 *
120 * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
121 */
122 public void resetPropertyValue(Object id) {
123 }
124
125 public void setPropertyValue(Object nameObject, Object value) {
126 }
127
128 protected void updatePropertyDescriptors() {
129 }
130}