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.vmd.flow;
042:
043: import org.netbeans.modules.vmd.api.io.DataEditorView;
044: import org.netbeans.modules.vmd.api.io.DataObjectContext;
045: import org.openide.awt.UndoRedo;
046: import org.openide.util.HelpCtx;
047: import org.openide.util.NbBundle;
048:
049: import javax.swing.*;
050: import java.io.IOException;
051: import java.util.Collection;
052: import java.util.Collections;
053:
054: /**
055: * @author David Kaspar
056: */
057: public class FlowEditorView implements DataEditorView {
058:
059: private static final long serialVersionUID = -1;
060:
061: private DataObjectContext context;
062: private transient FlowViewController controller;
063:
064: public FlowEditorView(DataObjectContext context) {
065: this .context = context;
066: init();
067: }
068:
069: private void init() {
070: controller = new FlowViewController(context);
071: }
072:
073: public DataObjectContext getContext() {
074: return context;
075: }
076:
077: public Kind getKind() {
078: return Kind.MODEL;
079: }
080:
081: public boolean canShowSideWindows() {
082: return true;
083: }
084:
085: public Collection<String> getTags() {
086: return Collections.emptySet();
087: }
088:
089: public String preferredID() {
090: return FlowViewController.FLOW_ID;
091: }
092:
093: public String getDisplayName() {
094: return NbBundle.getMessage(FlowEditorView.class,
095: "DISP_FlowView"); // NOI18N
096: }
097:
098: public HelpCtx getHelpCtx() {
099: return new HelpCtx(FlowEditorView.class);
100: }
101:
102: public JComponent getVisualRepresentation() {
103: return controller.getVisualRepresentation();
104: }
105:
106: public JComponent getToolbarRepresentation() {
107: return controller.getToolbarRepresentation();
108: }
109:
110: public UndoRedo getUndoRedo() {
111: return null;
112: }
113:
114: public void componentOpened() {
115: }
116:
117: public void componentClosed() {
118: }
119:
120: public void componentShowing() {
121: }
122:
123: public void componentHidden() {
124: }
125:
126: public void componentActivated() {
127: }
128:
129: public void componentDeactivated() {
130: }
131:
132: public int getOpenPriority() {
133: return getOrder();
134: }
135:
136: public int getEditPriority() {
137: return -getOrder();
138: }
139:
140: public int getOrder() {
141: return 2000;
142: }
143:
144: private void writeObject(java.io.ObjectOutputStream out)
145: throws IOException {
146: out.writeObject(context);
147: }
148:
149: private void readObject(java.io.ObjectInputStream in)
150: throws IOException, ClassNotFoundException {
151: Object object = in.readObject();
152: if (!(object instanceof DataObjectContext))
153: throw new ClassNotFoundException(
154: "DataObjectContext expected but not found"); // NOI18N
155: context = (DataObjectContext) object;
156: init();
157: }
158:
159: }
|