Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: cc90289ae0bedd5d8d5b96c1eb93a1e3aec438c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*******************************************************************************
 * Copyright (c) 2001, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     Jens Lukowski/Innoopract - initial renaming/restructuring
 *     
 *******************************************************************************/
package org.eclipse.wst.dtd.ui.internal.views.properties;

import java.util.Stack;

import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.wst.dtd.core.internal.DTDNode;
import org.eclipse.wst.dtd.ui.internal.DTDUIMessages;
import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
import org.eclipse.wst.sse.ui.internal.properties.CustomPropertyDescriptor;


/**
 * An IPropertySource implementation for a JFace viewer used to display
 * properties of DOM nodes. Requires an adapter factory to create JFace
 * adapters for the nodes in the tree.
 */
public class DTDPropertySourceAdapter implements INodeAdapter, IPropertySource {
	protected final static String CATEGORY_ATTRIBUTES = "Attributes"; //$NON-NLS-1$

	private static final String ID_NAME = DTDUIMessages.DTDPropertySourceAdapter_0; //$NON-NLS-1$
	private static final String ID_TEXT = DTDUIMessages.DTDPropertySourceAdapter_1; //$NON-NLS-1$

	protected IPropertyDescriptor[] fDescriptors = null;
	protected INodeNotifier fNode = null;

	protected Stack fValuesBeingSet = new Stack();

	public DTDPropertySourceAdapter(INodeNotifier target) {
		super();
		fNode = target;
	}

	/**
	 * @return
	 */
	private IPropertyDescriptor[] createPropertyDescriptors() {
		CustomPropertyDescriptor nameDescriptor = new CustomPropertyDescriptor(ID_NAME, ID_NAME, null);
		nameDescriptor.setCategory(DTDUIMessages.DTDPropertySourceAdapter_2); //$NON-NLS-1$
		// CustomPropertyDescriptor contentDescriptor = new
		// CustomPropertyDescriptor(ID_TEXT, ID_TEXT, null);
		// contentDescriptor.setCategory("Attributes");
		return new IPropertyDescriptor[]{nameDescriptor};
	}

	/**
	 * Returns a value for this Node that can be editted in a property sheet.
	 * 
	 * @return a value that can be editted
	 */
	public Object getEditableValue() {
		return null;
	}

	/**
	 * Returns the current collection of property descriptors.
	 * 
	 * @return all valid descriptors.
	 */
	public IPropertyDescriptor[] getPropertyDescriptors() {
		if (fDescriptors == null || fDescriptors.length == 0) {
			fDescriptors = createPropertyDescriptors();
		}
		else {
			updatePropertyDescriptors();
		}
		return fDescriptors;
	}

	/**
	 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
	 */
	public Object getPropertyValue(Object id) {
		Object value = null;
		if (id.equals(ID_NAME) && fNode instanceof DTDNode) {
			value = ((DTDNode) fNode).getName();
		}
		if (id.equals(ID_TEXT) && fNode instanceof DTDNode) {
			value = ((DTDNode) fNode).getFullNodeText();
		}
		return value;
	}

	/**
	 * Allowing the INodeAdapter to compare itself against the type allows it
	 * to return true in more than one case.
	 */
	public boolean isAdapterForType(Object type) {
		return type == IPropertySource.class;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
	 */
	public boolean isPropertySet(Object id) {
		return false;
	}

	public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
	 */
	public void resetPropertyValue(Object id) {
	}

	public void setPropertyValue(Object nameObject, Object value) {
	}

	protected void updatePropertyDescriptors() {
	}
}

Back to the top