1 package com.bull.eclipse.jonas.wizard; 2 3 7 8 9 import org.eclipse.jface.viewers.ISelection; 10 import org.eclipse.jface.wizard.WizardPage; 11 import org.eclipse.swt.SWT; 12 import org.eclipse.swt.events.SelectionAdapter; 13 import org.eclipse.swt.events.SelectionEvent; 14 import org.eclipse.swt.layout.GridData; 15 import org.eclipse.swt.layout.GridLayout; 16 import org.eclipse.swt.widgets.Button; 17 import org.eclipse.swt.widgets.Composite; 18 import org.eclipse.swt.widgets.Label; 19 import org.eclipse.swt.widgets.Text; 20 21 import com.bull.eclipse.jonas.JonasPluginResources; 22 23 24 public class NewJonasProjectWizardPage extends WizardPage implements JonasPluginResources { 25 26 private Button createWebApp; 27 private Button createEJB; 28 private Text webcontextText; 29 private Text webnameText; 30 private Text websrcText; 31 private String warLocation; 32 private Button createSample; 33 private ISelection selection; 34 private Button ejbInProject; 35 36 37 private Text srcDirEJB; 38 39 private JonasProjectCreationWizard wizard; 41 42 private boolean displayedOnce = false; 44 45 private static final int TEXT_FIELD_WIDTH = 200; 46 47 52 public NewJonasProjectWizardPage(ISelection selection, String pageName) { 53 super(pageName); 54 this.selection = selection; 55 } 56 57 60 public void createControl(Composite parent) { 61 62 Composite composite = new Composite(parent, SWT.NULL); 63 64 composite.setLayout(new GridLayout()); 65 composite.setLayoutData(new GridData(GridData.FILL_BOTH)); 66 67 createWebGroup(composite); 68 createEJBGroup(composite); 69 70 71 setErrorMessage(null); 72 setMessage(null); 73 setControl(composite); 74 } 75 76 77 public void createWebGroup(Composite parent) { 78 79 Composite webGroup = new Composite(parent,SWT.LEFT); 80 GridLayout layout = new GridLayout(); 81 layout.numColumns = 2; 82 webGroup.setLayout(layout); 83 webGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 84 85 createWebApp = new Button(webGroup, SWT.CHECK | SWT.LEFT); 87 createWebApp.setText(WIZARD_PROJECT_CREATEWEBAPP_LABEL); 88 createWebApp.setEnabled(true); 89 createWebApp.setSelection(true); 90 createWebApp.addSelectionListener(new SelectionAdapter() { 91 public void widgetSelected(SelectionEvent ev) { 92 if (createWebApp.getSelection()) { 93 webcontextText.setEnabled(true); 94 webnameText.setEnabled(true); 95 websrcText.setEnabled(true); 96 } else { 97 webcontextText.setEnabled(false); 98 webnameText.setEnabled(false); 99 websrcText.setEnabled(false); 100 } 101 }}); 102 103 104 new Label(webGroup, SWT.NULL); 105 106 Label webpathLabel = new Label(webGroup,SWT.LEFT); 108 webpathLabel.setText(WIZARD_PROJECT_WEBPATH_LABEL); 109 webpathLabel.setEnabled(true); 110 111 webcontextText = new Text(webGroup, SWT.BORDER); 113 GridData data = new GridData(GridData.FILL_HORIZONTAL); 114 data.widthHint = TEXT_FIELD_WIDTH; 115 webcontextText.setLayoutData(data); 116 webcontextText.setText(""); 118 119 Label webnameLabel = new Label(webGroup,SWT.LEFT); 121 webnameLabel.setText(WIZARD_PROJECT_WEBNAME_LABEL); 122 123 webnameText = new Text(webGroup, SWT.BORDER); 125 GridData dataname = new GridData(GridData.FILL_HORIZONTAL); 126 data.widthHint = TEXT_FIELD_WIDTH; 127 webnameText.setLayoutData(dataname); 128 webnameText.setText(""); 130 131 Label websrcLabel = new Label(webGroup,SWT.LEFT); 133 websrcLabel.setText(WIZARD_PROJECT_WEBSRC_LABEL); 134 websrcLabel.setEnabled(true); 135 136 websrcText = new Text(webGroup, SWT.BORDER); 138 GridData datasrc = new GridData(GridData.FILL_HORIZONTAL); 139 data.widthHint = TEXT_FIELD_WIDTH; 140 websrcText.setLayoutData(datasrc); 141 websrcText.setText(""); 143 createSample = new Button( webGroup, SWT.CHECK | SWT.LEFT ); 144 createSample.setText(WIZARD_PROJECT_CREATESRC_LABEL); 145 createSample.setEnabled(true); 146 createSample.setSelection(false); 147 148 149 } 150 151 public void createEJBGroup(Composite parent) { 152 Composite ejbGroup = new Composite(parent,SWT.LEFT); 153 GridLayout layout = new GridLayout(); 154 layout.numColumns = 2; 155 ejbGroup.setLayout(layout); 156 ejbGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 157 158 ejbInProject = new Button( ejbGroup, SWT.CHECK | SWT.LEFT ); 159 ejbInProject.setText(WIZARD_PROJECT_EJBINPROJECT_LABEL); 160 ejbInProject.setEnabled(true); 161 ejbInProject.setSelection(false); 162 ejbInProject.addSelectionListener(new SelectionAdapter() { 163 public void widgetSelected(SelectionEvent ev) { 164 if (ejbInProject.getSelection()) { 165 srcDirEJB.setEnabled(true); 166 } else { 167 srcDirEJB.setEnabled(false); 168 } 169 }}); 170 171 new Label(ejbGroup, SWT.NULL); 172 173 Label ejbsrcLabel = new Label(ejbGroup,SWT.LEFT); 175 ejbsrcLabel.setText(WIZARD_PROJECT_EJBSRC_LABEL); 176 177 srcDirEJB = new Text(ejbGroup, SWT.BORDER); 179 GridData datasrc = new GridData(GridData.FILL_HORIZONTAL); 180 datasrc.widthHint = TEXT_FIELD_WIDTH; 181 srcDirEJB.setLayoutData(datasrc); 182 srcDirEJB.setText("components"); srcDirEJB.setEnabled(false); 184 185 } 186 187 188 public boolean isWebApp() { 189 return createWebApp.getSelection(); 190 } 191 192 public String getWebcontext() { 193 return webcontextText.getText(); 194 } 195 196 public String getSrcpath() { 197 return websrcText.getText(); 198 } 199 200 public String getWebname() { 201 return webnameText.getText(); 202 } 203 204 public String getWarlocation() { 205 return warLocation; 206 } 207 208 209 public void setWebcontext(String path) { 210 warLocation = path + ".war"; 211 webcontextText.setText(path); 212 } 213 214 public void setSrcpath(String path) { 215 websrcText.setText(path); 216 } 217 218 public void setWebname(String name) { 219 webnameText.setText(name); 220 } 221 222 public boolean isCreateWebApp() { 223 return createWebApp.getSelection(); 224 } 225 226 public boolean isEJBApp() { 227 return createEJB.getSelection(); 228 } 229 230 public String getSrcEJBpath() { 231 return srcDirEJB.getText(); 232 } 233 234 235 public boolean isSample() { 236 237 return createSample.getSelection(); 238 } 239 240 public boolean isEJBPrj() { 241 return ejbInProject.getSelection(); 242 } 243 244 245 246 249 public boolean canFlipToNextPage() { 250 displayedOnce = true; 251 return super.canFlipToNextPage(); 252 } 253 254 255 259 public boolean wasDisplayedOnce() { 260 return displayedOnce; 261 } 262 263 264 } 265 | Popular Tags |