@Override protected void createMasterPart(IManagedForm managedForm, Composite parent) { // TODO Auto-generated method stub fManagedForm = managedForm; FormToolkit toolkit = managedForm.getToolkit(); Composite composite = toolkit.createComposite(parent); composite.setLayout(new GridLayout(1, false)); Section section = toolkit.createSection(composite, Section.TITLE_BAR); section.setText("overlay"); Composite viewercomposite = toolkit.createComposite(composite, SWT.NONE); viewercomposite.setLayout(new GridLayout(2, false)); viewercomposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final Tree tree = toolkit.createTree(viewercomposite, SWT.BORDER); fTreeViewer = new TreeViewer(tree); // fTreeViewer.setContentProvider(new XULTreeContentProvider()); // fTreeViewer.setLabelProvider(new XULLabelProvider()); MenuManager menu_manager = new MenuManager(); // final Action addmenu = new AddAction("add"); // menu_manager.add(addmenu); }
/** * Creates the master part of the master-details block. * * @param managedForm managed for for toolkit reference * @param parent composite parent for the part; we put a new composite on it */ protected void createMasterPart(final IManagedForm managedForm, Composite parent) { // final ScrolledForm form = managedForm.getForm(); FormToolkit toolkit = managedForm.getToolkit(); Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR); section.setText("Contributed Examples"); section.setDescription("Select a category or example for details"); section.marginWidth = 10; section.marginHeight = 5; toolkit.createCompositeSeparator(section); Composite client = toolkit.createComposite(section, SWT.WRAP); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; layout.marginHeight = 0; client.setLayout(layout); Tree t = toolkit.createTree(client, SWT.NULL); GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 300; gd.widthHint = 200; t.setLayoutData(gd); toolkit.paintBordersFor(client); section.setClient(client); final SectionPart spart = new SectionPart(section); managedForm.addPart(spart); TreeViewer viewer = new TreeViewer(t); viewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { managedForm.fireSelectionChanged(spart, event.getSelection()); wizardPage.setSelectedNode(event.getSelection()); } }); viewer.setContentProvider(new MasterContentProvider()); viewer.setLabelProvider(new MasterLabelProvider()); viewer.setInput(ec); viewer.expandAll(); }
/** Initializes the widgets on the left side. */ protected void createLeftWidgets() { FormToolkit toolkit = this.ise.getFormToolkit(); Composite container = toolkit.createComposite(this); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginTop = 11; layout.marginRight = 7; container.setLayout(layout); container.setLayoutData(new GridData(GridData.FILL_BOTH)); Section section = toolkit.createSection( container, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED); section.setLayoutData(new GridData(GridData.FILL_BOTH)); section.clientVerticalSpacing = 10; section.setText("Service Assembly's Content"); section.setDescription("Select the elements to edit."); container = toolkit.createComposite(section); layout = new GridLayout(2, false); layout.marginWidth = 0; container.setLayout(layout); container.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); section.setClient(container); // Add the tree Tree tree = toolkit.createTree(container, SWT.BORDER | SWT.MULTI); this.viewer = new TreeViewer(tree); this.viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH)); // Add the content provider this.labelProvider = new ServicesLabelProvider(); this.viewer.setLabelProvider(this.labelProvider); this.viewer.setContentProvider( new DefaultTreeContentProvider() { @Override public Object[] getElements(Object inputElement) { Object o = SaEditionComposite.this.ise.getJbiModel().getServiceAssembly(); return new Object[] {o}; } @Override public boolean hasChildren(Object element) { return getChildren(element).length > 0; } @Override public Object getParent(Object element) { return null; } @Override public Object[] getChildren(Object parentElement) { Object[] result = new Object[0]; if (parentElement instanceof ServiceAssembly) result = ((ServiceAssembly) parentElement).getServiceUnit().toArray(); return result; } }); this.viewer.setInput(new Object()); // Add the buttons Composite buttonsComposite = toolkit.createComposite(container); layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; buttonsComposite.setLayout(layout); buttonsComposite.setLayoutData(new GridData(SWT.DEFAULT, SWT.TOP, false, false)); Button newSuButton = this.ise.getFormToolkit().createButton(buttonsComposite, "New...", SWT.PUSH); newSuButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); newSuButton.setImage(PetalsImages.getAdd()); newSuButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // Select a SU project List<IProject> suProjects = ServiceProjectRelationUtils.getAllSuProjects(); ListDialog dlg = new ListDialog(new Shell()); dlg.setAddCancelButton(true); dlg.setContentProvider(new ArrayContentProvider()); dlg.setLabelProvider(new WorkbenchLabelProvider()); dlg.setInput(suProjects); dlg.setTitle("Service Unit Selection"); dlg.setMessage("Select a Service Unit project."); if (dlg.open() != Window.OK) return; // Create the SU element IProject selectedProject = (IProject) dlg.getResult()[0]; ServiceUnit su = JbiFactory.eINSTANCE.createServiceUnit(); Identification id = JbiFactory.eINSTANCE.createIdentification(); id.setName(selectedProject.getName()); id.setDescription(""); su.setIdentification(id); Target target = JbiFactory.eINSTANCE.createTarget(); target.setArtifactsZip(selectedProject.getName() + ".zip"); Properties properties = PetalsSPPropertiesManager.getProperties(selectedProject); String componentName = properties.getProperty(PetalsSPPropertiesManager.COMPONENT_DEPLOYMENT_ID, ""); target.setComponentName(componentName); su.setTarget(target); EList<?> list = SaEditionComposite.this.ise.getJbiModel().getServiceAssembly().getServiceUnit(); AddCommand addCommand = new AddCommand(SaEditionComposite.this.ise.getEditingDomain(), list, su); SaEditionComposite.this.ise.getEditingDomain().getCommandStack().execute(addCommand); // Update the viewers SaEditionComposite.this.viewer.refresh(); SaEditionComposite.this.viewer.expandAll(); SaEditionComposite.this.viewer.setSelection(new StructuredSelection(su)); SaEditionComposite.this.viewer.getTree().notifyListeners(SWT.Selection, new Event()); SaEditionComposite.this.viewer.getTree().setFocus(); } }); final Button removeProvidesButton = this.ise.getFormToolkit().createButton(buttonsComposite, "Remove", SWT.PUSH); removeProvidesButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); removeProvidesButton.setImage(PetalsImages.getDelete()); removeProvidesButton.addSelectionListener( new DefaultSelectionListener() { /* * (non-Javadoc) * @see org.eclipse.swt.events.SelectionListener * #widgetSelected(org.eclipse.swt.events.SelectionEvent) */ @Override public void widgetSelected(SelectionEvent e) { if (MessageDialog.openConfirm( getShell(), Messages.confimeRemoveEndpointTitle, Messages.confimeRemoveEndpointMessage)) { ServiceAssembly sa = SaEditionComposite.this.ise.getJbiModel().getServiceAssembly(); Object o = ((IStructuredSelection) SaEditionComposite.this.viewer.getSelection()) .getFirstElement(); RemoveCommand deleteCommand = new RemoveCommand( SaEditionComposite.this.ise.getEditingDomain(), sa.getServiceUnit(), o); SaEditionComposite.this .ise .getEditingDomain() .getCommandStack() .execute(deleteCommand); SaEditionComposite.this.pageBook.removePage(o); SaEditionComposite.this.viewer.refresh(); SaEditionComposite.this.viewer.expandAll(); SaEditionComposite.this.viewer.setSelection(new StructuredSelection(sa)); SaEditionComposite.this.viewer.getTree().notifyListeners(SWT.Selection, new Event()); } } }); final Button upProvidesButton = this.ise.getFormToolkit().createButton(buttonsComposite, "", SWT.PUSH); upProvidesButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); upProvidesButton.setText("&Up"); upProvidesButton.addSelectionListener( new DefaultSelectionListener() { /* * (non-Javadoc) * @see org.eclipse.swt.events.SelectionListener * #widgetSelected(org.eclipse.swt.events.SelectionEvent) */ @Override public void widgetSelected(SelectionEvent e) { EList<?> list = SaEditionComposite.this.ise.getJbiModel().getServiceAssembly().getServiceUnit(); Object o = ((IStructuredSelection) SaEditionComposite.this.viewer.getSelection()) .getFirstElement(); MoveCommand moveCommand = new MoveCommand( SaEditionComposite.this.ise.getEditingDomain(), list, o, list.indexOf(o) - 1); SaEditionComposite.this.ise.getEditingDomain().getCommandStack().execute(moveCommand); } }); final Button downProvidesButton = this.ise.getFormToolkit().createButton(buttonsComposite, "", SWT.PUSH); downProvidesButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); downProvidesButton.setText("&Down"); downProvidesButton.addSelectionListener( new DefaultSelectionListener() { /* * (non-Javadoc) * @see org.eclipse.swt.events.SelectionListener * #widgetSelected(org.eclipse.swt.events.SelectionEvent) */ @Override public void widgetSelected(SelectionEvent e) { EList<?> list = SaEditionComposite.this.ise.getJbiModel().getServiceAssembly().getServiceUnit(); Object o = ((IStructuredSelection) SaEditionComposite.this.viewer.getSelection()) .getFirstElement(); MoveCommand moveCommand = new MoveCommand( SaEditionComposite.this.ise.getEditingDomain(), list, o, list.indexOf(o) + 1); SaEditionComposite.this.ise.getEditingDomain().getCommandStack().execute(moveCommand); } }); this.viewer.addSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { Object o = ((IStructuredSelection) SaEditionComposite.this.viewer.getSelection()) .getFirstElement(); EList<?> sus = SaEditionComposite.this.ise.getJbiModel().getServiceAssembly().getServiceUnit(); boolean isSa = o instanceof ServiceAssembly; boolean isFirst = sus.indexOf(o) == 0; boolean isLast = sus.indexOf(o) == sus.size() - 1; downProvidesButton.setEnabled(!isSa && !isLast); upProvidesButton.setEnabled(!isSa && !isFirst); removeProvidesButton.setEnabled(!isSa); } }); }
protected void createFormContent(IManagedForm managedForm) { ScrolledForm form = managedForm.getForm(); form.setText(wrapper.getObjectName().toString()); FormToolkit toolkit = managedForm.getToolkit(); form.getForm().setSeparatorVisible(true); Composite body = form.getBody(); FontData fd[] = body.getFont().getFontData(); bold = new Font(body.getDisplay(), fd[0].getName(), fd[0].getHeight(), SWT.BOLD); GridLayout layout = new GridLayout(2, false); body.setLayout(layout); GridDataFactory defaultGridData = GridDataFactory.fillDefaults(); String className = wrapper.getMBeanInfo().getClassName(); toolkit.createLabel(body, Messages.className); Label classNameLabel = toolkit.createLabel(body, className, SWT.WRAP | SWT.READ_ONLY); classNameLabel.setFont(bold); classNameLabel.setLayoutData(defaultGridData.create()); String description = wrapper.getMBeanInfo().getDescription(); toolkit.createLabel(body, Messages.description); Text descriptionText = toolkit.createText(body, description, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY); descriptionText.setLayoutData(defaultGridData.create()); Section notifSection = toolkit.createSection(body, Section.TITLE_BAR | Section.TWISTIE | Section.TWISTIE); notifSection.setText(Messages.InfoPage_notificationsSectionTitle); GridDataFactory.fillDefaults().span(2, 1).grab(true, true).applyTo(notifSection); if (wrapper.getMBeanNotificationInfoWrappers().length == 0) { notifSection.setEnabled(false); notifSection.setExpanded(false); } else { notifSection.setEnabled(true); notifSection.setExpanded(true); } Composite notificationContainer = toolkit.createComposite(notifSection); notifSection.setClient(notificationContainer); GridLayoutFactory.fillDefaults().generateLayout(notificationContainer); Tree notificationTree = toolkit.createTree(notificationContainer, SWT.BORDER); GridDataFactory.fillDefaults().hint(500, 150).applyTo(notificationTree); TreeViewer notificationViewer = new TreeViewer(notificationTree); notificationViewer.setLabelProvider( new LabelProvider() { public String getText(Object element) { if (element instanceof MBeanNotificationInfoWrapper) { MBeanNotificationInfoWrapper notifWrapper = (MBeanNotificationInfoWrapper) element; return notifWrapper.getMBeanNotificationInfo().getName(); } return super.getText(element); } }); notificationViewer.setContentProvider( new ITreeContentProvider() { public Object[] getChildren(Object parent) { if (parent instanceof MBeanNotificationInfoWrapper) { MBeanNotificationInfoWrapper notifWrapper = (MBeanNotificationInfoWrapper) parent; return notifWrapper.getMBeanNotificationInfo().getNotifTypes(); } return new Object[0]; } public Object getParent(Object element) { return null; } public boolean hasChildren(Object element) { if (element instanceof MBeanNotificationInfoWrapper) { MBeanNotificationInfoWrapper notifWrapper = (MBeanNotificationInfoWrapper) element; return (notifWrapper.getMBeanNotificationInfo().getNotifTypes().length > 0); } return false; } public Object[] getElements(Object input) { return ((MBeanInfoWrapper) input).getMBeanNotificationInfoWrappers(); } public void dispose() {} public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }); notificationViewer.setInput(wrapper); }