01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor.schema;
11:
12: import org.eclipse.jface.action.Action;
13: import org.eclipse.jface.resource.ImageDescriptor;
14: import org.eclipse.pde.internal.core.ischema.ISchemaElement;
15: import org.eclipse.pde.internal.core.schema.SchemaCompositor;
16: import org.eclipse.pde.internal.core.schema.SchemaElementReference;
17: import org.eclipse.pde.internal.ui.PDEPluginImages;
18:
19: public class NewReferenceAction extends Action {
20: private Object object;
21:
22: private ISchemaElement referencedElement;
23:
24: public NewReferenceAction(ISchemaElement source, Object object,
25: ISchemaElement referencedElement) {
26: this .object = object;
27: this .referencedElement = referencedElement;
28: setText(referencedElement.getName());
29: ImageDescriptor desc = PDEPluginImages.DESC_ELREF_SC_OBJ;
30: setImageDescriptor(desc);
31: setEnabled(source.getSchema().isEditable());
32: }
33:
34: public void run() {
35: if (object != null && object instanceof SchemaCompositor) {
36: SchemaCompositor parent = (SchemaCompositor) object;
37: SchemaElementReference reference = new SchemaElementReference(
38: parent, referencedElement.getName());
39: reference.setReferencedObject(referencedElement);
40: parent.addChild(reference);
41: }
42: }
43: }
|