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: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.collab.ui;
042:
043: import org.openide.cookies.OpenCookie;
044: import org.openide.nodes.*;
045: import org.openide.util.*;
046: import org.openide.windows.*;
047:
048: import com.sun.collablet.Conversation;
049:
050: /**
051: *
052: * @author todd
053: */
054: public class ConversationOpenSupport extends CloneableOpenSupport
055: implements OpenCookie {
056: ////////////////////////////////////////////////////////////////////////////
057: // Instance variables
058: ////////////////////////////////////////////////////////////////////////////
059: private Node node;
060: private Conversation conversation;
061: private ConversationComponent component;
062:
063: /**
064: * Creates an instance with a default Env
065: *
066: */
067: public ConversationOpenSupport(Node node, Conversation conversation) {
068: this (node, conversation, new ConversationOpenSupportEnv(
069: conversation));
070:
071: // Register this instance with the Env
072: ((ConversationOpenSupportEnv) env)
073: .registerCloneableOpenSupport(this );
074: }
075:
076: /**
077: * Creates an instance with the specified Env. The Env must be implemented
078: * to return this instance from its <code>findCloneableOpenSupport()</code>
079: * method.
080: *
081: */
082: protected ConversationOpenSupport(Node node,
083: Conversation conversation, CloneableOpenSupport.Env env) {
084: super (env);
085: this .node = node;
086: this .conversation = conversation;
087: }
088:
089: /**
090: *
091: *
092: */
093: public Node getNode() {
094: return node;
095: }
096:
097: /**
098: *
099: *
100: */
101: public Conversation getConversation() {
102: return conversation;
103: }
104:
105: /**
106: *
107: *
108: */
109: public void open() {
110: if (conversation.isValid() && (component != null)) {
111: // Reset the component's reference, which was unset when
112: // the component was closed
113: component.setReference(allEditors);
114:
115: // This code was effectively copied from CloneableOpenSupport
116: // Bugfix #10688 open() is now run in AWT thread
117: Mutex.EVENT.writeAccess(new Runnable() {
118: public void run() {
119: // Open it and request active
120: component.open();
121: component.requestActive();
122: }
123: });
124: } else {
125: component = null;
126: super .open();
127: }
128: }
129:
130: /**
131: *
132: *
133: */
134: protected CloneableTopComponent createCloneableTopComponent() {
135: // // join public conversation and initialize channel again
136: // if (getConversation().isPublic() &&
137: // (!getConversation().isValid() ||
138: // getConversation().getChannels().length ==0))
139: // {
140: // try {
141: // conversation.join();
142: // }catch (CollabException e)
143: // {
144: // Debug.errorManager.notify(e);
145: // }
146: // }
147: component = new ConversationComponent(getNode(),
148: getConversation());
149:
150: return component;
151: }
152:
153: /**
154: *
155: *
156: */
157: protected String messageOpened() {
158: return "";
159: }
160:
161: /**
162: *
163: *
164: */
165: protected String messageOpening() {
166: return "";
167: }
168: }
|