1 2 24 package org.enhydra.tool.archive.wizard; 25 26 import org.enhydra.tool.archive.ArchiveException; 28 import org.enhydra.tool.archive.JarPlan; 29 import org.enhydra.tool.common.ToolException; 30 import org.enhydra.tool.common.wizard.TBWizardDeck; 31 32 import java.awt.Component ; 34 import java.lang.ref.WeakReference ; 35 36 public class ArchiveDeck extends TBWizardDeck { 38 private ArchiveType selection = null; 39 private boolean selectionHidden = false; 40 private WeakReference wizardRef = null; 41 42 public ArchiveDeck(ArchiveWizard wizard) { 43 super(); 44 wizardRef = new WeakReference (wizard); 45 } 46 47 protected void setSelectionPageHidden(boolean b) { 48 selectionHidden = b && (selection != null); 49 if (selectionHidden && (getPageIndex() == 0)) { 50 next(); 51 } 52 } 53 54 protected boolean isSelectionPageHidden() { 55 return selectionHidden; 56 } 57 58 64 protected void setSelection(ArchiveType select) throws ArchiveException { 65 selection = select; 66 if (selection == null) { 67 68 } else { 70 while (getPages().length > 1) { 71 removeWizardPage(getPages()[1]); 72 } 73 for (int i = 0; i < selection.getWizardPanels().length; i++) { 74 ArchivePage newPage = new ArchivePage(); 75 ArchivePanel panel = selection.getWizardPanels()[i]; 76 77 panel.setWizard(getWizard()); 78 newPage.add(panel); 79 newPage.setPageTitle(panel.getPageTitle()); 80 newPage.setInstructions(panel.getInstructions()); 81 addWizardPage(newPage); 82 } 83 } 84 } 85 86 protected ArchiveType getSelection() { 87 return selection; 88 } 89 90 protected boolean isSelectionPageShowing() { 91 return getPageIndex() == 0; 92 } 93 94 protected boolean isFirstPageShowing() { 96 boolean atFirst = super.isFirstPageShowing(); 97 98 if (isSelectionPageHidden()) { 99 atFirst = (getPageIndex() == 1); 100 } 101 return (atFirst); 102 } 103 104 protected boolean isLastPageShowing() { 106 boolean atLast = super.isLastPageShowing(); 107 108 if (!isSelectionPageHidden()) { 109 if (isSelectionPageShowing()) { 110 atLast = false; 111 } 112 } 113 return (atLast); 114 } 115 116 protected void readPlan() throws ArchiveException { 117 ArchivePage page = null; 118 119 for (int i = 0; i < getPages().length; i++) { 120 page = (ArchivePage) getPages()[i]; 121 page.readPlan(selection.getPlan()); 122 } 123 } 124 125 protected void validatePlan() throws ArchiveException { 126 ArchivePage page = null; 127 128 try { 130 for (int i = 0; i < getPages().length; i++) { 131 page = (ArchivePage) getPages()[i]; 132 page.validatePage(); 133 } 134 } catch (ToolException e) { 135 throw new ArchiveException(e, e.getMessage()); 136 } 137 } 138 139 protected void writePlan() throws ArchiveException { 140 ArchivePage page = null; 141 142 for (int i = 0; i < getPages().length; i++) { 143 page = (ArchivePage) getPages()[i]; 144 page.writePlan(selection.getPlan()); 145 } 146 } 147 148 private ArchiveWizard getWizard() { 149 ArchiveWizard wizard = null; 150 151 if (wizardRef != null) { 152 wizard = (ArchiveWizard) wizardRef.get(); 153 } 154 return wizard; 155 } 156 157 } 158 | Popular Tags |