1 11 package org.eclipse.update.internal.ui.model; 12 13 import java.io.*; 14 15 import org.eclipse.core.runtime.*; 16 import org.eclipse.jface.resource.*; 17 import org.eclipse.ui.model.*; 18 19 public class NamedModelObject extends UIModelObject 20 implements IWorkbenchAdapter, Serializable { 21 22 private static final long serialVersionUID = 1L; 23 private String name; 24 transient private NamedModelObject parent; 25 26 public static final String P_NAME="p_name"; 28 public NamedModelObject() { 29 } 30 31 public NamedModelObject(String name) { 32 this.name = name; 33 } 34 35 public Object getAdapter(Class adapter) { 36 if (adapter.equals(IWorkbenchAdapter.class)) { 37 return this; 38 } 39 return super.getAdapter(adapter); 40 } 41 42 public String getName() { 43 return name; 44 } 45 46 public IPath getPath() { 47 Object parent = getParent(null); 48 if (parent!=null && parent instanceof NamedModelObject) 49 return ((NamedModelObject)parent).getPath().append(getName()); 50 else 51 return new Path(getName()); 52 } 53 54 public String toString() { 55 return getName(); 56 } 57 58 public void setName(String name) { 59 this.name = name; 60 notifyObjectChanged(P_NAME); 61 } 62 63 66 public Object [] getChildren(Object parent) { 67 return null; 68 } 69 70 71 74 public ImageDescriptor getImageDescriptor(Object obj) { 75 return null; 76 } 77 78 79 82 public String getLabel(Object obj) { 83 return getName(); 84 } 85 86 87 90 public Object getParent(Object arg0) { 91 return parent; 92 } 93 public void setParent(NamedModelObject parent) { 94 this.parent = parent; 95 } 96 } 97 | Popular Tags |