/** * enables a section by given id. More precisely, this * means setting the enablement state of any child of the * section that is a {@link Composite} but not a {@link Section} * to enabled. */ public void enableSection(String id, boolean enabled) { SectionPart part = sectionParts.get(id); if (part == null) { throw new IllegalArgumentException("No section for id"); } Section section = part.getSection(); Control[] children = section.getChildren(); for (int i = 0; i < children.length; i++) { if (children[i] instanceof Composite) { enableSectionComposite((Composite) children[i], enabled); } } }
/** * Adds a section to the manager * @param section * @param id * @param pageId */ public void bindSection(SectionPart sectionPart, String id, String pageId) { // store the section sectionParts.put(id, sectionPart); // store the page id pageForSection.put(id, pageId); Vector<String> sectionIds = sectionsForPage.get(pageId); if (sectionIds == null) { sectionIds = new Vector<String>(); sectionsForPage.put(pageId, sectionIds); } sectionIds.add(id); }
/** * Bind an attribute name <code>attributeName</code> to the viewer <code>attributeViewer</code> location in the section part <code>sectionPart</code> * This method should be called after the section is bound to the section id and page using {@link DataBindingManager#bindSection(SectionPart, String, String)} method * @param attributeName * @param attributeViewer * @param sectionPart */ public void bindAttribute(String attributeName, Object attributeViewer, SectionPart sectionPart) { // bind the viewer viewerForAttribute.put(attributeName, attributeViewer); // bind the section id Enumeration<String> enumeration = sectionParts.keys(); while (enumeration.hasMoreElements()) { String sectionId = enumeration.nextElement(); SectionPart registeredPart = sectionParts.get(sectionId); if (registeredPart.equals(sectionPart)) { sectionForAttribute.put(attributeName, sectionId); break; } } }
/** * expands a section by given section id */ public void expandSection(String id) { SectionPart part = sectionParts.get(id); if (part == null) { throw new IllegalArgumentException("No section for id"); } if (!part.getSection().isExpanded()) { part.getSection().setExpanded(true); } }
@Override protected void createFormContent(IManagedForm managedForm) { FormToolkit toolkit = managedForm.getToolkit(); ScrolledForm form = managedForm.getForm(); form.setText(getTitle()); form.setImage(MuleImages.GLOBALS_TITLE_IMAGE); //set the layout. TableWrapLayout layout = new TableWrapLayout(); layout.numColumns = 1; layout.makeColumnsEqualWidth = true; form.getBody().setLayout(layout); //configure the toolbar buttons configureFormToolbarButtons(toolkit, form); //add the two sections. SectionPart toolBar = addButtons(toolkit, form); managedForm.addPart(toolBar); TableWrapData toolbarData = new TableWrapData(TableWrapData.FILL_GRAB); toolbarData.rowspan = 1; toolbarData.valign = TableWrapData.FILL; toolBar.getSection().setLayoutData(toolbarData); GradleDependenciesTablePart depsTable = addDependenciesTable(toolkit, form); managedForm.addPart(depsTable); TableWrapData depsTableData = new TableWrapData(TableWrapData.FILL_GRAB); depsTableData.rowspan = 2; depsTableData.valign = TableWrapData.FILL; depsTable.getSection().setLayoutData(depsTableData); this.table = depsTable; table.refreshData(); }
/** * Expands the properties table. */ public void expandPropertiesSection() { final SectionPart section = getDataBindingManager().getSection(SEC_WHAT_TO_CHECK_PROPERTIES); section.getSection().setExpanded(true); }
protected void createMasterPart(final IManagedForm managedForm, Composite parent) { // final ScrolledForm form = managedForm.getForm(); IEditorInput input = page.getEditor().getEditorInput(); FormToolkit toolkit = managedForm.getToolkit(); Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR); section.setText(Messages.getString("NamespaceDetailsBlock.sname")); //$NON-NLS-1$ section.setDescription(Messages.getString("NamespaceDetailsBlock.sdesc")); //$NON-NLS-1$ section.marginWidth = 10; section.marginHeight = 5; Composite client = toolkit.createComposite(section, SWT.WRAP); Composite headerContainer = toolkit.createComposite(client, SWT.WRAP); toolkit.createLabel(headerContainer, "Select editor", SWT.NULL); //TODO Remove combo @SuppressWarnings("unused") final ComboPart comboPart = new ComboPart(headerContainer, toolkit, toolkit.getBorderStyle()); headerContainer.setVisible(false); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 2; layout.marginHeight = 2; headerContainer.setLayout(layout); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.heightHint = 20; gd.widthHint = 100; gd.horizontalSpan = 2; headerContainer.setLayoutData(gd); layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 2; layout.marginHeight = 2; client.setLayout(layout); Tree t = toolkit.createTree(client, SWT.NULL); gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 20; gd.widthHint = 100; t.setLayoutData(gd); toolkit.paintBordersFor(client); Button collapseButton = toolkit.createButton(client, Messages.getString("Collapse"), SWT.PUSH); //$NON-NLS-1$ gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); collapseButton.setLayoutData(gd); section.setClient(client); final SectionPart spart = new SectionPart(section); managedForm.addPart(spart); viewer = new TreeViewer(t); viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { managedForm.fireSelectionChanged(spart, event.getSelection()); } }); viewer.setContentProvider(new NamespaceContentProvider()); viewer.setLabelProvider(new NamespaceLabelProvider()); if (input != null) { viewer.setInput(new StudioUIFormEditorInput(input)); } else { viewer.setInput(new StudioUIFormEditorInput()); } viewer.expandToLevel(5); collapseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { viewer.collapseAll(); } }); configureMenu(viewer); }
/** * Retrieves the section by id * @param sectionId * @return the section part, or <code>null</code> if not found */ public SectionPart getSection(String sectionId) { return (SectionPart) sectionParts.get(sectionId); }