1 11 package org.eclipse.pde.internal.ui.editor.schema; 12 13 import org.eclipse.jface.action.Action; 14 import org.eclipse.jface.resource.ImageDescriptor; 15 import org.eclipse.pde.internal.core.ischema.ISchemaElement; 16 import org.eclipse.pde.internal.core.schema.SchemaCompositor; 17 import org.eclipse.pde.internal.core.schema.SchemaElementReference; 18 import org.eclipse.pde.internal.ui.PDEPluginImages; 19 20 public class NewReferenceAction extends Action { 21 private Object object; 22 23 private ISchemaElement referencedElement; 24 25 public NewReferenceAction(ISchemaElement source, Object object, 26 ISchemaElement referencedElement) { 27 this.object = object; 28 this.referencedElement = referencedElement; 29 setText(referencedElement.getName()); 30 ImageDescriptor desc = PDEPluginImages.DESC_ELREF_SC_OBJ; 31 setImageDescriptor(desc); 32 setEnabled(source.getSchema().isEditable()); 33 } 34 35 public void run() { 36 if (object != null && object instanceof SchemaCompositor) { 37 SchemaCompositor parent = (SchemaCompositor) object; 38 SchemaElementReference reference = new SchemaElementReference(parent, 39 referencedElement.getName()); 40 reference.setReferencedObject(referencedElement); 41 parent.addChild(reference); 42 } 43 } 44 } 45 | Popular Tags |