[izpack-changes] r1908 - in izpack-src/trunk/src: . lib/com/izforge/izpack/compiler lib/com/izforge/izpack/installer lib/com/izforge/izpack/panels
noreply at berlios.de
noreply at berlios.de
Tue Nov 20 09:02:31 CET 2007
Author: dreil
Date: 2007-11-20 09:02:22 +0100 (Tue, 20 Nov 2007)
New Revision: 1908
Added:
izpack-src/trunk/src/lib/com/izforge/izpack/panels/InstallationTypePanel.java
Modified:
izpack-src/trunk/src/build.xml
izpack-src/trunk/src/lib/com/izforge/izpack/compiler/MultiVolumePackager.java
izpack-src/trunk/src/lib/com/izforge/izpack/installer/AutomatedInstallData.java
izpack-src/trunk/src/lib/com/izforge/izpack/installer/MultiVolumeUnpacker.java
izpack-src/trunk/src/lib/com/izforge/izpack/installer/Unpacker.java
izpack-src/trunk/src/lib/com/izforge/izpack/installer/UnpackerBase.java
izpack-src/trunk/src/lib/com/izforge/izpack/panels/PacksModel.java
izpack-src/trunk/src/lib/com/izforge/izpack/panels/PacksPanelBase.java
izpack-src/trunk/src/lib/com/izforge/izpack/panels/TargetPanel.java
Log:
added modify installation mode.
Modified: izpack-src/trunk/src/build.xml
===================================================================
--- izpack-src/trunk/src/build.xml 2007-11-16 14:20:55 UTC (rev 1907)
+++ izpack-src/trunk/src/build.xml 2007-11-20 08:02:22 UTC (rev 1908)
@@ -680,6 +680,9 @@
<include name="com/izforge/izpack/panels/PacksPanelBase.java" />
<include name="com/izforge/izpack/panels/PacksPanelInterface.java" />
</build-panel>
+ <build-panel name="InstallationTypePanel">
+ <include name="com/izforge/izpack/panels/InstallationTypePanel.java"/>
+ </build-panel>
</target>
<!--
@@ -914,7 +917,7 @@
</copy>
</target>
- <target name="build.docu" description="Builds the customer documentation">
+ <target name="build.docu" description="Builds the customer documentation">
<exec executable="python" dir="${basedir}/src/doc-reST">
<arg value="build.py"/>
</exec>
@@ -929,7 +932,7 @@
<fileset dir="${basedir}/src/doc-reST/pdf">
<include name="manual.pdf" />
</fileset>
- </copy>
+ </copy>
</target>
<target name="create.docu"
Modified: izpack-src/trunk/src/lib/com/izforge/izpack/compiler/MultiVolumePackager.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/compiler/MultiVolumePackager.java 2007-11-16 14:20:55 UTC (rev 1907)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/compiler/MultiVolumePackager.java 2007-11-20 08:02:22 UTC (rev 1908)
@@ -33,27 +33,17 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
import java.util.zip.Deflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
-import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import net.n3.nanoxml.XMLElement;
-import com.izforge.izpack.CustomData;
-import com.izforge.izpack.GUIPrefs;
-import com.izforge.izpack.Info;
import com.izforge.izpack.Pack;
import com.izforge.izpack.PackFile;
-import com.izforge.izpack.Panel;
import com.izforge.izpack.XPackFile;
-import com.izforge.izpack.compressor.PackCompressor;
-import com.izforge.izpack.compressor.PackCompressorFactory;
-import com.izforge.izpack.io.FileSpanningInputStream;
import com.izforge.izpack.io.FileSpanningOutputStream;
import com.izforge.izpack.util.Debug;
import com.izforge.izpack.util.FileUtil;
@@ -178,7 +168,8 @@
{
String classname = this.getClass().getName();
String sizeprop = classname + ".volumesize";
- String freespaceprop = classname + ".firstvolumefreespace";
+ String freespaceprop = classname + ".firstvolumefreespace";
+
if (this.configdata == null){
// no configdata given, set default values
this.variables.setProperty(sizeprop, Long.toString(FileSpanningOutputStream.DEFAULT_VOLUME_SIZE));
@@ -371,10 +362,6 @@
Debug.trace("Writing Pack " + packNumber + ": " + pack.name);
ZipEntry entry = new ZipEntry("packs/pack" + packNumber);
// write the metadata as uncompressed object stream to primaryJarStream
- // ByteCountingOutputStream dos = new
- // ByteCountingOutputStream(comprStream);
- // ByteCountingOutputStream dos = new
- // ByteCountingOutputStream(primaryJarStream);
// first write a packs entry
primaryJarStream.putNextEntry(entry);
Modified: izpack-src/trunk/src/lib/com/izforge/izpack/installer/AutomatedInstallData.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/installer/AutomatedInstallData.java 2007-11-16 14:20:55 UTC (rev 1907)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/installer/AutomatedInstallData.java 2007-11-20 08:02:22 UTC (rev 1908)
@@ -42,7 +42,9 @@
{
// --- Static members -------------------------------------------------
-
+ public static final String MODIFY_INSTALLATION = "modify.izpack.install";
+ public static final String INSTALLATION_INFORMATION = ".installationinformation";
+
/**
* Names of the custom actions types with which they are stored in the installer jar file. These
* names are also used to identify the type of custom action in the customData map. Slashes as
Modified: izpack-src/trunk/src/lib/com/izforge/izpack/installer/MultiVolumeUnpacker.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/installer/MultiVolumeUnpacker.java 2007-11-16 14:20:55 UTC (rev 1907)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/installer/MultiVolumeUnpacker.java 2007-11-20 08:02:22 UTC (rev 1908)
@@ -56,7 +56,7 @@
/**
* Unpacker class for a multi volume installation.
*
- * @author Dennis Reil
+ * @author Dennis Reil, <izpack at reil-online.de>
*/
public class MultiVolumeUnpacker extends UnpackerBase
{
@@ -568,6 +568,10 @@
{ // Interrupt was initiated; perform it.
return;
}
+
+ // write installation information
+ writeInstallationInformation();
+
this.writeConfigInformation();
// The end :-)
handler.stopAction();
Modified: izpack-src/trunk/src/lib/com/izforge/izpack/installer/Unpacker.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/installer/Unpacker.java 2007-11-16 14:20:55 UTC (rev 1907)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/installer/Unpacker.java 2007-11-20 08:02:22 UTC (rev 1908)
@@ -451,6 +451,9 @@
return;
}
+ // write installation information
+ writeInstallationInformation();
+
// The end :-)
handler.stopAction();
}
Modified: izpack-src/trunk/src/lib/com/izforge/izpack/installer/UnpackerBase.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/installer/UnpackerBase.java 2007-11-16 14:20:55 UTC (rev 1907)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/installer/UnpackerBase.java 2007-11-20 08:02:22 UTC (rev 1908)
@@ -22,9 +22,12 @@
import java.io.BufferedOutputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -47,6 +50,7 @@
import com.izforge.izpack.event.InstallerListener;
import com.izforge.izpack.rules.RulesEngine;
import com.izforge.izpack.util.AbstractUIProgressHandler;
+import com.izforge.izpack.util.Debug;
import com.izforge.izpack.util.IoHelper;
import com.izforge.izpack.util.VariableSubstitutor;
@@ -803,7 +807,57 @@
}
}
-
}
+
+ /**
+ * Writes information about the installed packs and the variables at
+ * installation time.
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ public void writeInstallationInformation() throws IOException, ClassNotFoundException {
+ Debug.trace("writing installation information");
+ String installdir = idata.getInstallPath();
+
+ List installedpacks = new ArrayList(idata.selectedPacks);
+
+ File installationinfo = new File(installdir + File.separator + AutomatedInstallData.INSTALLATION_INFORMATION);
+ if (!installationinfo.exists()) {
+ Debug.trace("creating info file" + installationinfo.getAbsolutePath());
+ installationinfo.createNewFile();
+ }
+ else {
+ Debug.trace("installation information found");
+ // read in old information and update
+ FileInputStream fin = new FileInputStream(installationinfo);
+ ObjectInputStream oin = new ObjectInputStream(fin);
+
+ List packs = (List) oin.readObject();
+ for (Iterator iterator = packs.iterator(); iterator.hasNext();)
+ {
+ Pack pack = (Pack) iterator.next();
+ installedpacks.add(pack);
+ }
+ oin.close();
+ fin.close();
+
+ }
+
+ FileOutputStream fout = new FileOutputStream(installationinfo);
+ ObjectOutputStream oout = new ObjectOutputStream(fout);
+ oout.writeObject(installedpacks);
+ /*
+ int selectedpackscount = idata.selectedPacks.size();
+ for (int i = 0; i < selectedpackscount; i++)
+ {
+ Pack pack = (Pack) idata.selectedPacks.get(i);
+ oout.writeObject(pack);
+ }
+ */
+ oout.writeObject(idata.variables);
+ Debug.trace("done.");
+ oout.close();
+ fout.close();
+ }
}
Added: izpack-src/trunk/src/lib/com/izforge/izpack/panels/InstallationTypePanel.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/panels/InstallationTypePanel.java 2007-11-16 14:20:55 UTC (rev 1907)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/panels/InstallationTypePanel.java 2007-11-20 08:02:22 UTC (rev 1908)
@@ -0,0 +1,83 @@
+/**
+ *
+ */
+package com.izforge.izpack.panels;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.ButtonGroup;
+import javax.swing.JRadioButton;
+
+import com.izforge.izpack.gui.IzPanelLayout;
+import com.izforge.izpack.gui.LabelFactory;
+import com.izforge.izpack.installer.InstallData;
+import com.izforge.izpack.installer.InstallerFrame;
+import com.izforge.izpack.installer.IzPanel;
+
+
+/**
+ * @author Dennis Reil, <Dennis.Reil at reddot.de>
+ * @version $Id: $
+ */
+public class InstallationTypePanel extends IzPanel implements ActionListener
+{
+ private JRadioButton normalinstall;
+ private JRadioButton modifyinstall;
+
+ public InstallationTypePanel(InstallerFrame parent, InstallData idata)
+ {
+ super(parent, idata, new IzPanelLayout());
+
+ }
+
+ private void buildGUI() {
+ // We put our components
+
+ add(LabelFactory.create(parent.langpack.getString("InstallationTypePanel.info"),
+ parent.icons.getImageIcon("history"), LEADING), NEXT_LINE);
+
+
+ ButtonGroup group = new ButtonGroup();
+
+ boolean modifyinstallation = Boolean.valueOf(idata.getVariable(InstallData.MODIFY_INSTALLATION)).booleanValue();
+
+ normalinstall = new JRadioButton(parent.langpack.getString("InstallationTypePanel.normal"), !modifyinstallation);
+ normalinstall.addActionListener(this);
+ group.add(normalinstall);
+ add(normalinstall, NEXT_LINE);
+
+ modifyinstall = new JRadioButton(parent.langpack.getString("InstallationTypePanel.modify"), modifyinstallation);
+ modifyinstall.addActionListener(this);
+ group.add(modifyinstall);
+ add(modifyinstall, NEXT_LINE);
+
+ setInitialFocus(normalinstall);
+ getLayoutHelper().completeLayout();
+ }
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -8178770882900584122L;
+
+ /* (non-Javadoc)
+ * @see com.izforge.izpack.installer.IzPanel#panelActivate()
+ */
+ public void panelActivate()
+ {
+ buildGUI();
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (normalinstall.isSelected()) {
+ idata.setVariable(InstallData.MODIFY_INSTALLATION, "false");
+ }
+ else {
+ idata.setVariable(InstallData.MODIFY_INSTALLATION, "true");
+ }
+
+ }
+}
+
Modified: izpack-src/trunk/src/lib/com/izforge/izpack/panels/PacksModel.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/panels/PacksModel.java 2007-11-16 14:20:55 UTC (rev 1907)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/panels/PacksModel.java 2007-11-20 08:02:22 UTC (rev 1908)
@@ -24,7 +24,14 @@
package com.izforge.izpack.panels;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -33,6 +40,7 @@
import com.izforge.izpack.LocaleDatabase;
import com.izforge.izpack.Pack;
+import com.izforge.izpack.installer.AutomatedInstallData;
import com.izforge.izpack.installer.InstallData;
import com.izforge.izpack.rules.RulesEngine;
import com.izforge.izpack.util.Debug;
@@ -53,6 +61,10 @@
private List packs;
private List packsToInstall;
+
+ private Map installedpacks;
+ private boolean modifyinstallation;
+
private PacksPanelInterface panel;
@@ -74,17 +86,55 @@
private Properties variables;
public PacksModel(PacksPanelInterface panel, InstallData idata, RulesEngine rules)
- {
- this(idata.availablePacks, idata.selectedPacks, panel, rules, idata.getVariables());
- }
-
- public PacksModel(List packs, List packsToInstall, PacksPanelInterface panel, RulesEngine rules, Properties variables)
- {
+ {
+ modifyinstallation = Boolean.valueOf(idata.getVariable(InstallData.MODIFY_INSTALLATION)).booleanValue();
+ this.installedpacks = new HashMap();
+
+ if (modifyinstallation) {
+ // installation shall be modified
+ // load installation information
+
+ try
+ {
+ FileInputStream fin = new FileInputStream(new File(idata.getInstallPath() + File.separator + AutomatedInstallData.INSTALLATION_INFORMATION));
+ ObjectInputStream oin = new ObjectInputStream(fin);
+ List packsinstalled = (List) oin.readObject();
+ for (int i = 0; i < packsinstalled.size(); i++)
+ {
+ Pack installedpack = (Pack) packsinstalled.get(i);
+ if ((installedpack.id != null) && (installedpack.id.length() > 0)) {
+ this.installedpacks.put(installedpack.id, installedpack);
+ }
+ else {
+ this.installedpacks.put(installedpack.name, installedpack);
+ }
+ }
+ this.removeAlreadyInstalledPacks(idata.selectedPacks);
+ Properties variables = (Properties) oin.readObject();
+ Debug.trace("Found " + packsinstalled.size() + " installed packs");
+ fin.close();
+ }
+ catch (FileNotFoundException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ catch (IOException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ catch (ClassNotFoundException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
this.rules = rules;
- this.packs = packs;
- this.packsToInstall = packsToInstall;
+ this.packs = idata.availablePacks;
+ this.packsToInstall = idata.selectedPacks;
this.panel = panel;
- this.variables = variables;
+ this.variables = idata.getVariables();
this.variables.setProperty(INITAL_PACKSELECTION,Boolean.toString(true));
langpack = panel.getLangpack();
checkValues = new int[packs.size()];
@@ -93,6 +143,31 @@
this.updateConditions(true);
refreshPacksToInstall();
this.variables.setProperty(INITAL_PACKSELECTION,Boolean.toString(false));
+ }
+
+ private void removeAlreadyInstalledPacks(List selectedpacks) {
+ List removepacks = new ArrayList();
+
+ for (Iterator iterator = selectedpacks.iterator(); iterator.hasNext();)
+ {
+ Pack selectedpack = (Pack) iterator.next();
+ String key = "";
+ if ((selectedpack.id != null) && (selectedpack.id.length() > 0)){
+ key = selectedpack.id;
+ }
+ else {
+ key = selectedpack.name;
+ }
+ if (installedpacks.containsKey(key)) {
+ // pack is already installed, remove it
+ removepacks.add(selectedpack);
+ }
+ }
+ for (Iterator iterator = removepacks.iterator(); iterator.hasNext();)
+ {
+ Pack removepack = (Pack) iterator.next();
+ selectedpacks.remove(removepack);
+ }
}
public void updateConditions()
@@ -190,7 +265,8 @@
{
Pack pack = (Pack) packs.get(i);
if (packsToInstall.contains(pack)) checkValues[i] = 1;
- }
+ }
+
// Check out and disable the ones that are excluded by non fullfiled
// deps
for (int i = 0; i < packs.size(); i++)
@@ -230,8 +306,10 @@
for (int i = 0; i < packs.size(); i++)
{
Pack pack = (Pack) packs.get(i);
+
if (pack.required) propRequirement(pack.name);
}
+
refreshPacksToInstall();
}
@@ -413,13 +491,36 @@
for (int i = 0; i < packs.size(); i++)
{
Pack pack = (Pack) packs.get(i);
- if (Math.abs(checkValues[i]) == 1) {
+ String key = "";
+ if ((pack.id != null) && (pack.id.length() > 0)) {
+ key = pack.id;
+ }
+ else {
+ key = pack.name;
+ }
+ if ((Math.abs(checkValues[i]) == 1) && (!installedpacks.containsKey(key))) {
packsToInstall.add(pack);
}
}
-
+
+ for (int i=0; i < packs.size(); i++) {
+ Pack pack = (Pack) packs.get(i);
+
+ String key = "";
+ if ((pack.id != null) && (pack.id.length() > 0)) {
+ key = pack.id;
+ }
+ else {
+ key = pack.name;
+ }
+ if (installedpacks.containsKey(key)) {
+ checkValues[i] = -3;
+ }
+ }
}
+
+
/**
* This function updates the checkboxes after a change by disabling packs that cannot be
@@ -554,4 +655,21 @@
u.color = Pack.BLACK;
return 0;
}
+
+
+ /**
+ * @return the installedpacks
+ */
+ public Map getInstalledpacks()
+ {
+ return this.installedpacks;
+ }
+
+ /**
+ * @return the modifyinstallation
+ */
+ public boolean isModifyinstallation()
+ {
+ return this.modifyinstallation;
+ }
}
Modified: izpack-src/trunk/src/lib/com/izforge/izpack/panels/PacksPanelBase.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/panels/PacksPanelBase.java 2007-11-16 14:20:55 UTC (rev 1907)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/panels/PacksPanelBase.java 2007-11-20 08:02:22 UTC (rev 1908)
@@ -81,8 +81,8 @@
*/
public abstract class PacksPanelBase extends IzPanel implements PacksPanelInterface,
ListSelectionListener
-{
-
+{
+
// Common used Swing fields
/**
* The free space label.
@@ -529,7 +529,7 @@
public void panelActivate()
{
try
- {
+ {
// TODO the PacksModel could be patched such that isCellEditable
// allows returns false. In that case the PacksModel must not be
// adapted here.
@@ -601,6 +601,25 @@
else
retval.append(pack.name);
}
+ if (packsModel.isModifyinstallation()) {
+ Map installedpacks = packsModel.getInstalledpacks();
+ iter = installedpacks.keySet().iterator();
+ retval.append("<br><b>");
+ retval.append(langpack.getString("PacksPanel.installedpacks.summarycaption"));
+ retval.append("</b>");
+ retval.append("<br>");
+ while (iter.hasNext()) {
+ Pack pack = (Pack) installedpacks.get(iter.next());
+ if (langpack != null && pack.id != null && !"".equals(pack.id))
+ {
+ retval.append(langpack.getString(pack.id));
+ }
+ else {
+ retval.append(pack.name);
+ }
+ retval.append("<br>");
+ }
+ }
return (retval.toString());
}
@@ -636,6 +655,12 @@
display.setForeground(Color.GRAY);
}
display.setSelected((value != null && Math.abs(state) == 1));
+
+ if (state == -3) {
+ display.setForeground(Color.RED);
+ display.setSelected(true);
+ }
+
display.setEnabled(state >= 0);
return display;
}
Modified: izpack-src/trunk/src/lib/com/izforge/izpack/panels/TargetPanel.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/panels/TargetPanel.java 2007-11-16 14:20:55 UTC (rev 1907)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/panels/TargetPanel.java 2007-11-20 08:02:22 UTC (rev 1908)
@@ -130,4 +130,5 @@
{
return (idata.getInstallPath());
}
+
}
More information about the izpack-changes
mailing list