001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Sam
028: */
029:
030: package com.caucho.netbeans;
031:
032: import org.netbeans.api.java.platform.JavaPlatform;
033: import org.netbeans.modules.j2ee.deployment.common.api.J2eeLibraryTypeProvider;
034: import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
035: import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformImpl;
036: import org.netbeans.spi.project.libraries.LibraryImplementation;
037: import org.openide.util.Utilities;
038:
039: import java.awt.*;
040: import java.io.File;
041: import java.util.ArrayList;
042: import java.util.LinkedHashSet;
043: import java.util.List;
044: import java.util.Set;
045: import java.util.logging.Logger;
046:
047: public class ResinPlatformImpl extends J2eePlatformImpl {
048: private static final Logger log = Logger
049: .getLogger(ResinPlatformImpl.class.getName());
050: private static final PluginL10N L = new PluginL10N(
051: ResinPlatformImpl.class);
052:
053: private static final Set<Object> SUPPORTED_MODULE_TYPES = new LinkedHashSet<Object>();
054:
055: private static final Set<String> SUPPORTED_SPEC_VERSIONS = new LinkedHashSet<String>();
056:
057: private static final Set<String> SUPPORTED_JAVA_PLATFORM_VERSIONS = new LinkedHashSet<String>();
058:
059: private String _displayName;
060: private ResinConfiguration _resinConfiguration;
061:
062: private final List<LibraryImplementation> _libraries = new ArrayList<LibraryImplementation>();
063:
064: ResinPlatformImpl(ResinDeploymentManager resinDeploymentManager) {
065: _resinConfiguration = resinDeploymentManager
066: .getResinConfiguration();
067: _displayName = _resinConfiguration.getDisplayName();
068:
069: J2eeLibraryTypeProvider libProvider = new J2eeLibraryTypeProvider();
070:
071: LibraryImplementation library = libProvider.createLibrary();
072:
073: library
074: .setName(L
075: .l("Resin J2EE Library for {0}", _displayName));
076:
077: initLibrary(library);
078:
079: _libraries.add(library);
080: }
081:
082: private void initLibrary(LibraryImplementation library) {
083: library.setContent(
084: J2eeLibraryTypeProvider.VOLUME_TYPE_CLASSPATH,
085: _resinConfiguration.getClasses());
086:
087: library.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_JAVADOC,
088: _resinConfiguration.getJavadocs());
089:
090: library.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_SRC,
091: _resinConfiguration.getSources());
092: }
093:
094: public void notifyLibrariesChanged() {
095: LibraryImplementation libraryImplementation = _libraries.get(0);
096:
097: initLibrary(libraryImplementation);
098:
099: firePropertyChange(PROP_LIBRARIES, null, _libraries);
100: }
101:
102: public LibraryImplementation[] getLibraries() {
103: return _libraries.toArray(new LibraryImplementation[_libraries
104: .size()]);
105: }
106:
107: public String getDisplayName() {
108: return _displayName;
109: }
110:
111: public Image getIcon() {
112: return Utilities
113: .loadImage("com/caucho/netbeans/resources/CauchoFLY_blu16.gif");
114: }
115:
116: public File[] getPlatformRoots() {
117: return new File[] { _resinConfiguration.getResinHome() };
118: }
119:
120: public File[] getToolClasspathEntries(String toolName) {
121: return new File[0];
122: }
123:
124: public boolean isToolSupported(String toolName) {
125: return false;
126: }
127:
128: public Set getSupportedModuleTypes() {
129: return SUPPORTED_MODULE_TYPES;
130: }
131:
132: public Set<String> getSupportedSpecVersions() {
133: return SUPPORTED_SPEC_VERSIONS;
134: }
135:
136: public Set<String> getSupportedJavaPlatformVersions() {
137: return SUPPORTED_JAVA_PLATFORM_VERSIONS;
138: }
139:
140: public JavaPlatform getJavaPlatform() {
141: return _resinConfiguration.getJavaPlatform();
142: }
143:
144: static {
145: SUPPORTED_MODULE_TYPES.add(J2eeModule.WAR);
146: SUPPORTED_MODULE_TYPES.add(J2eeModule.EAR);
147: SUPPORTED_MODULE_TYPES.add(J2eeModule.EJB);
148:
149: SUPPORTED_SPEC_VERSIONS.add(J2eeModule.J2EE_13);
150: SUPPORTED_SPEC_VERSIONS.add(J2eeModule.J2EE_14);
151: SUPPORTED_SPEC_VERSIONS.add(J2eeModule.JAVA_EE_5);
152:
153: SUPPORTED_JAVA_PLATFORM_VERSIONS.add("1.5");
154: SUPPORTED_JAVA_PLATFORM_VERSIONS.add("1.6");
155: }
156: }
|