protected void createFormContent(IManagedForm managedForm) { final ScrolledForm form = managedForm.getForm(); FormToolkit toolkit = managedForm.getToolkit(); TableWrapLayout tw = new TableWrapLayout(); tw.leftMargin = 10; tw.rightMargin = 10; tw.verticalSpacing = 25; form.getBody().setLayout(tw); form.setText(Messages.EvaluationGeneralPage_2); Section generalSection = toolkit.createSection( form.getBody(), Section.TWISTIE | Section.TITLE_BAR | Section.DESCRIPTION | Section.EXPANDED); generalSection.setText(Messages.EvaluationGeneralPage_3); generalSection.setDescription(Messages.EvaluationGeneralPage_4); TableWrapData td = new TableWrapData(); td.align = TableWrapData.LEFT; td.grabHorizontal = true; generalSection.setLayoutData(td); final Composite generalComposite = toolkit.createComposite(generalSection); generalSection.setClient(generalComposite); GridLayout layout = new GridLayout(); layout.numColumns = 4; layout.marginHeight = layout.marginWidth = 0; layout.verticalSpacing = 8; layout.horizontalSpacing = 20; generalComposite.setLayout(layout); generalSection.setClient(generalComposite); toolkit.createLabel(generalComposite, Messages.EvaluationGeneralPage_5); schemeName = toolkit.createText(generalComposite, "", SWT.SINGLE); schemeName.setEnabled(false); GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = 150; schemeName.setLayoutData(gd); toolkit.createLabel(generalComposite, ""); toolkit.createLabel(generalComposite, ""); toolkit.createLabel(generalComposite, Messages.EvaluationGeneralPage_9); evalSerial = toolkit.createText(generalComposite, "", SWT.SINGLE); evalSerial.setLayoutData(gd); evalSerial.setEnabled(false); toolkit.createLabel(generalComposite, Messages.EvaluationGeneralPage_11); author = toolkit.createText(generalComposite, "", SWT.SINGLE); author.setLayoutData(gd); author.setEnabled(false); toolkit.createLabel(generalComposite, Messages.EvaluationGeneralPage_13); backgroud = toolkit.createText(generalComposite, "", SWT.MULTI); gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = 153; gd.heightHint = 50; backgroud.setLayoutData(gd); backgroud.setEnabled(((EvaluationEditor) this.getEditor()).isAllowed()); toolkit.createLabel(generalComposite, Messages.EvaluationGeneralPage_15); remark = toolkit.createText(generalComposite, "", SWT.MULTI); remark.setLayoutData(gd); remark.setEnabled(((EvaluationEditor) this.getEditor()).isAllowed()); update(); }
public void build(ScrolledForm form, SpyFormToolkit toolkit, ExecutionEvent event) { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); if (window == null) // if we don't have an active workbench, we don't have a valid selection to analyze return; // analyze the selection ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection != null) { Section section = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR); section.clientVerticalSpacing = 9; section.setText(MDERuntimeMessages.SpyDialog_activeSelection_title); FormText text = toolkit.createFormText(section, true); section.setClient(text); TableWrapData td = new TableWrapData(); td.align = TableWrapData.FILL; td.grabHorizontal = true; section.setLayoutData(td); // time to analyze the selection Class clazz = selection.getClass(); StringBuffer buffer = new StringBuffer(); buffer.append("<form>"); // $NON-NLS-1$ buffer.append( toolkit.createClassSection( text, MDERuntimeMessages.SpyDialog_activeSelection_desc, new Class[] {clazz})); Class[] interfaces = clazz.getInterfaces(); buffer.append( toolkit.createInterfaceSection( text, MDERuntimeMessages.SpyDialog_activeSelectionInterfaces_desc, interfaces)); if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; int size = ss.size(); if (size == 1) { clazz = ss.getFirstElement().getClass(); buffer.append( toolkit.createClassSection( text, MDERuntimeMessages.SpyDialog_activeSelectedElement_desc, new Class[] {clazz})); interfaces = clazz.getInterfaces(); buffer.append( toolkit.createInterfaceSection( text, MDERuntimeMessages.SpyDialog_activeSelectedElementInterfaces_desc, interfaces)); } else if (size > 1) { buffer.append( NLS.bind( MDERuntimeMessages.SpyDialog_activeSelectedElementsCount_desc, new Integer(size))); } } buffer.append("</form>"); // $NON-NLS-1$ text.setText(buffer.toString(), true, false); } }