Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1658fad64edee1b74d21887b27fc61971ac8fafb (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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/*****************************************************************************
 * Copyright (c) 2013 CEA LIST.
 *
 *    
 * 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:
 *  Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
 *
 *****************************************************************************/
package org.eclipse.papyrus.uml.nattable.ws.preferences.manager.axis;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;

import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
import org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
import org.eclipse.papyrus.infra.widgets.providers.IRestrictedContentProvider;
import org.eclipse.papyrus.uml.nattable.ws.preferences.utils.Constants;


public class PropertyFilePropertyAxisManager extends AbstractAxisManager {

	@Override
	public void init(INattableModelManager manager, AxisManagerRepresentation rep, AbstractAxisProvider provider) {
		super.init(manager, rep, provider);
	}

	@Override
	public NattableModelManager getTableManager() {
		return super.getTableManager();
	}

	@Override
	public boolean canInsertAxis(Collection<Object> objectsToAdd, int index) {
		return super.canInsertAxis(objectsToAdd, index);
	}

	@Override
	public boolean canCreateAxisElement(String elementId) {
		return super.canCreateAxisElement(elementId);
	}

	@Override
	public boolean canDropAxisElement(Collection<Object> objectsToAdd) {
		return super.canDropAxisElement(objectsToAdd);
	}

	@Override
	public void dispose() {
		super.dispose();
	}

	@Override
	public boolean canBeUsedAsRowManager() {
		return super.canBeUsedAsRowManager();
	}

	@Override
	public boolean canBeUsedAsColumnManager() {
		return super.canBeUsedAsColumnManager();
	}

	@Override
	public Command getAddAxisCommand(EditingDomain domain, Collection<Object> objectToAdd) {
		return super.getAddAxisCommand(domain, objectToAdd);
	}

	@Override
	public Command getInsertAxisCommand(Collection<Object> objectsToAdd, int index) {
		return super.getInsertAxisCommand(objectsToAdd, index);
	}

	@Override
	public Command getComplementaryAddAxisCommand(EditingDomain domain, Collection<Object> objectToAdd) {
		return super.getComplementaryAddAxisCommand(domain, objectToAdd);
	}

	@Override
	public AbstractAxisProvider getRepresentedContentProvider() {
		return super.getRepresentedContentProvider();
	}

	@Override
	public void setHeaderDataValue(int columnIndex, int rowIndex, Object newValue) {
		super.setHeaderDataValue(columnIndex, rowIndex, newValue);
	}

	@Override
	public boolean isAllowedContents(Object object) {
		return super.isAllowedContents(object);
	}

	@Override
	public boolean canMoveAxis() {
		return super.canMoveAxis();
	}

	@Override
	public IRestrictedContentProvider createPossibleAxisContentProvider(boolean isRestricted) {
		return super.createPossibleAxisContentProvider(isRestricted);
	}

	@Override
	public Command getDestroyAxisCommand(EditingDomain domain, Collection<Object> objectToDestroy) {
		return super.getDestroyAxisCommand(domain, objectToDestroy);
	}

	@Override
	public Collection<Object> getAllManagedAxis() {
		List<Object> rowElements = getTableManager().getRowElementsList();//FIXME use the best way for that!
		Collection<Object> values = new ArrayList<Object>();
		for(final Object current : rowElements) {
			if(current instanceof String) {
				//				String filePath = body.replace("wsPref:/", "");
				Properties currentProp = new Properties();
				try {
					currentProp.load(new FileInputStream(((String)current).replace(Constants.WORKSPACE_PREFIX, "")));
				} catch (FileNotFoundException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				}
				Set<Entry<Object, Object>> entrySet = ((Properties)currentProp).entrySet();
				for(Entry<Object, Object> entry : entrySet) {
					values.add(Constants.PROPERTY_PREFIX + entry.getKey());
				}
				currentProp.clear();
				//				Enumeration<Object> elements = currentProp.elements();
				//				while(elements.hasMoreElements()) {
				//					values.add(elements.nextElement());
				//				}
				//				int i = 0;
				//				i++;
				//				//				comments.add(current);
				//				prop.add(currentProp);
			}
			//			if(current instanceof Properties) {
			//				values.addAll(((Properties)current).entrySet());
			//				Enumeration<Object> el = ((Properties)current).elements();
			//				while(el.hasMoreElements()) {
			//					System.out.println(((Properties)current).get(el.nextElement()));
			//
			//					//					System.out.println(((Properties)current).getProperty(el.nextElement()));
			//					//					System.out.println(el.nextElement());
			//				}
			//				//				Object next = el.nextElement();
			//				//				int i = 0;
			//				//				i++;
			//			}
		}
		return values;
	}

	@Override
	protected EditingDomain getTableEditingDomain() {
		return super.getTableEditingDomain();
	}

	@Override
	protected EditingDomain getContextEditingDomain() {
		return super.getContextEditingDomain();
	}

	@Override
	public void moveAxis(Object elementToMove, int newIndex) {
		super.moveAxis(elementToMove, newIndex);
	}

	@Override
	public void openEditAxisAliasDialog(NatEventData event, int axisPosition) {
		super.openEditAxisAliasDialog(event, axisPosition);
	}

	@Override
	public String getElementAxisName(IAxis axis) {
		return super.getElementAxisName(axis);
	}

	@Override
	public AxisManagerRepresentation getAxisManagerRepresentation() {
		return super.getAxisManagerRepresentation();
	}

	@Override
	public boolean canDestroyAxis(List<Integer> axisPositions) {
		return super.canDestroyAxis(axisPositions);
	}

	@Override
	public boolean canDestroyAxisElement(List<Integer> axisPositions) {
		return super.canDestroyAxisElement(axisPositions);
	}

	@Override
	public void destroyAxis(List<Integer> axisPositions) {
		super.destroyAxis(axisPositions);
	}

	@Override
	public boolean canDestroyAxis(Integer axisPosition) {
		return super.canDestroyAxis(axisPosition);
	}

	@Override
	protected List<Object> getElements(List<Integer> axisPositions) {
		return super.getElements(axisPositions);
	}

	@Override
	public void destroyAxisElement(List<Integer> axisPosition) {
		super.destroyAxisElement(axisPosition);
	}

	@Override
	protected List<Object> getElements() {
		return super.getElements();
	}

	@Override
	public boolean isSlave() {
		return false;
	}

	//	@Override
	//	public boolean isDynamic() {
	//		return true;
	//	}

	@Override
	public boolean canEditAxisHeader() {
		return false;
	}

	@Override
	public boolean canDestroyAxisElement(Integer axisIndex) {
		return false;
	}

	@Override
	public Command getDestroyAxisElementCommand(EditingDomain domain, Integer axisPosition) {
		return null;
	}

	@Override
	public boolean isDynamic() {
		return true;
	}

}

Back to the top