From 6e04761cf320ff71f1454a6c37798d9807247a3c Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Wed, 10 Oct 2012 21:34:29 +0000 Subject: [PATCH] SDK: - add Upgrader plugin, basically a copy of the same NetBeans plugin, allows importing settings from previous SDK installs git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9860 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- sdk/jme3-upgrader/build.xml | 8 + sdk/jme3-upgrader/manifest.mf | 5 + sdk/jme3-upgrader/nbproject/build-impl.xml | 45 + .../nbproject/genfiles.properties | 8 + .../nbproject/project.properties | 3 + sdk/jme3-upgrader/nbproject/project.xml | 47 + sdk/jme3-upgrader/nbproject/suite.properties | 1 + .../com/jme3/gde/upgrader/Bundle.properties | 5 + .../org/netbeans/license/AcceptLicense.java | 237 +++++ .../org/netbeans/license/Bundle.properties | 66 ++ .../org/netbeans/license/LicensePanel.form | 87 ++ .../org/netbeans/license/LicensePanel.java | 169 ++++ .../src/org/netbeans/upgrade/AutoUpgrade.java | 312 +++++++ .../netbeans/upgrade/AutoUpgradePanel.form | 53 ++ .../netbeans/upgrade/AutoUpgradePanel.java | 137 +++ .../org/netbeans/upgrade/Bundle.properties | 54 ++ .../org/netbeans/upgrade/ColoringStorage.java | 335 +++++++ .../src/org/netbeans/upgrade/Copy.java | 210 +++++ .../src/org/netbeans/upgrade/CopyFiles.java | 367 ++++++++ .../org/netbeans/upgrade/IncludeExclude.java | 138 +++ .../netbeans/upgrade/PathTransformation.java | 93 ++ .../src/org/netbeans/upgrade/XMLStorage.java | 291 ++++++ .../src/org/netbeans/upgrade/copy5.5 | 106 +++ .../src/org/netbeans/upgrade/copy5.5.1 | 106 +++ .../src/org/netbeans/upgrade/copy6.0 | 82 ++ .../src/org/netbeans/upgrade/copy6.1 | 85 ++ .../src/org/netbeans/upgrade/copy6.5 | 85 ++ .../org/netbeans/upgrade/copyjstudio_6me_user | 90 ++ .../src/org/netbeans/upgrade/layer5.5.1.xml | 65 ++ .../src/org/netbeans/upgrade/layer5.5.xml | 65 ++ .../src/org/netbeans/upgrade/layer6.0.xml | 65 ++ .../src/org/netbeans/upgrade/layer6.1.xml | 65 ++ .../src/org/netbeans/upgrade/nonstandard5.5 | 54 ++ .../src/org/netbeans/upgrade/nonstandard5.5.1 | 54 ++ .../src/org/netbeans/upgrade/nonstandard6.0 | 56 ++ .../src/org/netbeans/upgrade/nonstandard6.1 | 51 + .../src/org/netbeans/upgrade/nonstandard6.5 | 52 ++ .../upgrade/systemoptions/ColorProcessor.java | 81 ++ .../systemoptions/ContentProcessor.java | 135 +++ .../systemoptions/CvsSettingsProcessor.java | 91 ++ .../upgrade/systemoptions/DefaultResult.java | 75 ++ .../DocumentationSettingsProcessor.java | 67 ++ .../upgrade/systemoptions/FileProcessor.java | 77 ++ .../systemoptions/HashMapProcessor.java | 84 ++ .../systemoptions/HashSetProcessor.java | 64 ++ .../systemoptions/HostPropertyProcessor.java | 82 ++ .../upgrade/systemoptions/Importer.java | 135 +++ .../IntrospectedInfoProcessor.java | 64 ++ .../systemoptions/JUnitContentProcessor.java | 147 +++ .../upgrade/systemoptions/ListProcessor.java | 87 ++ .../systemoptions/NbClassPathProcessor.java | 75 ++ .../systemoptions/PropertiesStorage.java | 185 ++++ .../systemoptions/PropertyProcessor.java | 131 +++ .../upgrade/systemoptions/Result.java | 55 ++ .../upgrade/systemoptions/SerParser.java | 608 ++++++++++++ .../systemoptions/SettingsRecognizer.java | 881 ++++++++++++++++++ .../StringPropertyProcessor.java | 69 ++ .../systemoptions/SystemOptionsParser.java | 119 +++ .../systemoptions/TaskTagsProcessor.java | 96 ++ .../upgrade/systemoptions/URLProcessor.java | 111 +++ .../netbeans/upgrade/systemoptions/Utils.java | 150 +++ .../upgrade/systemoptions/systemoptionsimport | 16 + .../src/org/netbeans/util/Util.java | 176 ++++ 63 files changed, 7613 insertions(+) create mode 100644 sdk/jme3-upgrader/build.xml create mode 100644 sdk/jme3-upgrader/manifest.mf create mode 100644 sdk/jme3-upgrader/nbproject/build-impl.xml create mode 100644 sdk/jme3-upgrader/nbproject/genfiles.properties create mode 100644 sdk/jme3-upgrader/nbproject/project.properties create mode 100644 sdk/jme3-upgrader/nbproject/project.xml create mode 100644 sdk/jme3-upgrader/nbproject/suite.properties create mode 100644 sdk/jme3-upgrader/src/com/jme3/gde/upgrader/Bundle.properties create mode 100644 sdk/jme3-upgrader/src/org/netbeans/license/AcceptLicense.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/license/Bundle.properties create mode 100644 sdk/jme3-upgrader/src/org/netbeans/license/LicensePanel.form create mode 100644 sdk/jme3-upgrader/src/org/netbeans/license/LicensePanel.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/AutoUpgrade.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/AutoUpgradePanel.form create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/AutoUpgradePanel.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/Bundle.properties create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/ColoringStorage.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/Copy.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/CopyFiles.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/IncludeExclude.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/PathTransformation.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/XMLStorage.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/copy5.5 create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/copy5.5.1 create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/copy6.0 create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/copy6.1 create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/copy6.5 create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/copyjstudio_6me_user create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/layer5.5.1.xml create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/layer5.5.xml create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/layer6.0.xml create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/layer6.1.xml create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard5.5 create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard5.5.1 create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard6.0 create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard6.1 create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard6.5 create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/ColorProcessor.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/ContentProcessor.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/CvsSettingsProcessor.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/DefaultResult.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/DocumentationSettingsProcessor.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/FileProcessor.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/HashMapProcessor.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/HashSetProcessor.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/HostPropertyProcessor.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/Importer.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/IntrospectedInfoProcessor.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/JUnitContentProcessor.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/ListProcessor.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/NbClassPathProcessor.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/PropertiesStorage.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/PropertyProcessor.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/Result.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/SerParser.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/SettingsRecognizer.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/StringPropertyProcessor.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/SystemOptionsParser.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/TaskTagsProcessor.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/URLProcessor.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/Utils.java create mode 100644 sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/systemoptionsimport create mode 100644 sdk/jme3-upgrader/src/org/netbeans/util/Util.java diff --git a/sdk/jme3-upgrader/build.xml b/sdk/jme3-upgrader/build.xml new file mode 100644 index 000000000..1ce7ebb43 --- /dev/null +++ b/sdk/jme3-upgrader/build.xml @@ -0,0 +1,8 @@ + + + + + + Builds, tests, and runs the project com.jme3.gde.upgrader. + + diff --git a/sdk/jme3-upgrader/manifest.mf b/sdk/jme3-upgrader/manifest.mf new file mode 100644 index 000000000..0af8c6990 --- /dev/null +++ b/sdk/jme3-upgrader/manifest.mf @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +OpenIDE-Module: com.jme3.gde.upgrader +OpenIDE-Module-Implementation-Version: 0 +OpenIDE-Module-Localizing-Bundle: com/jme3/gde/upgrader/Bundle.properties + diff --git a/sdk/jme3-upgrader/nbproject/build-impl.xml b/sdk/jme3-upgrader/nbproject/build-impl.xml new file mode 100644 index 000000000..6005ca1c6 --- /dev/null +++ b/sdk/jme3-upgrader/nbproject/build-impl.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + You must set 'suite.dir' to point to your containing module suite + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sdk/jme3-upgrader/nbproject/genfiles.properties b/sdk/jme3-upgrader/nbproject/genfiles.properties new file mode 100644 index 000000000..aafdf2d38 --- /dev/null +++ b/sdk/jme3-upgrader/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=872e7e8b +build.xml.script.CRC32=8cafdaf9 +build.xml.stylesheet.CRC32=a56c6a5b@2.50.1 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=872e7e8b +nbproject/build-impl.xml.script.CRC32=aa96997a +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.50.1 diff --git a/sdk/jme3-upgrader/nbproject/project.properties b/sdk/jme3-upgrader/nbproject/project.properties new file mode 100644 index 000000000..f7e2314bf --- /dev/null +++ b/sdk/jme3-upgrader/nbproject/project.properties @@ -0,0 +1,3 @@ +javac.source=1.6 +javac.compilerargs=-Xlint -Xlint:-serial +spec.version.base=3.0.0 diff --git a/sdk/jme3-upgrader/nbproject/project.xml b/sdk/jme3-upgrader/nbproject/project.xml new file mode 100644 index 000000000..38dfbc8ab --- /dev/null +++ b/sdk/jme3-upgrader/nbproject/project.xml @@ -0,0 +1,47 @@ + + + org.netbeans.modules.apisupport.project + + + com.jme3.gde.upgrader + + + + org.openide.filesystems + + + + 7.19 + + + + org.openide.modules + + + + 7.2 + + + + org.openide.util + + + + 8.0 + + + + org.openide.util.lookup + + + + 8.0 + + + + + org.netbeans.upgrade + + + + diff --git a/sdk/jme3-upgrader/nbproject/suite.properties b/sdk/jme3-upgrader/nbproject/suite.properties new file mode 100644 index 000000000..29d7cc9bd --- /dev/null +++ b/sdk/jme3-upgrader/nbproject/suite.properties @@ -0,0 +1 @@ +suite.dir=${basedir}/.. diff --git a/sdk/jme3-upgrader/src/com/jme3/gde/upgrader/Bundle.properties b/sdk/jme3-upgrader/src/com/jme3/gde/upgrader/Bundle.properties new file mode 100644 index 000000000..e3b3a408f --- /dev/null +++ b/sdk/jme3-upgrader/src/com/jme3/gde/upgrader/Bundle.properties @@ -0,0 +1,5 @@ +OpenIDE-Module-Display-Category=jMonkeyEngine +OpenIDE-Module-Long-Description=\ + Handles upgrades of the SDK, allows import of previous installs settings +OpenIDE-Module-Name=Upgrader +OpenIDE-Module-Short-Description=Handles upgrades of the SDK diff --git a/sdk/jme3-upgrader/src/org/netbeans/license/AcceptLicense.java b/sdk/jme3-upgrader/src/org/netbeans/license/AcceptLicense.java new file mode 100644 index 000000000..d1768ec0d --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/license/AcceptLicense.java @@ -0,0 +1,237 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.license; + +import java.awt.BorderLayout; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.net.URL; +import java.util.ResourceBundle; +import javax.swing.AbstractAction; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.KeyStroke; +import org.netbeans.util.Util; +import org.openide.util.NbBundle; +import org.openide.util.Utilities; + +/** + * Displays LicensePanel to user. User must accept license to continue. + * if user does not accept license UserCancelException is thrown. + * + * @author Marek Slama + */ + +public final class AcceptLicense { + + private static String command; + + /** If License was not accepted during installation user must accept it here. + */ + public static void showLicensePanel () throws Exception { + Util.setDefaultLookAndFeel(); + URL url = AcceptLicense.class.getResource("LICENSE.txt"); // NOI18N + LicensePanel licensePanel = new LicensePanel(url); + ResourceBundle bundle = NbBundle.getBundle(AcceptLicense.class); + String yesLabel = bundle.getString("MSG_LicenseYesButton"); + String noLabel = bundle.getString("MSG_LicenseNoButton"); + JButton yesButton = new JButton(); + JButton noButton = new JButton(); + setLocalizedText(yesButton,yesLabel); + setLocalizedText(noButton,noLabel); + + yesButton.setActionCommand("yes"); // NOI18N + noButton.setActionCommand("no"); // NOI18N + + yesButton.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_AcceptButton")); + yesButton.getAccessibleContext().setAccessibleName(bundle.getString("ACSD_AcceptButton")); + + noButton.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_RejectButton")); + noButton.getAccessibleContext().setAccessibleName(bundle.getString("ACSD_RejectButton")); + + Dimension yesPF = yesButton.getPreferredSize(); + Dimension noPF = noButton.getPreferredSize(); + int maxWidth = Math.max(yesButton.getPreferredSize().width, noButton.getPreferredSize().width); + int maxHeight = Math.max(yesButton.getPreferredSize().height, noButton.getPreferredSize().height); + yesButton.setPreferredSize(new Dimension(maxWidth, maxHeight)); + noButton.setPreferredSize(new Dimension(maxWidth, maxHeight)); + + final JDialog d = new JDialog(null, bundle.getString("MSG_LicenseDlgTitle"), Dialog.ModalityType.APPLICATION_MODAL); + Util.initIcons(d); + d.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_LicenseDlg")); + d.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_LicenseDlg")); + d.getContentPane().add(licensePanel,BorderLayout.CENTER); + ActionListener listener = new ActionListener () { + public void actionPerformed (ActionEvent e) { + command = e.getActionCommand(); + d.setVisible(false); + } + }; + yesButton.addActionListener(listener); + noButton.addActionListener(listener); + JPanel buttonPanel = new JPanel(); + buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); + buttonPanel.setBorder(BorderFactory.createEmptyBorder(17,12,11,11)); + buttonPanel.add(yesButton); + buttonPanel.add(noButton); + d.getContentPane().add(buttonPanel,BorderLayout.SOUTH); + d.setSize(new Dimension(600,600)); + d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + d.setResizable(true); + d.getRootPane().setDefaultButton(yesButton); + d.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("ESCAPE"), "exit"); //NOI18N + d.getRootPane().getActionMap().put("exit", new AbstractAction() { //NOI18N + public void actionPerformed(ActionEvent e) { + command = "no"; //NOI18N + d.setVisible(false); + } + }); + + licensePanel.jEditorPane1.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "accept"); //NOI18N + licensePanel.jEditorPane1.getActionMap().put("accept", new AbstractAction() { //NOI18N + public void actionPerformed(ActionEvent e) { + command = "yes"; //NOI18N + d.setVisible(false); + } + }); + + //Center on screen + d.setLocationRelativeTo(null); + d.setVisible(true); + + if ("yes".equals(command)) { // NOI18N + return; + } else { + throw new org.openide.util.UserCancelException(); + } + } + + /** + * Actual setter of the text & mnemonics for the AbstractButton or + * their subclasses. We must copy necessary code from org.openide.awt.Mnemonics + * because org.openide.awt module is not available yet when this code is called. + * @param item AbstractButton + * @param text new label + */ + private static void setLocalizedText (AbstractButton button, String text) { + if (text == null) { + button.setText(null); + return; + } + + int i = findMnemonicAmpersand(text); + + if (i < 0) { + // no '&' - don't set the mnemonic + button.setText(text); + button.setMnemonic(0); + } else { + button.setText(text.substring(0, i) + text.substring(i + 1)); + + if (Utilities.isMac()) { + // there shall be no mnemonics on macosx. + //#55864 + return; + } + + char ch = text.charAt(i + 1); + + // it's latin character or arabic digit, + // setting it as mnemonics + button.setMnemonic(ch); + + // If it's something like "Save &As", we need to set another + // mnemonic index (at least under 1.4 or later) + // see #29676 + button.setDisplayedMnemonicIndex(i); + } + } + + /** + * Searches for an ampersand in a string which indicates a mnemonic. + * Recognizes the following cases: + * + * @param text text to search + * @return the position of mnemonic ampersand in text, or -1 if there is none + */ + public static int findMnemonicAmpersand(String text) { + int i = -1; + + do { + // searching for the next ampersand + i = text.indexOf('&', i + 1); + + if ((i >= 0) && ((i + 1) < text.length())) { + // before ' ' + if (text.charAt(i + 1) == ' ') { + continue; + + // before ', and after ' + } else if ((text.charAt(i + 1) == '\'') && (i > 0) && (text.charAt(i - 1) == '\'')) { + continue; + } + + // ampersand is marking mnemonics + return i; + } + } while (i >= 0); + + return -1; + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/license/Bundle.properties b/sdk/jme3-upgrader/src/org/netbeans/license/Bundle.properties new file mode 100644 index 000000000..d3d8a577a --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/license/Bundle.properties @@ -0,0 +1,66 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. +# +# Oracle and Java are registered trademarks of Oracle and/or its affiliates. +# Other names may be trademarks of their respective owners. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# Contributor(s): +# +# The Original Software is NetBeans. The Initial Developer of the Original +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun +# Microsystems, Inc. All Rights Reserved. +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. + +#Licence dialog +MSG_LicenseDlgTitle=License Agreement +MSG_LicenseDlgLabelTop=Please read the following license agreement carefully. +MSG_LicenseDlgLabelBottom=If you accept all terms of the agreement, click I Accept \ +to start NetBeans IDE. You must accept the agreement to start NetBeans IDE. +MSG_LicenseYesButton=I &Accept +MSG_LicenseNoButton=E&xit + +ACSN_LicensePanel=License Panel +ACSD_LicensePanel=N/A + +ACSN_LicenseDlg=License Dialog +ACSD_LicenseDlg=License Agreement + +ACSN_EditorPane=License Text +ACSD_EditorPane=Please read the following license agreement carefully. \ +If you accept all terms of the agreement, click I Accept \ +to start NetBeans IDE. You must accept the agreement to start NetBeans IDE. + +ACSN_AcceptButton=Accept Button +ACSD_AcceptButton=Click to accept license and continue + +ACSN_RejectButton=Reject Button +ACSD_RejectButton=Click to reject license and exit diff --git a/sdk/jme3-upgrader/src/org/netbeans/license/LicensePanel.form b/sdk/jme3-upgrader/src/org/netbeans/license/LicensePanel.form new file mode 100644 index 000000000..2ef19595c --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/license/LicensePanel.form @@ -0,0 +1,87 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sdk/jme3-upgrader/src/org/netbeans/license/LicensePanel.java b/sdk/jme3-upgrader/src/org/netbeans/license/LicensePanel.java new file mode 100644 index 000000000..d62053065 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/license/LicensePanel.java @@ -0,0 +1,169 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.license; + +import java.awt.Rectangle; +import java.io.IOException; +import java.net.URL; +import java.util.ResourceBundle; + +import javax.swing.AbstractAction; +import javax.swing.ActionMap; +import javax.swing.SwingConstants; +import javax.swing.text.DefaultEditorKit; +import org.openide.util.NbBundle; + +/** + * This class displays license during first start of IDE. + * + * @author Marek Slama + */ +final class LicensePanel extends javax.swing.JPanel { + + /** Creates new form LicensePanel */ + public LicensePanel(URL url) { + this.url = url; + initComponents(); + initAccessibility(); + try { + jEditorPane1.setPage(url); + } catch (IOException exc) { + //Problem with locating file + System.err.println("Exception: " + exc.getMessage()); //NOI18N + exc.printStackTrace(); + } + ActionMap actionMap = jEditorPane1.getActionMap(); + actionMap.put(DefaultEditorKit.upAction, new ScrollAction(-1)); + actionMap.put(DefaultEditorKit.downAction, new ScrollAction(1)); + } + + private void initAccessibility() { + this.getAccessibleContext().setAccessibleName + (bundle.getString("ACSN_LicensePanel")); + this.getAccessibleContext().setAccessibleDescription + (bundle.getString("ACSD_LicensePanel")); + + jEditorPane1.getAccessibleContext().setAccessibleName + (bundle.getString("ACSN_EditorPane")); + jEditorPane1.getAccessibleContext().setAccessibleDescription + (bundle.getString("ACSD_EditorPane")); + } + + /** 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() { + + jTextAreaTop = new javax.swing.JTextArea(); + jScrollPane1 = new javax.swing.JScrollPane(); + jEditorPane1 = new javax.swing.JEditorPane(); + jTextAreaBottom = new javax.swing.JTextArea(); + + setBorder(javax.swing.BorderFactory.createEmptyBorder(12, 12, 0, 11)); + setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS)); + + jTextAreaTop.setBackground(getBackground()); + jTextAreaTop.setColumns(20); + jTextAreaTop.setEditable(false); + jTextAreaTop.setFont(new java.awt.Font("Dialog", 1, 12)); + jTextAreaTop.setLineWrap(true); + jTextAreaTop.setRows(1); + jTextAreaTop.setText(bundle.getString("MSG_LicenseDlgLabelTop")); + jTextAreaTop.setWrapStyleWord(true); + jTextAreaTop.setFocusable(false); + jTextAreaTop.setMargin(new java.awt.Insets(0, 0, 2, 0)); + jTextAreaTop.setRequestFocusEnabled(false); + add(jTextAreaTop); + + jEditorPane1.setEditable(false); + jEditorPane1.setPreferredSize(new java.awt.Dimension(500, 500)); + jScrollPane1.setViewportView(jEditorPane1); + + add(jScrollPane1); + + jTextAreaBottom.setBackground(getBackground()); + jTextAreaBottom.setColumns(20); + jTextAreaBottom.setEditable(false); + jTextAreaBottom.setFont(new java.awt.Font("Dialog", 1, 12)); + jTextAreaBottom.setLineWrap(true); + jTextAreaBottom.setRows(2); + jTextAreaBottom.setText(bundle.getString("MSG_LicenseDlgLabelBottom")); + jTextAreaBottom.setWrapStyleWord(true); + jTextAreaBottom.setFocusable(false); + jTextAreaBottom.setRequestFocusEnabled(false); + add(jTextAreaBottom); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + javax.swing.JEditorPane jEditorPane1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextArea jTextAreaBottom; + private javax.swing.JTextArea jTextAreaTop; + // End of variables declaration//GEN-END:variables + private URL url; + private static final ResourceBundle bundle = NbBundle.getBundle(LicensePanel.class); + + /** + * An action to scroll the browser content up or down. + */ + private class ScrollAction extends AbstractAction { + int direction; + + public ScrollAction(int direction) { + this.direction = direction; + } + + public void actionPerformed(java.awt.event.ActionEvent e) { + Rectangle r = jEditorPane1.getVisibleRect(); + int increment = jEditorPane1.getScrollableUnitIncrement(r, SwingConstants.VERTICAL, direction); + r.y += (increment * direction); + jEditorPane1.scrollRectToVisible(r); + } + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/AutoUpgrade.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/AutoUpgrade.java new file mode 100644 index 000000000..fd39fe14c --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/AutoUpgrade.java @@ -0,0 +1,312 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2010 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade; +import java.beans.PropertyVetoException; +import java.io.*; +import java.net.URL; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.logging.Logger; +import javax.swing.JDialog; +import javax.swing.JOptionPane; +import org.netbeans.upgrade.systemoptions.Importer; +import org.netbeans.util.Util; +import org.openide.ErrorManager; +import org.openide.filesystems.FileUtil; +import org.openide.filesystems.LocalFileSystem; +import org.openide.filesystems.MultiFileSystem; +import org.openide.filesystems.XMLFileSystem; +import org.openide.modules.InstalledFileLocator; +import org.openide.util.Exceptions; +import org.openide.util.NbBundle; +import org.openide.util.Utilities; +import org.xml.sax.SAXException; + +/** pending + * + * @author Jiri Rechtacek, Jiri Skrivanek + */ +public final class AutoUpgrade { + + private static final Logger LOGGER = Logger.getLogger(AutoUpgrade.class.getName()); + + public static void main (String[] args) throws Exception { + // show warning if starts for the 1st time on changed userdir (see issue 196075) + String noteChangedDefaults = ""; + if (madeObsoleteMessagesLog()) { + noteChangedDefaults = NbBundle.getMessage (AutoUpgrade.class, "MSG_ChangedDefaults", System.getProperty ("netbeans.user", "")); // NOI18N + } + + // try new place + File sourceFolder = checkPreviousOnOsSpecificPlace (NEWER_VERSION_TO_CHECK); + if (sourceFolder == null) { + // try former place + sourceFolder = checkPrevious (VERSION_TO_CHECK); + } + if (sourceFolder != null) { + if (!showUpgradeDialog (sourceFolder, noteChangedDefaults)) { + throw new org.openide.util.UserCancelException (); + } + copyToUserdir(sourceFolder); + //migrates SystemOptions, converts them as a Preferences + Importer.doImport(); + } else if (! noteChangedDefaults.isEmpty()) { + // show a note only + showNoteDialog(noteChangedDefaults); + } + } + + //#75324 NBplatform settings are not imported + private static void upgradeBuildProperties(final File sourceFolder, final String[] version) throws IOException { + File userdir = new File(System.getProperty("netbeans.user", ""));//NOI18N + String[] regexForSelection = new String[]{ + "^nbplatform[.](?!default[.]netbeans[.]dest[.]dir).+[.].+=.+$", //NOI18N + // #161616 + "^var[.].*" //NOI18N + }; + Copy.appendSelectedLines(new File(sourceFolder, "build.properties"), //NOI18N + userdir, regexForSelection); + } + + // the order of VERSION_TO_CHECK here defines the precedence of imports + // the first one will be choosen for import + //normen + final static private List VERSION_TO_CHECK = + Arrays.asList (new String[] {".jmonkeyplatform/3.0Beta", ".jmonkeyplatform/3.0RC2" });//".netbeans/7.1.2", ".netbeans/7.1.1", ".netbeans/7.1", ".netbeans/7.0", ".netbeans/6.9" });//NOI18N +// Arrays.asList (new String[] {"build/3.0RC2", ".netbeans/7.1.1", ".netbeans/7.1", ".netbeans/7.0", ".netbeans/6.9" });//NOI18N + + // userdir on OS specific root of userdir (see issue 196075) + static final List NEWER_VERSION_TO_CHECK = + Arrays.asList ("3.0RC2", "3.0Beta"/*7.2, ..."*/); //NOI18N + + + private static File checkPreviousOnOsSpecificPlace (final List versionsToCheck) { + String defaultUserdirRoot = System.getProperty ("netbeans.default_userdir_root"); // NOI18N + //normen: to test in ide + if(defaultUserdirRoot==null){ + try { + defaultUserdirRoot = new File(System.getProperty("netbeans.user")).getParentFile().getCanonicalPath(); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + } + File sourceFolder; + if (defaultUserdirRoot != null) { + File userHomeFile = new File (defaultUserdirRoot); + for (String ver : versionsToCheck) { + sourceFolder = new File (userHomeFile.getAbsolutePath (), ver); + if (sourceFolder.exists () && sourceFolder.isDirectory ()) { + return sourceFolder; + } + } + } + return null; + } + + static private File checkPrevious (final List versionsToCheck) { + String userHome = System.getProperty ("user.home"); // NOI18N + File sourceFolder = null; + + if (userHome != null) { + File userHomeFile = new File (userHome); + Iterator it = versionsToCheck.iterator (); + String ver; + while (it.hasNext () && sourceFolder == null) { + ver = it.next (); + sourceFolder = new File (userHomeFile.getAbsolutePath (), ver); + + if (sourceFolder.isDirectory ()) { + break; + } + sourceFolder = null; + } + return sourceFolder; + } else { + return null; + } + } + + private static boolean madeObsoleteMessagesLog() { + String ud = System.getProperty ("netbeans.user", ""); + if ((Utilities.isMac() || Utilities.isWindows()) && ud.endsWith(File.separator + "dev")) { // NOI18N + String defaultUserdirRoot = System.getProperty ("netbeans.default_userdir_root", null); // NOI18N + if (defaultUserdirRoot != null) { + if (new File(ud).getParentFile().equals(new File(defaultUserdirRoot))) { + // check the former default root + String userHome = System.getProperty("user.home"); // NOI18N + if (userHome != null) { + File oldUserdir = new File(new File (userHome).getAbsolutePath (), ".netbeans/dev"); // NOI18N + if (oldUserdir.exists() && ! oldUserdir.equals(new File(ud))) { + // 1. modify messages log + File log = new File (oldUserdir, "/var/log/messages.log"); + File obsolete = new File (oldUserdir, "/var/log/messages.log.obsolete"); + if (! obsolete.exists() && log.exists()) { + return log.renameTo(obsolete); + } + } + } + } + } + } + return false; + } + + private static boolean showUpgradeDialog (final File source, String note) { + Util.setDefaultLookAndFeel(); + JOptionPane p = new JOptionPane ( + new AutoUpgradePanel (source.getAbsolutePath (), note), + JOptionPane.QUESTION_MESSAGE, + JOptionPane.YES_NO_OPTION + ); + JDialog d = Util.createJOptionDialog(p, NbBundle.getMessage (AutoUpgrade.class, "MSG_Confirmation_Title")); + d.setVisible (true); + + return new Integer (JOptionPane.YES_OPTION).equals (p.getValue ()); + } + + private static void showNoteDialog (String note) { + Util.setDefaultLookAndFeel(); + JOptionPane p = new JOptionPane(new AutoUpgradePanel (null, note), JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION); + JDialog d = Util.createJOptionDialog(p, NbBundle.getMessage (AutoUpgrade.class, "MSG_Note_Title")); + d.setVisible (true); + } + + static void doUpgrade (File source, String oldVersion) + throws java.io.IOException, java.beans.PropertyVetoException { + File userdir = new File(System.getProperty ("netbeans.user", "")); // NOI18N + + java.util.Set includeExclude; + try { + Reader r = new InputStreamReader ( + AutoUpgrade.class.getResourceAsStream ("copy" + oldVersion), // NOI18N + "utf-8"); // NOI18N + includeExclude = IncludeExclude.create (r); + r.close (); + } catch (IOException ex) { + throw new IOException("Cannot import from version: " + oldVersion, ex); + } + + ErrorManager.getDefault ().log ( + ErrorManager.USER, "Import: Old version: " // NOI18N + + oldVersion + ". Importing from " + source + " to " + userdir // NOI18N + ); + + File oldConfig = new File (source, "config"); // NOI18N + org.openide.filesystems.FileSystem old; + { + LocalFileSystem lfs = new LocalFileSystem (); + lfs.setRootDirectory (oldConfig); + + XMLFileSystem xmlfs = null; + try { + URL url = AutoUpgrade.class.getResource("layer" + oldVersion + ".xml"); // NOI18N + xmlfs = (url != null) ? new XMLFileSystem(url) : null; + } catch (SAXException ex) { + throw new IOException("Cannot import from version: " + oldVersion, ex); + } + + old = (xmlfs != null) ? createLayeredSystem(lfs, xmlfs) : lfs; + } + + Copy.copyDeep (old.getRoot (), FileUtil.getConfigRoot (), includeExclude, PathTransformation.getInstance(oldVersion)); + + } + + /* copy-pasted method doUpgrade and slightly modified to copy files relative + * to userdir. + */ + private static void doNonStandardUpgrade (File source,String oldVersion) + throws IOException, PropertyVetoException { + File userdir = new File(System.getProperty("netbeans.user", "")); // NOI18N + java.util.Set includeExclude; + try { + InputStream is = AutoUpgrade.class.getResourceAsStream("nonstandard" + oldVersion); // NOI18N + if (is == null) { + return; + } + Reader r = new InputStreamReader(is, "utf-8"); // NOI18N + includeExclude = IncludeExclude.create(r); + r.close(); + } catch (IOException ex) { + throw new IOException("Cannot import from version: " + oldVersion + "nonstandard", ex); + } + ErrorManager.getDefault ().log (ErrorManager.USER, "Import: Old version: " // NOI18N + + oldVersion + "nonstandard" + ". Importing from " + source + " to " + userdir // NOI18N + ); + + LocalFileSystem old = new LocalFileSystem(); + old.setRootDirectory(source); + + LocalFileSystem nfs = new LocalFileSystem(); + nfs.setRootDirectory(userdir); + Copy.copyDeep(old.getRoot(), nfs.getRoot(), includeExclude, PathTransformation.getInstance(oldVersion)); + } + + + static MultiFileSystem createLayeredSystem(final LocalFileSystem lfs, final XMLFileSystem xmlfs) { + MultiFileSystem old; + + old = new MultiFileSystem ( + new org.openide.filesystems.FileSystem[] { lfs, xmlfs } + ) { + { + setPropagateMasks(true); + } + }; + return old; + } + + /* Copy files from source folder to current userdir according to include/exclude + * patterns in etc/netbeans.import file. */ + private static void copyToUserdir(File source) throws IOException, PropertyVetoException { + File userdir = new File(System.getProperty("netbeans.user", "")); // NOI18N + File netBeansDir = InstalledFileLocator.getDefault().locate("modules", null, false).getParentFile().getParentFile(); //NOI18N + File importFile = new File(netBeansDir, "etc/jmonkeyplatform.import"); //NOI18N + LOGGER.fine("Import file: " + importFile); + LOGGER.info("Importing from " + source + " to " + userdir); // NOI18N + CopyFiles.copyDeep(source, userdir, importFile); + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/AutoUpgradePanel.form b/sdk/jme3-upgrader/src/org/netbeans/upgrade/AutoUpgradePanel.form new file mode 100644 index 000000000..5033b900a --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/AutoUpgradePanel.form @@ -0,0 +1,53 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/AutoUpgradePanel.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/AutoUpgradePanel.java new file mode 100644 index 000000000..1f9f5bbeb --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/AutoUpgradePanel.java @@ -0,0 +1,137 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade; + +import java.util.ArrayList; +import java.util.List; +import java.util.ResourceBundle; +import javax.swing.JPanel; +import javax.swing.event.ChangeListener; +import org.openide.util.NbBundle; + + +/** + * @author Jiri Rechtacek + */ +final class AutoUpgradePanel extends JPanel { + + private String source; + private String note; + + /** Creates new form UpgradePanel */ + public AutoUpgradePanel (String directory, String note) { + this.source = directory; + this.note = note; + initComponents(); + initAccessibility(); + } + + /** Remove a listener to changes of the panel's validity. + * @param l the listener to remove + */ + void removeChangeListener(ChangeListener l) { + changeListeners.remove(l); + } + + /** Add a listener to changes of the panel's validity. + * @param l the listener to add + * @see #isValid + */ + void addChangeListener(ChangeListener l) { + if (!changeListeners.contains(l)) { + changeListeners.add(l); + } + } + + private void initAccessibility() { + this.getAccessibleContext().setAccessibleDescription(bundle.getString("MSG_Confirmation")); // NOI18N + } + + + /** 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() { + + txtVersions = new javax.swing.JTextArea(); + + setPreferredSize(new java.awt.Dimension(550, source != null && ! note.isEmpty() ? 120 : 60)); + + txtVersions.setBackground(getBackground()); + txtVersions.setColumns(50); + txtVersions.setEditable(false); + txtVersions.setFont(new java.awt.Font("Dialog", 0, 12)); + txtVersions.setLineWrap(true); + txtVersions.setRows(source != null && ! note.isEmpty() ? 6 : 3); + if (source != null) { + txtVersions.setText(NbBundle.getMessage (AutoUpgradePanel.class, "MSG_Confirmation", source, note)); // NOI18N + } else { + txtVersions.setText(note); + } + txtVersions.setWrapStyleWord(true); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtVersions, javax.swing.GroupLayout.DEFAULT_SIZE, 583, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtVersions, javax.swing.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE) + ); + }// //GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextArea txtVersions; + // End of variables declaration//GEN-END:variables + + private static final ResourceBundle bundle = NbBundle.getBundle(AutoUpgradePanel.class); + private List changeListeners = new ArrayList(1); + +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/Bundle.properties b/sdk/jme3-upgrader/src/org/netbeans/upgrade/Bundle.properties new file mode 100644 index 000000000..ac519cfe3 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/Bundle.properties @@ -0,0 +1,54 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. +# +# Oracle and Java are registered trademarks of Oracle and/or its affiliates. +# Other names may be trademarks of their respective owners. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# Contributor(s): +# +# The Original Software is NetBeans. The Initial Developer of the Original +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun +# Microsystems, Inc. All Rights Reserved. +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. + +OpenIDE-Module-Name=Upgrade +OpenIDE-Module-Display-Category=Infrastructure +OpenIDE-Module-Long-Description=The Upgrade imports your IDE environment and settings from previous versions of the IDE. +OpenIDE-Module-Short-Description=Import IDE environment and settings. + +#AutoUpgdare dialog +MSG_Confirmation = {1}Settings created by a previous version of the IDE were found on your system at {0}. Do you want to import them? +MSG_Confirmation_Title = Confirm Import Settings + +MSG_Note_Title=Note +MSG_ChangedDefaults=Note: The default location of NetBeans userdir was changed to {0}\n\ +See http://wiki.netbeans.org/UserdirAndCachedirFoldersInSystemSpecificPaths\n\n \ No newline at end of file diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/ColoringStorage.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/ColoringStorage.java new file mode 100644 index 000000000..f0c72c3f1 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/ColoringStorage.java @@ -0,0 +1,335 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade; + +import java.awt.Color; +import java.io.IOException; +import java.io.InputStream; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import javax.swing.text.AttributeSet; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; +import org.netbeans.upgrade.XMLStorage.Attribs; +import org.openide.ErrorManager; + +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + + +/** + * This class contains support static methods for loading / saving and + * translating coloring (fontsColors.xml) files. It calls XMLStorage utilities. + * + * @author Jan Jancura + */ +class ColoringStorage { + + + // load .................................................................... + + static Map loadColorings ( + InputStream is, + String name + ) { + return (Map) XMLStorage.load (is, name, new ColoringsReader ()); + } + + private static class ColoringsReader extends XMLStorage.Handler { + private Map colorings = new HashMap (); + private SimpleAttributeSet last; + + Object getResult () { + return colorings; + } + + public void startElement ( + String uri, + String localName, + String name, + Attributes attributes + ) throws SAXException { + try { + if (name.equals ("fontscolors")) { + } else + if (name.equals ("fontcolor")) { + String n = (String) attributes.getValue ("syntaxName"); + if (n == null) + n = (String) attributes.getValue ("name"); + if (n == null) { + System.out.println("no syntaxName " + attributes); + return; + } + SimpleAttributeSet a = new SimpleAttributeSet (); + a.addAttribute ( + StyleConstants.NameAttribute, + n + ); + if (attributes.getValue ("bgColor") != null) + a.addAttribute ( + StyleConstants.Background, + XMLStorage.stringToColor (attributes.getValue ("bgColor")) + ); + if (attributes.getValue ("foreColor") != null) + a.addAttribute ( + StyleConstants.Foreground, + XMLStorage.stringToColor (attributes.getValue ("foreColor")) + ); + if (attributes.getValue ("underline") != null) + a.addAttribute ( + StyleConstants.Underline, + XMLStorage.stringToColor (attributes.getValue ("underline")) + ); + if (attributes.getValue ("strikeThrough") != null) + a.addAttribute ( + StyleConstants.StrikeThrough, + XMLStorage.stringToColor (attributes.getValue ("strikeThrough")) + ); + if (attributes.getValue ("waveUnderlined") != null) + a.addAttribute ( + "waveUnderlined", + XMLStorage.stringToColor (attributes.getValue ("waveUnderlined")) + ); + if (attributes.getValue ("default") != null) + a.addAttribute ( + "default", + (String) attributes.getValue ("default") + ); + colorings.put (n, a); + last = a; + } else + if (name.equals ("font")) { + if (attributes.getValue ("name") != null) + last.addAttribute ( + StyleConstants.FontFamily, + attributes.getValue ("name") + ); + if (attributes.getValue ("size") != null) + try { + last.addAttribute ( + StyleConstants.FontSize, + Integer.decode (attributes.getValue ("size")) + ); + } catch (NumberFormatException ex) { + ex.printStackTrace (); + } + if (attributes.getValue ("style") != null) { + if (attributes.getValue ("style").indexOf ("bold") >= 0) + last.addAttribute ( + StyleConstants.Bold, + Boolean.TRUE + ); + if (attributes.getValue ("style").indexOf ("italic") >= 0) + last.addAttribute ( + StyleConstants.Italic, + Boolean.TRUE + ); + } + } + } catch (Exception ex) { + ErrorManager.getDefault ().notify (ex); + } + } + + public InputSource resolveEntity (String pubid, String sysid) { + return new InputSource ( + new java.io.ByteArrayInputStream (new byte [0]) + ); + } + } + + + // save colorings .......................................................... + + static void saveColorings (FileObject fo, Collection colorings) { + final StringBuffer sb = XMLStorage.generateHeader (); + XMLStorage.generateFolderStart (sb, "fontscolors", null, ""); + Iterator it = colorings.iterator (); + while (it.hasNext ()) { + AttributeSet category = (AttributeSet) it.next (); + Attribs attributes = new Attribs (true); + attributes.add ( + "name", + (String) category.getAttribute (StyleConstants.NameAttribute) + ); + if (category.isDefined (StyleConstants.Foreground)) + attributes.add ( + "foreColor", + XMLStorage.colorToString ( + (Color) category.getAttribute (StyleConstants.Foreground) + ) + ); + if (category.isDefined (StyleConstants.Background)) + attributes.add ( + "bgColor", + XMLStorage.colorToString ( + (Color) category.getAttribute (StyleConstants.Background) + ) + ); + if (category.isDefined (StyleConstants.StrikeThrough)) + attributes.add ( + "strikeThrough", + XMLStorage.colorToString ( + (Color) category.getAttribute (StyleConstants.StrikeThrough) + ) + ); + if (category.isDefined ("waveUnderlined")) + attributes.add ( + "waveUnderlined", + XMLStorage.colorToString ( + (Color) category.getAttribute ("waveUnderlined") + ) + ); + if (category.isDefined (StyleConstants.Underline)) + attributes.add ( + "underline", + XMLStorage.colorToString ( + (Color) category.getAttribute (StyleConstants.Underline) + ) + ); + if (category.isDefined ("default")) + attributes.add ( + "default", + (String) category.getAttribute ("default") + ); + if ( category.isDefined (StyleConstants.FontFamily) || + category.isDefined (StyleConstants.FontSize) || + category.isDefined (StyleConstants.Bold) || + category.isDefined (StyleConstants.Italic) + ) { + XMLStorage.generateFolderStart (sb, "fontcolor", attributes, " "); + attributes = new Attribs (true); + if (category.isDefined (StyleConstants.FontFamily)) + attributes.add ( + "name", + (String) category.getAttribute (StyleConstants.FontFamily) + ); + if (category.isDefined (StyleConstants.FontSize)) + attributes.add ( + "size", + "" + category.getAttribute (StyleConstants.FontSize) + ); + if (category.isDefined (StyleConstants.Bold) || + category.isDefined (StyleConstants.Italic) + ) { + Boolean bold = Boolean.FALSE, italic = Boolean.FALSE; + if (category.isDefined (StyleConstants.Bold)) + bold = (Boolean) category.getAttribute (StyleConstants.Bold); + if (category.isDefined (StyleConstants.Italic)) + italic = (Boolean) category.getAttribute (StyleConstants.Italic); + attributes.add ("style", + bold.booleanValue () ? + (italic.booleanValue () ? + "bold+italic" : + "bold") : + (italic.booleanValue () ? + "italic" : "plain") + ); + } + XMLStorage.generateLeaf (sb, "font", attributes, " "); + XMLStorage.generateFolderEnd (sb, "fontcolor", " "); + } else + XMLStorage.generateLeaf (sb, "fontcolor", attributes, " "); + } + XMLStorage.generateFolderEnd (sb, "fontscolors", ""); + XMLStorage.save (fo, new String (sb)); + } + + /** + * Crates FileObject for given mimeTypes and profile. + */ + private static String getFolderName ( + String[] mimeTypes, + String profile + ) { + StringBuffer sb = new StringBuffer (); + sb.append ("Editors"); + int i, k = mimeTypes.length; + for (i = 0; i < k; i++) + sb.append ('/').append (mimeTypes [i]); + if (profile != null) + sb.append ('/').append (profile); + return sb.append ('/').toString (); + } + + /** + * Crates FileObject for given mimeTypes and profile. + */ + private static FileObject createFileObject ( + FileObject root, + String[] mimeTypes, + String profile, + String fileName + ) { + try { + FileObject fo = getFO (FileUtil.getConfigRoot (), "Editors"); + int i, k = mimeTypes.length; + for (i = 0; i < k; i++) + fo = getFO (fo, mimeTypes [i]); + if (profile != null) + fo = getFO (fo, profile); + if (fileName == null) + return fo; + FileObject fo1 = fo.getFileObject (fileName); + if (fo1 != null) return fo1; + return fo.createData (fileName); + } catch (IOException ex) { + ErrorManager.getDefault ().notify (ex); + return null; + } + } + + private static FileObject getFO (FileObject fo, String next) throws IOException { + FileObject fo1 = fo.getFileObject (next); + if (fo1 == null) + return fo.createFolder (next); + return fo1; + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/Copy.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/Copy.java new file mode 100644 index 000000000..e4816b874 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/Copy.java @@ -0,0 +1,210 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade; + +import java.io.*; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.openide.filesystems.*; + +/** Does copy of objects on filesystems. + * + * @author Jaroslav Tulach + */ +final class Copy extends Object { + private FileObject sourceRoot; + private FileObject targetRoot; + private Set thoseToCopy; + private PathTransformation transformation; + + private Copy(FileObject source, FileObject target, Set thoseToCopy, PathTransformation transformation) { + this.sourceRoot = source; + this.targetRoot = target; + this.thoseToCopy = thoseToCopy; + this.transformation = transformation; + } + + /** Does a selective copy of one source tree to another. + * @param source file object to copy from + * @param target file object to copy to + * @param thoseToCopy set on which contains (relativeNameOfAFileToCopy) + * is being called to find out whether to copy or not + * @throws IOException if coping fails + */ + public static void copyDeep (FileObject source, FileObject target, Set thoseToCopy) + throws IOException { + copyDeep(source, target, thoseToCopy, null); + } + + public static void copyDeep (FileObject source, FileObject target, Set thoseToCopy, PathTransformation transformation) + throws IOException { + Copy instance = new Copy(source, target, thoseToCopy, transformation); + instance.copyFolder (instance.sourceRoot); + } + + + private void copyFolder (FileObject sourceFolder) throws IOException { + FileObject[] srcChildren = sourceFolder.getChildren(); + for (int i = 0; i < srcChildren.length; i++) { + FileObject child = srcChildren[i]; + if (child.isFolder()) { + copyFolder (child); + // make sure 'include xyz/.*' copies xyz folder's attributes + if ((thoseToCopy.contains (child.getPath()) || thoseToCopy.contains (child.getPath() + "/")) && //NOI18N + child.getAttributes().hasMoreElements() + ) { + copyFolderAttributes(child); + } + } else { + if (thoseToCopy.contains (child.getPath())) { + copyFile(child); + } + } + } + } + + private void copyFolderAttributes(FileObject sourceFolder) throws IOException { + FileObject targetFolder = FileUtil.createFolder (targetRoot, sourceFolder.getPath()); + if (sourceFolder.getAttributes ().hasMoreElements ()) { + FileUtil.copyAttributes(sourceFolder, targetFolder); + } + } + + private void copyFile(FileObject sourceFile) throws IOException { + String targetPath = (transformation != null) ? transformation.transformPath(sourceFile.getPath()) : sourceFile.getPath(); + boolean isTransformed = !targetPath.equals(sourceFile.getPath()); + FileObject tg = targetRoot.getFileObject(targetPath); + try { + if (tg == null) { + // copy the file otherwise keep old content + FileObject targetFolder = null; + String name = null, ext = null; + if (isTransformed) { + FileObject targetFile = FileUtil.createData(targetRoot, targetPath); + targetFolder = targetFile.getParent(); + name = targetFile.getName(); + ext = targetFile.getExt(); + targetFile.delete(); + } else { + targetFolder = FileUtil.createFolder(targetRoot, sourceFile.getParent().getPath()); + name = sourceFile.getName(); + ext = sourceFile.getExt(); + } + tg = FileUtil.copyFile(sourceFile, targetFolder, name, ext); + } + } catch (IOException ex) { + if (sourceFile.getNameExt().endsWith("_hidden")) { + return; + } + throw ex; + } + FileUtil.copyAttributes(sourceFile, tg); + } + + public static void appendSelectedLines(File sourceFile, File targetFolder, String[] regexForSelection) + throws IOException { + if (!sourceFile.exists()) { + return; + } + Pattern[] linePattern = new Pattern[regexForSelection.length]; + for (int i = 0; i < linePattern.length; i++) { + linePattern[i] = Pattern.compile(regexForSelection[i]); + } + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + File targetFile = new File(targetFolder,sourceFile.getName()); + if (!targetFolder.exists()) { + targetFolder.mkdirs(); + } + assert targetFolder.exists(); + + if (!targetFile.exists()) { + targetFile.createNewFile(); + } else { + //read original content into ByteArrayOutputStream + FileInputStream targetIS = new FileInputStream(targetFile); + try { + FileUtil.copy(targetIS, bos); + } finally { + targetIS.close(); + } + } + assert targetFile.exists(); + + + //append lines into ByteArrayOutputStream + String line = null; + BufferedReader sourceReader = new BufferedReader(new FileReader(sourceFile)); + try { + while ((line = sourceReader.readLine()) != null) { + if (linePattern != null) { + for (int i = 0; i < linePattern.length; i++) { + Matcher m = linePattern[i].matcher(line); + if (m.matches()) { + bos.write(line.getBytes()); + bos.write('\n'); + break; + } + } + } else { + bos.write(line.getBytes()); + bos.write('\n'); + } + } + } finally { + sourceReader.close(); + } + + ByteArrayInputStream bin = new ByteArrayInputStream(bos.toByteArray()); + FileOutputStream targetOS = new FileOutputStream(targetFile); + try { + FileUtil.copy(bin, targetOS); + } finally { + bin.close(); + targetOS.close(); + } + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/CopyFiles.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/CopyFiles.java new file mode 100644 index 000000000..dd9e5c929 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/CopyFiles.java @@ -0,0 +1,367 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2010 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ +package org.netbeans.upgrade; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.Reader; +import java.util.HashSet; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JDialog; +import javax.swing.JOptionPane; +import org.netbeans.util.Util; +import org.openide.filesystems.FileUtil; +import org.openide.util.EditableProperties; + +/** Does copy of files according to include/exclude patterns. + * + * @author Jiri Skrivanek + */ +final class CopyFiles extends Object { + + private File sourceRoot; + private File targetRoot; + private EditableProperties currentProperties; + private Set includePatterns = new HashSet(); + private Set excludePatterns = new HashSet(); + private static final Logger LOGGER = Logger.getLogger(CopyFiles.class.getName()); + + private CopyFiles(File source, File target, File patternsFile) { + this.sourceRoot = source; + this.targetRoot = target; + try { + InputStream is = new FileInputStream(patternsFile); + Reader reader = new InputStreamReader(is, "utf-8"); // NOI18N + readPatterns(reader); + reader.close(); + } catch (IOException ex) { + // show error message and continue + JDialog dialog = Util.createJOptionDialog(new JOptionPane(ex, JOptionPane.ERROR_MESSAGE), ex.getMessage()); + dialog.setVisible(true); + return; + } + } + + public static void copyDeep(File source, File target, File patternsFile) throws IOException { + CopyFiles copyFiles = new CopyFiles(source, target, patternsFile); + LOGGER.fine("Copying from: " + copyFiles.sourceRoot + "\nto: " + copyFiles.targetRoot); //NOI18N + copyFiles.copyFolder(copyFiles.sourceRoot); + } + + private void copyFolder(File sourceFolder) throws IOException { + File[] srcChildren = sourceFolder.listFiles(); + if (srcChildren == null) { + LOGGER.info(sourceFolder + " is not a directory or is invalid."); //NOI18N + return ; + } + for (File child : srcChildren) { + if (child.isDirectory()) { + copyFolder(child); + } else { + copyFile(child); + } + } + } + + /** Returns slash separated path relative to given root. */ + private static String getRelativePath(File root, File file) { + String result = file.getAbsolutePath().substring(root.getAbsolutePath().length()); + result = result.replace('\\', '/'); //NOI18N + if (result.startsWith("/") && !result.startsWith("//")) { //NOI18N + result = result.substring(1); + } + return result; + } + + /** Copy source file to target file. It creates necessary sub folders. + * @param sourceFile source file + * @param targetFile target file + * @throws java.io.IOException if copying fails + */ + private static void copyFile(File sourceFile, File targetFile) throws IOException { + ensureParent(targetFile); + InputStream ins = null; + OutputStream out = null; + try { + ins = new FileInputStream(sourceFile); + out = new FileOutputStream(targetFile); + FileUtil.copy(ins, out); + } finally { + if (ins != null) { + ins.close(); + } + if (out != null) { + out.close(); + } + } + } + + /** Copy given file to target root dir if matches include/exclude patterns. + * If properties pattern is applicable, it copies only matching keys. + * @param sourceFile source file + * @throws java.io.IOException if copying fails + */ + private void copyFile(File sourceFile) throws IOException { + String relativePath = getRelativePath(sourceRoot, sourceFile); + currentProperties = null; + boolean includeFile = false; + Set includeKeys = new HashSet(); + Set excludeKeys = new HashSet(); + for (String pattern : includePatterns) { + if (pattern.contains("#")) { //NOI18N + includeKeys.addAll(matchingKeys(relativePath, pattern)); + } else { + if (relativePath.matches(pattern)) { + includeFile = true; + includeKeys.clear(); // include entire file + break; + } + } + } + if (includeFile || !includeKeys.isEmpty()) { + // check excludes + for (String pattern : excludePatterns) { + if (pattern.contains("#")) { //NOI18N + excludeKeys.addAll(matchingKeys(relativePath, pattern)); + } else { + if (relativePath.matches(pattern)) { + includeFile = false; + includeKeys.clear(); // exclude entire file + break; + } + } + } + } + LOGGER.log(Level.FINEST, "{0}, includeFile={1}, includeKeys={2}, excludeKeys={3}", new Object[]{relativePath, includeFile, includeKeys, excludeKeys}); //NOI18N + if (!includeFile && includeKeys.isEmpty()) { + // nothing matches + return; + } + + File targetFile = new File(targetRoot, relativePath); + LOGGER.log(Level.FINE, "Path: {0}", relativePath); //NOI18N + if (includeKeys.isEmpty() && excludeKeys.isEmpty()) { + // copy entire file + copyFile(sourceFile, targetFile); + } else { + if (!includeKeys.isEmpty()) { + currentProperties.keySet().retainAll(includeKeys); + } + currentProperties.keySet().removeAll(excludeKeys); + // copy just selected keys + LOGGER.log(Level.FINE, " Only keys: {0}", currentProperties.keySet()); + OutputStream out = null; + try { + ensureParent(targetFile); + out = new FileOutputStream(targetFile); + currentProperties.store(out); + } finally { + if (out != null) { + out.close(); + } + } + } + } + + /** Returns set of keys matching given pattern. + * @param relativePath path relative to sourceRoot + * @param propertiesPattern pattern like file.properties#keyPattern + * @return set of matching keys, never null + * @throws IOException if properties cannot be loaded + */ + private Set matchingKeys(String relativePath, String propertiesPattern) throws IOException { + Set matchingKeys = new HashSet(); + String[] patterns = propertiesPattern.split("#", 2); + String filePattern = patterns[0]; + String keyPattern = patterns[1]; + if (relativePath.matches(filePattern)) { + if (currentProperties == null) { + currentProperties = getProperties(relativePath); + } + for (String key : currentProperties.keySet()) { + if (key.matches(keyPattern)) { + matchingKeys.add(key); + } + } + } + return matchingKeys; + } + + /** Returns properties from relative path. + * @param relativePath relative path + * @return properties from relative path. + * @throws IOException if cannot open stream + */ + private EditableProperties getProperties(String relativePath) throws IOException { + EditableProperties properties = new EditableProperties(false); + InputStream in = null; + try { + in = new FileInputStream(new File(sourceRoot, relativePath)); + properties.load(in); + } finally { + if (in != null) { + in.close(); + } + } + return properties; + } + + /** Creates parent of given file, if doesn't exist. */ + private static void ensureParent(File file) throws IOException { + final File parent = file.getParentFile(); + if (parent != null && !parent.exists()) { + if (!parent.mkdirs()) { + throw new IOException("Cannot create folder: " + parent.getAbsolutePath()); //NOI18N + } + } + } + + /** Reads the include/exclude set from a given reader. + * @param r reader + */ + private void readPatterns(Reader r) throws IOException { + BufferedReader buf = new BufferedReader(r); + for (;;) { + String line = buf.readLine(); + if (line == null) { + break; + } + line = line.trim(); + if (line.length() == 0 || line.startsWith("#")) { //NOI18N + continue; + } + if (line.startsWith("include ")) { //NOI18N + line = line.substring(8); + if (line.length() > 0) { + includePatterns.addAll(parsePattern(line)); + } + } else if (line.startsWith("exclude ")) { //NOI18N + line = line.substring(8); + if (line.length() > 0) { + excludePatterns.addAll(parsePattern(line)); + } + } else { + throw new java.io.IOException("Wrong line: " + line); //NOI18N + } + } + } + + enum ParserState { + + START, + IN_KEY_PATTERN, + AFTER_KEY_PATTERN, + IN_BLOCK + } + + /** Parses given compound string pattern into set of single patterns. + * @param pattern compound pattern in form filePattern1#keyPattern1#|filePattern2#keyPattern2#|filePattern3 + * @return set of single patterns containing just one # (e.g. [filePattern1#keyPattern1, filePattern2#keyPattern2, filePattern3]) + */ + private static Set parsePattern(String pattern) { + Set patterns = new HashSet(); + if (pattern.contains("#")) { //NOI18N + StringBuilder partPattern = new StringBuilder(); + ParserState state = ParserState.START; + int blockLevel = 0; + for (int i = 0; i < pattern.length(); i++) { + char c = pattern.charAt(i); + switch (state) { + case START: + if (c == '#') { + state = ParserState.IN_KEY_PATTERN; + partPattern.append(c); + } else if (c == '(') { + state = ParserState.IN_BLOCK; + blockLevel++; + partPattern.append(c); + } else if (c == '|') { + patterns.add(partPattern.toString()); + partPattern = new StringBuilder(); + } else { + partPattern.append(c); + } + break; + case IN_KEY_PATTERN: + if (c == '#') { + state = ParserState.AFTER_KEY_PATTERN; + } else { + partPattern.append(c); + } + break; + case AFTER_KEY_PATTERN: + if (c == '|') { + state = ParserState.START; + patterns.add(partPattern.toString()); + partPattern = new StringBuilder(); + } else { + assert false : "Wrong OptionsExport pattern " + pattern + ". Only format like filePattern1#keyPattern#|filePattern2 is supported."; //NOI18N + } + break; + case IN_BLOCK: + partPattern.append(c); + if (c == ')') { + blockLevel--; + if (blockLevel == 0) { + state = ParserState.START; + } + } + break; + } + } + patterns.add(partPattern.toString()); + } else { + patterns.add(pattern); + } + return patterns; + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/IncludeExclude.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/IncludeExclude.java new file mode 100644 index 000000000..0cb9936fa --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/IncludeExclude.java @@ -0,0 +1,138 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade; + +import java.io.*; +import java.util.*; +import java.util.regex.*; +import org.openide.util.Union2; + + + +/** A test that is initialized based on includes and excludes. + * + * @author Jaroslav Tulach + */ +final class IncludeExclude extends AbstractSet { + /** List + */ + private List> patterns = new ArrayList> (); + + private IncludeExclude () { + } + + /** Reads the include/exclude set from a given reader. + * @param r reader + * @return set that accepts names based on include exclude from the file + */ + public static IncludeExclude create (Reader r) throws IOException { + IncludeExclude set = new IncludeExclude (); + + BufferedReader buf = new BufferedReader (r); + for (;;) { + String line = buf.readLine (); + if (line == null) break; + + line = line.trim (); + if (line.length () == 0 || line.startsWith ("#")) { + continue; + } + + Boolean plus; + if (line.startsWith ("include ")) { + line = line.substring (8); + plus = Boolean.TRUE; + } else { + if (line.startsWith ("exclude ")) { + line = line.substring (8); + plus = Boolean.FALSE; + } else { + throw new java.io.IOException ("Wrong line: " + line); + } + } + + Pattern p = Pattern.compile (line); + + set.patterns.add (Union2.createFirst(plus)); + set.patterns.add (Union2.createSecond(p)); + } + + return set; + } + + + public Iterator iterator () { + return null; + } + + public int size () { + return 0; + } + + @Override + public boolean contains (Object o) { + String s = (String)o; + + boolean yes = false; + + Iterator> it = patterns.iterator (); + while (it.hasNext ()) { + Boolean include = it.next ().first(); + Pattern p = it.next ().second(); + + Matcher m = p.matcher (s); + if (m.matches ()) { + yes = include.booleanValue (); + if (!yes) { + // exclude matches => immediately return + return false; + } + } + } + + return yes; + } + +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/PathTransformation.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/PathTransformation.java new file mode 100644 index 000000000..7f17f8490 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/PathTransformation.java @@ -0,0 +1,93 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ +package org.netbeans.upgrade; + +/** + * + * @author Radek Matous + */ +public class PathTransformation { + private String version; + private PathTransformation(String version) { + this.version = version; + } + public static PathTransformation getInstance(String version) { + return new PathTransformation(version); + } + + public String transformPath(String path) { + boolean isCreator = version.startsWith("2_");//NOI18N + if (isCreator) { + return transformCreatorPath(path); + } + + boolean i118364 = path.startsWith("Templates/Classes/");//NOI18N + if (i118364) { + if (!version.startsWith("6")) { + return transformTemplatePath118364(path); + } + } + + return path; + } + + private String transformTemplatePath118364(String path) { + return path.replace("Templates/Classes/", "Templates/Oldies/Classes/");//NOI18N + } + //CREATOR + private String transformCreatorPath(String path) { + String keyToReplace = null; + String[] keysToReplace = new String[] {"context.xml"};//NOI18N + for (String key : keysToReplace) { + if (path.startsWith(key)) { + keyToReplace = key; + break; + } + } + if (keyToReplace != null) { + return path.replace(keyToReplace, "config/"+version+"/"+keyToReplace);//NOI18N + } + return path; + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/XMLStorage.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/XMLStorage.java new file mode 100644 index 000000000..d9c4f46f8 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/XMLStorage.java @@ -0,0 +1,291 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade; + +import java.awt.Color; +import java.awt.Font; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openide.ErrorManager; +import org.openide.filesystems.FileLock; + +import org.openide.filesystems.FileObject; +import org.openide.util.RequestProcessor; +import org.openide.xml.XMLUtil; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.DefaultHandler; + + +public class XMLStorage { + + private static final Map colorToName = new HashMap (); + private static final Map nameToColor = new HashMap (); + private static final Map nameToFontStyle = new HashMap (); + private static final Map fontStyleToName = new HashMap (); + static { + colorToName.put (Color.black, "black"); + nameToColor.put ("black", Color.black); + colorToName.put (Color.blue, "blue"); + nameToColor.put ("blue", Color.blue); + colorToName.put (Color.cyan, "cyan"); + nameToColor.put ("cyan", Color.cyan); + colorToName.put (Color.darkGray, "darkGray"); + nameToColor.put ("darkGray", Color.darkGray); + colorToName.put (Color.gray, "gray"); + nameToColor.put ("gray", Color.gray); + colorToName.put (Color.green, "green"); + nameToColor.put ("green", Color.green); + colorToName.put (Color.lightGray, "lightGray"); + nameToColor.put ("lightGray", Color.lightGray); + colorToName.put (Color.magenta, "magenta"); + nameToColor.put ("magenta", Color.magenta); + colorToName.put (Color.orange, "orange"); + nameToColor.put ("orange", Color.orange); + colorToName.put (Color.pink, "pink"); + nameToColor.put ("pink", Color.pink); + colorToName.put (Color.red, "red"); + nameToColor.put ("red", Color.red); + colorToName.put (Color.white, "white"); + nameToColor.put ("white", Color.white); + colorToName.put (Color.yellow, "yellow"); + nameToColor.put ("yellow", Color.yellow); + + nameToFontStyle.put ("plain", Integer.valueOf (Font.PLAIN)); + fontStyleToName.put (Integer.valueOf (Font.PLAIN), "plain"); + nameToFontStyle.put ("bold", Integer.valueOf (Font.BOLD)); + fontStyleToName.put (Integer.valueOf (Font.BOLD), "bold"); + nameToFontStyle.put ("italic", Integer.valueOf (Font.ITALIC)); + fontStyleToName.put (Integer.valueOf (Font.ITALIC), "italic"); + nameToFontStyle.put ("bold+italic", Integer.valueOf (Font.BOLD + Font.ITALIC)); + fontStyleToName.put (Integer.valueOf (Font.BOLD + Font.ITALIC), "bold+italic"); + } + + static String colorToString (Color color) { + if (colorToName.containsKey (color)) + return (String) colorToName.get (color); + return Integer.toHexString (color.getRGB ()); + } + + static Color stringToColor (String color) throws Exception { + if (color.startsWith ("#")) + color = color.substring (1); + if (nameToColor.containsKey (color)) + return (Color) nameToColor.get (color); + try { + return new Color ((int) Long.parseLong (color, 16)); + } catch (NumberFormatException ex) { + throw new Exception (); + } + } + + + // generics support methods ................................................ + + private static RequestProcessor requestProcessor = new RequestProcessor ("XMLStorage"); + + static void save (final FileObject fo, final String content) { + if (fo == null) throw new NullPointerException (); + if (content == null) throw new NullPointerException (); + requestProcessor.post (new Runnable () { + public void run () { + try { + FileLock lock = fo.lock (); + try { + OutputStream os = fo.getOutputStream (lock); + Writer writer = new OutputStreamWriter (os, "UTF-8"); // NOI18N + try { + writer.write (content); + } finally { + writer.close (); + } + } finally { + lock.releaseLock (); + } + } catch (IOException ex) { + ErrorManager.getDefault ().notify (ex); + } + } + }); + } + + static Object load (InputStream is, String name, Handler handler) { + try { + try { + XMLReader reader = XMLUtil.createXMLReader (); + reader.setEntityResolver (handler); + reader.setContentHandler (handler); + reader.parse (new InputSource (is)); + return handler.getResult (); + } finally { + is.close (); + } + } catch (SAXException ex) { + if (System.getProperty ("org.netbeans.optionsDialog") != null) { + System.out.println("File: " + name); + ex.printStackTrace (); + } + return handler.getResult (); + } catch (IOException ex) { + if (System.getProperty ("org.netbeans.optionsDialog") != null) { + System.out.println("File: " + name); + ex.printStackTrace (); + } + return handler.getResult (); + } catch (Exception ex) { + if (System.getProperty ("org.netbeans.optionsDialog") != null) { + System.out.println("File: " + name); + ex.printStackTrace (); + } + return handler.getResult (); + } + } + + static StringBuffer generateHeader () { + StringBuffer sb = new StringBuffer (); + sb.append ("\n\n"); + return sb; + } + + static void generateFolderStart ( + StringBuffer sb, + String name, + Attribs attributes, + String indentation + ) { + sb.append (indentation).append ('<').append (name); + if (attributes != null) { + if (!attributes.oneLine) sb.append ('\n'); + else sb.append (' '); + generateAttributes (sb, attributes, indentation + " "); + if (!attributes.oneLine) sb.append (indentation); + sb.append (">\n"); + } else + sb.append (">\n"); + } + + static void generateFolderEnd (StringBuffer sb, String name, String indentation) { + sb.append (indentation).append ("\n"); + } + + static void generateLeaf ( + StringBuffer sb, + String name, + Attribs attributes, + String indentation + ) { + sb.append (indentation).append ('<').append (name); + if (attributes != null) { + if (!attributes.oneLine) sb.append ('\n'); + else sb.append (' '); + generateAttributes (sb, attributes, indentation + " "); + if (!attributes.oneLine) sb.append (indentation); + sb.append ("/>\n"); + } else + sb.append ("/>\n"); + } + + private static void generateAttributes ( + StringBuffer sb, + Attribs attributes, + String indentation + ) { + if (attributes == null) return; + int i, k = attributes.names.size (); + for (i = 0; i < k; i++) { + if (!attributes.oneLine) + sb.append (indentation); + sb.append (attributes.names.get (i)).append ("=\""). + append (attributes.values.get (i)).append ('\"'); + if (!attributes.oneLine) + sb.append ("\n"); + else + if (i < (k - 1)) + sb.append (' '); + } + } + + static class Handler extends DefaultHandler { + private Object result; + void setResult (Object result) { + this.result = result; + } + Object getResult () { + return result; + } + } + + static class Attribs { + private List names = new ArrayList (); + private List values = new ArrayList (); + private boolean oneLine; + + Attribs (boolean oneLine) { + this.oneLine = oneLine; + } + + void add (String name, String value) { + int i = names.indexOf (name); + if (i >= 0) { + names.remove (i); + values.remove (i); + } names.add (name); + values.add (value); + } + + void clear () { + names.clear (); + values.clear (); + } + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/copy5.5 b/sdk/jme3-upgrader/src/org/netbeans/upgrade/copy5.5 new file mode 100644 index 000000000..000a8bff3 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/copy5.5 @@ -0,0 +1,106 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. +# +# Oracle and Java are registered trademarks of Oracle and/or its affiliates. +# Other names may be trademarks of their respective owners. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# Contributor(s): +# +# The Original Software is NetBeans. The Initial Developer of the Original +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun +# Microsystems, Inc. All Rights Reserved. +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. + +# start the line either with # to begin a comment +# or include to describe a file(s) to be included during copy +# or exclude to describe a file(s) to be excluded +# use of regular expressions allowed in file names +# +# the list is iterated from first to last and the last match +# decides the result + +include CreatorDesignerPalette/.* +include CreatorDesignerPalette5/.* +include Databases/.* +include Editors/.* +exclude Editors/.*/macros.xml +exclude Editors/.*/Popup.* +exclude Editors/.*/.*\.instance +exclude Editors/.*/Settings\.settings +include Editors/AnnotationTypes/org-netbeans-modules-java-.*\.xml +include Editors/AnnotationTypes/TaskAnnotation.*\.xml +include Favorites/.* +include FormDesignerPalette/.* +include HTMLPalette/.* +include HTTPMonitor/.* +include J2EE/.* +include JSPPalette/.* +include Keymaps/.* +exclude MVD/.* +include org-netbeans-api-project-libraries/Libraries/.*\.xml +include Services/Browsers/.* +include Services/Collaboration/.* +include Services/DiffProviders/.* +include Services/Diffs/.* +include Services/DiffVisualizers/.* +include Services/formsettings\.settings +include Services/Hidden/org-netbeans-modules-diff-DiffSettings\.settings +include Services/Hidden/org-netbeans-modules-subversion-settings-.* +include Services/Hidden/org-netbeans-modules-tasklist-suggestions-settings-ManagerSettings\.instance +include Services/Hidden/org-netbeans-modules-vcscore-settings-GeneralVcsSettings\.settings +include Services/Hidden/org-netbeans-modules-versioning-system-cvss-settings.* +include Services/Hidden/VersionControl/org-netbeans-modules-vcscore-grouping-VcsGroupSettings\.settings +exclude Services/IndentEngine/.* +include Services/MergeVisualizers/.* +include Services/org-apache-tools-ant-module-AntSettings\.settings +include Services/org-netbeans-core-IDESettings\.settings +include Services/org-netbeans-modules-db-explorer-DatabaseOption\.settings +include Services/org-netbeans-modules-debugger-Settings\.properties +include Services/org-netbeans-modules-derby-DerbyOptions\.settings +include Services/org-netbeans-modules-httpserver-HttpServerSettings\.settings +include Services/org-netbeans-modules-java-settings-JavaSettings\.settings +include Services/org-netbeans-modules-javadoc-settings-DocumentationSettings\.settings +include Services/org-netbeans-modules-profiler-ProfilerIDESettings\.settings +include Services/org-netbeans-modules-project-ui-OpenProjectList\.settings +include Services/org-netbeans-modules-tasklist-docscan-Settings\.settings +include Services/Platforms/org-netbeans-api-java-Platform/.*\.xml +include Shortcuts/.* +include TaskList/.* +include Templates/Classes/.* +include Templates/J2MEProjectConfigurations/.*\.cfg +include Toolbars/.* +exclude Toolbars/Progress/.* +include vcs/.* +include VCSMount/.* +exclude Windows2Local/Components/DesignInspector.settings +exclude Windows2Local/Groups/mvd/DesignInspector.wstcgrp +exclude Windows2Local/Modes/navigator/DesignInspector.wstcref diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/copy5.5.1 b/sdk/jme3-upgrader/src/org/netbeans/upgrade/copy5.5.1 new file mode 100644 index 000000000..000a8bff3 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/copy5.5.1 @@ -0,0 +1,106 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. +# +# Oracle and Java are registered trademarks of Oracle and/or its affiliates. +# Other names may be trademarks of their respective owners. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# Contributor(s): +# +# The Original Software is NetBeans. The Initial Developer of the Original +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun +# Microsystems, Inc. All Rights Reserved. +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. + +# start the line either with # to begin a comment +# or include to describe a file(s) to be included during copy +# or exclude to describe a file(s) to be excluded +# use of regular expressions allowed in file names +# +# the list is iterated from first to last and the last match +# decides the result + +include CreatorDesignerPalette/.* +include CreatorDesignerPalette5/.* +include Databases/.* +include Editors/.* +exclude Editors/.*/macros.xml +exclude Editors/.*/Popup.* +exclude Editors/.*/.*\.instance +exclude Editors/.*/Settings\.settings +include Editors/AnnotationTypes/org-netbeans-modules-java-.*\.xml +include Editors/AnnotationTypes/TaskAnnotation.*\.xml +include Favorites/.* +include FormDesignerPalette/.* +include HTMLPalette/.* +include HTTPMonitor/.* +include J2EE/.* +include JSPPalette/.* +include Keymaps/.* +exclude MVD/.* +include org-netbeans-api-project-libraries/Libraries/.*\.xml +include Services/Browsers/.* +include Services/Collaboration/.* +include Services/DiffProviders/.* +include Services/Diffs/.* +include Services/DiffVisualizers/.* +include Services/formsettings\.settings +include Services/Hidden/org-netbeans-modules-diff-DiffSettings\.settings +include Services/Hidden/org-netbeans-modules-subversion-settings-.* +include Services/Hidden/org-netbeans-modules-tasklist-suggestions-settings-ManagerSettings\.instance +include Services/Hidden/org-netbeans-modules-vcscore-settings-GeneralVcsSettings\.settings +include Services/Hidden/org-netbeans-modules-versioning-system-cvss-settings.* +include Services/Hidden/VersionControl/org-netbeans-modules-vcscore-grouping-VcsGroupSettings\.settings +exclude Services/IndentEngine/.* +include Services/MergeVisualizers/.* +include Services/org-apache-tools-ant-module-AntSettings\.settings +include Services/org-netbeans-core-IDESettings\.settings +include Services/org-netbeans-modules-db-explorer-DatabaseOption\.settings +include Services/org-netbeans-modules-debugger-Settings\.properties +include Services/org-netbeans-modules-derby-DerbyOptions\.settings +include Services/org-netbeans-modules-httpserver-HttpServerSettings\.settings +include Services/org-netbeans-modules-java-settings-JavaSettings\.settings +include Services/org-netbeans-modules-javadoc-settings-DocumentationSettings\.settings +include Services/org-netbeans-modules-profiler-ProfilerIDESettings\.settings +include Services/org-netbeans-modules-project-ui-OpenProjectList\.settings +include Services/org-netbeans-modules-tasklist-docscan-Settings\.settings +include Services/Platforms/org-netbeans-api-java-Platform/.*\.xml +include Shortcuts/.* +include TaskList/.* +include Templates/Classes/.* +include Templates/J2MEProjectConfigurations/.*\.cfg +include Toolbars/.* +exclude Toolbars/Progress/.* +include vcs/.* +include VCSMount/.* +exclude Windows2Local/Components/DesignInspector.settings +exclude Windows2Local/Groups/mvd/DesignInspector.wstcgrp +exclude Windows2Local/Modes/navigator/DesignInspector.wstcref diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/copy6.0 b/sdk/jme3-upgrader/src/org/netbeans/upgrade/copy6.0 new file mode 100644 index 000000000..566c5692a --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/copy6.0 @@ -0,0 +1,82 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. +# +# Oracle and Java are registered trademarks of Oracle and/or its affiliates. +# Other names may be trademarks of their respective owners. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# Contributor(s): +# +# The Original Software is NetBeans. The Initial Developer of the Original +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun +# Microsystems, Inc. All Rights Reserved. +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. + +# start the line either with # to begin a comment +# or include to describe a file(s) to be included during copy +# or exclude to describe a file(s) to be excluded +# use of regular expressions allowed in file names +# +# the list is iterated from first to last and the last match +# decides the result + +include Preferences/.* +include Databases/.* +include Editors/.* +exclude Editors/.*/macros.xml +exclude Editors/.*/Popup.* +exclude Editors/.*/.*\.instance +exclude Editors/.*/Settings\.settings +include Favorites/.* +include FormDesignerPalette/.* +include HTMLPalette/.* +include J2EE/.* +include JSPPalette/.* +include Keymaps/.* +exclude MVD/.* +include org-netbeans-api-project-libraries/Libraries/.*\.xml +include Services/Browsers/.* +include Services/DiffProviders/.* +include Services/formsettings.settings +exclude Services/IndentEngine/.* +include Services/org-netbeans-modules-db-explorer-DatabaseOption\.settings +include Services/org-netbeans-modules-debugger-Settings\.properties +include Services/Platforms/org-netbeans-api-java-Platform/.*\.xml +include Shortcuts/.* +include Templates/Classes/.* +include Templates/J2MEProjectConfigurations/.*\.cfg +include Toolbars/.* +exclude Toolbars/Progress/.* +include WebServices/service-groups.xml +include WebServices/.*/.*-saas.xml +exclude Windows2Local/Components/DesignInspector.settings +exclude Windows2Local/Groups/mvd/DesignInspector.wstcgrp +exclude Windows2Local/Modes/navigator/DesignInspector.wstcref diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/copy6.1 b/sdk/jme3-upgrader/src/org/netbeans/upgrade/copy6.1 new file mode 100644 index 000000000..35c7ec6bf --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/copy6.1 @@ -0,0 +1,85 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. +# +# Oracle and Java are registered trademarks of Oracle and/or its affiliates. +# Other names may be trademarks of their respective owners. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# Contributor(s): +# +# The Original Software is NetBeans. The Initial Developer of the Original +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun +# Microsystems, Inc. All Rights Reserved. +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. + +# start the line either with # to begin a comment +# or include to describe a file(s) to be included during copy +# or exclude to describe a file(s) to be excluded +# use of regular expressions allowed in file names +# +# the list is iterated from first to last and the last match +# decides the result + +include Preferences/.* +exclude Preferences/org/netbeans/modules/welcome.properties!feedback.* +include Databases/.* +include Editors/.* +exclude Editors/.*/macros.xml +exclude Editors/.*/Popup.* +exclude Editors/.*/.*\.instance +exclude Editors/.*/Settings\.settings +include Favorites/.* +include FormDesignerPalette/.* +include GlassFish/.* +include HTMLPalette/.* +include J2EE/.* +include JSPPalette/.* +include Keymaps/.* +include org-netbeans-api-project-libraries/Libraries/.*\.xml +include Services/Browsers/.* +include Services/DiffProviders/.* +include Services/formsettings.settings +exclude Services/IndentEngine/.* +include Services/org-netbeans-modules-db-explorer-DatabaseOption\.settings +include Services/org-netbeans-modules-debugger-Settings\.properties +include Services/Platforms/org-netbeans-api-java-Platform/.*\.xml +include Shortcuts/.* +exclude Templates/Beans/Bean.java +exclude Templates/Beans/BeanInfo.java +exclude Templates/Beans/NoIconBeanInfo.java +exclude Templates/Beans/Customizer.java +exclude Templates/Beans/Customizer.form +exclude Templates/Beans/PropertyEditor.java +include Templates/Classes/.* +include Templates/J2MEProjectConfigurations/.*\.cfg +include Toolbars/.* +exclude Toolbars/Progress/.* +include vmd-midp/palette/custom/.* diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/copy6.5 b/sdk/jme3-upgrader/src/org/netbeans/upgrade/copy6.5 new file mode 100644 index 000000000..03c39ca9e --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/copy6.5 @@ -0,0 +1,85 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. +# +# Oracle and Java are registered trademarks of Oracle and/or its affiliates. +# Other names may be trademarks of their respective owners. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# Contributor(s): +# +# The Original Software is NetBeans. The Initial Developer of the Original +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun +# Microsystems, Inc. All Rights Reserved. +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. + +# start the line either with # to begin a comment +# or include to describe a file(s) to be included during copy +# or exclude to describe a file(s) to be excluded +# use of regular expressions allowed in file names +# +# the list is iterated from first to last and the last match +# decides the result + +include Preferences/.* +exclude Preferences/org/netbeans/modules/welcome.properties!feedback.* +include Databases/.* +include Editors/.* +exclude Editors/.*/macros.xml +exclude Editors/.*/Popup.* +exclude Editors/.*/.*\.instance +exclude Editors/.*/Settings\.settings +include Favorites/.* +include FormDesignerPalette/.* +include GlassFish/.* +include HTMLPalette/.* +include J2EE/.* +include JSPPalette/.* +include Keymaps/.* +include org-netbeans-api-project-libraries/Libraries/.*\.xml +include Services/Browsers/.* +include Services/DiffProviders/.* +include Services/formsettings.settings +exclude Services/IndentEngine/.* +include Services/MIMEResolver/.* +include Services/org-netbeans-modules-db-explorer-DatabaseOption\.settings +include Services/org-netbeans-modules-debugger-Settings\.properties +include Services/Platforms/org-netbeans-api-java-Platform/.*\.xml +include Shortcuts/.* +include Templates/.* +exclude Templates/Beans/Bean.java +exclude Templates/Beans/BeanInfo.java +exclude Templates/Beans/NoIconBeanInfo.java +exclude Templates/Beans/Customizer.java +exclude Templates/Beans/Customizer.form +exclude Templates/Beans/PropertyEditor.java +include Toolbars/.* +exclude Toolbars/Progress/.* +include vmd-midp/palette/custom/.* diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/copyjstudio_6me_user b/sdk/jme3-upgrader/src/org/netbeans/upgrade/copyjstudio_6me_user new file mode 100644 index 000000000..bb275c405 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/copyjstudio_6me_user @@ -0,0 +1,90 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. +# +# Oracle and Java are registered trademarks of Oracle and/or its affiliates. +# Other names may be trademarks of their respective owners. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# Contributor(s): +# +# The Original Software is NetBeans. The Initial Developer of the Original +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun +# Microsystems, Inc. All Rights Reserved. +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. + +# start the line either with # to begin a comment +# or include to describe a file(s) to be included during copy +# or exclude to describe a file(s) to be excluded +# use of regular expressions allowed in file names +# +# the list is iterated from first to last and the last match +# decides the result + +include Services/org-netbeans-core-IDESettings\.settings +include Shortcuts/.* + +include Services/Hidden/org-netbeans-modules-vcscore-settings-GeneralVcsSettings\.settings + +include Services/DiffProviders/.* +include Services/Diffs/.* +include Services/DiffVisualizers/.* +include Services/MergeVisualizers/.* +include Services/Hidden/org-netbeans-modules-diff-DiffSettings\.settings + +include Services/Browsers/.* +include Services/org-netbeans-modules-httpserver-HttpServerSettings\.settings + +include HTTPMonitor/.* + +include J2EE/.* + +include Services/JDBCDrivers/.* +include Services/org-netbeans-modules-db-explorer-DatabaseOption\.settings + +include Editors/.* +include Editors/AnnotationTypes/.* +include Services/org-openide-text-PrintSettings\.settings +include Services/IndentEngine/.* + +include Services/org-netbeans-modules-java-settings-JavaSettings\.settings +include Services/org-openide-src-nodes-SourceOptions\.settings +include Templates/Classes/.* +include Editors/AnnotationTypes/org-netbeans-modules-java-.*\.xml + +include Services/org-netbeans-modules-beans-beans\.settings +include Templates/Beans/.* + +include Services/org-netbeans-modules-javadoc-settings-DocumentationSettings\.settings + +include Services/formsettings\.settings +include Services/org-netbeans-modules-i18n-I18nOptions\.settings + +include Services/Emulators/.*\.settings diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/layer5.5.1.xml b/sdk/jme3-upgrader/src/org/netbeans/upgrade/layer5.5.1.xml new file mode 100644 index 000000000..3fb69b40c --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/layer5.5.1.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/layer5.5.xml b/sdk/jme3-upgrader/src/org/netbeans/upgrade/layer5.5.xml new file mode 100644 index 000000000..3fb69b40c --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/layer5.5.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/layer6.0.xml b/sdk/jme3-upgrader/src/org/netbeans/upgrade/layer6.0.xml new file mode 100644 index 000000000..3fb69b40c --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/layer6.0.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/layer6.1.xml b/sdk/jme3-upgrader/src/org/netbeans/upgrade/layer6.1.xml new file mode 100644 index 000000000..3fb69b40c --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/layer6.1.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard5.5 b/sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard5.5 new file mode 100644 index 000000000..114d07303 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard5.5 @@ -0,0 +1,54 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. +# +# Oracle and Java are registered trademarks of Oracle and/or its affiliates. +# Other names may be trademarks of their respective owners. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# Contributor(s): +# +# The Original Software is NetBeans. The Initial Developer of the Original +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun +# Microsystems, Inc. All Rights Reserved. +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. + +# start the line either with # to begin a comment +# or include to describe a file(s) to be included during copy +# or exclude to describe a file(s) to be excluded +# use of regular expressions allowed in file names +# +# the list is iterated from first to last and the last match +# decides the result + +#creator +include complibs/.* +include jdbc-drivers/.*\.jar +include context\.xml diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard5.5.1 b/sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard5.5.1 new file mode 100644 index 000000000..114d07303 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard5.5.1 @@ -0,0 +1,54 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. +# +# Oracle and Java are registered trademarks of Oracle and/or its affiliates. +# Other names may be trademarks of their respective owners. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# Contributor(s): +# +# The Original Software is NetBeans. The Initial Developer of the Original +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun +# Microsystems, Inc. All Rights Reserved. +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. + +# start the line either with # to begin a comment +# or include to describe a file(s) to be included during copy +# or exclude to describe a file(s) to be excluded +# use of regular expressions allowed in file names +# +# the list is iterated from first to last and the last match +# decides the result + +#creator +include complibs/.* +include jdbc-drivers/.*\.jar +include context\.xml diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard6.0 b/sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard6.0 new file mode 100644 index 000000000..8cb190b15 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard6.0 @@ -0,0 +1,56 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. +# +# Oracle and Java are registered trademarks of Oracle and/or its affiliates. +# Other names may be trademarks of their respective owners. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# Contributor(s): +# +# The Original Software is NetBeans. The Initial Developer of the Original +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun +# Microsystems, Inc. All Rights Reserved. +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. + +# start the line either with # to begin a comment +# or include to describe a file(s) to be included during copy +# or exclude to describe a file(s) to be excluded +# use of regular expressions allowed in file names +# +# the list is iterated from first to last and the last match +# decides the result + +#creator +include complibs/.* +include jdbc-drivers/.*\.jar +include context\.xml +include .uml +include var/filehistory/.* diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard6.1 b/sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard6.1 new file mode 100644 index 000000000..c14c5ced5 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard6.1 @@ -0,0 +1,51 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. +# +# Oracle and Java are registered trademarks of Oracle and/or its affiliates. +# Other names may be trademarks of their respective owners. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# Contributor(s): +# +# The Original Software is NetBeans. The Initial Developer of the Original +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun +# Microsystems, Inc. All Rights Reserved. +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. + +# start the line either with # to begin a comment +# or include to describe a file(s) to be included during copy +# or exclude to describe a file(s) to be excluded +# use of regular expressions allowed in file names +# +# the list is iterated from first to last and the last match +# decides the result + +include var/filehistory/.* diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard6.5 b/sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard6.5 new file mode 100644 index 000000000..f3555e412 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/nonstandard6.5 @@ -0,0 +1,52 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. +# +# Oracle and Java are registered trademarks of Oracle and/or its affiliates. +# Other names may be trademarks of their respective owners. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# Contributor(s): +# +# The Original Software is NetBeans. The Initial Developer of the Original +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun +# Microsystems, Inc. All Rights Reserved. +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. + +# start the line either with # to begin a comment +# or include to describe a file(s) to be included during copy +# or exclude to describe a file(s) to be excluded +# use of regular expressions allowed in file names +# +# the list is iterated from first to last and the last match +# decides the result + +include var/filehistory/.* +include etc/netbeans.conf diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/ColorProcessor.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/ColorProcessor.java new file mode 100644 index 000000000..d308a2f90 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/ColorProcessor.java @@ -0,0 +1,81 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; +import java.lang.Object; +import java.util.Iterator; + + +/** + * @author Radek Matous + */ +class ColorProcessor extends PropertyProcessor { + + static final String JAVA_AWT_COLOR = "java.awt.Color"; // NOI18N + static final String NETBEANS_COLOREDITOR_SUPERCOLOR = "org.netbeans.beaninfo.editors.ColorEditor.SuperColor"; // NOI18N + + ColorProcessor(String className) { + super(className);//NOI18N + } + + + void processPropertyImpl(String propertyName, Object value) { + StringBuffer sb = new StringBuffer(); + if ("connectionBorderColor".equals(propertyName)|| + "dragBorderColor".equals(propertyName)|| + "formDesignerBackgroundColor".equals(propertyName)|| + "formDesignerBorderColor".equals(propertyName)|| + "guidingLineColor".equals(propertyName)|| + "selectionBorderColor".equals(propertyName)) {//NOI18N + for (Iterator it = ((SerParser.ObjectWrapper)value).data.iterator(); it.hasNext();) { + Object o = it.next(); + if (o instanceof SerParser.NameValue && "value".equals(((SerParser.NameValue)o).name.name)) {//NOI18N + addProperty(propertyName, ((SerParser.NameValue)o).value.toString()); + } + } + } else { + throw new IllegalStateException(); + } + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/ContentProcessor.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/ContentProcessor.java new file mode 100644 index 000000000..4e7141244 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/ContentProcessor.java @@ -0,0 +1,135 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +class ContentProcessor { + private static Map clsname2Delegate = new HashMap(); + protected String systemOptionInstanceName; + + static { + registerContentProcessor(new JUnitContentProcessor("org.netbeans.modules.junit.JUnitSettings"));//NOI18N + } + + private static void registerContentProcessor(ContentProcessor instance) { + if (clsname2Delegate.put(instance.systemOptionInstanceName, instance) != null) { + throw new IllegalArgumentException(); + } + } + + + protected ContentProcessor(String systemOptionInstanceName) { + this.systemOptionInstanceName = systemOptionInstanceName; + } + + protected Result parseContent(final Iterator it, boolean types) { + Map m; + Result result = null; + try { + Map props = parseProperties(it); + assert props != null; + //debugInfo("before: ", m); + m = processProperties(props, types); + //assert debugInfo("after: ", m); + result = new DefaultResult(systemOptionInstanceName, m); + } catch (IllegalStateException isx) { + Logger.getLogger(ContentProcessor.class.getName()).log(Level.WARNING, systemOptionInstanceName + " not parsed", isx); + } + return result; + } + + static Result parseContent(String systemOptionInstanceName, boolean types, final Iterator it) { + ContentProcessor cp = clsname2Delegate.get(systemOptionInstanceName); + if (cp == null) { + cp = new ContentProcessor(systemOptionInstanceName); + } + return cp.parseContent(it, types); + } + + private final Map processProperties(final Map properties, boolean types) { + Map allProps = new HashMap(); + for (Iterator> it = properties.entrySet().iterator(); it.hasNext();) { + Map.Entry entry = it.next(); + String name = entry.getKey(); + Object value = entry.getValue(); + allProps.putAll(PropertyProcessor.processProperty(name, value, types)); + } + return allProps; + } + + private final Map parseProperties(final Iterator it) { // sequences String, Object, SerParser.ObjectWrapper + Map properties = new HashMap(); + for (; it.hasNext();) { + Object name = it.next(); + if ("null".equals(name) || name == null) { + //finito + return properties; + } else if (!(name instanceof String)) { + throw new IllegalStateException(name.getClass().getName()); + } else { + if (!it.hasNext()) { + throw new IllegalStateException(name.toString()); + } + Object value = it.next(); + properties.put((String)name, value); + Object propertyRead = it.next(); + if (!(propertyRead instanceof SerParser.ObjectWrapper )) { + throw new IllegalStateException(propertyRead.getClass().getName()); + } else { + SerParser.ObjectWrapper ow = (SerParser.ObjectWrapper)propertyRead; + if (!ow.classdesc.name.endsWith("java.lang.Boolean;")) {//NOI18N + throw new IllegalStateException(ow.classdesc.name); + } + } + } + } + throw new IllegalStateException("Unexpected end");//NOI18N + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/CvsSettingsProcessor.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/CvsSettingsProcessor.java new file mode 100644 index 000000000..02279852c --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/CvsSettingsProcessor.java @@ -0,0 +1,91 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ +package org.netbeans.upgrade.systemoptions; + +import java.util.*; + +/** + * Imports CVS root settings: external SSH command + * + * @author Maros Sandor + */ +public class CvsSettingsProcessor extends PropertyProcessor { + + private final String FIELD_SEPARATOR = "<~>"; + + public CvsSettingsProcessor() { + super("org.netbeans.modules.versioning.system.cvss.settings.CvsRootSettings.PersistentMap"); + } + + void processPropertyImpl(String propertyName, Object value) { + if ("rootsMap".equals(propertyName)) { // NOI18N + List mapData = ((SerParser.ObjectWrapper) value).data; + int n = 0; + int idx = 3; + if (mapData.size() > 3) { + for (;;) { + if (idx + 2 > mapData.size()) break; + String root = (String) mapData.get(idx); + List rootData = ((SerParser.ObjectWrapper) mapData.get(idx + 1)).data; + try { + List extSettingsData = ((SerParser.ObjectWrapper) ((SerParser.NameValue) rootData.get(0)).value).data; + Boolean extRememberPassword = (Boolean) ((SerParser.NameValue) extSettingsData.get(0)).value; + Boolean extUseInternalSSH = (Boolean) ((SerParser.NameValue) extSettingsData.get(1)).value; + String extCommand = (String) ((SerParser.NameValue) extSettingsData.get(2)).value; + String extPassword = (String) ((SerParser.NameValue) extSettingsData.get(3)).value; + String setting = root + FIELD_SEPARATOR + extUseInternalSSH + FIELD_SEPARATOR + extRememberPassword + FIELD_SEPARATOR + extCommand; + if (extPassword != null && !extPassword.equals("null")) setting += FIELD_SEPARATOR + extPassword; + addProperty("cvsRootSettings" + "." + n, setting); + n++; + } catch (Exception e) { + // the setting is not there => nothing to import + } + idx += 2; + } + } + } else { + throw new IllegalStateException(); + } + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/DefaultResult.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/DefaultResult.java new file mode 100644 index 000000000..46e99c2ae --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/DefaultResult.java @@ -0,0 +1,75 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.util.Map; + + +class DefaultResult implements Result { + private Map m; + private String instanceName; + private String moduleName; + DefaultResult(String instanceName, Map m) { + this.instanceName = instanceName; + this.m = m; + } + public String getProperty(final String propName) { + return m.get(propName); + } + + public String[] getPropertyNames() { + return m.keySet().toArray(new String[m.size()]); + } + + public String getInstanceName() { + return instanceName; + } + public String getModuleName() { + return moduleName; + } + public void setModuleName(String aModuleName) { + moduleName = aModuleName; + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/DocumentationSettingsProcessor.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/DocumentationSettingsProcessor.java new file mode 100644 index 000000000..c25526697 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/DocumentationSettingsProcessor.java @@ -0,0 +1,67 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2007 Sun Microsystems, Inc. + */ + +package org.netbeans.upgrade.systemoptions; + +/** + * + * @author Jan Pokorsky + */ +final class DocumentationSettingsProcessor extends PropertyProcessor { + + public DocumentationSettingsProcessor() { + super("org.netbeans.modules.javadoc.settings.DocumentationSettings"); + } + + @Override + void processPropertyImpl(String propertyName, Object value) { + // other properties are obsolete + if ("idxSearchSort".equals(propertyName) + || "idxSearchNoHtml".equals(propertyName) + || "idxSearchSplit".equals(propertyName)) { + + String stringvalue = Utils.valueFromObjectWrapper(value); + addProperty(propertyName, stringvalue); + } + } + +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/FileProcessor.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/FileProcessor.java new file mode 100644 index 000000000..92a03fab8 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/FileProcessor.java @@ -0,0 +1,77 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.util.Iterator; +import java.util.List; + +/** + * @author Radek Matous + */ +class FileProcessor extends PropertyProcessor { + FileProcessor() { + super("java.io.File");//NOI18N + } + + void processPropertyImpl(String propertyName, Object value) { + StringBuffer sb = new StringBuffer(); + if ("antHome".equals(propertyName) || "projectsFolder".equals(propertyName)) {//NOI18N + List l = ((SerParser.ObjectWrapper)value).data; + for (Iterator it = l.iterator(); it.hasNext();) { + Object elem = (Object) it.next(); + if (elem instanceof SerParser.NameValue) { + SerParser.NameValue nv = (SerParser.NameValue)elem; + if (nv.value != null && nv.name != null) { + if (nv.name.name.equals("path")) {//NOI18N + addProperty(propertyName,nv.value.toString());//NOI18N + } + } + } + } + } else { + throw new IllegalStateException(); + } + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/HashMapProcessor.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/HashMapProcessor.java new file mode 100644 index 000000000..46dc0e1ca --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/HashMapProcessor.java @@ -0,0 +1,84 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.util.Iterator; +import java.util.List; + +/** + * @author Radek Matous + */ +class HashMapProcessor extends PropertyProcessor { + HashMapProcessor() { + super("java.util.HashMap");//NOI18N + } + + void processPropertyImpl(String propertyName, Object value) { + if ("properties".equals(propertyName)) {//NOI18N + StringBuilder b = new StringBuilder(); + int s = 0; + List l = ((SerParser.ObjectWrapper)value).data; + for (Iterator it = l.iterator(); it.hasNext();) { + Object elem = (Object) it.next(); + if (elem instanceof String) { + switch (s) { + case 1: + b.append('\n'); + // FALLTHROUGH + case 0: + b.append(elem); + s = 2; + break; + case 2: + b.append('='); + b.append(elem); + s = 1; + } + } + } + addProperty(propertyName, b.toString()); + } + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/HashSetProcessor.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/HashSetProcessor.java new file mode 100644 index 000000000..dbfb38e2c --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/HashSetProcessor.java @@ -0,0 +1,64 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * Portions Copyrighted 2007 Sun Microsystems, Inc. + */ +package org.netbeans.upgrade.systemoptions; + +import java.util.Iterator; +import java.util.List; + +/** + * + * @author Tomas Stupka + */ +class HashSetProcessor extends PropertyProcessor { + + static final String CVS_PERSISTENT_HASHSET = "org.netbeans.modules.versioning.system.cvss.settings.CvsModuleConfig.PersistentHashSet"; // NOI18N + static final String SVN_PERSISTENT_HASHSET = "org.netbeans.modules.subversion.settings.SvnModuleConfig.PersistentHashSet"; // NOI18N + + HashSetProcessor(String className) { + super(className); + } + + void processPropertyImpl(String propertyName, Object value) { + if ("commitExclusions".equals(propertyName)) { // NOI18N + List l = ((SerParser.ObjectWrapper) value).data; + int c = 0; + for (Iterator it = l.iterator(); it.hasNext();) { + Object elem = it.next(); + if(elem instanceof String) { + addProperty(propertyName + "." + c, (String) elem); + c = c + 1; + } + } + } else { + throw new IllegalStateException(); + } + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/HostPropertyProcessor.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/HostPropertyProcessor.java new file mode 100644 index 000000000..3229e3769 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/HostPropertyProcessor.java @@ -0,0 +1,82 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.rmi.UnexpectedException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * @author Radek Matous + */ +class HostPropertyProcessor extends PropertyProcessor { + HostPropertyProcessor() { + super("org.netbeans.modules.httpserver.HttpServerSettings.HostProperty");//NOI18N + } + + void processPropertyImpl(String propertyName, Object value) { + StringBuffer sb = new StringBuffer(); + if ("hostProperty".equals(propertyName)) {//NOI18N + List l = ((SerParser.ObjectWrapper)value).data; + for (Iterator it = l.iterator(); it.hasNext();) { + Object elem = (Object) it.next(); + if (elem instanceof SerParser.NameValue) { + SerParser.NameValue nv = (SerParser.NameValue)elem; + if (nv.value != null && nv.name != null) { + if (nv.name.name.equals("grantedAddresses")) {//NOI18N + addProperty(nv.name.name,nv.value.toString());//NOI18N + } else if (nv.name.name.equals("host")) {//NOI18N + addProperty(nv.name.name,nv.value.toString()); + } + } + } + } + } else { + throw new IllegalStateException(); + } + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/Importer.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/Importer.java new file mode 100644 index 000000000..97ed805ca --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/Importer.java @@ -0,0 +1,135 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.io.*; +import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.openide.filesystems.*; + +/** + * + * @author Radek Matous + */ +public class Importer { + private static final String DEFINITION_OF_FILES = "systemoptionsimport";//NOI18N + + public static void doImport() throws IOException { + Set files = getImportFiles(loadImportFilesDefinition()); + for (Iterator it = parse(files).iterator(); it.hasNext();) { + saveResult(it.next()); + } + for (Iterator it = files.iterator(); it.hasNext();) { + FileObject fo = (FileObject) it.next(); + FileLock fLock = fo.lock(); + try { + fo.rename(fLock, fo.getName(), "imported");//NOI18N + } finally { + fLock.releaseLock(); + } + } + } + + private static void saveResult(final DefaultResult result) throws IOException { + String absolutePath = "/"+result.getModuleName(); + PropertiesStorage ps = PropertiesStorage.instance(absolutePath); + Properties props = ps.load(); + String[] propertyNames = result.getPropertyNames(); + for (int i = 0; i < propertyNames.length; i++) { + String val = result.getProperty(propertyNames[i]); + if (val != null) { + props.put(propertyNames[i], val); + } + } + if (props.size() > 0) { + ps.save(props); + } + } + + private static Set parse(final Set files) { + Set retval = new HashSet(); + for (FileObject f: files) { + try { + retval.add(SystemOptionsParser.parse(f, false)); + } catch (Exception ex) { + boolean assertOn = false; + assert assertOn = true; + if (assertOn) { + Logger.getLogger("org.netbeans.upgrade.systemoptions.parse").log(Level.INFO, "importing: " + f.getPath(), ex); // NOI18N + } + continue; + } + } + return retval; + } + + + static Properties loadImportFilesDefinition() throws IOException { + Properties props = new Properties(); + InputStream is = Importer.class.getResourceAsStream(DEFINITION_OF_FILES); + try { + props.load(is); + } finally { + is.close(); + } + return props; + } + + private static Set getImportFiles(final Properties props) { + Set fileobjects = new HashSet(); + for (Iterator it = props.keySet().iterator(); it.hasNext();) { + String path = (String) it.next(); + FileObject f = FileUtil.getConfigFile(path); + if (f != null) { + fileobjects.add(f); + } + } + return fileobjects; + } + + /** Creates a new instance of SettingsReadSupport */ + private Importer() {} +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/IntrospectedInfoProcessor.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/IntrospectedInfoProcessor.java new file mode 100644 index 000000000..359320dfc --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/IntrospectedInfoProcessor.java @@ -0,0 +1,64 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.rmi.UnexpectedException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * @author Radek Matous + */ +class IntrospectedInfoProcessor extends PropertyProcessor { + IntrospectedInfoProcessor() { + super("org.apache.tools.ant.module.api.IntrospectedInfo");//NOI18N + } + + void processPropertyImpl(String propertyName, Object value) { + //skip it + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/JUnitContentProcessor.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/JUnitContentProcessor.java new file mode 100644 index 000000000..6f7574b2a --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/JUnitContentProcessor.java @@ -0,0 +1,147 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +/** + * + * @author rmatous + */ +public class JUnitContentProcessor extends ContentProcessor{ + protected JUnitContentProcessor(String systemOptionInstanceName) { + super(systemOptionInstanceName); + } + + protected Result parseContent(final Iterator it, boolean types) { + Map properties = new HashMap(); + assert it.hasNext(); + Object o = it.next(); + assert o.getClass().equals(SerParser.ObjectWrapper.class); + SerParser.ObjectWrapper ow = (SerParser.ObjectWrapper)o; + assert Utils.getClassNameFromObject(ow).equals("java.lang.Integer") : Utils.getClassNameFromObject(ow);//NOI18N + properties.put("version", ((types)?Utils.getClassNameFromObject(ow): Utils.valueFromObjectWrapper(ow)));//NOI18N + assert it.hasNext(); + o = it.next(); + assert o.getClass().equals(String.class); + properties.put("fileSystem", ((types)?"java.lang.String": (String)o));//NOI18N + o = it.next(); + assert o.getClass().equals(SerParser.ObjectWrapper.class); + ow = (SerParser.ObjectWrapper)o; + assert Utils.getClassNameFromObject(ow).equals("java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N + properties.put("membersPublic", ((types)?Utils.getClassNameFromObject(ow): Utils.valueFromObjectWrapper(ow)));//NOI18N + o = it.next(); + assert o.getClass().equals(SerParser.ObjectWrapper.class); + ow = (SerParser.ObjectWrapper)o; + assert Utils.getClassNameFromObject(ow).equals("java.lang.Boolean") : Utils.getClassNameFromObject(ow); + properties.put("membersProtected", ((types)?Utils.getClassNameFromObject(ow): Utils.valueFromObjectWrapper(ow)));//NOI18N + o = it.next(); + assert o.getClass().equals(SerParser.ObjectWrapper.class); + ow = (SerParser.ObjectWrapper)o; + assert Utils.getClassNameFromObject(ow).equals("java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N + properties.put("membersPackage", ((types)?Utils.getClassNameFromObject(ow): Utils.valueFromObjectWrapper(ow)));//NOI18N + o = it.next(); + assert o.getClass().equals(SerParser.ObjectWrapper.class); + ow = (SerParser.ObjectWrapper)o; + assert Utils.getClassNameFromObject(ow).equals("java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N + properties.put("bodyComments", ((types)?Utils.getClassNameFromObject(ow): Utils.valueFromObjectWrapper(ow)));//NOI18N + o = it.next(); + assert o.getClass().equals(SerParser.ObjectWrapper.class); + ow = (SerParser.ObjectWrapper)o; + assert Utils.getClassNameFromObject(ow).equals("java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N + properties.put("bodyContent", ((types)?Utils.getClassNameFromObject(ow): Utils.valueFromObjectWrapper(ow)));//NOI18N + o = it.next(); + assert o.getClass().equals(SerParser.ObjectWrapper.class); + ow = (SerParser.ObjectWrapper)o; + assert Utils.getClassNameFromObject(ow).equals("java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N + properties.put("javaDoc", ((types)?Utils.getClassNameFromObject(ow): Utils.valueFromObjectWrapper(ow)));//NOI18N + o = it.next(); + assert o.getClass().equals(SerParser.ObjectWrapper.class); + ow = (SerParser.ObjectWrapper)o; + assert Utils.getClassNameFromObject(ow).equals("java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N + properties.put("generateAbstractImpl", ((types)?Utils.getClassNameFromObject(ow): Utils.valueFromObjectWrapper(ow)));//NOI18N + o = it.next(); + assert o.getClass().equals(SerParser.ObjectWrapper.class); + ow = (SerParser.ObjectWrapper)o; + assert Utils.getClassNameFromObject(ow).equals("java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N + properties.put("generateExceptionClasses", ((types)?Utils.getClassNameFromObject(ow): Utils.valueFromObjectWrapper(ow)));//NOI18N + o = it.next(); + assert o.getClass().equals(SerParser.ObjectWrapper.class); + ow = (SerParser.ObjectWrapper)o; + assert Utils.getClassNameFromObject(ow).equals("java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N + properties.put("generateSuiteClasses", ((types)?Utils.getClassNameFromObject(ow): Utils.valueFromObjectWrapper(ow)));//NOI18N + o = it.next(); + assert o.getClass().equals(SerParser.ObjectWrapper.class); + ow = (SerParser.ObjectWrapper)o; + assert Utils.getClassNameFromObject(ow).equals("java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N + properties.put("includePackagePrivateClasses", ((types)?Utils.getClassNameFromObject(ow): Utils.valueFromObjectWrapper(ow)));//NOI18N + o = it.next(); + assert o.getClass().equals(SerParser.ObjectWrapper.class); + ow = (SerParser.ObjectWrapper)o; + assert Utils.getClassNameFromObject(ow).equals("java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N + properties.put("generateMainMethod", ((types)?Utils.getClassNameFromObject(ow): Utils.valueFromObjectWrapper(ow)));//NOI18N + o = it.next(); + assert o.getClass().equals(String.class); + properties.put("generateMainMethodBody", ((types)?"java.lang.String": (String)o));//NOI18N + o = it.next(); + assert o.getClass().equals(String.class); + properties.put("rootSuiteClassName", ((types)?"java.lang.String": (String)o));//NOI18N + o = it.next(); + assert o.getClass().equals(SerParser.ObjectWrapper.class); + ow = (SerParser.ObjectWrapper)o; + assert Utils.getClassNameFromObject(ow).equals("java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N + properties.put("generateSetUp", ((types)?Utils.getClassNameFromObject(ow): Utils.valueFromObjectWrapper(ow)));//NOI18N + o = it.next(); + assert o.getClass().equals(SerParser.ObjectWrapper.class); + ow = (SerParser.ObjectWrapper)o; + assert Utils.getClassNameFromObject(ow).equals("java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N + properties.put("generateTearDown", ((types)?Utils.getClassNameFromObject(ow): Utils.valueFromObjectWrapper(ow)));//NOI18N + + + return new DefaultResult(systemOptionInstanceName, properties); + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/ListProcessor.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/ListProcessor.java new file mode 100644 index 000000000..7999856f8 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/ListProcessor.java @@ -0,0 +1,87 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Iterator; +import java.util.List; + +/** + * @author Radek Matous + */ +class ListProcessor extends PropertyProcessor { + ListProcessor() { + super("java.util.ArrayList");//NOI18N + } + + void processPropertyImpl(String propertyName, Object value) { + if ("openProjectsURLs".equals(propertyName) + || "recentProjectsURLs".equals(propertyName) + || "recentTemplates".equals(propertyName)) {//NOI18N + int s = 0; + List l = ((SerParser.ObjectWrapper)value).data; + for (Iterator it = l.iterator(); it.hasNext();) { + String prop = null; + Object elem = (Object) it.next(); + if (elem instanceof SerParser.ObjectWrapper) { + List list2 = ((SerParser.ObjectWrapper)elem).data; + try { + URL url = URLProcessor.createURL(list2); + prop = url.toExternalForm(); + } catch (MalformedURLException ex) { + ex.printStackTrace(); + } + } else if (elem instanceof String) { + prop = (String)elem; + } + if (prop != null) { + addProperty(propertyName + "." + s, prop); + s = s + 1; + } + } + } + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/NbClassPathProcessor.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/NbClassPathProcessor.java new file mode 100644 index 000000000..a4775ee3d --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/NbClassPathProcessor.java @@ -0,0 +1,75 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.util.Iterator; +import java.util.List; + +/** + * @author Radek Matous + */ +class NbClassPathProcessor extends PropertyProcessor { + NbClassPathProcessor() { + super("org.openide.execution.NbClassPath");//NOI18N + } + + void processPropertyImpl(String propertyName, Object value) { + StringBuffer sb = new StringBuffer(); + List l = ((SerParser.ObjectWrapper)value).data; + for (Iterator it = l.iterator(); it.hasNext();) { + Object elem = (Object) it.next(); + if (elem instanceof SerParser.NameValue) { + SerParser.NameValue nv = (SerParser.NameValue)elem; + if (nv.value != null && nv.name != null) { + if (nv.name.name.equals("classpath")) {//NOI18N + addProperty(propertyName, nv.value.toString()); + } else if (nv.name.name.equals("items")) {//NOI18N + //skip it - won't be imported + } + } + } + } + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/PropertiesStorage.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/PropertiesStorage.java new file mode 100644 index 000000000..8e9681a0b --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/PropertiesStorage.java @@ -0,0 +1,185 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Date; +import java.util.Properties; +import org.openide.filesystems.FileLock; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; + +/** + * @author Radek Matous + */ +class PropertiesStorage { + private static final String USERROOT_PREFIX = "/Preferences";//NOI18N + private final static FileObject SFS_ROOT = FileUtil.getConfigRoot(); + + private final String folderPath; + private String filePath; + + static PropertiesStorage instance(final String absolutePath) { + return new PropertiesStorage(absolutePath); + } + + FileObject preferencesRoot() throws IOException { + return FileUtil.createFolder(SFS_ROOT, USERROOT_PREFIX); + } + + + /** Creates a new instance */ + private PropertiesStorage(final String absolutePath) { + StringBuffer sb = new StringBuffer(); + sb.append(USERROOT_PREFIX).append(absolutePath); + folderPath = sb.toString(); + } + + + public Properties load() throws IOException { + try { + Properties retval = new Properties(); + InputStream is = inputStream(); + if (is != null) { + try { + retval.load(is); + } finally { + if (is != null) is.close(); + } + } + return retval; + } finally { + } + } + + public void save(final Properties properties) throws IOException { + if (!properties.isEmpty()) { + OutputStream os = null; + try { + os = outputStream(); + properties.store(os,new Date().toString());//NOI18N + } finally { + if (os != null) os.close(); + } + } else { + FileObject file = toPropertiesFile(); + if (file != null) { + file.delete(); + } + FileObject folder = toFolder(); + while (folder != null && folder != preferencesRoot() && folder.getChildren().length == 0) { + folder.delete(); + folder = folder.getParent(); + } + } + } + + private InputStream inputStream() throws IOException { + FileObject file = toPropertiesFile(false); + return (file == null) ? null : file.getInputStream(); + } + + private OutputStream outputStream() throws IOException { + FileObject fo = toPropertiesFile(true); + final FileLock lock = fo.lock(); + final OutputStream os = fo.getOutputStream(lock); + return new FilterOutputStream(os) { + public void close() throws IOException { + super.close(); + lock.releaseLock(); + } + }; + } + + private String folderPath() { + return folderPath; + } + + private String filePath() { + if (filePath == null) { + String[] all = folderPath().split("/");//NOI18N + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < all.length-1; i++) { + sb.append(all[i]).append("/");//NOI18N + } + if (all.length > 0) { + sb.append(all[all.length-1]).append(".properties");//NOI18N + } else { + sb.append("root.properties");//NOI18N + } + filePath = sb.toString(); + } + return filePath; + } + + protected FileObject toFolder() { + return SFS_ROOT.getFileObject(folderPath); + } + + protected FileObject toPropertiesFile() { + return SFS_ROOT.getFileObject(filePath()); + } + + protected FileObject toFolder(boolean create) throws IOException { + FileObject retval = toFolder(); + if (retval == null && create) { + retval = FileUtil.createFolder(SFS_ROOT, folderPath); + } + assert (retval == null && !create) || (retval != null && retval.isFolder()); + return retval; + } + + protected FileObject toPropertiesFile(boolean create) throws IOException { + FileObject retval = toPropertiesFile(); + if (retval == null && create) { + retval = FileUtil.createData(SFS_ROOT,filePath());//NOI18N + } + assert (retval == null && !create) || (retval != null && retval.isData()); + return retval; + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/PropertyProcessor.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/PropertyProcessor.java new file mode 100644 index 000000000..cc933692a --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/PropertyProcessor.java @@ -0,0 +1,131 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.util.HashMap; +import java.util.Map; + + +abstract class PropertyProcessor { + private String className; + private static Map results; + private static Map clsname2Delegate = new HashMap(); + + static { + //To extend behaviour of this class then regisetr your own implementation + registerPropertyProcessor(new TaskTagsProcessor()); + registerPropertyProcessor(new HostPropertyProcessor()); + registerPropertyProcessor(new FileProcessor());//AntSettings + registerPropertyProcessor(new NbClassPathProcessor());//AntSettings + registerPropertyProcessor(new HashMapProcessor());//AntSettings + registerPropertyProcessor(new IntrospectedInfoProcessor());//AntSettings + registerPropertyProcessor(new ListProcessor());//ProjectUISettings + registerPropertyProcessor(new URLProcessor());//ProjectUISettings + registerPropertyProcessor(new ColorProcessor(ColorProcessor.JAVA_AWT_COLOR));//FormLoaderSettings + registerPropertyProcessor(new ColorProcessor(ColorProcessor.NETBEANS_COLOREDITOR_SUPERCOLOR));//FormLoaderSettings + registerPropertyProcessor(new StringPropertyProcessor());//ProxySettings + registerPropertyProcessor(new HashSetProcessor(HashSetProcessor.CVS_PERSISTENT_HASHSET));//CvsSettings + registerPropertyProcessor(new HashSetProcessor(HashSetProcessor.SVN_PERSISTENT_HASHSET));//SvnSettings + registerPropertyProcessor(new CvsSettingsProcessor()); + registerPropertyProcessor(new DocumentationSettingsProcessor()); + } + + + private static void registerPropertyProcessor(PropertyProcessor instance) { + if (clsname2Delegate.put(instance.className, instance) != null) { + throw new IllegalArgumentException(); + } + } + + private static PropertyProcessor DEFAULT = new PropertyProcessor(false) { + void processPropertyImpl(final String propertyName, final Object value) { + String stringvalue = null; + stringvalue = Utils.valueFromObjectWrapper(value); + addProperty(propertyName, stringvalue); + } + }; + + private static PropertyProcessor TYPES = new PropertyProcessor(true) { + void processPropertyImpl(final String propertyName, final Object value) { + addProperty(propertyName, Utils.getClassNameFromObject(value)); + } + }; + + private boolean types; + + + private PropertyProcessor(boolean types) { + this.types = types; + } + + protected PropertyProcessor(String className) { + this(false); + this.className = className; + } + + static Map processProperty(String propertyName, Object value, boolean types) { + results = new HashMap(); + PropertyProcessor p = (types) ? TYPES : findDelegate(value); + if (p == null) { + p = DEFAULT; + } + assert p != null; + p.processPropertyImpl(propertyName, value); + return results; + } + + abstract void processPropertyImpl(String propertyName, Object value); + + protected final void addProperty(String propertyName, String value) { + if (results.put(propertyName, value) != null) { + throw new IllegalArgumentException(propertyName); + } + } + + private static PropertyProcessor findDelegate(final Object value) { + String clsName = Utils.getClassNameFromObject(value); + return (PropertyProcessor)clsname2Delegate.get(clsName); + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/Result.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/Result.java new file mode 100644 index 000000000..fa45ee1d4 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/Result.java @@ -0,0 +1,55 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +/** + * + * @author Radek Matous + */ +public interface Result { + String getInstanceName(); + String getProperty(final String propName); + String[] getPropertyNames(); +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/SerParser.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/SerParser.java new file mode 100644 index 000000000..c9d768ad2 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/SerParser.java @@ -0,0 +1,608 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.io.*; +import java.util.*; +import org.openide.util.NotImplementedException; + +/* The following may be useful to Emacs users: + +(defun comma-sep-decimal-encode () + (interactive) + (while + (let ((p (point))) + (and (re-search-forward "\\(-?[0-9][0-9]?[0-9]?\\),?" nil t) + (= p (match-beginning 0)))) + (replace-match (char-to-string + (let ((x (string-to-int (match-string 1)))) + (when (< x 0) (setq x (+ x 256))) + x)) + t t))) + +After evaluating this, go into an old cpanel.xml or similar +(M-x find-file-literally, by the way) and type +M-x comma-sep-decimal-encode right after the opening quote +of the value. The contents will be converted to raw binary and +may be saved as a .ser file parsable by this class. + +(defun hex-encode () + (interactive) + (while + (let ((p (point))) + (and (re-search-forward "\\s-*\\([a-fA-F0-9][a-fA-F0-9]\\)" nil t) + (= p (match-beginning 0)))) + (replace-match (char-to-string + (string-to-int (match-string 1) 16)) + t t))) + +Same for hexadecimal serialized data. For .settings files, it is +easier to select Customize Bean... in the IDE and save as *.ser. +*/ + +/** Parser for Java serialization files. + * Does no classloading or per-class semantics, simply parses the + * raw serialization structure. + * @author Jesse Glick + */ +public final class SerParser implements ObjectStreamConstants { + + private static final boolean DEBUG = Boolean.getBoolean("org.netbeans.modules.clazz.SerParser.DEBUG"); // NOI18N + + private final InputStream is; + private int seq = 0; + private final List refs = new ArrayList(100); + + public SerParser(InputStream is) { + this.is = is; + } + + private int makeRef(Object o) { + refs.add(o); + int i = seq; + seq++; + if (DEBUG) System.err.println("makeRef[" + i + "]=" + o); // NOI18N + return i; + } + + private Object getRef(int i) throws CorruptException { + int idx = i - baseWireHandle; + if (idx < 0 || idx >= seq) throw new CorruptException("Invalid reference: " + i); // NOI18N + Object o = refs.get(idx); + if (o == null) throw new CorruptException("Invalid reference: " + i); // NOI18N + return o; + } + + public Stream parse() throws IOException, CorruptException { + Stream s = new Stream(); + s.magic = readShort(); + s.version = readShort(); + if (s.magic != STREAM_MAGIC || s.version != STREAM_VERSION) { + throw new CorruptException("stream version mismatch: " + hexify(s.magic) + " != " + hexify(STREAM_MAGIC) + " or " + hexify(s.version) + " != " + hexify(STREAM_VERSION)); // NOI18N + } + s.contents = new ArrayList(10); + while (peek() != -1) { + s.contents.add(readContent()); + } + if (DEBUG) System.err.println("parsed: " + s); // NOI18N + return s; + } + + public static final class CorruptException extends IOException { + public CorruptException() { + } + public CorruptException(String m) { + super(m); + } + } + + private int pushback = -1; + private int rb() throws IOException { + if (pushback != -1) { + int c = pushback; + pushback = -1; + return c; + } + int c = is.read(); + if (DEBUG) System.err.println("read: " + Integer.toHexString(c)); // NOI18N + if (c == -1) { + throw new EOFException(); + } else { + return c; + } + } + private int peek() throws IOException { + if (pushback != -1) throw new IllegalStateException("can only peek once"); // NOI18N + pushback = is.read(); + if (DEBUG) System.err.println("read: " + Integer.toHexString(pushback)); // NOI18N + return pushback; + } + + static String hexify(byte b) { + int i = b; + if (i < 0) i += 256; + String s = Integer.toHexString(i).toUpperCase(Locale.US); + return "0x" + pad(s, 2); // NOI18N + } + static String hexify(short s) { + int i = s; + if (i < 0) i += 65536; + String st = Integer.toHexString(i).toUpperCase(Locale.US); + return "0x" + pad(st, 4); // NOI18N + } + static String hexify(int i) { + String s = Integer.toHexString(i).toUpperCase(Locale.US); + return "0x" + pad(s, 4); // NOI18N + } + static String hexify(long l) { + String s1 = Integer.toHexString((int)((l & 0xFFFFFFFF00000000L) << 32)).toUpperCase(Locale.US); + String s2 = Integer.toHexString((int)(l & 0x00000000FFFFFFFFL)).toUpperCase(Locale.US); + return "0x" + pad(s1, 4) + pad(s2, 4); // NOI18N + } + static String hexify(byte[] b) { + StringBuffer buf = new StringBuffer(2 + b.length * 2); + buf.append("0x"); // NOI18N + for (int i = 0; i < b.length; i++) { + int x = b[i]; + if (x < 0) x += 256; + buf.append(pad(Integer.toHexString(x).toUpperCase(Locale.US), 2)); + } + return buf.toString(); + } + private static String pad(String s, int size) { + int i = s.length(); + if (i == size) { + return s; + } else { + StringBuffer b = new StringBuffer(size); + for (int k = 0; k < size - i; k++) { + b.append('0'); // NOI18N + } + b.append(s); + return b.toString(); + } + } + + private long readLong() throws IOException { + long x1 = rb(); + long x2 = rb(); + long x3 = rb(); + long x4 = rb(); + long x5 = rb(); + long x6 = rb(); + long x7 = rb(); + long x8 = rb(); + long l = (x1 << 56) + (x2 << 48) + (x3 << 40) + (x4 << 32) + (x5 << 24) + (x6 << 16) + (x7 << 8) + x8; + if (DEBUG) System.err.println("readLong: " + l); // NOI18N + return l; + } + + private int readInt() throws IOException { + int x1 = rb(); + int x2 = rb(); + int x3 = rb(); + int x4 = rb(); + int i = (x1 << 24) + (x2 << 16) + (x3 << 8) + x4; + if (DEBUG) System.err.println("readInt: " + i); // NOI18N + return i; + } + + private short readShort() throws IOException { + int x1 = rb(); + int x2 = rb(); + short s = (short)((x1 << 8) + x2); + //System.err.println("x1=" + hexify(x1) + " x2=" + hexify(x2) + " s=" + hexify(s)); + //if (DEBUG) System.err.println("x1=" + x1 + " x2=" + x2 + " s=" + s); + if (DEBUG) System.err.println("readShort: " + s); // NOI18N + return s; + } + + private byte readByte() throws IOException { + return (byte)rb(); + } + + private String readUTF() throws IOException { + short len = readShort(); + if (len < 0) throw new NotImplementedException();//XXX + byte[] buf = new byte[len]; + for (int i = 0; i < len; i++) { + buf[i] = readByte(); + } + String s = new String(buf, "UTF-8"); // NOI18N + if (DEBUG) System.err.println("readUTF: " + s); // NOI18N + return s; + } + + /* + private String readLongUTF() throws IOException { + long len = readLong(); + if (len < 0) throw new NotImplementedException();//XXX + if (len > Integer.MAX_VALUE) throw new NotImplementedException();// XXX + int ilen = (int)len; + byte[] buf = new byte[ilen]; + for (int i = 0; i < ilen; i++) { + buf[i] = readByte(); + } + String s = new String(buf, "UTF-8"); // NOI18N + if (DEBUG) System.err.println("readUTF: " + s); // NOI18N + return s; + } + */ + + // See "Rules of the Grammar" in Java Object Serialization Specification + // for explanation of all these objects. + + public static final class Stream /*extends Thing*/ { + public short magic; + public short version; + public List contents; + public String toString() { + return "Stream[contents=" + contents + "]"; // NOI18N + } + } + + public static final Object NULL = "null"; // NOI18N + + private Object readContent() throws IOException { + byte tc = readByte(); + switch (tc) { + case TC_OBJECT: + return readNewObject(); + case TC_CLASS: + return readNewClass(); + case TC_ARRAY: + return readNewArray(); + case TC_CLASSDESC: + return readNewClassDesc(); + case TC_PROXYCLASSDESC: + // XXX too complicated: + throw new NotImplementedException("TC_PROXYCLASSDESC"); // NOI18N + //return readNewProxyClassDesc(); + case TC_STRING: + return readNewString(); + case TC_LONGSTRING: + // XXX later + throw new NotImplementedException("TC_LONGSTRING"); // NOI18N + //return readNewLongString(); + case TC_REFERENCE: + return readReference(); + case TC_NULL: + return NULL; + case TC_EXCEPTION: + // XXX what is this?? + throw new NotImplementedException("TC_EXCEPTION"); // NOI18N + case TC_RESET: + // XXX what is this?? + throw new NotImplementedException("TC_RESET"); // NOI18N + case TC_BLOCKDATA: + return readBlockData(); + case TC_BLOCKDATALONG: + return readBlockDataLong(); + default: + throw new CorruptException("Unknown typecode: " + hexify(tc)); // NOI18N + } + } + + public static final class ObjectWrapper { + public ClassDesc classdesc; + public List data; // > + public String toString() { + return "Object[class=" + classdesc.name + ",data=]"; // NOI18N + } + } + + public static final class NameValue { + public NameValue(FieldDesc name, Object value) { + this.name = name; + this.value = value; + } + public final FieldDesc name; + public final Object value; + public String toString() { + return name.toString() + "=" + value.toString(); // NOI18N + } + } + + public static final class ClassDesc { + public String name; + public long svuid; + public boolean writeMethod; + public boolean blockData; + public boolean serializable; + public boolean externalizable; + public List fields; + public List annotation; // List + public ClassDesc superclass; + public String toString() { + return "Class[name=" + name + "]"; // NOI18N + } + } + + private ObjectWrapper readNewObject() throws IOException { + ObjectWrapper ow = new ObjectWrapper(); + ow.classdesc = readClassDesc(); + makeRef(ow); + ow.data = new ArrayList (10); + LinkedList hier = new LinkedList(); + for (ClassDesc cd = ow.classdesc; cd != null; cd = cd.superclass) { + hier.addFirst(cd); + } + for (ClassDesc cd: hier) { + if (cd.serializable) { + ow.data.addAll(readNoWrClass(cd)); + if (cd.writeMethod) { + ow.data.addAll(readContents()); + } + } else { + if (cd.blockData) { + ow.data.addAll(readContents()); + } else { + // Old externalization. If this is not object content, + // the stream could now become corrupted. Oh well. + ow.data.add(readContent()); + } + } + } + if (DEBUG) System.err.println("readNewObject: " + ow); // NOI18N + return ow; + } + + private ClassDesc readClassDesc() throws IOException { + Object o = readContent(); + if (o instanceof ClassDesc) { + return (ClassDesc)o; + } else if (o == NULL) { + return null; + } else { + throw new CorruptException("Expected class desc, got: " + o); // NOI18N + } + } + + private ClassDesc readNewClass() throws IOException { + ClassDesc cd = readClassDesc(); + makeRef(cd); + return cd; + } + + private ClassDesc readNewClassDesc() throws IOException { + ClassDesc cd = new ClassDesc(); + cd.name = readUTF(); + if (! cd.name.startsWith("[") && // NOI18N + ! (cd.name.length() == 1 && "BSIJFDCZ".indexOf(cd.name) != -1) && // NOI18N + ! cd.name.endsWith(";")) { // NOI18N + // Canonicalize. It seems class names read normally need this; those + // read as part of an array do not. ?? + cd.name = "L" + cd.name + ";"; // NOI18N + } + cd.svuid = readLong(); + makeRef(cd); + byte cdf = readByte(); + cd.writeMethod = (cdf & SC_WRITE_METHOD) != 0; + cd.blockData = (cdf & SC_BLOCK_DATA) != 0; + cd.serializable = (cdf & SC_SERIALIZABLE) != 0; + cd.externalizable = (cdf & SC_EXTERNALIZABLE) != 0; + short count = readShort(); + cd.fields = new ArrayList(count); + for (int i = 0; i < count; i++) { + cd.fields.add(readFieldDesc()); + } + cd.annotation = readContents(); + cd.superclass = readClassDesc(); + if (DEBUG) System.err.println("readNewClassDesc: " + cd); // NOI18N + return cd; + } + + public static class FieldDesc { + public String name; + public String type; + public String toString() { + return "Field[name=" + name + ",type=" + type + "]"; // NOI18N + } + } + public static final class ObjFieldDesc extends FieldDesc { + public boolean array; + public String toString() { + return "Field[name=" + name + ",type=" + type + (array ? "[]" : "") + "]"; // NOI18N + } + } + + private FieldDesc readFieldDesc() throws IOException { + char tc = (char)readByte(); + FieldDesc fd; + switch (tc) { + case 'B': + case 'C': + case 'D': + case 'F': + case 'I': + case 'J': + case 'S': + case 'Z': + fd = new FieldDesc(); + fd.type = new String(new char[] {tc}); + break; + case '[': + fd = new ObjFieldDesc(); + ((ObjFieldDesc)fd).array = true; + break; + case 'L': + fd = new ObjFieldDesc(); + ((ObjFieldDesc)fd).array = false; + break; + default: + throw new CorruptException("Strange field type: " + tc); // NOI18N + } + fd.name = readUTF(); + if (fd instanceof ObjFieldDesc) { + String clazz = (String)readContent(); + /* + if (((ObjFieldDesc)fd).array) { + if (! clazz.startsWith("[")) throw new CorruptException("Field type: " + clazz); // NOI18N + clazz = clazz.substring(1, clazz.length()); + } + if (! (clazz.startsWith("L") && clazz.endsWith(";"))) throw new CorruptException("Field type: " + clazz); // NOI18N + fd.type = clazz.substring(1, clazz.length() - 1).replace('/', '.'); // NOI18N + */ + fd.type = clazz; + } + if (DEBUG) System.err.println("readFieldDesc: " + fd); // NOI18N + return fd; + } + + private List readContents() throws IOException { + List l = new ArrayList(10); + while (peek() != TC_ENDBLOCKDATA) { + l.add(readContent()); + } + if (readByte() != TC_ENDBLOCKDATA) throw new IllegalStateException(); + if (DEBUG) System.err.println("readContents: " + l); // NOI18N + return l; + } + + public static final class ArrayWrapper { + public ClassDesc classdesc; + public List values; + public String toString() { + return classdesc.name + "{" + values + "}"; // NOI18N + } + } + + private ArrayWrapper readNewArray() throws IOException { + ArrayWrapper aw = new ArrayWrapper(); + aw.classdesc = readClassDesc(); + makeRef(aw); + int size = readInt(); + if (size < 0) throw new NotImplementedException(); + aw.values = new ArrayList(size); + for (int i = 0; i < size; i++) { + if (aw.classdesc.name.equals("[B")) { // NOI18N + aw.values.add(new Byte(readByte())); + } else if (aw.classdesc.name.equals("[S")) { // NOI18N + aw.values.add(new Short(readShort())); + } else if (aw.classdesc.name.equals("[I")) { // NOI18N + aw.values.add(new Integer(readInt())); + } else if (aw.classdesc.name.equals("[J")) { // NOI18N + aw.values.add(new Long(readLong())); + } else if (aw.classdesc.name.equals("[F")) { // NOI18N + aw.values.add(new Float(Float.intBitsToFloat(readInt()))); + } else if (aw.classdesc.name.equals("[D")) { // NOI18N + aw.values.add(new Double(Double.longBitsToDouble(readLong()))); + } else if (aw.classdesc.name.equals("[C")) { // NOI18N + aw.values.add(new Character((char)readShort())); + } else if (aw.classdesc.name.equals("[Z")) { // NOI18N + aw.values.add(readByte() == 1 ? Boolean.TRUE : Boolean.FALSE); + } else { + aw.values.add(readContent()); + } + } + if (DEBUG) System.err.println("readNewArray: " + aw); // NOI18N + return aw; + } + + private String readNewString() throws IOException { + String s = readUTF(); + makeRef(s); + return s; + } + + private Object readReference() throws IOException { + int i = readInt(); + Object r = getRef(i); + if (DEBUG) System.err.println("readReference: " + r); // NOI18N + return r; + } + + private byte[] readBlockData() throws IOException { + int size = readByte(); + if (size < 0) size += 256; + byte[] b = new byte[size]; + for (int i = 0; i < size; i++) { + b[i] = readByte(); + } + if (DEBUG) System.err.println("readBlockData: " + size + " bytes"); // NOI18N + return b; + } + + private byte[] readBlockDataLong() throws IOException { + int size = readInt(); + if (size < 0) throw new NotImplementedException(); + byte[] b = new byte[size]; + for (int i = 0; i < size; i++) { + b[i] = readByte(); + } + if (DEBUG) System.err.println("readBlockDataLong: " + size + " bytes"); // NOI18N + return b; + } + + private List readNoWrClass(ClassDesc cd) throws IOException { + List fields = cd.fields; + List values = new ArrayList(fields.size()); + for (int i = 0; i < fields.size(); i++) { + FieldDesc fd = (FieldDesc)fields.get(i); + if (fd.type.equals("B")) { // NOI18N + values.add(new NameValue(fd, new Byte(readByte()))); + } else if (fd.type.equals("S")) { // NOI18N + values.add(new NameValue(fd, new Short(readShort()))); + } else if (fd.type.equals("I")) { // NOI18N + values.add(new NameValue(fd, new Integer(readInt()))); + } else if (fd.type.equals("J")) { // NOI18N + values.add(new NameValue(fd, new Long(readLong()))); + } else if (fd.type.equals("F")) { // NOI18N + values.add(new NameValue(fd, new Float(Float.intBitsToFloat(readInt())))); + } else if (fd.type.equals("D")) { // NOI18N + values.add(new NameValue(fd, new Double(Double.longBitsToDouble(readLong())))); + } else if (fd.type.equals("C")) { // NOI18N + values.add(new NameValue(fd, new Character((char)readShort()))); + } else if (fd.type.equals("Z")) { // NOI18N + values.add(new NameValue(fd, readByte() == 1 ? Boolean.TRUE : Boolean.FALSE)); + } else { + values.add(new NameValue(fd, readContent())); + } + } + if (DEBUG) System.err.println("readNoWrClass: " + values); // NOI18N + return values; + } + +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/SettingsRecognizer.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/SettingsRecognizer.java new file mode 100644 index 000000000..f86b05e13 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/SettingsRecognizer.java @@ -0,0 +1,881 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.CharArrayWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.ObjectInput; +import java.io.ObjectInputStream; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.io.Reader; +import java.io.StringWriter; +import java.lang.reflect.Method; +import java.util.HashSet; +import java.util.Set; +import java.util.Stack; +import org.openide.ErrorManager; +import org.openide.filesystems.FileObject; +//import org.openide.modules.SpecificationVersion; +import org.openide.util.Lookup; +import org.openide.util.SharedClassObject; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; + +/** + * Copy of XMLSettingsSupport.SettingsRecognizer by Jan Pokorsky + */ +public class SettingsRecognizer extends org.xml.sax.helpers.DefaultHandler { + public static final String INSTANCE_DTD_ID = "-//NetBeans//DTD Session settings 1.0//EN"; // NOI18N + static final ErrorManager err = ErrorManager.getDefault().getInstance(SettingsRecognizer.class.getName()); // NOI18N + + private static final String ELM_SETTING = "settings"; // NOI18N + private static final String ATR_SETTING_VERSION = "version"; // NOI18N + + private static final String ELM_MODULE = "module"; // NOI18N + private static final String ATR_MODULE_NAME = "name"; // NOI18N + private static final String ATR_MODULE_SPEC = "spec"; // NOI18N + private static final String ATR_MODULE_IMPL = "impl"; // NOI18N + + private static final String ELM_INSTANCE = "instance"; // NOI18N + private static final String ATR_INSTANCE_CLASS = "class"; // NOI18N + private static final String ATR_INSTANCE_METHOD = "method"; // NOI18N + + private static final String ELM_INSTANCEOF = "instanceof"; // NOI18N + private static final String ATR_INSTANCEOF_CLASS = "class"; // NOI18N + + private static final String ELM_SERIALDATA = "serialdata"; // NOI18N + private static final String ATR_SERIALDATA_CLASS = "class"; // NOI18N + + //private static final String VERSION = "1.0"; // NOI18N + + private boolean header; + private Stack stack; + + private String version; + private String instanceClass; + private String instanceMethod; + private Set instanceOf = new HashSet(); + + private byte[] serialdata; + private CharArrayWriter chaos = null; + + private String codeName; + private String codeNameBase; + private int codeNameRelease; + //private SpecificationVersion moduleSpec; + private String moduleImpl; + /** file with stored settings */ + private final FileObject source; + + /** XML handler recognizing settings. + * @param header if true read just elements instanceof, module and attr classname. + * @param source file with stored settings + */ + public SettingsRecognizer(boolean header, FileObject source) { + this.header = header; + this.source = source; + } + + public boolean isAllRead() { + return !header; + } + + public void setAllRead(boolean all) { + if (!header) return; + header = all; + } + + public String getSettingsVerison() { + return version; + } + + public String getCodeName() { + return codeName; + } + + public String getCodeNameBase() { + return codeNameBase; + } + + public int getCodeNameRelease() { + return codeNameRelease; + } + + /*public SpecificationVersion getSpecificationVersion() { + return moduleSpec; + }*/ + + public String getModuleImpl() { + return moduleImpl; + } + + /** Set of names. */ + public Set getInstanceOf() { + return instanceOf; + } + + /** Method attribute from the instance element. */ + public String getMethodName() { + return instanceMethod; + } + + /** Serialized instance, can be null. */ + public InputStream getSerializedInstance() { + if (serialdata == null) return null; + return new ByteArrayInputStream(serialdata); + } + + public org.xml.sax.InputSource resolveEntity(String publicId, String systemId) + throws SAXException { + if (INSTANCE_DTD_ID.equals(publicId)) { + return new org.xml.sax.InputSource(new ByteArrayInputStream(new byte[0])); + } else { + return null; // i.e. follow advice of systemID + } + } + + public void characters(char[] values, int start, int length) throws SAXException { + if (header) return; + String element = stack.peek(); + if (ELM_SERIALDATA.equals(element)) { + // [PENDING] should be optimized to do not read all chars to memory + if (chaos == null) chaos = new CharArrayWriter(length); + chaos.write(values, start, length); + } + } + + public void startElement(String uri, String localName, String qName, Attributes attribs) throws SAXException { + stack.push(qName); + if (ELM_SETTING.equals(qName)) { + version = attribs.getValue(ATR_SETTING_VERSION); + } else if (ELM_MODULE.equals(qName)) { + codeName = attribs.getValue(ATR_MODULE_NAME); + resolveModuleElm(codeName); + moduleImpl = attribs.getValue(ATR_MODULE_IMPL); + try { + String spec = attribs.getValue(ATR_MODULE_SPEC); + //moduleSpec = spec == null ? null : new SpecificationVersion(spec); + } catch (NumberFormatException nfe) { + throw new SAXException(nfe); + } + } else if (ELM_INSTANCEOF.equals(qName)) { + instanceOf.add(org.openide.util.Utilities.translate( + attribs.getValue(ATR_INSTANCEOF_CLASS))); + } else if (ELM_INSTANCE.equals(qName)) { + instanceClass = attribs.getValue(ATR_INSTANCE_CLASS); + if (instanceClass == null) { + System.err.println("Hint: NPE is caused by broken settings file: " + source ); // NOI18N + } + instanceClass = org.openide.util.Utilities.translate(instanceClass); + instanceMethod = attribs.getValue(ATR_INSTANCE_METHOD); + } else if (ELM_SERIALDATA.equals(qName)) { + instanceClass = attribs.getValue(ATR_SERIALDATA_CLASS); + instanceClass = org.openide.util.Utilities.translate(instanceClass); + if (header) throw new StopSAXException(); + } + } + + /** reade codenamebase + revision */ + private void resolveModuleElm(String codeName) { + if (codeName != null) { + int slash = codeName.indexOf("/"); // NOI18N + if (slash == -1) { + codeNameBase = codeName; + codeNameRelease = -1; + } else { + codeNameBase = codeName.substring(0, slash); + try { + codeNameRelease = Integer.parseInt(codeName.substring(slash + 1)); + } catch (NumberFormatException ex) { + ErrorManager emgr = ErrorManager.getDefault(); + emgr.annotate(ex, "Content: \n" + getFileContent(source)); // NOI18N + emgr.annotate(ex, "Source: " + source); // NOI18N + emgr.notify(ErrorManager.INFORMATIONAL, ex); + codeNameRelease = -1; + } + } + } else { + codeNameBase = null; + codeNameRelease = -1; + } + } + + public void endElement(String uri, String localName, String qName) throws SAXException { + //if (header) return; + String element = stack.pop(); + if (ELM_SERIALDATA.equals(element)) { + if (chaos != null) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(chaos.size() >> 1); + try { + chars2Bytes(baos, chaos.toCharArray(), 0, chaos.size()); + serialdata = baos.toByteArray(); + } catch (IOException ex) { + ErrorManager.getDefault().notify( + ErrorManager.WARNING, ex + ); + } finally { + chaos = null; // don't keep the info twice + try { + baos.close(); + } catch (IOException ex) { + // doesn't matter + } + } + } + } + } + + /** Tries to deserialize instance saved in is. + * @param is stream with stored object, can be null + * @return deserialized object or null + */ + private Object readSerial(InputStream is) throws IOException, ClassNotFoundException { + if (is == null) return null; + try { + ObjectInput oi = new ObjectInputStream(is); + try { + Object o = oi.readObject(); + return o; + } finally { + oi.close(); + } + } catch (IOException ex) { + ErrorManager emgr = ErrorManager.getDefault(); + emgr.annotate(ex, "Content: \n" + getFileContent(source)); // NOI18N + emgr.annotate(ex, "Source: " + source); // NOI18N + emgr.annotate(ex, "Cannot read class: " + instanceClass); // NOI18N + throw ex; + } catch (ClassNotFoundException ex) { + ErrorManager emgr = ErrorManager.getDefault(); + emgr.annotate(ex, "Content: \n" + getFileContent(source)); // NOI18N + emgr.annotate(ex, "Source: " + source); // NOI18N + throw ex; + } + } + + /** Create an instance. + * @return the instance of type {@link #instanceClass} + * @exception IOException if an I/O error occured + * @exception ClassNotFoundException if a class was not found + */ + public Object instanceCreate() throws java.io.IOException, ClassNotFoundException { + Object inst = null; + + // deserialize + inst = readSerial(getSerializedInstance()); + + // default instance + if (inst == null) { + if (instanceMethod != null) { + inst = createFromMethod(instanceClass, instanceMethod); + } else { + // use default constructor + Class clazz = instanceClass(); + if (SharedClassObject.class.isAssignableFrom(clazz)) { + inst = SharedClassObject.findObject(clazz.asSubclass(SharedClassObject.class), false); + if (null != inst) { + // instance already exists -> reset it to defaults + try { + Method method = SharedClassObject.class.getDeclaredMethod("reset", new Class[0]); // NOI18N + method.setAccessible(true); + method.invoke(inst, new Object[0]); + } catch (Exception e) { + ErrorManager.getDefault().notify(e); + } + } else { + inst = SharedClassObject.findObject(clazz.asSubclass(SharedClassObject.class), true); + } + } else { + try { + inst = clazz.newInstance(); + } catch (Exception ex) { + IOException ioe = new IOException(); + ErrorManager emgr = ErrorManager.getDefault(); + emgr.annotate(ioe, ex); + emgr.annotate(ioe, "Content: \n" + getFileContent(source)); // NOI18N + emgr.annotate(ioe, "Class: " + clazz); // NOI18N + emgr.annotate(ioe, "Source: " + source); // NOI18N + throw ioe; + } + } + } + } + + return inst; + } + + /** Get file content as String. If some exception occures its stack trace + * is return instead. */ + private static String getFileContent(FileObject fo) { + try { + InputStreamReader isr = new InputStreamReader(fo.getInputStream()); + char[] cbuf = new char[1024]; + int length; + StringBuffer sbuf = new StringBuffer(1024); + while (true) { + length = isr.read(cbuf); + if (length > 0) { + sbuf.append(cbuf, 0, length); + } else { + return sbuf.toString(); + } + } + } catch (Exception ex) { + StringWriter sw = new StringWriter(); + ex.printStackTrace(new PrintWriter(sw)); + return sw.toString(); + } + } + + /** create instance by invoking class method */ + private Object createFromMethod(String srcClazz, String srcMethod) + throws ClassNotFoundException, IOException { + int dotIndex = instanceMethod.lastIndexOf('.'); + String targetClass; + String targetMethod; + if (dotIndex > 0) { + targetClass = srcMethod.substring(0, dotIndex); + targetMethod = srcMethod.substring(dotIndex + 1); + } else { + targetClass = srcClazz; + targetMethod = srcMethod; + } + + Class clazz = loadClass(targetClass); + + try { + Object instance; + try { + Method method = clazz.getMethod(targetMethod, new Class[]{FileObject.class}); + method.setAccessible(true); + instance = method.invoke(null, source); + } catch (NoSuchMethodException ex) { + Method method = clazz.getMethod(targetMethod); + method.setAccessible(true); + instance = method.invoke(null, new Object[0]); + } + if (instance == null) { + // Strictly verboten. Cf. BT #4827173 for example. + throw new IOException("Null return not permitted from " + targetClass + "." + targetMethod); // NOI18N + } + return instance; + } catch (Exception ex) { + IOException ioe = new IOException("Error reading " + source + ": " + ex); // NOI18N + ErrorManager emgr = ErrorManager.getDefault(); + emgr.annotate(ioe, "Class: " + clazz); // NOI18N + emgr.annotate(ioe, "Method: " + srcMethod); // NOI18N + emgr.annotate(ioe, ex); + emgr.annotate(ioe, "Content:\n" + getFileContent(source)); // NOI18N + throw ioe; + } + } + + /** The representation type that may be created as instances. + * Can be used to test whether the instance is of an appropriate + * class without actually creating it. + * + * @return the representation class of the instance + * @exception IOException if an I/O error occurred + * @exception ClassNotFoundException if a class was not found + */ + public Class instanceClass() throws java.io.IOException, ClassNotFoundException { + if (instanceClass == null) { + throw new ClassNotFoundException(source + + ": missing 'class' attribute in 'instance' element"); //NOI18N + } + + return loadClass(instanceClass); + } + + /** try to load class from system and current classloader. */ + private Class loadClass(String clazz) throws ClassNotFoundException { + return ((ClassLoader)Lookup.getDefault().lookup(ClassLoader.class)).loadClass(clazz); + } + + /** get class name of instance */ + public String instanceName() { + if (instanceClass == null) { + return ""; // NOI18N + } else { + return instanceClass; + } + } + + private int tr(char c) { + if (c >= '0' && c <= '9') return c - '0'; + if (c >= 'A' && c <= 'F') return c - 'A' + 10; + if (c >= 'a' && c <= 'f') return c - 'a' + 10; + return -1; + } + + /** Converts array of chars to array of bytes. All whitespaces and + * unknown chars are skipped. + */ + private void chars2Bytes(OutputStream os, char[] chars, int off, int length) + throws IOException { + byte rbyte; + int read; + + for (int i = off; i < length; ) { + read = tr(chars[i++]); + if (read >= 0) rbyte = (byte) (read << 4); // * 16; + else continue; + + while (i < length) { + read = tr(chars[i++]); + if (read >= 0) { + rbyte += (byte) read; + os.write(rbyte); + break; + } + } + } + } + + /** Parse settings file. */ + public void parse() throws IOException { + InputStream in = null; + + try { + if (header) { + if (err.isLoggable(err.INFORMATIONAL) && source.getSize() < 12000) { + // log the content of the stream + byte[] arr = new byte[(int)source.getSize()]; + InputStream temp = source.getInputStream(); + int len = temp.read(arr); + if (len != arr.length) { + throw new IOException("Could not read " + arr.length + " bytes from " + source + " just " + len); // NOI18N + } + + err.log("Parsing:" + new String(arr)); + + temp.close(); + + in = new ByteArrayInputStream(arr); + } else { + in = new BufferedInputStream(source.getInputStream()); + } + Set iofs = quickParse(new BufferedInputStream(in)); + if (iofs != null) { + instanceOf = iofs; + return; + } + } + } catch (IOException ioe) { + // ignore - fallback to XML parser follows + } finally { + if (in != null) in.close(); + } + stack = new Stack(); + try { + in = source.getInputStream(); + XMLReader reader = org.openide.xml.XMLUtil.createXMLReader(); + reader.setContentHandler(this); + reader.setErrorHandler(this); + reader.setEntityResolver(this); + reader.parse(new org.xml.sax.InputSource(new BufferedInputStream(in))); + } catch (SettingsRecognizer.StopSAXException ex) { + // Ok, header is read + } catch (SAXException ex) { + IOException ioe = new IOException(source.toString()); // NOI18N + ErrorManager emgr = ErrorManager.getDefault(); + emgr.annotate(ioe, ex); + if (ex.getException() != null) { + emgr.annotate(ioe, ex.getException()); + } + emgr.annotate(ioe, "Content: \n" + getFileContent(source)); // NOI18N + emgr.annotate(ioe, "Source: " + source); // NOI18N + throw ioe; + } finally { + stack = null; + try { + if (in != null) { + in.close(); + } + } catch (IOException ex) { + // ignore already closed + } + } + } + + /** Parse setting from source. */ + public void parse(Reader source) throws IOException { + stack = new Stack(); + + try { + XMLReader reader = org.openide.xml.XMLUtil.createXMLReader(); + reader.setContentHandler(this); + reader.setErrorHandler(this); + reader.setEntityResolver(this); + reader.parse(new org.xml.sax.InputSource(source)); + } catch (SettingsRecognizer.StopSAXException ex) { + // Ok, header is read + } catch (SAXException ex) { + IOException ioe = new IOException(source.toString()); // NOI18N + ErrorManager emgr = ErrorManager.getDefault(); + emgr.annotate(ioe, ex); + if (ex.getException() != null) { + emgr.annotate(ioe, ex.getException()); + } + throw ioe; + } finally { + stack = null; + } + } + + // Encoding irrelevant for these getBytes() calls: all are ASCII... + // (unless someone has their system encoding set to UCS-16!) + private static final byte[] MODULE_SETTINGS_INTRO = " quickParse(InputStream is) throws IOException { + Set iofs = new HashSet(); // + + if (!expect(is, MODULE_SETTINGS_INTRO)) { + err.log("Could not read intro "+source); // NOI18N + return null; + } + version = readTo(is, '"'); + if (version == null) { + err.log("Could not read version "+source); // NOI18N + return null; + } + if (!expect(is, MODULE_SETTINGS_INTRO_END)) { + err.log("Could not read stuff after cnb "+source); // NOI18N + return null; + } + // Now we have (module?, instanceof*, (instance | serialdata)). + int c; + PARSE: + while (true) { + c = is.read(); + switch (c) { + case 'm': + // + if (!expect(is, MODULE_SETTINGS_MODULE_NAME)) { + err.log("Could not read up to + if (!expect(is, MODULE_SETTINGS_MODULE_SPEC)) { + err.log("Could not read up to spec=\" "+source); // NOI18N + return null; + } + String mspec = readTo(is, '"'); + if (mspec == null) { + err.log("Could not read module spec value "+source); // NOI18N + return null; + } + try { + //moduleSpec = new SpecificationVersion(mspec); + } catch (NumberFormatException nfe) { + return null; + } + c = is.read(); + if (c == '/') { + if (!expect(is, MODULE_SETTINGS_TAG_END)) { + err.log("Could not read up to end of tag "+source); // NOI18N + return null; + } + break; + } else if (c != ' ') { + err.log("Could not read space after module name "+source); // NOI18N + return null; + } + // + if (!expect(is, MODULE_SETTINGS_MODULE_IMPL)) { + err.log("Could not read up to impl=\" "+source); // NOI18N + return null; + } + moduleImpl = readTo(is, '"'); + if (moduleImpl == null) { + err.log("Could not read module impl value "+source); // NOI18N + return null; + } + moduleImpl = moduleImpl.intern(); + // /> > + if (!expect(is, MODULE_SETTINGS_TAG_END)) { + err.log("Could not read up to /> < "+source); // NOI18N + return null; + } + break; + case 'i': + // or + if (!expect(is, MODULE_SETTINGS_INSTANCE)) { + err.log("Could not read up to instance "+source); // NOI18N + return null; + } + // Now we need to check which one + c = is.read(); + if (c == 'o') { + if (!expect(is, MODULE_SETTINGS_OF)) { + err.log("Could not read up to instance"); // NOI18N + return null; + } + String iof = readTo(is, '"'); + if (iof == null) { + err.log("Could not read instanceof value "+source); // NOI18N + return null; + } + iof = org.openide.util.Utilities.translate(iof).intern(); + iofs.add(iof); + if (is.read() != '/') { + err.log("No / at end of " + iof+" "+source); // NOI18N + return null; + } + if (!expect(is, MODULE_SETTINGS_TAG_END)) { + err.log("Could not read up to next tag after " + iof+" "+source); // NOI18N + return null; + } + } else if (c == ' ') { + // read class and optional method + if (!expect(is, MODULE_SETTINGS_INSTANCE_CLZ)) { + err.log("Could not read up to class=\" "+source); // NOI18N + return null; + } + instanceClass = readTo(is, '"'); + if (instanceClass == null) { + err.log("Could not read instance class value "+source); // NOI18N + return null; + } + instanceClass = org.openide.util.Utilities.translate(instanceClass).intern(); + c = is.read(); + if (c == '/') { + if (!expect(is, MODULE_SETTINGS_TAG_END)) { + err.log("Could not read up to end of instance tag "+source); // NOI18N + return null; + } + break; + } else if (c != ' ') { + err.log("Could not space after instance class "+source); // NOI18N + return null; + } + // + if (!expect(is, MODULE_SETTINGS_INSTANCE_MTD)) { + err.log("Could not read up to method=\" "+source); // NOI18N + return null; + } + instanceMethod = readTo(is, '"'); + if (instanceMethod == null) { + err.log("Could not read method value "+source); // NOI18N + return null; + } + instanceMethod = instanceMethod.intern(); + c = is.read(); + if (c == '/') { + if (!expect(is, MODULE_SETTINGS_TAG_END)) { + err.log("Could not read up to end of instance tag "+source); // NOI18N + return null; + } + break; + } + err.log("Strange stuff after method attribute "+source); // NOI18N + return null; + } else { + err.log("Could not read after to instance "+source); // NOI18N + return null; + } + break; + case 's': + // 126) return null; + if (c == 10 || c == 13) { + // Normalize: s/[\r\n]+/\n/g + if (inNewline) { + continue; + } else { + inNewline = true; + c = 10; + } + } else if (c < 32 && c != 9) { + // Random control character! + return null; + } else { + inNewline = false; + } + if (c == delim) { + return caw.toString(); + } else { + caw.write(c); + } + } + } + + final static class StopSAXException extends SAXException { + public StopSAXException() { + super("Parser stopped"); // NOI18N + } + } + +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/StringPropertyProcessor.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/StringPropertyProcessor.java new file mode 100644 index 000000000..f6eec332a --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/StringPropertyProcessor.java @@ -0,0 +1,69 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.util.Iterator; +import java.util.List; + +/** + * @author Radek Matous + */ +class StringPropertyProcessor extends PropertyProcessor { + StringPropertyProcessor() { + super("java.lang.String");//NOI18N + } + + void processPropertyImpl(String propertyName, Object value) { + if ("userProxyHost".equals(propertyName)) {//NOI18N + addProperty("proxyHttpHost", value.toString()); + } else if ("userProxyPort".equals(propertyName)) {//NOI18N + addProperty("proxyHttpPort", value.toString()); + } else if ("userNonProxy".equals(propertyName)) {//NOI18N + addProperty("proxyNonProxyHosts", value.toString()); + } else { + addProperty(propertyName, value == SerParser.NULL ? null : value.toString()); + } + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/SystemOptionsParser.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/SystemOptionsParser.java new file mode 100644 index 000000000..cbafd4a1a --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/SystemOptionsParser.java @@ -0,0 +1,119 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.io.*; +import java.util.Iterator; +import java.util.Set; +import org.openide.filesystems.FileObject; + +/** + * + * @author Radek Matous + */ +public class SystemOptionsParser { + static final String EXPECTED_INSTANCE = "org.openide.options.SystemOption";//NOI18N + + private String systemOptionInstanceName; + private boolean types; + + private SystemOptionsParser(final String systemOptionInstanceName, final boolean types) { + this.systemOptionInstanceName = systemOptionInstanceName; + this.types = types; + } + + public static DefaultResult parse(FileObject settingsFo, boolean types) throws IOException, ClassNotFoundException { + SettingsRecognizer instance = getRecognizer(settingsFo); + + SystemOptionsParser rImpl = null; + InputStream is = instance.getSerializedInstance(); + try { + SerParser sp = new SerParser(is); + SerParser.Stream s = sp.parse(); + rImpl = new SystemOptionsParser(instance.instanceName(), types); + DefaultResult ret = (DefaultResult)rImpl.processContent(s.contents.iterator(), false); + ret.setModuleName(instance.getCodeNameBase().replace('.','/')); + return ret; + } finally { + is.close(); + } + } + + private Result processContent(final Iterator it, final boolean reachedWriteReplace) { + for (; it.hasNext();) { + Object elem = it.next(); + if (!reachedWriteReplace && elem instanceof SerParser.ObjectWrapper) { + SerParser.ObjectWrapper ow = (SerParser.ObjectWrapper)elem; + String name = ow.classdesc.name; + if (name.endsWith("org.openide.util.SharedClassObject$WriteReplace;")) {//NOI18N + return processContent(ow.data.iterator(), true); + } + } else if (reachedWriteReplace && elem instanceof SerParser.NameValue ) { + SerParser.NameValue nv = (SerParser.NameValue)elem; + if (systemOptionInstanceName.equals(nv.value)) { + Result result = ContentProcessor.parseContent(systemOptionInstanceName, types, it); + return result; + } + } + } + return null; + } + + private static SettingsRecognizer getRecognizer(final FileObject settingsFo) throws IOException { + SettingsRecognizer recognizer = new SettingsRecognizer(false, settingsFo); + recognizer.parse(); + + Set instances = recognizer.getInstanceOf(); + String iName = recognizer.instanceName(); + if (!instances.contains(EXPECTED_INSTANCE)) { + throw new IOException(iName); + } + return recognizer; + } +} + + + + diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/TaskTagsProcessor.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/TaskTagsProcessor.java new file mode 100644 index 000000000..e08a2993b --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/TaskTagsProcessor.java @@ -0,0 +1,96 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.rmi.UnexpectedException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * For: org.netbeans.modules.tasklist.docscan.TaskTags + * @author Radek Matous + */ +class TaskTagsProcessor extends PropertyProcessor { + + /** Creates a new instance of TaskTagsProcessor */ + TaskTagsProcessor() { + super("org.netbeans.modules.tasklist.docscan.TaskTags");//NOI18N + } + + void processPropertyImpl(String propertyName, Object value) { + if ("taskTags".equals(propertyName)) {//NOI18N + List l = ((SerParser.ObjectWrapper)value).data; + for (Iterator it = l.iterator(); it.hasNext();) { + Object elem = (Object) it.next(); + if (elem instanceof SerParser.ObjectWrapper) { + String clsname = Utils.prettify(((SerParser.ObjectWrapper)elem).classdesc.name); + if ("org.netbeans.modules.tasklist.docscan.TaskTag".equals(clsname)) {//NOI18N + processTag(elem);//NOI18N + } + } + } + } else { + throw new IllegalStateException(); + } + } + + private void processTag(final Object value) { + String tagName = null; + List l = ((SerParser.ObjectWrapper)value).data; + for (Iterator it = l.iterator(); it.hasNext();) { + Object elem = (Object) it.next(); + if (elem instanceof SerParser.ObjectWrapper) { + String val = ((SerParser.NameValue)(((SerParser.ObjectWrapper)elem).data.get(0))).value.toString(); + assert tagName != null; + addProperty(tagName, val); + } else if (elem instanceof String) { + tagName = "Tag"+(String)elem;//NOI18N + } + } + } + +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/URLProcessor.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/URLProcessor.java new file mode 100644 index 000000000..8fdd7ac2d --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/URLProcessor.java @@ -0,0 +1,111 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Iterator; +import java.util.List; + +/** + * @author Milos Kleint + */ +class URLProcessor extends PropertyProcessor { + URLProcessor() { + super("java.net.URL");//NOI18N + } + + void processPropertyImpl(String propertyName, Object value) { + StringBuffer sb = new StringBuffer(); + if ("mainProjectURL".equals(propertyName)) {//NOI18N + List l = ((SerParser.ObjectWrapper)value).data; + try { + URL url = createURL(l); + addProperty(propertyName, url.toExternalForm()); + } catch (MalformedURLException ex) { + ex.printStackTrace(); + } + } else { + throw new IllegalStateException(); + } + } + + public static URL createURL(List l) throws MalformedURLException { + String protocol = null; + String host = null; + int port = -1; + String file = null; + String authority = null; + String ref = null; + for (Iterator it = l.iterator(); it.hasNext();) { + Object elem = (Object) it.next(); + if (elem instanceof SerParser.NameValue) { + SerParser.NameValue nv = (SerParser.NameValue)elem; + if (nv.value != null && nv.name != null) { + if (nv.name.name.equals("port")) {//NOI18N + port = ((Integer)nv.value).intValue();//NOI18N + } + else if (nv.name.name.equals("file")) {//NOI18N + file = nv.value.toString();//NOI18N + } + else if (nv.name.name.equals("authority")) {//NOI18N + authority = nv.value.toString();//NOI18N + } + else if (nv.name.name.equals("host")) {//NOI18N + host = nv.value.toString();//NOI18N + } + else if (nv.name.name.equals("protocol")) {//NOI18N + protocol = nv.value.toString();//NOI18N + } + else if (nv.name.name.equals("ref")) {//NOI18N + ref = nv.value.toString();//NOI18N + } + } + } + } + return new URL(protocol, host, port, file); + + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/Utils.java b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/Utils.java new file mode 100644 index 000000000..d077c8f55 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/Utils.java @@ -0,0 +1,150 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.upgrade.systemoptions; + +import java.util.Iterator; +import java.util.List; +import org.netbeans.upgrade.systemoptions.SerParser.ArrayWrapper; +import org.netbeans.upgrade.systemoptions.SerParser.NameValue; +import org.netbeans.upgrade.systemoptions.SerParser.ObjectWrapper; + +/** + * + * @author rmatous + */ +final class Utils { + + /** Creates a new instance of Utils */ + private Utils() {} + + + static String valueFromObjectWrapper(final Object value) { + String stringvalue = null; + if (value instanceof ObjectWrapper) { + List l = ((SerParser.ObjectWrapper)value).data; + if (l.size() == 1) { + Object o = l.get(0); + if (o instanceof NameValue) { + Object key = null; + stringvalue = ((NameValue) o).value.toString(); + } + } + if (stringvalue == null) { + stringvalue = ((ObjectWrapper) value).classdesc.name; + } + } else if (value instanceof String && !"null".equals(value)) { + stringvalue = value.toString(); + + } else if (value instanceof SerParser.ArrayWrapper && "[Ljava.lang.String;".equals(((SerParser.ArrayWrapper)value).classdesc.name)) { + StringBuffer sb = new StringBuffer(); + List es = ((SerParser.ArrayWrapper)value).values; + for (Iterator it = es.iterator(); it.hasNext();) { + sb.append((String)it.next()); + if (it.hasNext()) { + sb.append(" , "); + } + } + stringvalue = sb.toString(); + } else if (value instanceof SerParser.ArrayWrapper && "[[Ljava.lang.String;".equals(((SerParser.ArrayWrapper)value).classdesc.name)) { + StringBuffer sb = new StringBuffer(); + List awl = ((SerParser.ArrayWrapper)value).values; + for (Iterator it = awl.iterator(); it.hasNext();) { + SerParser.ArrayWrapper aw = (SerParser.ArrayWrapper)it.next(); + sb.append(valueFromObjectWrapper(aw)); + if (it.hasNext()) { + sb.append(" | "); + } + } + stringvalue = sb.toString(); + } else { + stringvalue = "unknown";//value.toString(); + } + return stringvalue; + } + + static String getClassNameFromObject(final Object value) { + String clsName = null; + if (value instanceof ObjectWrapper) { + clsName = prettify(((ObjectWrapper) value).classdesc.name); + } else if (value instanceof ArrayWrapper) { + clsName = prettify(((ArrayWrapper) value).classdesc.name); + } else { + clsName = prettify(value.getClass().getName()); + } + return clsName; + } + + static String prettify(String type) { + if (type.equals("B")) { // NOI18N + return "byte"; // NOI18N + } else if (type.equals("S")) { // NOI18N + return "short"; // NOI18N + } else if (type.equals("I")) { // NOI18N + return "int"; // NOI18N + } else if (type.equals("J")) { // NOI18N + return "long"; // NOI18N + } else if (type.equals("F")) { // NOI18N + return "float"; // NOI18N + } else if (type.equals("D")) { // NOI18N + return "double"; // NOI18N + } else if (type.equals("C")) { // NOI18N + return "char"; // NOI18N + } else if (type.equals("Z")) { // NOI18N + return "boolean"; // NOI18N + } else if (type.startsWith("L") && type.endsWith(";")) { // NOI18N + String fqn = type.substring(1, type.length() - 1).replace('/', '.').replace('$', '.'); // NOI18N + return fqn; + } + if (!type.startsWith("[")) { + if (type.startsWith("L")) { + return type.substring(1); + } + if (type.endsWith(";")) { + return type.substring(0,type.length()-1); + } + } + return type; + } +} diff --git a/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/systemoptionsimport b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/systemoptionsimport new file mode 100644 index 000000000..6caf84336 --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/upgrade/systemoptions/systemoptionsimport @@ -0,0 +1,16 @@ +Services/org-netbeans-core-IDESettings.settings +Services/org-netbeans-modules-derby-DerbyOptions.settings +Services/org-apache-tools-ant-module-AntSettings.settings +Services/org-netbeans-modules-project-ui-OpenProjectList.settings +Services/org-netbeans-modules-i18n-I18nOptions.settings +Services/org-netbeans-modules-javadoc-settings-DocumentationSettings.settings +Services/org-netbeans-modules-junit-JUnitSettings.settings +Services/org-netbeans-modules-tasklist-docscan-Settings.settings +Services/org-netbeans-modules-xml-core-settings-CoreSettings.settings +Services/org-netbeans-modules-httpserver-HttpServerSettings.settings +Services/formsettings.settings +Services/org-openide-text-PrintSettings.settings +Services/org-netbeans-modules-profiler-ProfilerIDESettings.settings +Services/Hidden/org-netbeans-modules-versioning-system-cvss-settings-CvsModuleConfig.settings +Services/Hidden/org-netbeans-modules-versioning-system-cvss-settings-CvsRootSettings.settings +Services/Hidden/org-netbeans-modules-subversion-settings-SvnModuleConfig.settings \ No newline at end of file diff --git a/sdk/jme3-upgrader/src/org/netbeans/util/Util.java b/sdk/jme3-upgrader/src/org/netbeans/util/Util.java new file mode 100644 index 000000000..6d89ab0fa --- /dev/null +++ b/sdk/jme3-upgrader/src/org/netbeans/util/Util.java @@ -0,0 +1,176 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.util; + +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.Dialog; +import java.awt.Image; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.List; +import javax.swing.JDialog; +import javax.swing.JOptionPane; +import javax.swing.UIManager; +import org.openide.util.ImageUtilities; +import org.openide.util.Utilities; + +/** + * Provides utility methods + * + * @author Marek Slama + */ + +public class Util { + + /** Creates a new instance of Utilities */ + private Util() { + } + + /** Tries to set default L&F according to platform. + * Uses: + * Metal L&F on Linux and Solaris + * Windows L&F on Windows + * Aqua L&F on Mac OS X + * System L&F on other OS + */ + public static void setDefaultLookAndFeel () { + String uiClassName; + if (Utilities.isWindows()) { + uiClassName = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; //NOI18N + } else if (Utilities.isMac()) { + uiClassName = "apple.laf.AquaLookAndFeel"; //NOI18N + } else if (Utilities.isUnix()) { + uiClassName = "javax.swing.plaf.metal.MetalLookAndFeel"; //NOI18N + } else { + uiClassName = UIManager.getSystemLookAndFeelClassName(); + } + if (uiClassName.equals(UIManager.getLookAndFeel().getClass().getName())) { + //Desired L&F is already set + return; + } + try { + UIManager.setLookAndFeel(uiClassName); + } catch (Exception ex) { + System.err.println("Cannot set L&F " + uiClassName); //NOI18N + System.err.println("Exception:" + ex.getMessage()); //NOI18N + ex.printStackTrace(); + } + } + + /** #154031 - set NetBeans icons for license dialog. + */ + public static void initIcons(JDialog dialog) { + List images = new ArrayList(); + images.add(ImageUtilities.loadImage("org/netbeans/core/startup/frame.gif", true)); //NOI18N + images.add(ImageUtilities.loadImage("org/netbeans/core/startup/frame32.gif", true)); //NOI18N + images.add(ImageUtilities.loadImage("org/netbeans/core/startup/frame48.gif", true)); //NOI18N + dialog.setIconImages(images); + } + + /** #154030 - Creates JDialog around JOptionPane. The body is copied from JOptionPane.createDialog + * because we need APPLICATION_MODAL type of dialog on JDK6. + */ + public static JDialog createJOptionDialog(final JOptionPane pane, String title) { + final JDialog dialog = new JDialog(null, title, Dialog.ModalityType.APPLICATION_MODAL); + Util.initIcons(dialog); + Container contentPane = dialog.getContentPane(); + contentPane.setLayout(new BorderLayout()); + contentPane.add(pane, BorderLayout.CENTER); + dialog.setResizable(false); + dialog.pack(); + dialog.setLocationRelativeTo(null); + WindowAdapter adapter = new WindowAdapter() { + + private boolean gotFocus = false; + + @Override + public void windowClosing(WindowEvent we) { + pane.setValue(null); + } + + @Override + public void windowGainedFocus(WindowEvent we) { + // Once window gets focus, set initial focus + if (!gotFocus) { + pane.selectInitialValue(); + gotFocus = true; + } + } + }; + dialog.addWindowListener(adapter); + dialog.addWindowFocusListener(adapter); + dialog.addComponentListener(new ComponentAdapter() { + + @Override + public void componentShown(ComponentEvent ce) { + // reset value to ensure closing works properly + pane.setValue(JOptionPane.UNINITIALIZED_VALUE); + } + }); + pane.addPropertyChangeListener(new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent event) { + // Let the defaultCloseOperation handle the closing + // if the user closed the window without selecting a button + // (newValue = null in that case). Otherwise, close the dialog. + if (dialog.isVisible() && event.getSource() == pane && + (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) && + event.getNewValue() != null && + event.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) { + dialog.setVisible(false); + } + } + }); + return dialog; + } +} +