1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/iep.editor/nbproject/project.properties Fri Jul 20 23:27:49 2007 +0000
1.3 @@ -0,0 +1,2 @@
1.4 +javac.compilerargs=-Xlint -Xlint:-serial
1.5 +javac.source=1.5
2.1 --- a/iep.editor/nbproject/project.xml Fri Jul 20 23:05:01 2007 +0000
2.2 +++ b/iep.editor/nbproject/project.xml Fri Jul 20 23:27:49 2007 +0000
2.3 @@ -1,5 +1,4 @@
2.4 <?xml version="1.0" encoding="UTF-8"?>
2.5 -
2.6 <!--
2.7 The contents of this file are subject to the terms of the Common Development
2.8 and Distribution License (the License). You may not use this file except in
2.9 @@ -18,7 +17,6 @@
2.10 Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
2.11 Microsystems, Inc. All Rights Reserved.
2.12 -->
2.13 -
2.14 <project xmlns="http://www.netbeans.org/ns/project/1">
2.15 <type>org.netbeans.modules.apisupport.project</type>
2.16 <configuration>
2.17 @@ -26,6 +24,15 @@
2.18 <code-name-base>org.netbeans.modules.iep.editor</code-name-base>
2.19 <module-dependencies>
2.20 <dependency>
2.21 + <code-name-base>org.netbeans.core.multiview</code-name-base>
2.22 + <build-prerequisite/>
2.23 + <compile-dependency/>
2.24 + <run-dependency>
2.25 + <release-version>1</release-version>
2.26 + <specification-version>1.9</specification-version>
2.27 + </run-dependency>
2.28 + </dependency>
2.29 + <dependency>
2.30 <code-name-base>org.netbeans.spi.palette</code-name-base>
2.31 <build-prerequisite/>
2.32 <compile-dependency/>
3.1 --- a/iep.editor/src/org/netbeans/modules/iep/editor/PlanDataLoader.java Fri Jul 20 23:05:01 2007 +0000
3.2 +++ b/iep.editor/src/org/netbeans/modules/iep/editor/PlanDataLoader.java Fri Jul 20 23:27:49 2007 +0000
3.3 @@ -48,6 +48,8 @@
3.4 */
3.5 public static final String PLAN_EXTENSION = "iep";
3.6
3.7 + public static final String MIME_TYPE = "text/x-iep+xml"; // NOI18N
3.8 +
3.9 private static final long serialVersionUID = -4579746482156152493L;
3.10
3.11 public PlanDataLoader() {
4.1 --- a/iep.editor/src/org/netbeans/modules/iep/editor/PlanDataObject.java Fri Jul 20 23:05:01 2007 +0000
4.2 +++ b/iep.editor/src/org/netbeans/modules/iep/editor/PlanDataObject.java Fri Jul 20 23:27:49 2007 +0000
4.3 @@ -59,5 +59,13 @@
4.4 getCookieSet().remove(cookie);
4.5 }
4.6
4.7 + public PlanEditorSupport getPlanEditorSupport() {
4.8 + return editorSupport;
4.9 + }
4.10 +
4.11 + private transient PlanEditorSupport editorSupport;
4.12 +
4.13 + public static final String IEP_ICON_BASE_WITH_EXT = "org/netbeans/modules/iep/editor/eventProcess.png";
4.14 +
4.15 private static final long serialVersionUID = 6338889116068357651L;
4.16 }
4.17 \ No newline at end of file
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/iep.editor/src/org/netbeans/modules/iep/editor/PlanDesignViewMultiViewDesc.java Fri Jul 20 23:27:49 2007 +0000
5.3 @@ -0,0 +1,138 @@
5.4 +/*
5.5 + * The contents of this file are subject to the terms of the Common Development
5.6 + * and Distribution License (the License). You may not use this file except in
5.7 + * compliance with the License.
5.8 + *
5.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
5.10 + * or http://www.netbeans.org/cddl.txt.
5.11 + *
5.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
5.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
5.14 + * If applicable, add the following below the CDDL Header, with the fields
5.15 + * enclosed by brackets [] replaced by your own identifying information:
5.16 + * "Portions Copyrighted [year] [name of copyright owner]"
5.17 + *
5.18 + * The Original Software is NetBeans. The Initial Developer of the Original
5.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
5.20 + * Microsystems, Inc. All Rights Reserved.
5.21 + */
5.22 +
5.23 +package org.netbeans.modules.iep.editor;
5.24 +
5.25 +import java.io.IOException;
5.26 +import java.io.ObjectInput;
5.27 +import java.io.ObjectOutput;
5.28 +import java.io.Serializable;
5.29 +
5.30 +import org.netbeans.core.spi.multiview.MultiViewDescription;
5.31 +import org.netbeans.core.spi.multiview.MultiViewElement;
5.32 +import org.openide.util.HelpCtx;
5.33 +import org.openide.util.NbBundle;
5.34 +import org.openide.util.Utilities;
5.35 +import org.openide.windows.TopComponent;
5.36 +
5.37 +/**
5.38 + *
5.39 + * @author Jeri Lockhart
5.40 + */
5.41 +public class PlanDesignViewMultiViewDesc extends Object
5.42 + implements MultiViewDescription, Serializable {
5.43 +
5.44 +
5.45 + /**
5.46 + *
5.47 + */
5.48 + private static final long serialVersionUID = 2580263536201519563L;
5.49 + public static final String PREFERRED_ID = "wsdl-treeview";
5.50 + private PlanDataObject wsdlDataObject;
5.51 +
5.52 + /**
5.53 + *
5.54 + *
5.55 + */
5.56 + public PlanDesignViewMultiViewDesc() {
5.57 + super();
5.58 + }
5.59 +
5.60 +
5.61 + /**
5.62 + *
5.63 + *
5.64 + */
5.65 + public PlanDesignViewMultiViewDesc(PlanDataObject wsdlDataObject) {
5.66 + this.wsdlDataObject = wsdlDataObject;
5.67 + }
5.68 +
5.69 +
5.70 + /**
5.71 + *
5.72 + *
5.73 + */
5.74 + public String preferredID() {
5.75 + return PREFERRED_ID;
5.76 + }
5.77 +
5.78 +
5.79 + /**
5.80 + *
5.81 + *
5.82 + */
5.83 + public int getPersistenceType() {
5.84 + return TopComponent.PERSISTENCE_NEVER;
5.85 + }
5.86 +
5.87 +
5.88 + /**
5.89 + *
5.90 + *
5.91 + */
5.92 + public java.awt.Image getIcon() {
5.93 + return Utilities.loadImage(PlanDataObject.IEP_ICON_BASE_WITH_EXT);
5.94 + }
5.95 +
5.96 +
5.97 + public HelpCtx getHelpCtx() {
5.98 + return new HelpCtx(PlanDesignViewMultiViewDesc.class);
5.99 + }
5.100 +
5.101 +
5.102 + /**
5.103 + *
5.104 + *
5.105 + */
5.106 + public String getDisplayName() {
5.107 + return NbBundle.getMessage(PlanDesignViewMultiViewDesc.class,
5.108 + "LBL_designView_name");
5.109 + }
5.110 +
5.111 +
5.112 + /**
5.113 + *
5.114 + *
5.115 + */
5.116 + public MultiViewElement createElement() {
5.117 + return new PlanDesignViewMultiViewElement(wsdlDataObject);
5.118 + }
5.119 +
5.120 +
5.121 + /**
5.122 + *
5.123 + *
5.124 + */
5.125 + public void writeExternal(ObjectOutput out) throws IOException {
5.126 + out.writeObject(wsdlDataObject);
5.127 + }
5.128 +
5.129 +
5.130 + /**
5.131 + *
5.132 + *
5.133 + */
5.134 + public void readExternal(ObjectInput in)
5.135 + throws IOException, ClassNotFoundException
5.136 + {
5.137 + Object firstObject = in.readObject();
5.138 + if (firstObject instanceof PlanDataObject)
5.139 + wsdlDataObject = (PlanDataObject) firstObject;
5.140 + }
5.141 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/iep.editor/src/org/netbeans/modules/iep/editor/PlanDesignViewMultiViewElement.java Fri Jul 20 23:27:49 2007 +0000
6.3 @@ -0,0 +1,331 @@
6.4 +/*
6.5 + * The contents of this file are subject to the terms of the Common Development
6.6 + * and Distribution License (the License). You may not use this file except in
6.7 + * compliance with the License.
6.8 + *
6.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
6.10 + * or http://www.netbeans.org/cddl.txt.
6.11 + *
6.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
6.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
6.14 + * If applicable, add the following below the CDDL Header, with the fields
6.15 + * enclosed by brackets [] replaced by your own identifying information:
6.16 + * "Portions Copyrighted [year] [name of copyright owner]"
6.17 + *
6.18 + * The Original Software is NetBeans. The Initial Developer of the Original
6.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
6.20 + * Microsystems, Inc. All Rights Reserved.
6.21 + */
6.22 +
6.23 +package org.netbeans.modules.iep.editor;
6.24 +
6.25 +import java.awt.BorderLayout;
6.26 +import java.awt.Color;
6.27 +import java.awt.event.ActionEvent;
6.28 +import java.beans.PropertyVetoException;
6.29 +import java.util.Iterator;
6.30 +
6.31 +import javax.swing.AbstractAction;
6.32 +import javax.swing.Action;
6.33 +import javax.swing.ActionMap;
6.34 +import javax.swing.InputMap;
6.35 +import javax.swing.JComponent;
6.36 +import javax.swing.JToolBar;
6.37 +import javax.swing.KeyStroke;
6.38 +import javax.swing.UIManager;
6.39 +import javax.swing.text.DefaultEditorKit;
6.40 +
6.41 +import org.netbeans.core.api.multiview.MultiViewHandler;
6.42 +import org.netbeans.core.api.multiview.MultiViewPerspective;
6.43 +import org.netbeans.core.api.multiview.MultiViews;
6.44 +import org.netbeans.core.spi.multiview.CloseOperationState;
6.45 +import org.netbeans.core.spi.multiview.MultiViewElement;
6.46 +import org.netbeans.core.spi.multiview.MultiViewElementCallback;
6.47 +import org.netbeans.core.spi.multiview.MultiViewFactory;
6.48 +import org.openide.actions.FindAction;
6.49 +import org.openide.awt.UndoRedo;
6.50 +import org.openide.explorer.ExplorerManager;
6.51 +import org.openide.explorer.ExplorerUtils;
6.52 +import org.openide.nodes.Node;
6.53 +import org.openide.util.HelpCtx;
6.54 +import org.openide.util.Lookup;
6.55 +import org.openide.util.NbBundle;
6.56 +import org.openide.util.actions.CallbackSystemAction;
6.57 +import org.openide.util.actions.SystemAction;
6.58 +import org.openide.util.lookup.Lookups;
6.59 +import org.openide.windows.Mode;
6.60 +import org.openide.windows.TopComponent;
6.61 +import org.openide.windows.TopComponentGroup;
6.62 +import org.openide.windows.WindowManager;
6.63 +
6.64 +/**
6.65 + * @author radval
6.66 + *
6.67 + * To change the template for this generated type comment go to
6.68 + * Window - Preferences - Java - Code Generation - Code and Comments
6.69 + */
6.70 +public class PlanDesignViewMultiViewElement extends TopComponent
6.71 + implements MultiViewElement, ExplorerManager.Provider {
6.72 + private static final long serialVersionUID = -655912409997381426L;
6.73 + private static final String ACTIVATED_NODES = "activatedNodes";//NOI18N
6.74 + private ExplorerManager manager;
6.75 + private PlanDataObject mObj;
6.76 + private transient MultiViewElementCallback multiViewObserver;
6.77 + private transient javax.swing.JLabel errorLabel = new javax.swing.JLabel();
6.78 + private transient JToolBar mToolbar;
6.79 +
6.80 + public PlanDesignViewMultiViewElement() {
6.81 + super();
6.82 + }
6.83 +
6.84 + public PlanDesignViewMultiViewElement(PlanDataObject dObj) {
6.85 + super();
6.86 + this.mObj = dObj;
6.87 + initialize();
6.88 + }
6.89 +
6.90 + private void initialize() {
6.91 + manager = new ExplorerManager();
6.92 + // Install our own actions.
6.93 + CallbackSystemAction globalFindAction = SystemAction.get(FindAction.class);
6.94 + Object mapKey = globalFindAction.getActionMapKey();
6.95 + Action action = new WSDLFindAction();
6.96 + ActionMap map = getActionMap();
6.97 + map.put(mapKey, action);
6.98 + map.put(DefaultEditorKit.copyAction, ExplorerUtils.actionCopy(manager));
6.99 + map.put(DefaultEditorKit.cutAction, ExplorerUtils.actionCut(manager));
6.100 + map.put(DefaultEditorKit.pasteAction, ExplorerUtils.actionPaste(manager));
6.101 + map.put("delete", ExplorerUtils.actionDelete(manager, false));
6.102 +
6.103 + // Define the keyboard shortcuts for the actions.
6.104 + InputMap keys = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
6.105 + KeyStroke key = (KeyStroke) globalFindAction.getValue(Action.ACCELERATOR_KEY);
6.106 + if (key == null) {
6.107 + key = KeyStroke.getKeyStroke("control F");
6.108 + }
6.109 + keys.put(key, mapKey);
6.110 +
6.111 +
6.112 + Node delegate = mObj.getNodeDelegate();
6.113 +
6.114 + setLayout(new BorderLayout());
6.115 + }
6.116 +
6.117 +
6.118 + private void cleanup() {
6.119 + try {
6.120 + manager.setSelectedNodes(new Node[0]);
6.121 + } catch (PropertyVetoException e) {
6.122 + }
6.123 +
6.124 + if (mToolbar != null) mToolbar.removeAll();
6.125 + mToolbar = null;
6.126 + removeAll();
6.127 + }
6.128 + public ExplorerManager getExplorerManager() {
6.129 + return manager;
6.130 + }
6.131 +
6.132 + @Override
6.133 + public int getPersistenceType() {
6.134 + return PERSISTENCE_NEVER;
6.135 + }
6.136 +
6.137 + public void setMultiViewCallback(final MultiViewElementCallback callback) {
6.138 + multiViewObserver = callback;
6.139 + }
6.140 +
6.141 + public CloseOperationState canCloseElement() {
6.142 + // if this is not the last cloned xml editor component, closing is OK
6.143 + if (!PlanEditorSupport.isLastView(multiViewObserver.getTopComponent())) {
6.144 + return CloseOperationState.STATE_OK;
6.145 + }
6.146 + // return a placeholder state - to be sure our CloseHandler is called
6.147 + return MultiViewFactory.createUnsafeCloseState(
6.148 + "ID_TEXT_CLOSING", // dummy ID // NOI18N
6.149 + MultiViewFactory.NOOP_CLOSE_ACTION,
6.150 + MultiViewFactory.NOOP_CLOSE_ACTION);
6.151 + }
6.152 +/*
6.153 + @Override
6.154 + public UndoRedo getUndoRedo() {
6.155 + return mObj.getWSDLEditorSupport().getUndoManager();
6.156 + }
6.157 +*/
6.158 + @Override
6.159 + public void componentHidden() {
6.160 + super.componentHidden();
6.161 +
6.162 + }
6.163 +
6.164 + @Override
6.165 + public void componentClosed() {
6.166 + super.componentClosed();
6.167 + cleanup();
6.168 + }
6.169 +
6.170 + @Override
6.171 + public void componentOpened() {
6.172 + super.componentOpened();
6.173 + initUI();
6.174 + }
6.175 +
6.176 + @Override
6.177 + public void componentActivated() {
6.178 + super.componentActivated();
6.179 + ExplorerUtils.activateActions(manager, true);
6.180 + //mObj.getWSDLEditorSupport().syncModel();
6.181 + updateGroupVisibility();
6.182 + }
6.183 +
6.184 + @Override
6.185 + public void componentDeactivated() {
6.186 + ExplorerUtils.activateActions(manager, false);
6.187 + super.componentDeactivated();
6.188 + updateGroupVisibility();
6.189 + }
6.190 +
6.191 + @Override
6.192 + public void componentShowing() {
6.193 + super.componentShowing();
6.194 + initUI();
6.195 +
6.196 +
6.197 + }
6.198 +
6.199 + @Override
6.200 + public void requestActive() {
6.201 + super.requestActive();
6.202 +
6.203 + }
6.204 +
6.205 + @Override
6.206 + public HelpCtx getHelpCtx() {
6.207 + return new HelpCtx(PlanDesignViewMultiViewDesc.class);
6.208 + }
6.209 +
6.210 + private static Boolean groupVisible = null;
6.211 +
6.212 + private void updateGroupVisibility() {
6.213 + WindowManager wm = WindowManager.getDefault();
6.214 + final TopComponentGroup group = wm.findTopComponentGroup("wsdl_ui"); // NOI18N
6.215 + if (group == null) {
6.216 + return; // group not found (should not happen)
6.217 + }
6.218 + //
6.219 + boolean isWSDLViewSelected = false;
6.220 + Iterator it = wm.getModes().iterator();
6.221 + while (it.hasNext()) {
6.222 + Mode mode = (Mode) it.next();
6.223 + TopComponent selected = mode.getSelectedTopComponent();
6.224 + if (selected != null) {
6.225 + MultiViewHandler mvh = MultiViews.findMultiViewHandler(selected);
6.226 + if (mvh != null) {
6.227 + MultiViewPerspective mvp = mvh.getSelectedPerspective();
6.228 + if (mvp != null) {
6.229 + String id = mvp.preferredID();
6.230 + if (PlanDesignViewMultiViewDesc.PREFERRED_ID.equals(id)) {
6.231 + isWSDLViewSelected = true;
6.232 + break;
6.233 + }
6.234 + }
6.235 + }
6.236 + }
6.237 + }
6.238 + //
6.239 + if (isWSDLViewSelected && !Boolean.TRUE.equals(groupVisible)) {
6.240 + group.open();
6.241 + } else if (!isWSDLViewSelected && !Boolean.FALSE.equals(groupVisible)) {
6.242 + group.close();
6.243 + }
6.244 + //
6.245 + groupVisible = isWSDLViewSelected ? Boolean.TRUE : Boolean.FALSE;
6.246 +
6.247 + }
6.248 +
6.249 + @Override
6.250 + protected String preferredID() {
6.251 + return "WSDLTreeViewMultiViewElementTC"; // NOI18N
6.252 + }
6.253 +
6.254 + /**
6.255 + * Construct the user interface.
6.256 + */
6.257 + private void initUI() {
6.258 + PlanEditorSupport editor = mObj.getPlanEditorSupport();
6.259 + //WSDLModel wsdlModel = null;
6.260 + String errorMessage = null;
6.261 + /*wsdlModel = editor.getModel();
6.262 + if (wsdlModel != null &&
6.263 + wsdlModel.getState() == WSDLModel.State.VALID) {
6.264 + // Construct the standard editor interface.
6.265 + return;
6.266 + }
6.267 +
6.268 + // If it comes here, either the model is not well-formed or invalid.
6.269 + if (wsdlModel == null ||
6.270 + wsdlModel.getState() == WSDLModel.State.NOT_WELL_FORMED) {
6.271 + errorMessage = NbBundle.getMessage(
6.272 + WSDLTreeViewMultiViewElement.class,
6.273 + "MSG_NotWellformedWsdl");
6.274 + }*/
6.275 +
6.276 + // Clear the interface and show the error message.
6.277 + removeAll();
6.278 + errorLabel.setText("<" + errorMessage + ">");
6.279 + errorLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
6.280 + errorLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
6.281 + errorLabel.setEnabled(false);
6.282 + Color usualWindowBkg = UIManager.getColor("window"); //NOI18N
6.283 + errorLabel.setBackground(usualWindowBkg != null ? usualWindowBkg :
6.284 + Color.white);
6.285 + errorLabel.setOpaque(true);
6.286 + add(errorLabel, BorderLayout.CENTER);
6.287 + }
6.288 +
6.289 + public javax.swing.JComponent getToolbarRepresentation() {
6.290 + if (mToolbar == null) {
6.291 + /*WSDLModel model = mObj.getWSDLEditorSupport().getModel();
6.292 + if (model != null && model.getState() == WSDLModel.State.VALID) {
6.293 + mToolbar = new JToolBar();
6.294 + mToolbar.setFloatable(false);
6.295 + // vlv: search
6.296 + mToolbar.addSeparator();
6.297 + SearchManager searchManager = SearchManagerAccess.getManager();
6.298 +
6.299 + if (searchManager != null) {
6.300 + mToolbar.add(searchManager.getSearchAction());
6.301 + }
6.302 + mToolbar.addSeparator();
6.303 + mToolbar.add(new ValidateAction(model));
6.304 + }*/
6.305 + }
6.306 + return mToolbar;
6.307 + }
6.308 +
6.309 + public javax.swing.JComponent getVisualRepresentation() {
6.310 + return this;
6.311 + }
6.312 +
6.313 + /**
6.314 + * Find action for WSDL editor.
6.315 + *
6.316 + * @author Nathan Fiedler
6.317 + */
6.318 + private class WSDLFindAction extends AbstractAction {
6.319 + /** silence compiler warnings */
6.320 + private static final long serialVersionUID = 1L;
6.321 +
6.322 + /**
6.323 + * Creates a new instance of WSDLFindAction.
6.324 + */
6.325 + public WSDLFindAction() {
6.326 + }
6.327 +
6.328 + public void actionPerformed(ActionEvent event) {
6.329 + PlanDesignViewMultiViewElement parent =
6.330 + PlanDesignViewMultiViewElement.this;
6.331 +
6.332 + }
6.333 + }
6.334 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/iep.editor/src/org/netbeans/modules/iep/editor/PlanEditorSupport.java Fri Jul 20 23:27:49 2007 +0000
7.3 @@ -0,0 +1,281 @@
7.4 +/*
7.5 + * The contents of this file are subject to the terms of the Common Development
7.6 + * and Distribution License (the License). You may not use this file except in
7.7 + * compliance with the License.
7.8 + *
7.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7.10 + * or http://www.netbeans.org/cddl.txt.
7.11 + *
7.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
7.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
7.14 + * If applicable, add the following below the CDDL Header, with the fields
7.15 + * enclosed by brackets [] replaced by your own identifying information:
7.16 + * "Portions Copyrighted [year] [name of copyright owner]"
7.17 + *
7.18 + * The Original Software is NetBeans. The Initial Developer of the Original
7.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
7.20 + * Microsystems, Inc. All Rights Reserved.
7.21 + */
7.22 +
7.23 +package org.netbeans.modules.iep.editor;
7.24 +
7.25 +import java.awt.EventQueue;
7.26 +import java.io.IOException;
7.27 +import java.io.Serializable;
7.28 +import java.util.ArrayList;
7.29 +import java.util.Enumeration;
7.30 +import java.util.List;
7.31 +import java.util.Set;
7.32 +
7.33 +import javax.swing.text.AbstractDocument;
7.34 +import javax.swing.text.StyledDocument;
7.35 +
7.36 +import org.netbeans.core.api.multiview.MultiViewHandler;
7.37 +import org.netbeans.core.api.multiview.MultiViews;
7.38 +import org.netbeans.core.spi.multiview.CloseOperationHandler;
7.39 +import org.netbeans.core.spi.multiview.CloseOperationState;
7.40 +import org.openide.DialogDisplayer;
7.41 +import org.openide.NotifyDescriptor;
7.42 +import org.openide.awt.UndoRedo;
7.43 +import org.openide.cookies.CloseCookie;
7.44 +import org.openide.cookies.EditCookie;
7.45 +import org.openide.cookies.EditorCookie;
7.46 +import org.openide.cookies.LineCookie;
7.47 +import org.openide.cookies.OpenCookie;
7.48 +import org.openide.cookies.PrintCookie;
7.49 +import org.openide.filesystems.FileLock;
7.50 +import org.openide.filesystems.FileObject;
7.51 +import org.openide.loaders.DataObject;
7.52 +import org.openide.text.CloneableEditor;
7.53 +import org.openide.text.CloneableEditorSupport;
7.54 +import org.openide.text.DataEditorSupport;
7.55 +import org.openide.util.NbBundle;
7.56 +import org.openide.util.Task;
7.57 +import org.openide.util.TaskListener;
7.58 +import org.openide.windows.CloneableTopComponent;
7.59 +import org.openide.windows.Mode;
7.60 +import org.openide.windows.TopComponent;
7.61 +import org.openide.windows.WindowManager;
7.62 +
7.63 +
7.64 +/**
7.65 + *
7.66 + * @author Jeri Lockhart
7.67 + * @author Todd Fast, todd.fast@sun.com
7.68 + */
7.69 +public class PlanEditorSupport extends DataEditorSupport
7.70 + implements OpenCookie, EditCookie,
7.71 + EditorCookie.Observable, LineCookie, CloseCookie, PrintCookie {
7.72 + /** Used for managing the prepareTask listener. */
7.73 + private transient Task prepareTask2;
7.74 +
7.75 + /**
7.76 + *
7.77 + *
7.78 + */
7.79 + public PlanEditorSupport(PlanDataObject sobj) {
7.80 + super(sobj, new WSDLEditorEnv(sobj));
7.81 + setMIMEType(PlanDataLoader.MIME_TYPE);
7.82 + }
7.83 +
7.84 +
7.85 + /**
7.86 + *
7.87 + *
7.88 + */
7.89 + public WSDLEditorEnv getEnv() {
7.90 + return (WSDLEditorEnv)env;
7.91 + }
7.92 +
7.93 + @Override
7.94 + protected Pane createPane() {
7.95 + TopComponent tc = PlanMultiViewFactory.createMultiView(
7.96 + (PlanDataObject) getDataObject());
7.97 + // Note that initialization of the editor happens separately,
7.98 + // and we only need to handle that during the initial creation
7.99 + // of the text editor.
7.100 + Mode editorMode = WindowManager.getDefault().findMode(
7.101 + PlanEditorSupport.EDITOR_MODE);
7.102 + if (editorMode != null) {
7.103 + editorMode.dockInto(tc);
7.104 + }
7.105 + return (Pane) tc;
7.106 + }
7.107 +
7.108 + /**
7.109 + *
7.110 + *
7.111 + */
7.112 + public static boolean isLastView(TopComponent tc) {
7.113 +
7.114 + if (!(tc instanceof CloneableTopComponent))
7.115 + return false;
7.116 +
7.117 + boolean oneOrLess = true;
7.118 + Enumeration en =
7.119 + ((CloneableTopComponent)tc).getReference().getComponents();
7.120 + if (en.hasMoreElements()) {
7.121 + en.nextElement();
7.122 + if (en.hasMoreElements())
7.123 + oneOrLess = false;
7.124 + }
7.125 +
7.126 + return oneOrLess;
7.127 + }
7.128 +
7.129 + // Change method access to public
7.130 + @Override
7.131 + public void initializeCloneableEditor(CloneableEditor editor) {
7.132 + super.initializeCloneableEditor(editor);
7.133 + // Force the title to update so the * left over from when the
7.134 + // modified data object was discarded is removed from the title.
7.135 + EventQueue.invokeLater(new Runnable() {
7.136 + public void run() {
7.137 + // Have to do this later to avoid infinite loop.
7.138 + updateTitles();
7.139 + }
7.140 + });
7.141 + }
7.142 +
7.143 + @Override
7.144 + protected void updateTitles() {
7.145 + // This method is invoked by DataEditorSupport.DataNodeListener
7.146 + // whenever the DataNode displayName property is changed. It is
7.147 + // also called when the CloneableEditorSupport is (un)modified.
7.148 +
7.149 + // Let the superclass handle the CloneableEditor instances.
7.150 + super.updateTitles();
7.151 +
7.152 + // We need to get the title updated on the MultiViewTopComponent.
7.153 + EventQueue.invokeLater(new Runnable() {
7.154 + public void run() {
7.155 + // Create a list of TopComponents associated with the
7.156 + // editor's data object, starting with the active
7.157 + // TopComponent. Add all open TopComponents in any
7.158 + // mode that are associated with the DataObject.
7.159 + // [Note that EDITOR_MODE does not contain editors in
7.160 + // split mode.]
7.161 + List<TopComponent> associatedTCs = new ArrayList<TopComponent>();
7.162 + DataObject targetDO = getDataObject();
7.163 + TopComponent activeTC = TopComponent.getRegistry().getActivated();
7.164 + if (activeTC != null && targetDO == activeTC.getLookup().lookup(
7.165 + DataObject.class)) {
7.166 + associatedTCs.add(activeTC);
7.167 + }
7.168 + Set openTCs = TopComponent.getRegistry().getOpened();
7.169 + for (Object tc : openTCs) {
7.170 + TopComponent tcc = (TopComponent) tc;
7.171 + if (targetDO == tcc.getLookup().lookup(
7.172 + DataObject.class)) {
7.173 + associatedTCs.add(tcc);
7.174 + }
7.175 + }
7.176 + for (TopComponent tc : associatedTCs) {
7.177 + // Make sure this is a multiview window, and not just some
7.178 + // window that has our DataObject (e.g. Projects, Files).
7.179 + MultiViewHandler mvh = MultiViews.findMultiViewHandler(tc);
7.180 + if (mvh != null) {
7.181 + tc.setHtmlDisplayName(messageHtmlName());
7.182 + String name = messageName();
7.183 + tc.setDisplayName(name);
7.184 + tc.setName(name);
7.185 + tc.setToolTipText(messageToolTip());
7.186 + }
7.187 + }
7.188 + }
7.189 + });
7.190 + }
7.191 +
7.192 +
7.193 +
7.194 + /**
7.195 + * This method allows the close behavior of CloneableEditorSupport to be
7.196 + * invoked from the SourceMultiViewElement. The close method of
7.197 + * CloneableEditorSupport at least clears the undo queue and releases
7.198 + * the swing document.
7.199 + */
7.200 + public boolean silentClose() {
7.201 + return super.close(false);
7.202 + }
7.203 +
7.204 +
7.205 +
7.206 + ////////////////////////////////////////////////////////////////////////////
7.207 + // Inner class
7.208 + ////////////////////////////////////////////////////////////////////////////
7.209 +
7.210 + /**
7.211 + * Env class extends DataEditorSupport.Env.
7.212 + */
7.213 + protected static class WSDLEditorEnv extends DataEditorSupport.Env {
7.214 +
7.215 + static final long serialVersionUID =1099957785497677206L;
7.216 +
7.217 + public WSDLEditorEnv(PlanDataObject obj) {
7.218 + super(obj);
7.219 + }
7.220 +
7.221 + public CloneableEditorSupport findTextEditorSupport() {
7.222 + return getWSDLDataObject().getPlanEditorSupport();
7.223 + }
7.224 +
7.225 + public PlanDataObject getWSDLDataObject(){
7.226 + return (PlanDataObject) getDataObject();
7.227 + }
7.228 +
7.229 + @Override
7.230 + protected FileObject getFile() {
7.231 + return getDataObject().getPrimaryFile();
7.232 + }
7.233 +
7.234 + @Override
7.235 + protected FileLock takeLock() throws IOException {
7.236 + return getDataObject().getPrimaryFile().lock();
7.237 + }
7.238 + }
7.239 +
7.240 +
7.241 +
7.242 +
7.243 + ////////////////////////////////////////////////////////////////////////////
7.244 + // Inner class
7.245 + ////////////////////////////////////////////////////////////////////////////
7.246 +
7.247 + /**
7.248 + * Implementation of CloseOperationHandler for multiview. Ensures both
7.249 + * column view and xml editor are correctly closed, data saved, etc. Holds
7.250 + * a reference to DataObject only - to be serializable with the
7.251 + * multiview TopComponent without problems.
7.252 + */
7.253 + public static class CloseHandler implements CloseOperationHandler, Serializable {
7.254 + private static final long serialVersionUID =-3838395157610633251L;
7.255 + private DataObject dataObject;
7.256 +
7.257 + private CloseHandler() {
7.258 + super();
7.259 + }
7.260 +
7.261 + public CloseHandler(DataObject dobj) {
7.262 + dataObject = dobj;
7.263 + }
7.264 +
7.265 + private PlanEditorSupport getWSDLEditorSupport() {
7.266 + return dataObject instanceof PlanDataObject ?
7.267 + ((PlanDataObject) dataObject).getPlanEditorSupport() : null;
7.268 + }
7.269 +
7.270 + public boolean resolveCloseOperation(CloseOperationState[] elements) {
7.271 + PlanEditorSupport wsdlEditor = getWSDLEditorSupport();
7.272 + boolean canClose = wsdlEditor != null ? wsdlEditor.canClose() : true;
7.273 + // during the shutdown sequence this is called twice. The first time
7.274 + // through the multi-view infrastructure. The second time is done through
7.275 + // the TopComponent close. If the file is dirty and the user chooses
7.276 + // to discard changes, the second time will also ask whether the
7.277 + // to save or discard changes.
7.278 + if (canClose) {
7.279 + dataObject.setModified(false);
7.280 + }
7.281 + return canClose;
7.282 + }
7.283 + }
7.284 +}
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/iep.editor/src/org/netbeans/modules/iep/editor/PlanMultiViewFactory.java Fri Jul 20 23:27:49 2007 +0000
8.3 @@ -0,0 +1,91 @@
8.4 +/*
8.5 + * The contents of this file are subject to the terms of the Common Development
8.6 + * and Distribution License (the License). You may not use this file except in
8.7 + * compliance with the License.
8.8 + *
8.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
8.10 + * or http://www.netbeans.org/cddl.txt.
8.11 + *
8.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
8.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
8.14 + * If applicable, add the following below the CDDL Header, with the fields
8.15 + * enclosed by brackets [] replaced by your own identifying information:
8.16 + * "Portions Copyrighted [year] [name of copyright owner]"
8.17 + *
8.18 + * The Original Software is NetBeans. The Initial Developer of the Original
8.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
8.20 + * Microsystems, Inc. All Rights Reserved.
8.21 + */
8.22 +
8.23 +package org.netbeans.modules.iep.editor;
8.24 +import org.netbeans.core.api.multiview.MultiViewHandler;
8.25 +import org.netbeans.core.api.multiview.MultiViewPerspective;
8.26 +import org.netbeans.core.api.multiview.MultiViews;
8.27 +import org.netbeans.core.spi.multiview.MultiViewDescription;
8.28 +import org.netbeans.core.spi.multiview.MultiViewFactory;
8.29 +import org.openide.windows.CloneableTopComponent;
8.30 +import org.openide.windows.TopComponent;
8.31 +
8.32 +/**
8.33 + *
8.34 + * @author Jeri Lockhart
8.35 + */
8.36 +public class PlanMultiViewFactory {
8.37 + /**
8.38 + * Creates a new instance of WSDLMultiViewFactory
8.39 + */
8.40 + public PlanMultiViewFactory() {
8.41 + }
8.42 +
8.43 + public static CloneableTopComponent createMultiView(PlanDataObject wsdlDataObject) {
8.44 + MultiViewDescription views[] = new MultiViewDescription[3];
8.45 +
8.46 + views[0] = getWSDLSourceMultiviewDesc(wsdlDataObject);
8.47 + views[1] = getWSDLDesignMultiviewDesc(wsdlDataObject);
8.48 +
8.49 +
8.50 + CloneableTopComponent multiview =
8.51 + MultiViewFactory.createCloneableMultiView(
8.52 +
8.53 + views,
8.54 + views[0],
8.55 + new PlanEditorSupport.CloseHandler(wsdlDataObject));
8.56 +
8.57 + //IZ 84440 - show file name with extension
8.58 + String name = wsdlDataObject.getNodeDelegate().getDisplayName();
8.59 + multiview.setDisplayName(name);
8.60 + multiview.setName(name);
8.61 +
8.62 +
8.63 + return multiview;
8.64 + }
8.65 +
8.66 +
8.67 + private static MultiViewDescription getWSDLSourceMultiviewDesc(PlanDataObject wsdlDataObject) {
8.68 + return new PlanSourceMultiviewDesc(wsdlDataObject);
8.69 + }
8.70 +
8.71 + private static MultiViewDescription getWSDLDesignMultiviewDesc(PlanDataObject wsdlDataObject) {
8.72 + return new PlanDesignViewMultiViewDesc(wsdlDataObject);
8.73 + }
8.74 +
8.75 + /**
8.76 + * Shows the desired multiview element. Must be called after the editor
8.77 + * has been opened (i.e. WSDLEditorSupport.open()) so the TopComponent
8.78 + * will be the active one in the registry.
8.79 + *
8.80 + * @param id identifier of the multiview element.
8.81 + */
8.82 + public static void requestMultiviewActive(String id) {
8.83 + TopComponent activeTC = TopComponent.getRegistry().getActivated();
8.84 + MultiViewHandler handler = MultiViews.findMultiViewHandler(activeTC);
8.85 + if (handler != null) {
8.86 + MultiViewPerspective[] perspectives = handler.getPerspectives();
8.87 + for (MultiViewPerspective perspective : perspectives) {
8.88 + if (perspective.preferredID().equals(id)) {
8.89 + handler.requestActive(perspective);
8.90 + }
8.91 + }
8.92 + }
8.93 + }
8.94 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/iep.editor/src/org/netbeans/modules/iep/editor/PlanSourceMultiViewElement.java Fri Jul 20 23:27:49 2007 +0000
9.3 @@ -0,0 +1,313 @@
9.4 +/*
9.5 + * The contents of this file are subject to the terms of the Common Development
9.6 + * and Distribution License (the License). You may not use this file except in
9.7 + * compliance with the License.
9.8 + *
9.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
9.10 + * or http://www.netbeans.org/cddl.txt.
9.11 + *
9.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
9.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
9.14 + * If applicable, add the following below the CDDL Header, with the fields
9.15 + * enclosed by brackets [] replaced by your own identifying information:
9.16 + * "Portions Copyrighted [year] [name of copyright owner]"
9.17 + *
9.18 + * The Original Software is NetBeans. The Initial Developer of the Original
9.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
9.20 + * Microsystems, Inc. All Rights Reserved.
9.21 + */
9.22 +
9.23 +package org.netbeans.modules.iep.editor;
9.24 +
9.25 +import java.awt.EventQueue;
9.26 +import java.awt.event.ActionEvent;
9.27 +import java.awt.event.ActionListener;
9.28 +import java.io.IOException;
9.29 +import java.io.ObjectInput;
9.30 +import java.io.ObjectOutput;
9.31 +import java.util.List;
9.32 +
9.33 +import javax.swing.JComponent;
9.34 +import javax.swing.JEditorPane;
9.35 +import javax.swing.SwingUtilities;
9.36 +import javax.swing.Timer;
9.37 +import javax.swing.event.CaretEvent;
9.38 +import javax.swing.event.CaretListener;
9.39 +import javax.swing.text.Document;
9.40 +import javax.swing.text.StyledDocument;
9.41 +
9.42 +import org.netbeans.core.spi.multiview.CloseOperationState;
9.43 +import org.netbeans.core.spi.multiview.MultiViewElement;
9.44 +import org.netbeans.core.spi.multiview.MultiViewElementCallback;
9.45 +import org.netbeans.core.spi.multiview.MultiViewFactory;
9.46 +import org.openide.awt.UndoRedo;
9.47 +import org.openide.nodes.Node;
9.48 +import org.openide.nodes.NodeAdapter;
9.49 +import org.openide.nodes.NodeEvent;
9.50 +import org.openide.text.CloneableEditor;
9.51 +import org.openide.text.NbDocument;
9.52 +import org.openide.util.Lookup;
9.53 +import org.openide.util.RequestProcessor;
9.54 +import org.openide.util.lookup.Lookups;
9.55 +
9.56 +/**
9.57 + *
9.58 + * @author Jeri Lockhart
9.59 + */
9.60 +
9.61 +public class PlanSourceMultiViewElement extends CloneableEditor implements MultiViewElement {
9.62 +
9.63 + private static final long serialVersionUID = 4403502726950453345L;
9.64 +
9.65 + transient private JComponent toolbar;
9.66 + transient private MultiViewElementCallback multiViewObserver;
9.67 + private PlanDataObject wsdlDataObject;
9.68 +
9.69 +
9.70 + // Do NOT remove. Only for externalization //
9.71 + public PlanSourceMultiViewElement() {
9.72 + super();
9.73 + }
9.74 +
9.75 + // Creates new editor //
9.76 + public PlanSourceMultiViewElement(PlanDataObject wsdlDataObject) {
9.77 + super(wsdlDataObject.getPlanEditorSupport());
9.78 + this.wsdlDataObject = wsdlDataObject;
9.79 +
9.80 +
9.81 + // Initialize the editor support properly, which only needs to be
9.82 + // done when the editor is created (deserialization is working
9.83 + // due to CloneableEditor.readResolve() initializing the editor).
9.84 + // Note that this relies on the source view being the first in the
9.85 + // array of MultiViewDescription instances in WSDLMultiViewFactory,
9.86 + // since that results in the source view being created and opened
9.87 + // by default, only to be hidden when the DataObject default action
9.88 + // makes the tree view appear.
9.89 + // This initialization fixes CR 6380287 by ensuring that the Node
9.90 + // listener is registered with the DataObject Node delegate.
9.91 + wsdlDataObject.getPlanEditorSupport().initializeCloneableEditor(this);
9.92 + initialize();
9.93 + }
9.94 +
9.95 + /**
9.96 + * create lookup, caretlistener, timer
9.97 + */
9.98 + private void initialize()
9.99 + {
9.100 +
9.101 + caretListener = new CaretListener() {
9.102 + public void caretUpdate(CaretEvent e) {
9.103 + timerSelNodes.restart();
9.104 + }
9.105 + };
9.106 +
9.107 + timerSelNodes = new Timer(1, new ActionListener() {
9.108 + public void actionPerformed(ActionEvent e) {
9.109 + if (!isActiveTC() || getEditorPane() == null) {
9.110 + return;
9.111 + }
9.112 + //selectElementsAtOffset();
9.113 + }
9.114 + });
9.115 + timerSelNodes.setRepeats(false);
9.116 + }
9.117 +
9.118 + public JComponent getToolbarRepresentation() {
9.119 + Document doc = getEditorPane().getDocument();
9.120 + if (doc instanceof NbDocument.CustomToolbar) {
9.121 + if (toolbar == null) {
9.122 + toolbar = ((NbDocument.CustomToolbar) doc).createToolbar(getEditorPane());
9.123 + }
9.124 + return toolbar;
9.125 + }
9.126 + return null;
9.127 + }
9.128 +
9.129 + public JComponent getVisualRepresentation() {
9.130 + return this;
9.131 + }
9.132 +
9.133 + public void setMultiViewCallback(MultiViewElementCallback callback) {
9.134 + multiViewObserver = callback;
9.135 + }
9.136 +
9.137 + @Override
9.138 + public void requestVisible() {
9.139 + if (multiViewObserver != null)
9.140 + multiViewObserver.requestVisible();
9.141 + else
9.142 + super.requestVisible();
9.143 + }
9.144 +
9.145 + @Override
9.146 + public void requestActive() {
9.147 + if (multiViewObserver != null)
9.148 + multiViewObserver.requestActive();
9.149 + else
9.150 + super.requestActive();
9.151 + }
9.152 +
9.153 + @Override
9.154 + protected String preferredID() {
9.155 +
9.156 + return "WSDLSourceMultiViewElementTC"; // NOI18N
9.157 + }
9.158 +
9.159 +
9.160 + /* @Override
9.161 + public UndoRedo getUndoRedo() {
9.162 + return wsdlDataObject.getWSDLEditorSupport().getUndoManager();
9.163 + }*/
9.164 +
9.165 + /**
9.166 + * The close last method should be called only for the last clone.
9.167 + * If there are still existing clones this method must return false. The
9.168 + * implementation from the FormEditor always returns true but this is
9.169 + * not the expected behavior. The intention is to close the editor support
9.170 + * once the last editor has been closed, using the silent close to avoid
9.171 + * displaying a new dialog which is already being displayed via the
9.172 + * close handler.
9.173 + */
9.174 + @Override
9.175 + protected boolean closeLast() {
9.176 + PlanEditorSupport support = wsdlDataObject.getPlanEditorSupport();
9.177 + JEditorPane[] editors = support.getOpenedPanes();
9.178 + if (editors == null || editors.length == 0) {
9.179 + return support.silentClose();
9.180 + }
9.181 + return false;
9.182 + }
9.183 +
9.184 + public CloseOperationState canCloseElement() {
9.185 + // if this is not the last cloned xml editor component, closing is OK
9.186 + if (!PlanEditorSupport.isLastView(multiViewObserver.getTopComponent())) {
9.187 + return CloseOperationState.STATE_OK;
9.188 + }
9.189 + // return a placeholder state - to be sure our CloseHandler is called
9.190 + return MultiViewFactory.createUnsafeCloseState(
9.191 + "ID_TEXT_CLOSING", // dummy ID // NOI18N
9.192 + MultiViewFactory.NOOP_CLOSE_ACTION,
9.193 + MultiViewFactory.NOOP_CLOSE_ACTION);
9.194 + }
9.195 +
9.196 + @Override
9.197 + public void componentActivated() {
9.198 + JEditorPane p = getEditorPane();
9.199 + if (p != null) {
9.200 + p.addCaretListener(caretListener);
9.201 + }
9.202 + if(timerSelNodes!=null) {
9.203 + timerSelNodes.restart();
9.204 + }
9.205 + super.componentActivated();
9.206 + PlanEditorSupport editor = wsdlDataObject.getPlanEditorSupport();
9.207 + //editor.addUndoManagerToDocument();
9.208 + }
9.209 + @Override
9.210 + public void componentDeactivated() {
9.211 + // Note: componentDeactivated() is called when the entire
9.212 + // MultiViewTopComponent is deactivated, _not_ when switching
9.213 + // between the multiview elements.
9.214 + JEditorPane p = getEditorPane();
9.215 + if (p != null) {
9.216 + p.removeCaretListener(caretListener);
9.217 + }
9.218 + synchronized (this) {
9.219 + if (selectionTask != null) {
9.220 + selectionTask.cancel();
9.221 + selectionTask = null;
9.222 + }
9.223 + }
9.224 + if(timerSelNodes!=null) {
9.225 + timerSelNodes.stop();
9.226 + }
9.227 + super.componentDeactivated();
9.228 + PlanEditorSupport editor = wsdlDataObject.getPlanEditorSupport();
9.229 + // Sync model before having undo manager listen to the model,
9.230 + // lest we get redundant undoable edits added to the queue.
9.231 + //editor.syncModel();
9.232 + //editor.removeUndoManagerFromDocument();
9.233 + }
9.234 +
9.235 + @Override
9.236 + public void componentOpened() {
9.237 + super.componentOpened();
9.238 + }
9.239 +
9.240 +
9.241 + /*
9.242 + * In other non-multiview editors, the text editor is the one that is docked into the editor mode.
9.243 + * and super.canClose() returns true and schedules the clean up of editor kit,
9.244 + * which in turn calls uninstallUI in NbEditorUI class.
9.245 + *
9.246 + * In our case, we need to explicitly call setEditorKit(null), so that uninstallUI gets called.
9.247 + * So our editor gets removed from different caches and propertychangesupports.
9.248 + *
9.249 + * (non-Javadoc)
9.250 + * @see org.openide.text.CloneableEditor#componentClosed()
9.251 + */
9.252 + @Override
9.253 + public void componentClosed() {
9.254 + super.componentClosed();
9.255 + multiViewObserver = null;
9.256 + }
9.257 +
9.258 + @Override
9.259 + public void componentShowing() {
9.260 + super.componentShowing();
9.261 + PlanEditorSupport editor = wsdlDataObject.getPlanEditorSupport();
9.262 + //editor.addUndoManagerToDocument();
9.263 + }
9.264 +
9.265 + @Override
9.266 + public void componentHidden() {
9.267 + super.componentHidden();
9.268 + PlanEditorSupport editor = wsdlDataObject.getPlanEditorSupport();
9.269 + // Sync model before having undo manager listen to the model,
9.270 + // lest we get redundant undoable edits added to the queue.
9.271 + //editor.syncModel();
9.272 + //editor.removeUndoManagerFromDocument();
9.273 + }
9.274 +
9.275 + @Override
9.276 + public void writeExternal(ObjectOutput out) throws IOException {
9.277 + super.writeExternal(out);
9.278 + out.writeObject(wsdlDataObject);
9.279 + }
9.280 +
9.281 + @Override
9.282 + public void readExternal(ObjectInput in)
9.283 + throws IOException, ClassNotFoundException {
9.284 + super.readExternal(in);
9.285 + Object firstObject = in.readObject();
9.286 + if (firstObject instanceof PlanDataObject) {
9.287 + wsdlDataObject = (PlanDataObject) firstObject;
9.288 + initialize();
9.289 + }
9.290 + }
9.291 +
9.292 + // node support
9.293 + /** Root node of schema model */
9.294 + private Node rootNode;
9.295 + /** current selection*/
9.296 + private Node selectedNode;
9.297 + /** listens to selected node destroyed event */
9.298 + private NodeAdapter nl;
9.299 + /** Timer which countdowns the "update selected element node" time. */
9.300 + private Timer timerSelNodes;
9.301 + /** Listener on caret movements */
9.302 + private CaretListener caretListener;
9.303 + /* task */
9.304 + private transient RequestProcessor.Task selectionTask = null;
9.305 + /** Selects element at the caret position. */
9.306 +
9.307 +
9.308 +
9.309 +
9.310 + protected boolean isActiveTC() {
9.311 + if (multiViewObserver != null)
9.312 + return getRegistry().getActivated() == multiViewObserver.getTopComponent();
9.313 +
9.314 + return false;
9.315 + }
9.316 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/iep.editor/src/org/netbeans/modules/iep/editor/PlanSourceMultiviewDesc.java Fri Jul 20 23:27:49 2007 +0000
10.3 @@ -0,0 +1,97 @@
10.4 +/*
10.5 + * The contents of this file are subject to the terms of the Common Development
10.6 + * and Distribution License (the License). You may not use this file except in
10.7 + * compliance with the License.
10.8 + *
10.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
10.10 + * or http://www.netbeans.org/cddl.txt.
10.11 + *
10.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
10.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
10.14 + * If applicable, add the following below the CDDL Header, with the fields
10.15 + * enclosed by brackets [] replaced by your own identifying information:
10.16 + * "Portions Copyrighted [year] [name of copyright owner]"
10.17 + *
10.18 + * The Original Software is NetBeans. The Initial Developer of the Original
10.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
10.20 + * Microsystems, Inc. All Rights Reserved.
10.21 + */
10.22 +
10.23 +package org.netbeans.modules.iep.editor;
10.24 +
10.25 +import java.io.IOException;
10.26 +import java.io.ObjectInput;
10.27 +import java.io.ObjectOutput;
10.28 +import java.io.Serializable;
10.29 +
10.30 +import org.netbeans.core.spi.multiview.MultiViewDescription;
10.31 +import org.netbeans.core.spi.multiview.MultiViewFactory;
10.32 +import org.openide.util.NbBundle;
10.33 +import org.openide.util.Utilities;
10.34 +import org.openide.windows.TopComponent;
10.35 +/**
10.36 + *
10.37 + * @author Jeri Lockhart
10.38 + */
10.39 +public class PlanSourceMultiviewDesc
10.40 + implements MultiViewDescription, Serializable {
10.41 +
10.42 +
10.43 + private static final long serialVersionUID = -4505309173196320880L;
10.44 + public static final String PREFERRED_ID = "wsdl-sourceview";
10.45 + private PlanDataObject wsdlDataObject;
10.46 +
10.47 + // Constructor for reserialization
10.48 + public PlanSourceMultiviewDesc( ) {
10.49 + }
10.50 +
10.51 + /**
10.52 + * Creates a new instance of WSDLSourceMultiviewDesc
10.53 + */
10.54 + public PlanSourceMultiviewDesc(PlanDataObject wsdlDataObject) {
10.55 + this.wsdlDataObject = wsdlDataObject;
10.56 + }
10.57 +
10.58 + public String preferredID() {
10.59 + return PREFERRED_ID;
10.60 + }
10.61 +
10.62 + public int getPersistenceType() {
10.63 + return TopComponent.PERSISTENCE_ONLY_OPENED;
10.64 + }
10.65 +
10.66 + public java.awt.Image getIcon() {
10.67 + return Utilities.loadImage(PlanDataObject.IEP_ICON_BASE_WITH_EXT);
10.68 + }
10.69 +
10.70 + public org.openide.util.HelpCtx getHelpCtx() {
10.71 + return org.openide.util.HelpCtx.DEFAULT_HELP;
10.72 + }
10.73 +
10.74 + public String getDisplayName() {
10.75 + return NbBundle.getMessage(PlanDesignViewMultiViewDesc.class, "LBL_sourceView_name");
10.76 + }
10.77 +
10.78 + public org.netbeans.core.spi.multiview.MultiViewElement createElement() {
10.79 + PlanEditorSupport editorSupport = wsdlDataObject.getPlanEditorSupport();
10.80 + if (editorSupport != null) {
10.81 + PlanSourceMultiViewElement editorComponent = new PlanSourceMultiViewElement(wsdlDataObject);
10.82 + return editorComponent;
10.83 + }
10.84 + return MultiViewFactory.BLANK_ELEMENT;
10.85 +
10.86 + }
10.87 +
10.88 + public void writeExternal(ObjectOutput out) throws IOException {
10.89 + out.writeObject(wsdlDataObject);
10.90 + }
10.91 +
10.92 + public void readExternal(ObjectInput in)
10.93 + throws IOException, ClassNotFoundException
10.94 + {
10.95 + Object firstObject = in.readObject();
10.96 + if (firstObject instanceof PlanDataObject)
10.97 + wsdlDataObject = (PlanDataObject) firstObject;
10.98 + }
10.99 +
10.100 +}