KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > bridge > EditingRunnable


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

19
20 package org.netbeans.modules.java.bridge;
21
22 import org.openide.src.*;
23
24 /**
25  *
26  * @author sdedic
27  * @version
28  */

29 class EditingRunnable implements ExceptionRunnable {
30     public static final int OP_MODIFIERS = 0;
31     public static final int OP_NAME = 1;
32     public static final int OP_SUPERCLASS = 2;
33     public static final int OP_SUPERINTERFACES = 3;
34     public static final int OP_EXCEPTIONS = 4;
35     public static final int OP_PARAMETERS = 5;
36     public static final int OP_RETURNTYPE = 6;
37     public static final int OP_CHANGE_FIELDS = 7;
38     public static final int OP_CHANGE_METHODS = 8;
39     public static final int OP_CHANGE_CONSTRUCTORS = 9;
40     public static final int OP_CHANGE_INITIALIZERS = 10;
41     public static final int OP_CHANGE_CLASSES = 11;
42     public static final int OP_BODY = 12;
43     public static final int OP_CLASSFLAG = 13;
44     public static final int OP_PACKAGE = 14;
45     public static final int OP_IMPORT = 15;
46     
47     ElementImpl impl;
48     int op;
49     int mods;
50     Identifier name;
51     Element[] elems;
52     Identifier[] ids;
53     MethodParameter[] params;
54     Type rettype;
55     String JavaDoc str;
56     boolean flag;
57     Import imp;
58     
59     public EditingRunnable(ElementImpl impl, boolean flag) {
60         this.impl = impl;
61         this.flag = flag;
62         this.op = OP_CLASSFLAG;
63     }
64     
65     public EditingRunnable(ElementImpl impl, Import i) {
66         this.impl = impl;
67         this.imp = i;
68         this.op = OP_IMPORT;
69     }
70     
71     public EditingRunnable(ElementImpl impl, int mods) {
72         this.impl = impl;
73         this.mods = mods;
74         this.op = OP_MODIFIERS;
75     }
76     
77     public EditingRunnable(ElementImpl impl, int opcode, Element[] elems, int changeCode) {
78         this.impl = impl;
79         this.op = opcode;
80         this.elems = elems;
81         this.mods = changeCode;
82     }
83     
84     public EditingRunnable(ElementImpl impl, MethodParameter[] params) {
85         this.impl = impl;
86         this.params = params;
87         this.op = OP_PARAMETERS;
88     }
89     
90     public EditingRunnable(ElementImpl impl, Identifier[] ids, int operation) {
91         this.impl = impl;
92         this.op = OP_SUPERINTERFACES;
93         this.ids = ids;
94         this.mods = operation;
95     }
96     
97     public EditingRunnable(ElementImpl impl, Identifier[] ids) {
98         this.impl = impl;
99         this.ids = ids;
100         this.op = OP_EXCEPTIONS;
101     }
102     
103     public EditingRunnable(ElementImpl impl, int opcode, Identifier name) {
104         this.impl = impl;
105         this.name = name;
106         this.op = opcode;
107     }
108         
109     public EditingRunnable(ElementImpl impl, Type rettype) {
110         this.impl = impl;
111         this.rettype = rettype;
112         this.op = OP_RETURNTYPE;
113     }
114     
115     public EditingRunnable(ElementImpl impl, String JavaDoc str) {
116         this.impl = impl;
117         this.op = OP_BODY;
118         this.str = str;
119     }
120     
121     public void run() throws SourceException {
122         switch (op) {
123             /*
124             case OP_MODIFIERS:
125                 ((MemberElementImpl)impl).doSetModifiers(mods);
126                 break;
127             case OP_NAME:
128                 ((MemberElementImpl)impl).doSetName(name);
129                 break;
130             case OP_SUPERCLASS:
131                 ((ClassElementImpl)impl).doSetSuperclass(name);
132                 break;
133             case OP_SUPERINTERFACES:
134                 ((ClassElementImpl)impl).doChangeInterfaces(ids, mods);
135                 break;
136             case OP_EXCEPTIONS:
137                 ((CallableImpl)impl).doSetExceptions(ids);
138                 break;
139             case OP_PARAMETERS:
140                 ((CallableImpl)impl).doSetParameters(params);
141                 break;
142             case OP_RETURNTYPE:
143                 ((MethodElementImpl)impl).doSetReturn(rettype);
144                 break;
145             case OP_CHANGE_FIELDS:
146                 ((ClassElementImpl)impl).doChangeFields(elems, mods);
147                 break;
148             case OP_CHANGE_METHODS:
149                 ((ClassElementImpl)impl).doChangeMethods(elems, mods);
150                 break;
151             case OP_CHANGE_CONSTRUCTORS:
152                 ((ClassElementImpl)impl).doChangeConstructors(elems, mods);
153                 break;
154             case OP_CHANGE_INITIALIZERS:
155                 ((ClassElementImpl)impl).doChangeInitializers(elems, mods);
156                 break;
157             case OP_CHANGE_CLASSES:
158                 ((ClassElementImpl)impl).doChangeClasses(elems, mods);
159                 break;
160             case OP_BODY:
161                 ((CallableImpl)impl).doSetBody(str);
162                 break;
163             case OP_CLASSFLAG:
164                 ((ClassElementImpl)impl).doSetClassOrInterface(flag);
165                 break;
166             case OP_IMPORT:
167                 ((ImportImpl)impl).doSetImport(imp);
168                 break;
169             default:
170                 throw new InternalError("Unsupported edit operation"); // NOI18N
171              */

172         }
173     }
174 }
175
Popular Tags