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-2007 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.sql.framework.ui.view.graph;
042:
043: import java.awt.BorderLayout;
044: import java.awt.Component;
045:
046: import javax.swing.JPanel;
047:
048: import org.netbeans.modules.sql.framework.ui.event.SQLDataEvent;
049: import org.netbeans.modules.sql.framework.ui.event.SQLDataListener;
050: import org.netbeans.modules.sql.framework.ui.event.SQLLinkEvent;
051: import org.netbeans.modules.sql.framework.ui.graph.IGraphNode;
052: import org.netbeans.modules.sql.framework.ui.graph.IGraphView;
053: import org.netbeans.modules.sql.framework.ui.graph.IOperatorManager;
054:
055: import com.sun.sql.framework.exception.BaseException;
056:
057: /**
058: * @author Ritesh Adval
059: * @version $Revision$
060: */
061: public class SQLCollaborationView extends JPanel implements
062: SQLDataListener {
063:
064: private SQLGraphView graphView;
065: private IOperatorManager mgr;
066:
067: /** Creates a new instance of SQLCollaborationView */
068: public SQLCollaborationView(IOperatorManager opManager) {
069: super ();
070: this .mgr = opManager;
071: this .setLayout(new BorderLayout());
072: graphView = (SQLGraphView) opManager.getGraphView();
073: if (opManager.getOperatorView() != null) {
074: this .add((Component) opManager.getOperatorView(),
075: BorderLayout.NORTH);
076: }
077: if (opManager.getGraphView() != null) {
078: this .add((Component) opManager.getGraphView(),
079: BorderLayout.CENTER);
080: }
081: }
082:
083: public IOperatorManager getIOperatorManager() {
084: return this .mgr;
085: }
086:
087: public IGraphView getGraphView() {
088: return graphView;
089: }
090:
091: public IGraphNode findGraphNode(Object dataObj) {
092: return graphView.findGraphNode(dataObj);
093: }
094:
095: /**
096: * delete a graph node
097: *
098: * @param node graph node
099: */
100: public void deleteNode(IGraphNode node) {
101: graphView.deleteNode(node);
102: }
103:
104: public void setZoomFactor(double factor) {
105: graphView.setScale(factor);
106: }
107:
108: public double getZoomFactor() {
109: return graphView.getScale();
110: }
111:
112: public void linkCreated(SQLLinkEvent evt) {
113: graphView.linkCreated(evt);
114: }
115:
116: public void linkDeleted(SQLLinkEvent evt) {
117: graphView.linkDeleted(evt);
118: }
119:
120: public void objectCreated(SQLDataEvent evt) throws BaseException {
121: graphView.objectCreated(evt);
122: }
123:
124: public void objectDeleted(SQLDataEvent evt) {
125: graphView.objectDeleted(evt);
126: }
127:
128: @Override
129: public void requestFocus() {
130: super .requestFocus();
131: //This should have focus so that user can delete selected objects which
132: //we select when reload happens only one object is selected but
133: //without focus on graph view key event are not delegated to graph view
134: graphView.requestFocus();
135: }
136:
137: public void reset() {
138: graphView.reset();
139: }
140:
141: public void highlightInvalidNode(Object obj, boolean createSel) {
142: graphView.highlightInvalidNode(obj, createSel);
143: }
144:
145: public void childObjectCreated(SQLDataEvent evt) {
146: graphView.childObjectCreated(evt);
147: }
148:
149: public void childObjectDeleted(SQLDataEvent evt) {
150: graphView.childObjectDeleted(evt);
151: }
152:
153: public void objectUpdated(SQLDataEvent evt) {
154: graphView.objectUpdated(evt);
155: }
156:
157: /**
158: * This method is called after each undoable operation in order to refresh the
159: * presentation state of the undo/redo GUI
160: */
161:
162: public void refreshUndoRedo() {
163: //toolBar.refreshUndoRedo();
164: }
165: }
|