- 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-0572b91ccdca3.0
parent
ea9ebd8a22
commit
6e04761cf3
@ -0,0 +1,8 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- You may freely edit this file. See harness/README in the NetBeans platform --> |
||||
<!-- for some information on what you could do (e.g. targets to override). --> |
||||
<!-- If you delete this file and reopen the project it will be recreated. --> |
||||
<project name="com.jme3.gde.upgrader" default="netbeans" basedir="."> |
||||
<description>Builds, tests, and runs the project com.jme3.gde.upgrader.</description> |
||||
<import file="nbproject/build-impl.xml"/> |
||||
</project> |
@ -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 |
||||
|
@ -0,0 +1,45 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
*** GENERATED FROM project.xml - DO NOT EDIT *** |
||||
*** EDIT ../build.xml INSTEAD *** |
||||
--> |
||||
<project name="com.jme3.gde.upgrader-impl" basedir=".."> |
||||
<fail message="Please build using Ant 1.7.1 or higher."> |
||||
<condition> |
||||
<not> |
||||
<antversion atleast="1.7.1"/> |
||||
</not> |
||||
</condition> |
||||
</fail> |
||||
<property file="nbproject/private/suite-private.properties"/> |
||||
<property file="nbproject/suite.properties"/> |
||||
<fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail> |
||||
<property file="${suite.dir}/nbproject/private/platform-private.properties"/> |
||||
<property file="${suite.dir}/nbproject/platform.properties"/> |
||||
<macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2"> |
||||
<attribute name="name"/> |
||||
<attribute name="value"/> |
||||
<sequential> |
||||
<property name="@{name}" value="${@{value}}"/> |
||||
</sequential> |
||||
</macrodef> |
||||
<macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2"> |
||||
<attribute name="property"/> |
||||
<attribute name="value"/> |
||||
<sequential> |
||||
<property name="@{property}" value="@{value}"/> |
||||
</sequential> |
||||
</macrodef> |
||||
<property file="${user.properties.file}"/> |
||||
<nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> |
||||
<nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> |
||||
<nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> |
||||
<fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness)."> |
||||
<condition> |
||||
<not> |
||||
<contains string="${cluster.path.evaluated}" substring="platform"/> |
||||
</not> |
||||
</condition> |
||||
</fail> |
||||
<import file="${harness.dir}/build.xml"/> |
||||
</project> |
@ -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 |
@ -0,0 +1,3 @@ |
||||
javac.source=1.6 |
||||
javac.compilerargs=-Xlint -Xlint:-serial |
||||
spec.version.base=3.0.0 |
@ -0,0 +1,47 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://www.netbeans.org/ns/project/1"> |
||||
<type>org.netbeans.modules.apisupport.project</type> |
||||
<configuration> |
||||
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3"> |
||||
<code-name-base>com.jme3.gde.upgrader</code-name-base> |
||||
<suite-component/> |
||||
<module-dependencies> |
||||
<dependency> |
||||
<code-name-base>org.openide.filesystems</code-name-base> |
||||
<build-prerequisite/> |
||||
<compile-dependency/> |
||||
<run-dependency> |
||||
<specification-version>7.19</specification-version> |
||||
</run-dependency> |
||||
</dependency> |
||||
<dependency> |
||||
<code-name-base>org.openide.modules</code-name-base> |
||||
<build-prerequisite/> |
||||
<compile-dependency/> |
||||
<run-dependency> |
||||
<specification-version>7.2</specification-version> |
||||
</run-dependency> |
||||
</dependency> |
||||
<dependency> |
||||
<code-name-base>org.openide.util</code-name-base> |
||||
<build-prerequisite/> |
||||
<compile-dependency/> |
||||
<run-dependency> |
||||
<specification-version>8.0</specification-version> |
||||
</run-dependency> |
||||
</dependency> |
||||
<dependency> |
||||
<code-name-base>org.openide.util.lookup</code-name-base> |
||||
<build-prerequisite/> |
||||
<compile-dependency/> |
||||
<run-dependency> |
||||
<specification-version>8.0</specification-version> |
||||
</run-dependency> |
||||
</dependency> |
||||
</module-dependencies> |
||||
<public-packages> |
||||
<package>org.netbeans.upgrade</package> |
||||
</public-packages> |
||||
</data> |
||||
</configuration> |
||||
</project> |
@ -0,0 +1 @@ |
||||
suite.dir=${basedir}/.. |
@ -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 |
@ -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: |
||||
* <ul> |
||||
* <li>"Drag & Drop", "Ampersand ('&')" - don't have mnemonic ampersand. |
||||
* "&" is not found before " " (space), or if enclosed in "'" |
||||
* (single quotation marks). |
||||
* <li>"&File", "Save &As..." - do have mnemonic ampersand. |
||||
* <li>"Rock & Ro&ll", "Underline the '&' &character" - also do have |
||||
* mnemonic ampersand, but the second one. |
||||
* </ul> |
||||
* @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; |
||||
} |
||||
} |
@ -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 |
@ -0,0 +1,87 @@ |
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> |
||||
<Properties> |
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> |
||||
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> |
||||
<EmptyBorder bottom="0" left="12" right="11" top="12"/> |
||||
</Border> |
||||
</Property> |
||||
</Properties> |
||||
<AuxValues> |
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> |
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> |
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> |
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> |
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> |
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> |
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> |
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> |
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,27,0,0,2,124"/> |
||||
</AuxValues> |
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> |
||||
<Property name="axis" type="int" value="1"/> |
||||
</Layout> |
||||
<SubComponents> |
||||
<Component class="javax.swing.JTextArea" name="jTextAreaTop"> |
||||
<Properties> |
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> |
||||
<Connection component="Form" name="background" type="property"/> |
||||
</Property> |
||||
<Property name="columns" type="int" value="20"/> |
||||
<Property name="editable" type="boolean" value="false"/> |
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> |
||||
<Font name="Dialog" size="12" style="1"/> |
||||
</Property> |
||||
<Property name="lineWrap" type="boolean" value="true"/> |
||||
<Property name="rows" type="int" value="1"/> |
||||
<Property name="text" preCode="jTextAreaTop.setText(bundle.getString("MSG_LicenseDlgLabelTop"));"/> |
||||
<Property name="wrapStyleWord" type="boolean" value="true"/> |
||||
<Property name="focusable" type="boolean" value="false"/> |
||||
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> |
||||
<Insets value="[0, 0, 2, 0]"/> |
||||
</Property> |
||||
<Property name="requestFocusEnabled" type="boolean" value="false"/> |
||||
</Properties> |
||||
</Component> |
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1"> |
||||
<AuxValues> |
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> |
||||
</AuxValues> |
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> |
||||
<SubComponents> |
||||
<Component class="javax.swing.JEditorPane" name="jEditorPane1"> |
||||
<Properties> |
||||
<Property name="editable" type="boolean" value="false"/> |
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> |
||||
<Dimension value="[500, 500]"/> |
||||
</Property> |
||||
</Properties> |
||||
<AuxValues> |
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/> |
||||
</AuxValues> |
||||
</Component> |
||||
</SubComponents> |
||||
</Container> |
||||
<Component class="javax.swing.JTextArea" name="jTextAreaBottom"> |
||||
<Properties> |
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> |
||||
<Connection component="Form" name="background" type="property"/> |
||||
</Property> |
||||
<Property name="columns" type="int" value="20"/> |
||||
<Property name="editable" type="boolean" value="false"/> |
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> |
||||
<Font name="Dialog" size="12" style="1"/> |
||||
</Property> |
||||
<Property name="lineWrap" type="boolean" value="true"/> |
||||
<Property name="rows" type="int" value="2"/> |
||||
<Property name="text" preCode="jTextAreaBottom.setText(bundle.getString("MSG_LicenseDlgLabelBottom"));"/> |
||||
<Property name="wrapStyleWord" type="boolean" value="true"/> |
||||
<Property name="focusable" type="boolean" value="false"/> |
||||
<Property name="requestFocusEnabled" type="boolean" value="false"/> |
||||
</Properties> |
||||
</Component> |
||||
</SubComponents> |
||||
</Form> |
@ -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. |
||||
*/ |
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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); |
||||
}// </editor-fold>//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); |
||||
} |
||||
} |
||||
} |
@ -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<String> 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<String> NEWER_VERSION_TO_CHECK = |
||||
Arrays.asList ("3.0RC2", "3.0Beta"/*7.2, ..."*/); //NOI18N
|
||||
|
||||
|
||||
private static File checkPreviousOnOsSpecificPlace (final List<String> 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<String> versionsToCheck) { |
||||
String userHome = System.getProperty ("user.home"); // NOI18N
|
||||
File sourceFolder = null; |
||||
|
||||
if (userHome != null) { |
||||
File userHomeFile = new File (userHome); |
||||
Iterator<String> 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); |
||||
} |
||||
} |
@ -0,0 +1,53 @@ |
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> |
||||
<Properties> |
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> |
||||
<Connection code="new java.awt.Dimension(550, source != null && ! note.isEmpty() ? 120 : 60)" type="code"/> |
||||
</Property> |
||||
</Properties> |
||||
<AuxValues> |
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> |
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> |
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> |
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> |
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> |
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> |
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> |
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> |
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> |
||||
</AuxValues> |
||||
|
||||
<Layout> |
||||
<DimensionLayout dim="0"> |
||||
<Group type="103" groupAlignment="0" attributes="0"> |
||||
<Component id="txtVersions" alignment="0" pref="583" max="32767" attributes="0"/> |
||||
</Group> |
||||
</DimensionLayout> |
||||
<DimensionLayout dim="1"> |
||||
<Group type="103" groupAlignment="0" attributes="0"> |
||||
<Component id="txtVersions" alignment="0" pref="60" max="32767" attributes="0"/> |
||||
</Group> |
||||
</DimensionLayout> |
||||
</Layout> |
||||
<SubComponents> |
||||
<Component class="javax.swing.JTextArea" name="txtVersions"> |
||||
<Properties> |
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> |
||||
<Connection component="Form" name="background" type="property"/> |
||||
</Property> |
||||
<Property name="columns" type="int" value="50"/> |
||||
<Property name="editable" type="boolean" value="false"/> |
||||
<Property name="font" postCode="txtVersions.setFont(new java.awt.Font("Dialog", 0, 12));"/> |
||||
<Property name="lineWrap" type="boolean" value="true"/> |
||||
<Property name="rows" type="int" editor="org.netbeans.modules.form.RADConnectionPropertyEditor" postCode="if (source != null) {"> |
||||
<Connection code="source != null && ! note.isEmpty() ? 6 : 3" type="code"/> |
||||
</Property> |
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor" postCode="} else {
txtVersions.setText(note);
}"> |
||||
<ResourceString bundle="org/netbeans/upgrade/Bundle.properties" key="MSG_Confirmation" replaceFormat="NbBundle.getMessage (AutoUpgradePanel.class, "{key}", source, note)"/> |
||||
</Property> |
||||
<Property name="wrapStyleWord" type="boolean" value="true"/> |
||||
</Properties> |
||||
</Component> |
||||
</SubComponents> |
||||
</Form> |
@ -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. |
||||
*/ |
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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) |
||||
); |
||||
}// </editor-fold>//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<ChangeListener> changeListeners = new ArrayList<ChangeListener>(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-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 |
@ -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<String, SimpleAttributeSet> colorings = new HashMap<String, SimpleAttributeSet> (); |
||||
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; |
||||
} |
||||
} |
@ -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(); |
||||
} |
||||
} |
||||
} |
@ -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<String> includePatterns = new HashSet<String>(); |
||||
private Set<String> excludePatterns = new HashSet<String>(); |
||||
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<String> includeKeys = new HashSet<String>(); |
||||
Set<String> excludeKeys = new HashSet<String>(); |
||||
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<String> matchingKeys(String relativePath, String propertiesPattern) throws IOException { |
||||
Set<String> matchingKeys = new HashSet<String>(); |
||||
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<String> parsePattern(String pattern) { |
||||
Set<String> patterns = new HashSet<String>(); |
||||
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; |
||||
} |
||||
} |
@ -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<Boolean and Pattern> |
||||
*/ |
||||
private List<Union2<Boolean, Pattern>> patterns = new ArrayList<Union2<Boolean, Pattern>> (); |
||||
|
||||
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.<Boolean,Pattern>createFirst(plus)); |
||||
set.patterns.add (Union2.<Boolean,Pattern>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<Union2<Boolean,Pattern>> 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; |
||||
} |
||||
|
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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<Color,String> colorToName = new HashMap<Color,String> (); |
||||
private static final Map<String, Color> nameToColor = new HashMap<String, Color> (); |
||||
private static final Map<String, Integer> nameToFontStyle = new HashMap<String, Integer> (); |
||||
private static final Map<Integer, String> fontStyleToName = new HashMap<Integer, String> (); |
||||
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 ("<?xml version=\"1.0\"?>\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 ("</").append (name).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<String> names = new ArrayList<String> (); |
||||
private List<String> values = new ArrayList<String> (); |
||||
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 (); |
||||
} |
||||
} |
||||
} |
@ -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 |
@ -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 |
@ -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 |
@ -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/.* |
@ -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/.* |
@ -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 |
@ -0,0 +1,65 @@ |
||||
<?xml version="1.0"?> |
||||
<!-- |
||||
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. |
||||
--> |
||||
|
||||
<!-- |
||||
|
||||
Here you can register fileobjects, which do not exist on the local filesystem but |
||||
whose attribute settings are stored there. This may occur for example when attributes |
||||
of a fileobject which exists on the XML filesystem, are changed. Since the XML filesystem |
||||
is read-only, new attribute settings are stored on the local filesystem. During upgrading, |
||||
which is done from the local filesystem such a fileobject does not exist and |
||||
thus its attribute settings are not imported. |
||||
|
||||
--> |
||||
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.0//EN" "http://www.netbeans.org/dtds/filesystem-1_0.dtd"> |
||||
|
||||
<filesystem> |
||||
<folder name="J2EE"> |
||||
<folder name="InstalledServers"> |
||||
<file name="Tomcat_instance"/> |
||||
</folder> |
||||
</folder> |
||||
</filesystem> |
@ -0,0 +1,65 @@ |
||||
<?xml version="1.0"?> |
||||
<!-- |
||||
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. |
||||
--> |
||||
|
||||
<!-- |
||||
|
||||
Here you can register fileobjects, which do not exist on the local filesystem but |
||||
whose attribute settings are stored there. This may occur for example when attributes |
||||
of a fileobject which exists on the XML filesystem, are changed. Since the XML filesystem |
||||
is read-only, new attribute settings are stored on the local filesystem. During upgrading, |
||||
which is done from the local filesystem such a fileobject does not exist and |
||||
thus its attribute settings are not imported. |
||||
|
||||
--> |
||||
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.0//EN" "http://www.netbeans.org/dtds/filesystem-1_0.dtd"> |
||||
|
||||
<filesystem> |
||||
<folder name="J2EE"> |
||||
<folder name="InstalledServers"> |
||||
<file name="Tomcat_instance"/> |
||||
</folder> |
||||
</folder> |
||||
</filesystem> |
@ -0,0 +1,65 @@ |
||||
<?xml version="1.0"?> |
||||
<!-- |
||||
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. |
||||
--> |
||||
|
||||
<!-- |
||||
|
||||
Here you can register fileobjects, which do not exist on the local filesystem but |
||||
whose attribute settings are stored there. This may occur for example when attributes |
||||
of a fileobject which exists on the XML filesystem, are changed. Since the XML filesystem |
||||
is read-only, new attribute settings are stored on the local filesystem. During upgrading, |
||||
which is done from the local filesystem such a fileobject does not exist and |
||||
thus its attribute settings are not imported. |
||||
|
||||
--> |
||||
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.0//EN" "http://www.netbeans.org/dtds/filesystem-1_0.dtd"> |
||||
|
||||
<filesystem> |
||||
<folder name="J2EE"> |
||||
<folder name="InstalledServers"> |
||||
<file name="Tomcat_instance"/> |
||||
</folder> |
||||
</folder> |
||||
</filesystem> |
@ -0,0 +1,65 @@ |
||||
<?xml version="1.0"?> |
||||
<!-- |
||||
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. |
||||
--> |
||||
|
||||
<!-- |
||||
|
||||
Here you can register fileobjects, which do not exist on the local filesystem but |
||||
whose attribute settings are stored there. This may occur for example when attributes |
||||
of a fileobject which exists on the XML filesystem, are changed. Since the XML filesystem |
||||
is read-only, new attribute settings are stored on the local filesystem. During upgrading, |
||||
which is done from the local filesystem such a fileobject does not exist and |
||||
thus its attribute settings are not imported. |
||||
|
||||
--> |
||||
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.0//EN" "http://www.netbeans.org/dtds/filesystem-1_0.dtd"> |
||||
|
||||
<filesystem> |
||||
<folder name="J2EE"> |
||||
<folder name="InstalledServers"> |
||||
<file name="Tomcat_instance"/> |
||||
</folder> |
||||
</folder> |
||||
</filesystem> |
@ -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 |
@ -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 |
@ -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/.* |
@ -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/.* |
@ -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 |
@ -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(); |
||||
} |
||||
} |
||||
} |
@ -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<String, ContentProcessor> clsname2Delegate = new HashMap<String, ContentProcessor>(); |
||||
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<Object> it, boolean types) { |
||||
Map<String, String> m; |
||||
Result result = null; |
||||
try { |
||||
Map<String, Object> 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<Object> it) { |
||||
ContentProcessor cp = clsname2Delegate.get(systemOptionInstanceName); |
||||
if (cp == null) { |
||||
cp = new ContentProcessor(systemOptionInstanceName); |
||||
} |
||||
return cp.parseContent(it, types); |
||||
} |
||||
|
||||
private final Map<String, String> processProperties(final Map<String, Object> properties, boolean types) { |
||||
Map<String, String> allProps = new HashMap<String, String>(); |
||||
for (Iterator<Map.Entry<String, Object>> it = properties.entrySet().iterator(); it.hasNext();) { |
||||
Map.Entry<String, Object> entry = it.next(); |
||||
String name = entry.getKey(); |
||||
Object value = entry.getValue(); |
||||
allProps.putAll(PropertyProcessor.processProperty(name, value, types)); |
||||
} |
||||
return allProps; |
||||
} |
||||
|
||||
private final Map<String, Object> parseProperties(final Iterator<Object> it) { // sequences String, Object, SerParser.ObjectWrapper
|
||||
Map<String, Object> properties = new HashMap<String, Object>(); |
||||
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
|
||||
} |
||||
} |
@ -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(); |
||||
} |
||||
} |
||||
} |
@ -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<String, String> m; |
||||
private String instanceName; |
||||
private String moduleName; |
||||
DefaultResult(String instanceName, Map<String, String> 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; |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
||||
|
||||
} |
@ -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(); |
||||
} |
||||
} |
||||
} |
@ -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()); |
||||
} |
||||
} |
||||
} |
@ -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(); |
||||
} |
||||
} |
||||
} |
@ -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(); |
||||
} |
||||
} |
||||
} |
@ -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<FileObject> files = getImportFiles(loadImportFilesDefinition()); |
||||
for (Iterator<DefaultResult> 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<DefaultResult> parse(final Set<FileObject> files) { |
||||
Set<DefaultResult> retval = new HashSet<DefaultResult>(); |
||||
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<FileObject> getImportFiles(final Properties props) { |
||||
Set<FileObject> fileobjects = new HashSet<FileObject>(); |
||||
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() {} |
||||
} |
@ -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
|
||||
} |
||||
} |
@ -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<Object> it, boolean types) { |
||||
Map<String, String> properties = new HashMap<String, String>(); |
||||
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); |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -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
|
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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<String, String> results; |
||||
private static Map<String, PropertyProcessor> clsname2Delegate = new HashMap<String, PropertyProcessor>(); |
||||
|
||||
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<String, String> processProperty(String propertyName, Object value, boolean types) { |
||||
results = new HashMap<String, String>(); |
||||
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); |
||||
} |
||||
} |
@ -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(); |
||||
} |
@ -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<Object> refs = new ArrayList<Object>(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<Object>(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<Object> 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<Object> data; // <Union2<NameValue,Object>>
|
||||
public String toString() { |
||||
return "Object[class=" + classdesc.name + ",data=<omitted>]"; // 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<FieldDesc> fields; |
||||
public List annotation; // List<Object>
|
||||
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<Object> (10); |
||||
LinkedList<ClassDesc> hier = new LinkedList<ClassDesc>(); |
||||
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<FieldDesc>(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<Object> readContents() throws IOException { |
||||
List<Object> l = new ArrayList<Object>(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<Object> 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<Object>(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<NameValue> readNoWrClass(ClassDesc cd) throws IOException { |
||||
List<FieldDesc> fields = cd.fields; |
||||
List<NameValue> values = new ArrayList<NameValue>(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; |
||||
} |
||||
|
||||
} |
@ -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<String> stack; |
||||
|
||||
private String version; |
||||
private String instanceClass; |
||||
private String instanceMethod; |
||||
private Set<String> instanceOf = new HashSet<String>(); |
||||
|
||||
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<String> 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<String>(); |
||||
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<String>(); |
||||
|
||||
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 = "<?xml version=\"1.0\"?> <!DOCTYPE settings PUBLIC \"-//NetBeans//DTD Session settings 1.0//EN\" \"http://www.netbeans.org/dtds/sessionsettings-1_0.dtd\"> <settings version=\"".getBytes(); // NOI18N
|
||||
private static final byte[] MODULE_SETTINGS_INTRO_END = "> <".getBytes(); // NOI18N
|
||||
private static final byte[] MODULE_SETTINGS_MODULE_NAME = "odule name=\"".getBytes(); // NOI18N
|
||||
private static final byte[] MODULE_SETTINGS_MODULE_SPEC = "spec=\"".getBytes(); // NOI18N
|
||||
private static final byte[] MODULE_SETTINGS_MODULE_IMPL = "impl=\"".getBytes(); // NOI18N
|
||||
private static final byte[] MODULE_SETTINGS_TAG_END = "> <".getBytes(); // NOI18N
|
||||
private static final byte[] MODULE_SETTINGS_INSTANCE = "nstance".getBytes(); // NOI18N
|
||||
private static final byte[] MODULE_SETTINGS_INSTANCE_CLZ = "class=\"".getBytes(); // NOI18N
|
||||
private static final byte[] MODULE_SETTINGS_INSTANCE_MTD = "method=\"".getBytes(); // NOI18N
|
||||
private static final byte[] MODULE_SETTINGS_OF = "f class=\"".getBytes(); // NOI18N
|
||||
private static final byte[] MODULE_SETTINGS_SERIAL = "erialdata class=\"".getBytes(); // NOI18N
|
||||
private static final byte[] MODULE_SETTINGS_END = "settings>".getBytes(); // NOI18N
|
||||
|
||||
/** Attempts to read the stream in the same way as SAX parser but avoids using it. |
||||
* If it does not manage to parse it this way, it returns null, in which case |
||||
* you have to use a real parser. |
||||
* @see "#36718" |
||||
*/ |
||||
private Set<String> quickParse(InputStream is) throws IOException { |
||||
Set<String> iofs = new HashSet<String>(); // <String>
|
||||
|
||||
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': |
||||
// <module />
|
||||
if (!expect(is, MODULE_SETTINGS_MODULE_NAME)) { |
||||
err.log("Could not read up to <module name=\" "+source); // NOI18N
|
||||
return null; |
||||
} |
||||
String codeName = readTo(is, '"'); |
||||
if (codeName == null) { |
||||
err.log("Could not read module name value "+source); // NOI18N
|
||||
return null; |
||||
} |
||||
codeName = codeName.intern(); |
||||
resolveModuleElm(codeName); |
||||
c = is.read(); |
||||
if (c == '/') { |
||||
if (!expect(is, MODULE_SETTINGS_TAG_END)) { |
||||
err.log("Could not read up to end of module tag "+source); // NOI18N
|
||||
return null; |
||||
} |
||||
break; |
||||
} else if (c != ' ') { |
||||
err.log("Could not space after module name "+source); // NOI18N
|
||||
return null; |
||||
} |
||||
// <module spec/>
|
||||
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 <module name spec/> tag "+source); // NOI18N
|
||||
return null; |
||||
} |
||||
break; |
||||
} else if (c != ' ') { |
||||
err.log("Could not read space after module name "+source); // NOI18N
|
||||
return null; |
||||
} |
||||
// <module impl/>
|
||||
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': |
||||
// <instanceof> or <instance>
|
||||
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 <instanceof> " + iof+" "+source); // NOI18N
|
||||
return null; |
||||
} |
||||
if (!expect(is, MODULE_SETTINGS_TAG_END)) { |
||||
err.log("Could not read up to next tag after <instanceof> " + 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; |
||||
} |
||||
// <instance method/>
|
||||
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': |
||||
// <serialdata class
|
||||
if (!expect(is, MODULE_SETTINGS_SERIAL)) { |
||||
err.log("Could not read up to <serialdata class=\" "+source); // NOI18N
|
||||
return null; |
||||
} |
||||
instanceClass = readTo(is, '"'); |
||||
if (instanceClass == null) { |
||||
err.log("Could not read serialdata class value "+source); // NOI18N
|
||||
return null; |
||||
} |
||||
instanceClass = org.openide.util.Utilities.translate(instanceClass).intern(); |
||||
// here we are complete for header, otherwise we would need to go through serialdata stream
|
||||
c = is.read(); |
||||
if (c != '>') { |
||||
err.log("Could not read up to end of serialdata tag "+source); // NOI18N
|
||||
return null; |
||||
} |
||||
break PARSE; |
||||
case '/': |
||||
// </settings
|
||||
// XXX do not read further is neader is set
|
||||
if (!expect(is, MODULE_SETTINGS_END)) { |
||||
err.log("Could not read up to end of settings tag "+source); // NOI18N
|
||||
return null; |
||||
} |
||||
break PARSE; |
||||
default: |
||||
err.log("Strange stuff after <" + (char)c+" "+source); // NOI18N
|
||||
return null; |
||||
} |
||||
} |
||||
if (instanceClass != null && !iofs.isEmpty()) { |
||||
return iofs; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** Read some stuff from a stream and skip over it. |
||||
* Newlines conventions and whitespaces are normalized to one space. |
||||
* @return true upon success, false if stream contained something else |
||||
*/ |
||||
private boolean expect(InputStream is, byte[] stuff) throws IOException { |
||||
int len = stuff.length; |
||||
boolean inWhitespace = false; |
||||
for (int i = 0; i < len; ) { |
||||
int c = is.read(); |
||||
if (c == 10 || c == 13 || c == ' ' || c == '\t') { |
||||
// Normalize: s/[\t \r\n]+/\n/g
|
||||
if (inWhitespace) { |
||||
continue; |
||||
} else { |
||||
inWhitespace = true; |
||||
c = ' '; |
||||
} |
||||
} else { |
||||
inWhitespace = false; |
||||
} |
||||
if (c != stuff[i++]) { |
||||
return false; |
||||
} |
||||
} |
||||
if (stuff[len - 1] == 10) { |
||||
// Expecting something ending in a \n - so we have to
|
||||
// read any further \r or \n and discard.
|
||||
if (!is.markSupported()) throw new IOException("Mark not supported"); // NOI18N
|
||||
is.mark(1); |
||||
int c = is.read(); |
||||
if (c != -1 && c != 10 && c != 13) { |
||||
// Got some non-newline character, push it back!
|
||||
is.reset(); |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
/** Read a maximal string until delim is encountered (which will be removed from stream). |
||||
* This impl reads only ASCII, for speed. |
||||
* Newline conventions are normalized to Unix \n. |
||||
* @return the read string, or null if the delim is not encountered before EOF. |
||||
*/ |
||||
private String readTo(InputStream is, char delim) throws IOException { |
||||
if (delim == 10) { |
||||
// Not implemented - stream might have "foo\r\n" and we would
|
||||
// return "foo" and leave "\n" in the stream.
|
||||
throw new IOException("Not implemented"); // NOI18N
|
||||
} |
||||
CharArrayWriter caw = new CharArrayWriter(100); |
||||
boolean inNewline = false; |
||||
while (true) { |
||||
int c = is.read(); |
||||
if (c == -1) return null; |
||||
if (c > 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
|
||||
} |
||||
} |
||||
|
||||
} |
@ -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()); |
||||
} |
||||
} |
||||
} |
@ -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<Object> 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; |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
@ -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
|
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -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); |
||||
|
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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 |
@ -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<Image> images = new ArrayList<Image>(); |
||||
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; |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue