001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * If you wish your version of this file to be governed by only the CDDL
025: * or only the GPL Version 2, indicate your decision by adding
026: * "[Contributor] elects to include this software in this distribution
027: * under the [CDDL or GPL Version 2] license." If you do not indicate a
028: * single choice of license, a recipient has the option to distribute
029: * your version of this file under either the CDDL, the GPL Version 2 or
030: * to extend the choice of license to its licensees as provided above.
031: * However, if you add GPL Version 2 code and therefore, elected the GPL
032: * Version 2 license, then the option applies only if the new code is
033: * made subject to such option by the copyright holder.
034: *
035: * Contributor(s):
036: *
037: * Portions Copyrighted 2008 Sun Microsystems, Inc.
038: */
039:
040: package org.netbeans.api.server;
041:
042: import javax.swing.JComponent;
043: import org.netbeans.spi.server.ServerInstanceFactory;
044: import org.netbeans.spi.server.ServerInstanceImplementation;
045: import org.openide.nodes.Node;
046:
047: /**
048: * The API representation of the single server instance. Class describes
049: * the instance and provides needed operations.
050: * <p>
051: * Currently this class is not reachable through API methods. This can change
052: * in future if we'll need to provide API in common server.
053: *
054: * @author Petr Hejl
055: */
056: public final class ServerInstance {
057:
058: static {
059: ServerInstanceFactory.Accessor.DEFAULT = new ServerInstanceFactory.Accessor() {
060:
061: @Override
062: public ServerInstance createServerInstance(
063: ServerInstanceImplementation impl) {
064: return new ServerInstance(impl);
065: }
066: };
067: }
068:
069: private final ServerInstanceImplementation delegate;
070:
071: private ServerInstance(ServerInstanceImplementation delegate) {
072: this .delegate = delegate;
073: }
074:
075: /**
076: * Returns the display name of the instance.
077: *
078: * @return the display name of the instance
079: */
080: public String getDisplayName() {
081: return delegate.getDisplayName();
082: }
083:
084: /**
085: * Returns the display name of the server type to which this instance belongs.
086: *
087: * @return the display name of the server type to which this instance belongs
088: */
089: public String getServerDisplayName() {
090: return delegate.getServerDisplayName();
091: }
092:
093: /**
094: * Returns the node representing the runtime instance. The node should
095: * display instance status and provide actions to manage the server.
096: *
097: * @return the node representing the instance, may return <code>null</code>
098: */
099: public Node getFullNode() {
100: return delegate.getFullNode();
101: }
102:
103: /**
104: * Returns the node representing the instance while configuring it.
105: * The node should not display any status, actions or children.
106: *
107: * @return the node representing the instance, may return <code>null</code>
108: */
109: public Node getBasicNode() {
110: return delegate.getBasicNode();
111: }
112:
113: /**
114: * Returns the component allowing the customization of the instance. May
115: * return <code>null</code>.
116: * <p>
117: * Always called from Event Dispatch Thread.
118: *
119: * @return the component allowing the customization of the instance,
120: * may return <code>null</code>
121: */
122: public JComponent getCustomizer() {
123: return delegate.getCustomizer();
124: }
125:
126: /**
127: * Removes the instance. No {@link org.netbeans.spi.server.ServerInstanceProvider}
128: * should return this instance once it is removed.
129: */
130: public void remove() {
131: delegate.remove();
132: }
133:
134: /**
135: * Returns <code>true</code> if the instance can be removed by
136: * {@link #remove()}. Otherwise returns <code>false</code>.
137: *
138: * @return <code>true</code> if the instance can be removed
139: */
140: public boolean isRemovable() {
141: return delegate.isRemovable();
142: }
143:
144: }
|