?? install.java
字號:
/* * Oscar - An implementation of the OSGi framework. * Copyright (c) 2004, Richard S. Hall * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of the ungoverned.org nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Richard S. Hall (heavy@ungoverned.org) * Contributor(s): ***/package org.ungoverned.oscar.installer;import java.awt.*;import java.awt.event.*;import java.io.File;import java.util.*;import javax.swing.*;import javax.swing.border.BevelBorder;import org.ungoverned.oscar.installer.artifact.*;import org.ungoverned.oscar.installer.editor.*;import org.ungoverned.oscar.installer.property.*;import org.ungoverned.oscar.util.OscarConstants;public class Install extends JFrame{ private static transient final String PROPERTY_FILE = "property.xml"; private static transient final String ARTIFACT_FILE = "artifact.xml"; public static transient final String JAVA_DIR = "Java directory"; public static transient final String INSTALL_DIR = "Install directory"; private PropertyPanel m_propPanel = null; private JButton m_okayButton = null; private JButton m_cancelButton = null; private JLabel m_statusLabel = null; private java.util.List m_propList = null; private java.util.List m_artifactList = null; public Install() throws Exception { super("Install"); // Load properties before resources, because resources // refer to properties. m_propList = loadPropertyList(); m_artifactList = loadArtifactList(); getContentPane().setLayout(new BorderLayout()); getContentPane().add( m_propPanel = new PropertyPanel(m_propList), BorderLayout.CENTER); getContentPane().add(createButtonPanel(), BorderLayout.SOUTH); pack(); setResizable(true); centerWindow(this); // Make window closeable. setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { doCancel(); } }); } public java.util.List loadPropertyList() { String installDir = System.getProperty("user.home"); if (!installDir.endsWith(File.separator)) { installDir = installDir + File.separator; } Property prop = null; // Eventually these should be read from a file. java.util.List list = new ArrayList(); // Add the shell choice property. prop = new BooleanPropertyImpl("Shell", true); prop.setEditor(new BooleanEditor((BooleanProperty) prop, "Text", "GUI")); list.add(prop); // Add the java directory property. prop = new StringPropertyImpl(JAVA_DIR, System.getProperty("java.home")); prop.setEditor(new FileEditor((StringProperty) prop, true)); list.add(prop); // Add the installation directory property. prop = new StringPropertyImpl(INSTALL_DIR, installDir + "Oscar"); prop.setEditor(new FileEditor((StringProperty) prop, true)); list.add(prop); // Add the documentation URL property. prop = new BooleanStringPropertyImpl( "User documentation", true, "http://download.forge.objectweb.org/oscar/oscar-doc-" + OscarConstants.OSCAR_VERSION_VALUE + ".jar"); list.add(prop); // Add the documentation URL property. prop = new BooleanStringPropertyImpl( "API documentation", true, "http://download.forge.objectweb.org/oscar/oscar-api-" + OscarConstants.OSCAR_VERSION_VALUE + ".jar"); list.add(prop); return list; } public java.util.List loadArtifactList() throws Exception { // Eventually I will changed these to be read from a file. java.util.List list = new ArrayList(); list.add( new ArtifactHolder( (BooleanProperty) getProperty("User documentation"), new URLJarArtifact( (StringProperty) getProperty("User documentation")))); list.add( new ArtifactHolder( (BooleanProperty) getProperty("API documentation"), new URLJarArtifact( (StringProperty) getProperty("API documentation")))); list.add( new ArtifactHolder( new ResourceJarArtifact( new StringPropertyImpl("sourceName", "package.jar")))); list.add( new ArtifactHolder( new ResourceFileArtifact( new StringPropertyImpl("sourceName", "src.jar")))); list.add( new ArtifactHolder( new ResourceFileArtifact( new StringPropertyImpl("sourceName", "LICENSE.txt")))); list.add( new ArtifactHolder( (BooleanProperty) getProperty("Shell"), new ResourceFileArtifact( new StringPropertyImpl("sourceName", "system.properties.text"), new StringPropertyImpl("destName", "system.properties"), new StringPropertyImpl("destDir", "lib")))); list.add( new ArtifactHolder( new NotBooleanPropertyImpl((BooleanProperty) getProperty("Shell")), new ResourceFileArtifact( new StringPropertyImpl("sourceName", "system.properties.gui"), new StringPropertyImpl("destName", "system.properties"), new StringPropertyImpl("destDir", "lib")))); list.add( new ArtifactHolder( new ResourceFileArtifact( new StringPropertyImpl("sourceName", "example.policy")))); list.add( new ArtifactHolder( new ResourceFileArtifact( new StringPropertyImpl("sourceName", "oscar.bat"), new StringPropertyImpl("destName" , "oscar.bat"), new StringPropertyImpl("destDir", ""), true))); list.add( new ArtifactHolder( new ResourceFileArtifact( new StringPropertyImpl("sourceName", "oscar.sh"), new StringPropertyImpl("destName" , "oscar.sh"), new StringPropertyImpl("destDir", ""), true))); return list; } private Property getProperty(String name) { for (int i = 0; i < m_propList.size(); i++) { Property prop = (Property) m_propList.get(i); if (prop.getName().equals(name)) { return prop; } } return null; } protected void doOkay() { m_propPanel.setEnabled(false); m_okayButton.setEnabled(false); m_cancelButton.setEnabled(false); new Thread(new InstallRunnable()).start(); } protected void doCancel()
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -