001: /*
002: :tabSize=4:indentSize=4:noTabs=false:
003: :folding=explicit:collapseFolds=1:
004: This program is free software; you can redistribute it and/or
005: modify it under the terms of the GNU General Public License
006: as published by the Free Software Foundation; either version 2
007: of the License, or any later version.
008: This program is distributed in the hope that it will be useful,
009: but WITHOUT ANY WARRANTY; without even the implied warranty of
010: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
011: GNU General Public License for more detaProjectTreeSelectionListenerils.
012: You should have received a copy of the GNU General Public License
013: along with this program; if not, write to the Free Software
014: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
015: */
016: package org.acm.seguin.ide.jedit;
017:
018: import java.io.File;
019: import java.io.IOException;
020: import org.gjt.sp.jedit.Buffer;
021: import org.gjt.sp.jedit.GUIUtilities;
022:
023: import org.gjt.sp.jedit.View;
024: import org.gjt.sp.jedit.io.VFSManager;
025: import org.gjt.sp.util.Log;
026:
027: /**
028: * A collection of actions accessible through jEdit's Action mechanism, and other utility methods that may be
029: * interesting for interacting with the plugin.
030: *
031: * @author <a href="mailto:JRefactoryPlugin@ladyshot.demon.co.uk">Mike Atkinson</a>
032: * @since 0.0.1
033: * @created 23 July 2003
034: * @version $Id: JavaStyleActions.java,v 1.5 2003/12/02 23:39:37 mikeatkinson Exp $
035: */
036: public final class JavaStyleActions {
037:
038: /**
039: * Description of the Method
040: *
041: * @param view Description of Parameter
042: * @since 2.9.12
043: */
044: private static void openJRefactory(View view) {
045: view.getDockableWindowManager().showDockableWindow("javastyle");
046: Object pv = view.getDockableWindowManager().getDockable(
047: "javastyle");
048: ((org.acm.seguin.ide.jedit.JRefactory) pv)
049: .setVisible("JRefactory");
050: }
051:
052: /**
053: * Description of the Method
054: *
055: * @param view Description of Parameter
056: * @since 2.9.12
057: */
058: private static void openCodingStandards(View view) {
059: view.getDockableWindowManager().showDockableWindow("javastyle");
060: Object pv = view.getDockableWindowManager().getDockable(
061: "javastyle");
062: ((org.acm.seguin.ide.jedit.JRefactory) pv)
063: .setVisible("Coding standards");
064: }
065:
066: /**
067: * @param view the view; may be null, if there is no current view
068: * @param buffer the buffer containing the java source code
069: * @param silently if true, no error dialogs are shown
070: * @since v 1.0
071: */
072: public static void beautify(View view, Buffer buffer,
073: boolean silently) {
074: JavaStylePlugin.initJSPlugin();
075: JavaStylePlugin.jsPlugin.instanceBeautify(view, buffer,
076: silently);
077: }
078:
079: /**
080: * Description of the Method
081: *
082: * @param view Description of Parameter
083: * @since v 1.0
084: */
085: public static void optionDialog(View view) {
086: org.acm.seguin.ide.common.IDEPlugin
087: .setPlugin(new JavaStylePlugin());
088: new org.acm.seguin.ide.common.options.JSOptionDialog(view);
089: }
090:
091: /**
092: * check current buffer
093: *
094: * @param view Description of Parameter
095: * @param buffer Description of Parameter
096: * @since v 1.0
097: */
098: public static void check(View view, Buffer buffer) {
099: JavaStylePlugin.initJSPlugin();
100: openCodingStandards(view);
101: JavaStylePlugin.jsPlugin.instanceCheck(view, buffer, false);
102: }
103:
104: /**
105: * check current directory (of the File System Browser)
106: *
107: * @param view Description of Parameter
108: * @since v 1.0
109: */
110: public static void checkDirectory(View view) {
111: JavaStylePlugin.initJSPlugin();
112: openCodingStandards(view);
113: JavaStylePlugin.jsPlugin.instanceCheckDirectory(view, false);
114: }
115:
116: /**
117: * check all open buffers
118: *
119: * @param view Description of Parameter
120: * @since v 1.0
121: */
122: public static void checkAllOpenBuffers(View view) {
123: JavaStylePlugin.initJSPlugin();
124: openCodingStandards(view);
125: JavaStylePlugin.jsPlugin.instanceCheckAllOpenBuffers(view);
126: }
127:
128: /**
129: * check directory recursively
130: *
131: * @param view Description of Parameter
132: * @since v 1.0
133: */
134: public static void checkDirectoryRecursively(View view) {
135: JavaStylePlugin.initJSPlugin();
136: openCodingStandards(view);
137: JavaStylePlugin.jsPlugin.instanceCheckDirectory(view, true);
138: }
139:
140: /**
141: * clear error list
142: *
143: * @since v 1.0
144: */
145: public static void clearErrorList(View view) {
146: JavaStylePlugin.initJSPlugin();
147: openCodingStandards(view);
148: JavaStylePlugin.jsPlugin.instanceClearErrorList();
149: }
150:
151: /**
152: * @param view Description of the Parameter
153: * @since v 1.0
154: */
155: public static void loadUML(View view) {
156: JavaStylePlugin.initJSPlugin();
157: openJRefactory(view);
158: JavaStylePlugin.jsPlugin.loadUML(view, null);
159: }
160:
161: /**
162: * @param view Description of the Parameter
163: * @param file Description of Parameter
164: * @since v 1.0
165: */
166: public static void loadUML(View view, File file) {
167: try {
168: JavaStylePlugin.initJSPlugin();
169: openJRefactory(view);
170: JavaStylePlugin.jsPlugin.loadUML(view,
171: (file == null) ? null : file.getCanonicalPath());
172: } catch (IOException e) {
173: }
174: }
175:
176: /**
177: * @param view Description of the Parameter
178: * @param file Description of Parameter
179: * @since v 1.0
180: */
181: public static void loadUML(View view, String file) {
182: JavaStylePlugin.initJSPlugin();
183: openJRefactory(view);
184: JavaStylePlugin.jsPlugin.loadUML(view, file);
185: }
186:
187: /**
188: * @param view Description of the Parameter
189: * @param file Description of Parameter
190: * @since v 1.0
191: */
192: public static void openUML(View view, File file) {
193: try {
194: JavaStylePlugin.initJSPlugin();
195: openJRefactory(view);
196: JavaStylePlugin.jsPlugin.openUML(view, file
197: .getCanonicalPath());
198: } catch (IOException e) {
199: }
200: }
201:
202: /**
203: * @param view Description of the Parameter
204: * @param file Description of Parameter
205: * @since v 1.0
206: */
207: public static void openUML(View view, String file) {
208: JavaStylePlugin.initJSPlugin();
209: openJRefactory(view);
210: JavaStylePlugin.jsPlugin.openUML(view, file);
211: }
212:
213: /**
214: * @param view Description of the Parameter
215: * @since v 1.0
216: */
217: public static void openAllProjectFiles(View view) {
218: JRefactory viewer = JRefactory.getViewer(view);
219: openJRefactory(view);
220: }
221:
222: /**
223: * @param view Description of the Parameter
224: * @since v 1.0
225: */
226: public static void removeAllProjectFiles(View view) {
227: JRefactory viewer = JRefactory.getViewer(view);
228: openJRefactory(view);
229: }
230:
231: /**
232: * @param view Description of the Parameter
233: * @param buffer Description of Parameter
234: * @since v 1.0
235: */
236: public static void renameClass(View view, Buffer buffer) {
237: JavaStylePlugin.initJSPlugin();
238: JavaStylePlugin.jsPlugin.renameClass(view, buffer);
239: }
240:
241: /**
242: * @param view Description of the Parameter
243: * @param buffer Description of Parameter
244: * @since v 1.0
245: */
246: public static void moveClassTo(View view, Buffer buffer) {
247: JavaStylePlugin.initJSPlugin();
248: JavaStylePlugin.jsPlugin.moveClassTo(view, buffer);
249: }
250:
251: /**
252: * @param view Description of the Parameter
253: * @param buffer The feature to be added to the abstractParentClass attribute
254: * @since v 1.0
255: */
256: public static void addAbstractParentClass(View view, Buffer buffer) {
257: JavaStylePlugin.initJSPlugin();
258: JavaStylePlugin.jsPlugin.addAbstractParentClass(view, buffer);
259: }
260:
261: /**
262: * @param view Description of the Parameter
263: * @param buffer The feature to be added to the childClass attribute
264: * @since v 1.0
265: */
266: public static void addChildClass(View view, Buffer buffer) {
267: JavaStylePlugin.initJSPlugin();
268: JavaStylePlugin.jsPlugin.addChildClass(view, buffer);
269: }
270:
271: /**
272: * @param view Description of the Parameter
273: * @param buffer Description of Parameter
274: * @since v 1.0
275: */
276: public static void removeClass(View view, Buffer buffer) {
277: JavaStylePlugin.initJSPlugin();
278: JavaStylePlugin.jsPlugin.removeClass(view, buffer);
279: }
280:
281: /**
282: * @param view Description of the Parameter
283: * @param buffer Description of Parameter
284: * @since v 1.0
285: */
286: public static void extractInterface(View view, Buffer buffer) {
287: JavaStylePlugin.initJSPlugin();
288: JavaStylePlugin.jsPlugin.extractInterface(view, buffer);
289: }
290:
291: /**
292: * @param view Description of the Parameter
293: * @param buffer Description of Parameter
294: * @since v 1.0
295: */
296: public static void renameVariablesUsingHungarian(View view,
297: Buffer buffer) {
298: JavaStylePlugin.initJSPlugin();
299: JavaStylePlugin.jsPlugin.renameVariablesUsingHungarian(view,
300: buffer);
301: }
302:
303: /**
304: * @param view Description of the Parameter
305: * @param buffer Description of Parameter
306: * @since v 1.0
307: */
308: public static void renameMethod(View view, Buffer buffer) {
309: JavaStylePlugin.initJSPlugin();
310: JavaStylePlugin.jsPlugin.renameMethod(view, buffer);
311: }
312:
313: /**
314: * @param view Description of the Parameter
315: * @param buffer Description of Parameter
316: * @since v 1.0
317: */
318: public static void pushUpAbstractMethod(View view, Buffer buffer) {
319: JavaStylePlugin.initJSPlugin();
320: JavaStylePlugin.jsPlugin.pushUpAbstractMethod(view, buffer);
321: }
322:
323: /**
324: * @param view Description of the Parameter
325: * @param buffer Description of Parameter
326: * @since v 1.0
327: */
328: public static void pushDownMethod(View view, Buffer buffer) {
329: JavaStylePlugin.initJSPlugin();
330: JavaStylePlugin.jsPlugin.pushDownMethod(view, buffer);
331: }
332:
333: /**
334: * @param view Description of the Parameter
335: * @param buffer Description of Parameter
336: * @since v 1.0
337: */
338: public static void moveMethod(View view, Buffer buffer) {
339: JavaStylePlugin.initJSPlugin();
340: JavaStylePlugin.jsPlugin.moveMethod(view, buffer);
341: }
342:
343: /**
344: * @param view Description of the Parameter
345: * @param buffer Description of Parameter
346: * @since v 1.0
347: */
348: public static void renameMethodParameters(View view, Buffer buffer) {
349: JavaStylePlugin.initJSPlugin();
350: JavaStylePlugin.jsPlugin.renameMethodParameters(view, buffer);
351: }
352:
353: /**
354: * @param view Description of the Parameter
355: * @param buffer Description of Parameter
356: * @since v 1.0
357: */
358: public static void renameField(View view, Buffer buffer) {
359: JavaStylePlugin.initJSPlugin();
360: JavaStylePlugin.jsPlugin.renameField(view, buffer);
361: }
362:
363: /**
364: * @param view Description of the Parameter
365: * @param buffer Description of Parameter
366: * @since v 1.0
367: */
368: public static void pushUpField(View view, Buffer buffer) {
369: JavaStylePlugin.initJSPlugin();
370: JavaStylePlugin.jsPlugin.pushUpField(view, buffer);
371: }
372:
373: /**
374: * @param view Description of the Parameter
375: * @param buffer Description of Parameter
376: * @since v 1.0
377: */
378: public static void pushDownField(View view, Buffer buffer) {
379: JavaStylePlugin.initJSPlugin();
380: JavaStylePlugin.jsPlugin.pushDownField(view, buffer);
381: }
382:
383: }
|