Source Code Cross Referenced for PluginManager.java in  » Swing-Library » jEdit » org » gjt » sp » jedit » pluginmgr » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » jEdit » org.gjt.sp.jedit.pluginmgr 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * PluginManager.java - Plugin manager window
003:         * :tabSize=8:indentSize=8:noTabs=false:
004:         * :folding=explicit:collapseFolds=1:
005:         *
006:         * Copyright (C) 2002 Kris Kopicki
007:         *
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or any later version.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         */
022:
023:        package org.gjt.sp.jedit.pluginmgr;
024:
025:        //{{{ Imports
026:        import javax.swing.border.*;
027:        import javax.swing.event.*;
028:        import javax.swing.*;
029:        import java.awt.event.*;
030:        import java.awt.*;
031:        import org.xml.sax.SAXParseException;
032:        import org.gjt.sp.jedit.io.VFSManager;
033:        import org.gjt.sp.jedit.msg.*;
034:        import org.gjt.sp.jedit.options.*;
035:        import org.gjt.sp.jedit.*;
036:        import org.gjt.sp.util.Log;
037:        import org.gjt.sp.util.WorkRequest;
038:
039:        //}}}
040:
041:        /**
042:         * @version $Id: PluginManager.java 9956 2007-07-08 04:21:25Z ezust $
043:         */
044:        public class PluginManager extends JFrame implements  EBComponent {
045:
046:            //{{{ getInstance() method
047:            /**
048:             * Returns the currently visible plugin manager window, or null.
049:             * @since jEdit 4.2pre2
050:             */
051:            public static PluginManager getInstance() {
052:                return instance;
053:            } //}}}
054:
055:            //{{{ dispose() method
056:            public void dispose() {
057:                instance = null;
058:                EditBus.removeFromBus(this );
059:                EditBus.removeFromBus(installer);
060:                super .dispose();
061:            } //}}}
062:
063:            //{{{ handleMessage() method
064:            public void handleMessage(EBMessage message) {
065:                if (message instanceof  PropertiesChanged) {
066:                    if (shouldUpdatePluginList()) {
067:                        pluginList = null;
068:                        updatePluginList();
069:                        if (tabPane.getSelectedIndex() != 0) {
070:                            installer.updateModel();
071:                            updater.updateModel();
072:                        }
073:                    }
074:                } else if (message instanceof  PluginUpdate) {
075:                    if (!queuedUpdate) {
076:                        SwingUtilities.invokeLater(new Runnable() {
077:                            public void run() {
078:                                queuedUpdate = false;
079:                                manager.update();
080:                            }
081:                        });
082:                        queuedUpdate = true;
083:                    }
084:                }
085:            } //}}}
086:
087:            //{{{ showPluginManager() method
088:            public static void showPluginManager(Frame parent) {
089:                if (instance == null)
090:                    instance = new PluginManager(parent);
091:                else
092:                    instance.toFront();
093:            } //}}}
094:
095:            //{{{ ok() method
096:            public void ok() {
097:                dispose();
098:            } //}}}
099:
100:            //{{{ cancel() method
101:            public void cancel() {
102:                dispose();
103:            } //}}}
104:
105:            //{{{ getPluginList() method
106:            PluginList getPluginList() {
107:                return pluginList;
108:            } //}}}
109:
110:            //{{{ Private members
111:            private static PluginManager instance;
112:
113:            //{{{ Instance variables
114:            private JTabbedPane tabPane;
115:            private JButton done;
116:            private JButton mgrOptions;
117:            private JButton pluginOptions;
118:            private InstallPanel installer;
119:            private InstallPanel updater;
120:            private ManagePanel manager;
121:            private PluginList pluginList;
122:            private boolean queuedUpdate;
123:            private boolean downloadingPluginList;
124:            private final Frame parent;
125:            //}}}
126:
127:            static public final String PROPERTY_PLUGINSET = "plugin-manager.pluginset.path";
128:
129:            //{{{ PluginManager constructor
130:            private PluginManager(Frame parent) {
131:                super (jEdit.getProperty("plugin-manager.title"));
132:                this .parent = parent;
133:                init();
134:            } //}}}
135:
136:            //{{{ init() method
137:            private void init() {
138:                EditBus.addToBus(this );
139:
140:                /* Setup panes */
141:                JPanel content = new JPanel(new BorderLayout(12, 12));
142:                content.setBorder(new EmptyBorder(12, 12, 12, 12));
143:                setContentPane(content);
144:
145:                tabPane = new JTabbedPane();
146:                tabPane.addTab(jEdit.getProperty("manage-plugins.title"),
147:                        manager = new ManagePanel(this ));
148:                tabPane.addTab(jEdit.getProperty("update-plugins.title"),
149:                        updater = new InstallPanel(this , true));
150:                tabPane.addTab(jEdit.getProperty("install-plugins.title"),
151:                        installer = new InstallPanel(this , false));
152:                EditBus.addToBus(installer);
153:                content.add(BorderLayout.CENTER, tabPane);
154:
155:                tabPane.addChangeListener(new ListUpdater());
156:
157:                /* Create the buttons */
158:                Box buttons = new Box(BoxLayout.X_AXIS);
159:
160:                ActionListener al = new ActionHandler();
161:                mgrOptions = new JButton(jEdit
162:                        .getProperty("plugin-manager.mgr-options"));
163:                mgrOptions.addActionListener(al);
164:                pluginOptions = new JButton(jEdit
165:                        .getProperty("plugin-manager.plugin-options"));
166:                pluginOptions.addActionListener(al);
167:                done = new JButton(jEdit.getProperty("plugin-manager.done"));
168:                done.addActionListener(al);
169:
170:                buttons.add(Box.createGlue());
171:                buttons.add(mgrOptions);
172:                buttons.add(Box.createHorizontalStrut(6));
173:                buttons.add(pluginOptions);
174:                buttons.add(Box.createHorizontalStrut(6));
175:                buttons.add(done);
176:                buttons.add(Box.createGlue());
177:
178:                getRootPane().setDefaultButton(done);
179:
180:                content.add(BorderLayout.SOUTH, buttons);
181:
182:                setDefaultCloseOperation(DISPOSE_ON_CLOSE);
183:
184:                setIconImage(GUIUtilities.getPluginIcon());
185:
186:                pack();
187:                GUIUtilities.loadGeometry(this , parent, "plugin-manager");
188:                GUIUtilities.addSizeSaver(this , parent, "plugin-manager");
189:                setVisible(true);
190:            } //}}}
191:
192:            //{{{ shouldUpdatePluginList()
193:            /**
194:             * Check if the plugin list should be updated.
195:             * It will return <code>true</code> if the pluginList is <code>null</code>
196:             * or if the mirror id of the current plugin list is not the current preffered mirror id
197:             * and will return always false if the plugin list is currently downloading
198:             *
199:             * @return true if the plugin list should be updated
200:             */
201:            private boolean shouldUpdatePluginList() {
202:                return (pluginList == null || !pluginList.getMirrorId().equals(
203:                        jEdit.getProperty("plugin-manager.mirror.id")))
204:                        && !downloadingPluginList;
205:            } //}}}
206:
207:            //{{{ updatePluginList() method
208:            private void updatePluginList() {
209:                if (jEdit.getSettingsDirectory() == null
210:                        && jEdit.getJEditHome() == null) {
211:                    GUIUtilities.error(this , "no-settings", null);
212:                    return;
213:                }
214:                if (!shouldUpdatePluginList()) {
215:                    return;
216:                }
217:
218:                final Exception[] exception = new Exception[1];
219:
220:                VFSManager.runInWorkThread(new WorkRequest() {
221:                    public void run() {
222:                        try {
223:                            downloadingPluginList = true;
224:                            setStatus(jEdit
225:                                    .getProperty("plugin-manager.list-download-connect"));
226:                            pluginList = new PluginList(this );
227:                        } catch (Exception e) {
228:                            exception[0] = e;
229:                        } finally {
230:                            downloadingPluginList = false;
231:                        }
232:                    }
233:                });
234:
235:                VFSManager.runInAWTThread(new Runnable() {
236:                    public void run() {
237:                        if (exception[0] instanceof  SAXParseException) {
238:                            SAXParseException se = (SAXParseException) exception[0];
239:
240:                            int line = se.getLineNumber();
241:                            String path = jEdit
242:                                    .getProperty("plugin-manager.export-url");
243:                            String message = se.getMessage();
244:                            Log.log(Log.ERROR, this , path + ':' + line + ": "
245:                                    + message);
246:                            String[] pp = { path, String.valueOf(line), message };
247:                            GUIUtilities.error(PluginManager.this ,
248:                                    "plugin-list.xmlerror", pp);
249:                        } else if (exception[0] != null) {
250:                            Exception e = exception[0];
251:
252:                            Log.log(Log.ERROR, this , e);
253:                            String[] pp = { e.toString() };
254:
255:                            String ok = jEdit.getProperty("common.ok");
256:                            String proxyButton = jEdit
257:                                    .getProperty("plugin-list.ioerror.proxy-servers");
258:                            int retVal = JOptionPane
259:                                    .showOptionDialog(
260:                                            PluginManager.this ,
261:                                            jEdit
262:                                                    .getProperty(
263:                                                            "plugin-list.ioerror.message",
264:                                                            pp),
265:                                            jEdit
266:                                                    .getProperty("plugin-list.ioerror.title"),
267:                                            JOptionPane.YES_NO_OPTION,
268:                                            JOptionPane.ERROR_MESSAGE, null,
269:                                            new Object[] { proxyButton, ok },
270:                                            ok);
271:
272:                            if (retVal == 0) {
273:                                new GlobalOptions(PluginManager.this ,
274:                                        "firewall");
275:                            }
276:                        }
277:                    }
278:                });
279:            } //}}}
280:
281:            //{{{ processKeyEvent() method
282:            public void processKeyEvents(KeyEvent ke) {
283:                if ((ke.getID() == KeyEvent.KEY_PRESSED)
284:                        && (ke.getKeyCode() == KeyEvent.VK_ESCAPE)) {
285:                    cancel();
286:                    ke.consume();
287:                }
288:            } //}}}
289:
290:            //}}}
291:
292:            //{{{ Inner classes
293:
294:            //{{{ ActionHandler class
295:            class ActionHandler implements  ActionListener {
296:                public void actionPerformed(ActionEvent evt) {
297:                    Object source = evt.getSource();
298:                    if (source == done)
299:                        ok();
300:                    else if (source == mgrOptions)
301:                        new GlobalOptions(PluginManager.this , "plugin-manager");
302:                    else if (source == pluginOptions)
303:                        new PluginOptions(PluginManager.this );
304:                }
305:            } //}}}
306:
307:            //{{{ ListUpdater class
308:            class ListUpdater implements  ChangeListener {
309:                public void stateChanged(ChangeEvent e) {
310:                    Component selected = tabPane.getSelectedComponent();
311:                    if (selected == installer || selected == updater) {
312:                        updatePluginList();
313:                        installer.updateModel();
314:                        updater.updateModel();
315:                    } else if (selected == manager)
316:                        manager.update();
317:                }
318:            } //}}}
319:
320:            //}}}
321:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.