You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ar...@apache.org on 2012/01/27 02:29:58 UTC
svn commit: r1236486 [6/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/or...
Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/ConfigurationPanel.form
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/ConfigurationPanel.form?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/ConfigurationPanel.form (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/ConfigurationPanel.form Fri Jan 27 01:29:33 2012
@@ -0,0 +1,276 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.3" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="jTextPane1" pref="487" max="32767" attributes="0"/>
+ <Component id="descriptionTextPane" pref="487" max="32767" attributes="1"/>
+ <Component id="sunLabel" pref="487" max="32767" attributes="1"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="sunLogoPanel" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <Component id="settingsPanel" alignment="0" max="32767" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Component id="sunLabel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="descriptionTextPane" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jTextPane1" min="-2" pref="51" max="-2" attributes="0"/>
+ </Group>
+ <Component id="sunLogoPanel" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="settingsPanel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace pref="15" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Container class="javax.swing.JPanel" name="settingsPanel">
+ <Properties>
+ <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+ <Color blue="ff" green="ff" red="ff" type="rgb"/>
+ </Property>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
+ <TitledBorder title="OpenOffice.org Settings">
+ <ResourceString PropertyName="titleX" bundle="org/openoffice/extensions/config/Bundle.properties" key="ConfigurationPanel_Title" replaceFormat="NbBundle.getMessage(ConfigurationPanel.class, "{key}")"/>
+ <Color PropertyName="color" blue="0" green="0" red="0" type="rgb"/>
+ </TitledBorder>
+ </Border>
+ </Property>
+ <Property name="opaque" type="boolean" value="false"/>
+ </Properties>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="jScrollPane1" alignment="1" pref="573" max="32767" attributes="0"/>
+ <Group type="102" alignment="1" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="officeLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="sdkLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="sdkTextField" pref="296" max="32767" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="browseButtonSDK" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="officeTextField" pref="296" max="32767" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Component id="browseButtonOffice" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="browseButtonOffice" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="officeTextField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="officeLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="browseButtonSDK" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="sdkLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="sdkTextField" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace pref="15" max="32767" attributes="0"/>
+ <Component id="jScrollPane1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="officeLabel">
+ <Properties>
+ <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
+ <ComponentRef name="officeTextField"/>
+ </Property>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/openoffice/extensions/config/Bundle.properties" key="LB_OfficeInstallation" replaceFormat="NbBundle.getMessage(ConfigurationPanel.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="sdkLabel">
+ <Properties>
+ <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
+ <ComponentRef name="sdkTextField"/>
+ </Property>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/openoffice/extensions/config/Bundle.properties" key="LB_SDKInstallation" replaceFormat="NbBundle.getMessage(ConfigurationPanel.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="officeTextField">
+ <Properties>
+ <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/openoffice/extensions/config/Bundle.properties" key="TF_OfficeInstallation_Tooltip" replaceFormat="NbBundle.getMessage(ConfigurationPanel.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="sdkTextField">
+ <Properties>
+ <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/openoffice/extensions/config/Bundle.properties" key="TF_SDKInstallation_Tooltip" replaceFormat="NbBundle.getMessage(ConfigurationPanel.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JButton" name="browseButtonOffice">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/openoffice/extensions/config/Bundle.properties" key="LBL_BUTTON_BrowseOffice" replaceFormat="NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/openoffice/extensions/config/Bundle.properties" key="BUTTON_Office_Browse" replaceFormat="NbBundle.getMessage(ConfigurationPanel.class, "{key}")"/>
+ </Property>
+ <Property name="actionCommand" type="java.lang.String" value="BROWSE_OFFICE"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="browseButtonOfficeActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="browseButtonSDK">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/openoffice/extensions/config/Bundle.properties" key="LBL_BUTTON_BrowseSDK" replaceFormat="NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/openoffice/extensions/config/Bundle.properties" key="BUTTON_SDK_Browse" replaceFormat="NbBundle.getMessage(ConfigurationPanel.class, "{key}")"/>
+ </Property>
+ <Property name="actionCommand" type="java.lang.String" value="BROWSE_SDK"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="browseButtonSDKActionPerformed"/>
+ </Events>
+ </Component>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+ <Properties>
+ <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+ <Color blue="ff" green="ff" red="ff" type="rgb"/>
+ </Property>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="null"/>
+ </Property>
+ <Property name="opaque" type="boolean" value="false"/>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JTextPane" name="errorTextPane">
+ <Properties>
+ <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+ <Color blue="ee" green="ee" red="ee" type="rgb"/>
+ </Property>
+ <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+ <Color blue="33" green="33" red="ff" type="rgb"/>
+ </Property>
+ <Property name="autoscrolls" type="boolean" value="false"/>
+ <Property name="focusable" type="boolean" value="false"/>
+ <Property name="requestFocusEnabled" type="boolean" value="false"/>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JTextPane" name="descriptionTextPane">
+ <Properties>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="null"/>
+ </Property>
+ <Property name="editable" type="boolean" value="false"/>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/openoffice/extensions/config/Bundle.properties" key="TP_InitialSettings_Description" replaceFormat="NbBundle.getMessage(ConfigurationPanel.class, "{key}")"/>
+ </Property>
+ <Property name="autoscrolls" type="boolean" value="false"/>
+ <Property name="opaque" type="boolean" value="false"/>
+ <Property name="requestFocusEnabled" type="boolean" value="false"/>
+ <Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="sunLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/openoffice/extensions/config/Bundle.properties" key="TP_InitialSettings_SunDevelopment" replaceFormat="NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Container class="javax.swing.JPanel" name="sunLogoPanel">
+ <Properties>
+ <Property name="opaque" type="boolean" value="false"/>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new SunLogoPanel();"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <EmptySpace min="0" pref="108" max="32767" attributes="0"/>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <EmptySpace min="0" pref="112" max="32767" attributes="0"/>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ </Container>
+ <Component class="javax.swing.JTextPane" name="jTextPane1">
+ <Properties>
+ <Property name="editable" type="boolean" value="false"/>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/openoffice/extensions/config/Bundle.properties" key="TP_LegalNotice" replaceFormat="NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ <Property name="opaque" type="boolean" value="false"/>
+ </Properties>
+ </Component>
+ </SubComponents>
+</Form>
Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/ConfigurationPanel.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/ConfigurationPanel.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/ConfigurationPanel.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/ConfigurationPanel.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,481 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ConfigurationPanel.java,v $
+ *
+ * $Revision: 1.20 $
+ *
+ * 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.config;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Rectangle;
+import java.awt.image.ImageObserver;
+import java.io.File;
+import javax.swing.JFileChooser;
+import javax.swing.JPanel;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.filechooser.FileSystemView;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.ImageUtilities;
+import org.openide.util.NbBundle;
+import org.openoffice.extensions.config.office.OpenOfficeLocation;
+import org.openoffice.extensions.config.office.PlatformInfo;
+
+final class ConfigurationPanel extends javax.swing.JPanel {
+
+ protected static final boolean VALIDATE_SDK = Boolean.TRUE;
+ protected static final boolean VALIDATE_OFFICE = Boolean.FALSE;
+
+ //private final ConfigurationOptionsPanelController controller;
+
+// ConfigurationPanel(ConfigurationOptionsPanelController controller) {
+// this.controller = controller;
+// initComponents();
+// // TODO listen to changes in form fields and call controller.changed()
+// }
+ ConfigurationPanel(String officeInstallation, String sdkInstallation) {
+ initComponents();
+ officeTextField.setText(officeInstallation);
+ sdkTextField.setText(sdkInstallation);
+
+ boolean threeLayerOffice = OpenOfficeLocation.isThreeLayerOffice(officeInstallation);
+ sdkTextField.setEnabled(!threeLayerOffice);
+ browseButtonSDK.setEnabled(!threeLayerOffice);
+
+ // initial error message
+ validate();
+
+ officeTextField.getDocument().addDocumentListener(new DocumentListenerImplementation(VALIDATE_OFFICE));
+ sdkTextField.getDocument().addDocumentListener(new DocumentListenerImplementation(VALIDATE_SDK));
+ }
+
+ /** 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.
+ */
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ settingsPanel = new javax.swing.JPanel();
+ officeLabel = new javax.swing.JLabel();
+ sdkLabel = new javax.swing.JLabel();
+ officeTextField = new javax.swing.JTextField();
+ sdkTextField = new javax.swing.JTextField();
+ browseButtonOffice = new javax.swing.JButton();
+ browseButtonSDK = new javax.swing.JButton();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ errorTextPane = new javax.swing.JTextPane();
+ descriptionTextPane = new javax.swing.JTextPane();
+ sunLabel = new javax.swing.JLabel();
+ sunLogoPanel = new SunLogoPanel();
+ jTextPane1 = new javax.swing.JTextPane();
+
+ settingsPanel.setBackground(new java.awt.Color(255, 255, 255));
+ settingsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, NbBundle.getMessage(ConfigurationPanel.class, "ConfigurationPanel_Title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 11), new java.awt.Color(0, 0, 0))); // NOI18N
+ settingsPanel.setOpaque(false);
+
+ officeLabel.setLabelFor(officeTextField);
+ org.openide.awt.Mnemonics.setLocalizedText(officeLabel, NbBundle.getMessage(ConfigurationPanel.class, "LB_OfficeInstallation")); // NOI18N
+
+ sdkLabel.setLabelFor(sdkTextField);
+ org.openide.awt.Mnemonics.setLocalizedText(sdkLabel, NbBundle.getMessage(ConfigurationPanel.class, "LB_SDKInstallation")); // NOI18N
+
+ officeTextField.setToolTipText(NbBundle.getMessage(ConfigurationPanel.class, "TF_OfficeInstallation_Tooltip")); // NOI18N
+
+ sdkTextField.setToolTipText(NbBundle.getMessage(ConfigurationPanel.class, "TF_SDKInstallation_Tooltip")); // NOI18N
+
+ org.openide.awt.Mnemonics.setLocalizedText(browseButtonOffice, NbBundle.getMessage(ConfigurationPanel.class, "LBL_BUTTON_BrowseOffice")); // NOI18N
+ browseButtonOffice.setToolTipText(NbBundle.getMessage(ConfigurationPanel.class, "BUTTON_Office_Browse")); // NOI18N
+ browseButtonOffice.setActionCommand("BROWSE_OFFICE");
+ browseButtonOffice.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ browseButtonOfficeActionPerformed(evt);
+ }
+ });
+
+ org.openide.awt.Mnemonics.setLocalizedText(browseButtonSDK, NbBundle.getMessage(ConfigurationPanel.class, "LBL_BUTTON_BrowseSDK")); // NOI18N
+ browseButtonSDK.setToolTipText(NbBundle.getMessage(ConfigurationPanel.class, "BUTTON_SDK_Browse")); // NOI18N
+ browseButtonSDK.setActionCommand("BROWSE_SDK");
+ browseButtonSDK.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ browseButtonSDKActionPerformed(evt);
+ }
+ });
+
+ jScrollPane1.setBackground(new java.awt.Color(255, 255, 255));
+ jScrollPane1.setBorder(null);
+ jScrollPane1.setOpaque(false);
+
+ errorTextPane.setBackground(new java.awt.Color(238, 238, 238));
+ errorTextPane.setForeground(new java.awt.Color(255, 51, 51));
+ errorTextPane.setAutoscrolls(false);
+ errorTextPane.setFocusable(false);
+ errorTextPane.setRequestFocusEnabled(false);
+ jScrollPane1.setViewportView(errorTextPane);
+
+ org.jdesktop.layout.GroupLayout settingsPanelLayout = new org.jdesktop.layout.GroupLayout(settingsPanel);
+ settingsPanel.setLayout(settingsPanelLayout);
+ settingsPanelLayout.setHorizontalGroup(
+ settingsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, settingsPanelLayout.createSequentialGroup()
+ .addContainerGap()
+ .add(settingsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 573, Short.MAX_VALUE)
+ .add(settingsPanelLayout.createSequentialGroup()
+ .add(settingsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(officeLabel)
+ .add(sdkLabel))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(settingsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(settingsPanelLayout.createSequentialGroup()
+ .add(sdkTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(browseButtonSDK))
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, settingsPanelLayout.createSequentialGroup()
+ .add(officeTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(browseButtonOffice)))))
+ .addContainerGap())
+ );
+ settingsPanelLayout.setVerticalGroup(
+ settingsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(settingsPanelLayout.createSequentialGroup()
+ .addContainerGap()
+ .add(settingsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(browseButtonOffice)
+ .add(officeTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(officeLabel))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(settingsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(browseButtonSDK)
+ .add(sdkLabel)
+ .add(sdkTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 15, Short.MAX_VALUE)
+ .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap())
+ );
+
+ descriptionTextPane.setBorder(null);
+ descriptionTextPane.setEditable(false);
+ descriptionTextPane.setText(NbBundle.getMessage(ConfigurationPanel.class, "TP_InitialSettings_Description")); // NOI18N
+ descriptionTextPane.setAutoscrolls(false);
+ descriptionTextPane.setOpaque(false);
+ descriptionTextPane.setRequestFocusEnabled(false);
+ descriptionTextPane.setVerifyInputWhenFocusTarget(false);
+
+ org.openide.awt.Mnemonics.setLocalizedText(sunLabel, NbBundle.getMessage(ConfigurationPanel.class, "TP_InitialSettings_SunDevelopment")); // NOI18N
+
+ sunLogoPanel.setOpaque(false);
+
+ org.jdesktop.layout.GroupLayout sunLogoPanelLayout = new org.jdesktop.layout.GroupLayout(sunLogoPanel);
+ sunLogoPanel.setLayout(sunLogoPanelLayout);
+ sunLogoPanelLayout.setHorizontalGroup(
+ sunLogoPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(0, 108, Short.MAX_VALUE)
+ );
+ sunLogoPanelLayout.setVerticalGroup(
+ sunLogoPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(0, 112, Short.MAX_VALUE)
+ );
+
+ jTextPane1.setEditable(false);
+ jTextPane1.setText(NbBundle.getMessage(ConfigurationPanel.class, "TP_LegalNotice")); // NOI18N
+ jTextPane1.setOpaque(false);
+
+ 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(layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jTextPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 487, Short.MAX_VALUE)
+ .add(descriptionTextPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 487, Short.MAX_VALUE)
+ .add(sunLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 487, Short.MAX_VALUE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(sunLogoPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .add(settingsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(sunLabel)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(descriptionTextPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jTextPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 51, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .add(sunLogoPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(settingsPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(15, Short.MAX_VALUE))
+ );
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void browseButtonSDKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonSDKActionPerformed
+ browseInstallationDirectory(evt.getActionCommand());
+ }//GEN-LAST:event_browseButtonSDKActionPerformed
+
+ private void browseButtonOfficeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonOfficeActionPerformed
+ browseInstallationDirectory(evt.getActionCommand());
+ }//GEN-LAST:event_browseButtonOfficeActionPerformed
+
+ private void browseInstallationDirectory(String command) {
+ String dialogTitle = NbBundle.getMessage(ConfigurationPanel.class, "Browse_OfficeInstallation_Title"); // NOI18N
+ if ("BROWSE_SDK".equals(command)) { // NOI18N
+ dialogTitle = NbBundle.getMessage(ConfigurationPanel.class, "Browse_SDKInstallation_Title"); // NOI18N
+ }
+
+ JFileChooser chooser = new JFileChooser(FileSystemView.getFileSystemView());
+ FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
+
+ if ("BROWSE_SDK".equals(command) || !PlatformInfo.isMacOS()) { // NOI18N
+ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ }
+
+ chooser.setDialogTitle(dialogTitle);
+
+ String path = this.officeTextField.getText();
+ if (path.length() > 0) {
+ File f = new File(path);
+ if (f.exists()) {
+ chooser.setSelectedFile(f);
+ }
+ }
+ if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
+ File projectDir = chooser.getSelectedFile();
+ if ("BROWSE_SDK".equals(command)) { // NOI18N
+ sdkTextField.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
+ }
+ else {
+ officeTextField.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
+ }
+ }
+ }
+
+ public String getOffice() {
+ return officeTextField.getText();
+ }
+
+ public void setOffice(String officeInstallation) {
+ officeTextField.setText(officeInstallation);
+ }
+
+ public String getSDK() {
+ return sdkTextField.getText();
+ }
+
+ public void setSDK(String sdkInstallation) {
+ sdkTextField.setText(sdkInstallation);
+ }
+
+ void load() {
+ // TODO read settings and initialize GUI
+ // Example:
+ // someCheckBox.setSelected(Preferences.userNodeForPackage(ConfigurationPanel.class).getBoolean("someFlag", false));
+ // or:
+ // someTextField.setText(SomeSystemOption.getDefault().getSomeStringProperty());
+ }
+
+ void store() {
+ // TODO store modified settings
+ // Example:
+ // Preferences.userNodeForPackage(ConfigurationPanel.class).putBoolean("someFlag", someCheckBox.isSelected());
+ // or:
+ // SomeSystemOption.getDefault().setSomeStringProperty(someTextField.getText());
+ }
+
+ boolean valid() {
+ // TODO check whether form is consistent and complete
+ return (OpenOfficeLocation.validateOffice(officeTextField.getText())
+ && OpenOfficeLocation.validateSDK(sdkTextField.getText()));
+ }
+
+ public void validateWithFocus() {
+ validate();
+ if (errorTextPane.getText().length() != 0) {
+ sdkTextField.requestFocus();
+ }
+ }
+
+ @Override
+ public void validate() {
+ // cascade validation: first platform, then office, then sdk
+ validatePlatform();
+ if (errorTextPane.getText().length() == 0) {
+ // Never change this into validating the sdk before office:
+ // will produce problems with 3layer office
+ validateOffice();
+ if (errorTextPane.getText().length() == 0) {
+ validateSDK();
+ }
+ }
+ }
+
+ protected void validate(boolean val) {
+ if (val == VALIDATE_SDK) {
+ validateSDK();
+ }
+ else {
+ validateOffice();
+ }
+ }
+
+ private void validateOffice() {
+ String officePath = officeTextField.getText();
+
+ boolean threeLayerOffice = OpenOfficeLocation.isThreeLayerOffice(officePath);
+ sdkTextField.setEnabled(!threeLayerOffice);
+ browseButtonSDK.setEnabled(!threeLayerOffice);
+ // TODO: make error message for SDK not found with OOo 3
+ if( !OpenOfficeLocation.validateOffice(officePath) ) {
+ errorTextPane.setText(NbBundle.getMessage(ConfigurationPanel.class, "Error_OfficeInstallation")); // NOI18N
+ } else {
+ String sdk = OpenOfficeLocation.getSdk(officePath);
+ if (sdk != null && sdk.length() != 0) {
+ sdkTextField.setText(sdk);
+ errorTextPane.setText(""); // NOI18N
+ }
+ else {
+ validateSDK();
+ }
+ }
+ }
+
+ private void validateSDK() {
+ if( !OpenOfficeLocation.validateSDK(sdkTextField.getText()) ) {
+ errorTextPane.setText(NbBundle.getMessage(ConfigurationPanel.class, "Error_SDKInstallation")); // NOI18N
+ } else {
+ errorTextPane.setText(""); // NOI18N
+ }
+ }
+
+ private void validatePlatform() {
+ if( !ConfigurationValidator.validatePlatform() ) {
+ errorTextPane.setText(NbBundle.getMessage(ConfigurationPanel.class, "Error_UnknownPlatform")); // NOI18N
+ } else {
+ errorTextPane.setText(""); // NOI18N
+ }
+ }
+
+// public void removeUpdate(DocumentEvent e) {
+// validate(e);
+// }
+//
+// public void insertUpdate(DocumentEvent e) {
+// validate(e);
+// }
+//
+// public void changedUpdate(DocumentEvent e) {
+// validate(e);
+// }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton browseButtonOffice;
+ private javax.swing.JButton browseButtonSDK;
+ private javax.swing.JTextPane descriptionTextPane;
+ private javax.swing.JTextPane errorTextPane;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JTextPane jTextPane1;
+ private javax.swing.JLabel officeLabel;
+ private javax.swing.JTextField officeTextField;
+ private javax.swing.JLabel sdkLabel;
+ private javax.swing.JTextField sdkTextField;
+ private javax.swing.JPanel settingsPanel;
+ private javax.swing.JLabel sunLabel;
+ private javax.swing.JPanel sunLogoPanel;
+ // End of variables declaration//GEN-END:variables
+
+ private class SunLogoPanel extends JPanel {
+ @Override
+ protected void paintComponent(Graphics gfx) {
+ Image img = ImageUtilities.loadImage("org/openoffice/extensions/config/sun_logo.png"); // NOI18N
+ ImageObserver ob = new ImageObserver() {
+ public boolean imageUpdate(Image i, int infoflags, int x, int y, int width, int height) {
+ return false;
+ }
+ };
+ Rectangle resize = calculateSize(img, this.getPreferredSize(), ob);
+ gfx.drawImage(img, resize.x, resize.y, resize.width, resize.height, ob);
+ }
+
+
+ private Rectangle calculateSize(Image img, Dimension d, ImageObserver ob) {
+ int imageWidth = img.getWidth(ob);
+ int imageHeight = img.getHeight(ob);
+ Rectangle resized = new Rectangle(imageWidth, imageHeight);
+ // only resize when logo has to be smaller
+ if (d.width < imageWidth || d.height < imageHeight) {
+ double scale = (double)imageWidth / (double)imageHeight;
+
+ if (d.height * scale > d.width) {
+ // have to scale the height
+ int height = (int)(scale * resized.width);
+ resized.setSize(d.width, height);
+ }
+ else {
+ // have to scale the width
+ int width = (int)(scale * resized.height);
+ resized.setSize(width, d.height);
+ }
+ }
+ return resized;
+ }
+ }
+
+ private class DocumentListenerImplementation implements DocumentListener {
+ boolean validationType;
+ public DocumentListenerImplementation(boolean validationType) {
+ this.validationType = validationType;
+ }
+ public void insertUpdate(DocumentEvent e) {
+ ConfigurationPanel.this.validate(validationType);
+ }
+
+ public void removeUpdate(DocumentEvent e) {
+ ConfigurationPanel.this.validate(validationType);
+ }
+
+ public void changedUpdate(DocumentEvent e) {
+ ConfigurationPanel.this.validate(validationType);
+ }
+
+ }
+}
Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/ConfigurationSettings.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/ConfigurationSettings.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/ConfigurationSettings.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/ConfigurationSettings.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,444 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ConfigurationSettings.java,v $
+ *
+ * $Revision: 1.23 $
+ *
+ * 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.config;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.DecimalFormat;
+import java.util.Calendar;
+import java.util.Enumeration;
+import java.util.GregorianCalendar;
+import java.util.Properties;
+import java.util.Vector;
+import org.openide.filesystems.FileLock;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.NbBundle;
+import org.openoffice.extensions.config.office.OpenOfficeLocation;
+import org.openoffice.extensions.util.LogWriter;
+import org.openoffice.extensions.config.office.PlatformInfo;
+
+/**
+ *
+ * @author js93811
+ */
+public class ConfigurationSettings {
+
+ private FileObject settingsFolder;
+ private FileObject settingsFile;
+ private FileLock lock;
+ private Properties settings;
+ private LibraryManager libraryManager;
+ private String libraryName;
+ private String userName;
+ private ListenerContainer listenerContainer;
+
+// private static boolean firstInit = true;
+
+ /** Configuration file base name*/
+ public static final String PROPERTIES_BASE = "org-openoffice-extensions"; // NOI18N
+ /** Configuration file extension*/
+ public static final String PROPERTIES_EXTENSION = "xml"; // NOI18N
+ /** Key under which the office installtion path is stored in the properties file*/
+ public static final String KEY_OFFICE_INSTALLATION="office"; // NOI18N
+ /** Key under which the SDK installtion path is stored in the properties file*/
+ public static final String KEY_SDK_INSTALLATION="sdk"; // NOI18N
+ /** Log file for all logging all operations and errors */
+ public static final String KEY_LOG_FILE="log"; // NOI18N
+ /** Log level for logging */
+ public static final String KEY_LOG_LEVEL="log_level"; // NOI18N
+
+ /** There can only be one!*/
+ private static ConfigurationSettings SINGLETON = null;
+
+ private static File fileChooserStartingDirectory = null;
+
+ private ConfigurationSettings()
+ {
+// this.firstInit = firstInit;
+ listenerContainer = new ListenerContainer();
+ libraryManager = new LibraryManager();
+ settings = new Properties();
+ // get platform settings: not really needed, but this is the first that's executed
+ // and it should be assured that the settings are there early.
+ PlatformInfo.getPlatformBinDir();
+
+ // register listeners to set the Java system properties when office and sdk
+ // are set
+// this.registerPropertyChangeListener(KEY_OFFICE_INSTALLATION,
+// new OfficePropertyChangeListener(KEY_OFFICE_INSTALLATION, "office.home")); // NOI18N
+// this.registerPropertyChangeListener(KEY_OFFICE_INSTALLATION,
+// new OfficePropertyChangeListener(KEY_OFFICE_INSTALLATION, "office.program.path", "/".concat(PlatformInfo.getOfficeProgramDir()))); // NOI18N
+// this.registerPropertyChangeListener(KEY_SDK_INSTALLATION,
+// new OfficePropertyChangeListener(KEY_SDK_INSTALLATION, "oo.sdk.home")); // NOI18N
+
+ setDefaultValues();
+ settingsFolder= FileUtil.getConfigRoot().getFileObject("Settings"); // NOI18N
+ if (settingsFolder==null)
+ {
+ try
+ {
+ OpenOfficeLocation loc = OpenOfficeLocation.getOpenOfficeLocation();
+ if (loc != null) {
+ setValue(KEY_OFFICE_INSTALLATION, loc.getOfficePath());
+ setValue(KEY_SDK_INSTALLATION, loc.getSdkPath());
+ }
+ settingsFolder=FileUtil.getConfigRoot().createFolder("Settings"); // NOI18N
+ store();
+ }
+ catch (IOException ex)
+ {
+ ex.printStackTrace(); // no log available yet
+ }
+ }
+ else
+ {
+ load();
+ String office = getValue(KEY_OFFICE_INSTALLATION);
+ String sdk = getValue(KEY_SDK_INSTALLATION);
+ OpenOfficeLocation loc = OpenOfficeLocation.getOpenOfficeLocation(office, sdk, false);
+ if (loc == null) {
+ // no office set: search for one
+ loc = OpenOfficeLocation.getOpenOfficeLocation();
+ if (loc != null) {
+ // found office, so store it.
+ setValue(KEY_OFFICE_INSTALLATION, loc.getOfficePath());
+ setValue(KEY_SDK_INSTALLATION, loc.getSdkPath());
+ store();
+ }
+ }
+ else {
+ setOfficeLocation();
+ }
+ }
+
+ LogWriter lwr = LogWriter.createLogWriter(getValue(KEY_LOG_LEVEL), getValue(KEY_LOG_FILE));
+ // register listeners for log settings
+ this.registerPropertyChangeListener(KEY_LOG_FILE,
+ new OfficePropertyChangeListener(KEY_LOG_FILE, LogWriter.LOG_PATH)); // NOI18N
+ this.registerPropertyChangeListener(KEY_LOG_LEVEL,
+ new OfficePropertyChangeListener(KEY_LOG_LEVEL, LogWriter.LOG_LEVEL)); // NOI18N
+ LogWriter.LogSettingsChangeListener logListener = new LogWriter.LogSettingsChangeListener(lwr);
+ registerPropertyChangeListener(KEY_LOG_FILE, logListener);
+ registerPropertyChangeListener(KEY_LOG_LEVEL, logListener);
+
+ userName = System.getProperty ("user.name"); // NOI18N
+ if (userName == null) {
+ userName = "SomeBody"; // NOI18N
+ }
+ }
+
+ public static ConfigurationSettings getSettings() {
+ if (SINGLETON==null) {
+ SINGLETON=new ConfigurationSettings();
+ }
+ return SINGLETON;
+ }
+
+ public void setDefaultValues ()
+ {
+ this.clear();
+ this.setValue(KEY_OFFICE_INSTALLATION, ""); // NOI18N
+ this.setValue(KEY_SDK_INSTALLATION, ""); // NOI18N
+ String[] defVals = LogWriter.getDefaultValues();
+ this.setValue(KEY_LOG_LEVEL, defVals[0]);
+ this.setValue(KEY_LOG_FILE, defVals[1]);
+ }
+
+ public void store ()
+ {
+ try
+ {
+// if ( firstInit ) {
+// InitialSettingsDialog initDialog = new InitialSettingsDialog(null, true, this);
+// initDialog.setAlwaysOnTop(true);
+// initDialog.setVisible(true);
+//
+// String officePath = getValue(KEY_OFFICE_INSTALLATION);
+// String sdkPath = getValue(KEY_SDK_INSTALLATION);
+// if (officePath.length() > 0 && sdkPath.length() > 0) {
+// firstInit = false;
+// }
+// }
+
+
+ settingsFile = settingsFolder.getFileObject(PROPERTIES_BASE,PROPERTIES_EXTENSION);
+ if (settingsFile==null)
+ {
+ settingsFile = settingsFolder.createData(PROPERTIES_BASE,PROPERTIES_EXTENSION);
+ }
+
+ lock = settingsFile.lock();
+ OutputStream out = settingsFile.getOutputStream (lock);
+ settings.storeToXML(out, NbBundle.getMessage(ConfigurationSettings.class, "ConfigurationSettingsPropertiesComment"));
+ out.close ();
+ lock.releaseLock();
+
+ setOfficeLocation();
+ }
+ catch (IOException ex)
+ {
+ // TODO file can not be created , do something about it
+ ex.printStackTrace(); // no log available yet
+ }
+ }
+
+ protected void load()
+ {
+ settingsFile = settingsFolder.getFileObject(PROPERTIES_BASE,PROPERTIES_EXTENSION);
+ if (settingsFile != null)
+ {
+ // settings already exists. we don't need an initial configation step
+ try
+ {
+ InputStream in = settingsFile.getInputStream();
+ settings.loadFromXML(in);
+ in.close();
+ // call listeners
+ Enumeration keys = settings.keys();
+ while (keys.hasMoreElements()) {
+ String key = (String)keys.nextElement();
+ PropertyChangeListener[] listeners = listenerContainer.getListenerForProperty(key);
+ for (int i=0; i<listeners.length; i++) {
+ listeners[i].propertyChange(new PropertyChangeEvent(this, key, null, settings.getProperty(key)));
+ }
+ }
+ }
+ catch (IOException ex)
+ {
+ ex.printStackTrace(); // no log available yet
+ }
+ }
+ }
+
+ public String getValue(String key)
+ {
+ if (key == null) return "";
+ return settings.getProperty (key);
+ }
+
+ private void clear() {
+ Enumeration keys = settings.keys();
+ while (keys.hasMoreElements()) {
+ String key = (String)keys.nextElement();
+ PropertyChangeListener[] listeners = listenerContainer.getListenerForProperty(key);
+ for (int i=0; i<listeners.length; i++) {
+ listeners[i].propertyChange(new PropertyChangeEvent(this, key, null, null));
+ }
+ }
+ settings.clear();
+ }
+
+ public void setValue(String key, String value) {
+ if (key == null) return;
+ settings.setProperty(key, value == null?"":value.trim ());
+ PropertyChangeListener[] listeners = listenerContainer.getListenerForProperty(key);
+ for (int i=0; i<listeners.length; i++) {
+ listeners[i].propertyChange(new PropertyChangeEvent(this, key, null, value));
+ }
+ }
+
+ public String getLibraryName() {
+ if (libraryName == null) {
+ libraryName = LibraryManager.getLibraryName(
+ OpenOfficeLocation.getOpenOfficeLocation(
+ getValue(KEY_OFFICE_INSTALLATION),
+ getValue(KEY_SDK_INSTALLATION), false));
+ }
+ return libraryName;
+ }
+
+ public String getUser() {
+ return userName;
+ }
+
+ public static String getTimeStamp() {
+ Calendar cal = new GregorianCalendar();
+ DecimalFormat dfmt = new DecimalFormat("00"); // NOI18N
+
+ // Calendar.Month starts with numbering 0 for January
+ return dfmt.format(cal.get(Calendar.YEAR)) + "." +
+ dfmt.format(cal.get(Calendar.MONTH) + 1) + "." +
+ dfmt.format(cal.get(Calendar.DAY_OF_MONTH)) + " - " +
+ dfmt.format(cal.get(Calendar.HOUR_OF_DAY)) + ":" +
+ dfmt.format(cal.get(Calendar.MINUTE)) + ":" +
+ dfmt.format(cal.get(Calendar.SECOND)); // NOI18N
+ }
+
+ public static void storeDefaultFileChooserStartingDir(File dir) {
+ if (dir == null ) {
+ fileChooserStartingDirectory = null;
+ }
+ else if (dir.isDirectory()) {
+ fileChooserStartingDirectory = dir;
+ }
+ }
+
+ public static File getDefaultFileChooserStartingDir() {
+ return fileChooserStartingDirectory;
+ }
+
+ public void registerPropertyChangeListener(
+ // when propertyName is null, listener is registered for all.
+ String propertyName, PropertyChangeListener listener) {
+ listenerContainer.addListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(
+ PropertyChangeListener listener) {
+ listenerContainer.removeListener(listener);
+ }
+
+ private void setJavaSystemProperties(OpenOfficeLocation loc) {
+ // TODO: move all that three layer stuff and building of paths into OpenOfficeLocation class.
+ String officePath = loc.getOfficePath();
+ String sdkPath = loc.getSdkPath();
+ System.setProperty("office.home.dir", officePath); // NOI18N
+ System.setProperty("office.program.dir", officePath.concat("/").concat(PlatformInfo.getOfficeProgramDir())); // NOI18N
+ System.setProperty("oo.version.number", loc.isThreeLayerOffice()?"three":"older"); // NOI18N
+ System.setProperty("oo.sdk.dir", sdkPath); // NOI18N
+ String[] types = loc.getUnoTypesPath();
+ System.setProperty("oo.unotypes.rdb", "-X".concat(types[0])); // NOI18N
+ if (types.length > 1) {
+ System.setProperty("oo.offapi.rdb", "-X".concat(types[1])); // NOI18N
+ }
+ else {
+ // workaround for i92911: works on Windows, but not on *ix
+ System.setProperty("oo.offapi.rdb", "-X".concat(types[0])); // NOI18N
+ }
+ if (loc.isThreeLayerOffice()) {
+ System.setProperty("sdk.bin.dir", sdkPath.concat(File.separator).concat("bin")); // NOI18N
+ }
+ else {
+ String platform = PlatformInfo.getPlatformBinDir();
+ System.setProperty("sdk.bin.dir", sdkPath.concat(File.separator).concat(platform).concat(File.separator).concat("bin")); // NOI18N
+ }
+ System.setProperty("ure.bin.dir", loc.getUreBinPath()); // NOI18N
+ String soPath = loc.getPathVariable();
+ if (!PlatformInfo.isWindows()) {
+ soPath = soPath.concat(File.pathSeparator).concat("/usr/bin"); // NOI18N
+ }
+ System.setProperty("office.tool.path", soPath); // NOI18N
+ }
+
+ private void setOfficeLocation() {
+ String officePath = getValue(KEY_OFFICE_INSTALLATION);
+ String sdkPath = getValue(KEY_SDK_INSTALLATION);
+ OpenOfficeLocation.clearOpenOfficeLocation();
+ OpenOfficeLocation loc = OpenOfficeLocation.getOpenOfficeLocation(officePath, sdkPath, false);
+ if (loc != null) {
+ libraryName = libraryManager.createLibrary(loc);
+ setJavaSystemProperties(loc);
+ }
+ }
+
+ private class ListenerContainer {
+ PropertyChangeListener[] listeners;
+ String[] keys;
+ ListenerContainer() {
+ listeners = new PropertyChangeListener[0];
+ keys = new String[0];
+ }
+ void addListener(String property, PropertyChangeListener listener) {
+ if (listener == null) return;
+ PropertyChangeListener[] newListeners = new PropertyChangeListener[listeners.length + 1];
+ String[] newKeys = new String[keys.length + 1];
+ int i=0;
+ for (; i<listeners.length; i++) {
+ newListeners[i] = listeners[i];
+ newKeys[i] = keys[i];
+ }
+ newKeys[i] = property;
+ newListeners[i] = listener;
+ listeners = newListeners;
+ keys = newKeys;
+ }
+ void removeListener(PropertyChangeListener listener) {
+ if (listener == null) return;
+ Vector<PropertyChangeListener> v = new Vector<PropertyChangeListener>();
+ Vector<String> k = new Vector<String>();
+ for (int i=0; i<listeners.length; i++) {
+ if (!listeners[i].equals(listener)) {
+ v.add(listeners[i]);
+ k.add(keys[i]);
+ }
+ }
+ listeners = (PropertyChangeListener[])v.toArray(new PropertyChangeListener[v.size()]);
+ keys = (String[])k.toArray(new String[k.size()]);
+ }
+ PropertyChangeListener[] getListenerForProperty(String propertyName) {
+ Vector<PropertyChangeListener> v = new Vector<PropertyChangeListener>();
+ for (int i=0; i<listeners.length; i++) {
+ if (keys[i] == null || keys[i].equals(propertyName)) {
+ v.add(listeners[i]);
+ }
+ }
+ return v.toArray(new PropertyChangeListener[v.size()]);
+ }
+ }
+
+ /**
+ * Java properties office.home and oo.sdk.home have to be set, when the
+ * settings for these variables are changed. So use a listener for this.
+ */
+ private class OfficePropertyChangeListener implements PropertyChangeListener {
+ protected String localPropName;
+ protected String javaSysPropName;
+ protected String postfixValue;
+ public OfficePropertyChangeListener(String localPropName, String javaSysPropName) {
+ this(localPropName, javaSysPropName, null);
+ }
+ public OfficePropertyChangeListener(String localPropName, String javaSysPropName, String postfixValue) {
+ this.localPropName = localPropName;
+ this.javaSysPropName = javaSysPropName;
+ this.postfixValue = postfixValue;
+ }
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getPropertyName().equals(localPropName)) {
+ if (postfixValue == null) {
+ System.setProperty(javaSysPropName, (String)evt.getNewValue());
+ }
+ else {
+ System.setProperty(javaSysPropName, ((String)evt.getNewValue()).concat(postfixValue));
+ }
+ }
+ }
+ }
+}
Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/ConfigurationValidator.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/ConfigurationValidator.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/ConfigurationValidator.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/ConfigurationValidator.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ConfigurationValidator.java,v $
+ *
+ * $Revision: 1.16 $
+ *
+ * last change: $Author: sg $ $Date: 2008/10/13 08:43:18 $
+ *
+ * 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.config;
+
+import java.awt.Dialog;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ResourceBundle;
+import org.openide.DialogDescriptor;
+import org.openide.DialogDisplayer;
+import org.openide.util.HelpCtx;
+import org.openoffice.extensions.config.office.OpenOfficeLocation;
+import org.openoffice.extensions.config.office.PlatformInfo;
+
+/**
+ *
+ * @author js93811
+ */
+public class ConfigurationValidator {
+
+ /**
+ * Creates a new instance of ConfigurationValidator -
+ * do not use, everything's static
+ */
+ private ConfigurationValidator() {
+ }
+
+ public static boolean validatePlatform() {
+ return !PlatformInfo.getPlatformBinDir().equals(PlatformInfo.UNKNOWN_PLATFORM);
+ }
+
+ public static boolean validateSettings() {
+ final ConfigurationSettings settings = ConfigurationSettings.getSettings();
+ String officePath = settings.getValue(ConfigurationSettings.KEY_OFFICE_INSTALLATION);
+ String sdkPath = settings.getValue(ConfigurationSettings.KEY_SDK_INSTALLATION);
+ OpenOfficeLocation loc = OpenOfficeLocation.getOpenOfficeLocation(officePath, sdkPath, false);
+ boolean valid = (loc != null && loc.validate());
+ if (!valid) {
+ String title = ResourceBundle.getBundle(
+ "org/openoffice/extensions/config/Bundle").getString(
+ "ConfigurationDialog_Title"); // NOI18N
+ final ConfigurationPanel panel = new ConfigurationPanel(officePath, sdkPath);
+ panel.validateWithFocus(); // set the initial error message incl. focus on the right text field
+ DialogDescriptor ddscr = new DialogDescriptor(panel, title);
+ ddscr.setButtonListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ if (e.getActionCommand().equals("OK")) { // NOI18N
+ settings.setValue(ConfigurationSettings.KEY_OFFICE_INSTALLATION, panel.getOffice());
+ settings.setValue(ConfigurationSettings.KEY_SDK_INSTALLATION, panel.getSDK());
+ settings.store();
+ }
+ }
+ });
+ // set help to this panel
+ ddscr.setHelpCtx(new HelpCtx("org.openoffice.extensions.config.paths")); // NOI18N
+ Dialog d = DialogDisplayer.getDefault().createDialog(ddscr);
+ d.setVisible(true);
+ officePath = settings.getValue(ConfigurationSettings.KEY_OFFICE_INSTALLATION);
+ sdkPath = settings.getValue(ConfigurationSettings.KEY_SDK_INSTALLATION);
+ loc = OpenOfficeLocation.getOpenOfficeLocation(officePath, sdkPath, false);
+ valid = loc != null && loc.validate();
+ }
+ return valid;
+ }
+}
Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/LibraryManager.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/LibraryManager.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/LibraryManager.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/config/LibraryManager.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,230 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: LibraryManager.java,v $
+ *
+ * $Revision: 1.14 $
+ *
+ * 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.config;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import org.openide.filesystems.FileLock;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileSystem.AtomicAction;
+import org.openide.filesystems.FileUtil;
+import org.openoffice.extensions.config.office.OpenOfficeLocation;
+import org.openoffice.extensions.util.LogWriter;
+
+/**
+ *
+ * @author js93811
+ */
+public class LibraryManager {
+
+ public static final String LIBRARY_HOME = "org-netbeans-api-project-libraries/Libraries"; // NOI18N
+ public static final String LIBRARY_BASE = "org-netbeans-api-project-libraries"; // NOI18N
+ public static final String LIBRARY_DIR = "Libraries"; // NOI18N
+ public static final String LIBRARY_EXTENSION = "xml"; // NOI18N
+
+ // internal without officebean: may not be there
+ public static final String[] JAR_LIBRARIES_ESSENTIAL = new String[] {
+ "juh.jar", "jurt.jar", "ridl.jar", "unoil.jar",
+ }; // NOI18N
+
+ // jar libraries for external use including officebean: if it's missing,
+ // externals have to handle that
+ public static final String[] JAR_LIBRARIES = new String[] {
+ JAR_LIBRARIES_ESSENTIAL[0],
+ JAR_LIBRARIES_ESSENTIAL[1],
+ JAR_LIBRARIES_ESSENTIAL[2],
+ JAR_LIBRARIES_ESSENTIAL[3],
+ "officebean.jar"
+ }; // NOI18N
+
+ public static final String JAR_LIBRARY_CONTENT_LINE =
+ "\t\t<resource>jar:file:%LibrarySrcClassDir%!/</resource>\n"; // NOI18N
+
+ public static final String LIBRARY_CONTENT =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<!DOCTYPE library PUBLIC \"-//NetBeans//DTD Library Declaration 1.0//EN\" \"http://www.netbeans.org/dtds/library-declaration-1_0.dtd\">\n" +
+ "<library version=\"1.0\">\n" +
+ "\t<name>%LibraryName%</name>\n" +
+ "\t<type>j2se</type>\n" +
+ "\t<volume>\n" +
+ "\t\t<type>classpath</type>\n" +
+ "%AllLibraries%" +
+ "\n\t</volume>\n" +
+ "\t<volume>\n" +
+ "\t\t<type>src</type>\n" +
+ "\t</volume>\n" +
+ "\t<volume>\n" +
+ "\t\t<type>javadoc</type>\n" +
+ "\t\t<resource>file:%SdkPath%/docs/common/ref/</resource>\n" +
+ "\t\t<resource>file:%SdkPath%/docs/java/ref/</resource>\n" +
+ "\t</volume>\n" +
+ "</library>\n"; // NOI18N
+
+ /** Creates a new instance of LibraryManager */
+ public LibraryManager() {
+
+ }
+
+ public String createLibrary(OpenOfficeLocation loc) {
+ String libraryName = ""; // NOI18N
+ String allLibraries = ""; // NOI18N
+ try
+ {
+ FileObject libraryBaseFolder= FileUtil.getConfigRoot().getFileObject(LIBRARY_BASE);
+ if (libraryBaseFolder==null)
+ {
+ libraryBaseFolder = FileUtil.getConfigRoot().createFolder(LIBRARY_BASE);
+ }
+
+ FileObject libraryFolder= libraryBaseFolder.getFileObject(LIBRARY_DIR);
+ if (libraryFolder==null)
+ {
+ libraryFolder = libraryBaseFolder.createFolder(LIBRARY_DIR);
+ }
+
+ libraryName = getLibraryName(loc);
+
+ // officebean may not be there
+ String officeBeanEntry = correctPathForAllPlatforms(loc.getFullPathForJar("officebean.jar")); // NOI18N
+ if (officeBeanExists(officeBeanEntry)) {
+ officeBeanEntry = JAR_LIBRARY_CONTENT_LINE.replaceAll("%LibrarySrcClassDir%", officeBeanEntry); // NOI18N
+ allLibraries = officeBeanEntry;
+ }
+
+ for (int i = 0; i < JAR_LIBRARIES_ESSENTIAL.length; i++) {
+ String jarLib = JAR_LIBRARIES_ESSENTIAL[i];
+ String path = correctPathForAllPlatforms(loc.getFullPathForJar(jarLib));
+ allLibraries = allLibraries.concat(
+ JAR_LIBRARY_CONTENT_LINE.replaceAll("%LibrarySrcClassDir%", path)); // NOI18N
+ }
+
+ String content = LIBRARY_CONTENT.replaceAll("%SdkPath%", correctPathForAllPlatforms(loc.getSdkPath())); // NOI18N
+ content = content.replaceAll("%LibraryName%", libraryName); // NOI18N
+ content = content.replaceAll("%AllLibraries%", allLibraries); // NOI18N
+
+ LibraryCreateAction createAction = new LibraryCreateAction(libraryFolder, libraryName, content);
+
+ libraryFolder.getFileSystem().runAtomicAction(createAction);
+ }
+ catch (IOException ex)
+ {
+ // TODO file can not be created , do something about it
+ LogWriter.getLogWriter().printStackTrace(ex);
+ }
+
+ return libraryName;
+ }
+
+ /**
+ * Make a NB name out of platform dependent paths: start with
+ * slash, have slash as path separator and %20 instead of space.
+ * @param line
+ * @return
+ */
+ private String correctPathForAllPlatforms(String line) {
+ // really two backslashes needed + masking, so it's four
+ line = line.replaceAll("\\\\", "/").replaceAll(" ", "%20");
+ return line.startsWith("/")?line:"/".concat(line);
+ }
+
+ private boolean officeBeanExists(String officebeanpath) {
+ if (officebeanpath == null) return false;
+ File officebeanjar = new File(officebeanpath); // NOI18N
+ return officebeanjar.exists();
+ }
+
+ static String getLibraryName(OpenOfficeLocation loc) {
+ String libraryName = ""; // NOI18N
+ FileInputStream f = null;
+ try
+ {
+ f = new FileInputStream(loc.getBootstrapPath());
+ java.util.PropertyResourceBundle props = new java.util.PropertyResourceBundle(f);
+ libraryName = (String)props.handleGetObject("ProductKey"); // NOI18N
+ }
+ catch (IOException ex)
+ {
+ LogWriter.getLogWriter().printStackTrace(ex);
+ }
+ finally {
+ if (f != null) {
+ try {
+ f.close();
+ } catch (IOException ex) {
+ LogWriter.getLogWriter().printStackTrace(ex);
+ }
+ }
+ }
+ return libraryName;
+ }
+
+ class LibraryCreateAction implements AtomicAction {
+ private FileObject libraryFolder;
+ private String libraryContent;
+ private String libraryName;
+
+ public LibraryCreateAction(FileObject libraryfolder, String libraryname, String librarycontent) {
+ libraryFolder = libraryfolder;
+ libraryContent = librarycontent;
+ libraryName = libraryname;
+ }
+
+
+ public void run() {
+ try
+ {
+ FileObject libraryFile = libraryFolder.getFileObject(libraryName,LIBRARY_EXTENSION);
+ if (libraryFile==null)
+ {
+ libraryFile = libraryFolder.createData(libraryName,LIBRARY_EXTENSION);
+ }
+
+ FileLock lock = libraryFile.lock();
+ OutputStream out = libraryFile.getOutputStream(lock);
+ out.write(libraryContent.getBytes());
+ out.close();
+ lock.releaseLock();
+ }
+ catch (IOException ex)
+ {
+ // TODO file can not be created , do something about it
+ LogWriter.getLogWriter().printStackTrace(ex);
+ }
+ }
+ }
+}