Return-Path: X-Original-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BA3DE9E4E for ; Fri, 27 Jan 2012 01:31:43 +0000 (UTC) Received: (qmail 43715 invoked by uid 500); 27 Jan 2012 01:31:43 -0000 Delivered-To: apmail-incubator-ooo-commits-archive@incubator.apache.org Received: (qmail 43678 invoked by uid 500); 27 Jan 2012 01:31:43 -0000 Mailing-List: contact ooo-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ooo-dev@incubator.apache.org Delivered-To: mailing list ooo-commits@incubator.apache.org Received: (qmail 43671 invoked by uid 99); 27 Jan 2012 01:31:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jan 2012 01:31:43 +0000 X-ASF-Spam-Status: No, hits=-1998.0 required=5.0 tests=ALL_TRUSTED,FB_GET_MEDS X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jan 2012 01:31:39 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9A2062388C56; Fri, 27 Jan 2012 01:30:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1236486 [28/43] - in /incubator/ooo/devtools/netbeansintegration: ./ build/ build/public-package-jars/ javahelp/ javahelp/org/ javahelp/org/openoffice/ javahelp/org/openoffice/extensions/ javahelp/org/openoffice/extensions/docs/ javahelp/o... Date: Fri, 27 Jan 2012 01:29:58 -0000 To: ooo-commits@incubator.apache.org From: arist@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120127013025.9A2062388C56@eris.apache.org> Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/datamodel/types/node/ComponentTypeCustomEditor.java URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/datamodel/types/node/ComponentTypeCustomEditor.java?rev=1236486&view=auto ============================================================================== --- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/datamodel/types/node/ComponentTypeCustomEditor.java (added) +++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/datamodel/types/node/ComponentTypeCustomEditor.java Fri Jan 27 01:29:33 2012 @@ -0,0 +1,342 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ComponentTypeCustomEditor.java,v $ + * + * $Revision: 1.9 $ + * + * last change: $Author: sg $ $Date: 2009/07/06 14:51:29 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +package org.openoffice.extensions.projecttemplates.component.datamodel.types.node; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.beans.PropertyVetoException; +import java.beans.VetoableChangeListener; +import java.util.StringTokenizer; +import javax.swing.DefaultComboBoxModel; +import javax.swing.tree.TreeSelectionModel; +import org.openide.explorer.ExplorerManager; +import org.openide.explorer.propertysheet.PropertyEnv; +import org.openide.explorer.propertysheet.editors.EnhancedCustomPropertyEditor; +import org.openide.explorer.view.BeanTreeView; +import org.openide.nodes.Node; +import org.openide.util.NbBundle; +import org.openoffice.extensions.projecttemplates.component.ComponentWizardIterator; +import org.openoffice.extensions.util.LogWriter; +import org.openoffice.extensions.util.datamodel.NbNodeObject; +import org.openoffice.extensions.util.datamodel.PolyStruct; +import org.openoffice.extensions.util.datamodel.PropertyContainer; +import org.openoffice.extensions.util.datamodel.properties.UnknownOpenOfficeOrgPropertyException; +import org.openoffice.extensions.util.typebrowser.logic.UnoTypes; +import org.openoffice.extensions.util.typebrowser.logic.TypeBrowserChildren; +import org.openoffice.extensions.util.typebrowser.logic.TypeNode; + +/** + * + * @author sg128468 + */ +public class ComponentTypeCustomEditor extends javax.swing.JPanel + implements ExplorerManager.Provider, PropertyChangeListener, + VetoableChangeListener, EnhancedCustomPropertyEditor { + + private ExplorerManager manager = new ExplorerManager(); + private PropertyEnv propertyEnv; + private ComponentTypePropertyEditor editor; + +// private String selectedType; + private TypeNode rootNode; + + // the return type, set into the editor + private String type; + + /** Creates new form ComponentTypeCustomEditor */ + public ComponentTypeCustomEditor(ComponentTypePropertyEditor editor, + PropertyEnv propertyEnv) { + initComponents(); + type = ""; // NOI18N + this.propertyEnv = propertyEnv; + this.editor = editor; + propertyEnv.setState(PropertyEnv.STATE_INVALID); + propertyEnv.addVetoableChangeListener(this); + +// NbNodeObject[] addNodes = this.comp.getDesignedTypes(); + + // important: in the Resource Budle, entries for the type list + // must have this order: all, ifc, enum, struct, consts + this.rootNode = TypeNode.createRootNode( + new String[] { + UnoTypes.MODULE, + UnoTypes.INTERFACE, + UnoTypes.STRUCT, + UnoTypes.SIMPLE, +// TypeBrowser.ENUM, +// TypeBrowser.CONSTANTS, + } +// null + ); + +// 2do: use this later! +// FeatureDescriptor desc = propertyEnv.getFeatureDescriptor(); + + manager.setRootContext(rootNode); + BeanTreeView typeView = (BeanTreeView)jScrollPane1; + typeView.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + manager.addPropertyChangeListener(this); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + jScrollPane1 = new BeanTreeView(); + selectTypeComboBox = new javax.swing.JComboBox(); + jLabel1 = new javax.swing.JLabel(); + optionalCheckBox = new javax.swing.JCheckBox(); + ambiguousCheckBox = new javax.swing.JCheckBox(); + defaultedCheckBox = new javax.swing.JCheckBox(); + + jScrollPane1.setBackground(new java.awt.Color(255, 255, 255)); + jScrollPane1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + + selectTypeComboBox.setModel(new DefaultComboBoxModel(getComboBoxList())); + selectTypeComboBox.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + selectTypeActionPerformed(evt); + } + }); + + jLabel1.setLabelFor(selectTypeComboBox); + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, NbBundle.getMessage(ComponentWizardIterator.class, "LBL_DisplayType")); + + org.openide.awt.Mnemonics.setLocalizedText(optionalCheckBox, NbBundle.getMessage(ComponentWizardIterator.class, "LBL_optionalCheckBox")); + optionalCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); + optionalCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); + + org.openide.awt.Mnemonics.setLocalizedText(ambiguousCheckBox, NbBundle.getMessage(ComponentWizardIterator.class, "LBL_ambiguousCheckBox")); + ambiguousCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); + ambiguousCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); + + org.openide.awt.Mnemonics.setLocalizedText(defaultedCheckBox, NbBundle.getMessage(ComponentWizardIterator.class, "LBL_defaultedCheckBox")); + defaultedCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); + defaultedCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); + + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .addContainerGap() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() + .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(selectTypeComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 251, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE) + .add(layout.createSequentialGroup() + .add(optionalCheckBox) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 125, Short.MAX_VALUE) + .add(ambiguousCheckBox) + .add(114, 114, 114) + .add(defaultedCheckBox))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .addContainerGap() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(selectTypeComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(jLabel1)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 167, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(optionalCheckBox) + .add(defaultedCheckBox) + .add(ambiguousCheckBox)) + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void selectTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectTypeActionPerformed + + int index = selectTypeComboBox.getSelectedIndex(); + switch (index) { + case 1: + TypeNode.setDisplayedTypes(new String[]{UnoTypes.INTERFACE}); + break; + case 2: + TypeNode.setDisplayedTypes(new String[]{UnoTypes.STRUCT}); + break; + case 3: + TypeNode.setDisplayedTypes(new String[]{UnoTypes.CONSTANTS}); + break; + default: // default: show all + TypeNode.setDisplayedTypes(new String[]{ + UnoTypes.INTERFACE, + UnoTypes.SIMPLE, + UnoTypes.STRUCT, +// TypeBrowser.ENUM, +// TypeBrowser.CONSTANTS, + }); + } + // update UI + Node node = manager.getExploredContext(); + if (node == null) { + node = manager.getRootContext(); + } + TypeBrowserChildren tbc = (TypeBrowserChildren)node.getChildren(); + tbc.update(); + + }//GEN-LAST:event_selectTypeActionPerformed + + public ExplorerManager getExplorerManager() { + return manager; + } + + public void propertyChange(PropertyChangeEvent evt) { + Node[] nodes = manager.getSelectedNodes(); + if (nodes != null && nodes.length > 0) { + TypeNode node = (TypeNode)nodes[0]; // single tree selection + + if (node.getNodeType() != UnoTypes.MODULE_TYPE) { // do not add modules to this type +// selectedType = getSelectedType(); + propertyEnv.setState(PropertyEnv.STATE_NEEDS_VALIDATION); + } + else { +// selectedType = null; + propertyEnv.setState(PropertyEnv.STATE_INVALID); + } + } + } + + public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException { + if (PropertyEnv.PROP_STATE.equals(evt.getPropertyName()) && + PropertyEnv.STATE_VALID.equals(evt.getNewValue()) && + PropertyEnv.STATE_NEEDS_VALIDATION.equals(evt.getOldValue())) { // OK pressed + getSelectedTypeName(); + Node[] nodes = manager.getSelectedNodes(); + if (nodes != null && nodes.length > 0) { + TypeNode node = (TypeNode)nodes[0]; // single tree selection + if (node.getNodeType() == UnoTypes.POLY_STRUCT_TYPE) { + NbNodeObject[] nodeObjects = node.getDesignedTypes(); + if (nodeObjects != null) { + NbNodeObject polyStructObject = getOwnType(type, nodeObjects); + if (polyStructObject != null) { + PolyStruct plStruct = (PolyStruct)polyStructObject; + NewTemplateTypesDialog.start(editor, plStruct); + } + else { + // 2do for office poly struct types + } + } + } + else { + editor.setValue(type); + } + } + } + } + + public Object getPropertyValue() throws IllegalStateException { + getSelectedTypeName(); + return type; + } + +// public void addTemplateTypes(String polyStructTypes) { +// this.type = polyStructTypes; +// } + + private NbNodeObject getOwnType(String type, NbNodeObject[] nodeObjects) { + // get own tyope from list + for (int i=0; i 0) { + TypeNode node = (TypeNode)nodes[0]; // single tree selection + + if (node.getNodeType() != UnoTypes.MODULE_TYPE) { // do not add modules to this type + type = node.getHierarchicalName(); + } + } + if (optionalCheckBox.isSelected()) { + // add optional poly struct + type = "com.sun.star.beans.Optional< ".concat(type).concat(" >"); // NOI18N + } + if (ambiguousCheckBox.isSelected()) { + // ad ambiguous poly struct + type = "com.sun.star.beans.Ambiguous< ".concat(type).concat(" >"); // NOI18N + } + if (defaultedCheckBox.isSelected()) { + // ad defaulted poly struct + type = "com.sun.star.beans.Defaulted< ".concat(type).concat(" >"); // NOI18N + } + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JCheckBox ambiguousCheckBox; + private javax.swing.JCheckBox defaultedCheckBox; + private javax.swing.JLabel jLabel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JCheckBox optionalCheckBox; + private javax.swing.JComboBox selectTypeComboBox; + // End of variables declaration//GEN-END:variables + + +} Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/datamodel/types/node/ComponentTypeNode.java URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/datamodel/types/node/ComponentTypeNode.java?rev=1236486&view=auto ============================================================================== --- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/datamodel/types/node/ComponentTypeNode.java (added) +++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/datamodel/types/node/ComponentTypeNode.java Fri Jan 27 01:29:33 2012 @@ -0,0 +1,190 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ComponentTypeNode.java,v $ + * + * $Revision: 1.5 $ + * + * last change: $Author: sg $ $Date: 2009/07/06 14:51:29 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +package org.openoffice.extensions.projecttemplates.component.datamodel.types.node; + +import java.awt.Image; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import javax.swing.Action; +import org.openide.nodes.AbstractNode; +import org.openide.nodes.Children; +import org.openide.nodes.Node; +import org.openide.nodes.Node.Property; +import org.openide.nodes.Sheet; +import org.openide.util.ImageUtilities; +import org.openide.util.lookup.Lookups; +//import org.openoffice.extensions.projecttemplates.calcaddin.AddinActions; +import org.openoffice.extensions.util.datamodel.Function; +import org.openoffice.extensions.util.datamodel.Interface; +import org.openoffice.extensions.util.datamodel.NbNodeObject; +import org.openoffice.extensions.util.datamodel.PropertyContainer; +import org.openoffice.extensions.util.datamodel.actions.BaseAction; + +/** + * + * @author sg128468 + */ +public class ComponentTypeNode extends AbstractNode implements PropertyChangeListener { + + Action[] actions; + + // node has subnodes + public static final String NODE_ICON = + "org/openoffice/extensions/projecttemplates/component/icons/method.png"; // NOI18N + public static final String PARAMETER_ICON = + "org/openoffice/extensions/projecttemplates/component/icons/parameter.png"; // NOI18N + public static final String SIMPLE_ICON = + "org/openoffice/extensions/projecttemplates/component/icons/name.png"; // NOI18N +// public static final String DESC_ICON = +// "org/openoffice/extensions/projecttemplates/component/icons/description.png"; // NOI18N + public static final String INTERFACE_ICON = + "org/openoffice/extensions/projecttemplates/component/icons/interface.png"; // NOI18N + + public ComponentTypeNode(NbNodeObject obj, Children children) { + super (children, Lookups.singleton(obj)); + if (obj.hasActions(NbNodeObject.COMPONENT_TYPE)) { + actions = obj.getActions(false); + } + } + + public ComponentTypeNode() { + super (new ComponentTypeChildren()); + setDisplayName ("Root"); // NOI18N + } + + public Image getIcon (int type) { + String icon = SIMPLE_ICON; + Object o = this.getLookup().lookup(NbNodeObject.class); + if (o instanceof PropertyContainer) { + if (o instanceof Function) { + icon = NODE_ICON; + } + else if (o instanceof Interface) { + icon = INTERFACE_ICON; + } + else { + icon = PARAMETER_ICON; + } + } + return ImageUtilities.loadImage(icon); + } + + public String getDisplayName() { + NbNodeObject object = (NbNodeObject)getLookup().lookup(NbNodeObject.class); + String displayName = object.getDisplayName(); +// if (displayName.equals(super.getDisplayName())) { +// return displayName; +// } +// setDisplayName(displayName); + return displayName; + } + + public Image getOpenedIcon (int type) { + return getIcon(type); + } + + public Action[] getActions(boolean context) { + if (actions == null) + return super.getActions(context); + return actions; + } + + /** + * set AddinActions into the actions of this node, the AddinActions + * are used to perform the actions available in the context menu of the node + */ + public void setActions(BaseAction baseActions) { + if (actions != null) { + NbNodeObject o = (NbNodeObject)this.getLookup().lookup(NbNodeObject.class); + // if the object should have actions for this type, + // give to it the base action class to wrap + if (o.hasActions(NbNodeObject.COMPONENT_TYPE)) { + // rename setActions to something less confusing? + o.setActions(baseActions); + } + } + Node[] subnodes = this.getChildren().getNodes(); + for (int i=0; itemplTypes = new Vector(); + for (int i=0; i + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/datamodel/types/node/NewTemplateTypesDialog.java URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/datamodel/types/node/NewTemplateTypesDialog.java?rev=1236486&view=auto ============================================================================== --- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/datamodel/types/node/NewTemplateTypesDialog.java (added) +++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/datamodel/types/node/NewTemplateTypesDialog.java Fri Jan 27 01:29:33 2012 @@ -0,0 +1,172 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: NewTemplateTypesDialog.java,v $ + * + * $Revision: 1.3 $ + * + * last change: $Author: sg $ $Date: 2007/08/15 13:45:11 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +package org.openoffice.extensions.projecttemplates.component.datamodel.types.node; + +import java.awt.Dialog; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.beans.FeatureDescriptor; +import org.openide.DialogDescriptor; +import org.openide.DialogDisplayer; +import org.openide.explorer.ExplorerManager; +import org.openide.explorer.propertysheet.PropertySheet; +import org.openide.nodes.Node; +import org.openide.util.NbBundle; +import org.openoffice.extensions.projecttemplates.component.ComponentWizardIterator; +import org.openoffice.extensions.util.LogWriter; +import org.openoffice.extensions.util.datamodel.NbNodeObject; +import org.openoffice.extensions.util.datamodel.PolyStruct; +import org.openoffice.extensions.util.datamodel.TemplateType; +import org.openoffice.extensions.util.datamodel.properties.SimpleOpenOfficeOrgProperty; +import org.openoffice.extensions.util.datamodel.properties.UnknownOpenOfficeOrgPropertyException; + +/** + * + * @author sg128468 + */ +public class NewTemplateTypesDialog extends javax.swing.JPanel + implements ExplorerManager.Provider, ActionListener { + + + ExplorerManager manager = new ExplorerManager(); + + private PolyStruct plStruct; + private ComponentTypePropertyEditor editor; + + /** Creates new form NewTemplateTypesDialog */ + public NewTemplateTypesDialog(ComponentTypePropertyEditor editor, PolyStruct plStruct) { + this.editor = editor; + this.plStruct = plStruct; + initComponents(); + + Node node = (Node)IdlTypeTreeCreator.createTemplateNode(plStruct); + + manager.setRootContext(node); + + PropertySheet propSheet = (PropertySheet)jPanel1; + propSheet.setNodes(new Node[]{node}); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + jPanel1 = new PropertySheet(); + + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .addContainerGap() + .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE) + .addContainerGap()) + ); + }// //GEN-END:initComponents + + private void performOK() { + StringBuffer result = new StringBuffer(); + // write the information from this copy back to the editor + Node[] nodes = manager.getRootContext().getChildren().getNodes(); + try { + String structName = plStruct.getSimpleProperty(plStruct.PROPERTY_CONTAINER_PACKAGE).concat( + ".").concat(plStruct.getSimpleProperty(plStruct.PROPERTY_CONTAINER_NAME)); // NOI18N + result.append(structName).append("< "); // NOI18N + } catch (UnknownOpenOfficeOrgPropertyException ex) { + LogWriter.getLogWriter().printStackTrace(ex); + } + for (int i=0; i"); // NOI18N + FeatureDescriptor desc = editor.getPropertyEnv().getFeatureDescriptor(); + SimpleOpenOfficeOrgProperty.SimpleProperty prop = (SimpleOpenOfficeOrgProperty.SimpleProperty)desc; + editor.setAsText(result.toString()); + prop.setValue(result.toString()); + } + + /** + */ + public static void start(final ComponentTypePropertyEditor editor, + final PolyStruct plStruct) { + NewTemplateTypesDialog templTypes = new NewTemplateTypesDialog(editor, plStruct); + DialogDescriptor ddscr = new DialogDescriptor(templTypes, + NbBundle.getMessage(ComponentWizardIterator.class, "LBL_TemplateTypes_Title")); + + ddscr.setButtonListener(templTypes); + + Dialog d = DialogDisplayer.getDefault().createDialog(ddscr); + d.setVisible(true); + } + + public ExplorerManager getExplorerManager() { + return manager; + } + + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("OK")) { // NOI18N + performOK(); + } + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + // End of variables declaration//GEN-END:variables + +} Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/Bundle.properties URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/Bundle.properties?rev=1236486&view=auto ============================================================================== --- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/Bundle.properties (added) +++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/Bundle.properties Fri Jan 27 01:29:33 2012 @@ -0,0 +1,35 @@ +# Sample ResourceBundle properties file + +# NewDataTypedialog +LBL_Title_Create=Create New Data Type +LBL_Title_Edit=Edit Data Type +LBL_DataType=Data &Type +LBL_OK_Button=OK +LBL_Cancel_Button=Cancel + +# New InterfaceDataTypePanel +LBL_Button_NewFunction=New &Function +LBL_Button_NewParameter=New &Parameter + +# Poly Struct Data Type +LBL_Button_AddTemplate=&Add Template +LBL_Button_AddMember=Add &Member +LBL_Button_Delete=&Delete + +# Service Data Type +LBL_Error_Interface=You must include an interface to this service. + +# PolyStruct Data Type +LBL_Error_Template=There must be at least one template type. + +# Struct Data Type +LBL_Error_Struct=There must be at least one struct type. + +#Enumeration data type +LBL_Error_Enum=There must be at least one enum type. + +# general +LBL_Error_Name=This type must have a name and a package. +LBL_ButtonNewFunction= + +LBL_ButtonDelete=&Delete Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/Bundle_ja.properties URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/Bundle_ja.properties?rev=1236486&view=auto ============================================================================== --- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/Bundle_ja.properties (added) +++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/Bundle_ja.properties Fri Jan 27 01:29:33 2012 @@ -0,0 +1,55 @@ +# Sample ResourceBundle properties file + +# NewDataTypedialog +# LBL_Title_Create=Create New Data Type +LBL_Title_Create=\u65b0\u898f\u30c7\u30fc\u30bf\u578b\u3092\u4f5c\u6210 +# LBL_Title_Edit=Edit Data Type +LBL_Title_Edit=\u30c7\u30fc\u30bf\u578b\u3092\u7de8\u96c6 +# LBL_DataType=Data &Type +LBL_DataType=\u30c7\u30fc\u30bf\u578b(&T) +# LBL_OK_Button=OK +LBL_OK_Button=\u4e86\u89e3 +# LBL_Cancel_Button=Cancel +LBL_Cancel_Button=\u53d6\u6d88\u3057 + +# New InterfaceDataTypePanel +# LBL_Button_NewFunction=New &Function +LBL_Button_NewFunction=\u65b0\u898f\u95a2\u6570(&F) +# LBL_Button_NewParameter=New &Parameter +LBL_Button_NewParameter=\u65b0\u898f\u30d1\u30e9\u30e1\u30fc\u30bf(&P) + +# Poly Struct Data Type +# LBL_Button_AddTemplate=&Add Template +LBL_Button_AddTemplate=\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u8ffd\u52a0(&A) +# LBL_Button_AddMember=Add &Member +LBL_Button_AddMember=\u30e1\u30f3\u30d0\u30fc\u3092\u8ffd\u52a0(&M) +# LBL_Button_Delete=&Delete +LBL_Button_Delete=\u524a\u9664(&D) + +# Service Data Type +# LBL_Error_Interface=You must include an interface to this service. +LBL_Error_Interface=\u3053\u306e\u30b5\u30fc\u30d3\u30b9\u306b\u30a4\u30f3\u30bf\u30d5\u30a7\u30fc\u30b9\u3092\u542b\u3081\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 + +# PolyStruct Data Type +# LBL_Error_Template=There must be at least one template type. +LBL_Error_Template=\u5c11\u306a\u304f\u3068\u3082 1 \u3064\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u578b\u304c\u5fc5\u8981\u3067\u3059\u3002 + +# Struct Data Type +# LBL_Error_Struct=There must be at least one struct type. +LBL_Error_Struct=\u5c11\u306a\u304f\u3068\u3082 1 \u3064\u306e\u69cb\u9020\u4f53\u306e\u578b\u304c\u5fc5\u8981\u3067\u3059\u3002 + +#Enumeration data type +# LBL_Error_Enum=There must be at least one enum type. +LBL_Error_Enum=\u5c11\u306a\u304f\u3068\u3082 1 \u3064\u306e\u5217\u6319\u578b\u304c\u5fc5\u8981\u3067\u3059\u3002 + + +# general +# LBL_Error_Name=This type must have a name and a package. +LBL_Error_Name=\u3053\u306e\u578b\u306b\u306f\u3001\u540d\u524d\u3068\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u5fc5\u8981\u3067\u3059\u3002 +# LBL_ButtonNewFunction= +LBL_ButtonNewFunction= + +# LBL_ButtonDelete=&Delete +LBL_ButtonDelete=\u524a\u9664(&D) + + Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/Bundle_pt_BR.properties URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/Bundle_pt_BR.properties?rev=1236486&view=auto ============================================================================== --- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/Bundle_pt_BR.properties (added) +++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/Bundle_pt_BR.properties Fri Jan 27 01:29:33 2012 @@ -0,0 +1,35 @@ +# Sample ResourceBundle properties file + +# NewDataTypedialog +LBL_Title_Create=Create New Data Type +LBL_Title_Edit=Edit Data Type +LBL_DataType=Data &Type +LBL_OK_Button=OK +LBL_Cancel_Button=Cancel + +# New InterfaceDataTypePanel +LBL_Button_NewFunction=New &Function +LBL_Button_NewParameter=New &Parameter + +# Poly Struct Data Type +LBL_Button_AddTemplate=&Add Template +LBL_Button_AddMember=Add &Member +LBL_Button_Delete=&Delete + +# Service Data Type +LBL_Error_Interface=You must include an interface to this service. + +# PolyStruct Data Type +LBL_Error_Template=There must be at least one template type. + +# Struct Data Type +LBL_Error_Struct=There must be at least one struct type. + +#Enumeration data type +LBL_Error_Enum=There must be at least one enum type. + +# general +LBL_Error_Name=This type must have a name and a package. +LBL_ButtonNewFunction= + +LBL_ButtonDelete=&Delete Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/Bundle_zh_CN.properties URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/Bundle_zh_CN.properties?rev=1236486&view=auto ============================================================================== --- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/Bundle_zh_CN.properties (added) +++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/Bundle_zh_CN.properties Fri Jan 27 01:29:33 2012 @@ -0,0 +1,35 @@ +# Sample ResourceBundle properties file + +# NewDataTypedialog +LBL_Title_Create=\u521b\u5efa\u65b0\u7684\u6570\u636e\u7c7b\u578b +LBL_Title_Edit=\u7f16\u8f91\u6570\u636e\u7c7b\u578b +LBL_DataType=\u6570\u636e\u7c7b\u578b(&T) +LBL_OK_Button=\u786e\u5b9a +LBL_Cancel_Button=\u53d6\u6d88 + +# New InterfaceDataTypePanel +LBL_Button_NewFunction=\u65b0\u5efa\u51fd\u6570(&F) +LBL_Button_NewParameter=\u65b0\u5efa\u53c2\u6570(&P) + +# Poly Struct Data Type +LBL_Button_AddTemplate=\u6dfb\u52a0\u6a21\u677f(&A) +LBL_Button_AddMember=\u6dfb\u52a0\u6210\u5458(&M) +LBL_Button_Delete=\u5220\u9664(&D) + +# Service Data Type +LBL_Error_Interface=\u5fc5\u987b\u5728\u6b64\u670d\u52a1\u4e2d\u5305\u542b\u4e00\u4e2a\u63a5\u53e3\u3002 + +# PolyStruct Data Type +LBL_Error_Template=\u5fc5\u987b\u81f3\u5c11\u5177\u6709\u4e00\u4e2a\u6a21\u677f\u7c7b\u578b\u3002 + +# Struct Data Type +LBL_Error_Struct=\u5fc5\u987b\u81f3\u5c11\u5177\u6709\u4e00\u4e2a\u7ed3\u6784\u7c7b\u578b\u3002 + +#Enumeration data type +LBL_Error_Enum=\u5fc5\u987b\u81f3\u5c11\u5177\u6709\u4e00\u4e2a\u679a\u4e3e\u7c7b\u578b\u3002 + +# general +LBL_Error_Name=\u6b64\u7c7b\u578b\u5fc5\u987b\u5177\u6709\u540d\u79f0\u548c\u5305\u3002 +LBL_ButtonNewFunction= + +LBL_ButtonDelete=\u5220\u9664(&D) Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/ChangeEventPanel.java URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/ChangeEventPanel.java?rev=1236486&view=auto ============================================================================== --- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/ChangeEventPanel.java (added) +++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/ChangeEventPanel.java Fri Jan 27 01:29:33 2012 @@ -0,0 +1,44 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChangeEventPanel.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sg $ $Date: 2007/04/24 10:08:26 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +package org.openoffice.extensions.projecttemplates.component.dialogs; + +/** + * + * @author sg128468 + */ +public interface ChangeEventPanel { + public void fireChangeEvent(); +} Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/DialogProperties.java URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/DialogProperties.java?rev=1236486&view=auto ============================================================================== --- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/DialogProperties.java (added) +++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/DialogProperties.java Fri Jan 27 01:29:33 2012 @@ -0,0 +1,137 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DialogProperties.java,v $ + * + * $Revision: 1.6 $ + * + * last change: $Author: sg $ $Date: 2009/07/06 14:51:27 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +package org.openoffice.extensions.projecttemplates.component.dialogs; + +import java.util.HashMap; +import org.openoffice.extensions.util.LogWriter; + +/** + * + * @author sg128468 + */ +public class DialogProperties { + + public final static String EDIT = "EDIT"; // edit or new // NOI18N + public final static String NODE = "NODE"; // the node for editing; null when new // NOI18N + public final static String PKG = "PKG"; // the initial package suggestion // NOI18N + public final static String SRV = "SRV"; // the initial service name suggestion // NOI18N + public final static String IFC = "IFC"; // the initial interface suggestion // NOI18N + public final static String NAME = "NAME"; // the initial name suggestion // NOI18N + public final static String ALLOW_SELECTION = "ALLOW_SELECTION"; // allow selection of the type: no for wizard // NOI18N + public final static String SELECTION = "SELECTION"; // selected item as String[]: if no selection allowed, only item that's created or edited // NOI18N + public final static String PANEL = "PANEL"; // the panel to trigger updates // NOI18N + public final static String DATA_TYPE = "TYPE"; // a DataType integer type: mandatory // NOI18N + + private HashMap properties; + + /** Creates a new instance of DialogProperties */ + public DialogProperties() { + this(new OneDataType[0]); + } + + /** Creates a new instance of DialogProperties with properties*/ + public DialogProperties(OneDataType[]types) { + properties = new HashMap(); + // default props, may be overwritten + setDefaultProps(); + for (int i=0; i(EDIT, Boolean.TRUE)); + properties.put(ALLOW_SELECTION, new OneDataType(ALLOW_SELECTION, Boolean.FALSE)); + } + // consistency: if edit, then no selection allowed! + else if (getBooleanProperty(EDIT)) { + properties.put(ALLOW_SELECTION, new OneDataType(ALLOW_SELECTION, Boolean.FALSE)); + if (getProperty(NODE) == null) { // this is critical + LogWriter.getLogWriter().log(LogWriter.LEVEL_CRITICAL, "NODE is not set for editing it."); // NOI18N + } + } + if (getProperty(DATA_TYPE) == null) { + LogWriter.getLogWriter().log(LogWriter.LEVEL_CRITICAL, "No data type set for the plugged panel in NewDataTypeBaseDialog."); // NOI18N + } + } + + public Object getProperty(String key) { + OneDataType type = properties.get(key); + if (type == null) return null; + return type.o; + } + + public boolean getBooleanProperty(String key) { + @SuppressWarnings( value="unchecked" ) + OneDataType b = properties.get(key); + return b.o.booleanValue(); + } + + public int getIntProperty(String key) { + @SuppressWarnings( value="unchecked" ) + OneDataType b = properties.get(key); + return b.o.intValue(); + } + + public String getStringProperty(String key) { + @SuppressWarnings( value="unchecked" ) + OneDataType s = properties.get(key); + if (s == null) return null; + return s.o; + } + + public void setProperty(OneDataType value) { + properties.put(value.n, value); + } + + private void setDefaultProps() { + // no selection allowed + properties.put(ALLOW_SELECTION, new OneDataType(ALLOW_SELECTION, Boolean.FALSE)); + // set string as "null pointer exception" precaution: should be overwritten + properties.put(SELECTION, new OneDataType(SELECTION, new String[]{""})); // NOI18N + // default is create, not edit + properties.put(EDIT, new OneDataType(EDIT, Boolean.FALSE)); + } + + public static class OneDataType { + public OneDataType(String name, T object) { + n = name; + o = object; + } + protected T o; + protected String n; + } +} Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/EnumDataTypePanel.form URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/EnumDataTypePanel.form?rev=1236486&view=auto ============================================================================== --- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/EnumDataTypePanel.form (added) +++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/EnumDataTypePanel.form Fri Jan 27 01:29:33 2012 @@ -0,0 +1,112 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/EnumDataTypePanel.java URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/EnumDataTypePanel.java?rev=1236486&view=auto ============================================================================== --- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/EnumDataTypePanel.java (added) +++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/EnumDataTypePanel.java Fri Jan 27 01:29:33 2012 @@ -0,0 +1,255 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: EnumDataTypePanel.java,v $ + * + * $Revision: 1.4 $ + * + * last change: $Author: sg $ $Date: 2007/08/15 13:45:12 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +package org.openoffice.extensions.projecttemplates.component.dialogs; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.MissingResourceException; +import javax.swing.tree.TreeSelectionModel; +import org.openide.explorer.ExplorerManager; +import org.openide.explorer.propertysheet.PropertySheet; +import org.openide.explorer.view.BeanTreeView; +import org.openide.nodes.Node; +import org.openide.util.Lookup; +import org.openide.util.NbBundle; +import org.openoffice.extensions.projecttemplates.component.*; +import org.openoffice.extensions.projecttemplates.component.datamodel.types.node.IdlTypeTreeCreator; +import org.openoffice.extensions.util.LogWriter; +import org.openoffice.extensions.util.datamodel.IdlEnumeration; +import org.openoffice.extensions.util.datamodel.NbNodeObject; +import org.openoffice.extensions.util.datamodel.properties.UnknownOpenOfficeOrgPropertyException; + +/** + * + * @author sg128468 + */ +public class EnumDataTypePanel extends javax.swing.JPanel + implements ExplorerManager.Provider, PropertyChangeListener { + + private static final String ICON_PATH = "org/openoffice/extensions/projecttemplates/calcaddin/icons/netbeans.png"; // NOI18N + private ExplorerManager manager = new ExplorerManager(); + private PropertySheet propSheet; + private Node node; + + private Lookup lookup; + private ChangeEventPanel panel; + // all actions that can be done here + private ComponentActions actions; + private String oldName; + private boolean edit; + + private ValidateDataType dialog; + + /** + * Creates new form InterfaceDataTypeDialog + */ + public EnumDataTypePanel(ValidateDataType dialog, DialogProperties props) { + + initComponents(); + this.edit = props.getBooleanProperty(props.EDIT); + this.panel = (ChangeEventPanel)props.getProperty(props.PANEL); + this.actions = new ComponentActions(manager, panel); + this.dialog = dialog; + + String pkgName = props.getStringProperty(props.PKG); + String name = props.getStringProperty(props.NAME); + + if (edit) { + node = (Node)props.getProperty(props.NODE); + NbNodeObject ob = (NbNodeObject)node.getLookup().lookup(NbNodeObject.class); + oldName = ob.getDisplayName(); + } + else { + if (name == null) name = "Enum"; // NOI18N + node = (Node)IdlTypeTreeCreator.createInitialEnumTree(name, pkgName); + } + manager.setRootContext(node); + + manager.addPropertyChangeListener(this); + + propSheet = (PropertySheet)jPanel1; + propSheet.setNodes(new Node[]{node}); + + BeanTreeView componentView = (BeanTreeView)jScrollPane1; + componentView.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + + /* + actions = new ComponentActions(manager, panel); + + // for keyboard actions enable this: handle actions must be done, too + ActionMap map = jSplitPane1.getActionMap(); + map.put("delete", ExplorerUtils.actionDelete(manager, true)); // NOI18N + + lookup = ExplorerUtils.createLookup(manager, map); + + actions = new AddinActions(manager, panel, this); + + // deliver the actual actions to the node-actions + Node rootNode = manager.getRootContext(); + rootNode.setActions(actions); */ + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + jSplitPane1 = new javax.swing.JSplitPane(); + jPanel1 = new PropertySheet(); + jScrollPane1 = new BeanTreeView(); + addEnumJButton = new javax.swing.JButton(); + deleteJButton = new javax.swing.JButton(); + + jSplitPane1.setDividerLocation(200); + jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + jSplitPane1.setRightComponent(jPanel1); + + jScrollPane1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + jSplitPane1.setLeftComponent(jScrollPane1); + + org.openide.awt.Mnemonics.setLocalizedText(addEnumJButton, NbBundle.getMessage(ComponentWizardIterator.class, "LBL_Button_AddEnum")); + addEnumJButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + addFunctionActionPerformed(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(deleteJButton, NbBundle.getMessage(ComponentWizardIterator.class, "LBL_ButtonDelete")); + deleteJButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + deleteActionPerformed(evt); + } + }); + + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() + .add(jSplitPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 569, Short.MAX_VALUE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) + .add(deleteJButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(addEnumJButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .add(addEnumJButton) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(deleteJButton) + .addContainerGap(254, Short.MAX_VALUE)) + .add(jSplitPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 316, Short.MAX_VALUE) + ); + }// //GEN-END:initComponents + + private void deleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteActionPerformed + + actions.deleteActions(); + + }//GEN-LAST:event_deleteActionPerformed + + private void addFunctionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addFunctionActionPerformed + + actions.addEnumAction(); + + }//GEN-LAST:event_addFunctionActionPerformed + + public ExplorerManager getExplorerManager() { + return this.manager; + } + + public Lookup getLookup() { + return this.lookup; + } + + public void propertyChange(PropertyChangeEvent evt) { + Node[] selectedNodes = manager.getSelectedNodes(); + if (selectedNodes != null && selectedNodes.length == 1) { + propSheet.setNodes(selectedNodes); + NbNodeObject nodeObject = (NbNodeObject)selectedNodes[0].getLookup().lookup(NbNodeObject.class); + if (nodeObject.getType() == NbNodeObject.PROPERTY_TYPE){ + deleteJButton.setEnabled(false); + addEnumJButton.setEnabled(false); + } + else if (nodeObject.getType() == NbNodeObject.PARAMETER_TYPE) { + deleteJButton.setEnabled(true); + addEnumJButton.setEnabled(true); + } + else { + deleteJButton.setEnabled(false); + addEnumJButton.setEnabled(true); + } + } + valid(); +// panel.fireChangeEvent(); // Notify that the panel changed + } + + private void valid() { + NbNodeObject ob = (NbNodeObject)node.getLookup().lookup(NbNodeObject.class); + IdlEnumeration en = (IdlEnumeration)ob; + try { + if (en.getSimpleProperty(en.PROPERTY_CONTAINER_NAME).length() == 0 || + en.getSimpleProperty(en.PROPERTY_CONTAINER_PACKAGE).length() == 0) { + dialog.setEnableError(true, + NbBundle.getMessage(NewDataTypeBasePanel.class, "LBL_Error_Name")); + return; + } + else if (en.getAllSubObjects().length == 0) { + dialog.setEnableError(true, + NbBundle.getMessage(NewDataTypeBasePanel.class, "LBL_Error_Enum")); + return; + } + } catch (MissingResourceException ex) { + LogWriter.getLogWriter().printStackTrace(ex); + } catch (UnknownOpenOfficeOrgPropertyException ex) { + LogWriter.getLogWriter().printStackTrace(ex); + } + dialog.setEnableError(false, null); + } + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton addEnumJButton; + private javax.swing.JButton deleteJButton; + private javax.swing.JPanel jPanel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JSplitPane jSplitPane1; + // End of variables declaration//GEN-END:variables + +} Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/ExceptionDataTypePanel.form URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/ExceptionDataTypePanel.form?rev=1236486&view=auto ============================================================================== --- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/ExceptionDataTypePanel.form (added) +++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/projecttemplates/component/dialogs/ExceptionDataTypePanel.form Fri Jan 27 01:29:33 2012 @@ -0,0 +1,33 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +