1 2 24 package org.enhydra.tool.archive.wizard; 25 26 import org.enhydra.tool.ToolBoxInfo; 28 import org.enhydra.tool.archive.ArchiveException; 29 import org.enhydra.tool.archive.Main; 30 import org.enhydra.tool.archive.JarPlan; 31 import org.enhydra.tool.common.PathHandle; 32 import org.enhydra.tool.common.SwingUtil; 33 import org.enhydra.tool.common.wizard.TBWizard; 34 35 import javax.swing.*; 37 import javax.swing.border.*; 38 import java.awt.*; 39 import java.awt.event.ActionEvent ; 40 import java.awt.event.ActionListener ; 41 import java.io.File ; 42 import java.beans.*; 43 import java.util.ResourceBundle ; 44 45 49 public class ArchiveWizard extends TBWizard { 50 51 private final static String ARCHIVE_TITLE = "Kelp Archive Wizard"; 53 54 transient private Icon largeIcon = null; 56 transient private ArchiveSelectionPanel selectionPanel = null; 57 transient private JarPlan plan = null; 58 transient private String workRoot = null; 59 transient private boolean mru = true; 60 61 public ArchiveWizard() { 62 super(); 63 archiveInit(); 64 } 65 66 73 public String getNewArchive() { 74 String newArchive = new String (); 75 76 if (getPlan() != null) { 77 newArchive = 78 PathHandle.createPathString(getPlan().getArchivePath()); 79 } 80 return newArchive; 81 } 82 83 public JarPlan getPlan() { 84 return plan; 85 } 86 87 public void setMostRecentlyUsed(boolean b) { 88 mru = b; 89 } 90 public boolean isMostRecentlyUsed() { 91 return mru; 92 } 93 94 public void setPlan(JarPlan p) throws ArchiveException { 95 plan = p; 96 ArchiveType type = null; 97 type = ArchiveType.createType(plan); 98 type.setMostRecentlyUsed(isMostRecentlyUsed()); 99 getArchiveDeck().setSelection(type); 100 getArchiveDeck().setSelectionPageHidden(true); 101 } 102 103 110 public void readArchive(String archive) throws ArchiveException { 111 if (getArchiveDeck().getSelection() != null) { 112 getArchiveDeck().getSelection().readArchive(archive); 113 getArchiveDeck().readPlan(); 114 } 115 } 116 117 public void setWorkingRoot(String r) { 118 workRoot = PathHandle.createPathString(r); 119 System.setProperty("user.dir", getWorkingRoot()); 120 } 121 122 public String getWorkingRoot() { 123 if (workRoot == null) { 124 setWorkingRoot(System.getProperty("user.dir")); 125 } 126 return workRoot; 127 } 128 129 public void back() { 131 if (getArchiveDeck().getPageIndex() == 1) { 132 setLargeIcon(largeIcon); 133 } 134 super.back(); 135 } 136 137 public void next() { 139 ArchiveType type = null; 140 if (getArchiveDeck().isSelectionPageShowing()) { 141 type = selectionPanel.getSelection(); 142 try { 143 type.setMostRecentlyUsed(isMostRecentlyUsed()); 144 getArchiveDeck().setSelection(type); 145 setLargeIcon(null); 146 getArchiveDeck().next(); 147 } catch (ArchiveException e) { 148 JOptionPane.showMessageDialog(getInnerPanel(), 149 e.getMessage(), 150 "Archive Wizard Error", 151 JOptionPane.ERROR_MESSAGE); 152 if (Main.debug) { 153 e.printStackTrace(); 154 } 155 } 156 refreshButtons(); 157 } else { 158 super.next(); 159 } 160 } 161 162 public void finish() { 164 try { 165 ArchiveType type = null; 166 167 getArchiveDeck().writePlan(); 168 type = getArchiveDeck().getSelection(); 169 type.getPlan().setClassFiltering(true); 170 type.build(); 171 setPlan(type.getPlan()); 172 JOptionPane.showMessageDialog(getInnerPanel(), 173 "Created archive:\n" 174 + getNewArchive(), 175 "Archive Complete", 176 JOptionPane.INFORMATION_MESSAGE); 177 type.saveDefaults(); 178 super.finish(); 179 } catch (ArchiveException e) { 180 if (Main.debug) { 181 e.printStackTrace(); 182 } 183 JOptionPane.showMessageDialog(getInnerPanel(), e.getMessage(), 184 "Archive Error", 185 JOptionPane.ERROR_MESSAGE); 186 } 187 } 188 189 public String getTitle() { 191 return ARCHIVE_TITLE; 192 } 193 194 protected String getProgressTitle() { 196 return "Archive Progress"; 197 } 198 199 200 204 private void archiveInit() { 205 ArchiveDeck newDeck = null; 206 ArchivePage page = null; 207 208 largeIcon = getLargeIcon(); 209 newDeck = new ArchiveDeck(this); 210 selectionPanel = new ArchiveSelectionPanel(); 211 selectionPanel.setWizard(this); 212 setDeck(newDeck); 213 page = new ArchivePage(); 214 page.setPageTitle(selectionPanel.getPageTitle()); 215 page.setInstructions(selectionPanel.getInstructions()); 216 page.add(selectionPanel); 217 addWizardPage(page); 218 } 219 220 private ArchiveDeck getArchiveDeck() { 221 return (ArchiveDeck) getDeck(); 222 } 223 224 } 225 | Popular Tags |