KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > abe > action > CompositorOnElementNewType


1
2 /*
3  * The contents of this file are subject to the terms of the Common Development
4  * and Distribution License (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
8  * or http://www.netbeans.org/cddl.txt.
9  *
10  * When distributing Covered Code, include this CDDL Header Notice in each file
11  * and include the License file at http://www.netbeans.org/cddl.txt.
12  * If applicable, add the following below the CDDL Header, with the fields
13  * enclosed by brackets [] replaced by your own identifying information:
14  * "Portions Copyrighted [year] [name of copyright owner]"
15  *
16  * The Original Software is NetBeans. The Initial Developer of the Original
17  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
18  * Microsystems, Inc. All Rights Reserved.
19  */

20 /*
21  * CompositorOnElementNewType.java
22  *
23  * Created on July 18, 2006, 3:34 PM
24  *
25  * To change this template, choose Tools | Template Manager
26  * and open the template in the editor.
27  */

28
29 package org.netbeans.modules.xml.schema.abe.action;
30
31 import java.io.IOException JavaDoc;
32 import java.util.List JavaDoc;
33 import org.netbeans.modules.xml.axi.Compositor;
34 import org.netbeans.modules.xml.schema.abe.ABEBaseDropPanel;
35 import org.netbeans.modules.xml.schema.abe.InstanceUIContext;
36 import org.netbeans.modules.xml.schema.abe.StartTagPanel;
37 import org.netbeans.modules.xml.schema.abe.nodes.ABEAbstractNode;
38 import org.openide.util.NbBundle;
39 import org.openide.util.datatransfer.NewType;
40
41 /**
42  *
43  * @author girix
44  */

45 public class CompositorOnElementNewType extends NewType{
46     
47     InstanceUIContext context;
48     Compositor.CompositorType compType;
49     /** Creates a new instance of ElementNewType */
50     public CompositorOnElementNewType(InstanceUIContext context,
51             Compositor.CompositorType compType) {
52         super();
53         this.context = context;
54         this.compType = compType;
55     }
56     
57     public void create(Compositor.CompositorType compType) throws IOException JavaDoc {
58         List JavaDoc<ABEBaseDropPanel> list = context.getComponentSelectionManager().
59                 getSelectedComponentList();
60         if(list.size() <= 0)
61             return;
62         StartTagPanel startTagPanel = (StartTagPanel) list.get(0);
63         context.setUserInducedEventMode(true, startTagPanel);
64         startTagPanel.addCompositor(compType);
65         context.setUserInducedEventMode(false);
66     }
67     
68     public void create() throws IOException JavaDoc {
69         create(compType);
70     }
71     
72     public String JavaDoc getName() {
73         String JavaDoc comp = null;
74         switch(compType){
75             case SEQUENCE:
76                 comp = NbBundle.getMessage(ABEAbstractNode.class,"LBL_Sequence");
77                 break;
78             case CHOICE:
79                 comp = NbBundle.getMessage(ABEAbstractNode.class,"LBL_Choice");
80                 break;
81             case ALL:
82                 comp = NbBundle.getMessage(ABEAbstractNode.class,"LBL_All");
83                 break;
84         }
85         return comp;
86     }
87     
88     
89     
90 }
91
Popular Tags