@Override protected void buttonPressed(int buttonId) { switch (buttonId) { case APPLY_BUTTON: getButton(APPLY_BUTTON).setEnabled(false); somethingChanged= false; //$FALL-THROUGH$ case OK: applyChanges(); } super.buttonPressed(buttonId); }
@Override protected Control createDialogArea(Composite parent) { getShell().setText(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_windowTitle); LayoutUtil.setWidthHint(composite, convertWidthInCharsToPixels(100)); fBuilderClassName= createTextField(composite, 1, fBuilderSettings.className); setButtonLayoutData(button); button.addSelectionListener(new SelectionAdapter() { @Override fBuilderVariableName= createTextField(composite, 2, fBuilderSettings.variableName); fResultMethodName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); updateCombos(); ModifyListener comboListener= new ModifyListener() { @Override fAppendMethodName.addModifyListener(comboListener); fResultMethodName.addModifyListener(comboListener); if (!select(fAppendMethodName, fBuilderSettings.appendMethod)) { fAppendMethodName.select(0); if (!select(fResultMethodName, fBuilderSettings.resultMethod)) { fResultMethodName.select(0); PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), IJavaHelpContextIds.GENERATE_TOSTRING_CONFIGURE_CUSTOM_BUILDER_DIALOG);
@Override protected void createButtonsForButtonBar(Composite parent) { super.createButtonsForButtonBar(parent); createButton(parent, APPLY_BUTTON, JavaUIMessages.GenerateToStringDialog_customBuilderConfig_applyButton, false).setEnabled(false); }
@Override protected Control createDialogArea(Composite parent) { getShell().setText(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_windowTitle); LayoutUtil.setWidthHint(composite, convertWidthInCharsToPixels(100)); fBuilderClassName= createTextField(composite, 1, fBuilderSettings.className); setButtonLayoutData(button); button.addSelectionListener(new SelectionAdapter() { @Override fBuilderVariableName= createTextField(composite, 2, fBuilderSettings.variableName); fResultMethodName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); updateCombos(); ModifyListener comboListener= new ModifyListener() { @Override fAppendMethodName.addModifyListener(comboListener); fResultMethodName.addModifyListener(comboListener); if (!select(fAppendMethodName, fBuilderSettings.appendMethod)) { fAppendMethodName.select(0); if (!select(fResultMethodName, fBuilderSettings.resultMethod)) { fResultMethodName.select(0); PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), IJavaHelpContextIds.GENERATE_TOSTRING_CONFIGURE_CUSTOM_BUILDER_DIALOG);
private void browseForBuilderClass() { try { IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaElement[] { getType().getJavaProject() }); SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), PlatformUI.getWorkbench().getProgressService(), scope, IJavaElementSearchConstants.CONSIDER_CLASSES, false, "*ToString", fExtension); //$NON-NLS-1$ dialog.setTitle(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_classSelection_windowTitle); dialog.setMessage(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_classSelection_message); dialog.open(); if (dialog.getReturnCode() == OK) { IType type= (IType)dialog.getResult()[0]; fBuilderClassName.setText(type.getFullyQualifiedParameterizedName()); List<String> suggestions= fValidator.getAppendMethodSuggestions(type); if (!suggestions.contains(fAppendMethodName.getText())) fAppendMethodName.setText(suggestions.get(0)); suggestions= fValidator.getResultMethodSuggestions(type); if (!suggestions.contains(fResultMethodName.getText())) fResultMethodName.setText(suggestions.get(0)); } } catch (JavaModelException e) { JavaPlugin.log(e); } } }
private void browseForBuilderClass() { try { IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaElement[] { getType().getJavaProject() }); SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), PlatformUI.getWorkbench().getProgressService(), scope, IJavaElementSearchConstants.CONSIDER_CLASSES, false, "*ToString", fExtension); //$NON-NLS-1$ dialog.setTitle(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_classSelection_windowTitle); dialog.setMessage(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_classSelection_message); dialog.open(); if (dialog.getReturnCode() == OK) { IType type= (IType)dialog.getResult()[0]; fBuilderClassName.setText(type.getFullyQualifiedParameterizedName()); List<String> suggestions= fValidator.getAppendMethodSuggestions(type); if (!suggestions.contains(fAppendMethodName.getText())) fAppendMethodName.setText(suggestions.get(0)); suggestions= fValidator.getResultMethodSuggestions(type); if (!suggestions.contains(fResultMethodName.getText())) fResultMethodName.setText(suggestions.get(0)); } } catch (JavaModelException e) { JavaPlugin.log(e); } } }
@Override public ISelectionStatusValidator getSelectionValidator() { return getValidator(); } };
private void configureStyleButtonSelected() { CustomBuilderConfigurationDialog dialog= new CustomBuilderConfigurationDialog(getShell()); dialog.open(); updateOKStatus(); }
@Override public ISelectionStatusValidator getSelectionValidator() { return getValidator(); } };
@Override public void create() { super.create(); IStatus status= getValidator().revalidateAll(fBuilderSettings); updateStatus(status); }
@Override public void modifyText(ModifyEvent e) { if (e.widget == fBuilderClassName) { fBuilderSettings.className= fBuilderClassName.getText(); updateCombos(); } else if (e.widget == fBuilderVariableName) fBuilderSettings.variableName= fBuilderVariableName.getText(); IStatus status= getValidator().revalidateAll(fBuilderSettings); updateStatus(status); enableApplyButton(); } };
@Override public void modifyText(ModifyEvent e) { if (e.widget == fBuilderClassName) { fBuilderSettings.className= fBuilderClassName.getText(); updateCombos(); } else if (e.widget == fBuilderVariableName) fBuilderSettings.variableName= fBuilderVariableName.getText(); IStatus status= getValidator().revalidateAll(fBuilderSettings); updateStatus(status); enableApplyButton(); } };
private void configureStyleButtonSelected() { CustomBuilderConfigurationDialog dialog= new CustomBuilderConfigurationDialog(getShell()); dialog.open(); updateOKStatus(); }
public CustomBuilderConfigurationDialog(Shell parent) { super(parent); this.setShellStyle(this.getShellStyle() | SWT.RESIZE); fBuilderSettings= getGenerationSettings().getCustomBuilderSettings(); }
@Override protected void updateButtonsEnableState(IStatus status) { super.updateButtonsEnableState(status); getButton(APPLY_BUTTON).setEnabled(!status.matches(IStatus.ERROR) && somethingChanged); }
@Override public void create() { super.create(); IStatus status= getValidator().revalidateAll(fBuilderSettings); updateStatus(status); }
public CustomBuilderConfigurationDialog(Shell parent) { super(parent); this.setShellStyle(this.getShellStyle() | SWT.RESIZE); fBuilderSettings= getGenerationSettings().getCustomBuilderSettings(); }
@Override protected void buttonPressed(int buttonId) { switch (buttonId) { case APPLY_BUTTON: getButton(APPLY_BUTTON).setEnabled(false); somethingChanged= false; //$FALL-THROUGH$ case OK: applyChanges(); } super.buttonPressed(buttonId); }