Source Code Cross Referenced for Activator.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » ui » ide » 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 » ESB » cbesb 1.2 » com.bostechcorp.cbesb.ui.ide 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ChainBuilder ESB
003:         *          Visual Enterprise Integration
004:         * 
005:         * Copyright (C) 2006 Bostech Corporation
006:         * 
007:         * This program is free software; you can redistribute it and/or modify it 
008:         * under the terms of the GNU General Public License as published by the 
009:         * Free Software Foundation; either version 2 of the License, or (at your option) 
010:         * any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful, 
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
014:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
015:         * for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License along with 
018:         * this program; if not, write to the Free Software Foundation, Inc., 
019:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020:         *
021:         *
022:         * $Id$
023:         */
024:
025:        package com.bostechcorp.cbesb.ui.ide;
026:
027:        import java.io.File;
028:        import java.io.FileNotFoundException;
029:        import java.io.FileOutputStream;
030:        import java.io.IOException;
031:        import java.net.URL;
032:
033:        import org.eclipse.core.resources.IResourceChangeEvent;
034:        import org.eclipse.core.resources.IResourceChangeListener;
035:        import org.eclipse.core.resources.IResourceDelta;
036:        import org.eclipse.core.resources.IResourceDeltaVisitor;
037:        import org.eclipse.core.resources.IWorkspace;
038:        import org.eclipse.core.resources.ResourcesPlugin;
039:        import org.eclipse.core.runtime.CoreException;
040:        import org.eclipse.core.runtime.IPath;
041:        import org.eclipse.core.runtime.IStatus;
042:        import org.eclipse.core.runtime.Path;
043:        import org.eclipse.core.runtime.Platform;
044:        import org.eclipse.core.runtime.Status;
045:        import org.eclipse.ui.plugin.AbstractUIPlugin;
046:        import org.osgi.framework.BundleContext;
047:
048:        import com.bostechcorp.cbesb.common.i18n.I18N;
049:        import com.bostechcorp.cbesb.common.i18n.Messages;
050:        import com.bostechcorp.cbesb.ui.ide.classpath.CBESBCoreClasspathContainer;
051:        import com.bostechcorp.cbesb.ui.ide.classpath.CBJBISAClasspathContainer;
052:        import com.bostechcorp.cbesb.ui.ide.classpath.ClassPathContainerRepository;
053:        import com.bostechcorp.cbesb.ui.util.tagged.mdl.TaggedMDLFileDocument;
054:        import com.bostechcorp.cbesb.ui.util.tagged.mdl.TaggedMDLFileParser;
055:
056:        public class Activator extends AbstractUIPlugin {
057:
058:            // The plug-in ID
059:            public static final String PLUGIN_ID = "com.bostechcorp.cbesb.ui.ide";
060:
061:            // The shared instance
062:            private static Activator plugin;
063:
064:            public static String projectName = null;
065:
066:            /**
067:             * The constructor
068:             */
069:            public Activator() {
070:                plugin = this ;
071:            }
072:
073:            /**
074:             * Remove the file from the tag.
075:             */
076:            public void removeFromTag(IPath path) {
077:                File file = new File(path.toString());
078:                /*if (file.isDirectory()) {
079:                	System.out.println("I got here folder!");
080:                	String[] children = file.list();
081:                	deleteDir(path);
082:                } else {*/
083:                if (path.toString().endsWith(".mdl")) {
084:                    String name = path.toString().substring(
085:                            path.toString().lastIndexOf("/") + 1,
086:                            path.toString().length());
087:                    deleteMdl(path, name);
088:                }
089:                //}
090:
091:            }
092:
093:            private void deleteDir(IPath filePath) {
094:                String filepath = filePath.toString();
095:                String xmlPath = null;
096:                String fileName = null;
097:                if (filepath.contains("/x12/")) {
098:                    xmlPath = filepath.substring(0, filepath.indexOf("/x12"))
099:                            + "/taggedMDL.xml";
100:                    fileName = filepath.substring(filepath.indexOf("x12/"),
101:                            filepath.length());
102:                    File taggedMDLFile = new File(xmlPath);
103:                    if (!taggedMDLFile.exists())
104:                        return;
105:
106:                    TaggedMDLFileParser parser = new TaggedMDLFileParser();
107:                    TaggedMDLFileDocument doc = parser.load(taggedMDLFile);
108:
109:                    for (int i = 0; i < doc.getMDLList().getAllMDLFile().length; i++) {
110:                        if (doc.getMDLList().getAllMDLFile()[i].getName()
111:                                .contains(fileName))
112:                            doc.getMDLList().removeSubproject(
113:                                    doc.getMDLList().getAllMDLFile()[i]
114:                                            .getName());
115:                        //					doc.getMDLList().getAllMDLFile()[i];
116:                    }
117:                    doc.getMDLList().removeSubproject(fileName);
118:                    try {
119:                        doc.serialize(new FileOutputStream(taggedMDLFile));
120:                    } catch (FileNotFoundException e) {
121:                        //TODO
122:                        //e.printStackTrace();
123:                    }
124:                }
125:
126:            }
127:
128:            private void deleteMdl(IPath path, String name) {
129:
130:                /* taggedMDL.xml */
131:                String filepath = path.toString();
132:                String xmlPath = null;
133:                String fileName = null;
134:                if (filepath.contains("/x12/")) {
135:                    xmlPath = filepath.substring(0, filepath.indexOf("/x12"))
136:                            + "/taggedMDL.xml";
137:                    fileName = filepath.substring(filepath.indexOf("x12/"),
138:                            filepath.length());
139:                } else if (filepath.contains("/hl7/")) {
140:                    xmlPath = filepath.substring(0, filepath.indexOf("/hl7"))
141:                            + "/taggedMDL.xml";
142:                    fileName = filepath.substring(filepath.indexOf("hl7/"),
143:                            filepath.length());
144:                } else {
145:                    xmlPath = filepath.substring(0, filepath.length()
146:                            - name.length())
147:                            + "taggedMDL.xml";
148:                    fileName = name;
149:                }
150:                File taggedMDLFile = new File(xmlPath);
151:                if (!taggedMDLFile.exists())
152:                    return;
153:                TaggedMDLFileParser parser = new TaggedMDLFileParser();
154:                TaggedMDLFileDocument doc = null;
155:                try {
156:                    doc = parser.load(taggedMDLFile);
157:
158:                    doc.getMDLList().removeSubproject(fileName);
159:                } catch (Exception e) {
160:                    //TODO
161:                }
162:                try {
163:                    doc.serialize(new FileOutputStream(taggedMDLFile));
164:                } catch (FileNotFoundException e) {
165:
166:                    e.printStackTrace();
167:                }
168:            }
169:
170:            /**
171:             * (non-Javadoc)
172:             * 
173:             * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
174:             */
175:            public void start(BundleContext context) throws Exception {
176:                super .start(context);
177:                IWorkspace workspace = ResourcesPlugin.getWorkspace();
178:
179:                IResourceChangeListener listener = new IResourceChangeListener() {
180:                    public void resourceChanged(IResourceChangeEvent event) {
181:                        try {
182:                            event.getDelta().accept(
183:                                    new IResourceDeltaVisitor() {
184:                                        public boolean visit(
185:                                                IResourceDelta delta)
186:                                                throws CoreException {
187:                                            switch (delta.getKind()) {
188:                                            case IResourceDelta.ADDED: {
189:
190:                                                break;
191:                                            }
192:                                            case IResourceDelta.REMOVED:
193:                                                // System.out.println("the extension is
194:                                                // "+delta.getFullPath());
195:                                                // System.out.println("the location is
196:                                                // "+delta.getResource().getLocation().toString());
197:                                                // System.out.println("the name is
198:                                                // "+delta.getResource().getName());
199:                                                Path path = new Path(delta
200:                                                        .getResource()
201:                                                        .getLocation()
202:                                                        .toString());
203:                                                removeFromTag(path);
204:                                                break;
205:                                            case IResourceDelta.CHANGED: {
206:
207:                                                break;
208:                                            }
209:                                            default:
210:                                                break;
211:                                            }
212:                                            return true;
213:                                        }
214:
215:                                    });
216:                        } catch (CoreException ex) {
217:                            //TODO
218:                        }
219:
220:                    }
221:                };
222:
223:                workspace.addResourceChangeListener(listener,
224:                        IResourceChangeEvent.PRE_CLOSE
225:                                | IResourceChangeEvent.PRE_DELETE
226:                                | IResourceChangeEvent.PRE_AUTO_BUILD
227:                                | IResourceChangeEvent.POST_AUTO_BUILD
228:                                | IResourceChangeEvent.POST_CHANGE);
229:                // workspace.addResourceChangeListener(listener);
230:                // ClassPathContainerRepository.getInstance().addClassPathEntry(J2EE14ClasspathContainer.CLASSPATH_CONTAINER);
231:                ClassPathContainerRepository.getInstance().addClassPathEntry(
232:                        CBESBCoreClasspathContainer.CLASSPATH_CONTAINER);
233:                ClassPathContainerRepository.getInstance().addClassPathEntry(
234:                        CBJBISAClasspathContainer.CLASSPATH_CONTAINER);
235:
236:            }
237:
238:            /*
239:             * (non-Javadoc)
240:             * 
241:             * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
242:             */
243:            public void stop(BundleContext context) throws Exception {
244:                plugin = null;
245:                super .stop(context);
246:            }
247:
248:            /**
249:             * Returns the shared instance
250:             * 
251:             * @return the shared instance
252:             */
253:            public static Activator getDefault() {
254:                return plugin;
255:            }
256:
257:            /**
258:             * Gets the base installation dir of the plugin
259:             * 
260:             * @return The installation dir
261:             */
262:            public String getBaseDir() {
263:                try {
264:                    URL installURL = Platform.asLocalURL(this .getBundle()
265:                            .getEntry("/"));//$NON-NLS-1$
266:                    return installURL.getFile().toString();
267:                } catch (IOException ioe) { // "Cannot compute base installation dir of
268:                    // plugin"
269:                    logError(I18N.getString(Messages.IDE_ERR_CANNOT_INSTALL),
270:                            ioe);//$NON-NLS-1$
271:                }
272:                return null;
273:            }
274:
275:            /********************************************
276:             */
277:
278:            /**
279:             * Logs the specified status with this plug-in's log.
280:             * 
281:             * @param status
282:             *            status to log
283:             */
284:            public static void log(IStatus status) {
285:                getDefault().getLog().log(status);
286:            }
287:
288:            /**
289:             * Logs an internal error with the specified throwable
290:             * 
291:             * @param e
292:             *            the exception to be logged
293:             */
294:            public static void log(Throwable e) {
295:                log(new Status(IStatus.ERROR, getUniqueIdentifier(), 0,
296:                        "Internal Error", e));//$NON-NLS-1$
297:            }
298:
299:            /**
300:             * Logs an internal error with the specified message.
301:             * 
302:             * @param message
303:             *            the error message to log
304:             */
305:            public static void logError(String message) {
306:                logError(message, null);
307:            }
308:
309:            /**
310:             * Logs a throwable with the specified message.
311:             * 
312:             * @param message
313:             *            Message to log
314:             * @param throwable
315:             *            Throwable to log
316:             */
317:            public static void logError(String message, Throwable throwable) {
318:                log(new Status(IStatus.ERROR, getUniqueIdentifier(), 0,
319:                        message, throwable));
320:            }
321:
322:            /**
323:             * Convenience method which returns the unique identifier of this plugin.
324:             * 
325:             * @return The unique indentifier value
326:             */
327:            public static String getUniqueIdentifier() {
328:                if (getDefault() == null) {
329:                    // If the default instance is not yet initialized,
330:                    // return a static identifier. This identifier must
331:                    // match the plugin id defined in plugin.xml
332:                    return "org.jboss.ide.eclipse.core";//$NON-NLS-1$
333:                }
334:                return getDefault().getBundle().getSymbolicName();
335:            }
336:
337:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.