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.nodes;
031:
032: import com.caucho.netbeans.nodes.actions.ContainerRefreshAction;
033:
034: import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport;
035: import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport.ServerIcon;
036: import org.openide.nodes.AbstractNode;
037: import org.openide.util.Lookup;
038: import org.openide.util.NbBundle;
039: import org.openide.util.actions.SystemAction;
040:
041: import javax.enterprise.deploy.shared.ModuleType;
042: import java.awt.*;
043: import org.openide.util.lookup.Lookups;
044:
045: /**
046: * Node that represents a container, holder of J2EE modules of the same type
047: */
048: public final class ResinModuleContainerNode extends AbstractNode {
049: private ModuleType _moduleType;
050:
051: /**
052: * Creates a new instance of ResinModuleContainerNode
053: */
054: public ResinModuleContainerNode(Lookup lookup, ModuleType moduleType) {
055: this (new ResinModuleChildren(lookup, moduleType));
056:
057: _moduleType = moduleType;
058: }
059:
060: private ResinModuleContainerNode(
061: ResinModuleChildren resinWebModuleChildren) {
062: super (resinWebModuleChildren);
063:
064: getCookieSet().add(resinWebModuleChildren);
065: }
066:
067: public Image getIcon(int type) {
068: if (ModuleType.WAR.equals(_moduleType)) {
069: return UISupport.getIcon(ServerIcon.WAR_FOLDER);
070: } else if (ModuleType.EJB.equals(_moduleType)) {
071: return UISupport.getIcon(ServerIcon.EJB_FOLDER);
072: } else {
073: return UISupport.getIcon(ServerIcon.EAR_FOLDER);
074: }
075: }
076:
077: public Image getOpenedIcon(int type) {
078: if (ModuleType.WAR.equals(_moduleType)) {
079: return UISupport.getIcon(ServerIcon.WAR_OPENED_FOLDER);
080: } else if (ModuleType.EJB.equals(_moduleType)) {
081: return UISupport.getIcon(ServerIcon.EJB_OPENED_FOLDER);
082: } else {
083: return UISupport.getIcon(ServerIcon.EAR_OPENED_FOLDER);
084: }
085: }
086:
087: public String getDisplayName() {
088: if (ModuleType.WAR.equals(_moduleType)) {
089: return NbBundle.getMessage(ResinModuleContainerNode.class,
090: "LBL_WebContainer");
091: } else if (ModuleType.EJB.equals(_moduleType)) {
092: return NbBundle.getMessage(ResinModuleContainerNode.class,
093: "LBL_EJBContainer");
094: } else {
095: return NbBundle.getMessage(ResinModuleContainerNode.class,
096: "LBL_EARContainer");
097: }
098: }
099:
100: public javax.swing.Action[] getActions(boolean context) {
101: return new SystemAction[] { SystemAction
102: .get(ContainerRefreshAction.class) };
103: }
104: }
|