Lines 41-48
Link Here
|
41 |
* Version 2 license, then the option applies only if the new code is |
41 |
* Version 2 license, then the option applies only if the new code is |
42 |
* made subject to such option by the copyright holder. |
42 |
* made subject to such option by the copyright holder. |
43 |
*/ |
43 |
*/ |
44 |
|
|
|
45 |
|
46 |
package org.netbeans.modules.uml.project.ui.nodes; |
44 |
package org.netbeans.modules.uml.project.ui.nodes; |
47 |
|
45 |
|
48 |
import org.netbeans.modules.uml.core.metamodel.structure.IProject; |
46 |
import org.netbeans.modules.uml.core.metamodel.structure.IProject; |
Lines 67-73
Link Here
|
67 |
import org.openide.nodes.CookieSet; |
65 |
import org.openide.nodes.CookieSet; |
68 |
import org.openide.util.ImageUtilities; |
66 |
import org.openide.util.ImageUtilities; |
69 |
import org.openide.util.Lookup; |
67 |
import org.openide.util.Lookup; |
70 |
import org.openide.util.Utilities; |
|
|
71 |
import org.openide.util.actions.SystemAction; |
68 |
import org.openide.util.actions.SystemAction; |
72 |
|
69 |
|
73 |
import org.netbeans.modules.uml.core.eventframework.IEventPayload; |
70 |
import org.netbeans.modules.uml.core.eventframework.IEventPayload; |
Lines 90-226
Link Here
|
90 |
import org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeRelElement; |
87 |
import org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeRelElement; |
91 |
import org.netbeans.modules.uml.ui.support.projecttreesupport.ProjectTreeComparable; |
88 |
import org.netbeans.modules.uml.ui.support.projecttreesupport.ProjectTreeComparable; |
92 |
|
89 |
|
93 |
|
|
|
94 |
/** |
90 |
/** |
95 |
* |
91 |
* |
96 |
* @author Trey Spiva |
92 |
* @author Trey Spiva |
97 |
*/ |
93 |
*/ |
98 |
public class UMLElementNode extends AbstractModelElementNode |
94 |
public class UMLElementNode extends AbstractModelElementNode |
99 |
implements ITreeItem, CookieSet.Factory, Comparable |
95 |
implements ITreeItem, CookieSet.Factory, Comparable { |
100 |
{ |
96 |
|
101 |
private IProjectTreeItem m_Data = null; |
97 |
private IProjectTreeItem m_Data = null; |
102 |
private String mPathAsString = ""; // NOI18N |
98 |
private String mPathAsString = ""; // NOI18N |
103 |
private Node.Cookie mOpenCookie = null; |
99 |
private Node.Cookie mOpenCookie = null; |
104 |
private Node.Cookie mModelElementCookie = null; |
100 |
private Node.Cookie mModelElementCookie = null; |
105 |
|
101 |
/** Determines if the node has been initialized with children yet. */ |
106 |
/** Determines if the node has been initialized with children yet. */ |
102 |
private boolean mIsInitialized = false; |
107 |
private boolean mIsInitialized = false; |
103 |
//Cache to speed up performance |
108 |
|
104 |
private Image icon = null; |
109 |
//Cache to speed up performance |
|
|
110 |
private Image icon=null; |
111 |
// private Action[] actions=null; |
105 |
// private Action[] actions=null; |
112 |
|
106 |
|
113 |
/** |
107 |
/** |
114 |
* Create a new UMLElementNode |
108 |
* Create a new UMLElementNode |
115 |
*/ |
109 |
*/ |
116 |
public UMLElementNode() |
110 |
public UMLElementNode() { |
117 |
{ |
111 |
this(new ProjectTreeItemImpl()); |
118 |
this(new ProjectTreeItemImpl()); |
112 |
initCookies(); |
119 |
initCookies(); |
113 |
} |
120 |
} |
114 |
|
121 |
|
115 |
/** |
122 |
/** |
116 |
* |
123 |
* |
117 |
*/ |
124 |
*/ |
118 |
public UMLElementNode(Lookup lookup) { |
125 |
public UMLElementNode(Lookup lookup) |
119 |
this(lookup, new ProjectTreeItemImpl()); |
126 |
{ |
120 |
} |
127 |
this(lookup, new ProjectTreeItemImpl()); |
121 |
|
128 |
} |
122 |
/** |
129 |
|
123 |
* Create a new UMLElementNode |
130 |
/** |
124 |
*/ |
131 |
* Create a new UMLElementNode |
125 |
public UMLElementNode(Children ch, Lookup lookup) { |
132 |
*/ |
126 |
this(ch, lookup, new ProjectTreeItemImpl()); |
133 |
public UMLElementNode(Children ch, Lookup lookup) |
127 |
} |
134 |
{ |
128 |
|
135 |
this(ch, lookup, new ProjectTreeItemImpl()); |
129 |
/** |
136 |
} |
130 |
* Create a new UMLElementNode and initialize its data with the information |
137 |
|
131 |
* from an IProjectTreeItem. |
138 |
/** |
132 |
* |
139 |
* Create a new UMLElementNode and initialize its data with the information |
133 |
* @param item The ITreeItem used to initialize the new node. |
140 |
* from an IProjectTreeItem. |
134 |
* @see IProjectTreeItem |
141 |
* |
135 |
*/ |
142 |
* @param item The ITreeItem used to initialize the new node. |
136 |
public UMLElementNode(IProjectTreeItem data) { |
143 |
* @see IProjectTreeItem |
137 |
super(new UMLChildren()); |
144 |
*/ |
138 |
setData(data); |
145 |
public UMLElementNode(IProjectTreeItem data) |
139 |
setUpChildren(); |
146 |
{ |
140 |
addProjectTreeItemCookie(data); |
147 |
super(new UMLChildren()); |
141 |
} |
148 |
setData(data); |
142 |
|
149 |
setUpChildren(); |
143 |
/** |
150 |
addProjectTreeItemCookie(data); |
144 |
* Create a new UMLElementNode and initialize its data with the information |
151 |
} |
145 |
* from an ITreeItem. |
152 |
|
146 |
* |
153 |
/** |
147 |
* @param item The ITreeItem used to initialize the new node. |
154 |
* Create a new UMLElementNode and initialize its data with the information |
148 |
* @see ITreeItem |
155 |
* from an ITreeItem. |
149 |
*/ |
156 |
* |
150 |
public UMLElementNode(ITreeItem item) { |
157 |
* @param item The ITreeItem used to initialize the new node. |
151 |
this(item.getData()); |
158 |
* @see ITreeItem |
152 |
} |
159 |
*/ |
153 |
|
160 |
public UMLElementNode(ITreeItem item) |
154 |
/** |
161 |
{ |
155 |
* Create a new UMLElementNode and initialize its data with the information |
162 |
this(item.getData()); |
156 |
* from an IProjectTreeItem. |
163 |
} |
157 |
*/ |
164 |
|
158 |
public UMLElementNode(Lookup lookup, IProjectTreeItem data) { |
165 |
/** |
159 |
super(new UMLChildren(), lookup); |
166 |
* Create a new UMLElementNode and initialize its data with the information |
160 |
setData(data); |
167 |
* from an IProjectTreeItem. |
161 |
//addChild(this); |
168 |
*/ |
162 |
setUpChildren(); |
169 |
public UMLElementNode(Lookup lookup, IProjectTreeItem data) |
163 |
} |
170 |
{ |
164 |
|
171 |
super(new UMLChildren(), lookup); |
165 |
public UMLElementNode(Children ch, Lookup lookup, IProjectTreeItem data) { |
172 |
setData(data); |
166 |
super(ch, lookup); |
173 |
//addChild(this); |
167 |
setData(data); |
174 |
setUpChildren(); |
168 |
setUpChildren(); |
175 |
} |
169 |
//addChild(this); |
176 |
|
170 |
//setChildren(new UMLChildren(this)); |
177 |
public UMLElementNode(Children ch, Lookup lookup, IProjectTreeItem data) |
171 |
} |
178 |
{ |
172 |
|
179 |
super(ch, lookup); |
173 |
protected void addProjectTreeItemCookie(IProjectTreeItem projectTreeItem) { |
180 |
setData(data); |
174 |
getCookieSet().add(projectTreeItem); |
181 |
setUpChildren(); |
175 |
} |
182 |
//addChild(this); |
176 |
|
183 |
//setChildren(new UMLChildren(this)); |
177 |
/** |
184 |
} |
178 |
* Gathers the nodes children. |
185 |
|
179 |
*/ |
186 |
|
180 |
public void setUpChildren() { |
187 |
|
181 |
Children ch = getChildren(); |
188 |
protected void addProjectTreeItemCookie(IProjectTreeItem projectTreeItem) |
182 |
if (ch != null && ch instanceof UMLChildren) { |
189 |
{ |
183 |
final UMLChildren children = (UMLChildren) ch; |
190 |
getCookieSet().add(projectTreeItem); |
184 |
children.setItem(this); |
191 |
} |
185 |
} |
192 |
|
186 |
} |
193 |
/** |
187 |
|
194 |
* Gathers the nodes children. |
|
|
195 |
*/ |
196 |
public void setUpChildren() |
197 |
{ |
198 |
Children ch = getChildren(); |
199 |
if (ch != null && ch instanceof UMLChildren) |
200 |
{ |
201 |
final UMLChildren children = (UMLChildren)ch; |
202 |
children.setItem(this); |
203 |
} |
204 |
} |
205 |
|
206 |
//************************************************** |
188 |
//************************************************** |
207 |
// ITreeItem Implementation |
189 |
// ITreeItem Implementation |
208 |
//************************************************** |
190 |
//************************************************** |
|
|
191 |
public String getName() { |
192 |
IElement element = getModelElement(); |
209 |
|
193 |
|
210 |
public String getName() |
194 |
if (element instanceof INamedElement) { |
211 |
{ |
|
|
212 |
IElement element = getModelElement(); |
213 |
|
214 |
if (element instanceof INamedElement) |
215 |
{ |
216 |
// return unformatted name for attributes and operations, so that |
195 |
// return unformatted name for attributes and operations, so that |
217 |
// rename action on those nodes will display the bare name without |
196 |
// rename action on those nodes will display the bare name without |
218 |
// visibility modifier and type information, since we only support |
197 |
// visibility modifier and type information, since we only support |
219 |
// rename the name part of these two types of elements from project |
198 |
// rename the name part of these two types of elements from project |
220 |
// tree |
199 |
// tree |
221 |
if (element.getElementType().equals(ELEMENT_TYPE_ATTRIBUTE) || |
200 |
if (element.getElementType().equals(ELEMENT_TYPE_ATTRIBUTE) |
222 |
element.getElementType().equals(ELEMENT_TYPE_OPERATION)) |
201 |
|| element.getElementType().equals(ELEMENT_TYPE_OPERATION)) { |
223 |
{ |
|
|
224 |
return (((INamedElement) element).getName()); |
202 |
return (((INamedElement) element).getName()); |
225 |
} |
203 |
} |
226 |
} |
204 |
} |
Lines 228-621
Link Here
|
228 |
return super.getName(); |
206 |
return super.getName(); |
229 |
} |
207 |
} |
230 |
|
208 |
|
231 |
|
209 |
/* (non-Javadoc) |
232 |
/* (non-Javadoc) |
210 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setDisplayedName(java.lang.String) |
233 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setDisplayedName(java.lang.String) |
211 |
*/ |
234 |
*/ |
212 |
public void setDisplayedName(String name) { |
235 |
public void setDisplayedName(String name) |
213 |
setDisplayedName(name, true); |
236 |
{ |
214 |
} |
237 |
setDisplayedName(name, true); |
215 |
|
|
|
216 |
/* (non-Javadoc) |
217 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setDisplayedName(java.lang.String,V) |
218 |
*/ |
219 |
public void setDisplayedName(String name, boolean buildProperties) { |
220 |
setDisplayName(name, buildProperties); |
221 |
if (getData() != null) { |
222 |
getData().setItemText(name); |
238 |
} |
223 |
} |
239 |
|
224 |
|
240 |
/* (non-Javadoc) |
225 |
IElement element = getModelElement(); |
241 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setDisplayedName(java.lang.String,V) |
226 |
|
242 |
*/ |
227 |
if (element instanceof INamedElement) { |
243 |
public void setDisplayedName(String name, boolean buildProperties) |
228 |
// set the name of the node as well, so in edit mode, the new name |
244 |
{ |
229 |
// of the element will be displayed |
245 |
setDisplayName(name, buildProperties); |
230 |
super.setName(((INamedElement) element).getName()); |
246 |
if (getData() != null) |
231 |
} |
247 |
getData().setItemText(name); |
232 |
|
248 |
|
|
|
249 |
IElement element = getModelElement(); |
250 |
|
251 |
if (element instanceof INamedElement) |
252 |
{ |
253 |
// set the name of the node as well, so in edit mode, the new name |
254 |
// of the element will be displayed |
255 |
super.setName(((INamedElement)element).getName()); |
256 |
} |
257 |
|
258 |
// else |
233 |
// else |
259 |
// setName(name); |
234 |
// setName(name); |
|
|
235 |
} |
236 |
|
237 |
public String getDisplayName() { |
238 |
String retVal = super.getDisplayName(); |
239 |
|
240 |
if (retVal == null || retVal.length() <= 0) { |
241 |
if (getData() != null) { |
242 |
retVal = getData().getItemText(); |
243 |
} |
260 |
} |
244 |
} |
261 |
|
245 |
|
262 |
|
246 |
if (retVal == null || retVal.length() <= 0) { |
263 |
public String getDisplayName() |
247 |
retVal = getName(); |
264 |
{ |
|
|
265 |
String retVal = super.getDisplayName(); |
266 |
|
267 |
if (retVal == null || retVal.length() <= 0) |
268 |
{ |
269 |
if (getData() != null) |
270 |
retVal = getData().getItemText(); |
271 |
} |
248 |
} |
272 |
|
249 |
|
273 |
if (retVal == null || retVal.length() <= 0) |
|
|
274 |
retVal = getName(); |
275 |
|
276 |
return retVal; |
250 |
return retVal; |
277 |
} |
251 |
} |
278 |
|
252 |
|
279 |
|
253 |
/* (non-Javadoc) |
280 |
/* (non-Javadoc) |
254 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getDisplayedName() |
281 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getDisplayedName() |
255 |
*/ |
282 |
*/ |
256 |
public String getDisplayedName() { |
283 |
public String getDisplayedName() |
|
|
284 |
{ |
285 |
return getDisplayName(); |
257 |
return getDisplayName(); |
286 |
} |
258 |
} |
287 |
|
|
|
288 |
|
289 |
|
290 |
/* (non-Javadoc) |
291 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getPath() |
292 |
*/ |
293 |
public Object[] getPath() |
294 |
{ |
295 |
ArrayList parents = new ArrayList(); |
296 |
|
297 |
while (getParentNode() != null) |
298 |
{ |
299 |
parents.add(0, getParentNode()); |
300 |
} |
301 |
|
302 |
Object[] retVal = new Object[parents.size()]; |
303 |
parents.toArray(retVal); |
304 |
return retVal; |
305 |
} |
306 |
|
307 |
/* (non-Javadoc) |
308 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getPathAsString() |
309 |
*/ |
310 |
public String getPathAsString() |
311 |
{ |
312 |
// StringBuffer retVal = new StringBuffer(getDisplayName()); |
313 |
// |
314 |
//// ArrayList parents = new ArrayList(); |
315 |
//// |
316 |
//// while (getParentNode() != null) |
317 |
//// { |
318 |
//// retVal.insert(0, "|"); |
319 |
//// retVal.insert(0, getParentNode().getDisplayName()); |
320 |
//// } |
321 |
// |
322 |
// Node parent = getParentNode(); |
323 |
// if(parent != null) |
324 |
// { |
325 |
// |
326 |
// } |
327 |
// |
328 |
// return retVal.toString(); |
329 |
|
330 |
return mPathAsString; |
331 |
} |
332 |
|
333 |
/* (non-Javadoc) |
334 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setPathAsString(java.lang.String) |
335 |
*/ |
336 |
public void setPathAsString(String str) |
337 |
{ |
338 |
mPathAsString = str; |
339 |
} |
340 |
|
341 |
/* (non-Javadoc) |
342 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#isSame(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem) |
343 |
*/ |
344 |
public boolean isSame(ITreeItem queryItem) |
345 |
{ |
346 |
return equals(queryItem); |
347 |
} |
348 |
|
349 |
/* (non-Javadoc) |
350 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getParentItem() |
351 |
*/ |
352 |
public ITreeItem getParentItem() |
353 |
{ |
354 |
ITreeItem retVal = null; |
355 |
Node parentNode = getParentNode(); |
356 |
|
357 |
if (parentNode instanceof ITreeItem) |
358 |
retVal = (ITreeItem)parentNode; |
359 |
|
360 |
return retVal; |
361 |
} |
362 |
|
363 |
/* (non-Javadoc) |
364 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setParentItem(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem) |
365 |
*/ |
366 |
public void setParentItem(ITreeItem parent) |
367 |
{ |
368 |
} |
369 |
|
370 |
/* (non-Javadoc) |
371 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getTopParentItem() |
372 |
*/ |
373 |
public ITreeItem getTopParentItem() |
374 |
{ |
375 |
ITreeItem pTop = null; |
376 |
ITreeItem pItem = getParentItem(); |
377 |
|
378 |
while (pItem != null) |
379 |
{ |
380 |
pTop = pItem; |
381 |
ITreeItem pTemp = pTop.getParentItem(); |
382 |
pItem = pTemp; |
383 |
} |
384 |
|
385 |
return pTop; |
386 |
} |
387 |
|
388 |
/* (non-Javadoc) |
389 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getOwningTreeElement() |
390 |
*/ |
391 |
public ITreeElement getOwningTreeElement() |
392 |
{ |
393 |
ITreeElement pOutEle = null; |
394 |
ITreeItem pLast = null; |
395 |
ITreeItem pItem = getParentItem(); |
396 |
|
397 |
while (pItem != null) |
398 |
{ |
399 |
pLast = pItem; |
400 |
|
401 |
if (pItem instanceof ITreeRelElement) |
402 |
{ |
403 |
ITreeItem pTemp = pLast.getParentItem(); |
404 |
pItem = pTemp; |
405 |
} |
406 |
|
407 |
else if (pItem instanceof ITreeElement) |
408 |
pItem = null; |
409 |
|
410 |
else |
411 |
{ |
412 |
ITreeItem pTemp = pLast.getParentItem(); |
413 |
pItem = pTemp; |
414 |
} |
415 |
} |
416 |
|
259 |
|
417 |
if (pLast != null) |
260 |
/* (non-Javadoc) |
418 |
{ |
261 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getPath() |
419 |
if (pLast instanceof ITreeElement) |
262 |
*/ |
420 |
pOutEle = (ITreeElement)pLast; |
263 |
public Object[] getPath() { |
421 |
} |
264 |
ArrayList parents = new ArrayList(); |
422 |
|
265 |
|
423 |
return pOutEle; |
266 |
while (getParentNode() != null) { |
424 |
} |
267 |
parents.add(0, getParentNode()); |
425 |
|
268 |
} |
426 |
/* (non-Javadoc) |
269 |
|
427 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getType() |
270 |
Object[] retVal = new Object[parents.size()]; |
428 |
*/ |
271 |
parents.toArray(retVal); |
429 |
public String getType() |
272 |
return retVal; |
430 |
{ |
273 |
} |
431 |
return null; |
274 |
|
432 |
} |
275 |
/* (non-Javadoc) |
433 |
|
276 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getPathAsString() |
434 |
/* (non-Javadoc) |
277 |
*/ |
435 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#addChild(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem) |
278 |
public String getPathAsString() { |
436 |
*/ |
279 |
// StringBuffer retVal = new StringBuffer(getDisplayName()); |
437 |
public void addChild(ITreeItem item) |
280 |
// |
438 |
{ |
281 |
//// ArrayList parents = new ArrayList(); |
|
|
282 |
//// |
283 |
//// while (getParentNode() != null) |
284 |
//// { |
285 |
//// retVal.insert(0, "|"); |
286 |
//// retVal.insert(0, getParentNode().getDisplayName()); |
287 |
//// } |
288 |
// |
289 |
// Node parent = getParentNode(); |
290 |
// if(parent != null) |
291 |
// { |
292 |
// |
293 |
// } |
294 |
// |
295 |
// return retVal.toString(); |
296 |
|
297 |
return mPathAsString; |
298 |
} |
299 |
|
300 |
/* (non-Javadoc) |
301 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setPathAsString(java.lang.String) |
302 |
*/ |
303 |
public void setPathAsString(String str) { |
304 |
mPathAsString = str; |
305 |
} |
306 |
|
307 |
/* (non-Javadoc) |
308 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#isSame(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem) |
309 |
*/ |
310 |
public boolean isSame(ITreeItem queryItem) { |
311 |
return equals(queryItem); |
312 |
} |
313 |
|
314 |
/* (non-Javadoc) |
315 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getParentItem() |
316 |
*/ |
317 |
public ITreeItem getParentItem() { |
318 |
ITreeItem retVal = null; |
319 |
Node parentNode = getParentNode(); |
320 |
|
321 |
if (parentNode instanceof ITreeItem) { |
322 |
retVal = (ITreeItem) parentNode; |
323 |
} |
324 |
|
325 |
return retVal; |
326 |
} |
327 |
|
328 |
/* (non-Javadoc) |
329 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setParentItem(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem) |
330 |
*/ |
331 |
public void setParentItem(ITreeItem parent) { |
332 |
} |
333 |
|
334 |
/* (non-Javadoc) |
335 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getTopParentItem() |
336 |
*/ |
337 |
public ITreeItem getTopParentItem() { |
338 |
ITreeItem pTop = null; |
339 |
ITreeItem pItem = getParentItem(); |
340 |
|
341 |
while (pItem != null) { |
342 |
pTop = pItem; |
343 |
ITreeItem pTemp = pTop.getParentItem(); |
344 |
pItem = pTemp; |
345 |
} |
346 |
|
347 |
return pTop; |
348 |
} |
349 |
|
350 |
/* (non-Javadoc) |
351 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getOwningTreeElement() |
352 |
*/ |
353 |
public ITreeElement getOwningTreeElement() { |
354 |
ITreeElement pOutEle = null; |
355 |
ITreeItem pLast = null; |
356 |
ITreeItem pItem = getParentItem(); |
357 |
|
358 |
while (pItem != null) { |
359 |
pLast = pItem; |
360 |
|
361 |
if (pItem instanceof ITreeRelElement) { |
362 |
ITreeItem pTemp = pLast.getParentItem(); |
363 |
pItem = pTemp; |
364 |
} else if (pItem instanceof ITreeElement) { |
365 |
pItem = null; |
366 |
} else { |
367 |
ITreeItem pTemp = pLast.getParentItem(); |
368 |
pItem = pTemp; |
369 |
} |
370 |
} |
371 |
|
372 |
if (pLast != null) { |
373 |
if (pLast instanceof ITreeElement) { |
374 |
pOutEle = (ITreeElement) pLast; |
375 |
} |
376 |
} |
377 |
|
378 |
return pOutEle; |
379 |
} |
380 |
|
381 |
/* (non-Javadoc) |
382 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getType() |
383 |
*/ |
384 |
public String getType() { |
385 |
return null; |
386 |
} |
387 |
|
388 |
/* (non-Javadoc) |
389 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#addChild(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem) |
390 |
*/ |
391 |
public void addChild(ITreeItem item) { |
439 |
boolean canAdd = true; |
392 |
boolean canAdd = true; |
440 |
// <Sheryl> Do we really need this condition check? In case like 'Relationships' |
393 |
// <Sheryl> Do we really need this condition check? In case like 'Relationships' |
441 |
// -> 'Specializations', these two folders both refer to the same |
394 |
// -> 'Specializations', these two folders both refer to the same |
442 |
// model element, the sub-folder will not be added as a result, #6320478 |
395 |
// model element, the sub-folder will not be added as a result, #6320478 |
443 |
// to filter out the relationship end which refers to itself, it's temporary |
396 |
// to filter out the relationship end which refers to itself, it's temporary |
444 |
// we need to go back to visit the root cause in project tree impl |
397 |
// we need to go back to visit the root cause in project tree impl |
445 |
ITreeItem parent = getParentItem(); |
398 |
ITreeItem parent = getParentItem(); |
446 |
if(parent != null) |
399 |
if (parent != null) { |
447 |
{ |
|
|
448 |
String yourID = item.getData().getModelElementXMIID(); |
400 |
String yourID = item.getData().getModelElementXMIID(); |
449 |
String parentID = parent.getData().getModelElementXMIID(); |
401 |
String parentID = parent.getData().getModelElementXMIID(); |
450 |
if (item instanceof ITreeFolder == false) |
402 |
if (item instanceof ITreeFolder == false) { |
451 |
canAdd = !yourID.equals(parentID); |
403 |
canAdd = !yourID.equals(parentID); |
|
|
404 |
} |
452 |
} |
405 |
} |
453 |
if(canAdd == true) |
406 |
if (canAdd == true) { |
454 |
{ |
407 |
if (item instanceof Node) { |
455 |
if (item instanceof Node) |
408 |
Node[] node = {(Node) item}; |
456 |
{ |
|
|
457 |
Node[] node ={(Node)item}; |
458 |
Children children = getChildren(); |
409 |
Children children = getChildren(); |
459 |
|
410 |
|
460 |
if (children != null) |
411 |
if (children != null) { |
461 |
children.add(node); |
412 |
children.add(node); |
|
|
413 |
} |
462 |
} |
414 |
} |
463 |
} |
415 |
} |
464 |
} |
416 |
} |
465 |
|
417 |
|
466 |
/* (non-Javadoc) |
418 |
/* (non-Javadoc) |
467 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#insertAt(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem, int) |
419 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#insertAt(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem, int) |
468 |
*/ |
420 |
*/ |
469 |
public void insertAt(ITreeItem item, int index) |
421 |
public void insertAt(ITreeItem item, int index) { |
470 |
{ |
422 |
// The NetBeans API does not allow you to add a child to a specific |
471 |
// The NetBeans API does not allow you to add a child to a specific |
423 |
// index. The children are sorted so this is not neccessary. |
472 |
// index. The children are sorted so this is not neccessary. |
424 |
addChild(item); |
473 |
addChild(item); |
425 |
} |
474 |
} |
426 |
|
475 |
|
427 |
/* (non-Javadoc) |
476 |
/* (non-Javadoc) |
428 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#removeChild(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem) |
477 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#removeChild(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem) |
429 |
*/ |
478 |
*/ |
430 |
public void removeChild(ITreeItem item) { |
479 |
public void removeChild(ITreeItem item) |
431 |
if (item instanceof Node) { |
480 |
{ |
432 |
Node[] node = {(Node) item}; |
481 |
if (item instanceof Node) |
433 |
Children children = getChildren(); |
482 |
{ |
434 |
|
483 |
Node[] node = {(Node)item}; |
435 |
if (children != null) { |
484 |
Children children = getChildren(); |
436 |
children.remove(node); |
485 |
|
437 |
} |
486 |
if (children != null) |
438 |
} |
487 |
children.remove(node); |
439 |
} |
488 |
} |
440 |
|
489 |
} |
441 |
/* (non-Javadoc) |
490 |
|
442 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#removeAllChildren() |
491 |
/* (non-Javadoc) |
443 |
*/ |
492 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#removeAllChildren() |
444 |
public void removeAllChildren() { |
493 |
*/ |
445 |
Children children = getChildren(); |
494 |
public void removeAllChildren() |
446 |
|
495 |
{ |
447 |
if ((children != null) && (children.getNodesCount() > 0)) { |
496 |
Children children = getChildren(); |
448 |
children.remove(children.getNodes()); |
497 |
|
449 |
} |
498 |
if ((children != null) && (children.getNodesCount() > 0)) |
450 |
} |
499 |
children.remove(children.getNodes()); |
451 |
|
500 |
} |
452 |
/* (non-Javadoc) |
501 |
|
453 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getChild(int) |
502 |
/* (non-Javadoc) |
454 |
*/ |
503 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getChild(int) |
455 |
public ITreeItem getChild(int index) { |
504 |
*/ |
456 |
// TODO Auto-generated method stub |
505 |
public ITreeItem getChild(int index) |
457 |
return null; |
506 |
{ |
458 |
} |
507 |
// TODO Auto-generated method stub |
459 |
|
508 |
return null; |
460 |
/* (non-Javadoc) |
509 |
} |
461 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#sortChildren() |
510 |
|
462 |
*/ |
511 |
/* (non-Javadoc) |
463 |
public void sortChildren() { |
512 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#sortChildren() |
464 |
((UMLChildren) getChildren()).recalculateChildren(); |
513 |
*/ |
465 |
} |
514 |
public void sortChildren() |
466 |
|
515 |
{ |
467 |
/* (non-Javadoc) |
516 |
((UMLChildren)getChildren()).recalculateChildren(); |
468 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#sortChildren(java.util.Comparator) |
517 |
} |
469 |
*/ |
518 |
|
470 |
public void sortChildren(Comparator compare) { |
519 |
/* (non-Javadoc) |
471 |
} |
520 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#sortChildren(java.util.Comparator) |
472 |
|
521 |
*/ |
473 |
/* (non-Javadoc) |
522 |
public void sortChildren(Comparator compare) {} |
474 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getData() |
523 |
|
475 |
*/ |
524 |
/* (non-Javadoc) |
476 |
public IProjectTreeItem getData() { |
525 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getData() |
477 |
return m_Data; |
526 |
*/ |
478 |
} |
527 |
public IProjectTreeItem getData() |
479 |
|
528 |
{ |
480 |
protected void setData(IProjectTreeItem data) { |
529 |
return m_Data; |
481 |
m_Data = data; |
530 |
} |
482 |
|
531 |
|
483 |
if (data != null) { |
532 |
protected void setData(IProjectTreeItem data) |
484 |
m_Data.setProjectTreeSupportTreeItem(this); |
533 |
{ |
485 |
} |
534 |
m_Data = data; |
486 |
} |
535 |
|
487 |
|
536 |
if (data != null) |
488 |
/* (non-Javadoc) |
537 |
m_Data.setProjectTreeSupportTreeItem(this); |
489 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getChildCount() |
538 |
} |
490 |
*/ |
539 |
|
491 |
public int getChildCount() { |
540 |
/* (non-Javadoc) |
492 |
int retVal = 0; |
541 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getChildCount() |
493 |
Children children = getChildren(); |
542 |
*/ |
494 |
|
543 |
public int getChildCount() |
495 |
if (children != null) { |
544 |
{ |
496 |
retVal = children.getNodesCount(); |
545 |
int retVal = 0; |
497 |
} |
546 |
Children children = getChildren(); |
498 |
|
547 |
|
499 |
return retVal; |
548 |
if (children != null) |
500 |
} |
549 |
retVal = children.getNodesCount(); |
501 |
|
550 |
|
502 |
/* (non-Javadoc) |
551 |
return retVal; |
503 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#isInitalized() |
552 |
} |
504 |
*/ |
553 |
|
505 |
public boolean isInitalized() { |
554 |
/* (non-Javadoc) |
506 |
// TODO Auto-generated method stub |
555 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#isInitalized() |
507 |
return mIsInitialized; |
556 |
*/ |
508 |
} |
557 |
public boolean isInitalized() |
509 |
|
558 |
{ |
510 |
/* (non-Javadoc) |
559 |
// TODO Auto-generated method stub |
511 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setIsInitalized(boolean) |
560 |
return mIsInitialized; |
512 |
*/ |
561 |
} |
513 |
public void setIsInitalized(boolean value) { |
562 |
|
514 |
mIsInitialized = value; |
563 |
/* (non-Javadoc) |
515 |
} |
564 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setIsInitalized(boolean) |
516 |
|
565 |
*/ |
517 |
/* (non-Javadoc) |
566 |
public void setIsInitalized(boolean value) |
518 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getSortPriority() |
567 |
{ |
519 |
*/ |
568 |
mIsInitialized = value; |
520 |
public long getSortPriority() { |
569 |
} |
521 |
// TODO Auto-generated method stub |
570 |
|
522 |
return m_Data.getSortPriority(); |
571 |
/* (non-Javadoc) |
523 |
} |
572 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getSortPriority() |
524 |
|
573 |
*/ |
525 |
/* (non-Javadoc) |
574 |
public long getSortPriority() |
526 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setSortPriority(long) |
575 |
{ |
527 |
*/ |
576 |
// TODO Auto-generated method stub |
528 |
public void setSortPriority(long value) { |
577 |
return m_Data.getSortPriority(); |
529 |
m_Data.setSortPriority(value); |
578 |
} |
530 |
} |
579 |
|
531 |
|
580 |
/* (non-Javadoc) |
532 |
/* (non-Javadoc) |
581 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setSortPriority(long) |
533 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setExpanded(boolean) |
582 |
*/ |
534 |
*/ |
583 |
public void setSortPriority(long value) |
535 |
public void setExpanded(boolean value) { |
584 |
{ |
536 |
} |
585 |
m_Data.setSortPriority(value); |
537 |
|
586 |
} |
538 |
/* (non-Javadoc) |
587 |
|
539 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setSelected(boolean) |
588 |
/* (non-Javadoc) |
540 |
*/ |
589 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setExpanded(boolean) |
541 |
public void setSelected(boolean value) { |
590 |
*/ |
542 |
} |
591 |
public void setExpanded(boolean value){} |
543 |
|
592 |
|
544 |
/** |
593 |
/* (non-Javadoc) |
545 |
* Retrieve a collection that contains all of the children contained by the |
594 |
* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setSelected(boolean) |
546 |
* node. |
595 |
*/ |
547 |
* <br> |
596 |
public void setSelected(boolean value) {} |
548 |
* <i>Note:</i> This collection should be treated as <b>read-only</b>. If a |
597 |
|
549 |
* node is added to the returned collection any associated view will not be |
598 |
/** |
550 |
* updated until a refresh is performed. |
599 |
* Retrieve a collection that contains all of the children contained by the |
551 |
* |
600 |
* node. |
552 |
* @return The collection of children. |
601 |
* <br> |
553 |
*/ |
602 |
* <i>Note:</i> This collection should be treated as <b>read-only</b>. If a |
554 |
public Enumeration<ITreeItem> getNodeChildren() { |
603 |
* node is added to the returned collection any associated view will not be |
555 |
Children children = getChildren(); |
604 |
* updated until a refresh is performed. |
556 |
|
605 |
* |
557 |
return new TreeItemEnumeration(children); |
606 |
* @return The collection of children. |
558 |
} |
607 |
*/ |
559 |
|
608 |
public Enumeration<ITreeItem> getNodeChildren() |
560 |
//************************************************** |
609 |
{ |
561 |
// AbstractModelElement Implementation |
610 |
Children children = getChildren(); |
562 |
//************************************************** |
611 |
|
|
|
612 |
return new TreeItemEnumeration(children); |
613 |
} |
614 |
|
615 |
//************************************************** |
616 |
// AbstractModelElement Implementation |
617 |
//************************************************** |
618 |
|
619 |
/** |
563 |
/** |
620 |
* Retrieves the actions for the node. This method only returns |
564 |
* Retrieves the actions for the node. This method only returns |
621 |
* the context sensitive actions. |
565 |
* the context sensitive actions. |
Lines 624-1010
Link Here
|
624 |
* node itself |
568 |
* node itself |
625 |
* @return A list of actions (you may include nulls for separators) |
569 |
* @return A list of actions (you may include nulls for separators) |
626 |
*/ |
570 |
*/ |
627 |
public Action[] getActions(boolean context) |
571 |
public Action[] getActions(boolean context) { |
628 |
{ |
|
|
629 |
|
572 |
|
630 |
// Source control Sub menu Actions are created based on the SCM status of the nodes (Class diagrams, classes) |
573 |
// Source control Sub menu Actions are created based on the SCM status of the nodes (Class diagrams, classes) |
631 |
// so every time we need to get the actions afresh. |
574 |
// so every time we need to get the actions afresh. |
632 |
|
575 |
|
633 |
// if (actions == null) |
576 |
// if (actions == null) |
634 |
return super.getActions(context); |
577 |
return super.getActions(context); |
635 |
|
578 |
|
636 |
} |
579 |
} |
637 |
|
580 |
|
638 |
public Action getPreferredAction() |
581 |
public Action getPreferredAction() { |
639 |
{ |
582 |
return SystemAction.get(OpenAction.class); |
640 |
return SystemAction.get(OpenAction.class); |
583 |
} |
641 |
} |
584 |
|
642 |
|
|
|
643 |
@Override |
585 |
@Override |
644 |
public Image getIcon(int type) |
586 |
public Image getIcon(int type) { |
645 |
{ |
|
|
646 |
Image retVal = null; |
587 |
Image retVal = null; |
647 |
// if(icon!=null) return icon; |
588 |
// if(icon!=null) return icon; |
648 |
|
589 |
|
649 |
ITreeItem item = this; |
590 |
ITreeItem item = this; |
650 |
IProjectTreeItem data = item.getData(); |
591 |
IProjectTreeItem data = item.getData(); |
651 |
|
592 |
|
652 |
if (icon!=null) |
593 |
if (icon != null) { |
653 |
{ |
|
|
654 |
retVal = icon; |
594 |
retVal = icon; |
655 |
} |
595 |
} else { |
656 |
|
596 |
|
657 |
else |
597 |
if (item instanceof ITreeFolder) { |
658 |
{ |
598 |
CommonResourceManager resource = |
|
|
599 |
CommonResourceManager.instance(); |
659 |
|
600 |
|
660 |
if (item instanceof ITreeFolder) |
601 |
retVal = createImage(resource.getIconDetailsForElementType(item.getName())); |
661 |
{ |
602 |
} else if (item instanceof ITreeDiagram) { |
662 |
CommonResourceManager resource = |
603 |
ITreeDiagram diagram = (ITreeDiagram) item; |
663 |
CommonResourceManager.instance(); |
|
|
664 |
|
665 |
retVal = createImage(resource |
666 |
.getIconDetailsForElementType(item.getName())); |
667 |
} |
668 |
|
669 |
else if (item instanceof ITreeDiagram) |
670 |
{ |
671 |
ITreeDiagram diagram = (ITreeDiagram)item; |
672 |
|
604 |
|
673 |
CommonResourceManager resource = |
605 |
CommonResourceManager resource = |
674 |
CommonResourceManager.instance(); |
606 |
CommonResourceManager.instance(); |
675 |
|
607 |
|
676 |
retVal = createImage(resource |
608 |
retVal = createImage(resource.getIconDetailsForElementType(diagram.getDiagramType())); |
677 |
.getIconDetailsForElementType(diagram.getDiagramType())); |
|
|
678 |
|
609 |
|
679 |
if (diagram.getDiagram().getDiagramDetails() |
610 |
if (diagram.getDiagram().getDiagramDetails() instanceof TSDiagramDetails) { |
680 |
instanceof TSDiagramDetails) |
|
|
681 |
{ |
682 |
// this is an old TS diagram; when opened, it needs |
611 |
// this is an old TS diagram; when opened, it needs |
683 |
// to be converted to new Meteora diagram. |
612 |
// to be converted to new Meteora diagram. |
684 |
// this code will badge the diagram icon with a |
613 |
// this code will badge the diagram icon with a |
685 |
// yellow triangle with an exclamation point to |
614 |
// yellow triangle with an exclamation point to |
686 |
// visually indicate the diagram's state |
615 |
// visually indicate the diagram's state |
687 |
retVal = ImageUtilities.mergeImages( |
616 |
retVal = ImageUtilities.mergeImages( |
688 |
retVal, createImage(ICON_BADGE_EXCLAMATION), 0, 0); |
617 |
retVal, createImage(ICON_BADGE_EXCLAMATION), 0, 0); |
689 |
} |
618 |
} |
690 |
} |
619 |
} else if (data.getModelElement() != null) { |
|
|
620 |
if (data.getModelElement() instanceof IProject) { |
621 |
retVal = super.getIcon(type); |
622 |
} else { |
623 |
CommonResourceManager resource = |
624 |
CommonResourceManager.instance(); |
691 |
|
625 |
|
692 |
else if (data.getModelElement() != null) |
626 |
retVal = createImage(resource.getIconDetailsForDisp(data.getModelElement())); |
693 |
{ |
|
|
694 |
if (data.getModelElement() instanceof IProject) |
695 |
retVal = super.getIcon(type); |
696 |
|
697 |
else |
698 |
{ |
699 |
CommonResourceManager resource = |
700 |
CommonResourceManager.instance(); |
701 |
|
702 |
retVal = createImage(resource |
703 |
.getIconDetailsForDisp(data.getModelElement())); |
704 |
} |
627 |
} |
705 |
} |
628 |
} else if (data.isProject()) { |
706 |
|
|
|
707 |
else if (data.isProject()) |
708 |
{ |
709 |
// CommonResourceManager resource = |
629 |
// CommonResourceManager resource = |
710 |
// CommonResourceManager.instance(); |
630 |
// CommonResourceManager.instance(); |
711 |
// retVal = createImage( |
631 |
// retVal = createImage( |
712 |
// resource.getIconDetailsForElementType("WSProject")); |
632 |
// resource.getIconDetailsForElementType("WSProject")); |
713 |
|
633 |
|
714 |
retVal = super.getIcon(type); |
634 |
retVal = super.getIcon(type); |
715 |
} |
635 |
} else if (data.isWorkspace()) { |
716 |
|
|
|
717 |
else if (data.isWorkspace()) |
718 |
{ |
719 |
CommonResourceManager resource = CommonResourceManager.instance(); |
636 |
CommonResourceManager resource = CommonResourceManager.instance(); |
720 |
// special case for design pattern catalog |
637 |
// special case for design pattern catalog |
721 |
|
638 |
|
722 |
if (data.getItemText().equals("DesignPatternCatalog")) // NOI18N |
639 |
if (data.getItemText().equals("DesignPatternCatalog")) // NOI18N |
723 |
{ |
640 |
{ |
724 |
retVal = createImage( |
641 |
retVal = createImage( |
725 |
resource.getIconDetailsForElementType( |
642 |
resource.getIconDetailsForElementType( |
726 |
"DesignPatternCatalog")); // NOI18N |
643 |
"DesignPatternCatalog")); // NOI18N |
|
|
644 |
} else { |
645 |
retVal = createImage(resource.getIconDetailsForElementType("Workspace")); // NOI18N |
727 |
} |
646 |
} |
728 |
|
647 |
} else { |
729 |
else |
648 |
CommonResourceManager resource = |
730 |
{ |
649 |
CommonResourceManager.instance(); |
731 |
retVal = createImage(resource |
|
|
732 |
.getIconDetailsForElementType("Workspace")); // NOI18N |
733 |
} |
734 |
} |
735 |
|
736 |
else |
737 |
{ |
738 |
CommonResourceManager resource = |
739 |
CommonResourceManager.instance(); |
740 |
|
650 |
|
741 |
retVal = createImage( |
651 |
retVal = createImage( |
742 |
resource.getIconDetailsForElementType(item.getName())); |
652 |
resource.getIconDetailsForElementType(item.getName())); |
743 |
} |
653 |
} |
744 |
} |
654 |
} |
745 |
|
655 |
|
746 |
if (retVal == null) |
656 |
if (retVal == null) { |
747 |
retVal = super.getIcon(type); |
657 |
retVal = super.getIcon(type); |
|
|
658 |
} |
748 |
|
659 |
|
749 |
//return getIconWithOverlay(retVal, this); |
660 |
//return getIconWithOverlay(retVal, this); |
750 |
retVal=getIconWithOverlay(retVal, this); |
661 |
retVal = getIconWithOverlay(retVal, this); |
751 |
|
662 |
|
752 |
icon=retVal; |
663 |
icon = retVal; |
753 |
return icon; |
664 |
return icon; |
754 |
} |
665 |
} |
755 |
|
666 |
public final static String ICON_BADGE_EXCLAMATION = |
756 |
public final static String ICON_BADGE_EXCLAMATION = |
667 |
ImageUtil.IMAGE_FOLDER + "broken-project-badge.gif"; |
757 |
ImageUtil.IMAGE_FOLDER + "broken-project-badge.gif"; |
668 |
|
758 |
|
|
|
759 |
@Override |
669 |
@Override |
760 |
public Image getOpenedIcon(int type) |
670 |
public Image getOpenedIcon(int type) { |
761 |
{ |
671 |
return getIcon(type); |
762 |
return getIcon(type); |
672 |
} |
763 |
} |
|
|
764 |
|
765 |
/* (non-Javadoc) |
766 |
* @see org.netbeans.modules.uml.netbeans.umlproject.ui.AbstractModelElementNode#getModelElement() |
767 |
*/ |
768 |
public IElement getModelElement() |
769 |
{ |
770 |
IElement retVal = null; |
771 |
IProjectTreeItem item = getData(); |
772 |
|
773 |
if (item != null) |
774 |
retVal = item.getModelElement(); |
775 |
|
673 |
|
776 |
return retVal; |
674 |
/* (non-Javadoc) |
777 |
} |
675 |
* @see org.netbeans.modules.uml.netbeans.umlproject.ui.AbstractModelElementNode#getModelElement() |
778 |
|
676 |
*/ |
779 |
|
677 |
public IElement getModelElement() { |
780 |
//************************************************** |
678 |
IElement retVal = null; |
781 |
// CookieSet.Factory implementation |
679 |
IProjectTreeItem item = getData(); |
782 |
//************************************************** |
|
|
783 |
|
784 |
public Node.Cookie createCookie(Class klass) |
785 |
{ |
786 |
Node.Cookie retVal = null; |
787 |
|
788 |
if (OpenCookie.class.equals(klass) == true) |
789 |
{ |
790 |
if (mOpenCookie == null) |
791 |
mOpenCookie = createOpenCookie(); |
792 |
|
793 |
retVal = mOpenCookie; |
794 |
} |
795 |
|
796 |
return retVal; |
797 |
} |
798 |
|
799 |
|
800 |
//************************************************** |
801 |
// Helper Methods |
802 |
//************************************************** |
803 |
|
804 |
public String toString() |
805 |
{ |
806 |
String retVal = getDisplayedName(); |
807 |
|
808 |
if ((retVal == null) || (retVal.length() <= 0)) |
809 |
retVal = getName(); |
810 |
|
811 |
return retVal; |
812 |
} |
813 |
|
814 |
/* (non-Javadoc) |
815 |
* @see java.lang.Object#equals(java.lang.Object) |
816 |
*/ |
817 |
public boolean equals(Object obj) |
818 |
{ |
819 |
boolean retVal = false; |
820 |
|
821 |
if (obj != null && this.hashCode() == obj.hashCode()) |
822 |
return true; |
823 |
|
824 |
IProjectTreeItem myItem = getData(); |
825 |
|
826 |
if (obj instanceof IElement) |
827 |
{ |
828 |
IElement myElement = myItem.getModelElement(); |
829 |
|
830 |
if (myElement != null) |
831 |
retVal = myElement.isSame((IElement)obj); |
832 |
} |
833 |
|
680 |
|
834 |
else if (obj instanceof UMLElementNode) |
681 |
if (item != null) { |
835 |
{ |
682 |
retVal = item.getModelElement(); |
836 |
UMLElementNode node = (UMLElementNode)obj; |
683 |
} |
837 |
IProjectTreeItem testItem = node.getData(); |
684 |
|
838 |
String testText = node.getDisplayedName(); |
685 |
return retVal; |
839 |
String myText = getDisplayedName(); |
686 |
} |
840 |
|
687 |
|
841 |
if ((testText != null) && (myText != null)) |
688 |
//************************************************** |
842 |
retVal = testText.equals(myText); |
689 |
// CookieSet.Factory implementation |
843 |
|
690 |
//************************************************** |
844 |
else if ((testText == null) && (myText == null)) |
691 |
public Node.Cookie createCookie(Class klass) { |
845 |
retVal = super.equals(obj); |
692 |
Node.Cookie retVal = null; |
846 |
|
693 |
|
847 |
if (retVal == true) |
694 |
if (OpenCookie.class.equals(klass) == true) { |
848 |
{ |
695 |
if (mOpenCookie == null) { |
849 |
String testXMIID = testItem.getModelElementXMIID(); |
696 |
mOpenCookie = createOpenCookie(); |
850 |
String myXMIID = myItem.getModelElementXMIID(); |
697 |
} |
851 |
|
698 |
|
852 |
if ((testXMIID != null) && (myXMIID != null)) |
699 |
retVal = mOpenCookie; |
853 |
retVal = testXMIID.equals(myXMIID); |
700 |
} |
854 |
} |
701 |
|
855 |
} |
702 |
return retVal; |
856 |
|
703 |
} |
857 |
else |
704 |
|
858 |
{ // Generic equals method. This can be used to test |
705 |
//************************************************** |
859 |
// to ITreeItem(s). |
706 |
// Helper Methods |
860 |
retVal = super.equals(obj); |
707 |
//************************************************** |
861 |
} |
708 |
public String toString() { |
862 |
|
709 |
String retVal = getDisplayedName(); |
863 |
return retVal; |
710 |
|
864 |
} |
711 |
if ((retVal == null) || (retVal.length() <= 0)) { |
865 |
|
712 |
retVal = getName(); |
866 |
/** |
713 |
} |
867 |
* Initializes the node with the default cookies. <b>Note:</b> Do not |
714 |
|
868 |
* call this method if a looup is added. When a lookup is added then the |
715 |
return retVal; |
869 |
* lookup is used to find the cookies. |
716 |
} |
870 |
*/ |
717 |
|
871 |
protected void initCookies() |
718 |
/* (non-Javadoc) |
872 |
{ |
719 |
* @see java.lang.Object#equals(java.lang.Object) |
873 |
Class[] cookies = {OpenCookie.class}; |
720 |
*/ |
874 |
getCookieSet().add(cookies, this); |
721 |
public boolean equals(Object obj) { |
875 |
} |
722 |
boolean retVal = false; |
876 |
|
723 |
|
877 |
/** |
724 |
if (obj != null && this.hashCode() == obj.hashCode()) { |
878 |
* Creates the open cookie to use when opening the node. |
725 |
return true; |
879 |
*/ |
726 |
} |
880 |
protected Node.Cookie createOpenCookie() |
727 |
|
881 |
{ |
728 |
IProjectTreeItem myItem = getData(); |
882 |
return new ModelElementOpen(); |
729 |
|
883 |
} |
730 |
if (obj instanceof IElement) { |
884 |
|
731 |
IElement myElement = myItem.getModelElement(); |
885 |
|
732 |
|
886 |
|
733 |
if (myElement != null) { |
887 |
/** |
734 |
retVal = myElement.isSame((IElement) obj); |
888 |
* @param string |
735 |
} |
889 |
* @return |
736 |
} else if (obj instanceof UMLElementNode) { |
890 |
*/ |
737 |
UMLElementNode node = (UMLElementNode) obj; |
891 |
protected Image createImage(String iconLocation) |
738 |
IProjectTreeItem testItem = node.getData(); |
892 |
{ |
739 |
String testText = node.getDisplayedName(); |
893 |
return ImageUtilities.loadImage( iconLocation, true ); |
740 |
String myText = getDisplayedName(); |
894 |
} |
741 |
|
895 |
|
742 |
if ((testText != null) && (myText != null)) { |
896 |
/** |
743 |
retVal = testText.equals(myText); |
897 |
* Implementation of method from Comparable interface. |
744 |
} else if ((testText == null) && (myText == null)) { |
898 |
* @return |
745 |
retVal = super.equals(obj); |
899 |
*/ |
746 |
} |
900 |
public int compareTo(Object o) |
747 |
|
901 |
{ |
748 |
if (retVal == true) { |
902 |
return ProjectTreeComparable.compareTo(this, o); |
749 |
String testXMIID = testItem.getModelElementXMIID(); |
903 |
} |
750 |
String myXMIID = myItem.getModelElementXMIID(); |
904 |
|
751 |
|
905 |
// to be overridden by subclasses as needed |
752 |
if ((testXMIID != null) && (myXMIID != null)) { |
906 |
public void registerListeners() |
753 |
retVal = testXMIID.equals(myXMIID); |
907 |
{} |
754 |
} |
908 |
|
755 |
} |
909 |
|
756 |
} else { // Generic equals method. This can be used to test |
910 |
public class ModelElementOpen implements OpenCookie |
757 |
// to ITreeItem(s). |
911 |
{ |
758 |
retVal = super.equals(obj); |
912 |
public void open() |
759 |
} |
913 |
{ |
760 |
|
914 |
DispatchHelper helper = new DispatchHelper(); |
761 |
return retVal; |
915 |
IProjectTreeEventDispatcher disp = helper.getProjectTreeDispatcher(); |
762 |
} |
916 |
if (disp != null) |
763 |
|
917 |
{ |
764 |
/** |
918 |
IEventPayload payload = |
765 |
* Initializes the node with the default cookies. <b>Note:</b> Do not |
919 |
disp.createPayload("ProjectTreeDoubleClick"); // NOI18N |
766 |
* call this method if a looup is added. When a lookup is added then the |
920 |
|
767 |
* lookup is used to find the cookies. |
921 |
helper.getProjectTreeDispatcher().fireDoubleClick(null, |
768 |
*/ |
922 |
getData(), false, false, false, false, payload); |
769 |
protected void initCookies() { |
923 |
} |
770 |
Class[] cookies = {OpenCookie.class}; |
924 |
|
771 |
getCookieSet().add(cookies, this); |
925 |
registerListeners(); |
772 |
} |
926 |
} |
773 |
|
927 |
} |
774 |
/** |
928 |
|
775 |
* Creates the open cookie to use when opening the node. |
929 |
public class TreeItemEnumeration implements Enumeration < ITreeItem > |
776 |
*/ |
930 |
{ |
777 |
protected Node.Cookie createOpenCookie() { |
931 |
Enumeration m_ChildrenEnum = null; |
778 |
return new ModelElementOpen(); |
932 |
|
779 |
} |
933 |
public TreeItemEnumeration(Children c) |
780 |
|
934 |
{ |
781 |
/** |
935 |
m_ChildrenEnum = c.nodes(); |
782 |
* @param string |
936 |
} |
783 |
* @return |
937 |
|
784 |
*/ |
938 |
public boolean hasMoreElements() |
785 |
protected Image createImage(String iconLocation) { |
939 |
{ |
786 |
return ImageUtilities.loadImage(iconLocation, true); |
940 |
return m_ChildrenEnum.hasMoreElements(); |
787 |
} |
941 |
} |
788 |
|
942 |
|
789 |
/** |
943 |
public ITreeItem nextElement() |
790 |
* Implementation of method from Comparable interface. |
944 |
{ |
791 |
* @return |
945 |
return (ITreeItem)m_ChildrenEnum.nextElement(); |
792 |
*/ |
946 |
} |
793 |
public int compareTo(Object o) { |
947 |
} |
794 |
return ProjectTreeComparable.compareTo(this, o); |
948 |
|
795 |
} |
949 |
|
796 |
|
950 |
|
797 |
// to be overridden by subclasses as needed |
951 |
public void vcsFeatureExecuted(/* SCMFeatureKind */ int kind) |
798 |
public void registerListeners() { |
952 |
{ |
799 |
} |
953 |
if(kind == SCMFeatureKind.FK_CHECK_IN || |
800 |
|
954 |
kind == SCMFeatureKind.FK_CHECK_OUT || |
801 |
public class ModelElementOpen implements OpenCookie { |
955 |
kind == SCMFeatureKind.FK_ADD_TO_SOURCE_CONTROL || |
802 |
|
956 |
kind == SCMFeatureKind.FK_REMOVE_FROM_SOURCE_CONTROL || |
803 |
public void open() { |
957 |
kind == SCMFeatureKind.REFRESH_STATUS) |
804 |
DispatchHelper helper = new DispatchHelper(); |
958 |
{ |
805 |
IProjectTreeEventDispatcher disp = helper.getProjectTreeDispatcher(); |
959 |
fireIconChange(); |
806 |
if (disp != null) { |
960 |
} |
807 |
IEventPayload payload = |
961 |
} |
808 |
disp.createPayload("ProjectTreeDoubleClick"); // NOI18N |
962 |
|
809 |
|
963 |
protected Image getIconWithOverlay(Image image, ITreeItem item) |
810 |
helper.getProjectTreeDispatcher().fireDoubleClick(null, |
964 |
{ |
811 |
getData(), false, false, false, false, payload); |
965 |
ImageIcon image1 = new ImageIcon(image); |
812 |
} |
966 |
|
813 |
|
967 |
|
814 |
registerListeners(); |
968 |
if(!(item instanceof ITreeFolder)) |
815 |
} |
969 |
{ |
816 |
} |
970 |
Icon overlay = getOverlayIcon(item.getData()); |
817 |
|
971 |
|
818 |
public class TreeItemEnumeration implements Enumeration<ITreeItem> { |
972 |
if((image1 != null) && (overlay != null)) |
819 |
|
973 |
{ |
820 |
Enumeration m_ChildrenEnum = null; |
974 |
GraphicsDevice[] gs = GraphicsEnvironment |
821 |
|
975 |
.getLocalGraphicsEnvironment().getScreenDevices(); |
822 |
public TreeItemEnumeration(Children c) { |
976 |
|
823 |
m_ChildrenEnum = c.nodes(); |
977 |
GraphicsConfiguration[] gc = gs[0].getConfigurations(); |
824 |
} |
978 |
|
825 |
|
979 |
Image retImage = gc[0].createCompatibleVolatileImage( |
826 |
public boolean hasMoreElements() { |
980 |
image1.getIconWidth(), image1.getIconHeight()); |
827 |
return m_ChildrenEnum.hasMoreElements(); |
981 |
|
828 |
} |
982 |
Graphics g = retImage.getGraphics(); |
829 |
|
983 |
|
830 |
public ITreeItem nextElement() { |
984 |
image1.paintIcon(null, g, 0, 0); |
831 |
return (ITreeItem) m_ChildrenEnum.nextElement(); |
985 |
|
832 |
} |
986 |
int overlayY = image1.getIconHeight() - overlay.getIconHeight(); |
833 |
} |
987 |
overlay.paintIcon(null, g, 0, overlayY); |
834 |
|
988 |
|
835 |
public void vcsFeatureExecuted(/* SCMFeatureKind */int kind) { |
989 |
|
836 |
if (kind == SCMFeatureKind.FK_CHECK_IN |
990 |
image1 = new ImageIcon(retImage); |
837 |
|| kind == SCMFeatureKind.FK_CHECK_OUT |
991 |
} |
838 |
|| kind == SCMFeatureKind.FK_ADD_TO_SOURCE_CONTROL |
992 |
} |
839 |
|| kind == SCMFeatureKind.FK_REMOVE_FROM_SOURCE_CONTROL |
993 |
return image1.getImage(); |
840 |
|| kind == SCMFeatureKind.REFRESH_STATUS) { |
994 |
} |
841 |
fireIconChange(); |
995 |
|
842 |
} |
996 |
protected Icon getOverlayIcon(IProjectTreeItem item) |
843 |
} |
997 |
{ |
844 |
|
998 |
Icon retVal = null; |
845 |
protected Image getIconWithOverlay(Image image, ITreeItem item) { |
999 |
|
846 |
ImageIcon image1 = new ImageIcon(image); |
1000 |
|
847 |
|
1001 |
ISCMIntegrator gator = ProductHelper.getSCMIntegrator(); |
848 |
|
1002 |
if(gator != null) |
849 |
if (!(item instanceof ITreeFolder)) { |
1003 |
{ |
850 |
Icon overlay = getOverlayIcon(item.getData()); |
1004 |
int kind = gator.getSCMMaskKind(item); |
851 |
|
1005 |
retVal = gator.getSCMMask(kind); |
852 |
if ((image1 != null) && (overlay != null)) { |
1006 |
} |
853 |
GraphicsDevice[] gs = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); |
1007 |
|
854 |
|
1008 |
return retVal; |
855 |
GraphicsConfiguration[] gc = gs[0].getConfigurations(); |
1009 |
} |
856 |
|
|
|
857 |
Image retImage = gc[0].createCompatibleVolatileImage( |
858 |
image1.getIconWidth(), image1.getIconHeight()); |
859 |
|
860 |
Graphics g = retImage.getGraphics(); |
861 |
|
862 |
image1.paintIcon(null, g, 0, 0); |
863 |
|
864 |
int overlayY = image1.getIconHeight() - overlay.getIconHeight(); |
865 |
overlay.paintIcon(null, g, 0, overlayY); |
866 |
|
867 |
|
868 |
image1 = new ImageIcon(retImage); |
869 |
} |
870 |
} |
871 |
return image1.getImage(); |
872 |
} |
873 |
|
874 |
protected Icon getOverlayIcon(IProjectTreeItem item) { |
875 |
Icon retVal = null; |
876 |
|
877 |
|
878 |
ISCMIntegrator gator = ProductHelper.getSCMIntegrator(); |
879 |
if (gator != null) { |
880 |
int kind = gator.getSCMMaskKind(item); |
881 |
retVal = gator.getSCMMask(kind); |
882 |
} |
883 |
|
884 |
return retVal; |
885 |
} |
1010 |
} |
886 |
} |