KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > antlr > works > plugin > intellij > PIApplicationComponent


1 package org.antlr.works.plugin.intellij;
2
3 import com.intellij.openapi.actionSystem.ActionManager;
4 import com.intellij.openapi.actionSystem.Anchor;
5 import com.intellij.openapi.actionSystem.Constraints;
6 import com.intellij.openapi.actionSystem.DefaultActionGroup;
7 import com.intellij.openapi.components.ApplicationComponent;
8 import com.intellij.openapi.fileTypes.FileTypeManager;
9 import com.intellij.openapi.options.Configurable;
10 import com.intellij.openapi.options.ConfigurationException;
11 import org.antlr.works.IDE;
12 import org.antlr.works.plugin.container.PCXJApplicationDelegate;
13 import org.antlr.works.plugin.container.PCXJApplicationInterface;
14 import org.antlr.works.prefs.AWPrefsDialog;
15 import org.antlr.works.utils.IconManager;
16 import org.antlr.xjlib.appkit.app.XJApplication;
17
18 import javax.swing.*;
19
20 /*
21
22 [The "BSD licence"]
23 Copyright (c) 2005-2006 Jean Bovet
24 All rights reserved.
25
26 Redistribution and use in source and binary forms, with or without
27 modification, are permitted provided that the following conditions
28 are met:
29
30 1. Redistributions of source code must retain the above copyright
31 notice, this list of conditions and the following disclaimer.
32 2. Redistributions in binary form must reproduce the above copyright
33 notice, this list of conditions and the following disclaimer in the
34 documentation and/or other materials provided with the distribution.
35 3. The name of the author may not be used to endorse or promote products
36 derived from this software without specific prior written permission.
37
38 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
39 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
41 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
42 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
43 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
45 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
47 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48
49 */

50
51 public class PIApplicationComponent implements ApplicationComponent, Configurable {
52
53     private AWPrefsDialog prefsDialog;
54
55     public PIApplicationComponent() {
56         IDE._isPlugin = true;
57     }
58
59     public void initComponent() {
60         XJApplication.setDelegate(new PCXJApplicationDelegate());
61         XJApplication.setPropertiesPath(IDE.PROPERTIES_PATH);
62         XJApplication.setShared(new PCXJApplicationInterface(null));
63
64         FileTypeManager.getInstance().registerFileType(new PIFileType(), new String JavaDoc[] { "g" });
65
66         PIActionNewFile action = new PIActionNewFile();
67         ActionManager.getInstance().registerAction("NewGrammarFile", action);
68         DefaultActionGroup group = (DefaultActionGroup) ActionManager.getInstance().getAction("NewGroup");
69         group.add(action, new Constraints(Anchor.AFTER, "NewFile"));
70     }
71
72     public void disposeComponent() {
73     }
74
75     public String JavaDoc getComponentName() {
76         return "AWApplicationComponent";
77     }
78
79     // ********* Configurable *************
80

81     public String JavaDoc getDisplayName() {
82         return "ANTLRWorks";
83     }
84
85     public Icon getIcon() {
86         return IconManager.shared().getIconApplication32x32();
87     }
88
89     public String JavaDoc getHelpTopic() {
90         return null;
91     }
92
93     public JComponent createComponent() {
94         prefsDialog = new AWPrefsDialog();
95         prefsDialog.becomingVisibleForTheFirstTime();
96         return prefsDialog.getComponent();
97     }
98
99     public boolean isModified() {
100         return true;
101     }
102
103     public void apply() throws ConfigurationException {
104         prefsDialog.apply();
105     }
106
107     public void reset() {
108     }
109
110     public void disposeUIResources() {
111         prefsDialog.close();
112         prefsDialog = null;
113     }
114 }
115
Popular Tags