1 2 24 25 package org.enhydra.tool.codegen.wizard; 26 27 import org.enhydra.tool.common.wizard.TBWizardDeck; 31 import org.enhydra.tool.codegen.Generator; 32 import org.enhydra.tool.codegen.GeneratorException; 33 import org.enhydra.tool.codegen.ValidationException; 34 35 import java.awt.Component ; 37 38 44 public class CodeGenDeck extends TBWizardDeck implements RootEditor { 45 private Generator selection = null; 46 private boolean selectionHidden = false; 47 private boolean allowRootEdit = true; 48 49 public CodeGenDeck() { 50 super(); 51 } 52 53 public boolean isAllowRootEdit() { 54 return allowRootEdit; 55 } 56 57 public void setAllowRootEdit(boolean edit) { 58 allowRootEdit = edit; 59 } 60 61 protected void setSelectionPageHidden(boolean b) { 62 selectionHidden = b && (selection != null); 63 if (selectionHidden && getPageIndex() == 0) { 64 next(); 65 } 66 } 67 68 protected boolean isSelectionPageHidden() { 69 return selectionHidden; 70 } 71 72 78 protected void setSelection(Generator sel) 79 throws GeneratorException { 80 selection = sel; 81 if (selection == null) { 82 System.err.println("GodeGenDeck.setSelect(): null selection"); 83 } else { 84 while (getPages().length > 1) { 85 removeWizardPage(getPages()[1]); 86 } 87 selection.setSwing(true); 88 for (int i = 0; i < selection.getWizardPanels().length; i++) { 89 CodeGenPage newPage = new CodeGenPage(); 90 CodeGenPanel panel = selection.getWizardPanels()[i]; 91 if (panel instanceof RootEditor) { 92 RootEditor editor = (RootEditor) panel; 93 editor.setAllowRootEdit(isAllowRootEdit()); 94 } 95 96 newPage.add(panel); 97 newPage.setPageTitle(panel.getPageTitle()); 98 newPage.setInstructions(panel.getInstructions()); 99 addWizardPage(newPage); 100 } 101 } 102 } 103 104 112 protected Generator getSelection() { 113 return selection; 114 } 115 116 protected boolean isSelectionPageShowing() { 117 return getPageIndex() == 0; 118 } 119 120 protected boolean isFirstPageShowing() { 122 boolean atFirst = super.isFirstPageShowing(); 123 124 if (isSelectionPageHidden()) { 125 atFirst = (getPageIndex() == 1); 126 } 127 return (atFirst); 128 } 129 130 protected boolean isLastPageShowing() { 131 boolean atLast = super.isLastPageShowing(); 132 133 if (! isSelectionPageHidden()) { 134 if (isSelectionPageShowing()) { 135 atLast = false; 136 } 137 } 138 return (atLast); 139 } 140 141 142 143 152 protected void writeOptionSet() 153 throws ValidationException, GeneratorException { 154 CodeGenPage page = null; 155 156 for (int i = 0; i < getPages().length; i++) { 158 page = (CodeGenPage) getPages()[i]; 159 page.validateOptionSet(); 160 } 161 for (int i = 0; i < getPages().length; i++) { 162 page = (CodeGenPage) getPages()[i]; 163 page.writeOptionSet(); 164 } 165 } 166 167 } 168 | Popular Tags |