Changeset 770
- Timestamp:
- 06/27/07 17:08:44 (2 years ago)
- Files:
-
- trunk/plugins/org.jalcedo.generator.client.beans.ui/src/org/jalcedo/generator/client/beans/ui/BeanEditorGeneratorUIActivator.java (modified) (1 diff)
- trunk/plugins/org.jalcedo.generator.client.beans.ui/src/org/jalcedo/generator/client/beans/ui/internal/actions/GenerateAction.java (modified) (2 diffs)
- trunk/plugins/org.jalcedo.generator.client.beans.ui/src/org/jalcedo/generator/client/beans/ui/internal/wizards/BeanEditorGenerateWizard.java (modified) (5 diffs)
- trunk/plugins/org.jalcedo.generator.client.beans.ui/src/org/jalcedo/generator/client/beans/ui/internal/wizards/BeanInfoPage.java (moved) (moved from trunk/plugins/org.jalcedo.generator.client.beans.ui/src/org/jalcedo/generator/client/beans/ui/internal/wizards/PropertySelectionPage.java) (8 diffs)
- trunk/plugins/org.jalcedo.generator.client.beans.ui/src/org/jalcedo/generator/client/beans/ui/internal/wizards/TargetEnvironmentPage.java (moved) (moved from trunk/plugins/org.jalcedo.generator.client.beans.ui/src/org/jalcedo/generator/client/beans/ui/internal/wizards/BeanSelectionPage.java) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plugins/org.jalcedo.generator.client.beans.ui/src/org/jalcedo/generator/client/beans/ui/BeanEditorGeneratorUIActivator.java
r585 r770 1 1 /******************************************************************************* 2 * Copyright (c) 2006 NEC Soft, Ltd.2 * Copyright (c) 2006-2007 NEC Soft, Ltd. 3 3 * All rights reserved. This program and the accompanying materials 4 4 * are made available under the terms of the Eclipse Public License v1.0 trunk/plugins/org.jalcedo.generator.client.beans.ui/src/org/jalcedo/generator/client/beans/ui/internal/actions/GenerateAction.java
r766 r770 66 66 .getShell(); 67 67 boolean question = MessageDialog.openQuestion(shell, "", 68 "The file may already exist. Overwrite?");68 "The file may already exist. Overwrite?"); 69 69 70 70 if (question) { … … 101 101 IPackageFragment targetPackage = beanType.getPackageFragment(); 102 102 String packageName = targetPackage.getElementName(); 103 if (packageName.endsWith(" models")) {103 if (packageName.endsWith(".models")) { 104 104 IPackageFragmentRoot root = (IPackageFragmentRoot) targetPackage 105 105 .getParent(); 106 106 String newPackageName = packageName.substring(0, packageName 107 107 .length() - 7); 108 targetPackage = root.getPackageFragment(newPackageName); 108 IPackageFragment newPackage = root.getPackageFragment(newPackageName); 109 if(newPackage.exists()){ 110 targetPackage = newPackage; 111 } 109 112 } 110 113 trunk/plugins/org.jalcedo.generator.client.beans.ui/src/org/jalcedo/generator/client/beans/ui/internal/wizards/BeanEditorGenerateWizard.java
r765 r770 52 52 */ 53 53 public class BeanEditorGenerateWizard extends Wizard implements INewWizard { 54 private BeanSelectionPage beanSelectionPage;54 private TargetEnvironmentPage targetEnvironmentPage; 55 55 56 56 // private IdSelectionPage idSelectionPage; … … 58 58 private IStructuredSelection selection; 59 59 60 private PropertySelectionPage propertySelectionPage;60 private BeanInfoPage beanInfoPage; 61 61 62 62 public BeanEditorGenerateWizard() { … … 86 86 87 87 TargetBean targetBean = generatorPlugin.createTargetBean( 88 bean SelectionPage.getBeanType(),89 propertySelectionPage.getIdProperty(),90 propertySelectionPage.getEditableProperties());88 beanInfoPage.getBeanType(), 89 beanInfoPage.getIdProperty(), 90 beanInfoPage.getEditableProperties()); 91 91 BeanEditorInfo beanEditorInfo = generatorPlugin 92 .createBeanEditorInfo(targetBean, beanSelectionPage92 .createBeanEditorInfo(targetBean, targetEnvironmentPage 93 93 .getPackageFragment()); 94 94 95 95 SourceGenerator sourceGenerator = new SourceGenerator(); 96 96 97 sourceGenerator.generateAll(beanEditorInfo, monitor, beanSelectionPage.getFileOverWriteCheck());97 sourceGenerator.generateAll(beanEditorInfo, monitor, targetEnvironmentPage.getFileOverWriteCheck()); 98 98 IProject project = beanEditorInfo.getTargetSourceDir() 99 99 .getJavaProject().getProject(); … … 101 101 ProjectConfiguration config = new ProjectConfiguration( 102 102 project); 103 if ( beanSelectionPage.getLibraryAddCheck()) {103 if (targetEnvironmentPage.getLibraryAddCheck()) { 104 104 config.addJalcedoLibraryDependency(monitor); 105 105 } 106 106 107 if ( beanSelectionPage.getExtensionAddCheck()) {107 if (targetEnvironmentPage.getExtensionAddCheck()) { 108 108 config 109 109 .addBeanEditorToPluginXml(beanEditorInfo, … … 152 152 @Override 153 153 public void addPages() { 154 beanSelectionPage = new BeanSelectionPage();155 beanSelectionPage.init(this.selection);156 addPage( beanSelectionPage);154 targetEnvironmentPage = new TargetEnvironmentPage(); 155 targetEnvironmentPage.init(this.selection); 156 addPage(targetEnvironmentPage); 157 157 158 // idSelectionPage = new IdSelectionPage(beanInfo); 159 // addPage(idSelectionPage); 160 161 propertySelectionPage = new PropertySelectionPage(); 162 addPage(propertySelectionPage); 158 beanInfoPage = new BeanInfoPage(); 159 beanInfoPage.init(selection); 160 addPage(beanInfoPage); 163 161 } 164 162 } trunk/plugins/org.jalcedo.generator.client.beans.ui/src/org/jalcedo/generator/client/beans/ui/internal/wizards/BeanInfoPage.java
r761 r770 11 11 package org.jalcedo.generator.client.beans.ui.internal.wizards; 12 12 13 import org.eclipse.core.resources.IProject; 13 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.jdt.core.ICompilationUnit; 14 16 import org.eclipse.jdt.core.IType; 17 import org.eclipse.jdt.core.JavaModelException; 18 import org.eclipse.jdt.ui.IJavaElementSearchConstants; 19 import org.eclipse.jdt.ui.JavaUI; 15 20 import org.eclipse.jface.viewers.ArrayContentProvider; 16 21 import org.eclipse.jface.viewers.CheckboxTableViewer; … … 24 29 import org.eclipse.jface.wizard.WizardPage; 25 30 import org.eclipse.swt.SWT; 31 import org.eclipse.swt.events.ModifyEvent; 32 import org.eclipse.swt.events.ModifyListener; 33 import org.eclipse.swt.events.SelectionAdapter; 34 import org.eclipse.swt.events.SelectionEvent; 26 35 import org.eclipse.swt.layout.GridData; 27 36 import org.eclipse.swt.layout.GridLayout; 37 import org.eclipse.swt.widgets.Button; 28 38 import org.eclipse.swt.widgets.Composite; 29 39 import org.eclipse.swt.widgets.Label; 40 import org.eclipse.swt.widgets.Text; 41 import org.eclipse.ui.IWorkbenchWindow; 42 import org.eclipse.ui.PlatformUI; 43 import org.eclipse.ui.dialogs.SelectionDialog; 30 44 import org.jalcedo.generator.client.beans.BeanEditorGeneratorActivator; 31 45 import org.jalcedo.generator.client.beans.model.Property; … … 38 52 * 39 53 */ 40 public class PropertySelectionPage extends WizardPage { 54 public class BeanInfoPage extends WizardPage { 55 private IType beanType; 56 private Text beanTypeText; 41 57 private CheckboxTableViewer checkboxTableViewer; 42 58 private ComboViewer comboViewer; 43 59 44 protected PropertySelectionPage() { 45 super("PropertySelectionPage"); 46 setTitle("Property Selection Page"); 47 setDescription("Select id property and editable properties."); 60 protected BeanInfoPage() { 61 super("BeanInfoPage"); 62 setTitle("Bean Infomation "); 63 setDescription("Set the bean informations."); 64 } 65 /** 66 * ユーザの選択した要素からデフォルト値を取得し、設定する。 67 * 68 * @param selection 69 * ユーザの選択した要素 70 */ 71 public void init(IStructuredSelection selection) { 72 Object javaElement = selection.getFirstElement(); 73 74 if (javaElement instanceof IType) { 75 beanType = (IType) javaElement; 76 } else if (javaElement instanceof ICompilationUnit) { 77 beanType = ((ICompilationUnit) javaElement).findPrimaryType(); 78 } 48 79 } 49 80 … … 59 90 layout.numColumns = nColumns; 60 91 composite.setLayout(layout); 61 92 93 createBeanSelectionControls(composite, nColumns); 94 95 createIdPropertySelectionControls(composite, nColumns); 96 97 createEditablePropertySelectionControls(composite, nColumns); 98 99 setControl(composite); 100 doValidate(); 101 } 102 /** 103 * @param composite 104 */ 105 private void createEditablePropertySelectionControls(Composite composite, int nColumns) { 106 Label label = new Label(composite, SWT.NULL); 107 label.setText("&Editable Properties :"); 108 109 GridData gd = new GridData(GridData.FILL_HORIZONTAL); 110 gd.horizontalSpan = nColumns - 1; 111 gd.horizontalAlignment = GridData.FILL; 112 gd.grabExcessVerticalSpace = true; 113 gd.grabExcessHorizontalSpace = true; 114 gd.verticalAlignment = GridData.FILL; 115 116 checkboxTableViewer = CheckboxTableViewer.newCheckList(composite, 117 SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL); 118 119 checkboxTableViewer.setContentProvider(new ArrayContentProvider()); 120 checkboxTableViewer.setLabelProvider(new PropertyLabelProvider()); 121 checkboxTableViewer.getTable().setLayoutData(gd); 122 checkboxTableViewer 123 .addSelectionChangedListener(new PropertySelectionChangedListener()); 124 } 125 /** 126 * @param composite 127 */ 128 private void createIdPropertySelectionControls(Composite composite, int nColumns) { 62 129 Label label2 = new Label(composite, SWT.NULL); 63 130 label2.setText("&ID property:"); 64 131 65 132 GridData gd3 = new GridData(GridData.FILL_HORIZONTAL); 66 gd3.horizontalSpan = 3;133 gd3.horizontalSpan = nColumns - 1; 67 134 comboViewer = new ComboViewer(composite, SWT.BORDER | SWT.SINGLE); 68 135 comboViewer.getCombo().setLayoutData(gd3); … … 71 138 comboViewer 72 139 .addSelectionChangedListener(new IdSelectionChangedListener()); 73 140 } 141 142 /** 143 * TargetBean 選択の項目を作成する。 144 * 145 * @param composite 146 * @param nColumns 147 */ 148 private void createBeanSelectionControls(Composite composite, int nColumns) { 74 149 Label label = new Label(composite, SWT.NULL); 75 label.setText("Editable Properties :"); 76 77 GridData gd = new GridData(GridData.FILL_HORIZONTAL); 78 gd.horizontalSpan = 3; 79 gd.horizontalAlignment = GridData.FILL; 80 gd.grabExcessVerticalSpace = true; 81 gd.grabExcessHorizontalSpace = true; 82 gd.verticalAlignment = GridData.FILL; 83 84 checkboxTableViewer = CheckboxTableViewer.newCheckList(composite, 85 SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL); 86 87 checkboxTableViewer.setContentProvider(new ArrayContentProvider()); 88 checkboxTableViewer.setLabelProvider(new PropertyLabelProvider()); 89 checkboxTableViewer.getTable().setLayoutData(gd); 90 checkboxTableViewer 91 .addSelectionChangedListener(new PropertySelectionChangedListener()); 92 93 setControl(composite); 94 doValidate(); 95 } 150 label.setText("&Target Bean:"); 151 152 beanTypeText = new Text(composite, SWT.BORDER | SWT.SINGLE); 153 GridData gd4 = new GridData(GridData.FILL_HORIZONTAL); 154 gd4.horizontalSpan = nColumns -2; 155 beanTypeText.setLayoutData(gd4); 156 beanTypeText.addModifyListener(new BeanTypeTextModifyListener()); 157 158 Button button = new Button(composite, SWT.PUSH); 159 GridData gd5 = new GridData(GridData.FILL_HORIZONTAL); 160 gd5.horizontalSpan = 1; 161 button.setText("Browse..."); 162 button.setLayoutData(gd5); 163 button.addSelectionListener(new ChooseBeanButtonSelectionAdapter()); 164 } 165 // /** 166 // * BeanTypeの入力テキストボックスを取得する 167 // * 168 // * @return 169 // */ 170 // public Text getBeanTypeText() { 171 // return beanTypeText; 172 // } 173 /** 174 * TargetBeanのモデルを取得する 175 * 176 * @return TargetBeanのモデル 177 */ 178 public IType getBeanType() { 179 return beanType; 180 } 181 96 182 97 183 @Override 98 184 public void setVisible(boolean visible) { 99 IType beanType = ((BeanSelectionPage) getPreviousPage() 100 ).getBeanType(); 185 super.setVisible(visible); 186 if (beanType != null) { 187 beanTypeText.setText(beanType.getFullyQualifiedName()); 188 } 189 101 190 TargetBean targetBean = null; 102 191 … … 109 198 e.printStackTrace(); 110 199 } 111 super.setVisible(visible);200 112 201 Property[] properties = targetBean.getProperties(); 113 202 … … 133 222 134 223 private void doValidate() { 135 if (this.getIdProperty() == null) { 224 if (beanType == null) { 225 setErrorMessage("Input fully qualified name of TargetBean."); 226 setPageComplete(false); 227 return; 228 } else if (this.getIdProperty() == null) { 136 229 setErrorMessage("select id property"); 137 230 setPageComplete(false); … … 156 249 } 157 250 251 /** 252 * TargetBean 入力のテキストボックスの値が変更されたとき、そのクラスが 存在するか調べ、値のチェックを実行する。 253 * 254 * @author nozawa 255 * 256 */ 257 class BeanTypeTextModifyListener implements ModifyListener { 258 259 public void modifyText(ModifyEvent event) { 260 try { 261 beanType = beanType.getJavaProject().findType(beanTypeText.getText()); 262 263 264 if(beanType != null){ 265 266 TargetBean targetBean = null; 267 268 targetBean = BeanEditorGeneratorActivator.getDefault() 269 .createTargetBean(beanType, null); 270 271 Property[] properties = targetBean.getProperties(); 272 273 comboViewer.setInput(properties); 274 275 276 checkboxTableViewer.setInput(properties); 277 checkboxTableViewer.setAllChecked(true); 278 comboViewer.setSelection(new StructuredSelection(properties[0])); 279 } 280 doValidate(); 281 } catch (JavaModelException e) { 282 setMessage(e.getMessage()); 283 } catch (CoreException e) { 284 // TODO Auto-generated catch block 285 e.printStackTrace(); 286 } 287 } 288 } 289 290 /** 291 * TargetBean 入力項目のボタンが押されたとき、bean選択ダイアログを表示し、 値をテキストボックスにセットする。 292 * 293 * @author nozawa 294 * 295 */ 296 class ChooseBeanButtonSelectionAdapter extends SelectionAdapter { 297 298 public void widgetSelected(SelectionEvent e) { 299 IType choosedBean = chooseTargetBean(beanType.getJavaProject().getProject()); 300 beanTypeText.setText(choosedBean.getFullyQualifiedName()); 301 } 302 303 /** 304 * Open type selection dialog, and it returns IType of choosed bean. 305 * 306 * @param project 307 * @return IType of choosed bean 308 */ 309 private IType chooseTargetBean(IProject project) { 310 IWorkbenchWindow window = PlatformUI.getWorkbench() 311 .getActiveWorkbenchWindow(); 312 313 try { 314 SelectionDialog dialog = JavaUI.createTypeDialog(window 315 .getShell(), window, project, 316 IJavaElementSearchConstants.CONSIDER_CLASSES, false); 317 dialog.setTitle("select Bean"); 318 dialog.setMessage("Select Bean:"); 319 320 if (dialog.open() == SelectionDialog.OK) { 321 Object[] selection = dialog.getResult(); 322 return (IType) selection[0]; 323 } 324 } catch (JavaModelException e) { 325 setMessage(e.getMessage()); 326 } 327 return null; 328 } 329 330 } 331 158 332 class PropertyLabelProvider extends LabelProvider { 159 333 @Override trunk/plugins/org.jalcedo.generator.client.beans.ui/src/org/jalcedo/generator/client/beans/ui/internal/wizards/TargetEnvironmentPage.java
r765 r770 1 1 /******************************************************************************* 2 * Copyright (c) 2006 NEC Soft, Ltd.2 * Copyright (c) 2006-2007 NEC Soft, Ltd. 3 3 * All rights reserved. This program and the accompanying materials 4 4 * are made available under the terms of the Eclipse Public License v1.0 … … 15 15 import org.eclipse.core.runtime.CoreException; 16 16 import org.eclipse.core.runtime.IStatus; 17 import org.eclipse.jdt.core.ICompilationUnit;18 17 import org.eclipse.jdt.core.IJavaElement; 19 import org.eclipse.jdt.core.IJavaProject;20 import org.eclipse.jdt.core.IType;21 import org.eclipse.jdt.core.JavaModelException;22 import org.eclipse.jdt.ui.IJavaElementSearchConstants;23 import org.eclipse.jdt.ui.JavaUI;24 18 import org.eclipse.jdt.ui.wizards.NewTypeWizardPage; 25 19 import org.eclipse.jface.viewers.IStructuredSelection; 26 20 import org.eclipse.swt.SWT; 27 import org.eclipse.swt.events.ModifyEvent;28 import org.eclipse.swt.events.ModifyListener;29 import org.eclipse.swt.events.SelectionAdapter;30 import org.eclipse.swt.events.SelectionEvent;31 21 import org.eclipse.swt.layout.GridData; 32 22 import org.eclipse.swt.layout.GridLayout; 33 23 import org.eclipse.swt.widgets.Button; 34 24 import org.eclipse.swt.widgets.Composite; 35 import org.eclipse.swt.widgets.Label;36 import org.eclipse.swt.widgets.Text;37 import org.eclipse.ui.IWorkbenchWindow;38 import org.eclipse.ui.PlatformUI;39 import org.eclipse.ui.dialogs.SelectionDialog;40 25 41 26 /** … … 46 31 * <li>BeanEditorを出力するソースフォルダ。</li> 47 32 * <li>BeanEditorを出力するルートとなるパッケージ名。</li> 48 * <li>ターゲットとなるBean。</li>49 33 * <li>jalcedoのライブラリを追加するかどうか.</li> 50 34 * <li>生成したView をプラグインに登録するかどうか.</li> 35 * <li>Overwrite files or not.</li> 51 36 * </ul> 52 37 * … … 54 39 * 55 40 */ 56 // TODO add contents assistant to beanTypeText.57 public class BeanSelectionPage extends NewTypeWizardPage {58 private IJavaProject javaProject;59 41 60 private Text beanTypeText; 61 62 private IType beanType = null; 63 42 public class TargetEnvironmentPage extends NewTypeWizardPage { 64 43 private Button libraryAddCheckBox; 65 44 66 45 private Button extensionAddCheckBox; 67 46 68 47 private Button fileOverWriteCheckBox; 69 48 70 public BeanSelectionPage() {71 super(true, " BeanSelectionPage");72 setTitle(" BeanSlectionPage");73 setDescription(" select target bean");49 public TargetEnvironmentPage() { 50 super(true, "TargetEnvironmentPage"); 51 setTitle("Target Environment "); 52 setDescription("Set the parameters which is used to generate the editor. "); 74 53 75 54 } … … 85 64 initContainerPage(javaElement); 86 65 initTypePage(javaElement); 87 initBeanType(javaElement);88 javaProject = javaElement.getJavaProject();89 }90 91 /**92 *93 * ユーザの選択した要素が java クラスのモデルだったとき、 そのクラスを TargetBean の デフォルト値に設定する。94 *95 * @param javaElement96 */97 private void initBeanType(IJavaElement javaElement) {98 if (javaElement instanceof IType) {99 beanType = (IType) javaElement;100 } else if (javaElement instanceof ICompilationUnit) {101 beanType = ((ICompilationUnit) javaElement).findPrimaryType();102 }103 66 } 104 67 … … 123 86 createContainerControls(composite, nColumns); 124 87 createPackageControls(composite, nColumns); 125 126 88 127 89 createSeparator(composite, nColumns); 128 129 createBeanSelectionControls(composite, nColumns);130 90 131 91 createOptionCheckBoxes(composite, nColumns); … … 135 95 136 96 /** 137 * 入力値をチェックする。ソースフォルダ名、パッケージ名、TargetBeanに 未入力の項目があるときエラーを表示する。 138 * 選択されたプロジェクトがプラグインプロジェクトで無い場合もエラーを表示する。97 * 入力値をチェックする。ソースフォルダ名、パッケージ名、TargetBeanに 未入力の項目があるときエラーを表示する。 選択されたプロジェクトが 98 * プラグインプロジェクトで無い場合もエラーを表示する。 139 99 * 140 100 */ … … 142 102 IStatus[] status = new IStatus[] { fContainerStatus, fPackageStatus }; 143 103 updateStatus(status); 144 if (beanType == null) { 145 setErrorMessage("Input fully qualified name of TargetBean."); 146 setPageComplete(false); 147 return; 148 } else if (!hasPluginNature(this.getJavaProject().getProject())) { 104 if (!hasPluginNature(this.getJavaProject().getProject())) { 149 105 setErrorMessage("Project is not a plug-in project. Select a plugin project or convert this to a plugin project. "); 150 106 setPageComplete(false); 151 107 return; 152 } else if (this.getPackageFragment().getElementName().equals("")) {108 } else if (this.getPackageFragment().getElementName().equals("")) { 153 109 setErrorMessage("Root pacakge is not selected. "); 154 110 setPageComplete(false); 155 111 return; 156 112 } 157 158 113 159 114 } … … 187 142 188 143 /** 189 * TargetBean 選択の項目を作成する。190 *191 * @param composite192 * @param nColumns193 */194 private void createBeanSelectionControls(Composite composite, int nColumns) {195 Label label = new Label(composite, SWT.NULL);196 label.setText("&Target Bean:");197 198 beanTypeText = new Text(composite, SWT.BORDER | SWT.SINGLE);199 GridData gd = new GridData(GridData.FILL_HORIZONTAL);200 gd.horizontalSpan = nColumns - 2;201 beanTypeText.setLayoutData(gd);202 beanTypeText.addModifyListener(new BeanTypeTextModifyListener());203 204 Button button = new Button(composite, SWT.PUSH);205 GridData gd2 = new GridData(GridData.FILL_HORIZONTAL);206 button.setText("Browse...");207 button.setLayoutData(gd2);208 button.addSelectionListener(new ChooseBeanButtonSelectionAdapter());209 }210 211 /**212 144 * オプション選択のチェックボックスを作成する。 213 145 * … … 229 161 extensionAddCheckBox.setText("register generated view extension."); 230 162 extensionAddCheckBox.setSelection(true); 231 163 232 164 fileOverWriteCheckBox = new Button(composite, SWT.CHECK); 233 165 GridData gd5 = new GridData(GridData.FILL_HORIZONTAL); 234 166 gd5.horizontalSpan = nColumns; 235 167 fileOverWriteCheckBox.setLayoutData(gd5); 236 fileOverWriteCheckBox.setText("Overwrite files, if the same files exist."); 168 fileOverWriteCheckBox 169 .setText("Overwrite files, if the same files exist."); 237 170 fileOverWriteCheckBox.setSelection(false); 238 }239 240 /**241 * BeanTypeの入力テキストボックスを取得する242 *243 * @return244 */245 public Text getBeanTypeText() {246 return beanTypeText;247 }248 249 /**250 * TargetBeanのモデルを取得する251 *252 * @return TargetBeanのモデル253 */254 public IType getBeanType() {255 return beanType;256 171 } 257 172 … … 273 188 return extensionAddCheckBox.getSelection(); 274 189 } 275 276 public boolean getFileOverWriteCheck() {190 191 public boolean getFileOverWriteCheck() { 277 192 return fileOverWriteCheckBox.getSelection(); 278 193 } 279 280 /*281 * (non-Javadoc)282 *283 * @see org.eclipse.jdt.ui.wizards.NewElementWizardPage#setVisible(boolean)284 */285 @Override286 public void setVisible(boolean visible) {287 super.setVisible(visible);288 if (beanType != null) {289 beanTypeText.setText(beanType.getFullyQualifiedName());290 }291 doStatusUpdate();292 }293 294 /**295 * TargetBean 入力のテキストボックスの値が変更されたとき、そのクラスが 存在するか調べ、値のチェックを実行する。296 *297 * @author nozawa298 *299 */300 class BeanTypeTextModifyListener implements ModifyListener {301 302 public void modifyText(ModifyEvent event) {303 try {304 beanType = javaProject.findType(beanTypeText.getText());305 doStatusUpdate();306 } catch (JavaModelException e) {307 setMessage(e.getMessage());308 }309 }310 }311 312 /**313 * TargetBean 入力項目のボタンが押されたとき、bean選択ダイアログを表示し、 値をテキストボックスにセットする。314 *315 * @author nozawa316 *317 */318 class ChooseBeanButtonSelectionAdapter extends SelectionAdapter {319 320 public void widgetSelected(SelectionEvent e) {321 IType choosedBean = chooseTargetBean(javaProject.getProject());322 beanTypeText.setText(choosedBean.getFullyQualifiedName());323 }324 325 /**326 * Open type selection dialog, and it returns IType of choosed bean.327 *328 * @param project329 * @return IType of choosed bean330 */331 private IType chooseTargetBean(IProject project) {332 IWorkbenchWindow window = PlatformUI.getWorkbench()333 .getActiveWorkbenchWindow();334 335 try {336 SelectionDialog dialog = JavaUI.createTypeDialog(window337 .getShell(), window, project,338 IJavaElementSearchConstants.CONSIDER_ALL_TYPES, false);339 dialog.setTitle("select Bean");340 dialog.setMessage("Select Bean:");341 342 if (dialog.open() == SelectionDialog.OK) {343 Object[] selection = dialog.getResult();344 return (IType) selection[0];345 }346 } catch (JavaModelException e) {347 setMessage(e.getMessage());348 }349 return null;350 }351 352 }353 354 194 }
