List of usage examples for org.eclipse.jface.viewers IStructuredSelection iterator
@Override
public Iterator iterator();
From source file:com.mentor.nucleus.bp.ui.graphics.actions.SetSystemColorAction.java
License:Open Source License
@Override public void run(IAction action) { if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; String transactionId = "Set Fill Color"; if (actionId.contains("setLine")) { transactionId = "Set Line Color"; }/* www . j a va2 s . c o m*/ Color color = getColorFromActionLabel(); // UI guarantees selection type // do the following in a transaction for undo/redo support TransactionManager manager = TransactionManager.getSingleton(); Transaction transaction = null; try { transaction = manager.startTransaction(transactionId, new ModelRoot[] { Ooaofooa.getDefaultInstance(), Ooaofgraphics.getDefaultInstance() }); for (Iterator<?> iterator = ss.iterator(); iterator.hasNext();) { GraphicalEditPart part = (GraphicalEditPart) iterator.next(); // fill is supported for diagrams, shapes and connectors GraphicalElement_c element = null; if (part.getModel() instanceof Shape_c) { element = GraphicalElement_c.getOneGD_GEOnR2((Shape_c) part.getModel()); } if (part.getModel() instanceof Connector_c) { element = GraphicalElement_c.getOneGD_GEOnR2((Connector_c) part.getModel()); } if (actionId.contains("setFill")) { Fillcolorstyle_c fcs = null; if (element != null) { fcs = Fillcolorstyle_c.getOneSTY_FCSOnR400(Elementstyle_c.getManySTY_SsOnR401(element)); } else { fcs = Fillcolorstyle_c.getOneSTY_FCSOnR400( Elementstyle_c.getManySTY_SsOnR402((Model_c) part.getModel())); } if (fcs == null) { // create fill style and associate with graphic fcs = new Fillcolorstyle_c(((NonRootModelElement) part.getModel()).getModelRoot()); fcs.setRed(color.getRed()); fcs.setBlue(color.getBlue()); fcs.setGreen(color.getGreen()); Elementstyle_c style = new Elementstyle_c( ((NonRootModelElement) part.getModel()).getModelRoot()); style.relateAcrossR400To(fcs); if (part.getModel() instanceof Model_c) { style.relateAcrossR402To((Model_c) part.getModel()); } else { style.relateAcrossR401To(element); } } else { fcs.setRed(color.getRed()); fcs.setBlue(color.getBlue()); fcs.setGreen(color.getGreen()); } } else { Linecolorstyle_c lcs = Linecolorstyle_c .getOneSTY_LCSOnR400(Elementstyle_c.getManySTY_SsOnR401(element)); if (lcs == null) { // create fill style and associate with graphic lcs = new Linecolorstyle_c(((NonRootModelElement) part.getModel()).getModelRoot()); lcs.setRed(color.getRed()); lcs.setBlue(color.getBlue()); lcs.setGreen(color.getGreen()); Elementstyle_c style = new Elementstyle_c( ((NonRootModelElement) part.getModel()).getModelRoot()); style.relateAcrossR400To(lcs); style.relateAcrossR401To(element); } else { lcs.setRed(color.getRed()); lcs.setBlue(color.getBlue()); lcs.setGreen(color.getGreen()); } } } manager.endTransaction(transaction); } catch (Exception e) { if (transaction != null) { manager.cancelTransaction(transaction); } CorePlugin.logError("Unable to process fill color transaction.", e); } } }
From source file:com.mentor.nucleus.bp.ui.graphics.editor.GraphicalEditor.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//w ww . j a va 2 s. co m protected void createActions() { super.createActions(); // 'New' is provided as a sub-menu only. See 'createMenus' open = new Action(OPEN) { public void run() { handleOpen(null, fModel, (IStructuredSelection) getGraphicalViewer().getSelectionManager().getSelection()); } }; open.setText("Open"); open.setToolTipText("Open this model Element"); // 'Open With' is provided as a sub-menu only. See 'createMenus' cut = new CanvasCutAction(this); cut.setId(ActionFactory.CUT.getId()); copy = new CanvasCopyAction(this); copy.setId(ActionFactory.COPY.getId()); getActionRegistry().registerAction(copy); getActionRegistry().registerAction(cut); // line paste = new CanvasPasteAction(this); paste.setId(ActionFactory.PASTE.getId()); getActionRegistry().registerAction(paste); TransactionManager manager = getTransactionManager(); undo = manager.getUndoAction(); undo.setId(ActionFactory.UNDO.getId()); redo = manager.getRedoAction(); redo.setId(ActionFactory.REDO.getId()); getActionRegistry().registerAction(undo); getActionRegistry().registerAction(redo); selectAll = new SelectAllAction(this) { @Override public void run() { GraphicalViewer viewer = (GraphicalViewer) getAdapter(GraphicalViewer.class); if (viewer != null) { viewer.setSelection(new StructuredSelection(filterOutTextEditParts( getAllSymbols(getGraphicalViewer(), fModel.Hascontainersymbol())))); } } private List<GraphicalEditPart> filterOutTextEditParts(List<GraphicalEditPart> allSymbols) { List<GraphicalEditPart> filtered = new ArrayList<GraphicalEditPart>(); for (GraphicalEditPart part : allSymbols) { // we filter text edit parts as they are not really selectable, // which in-turn causes duplicates in the selection list as they // are migrated to their owning part if (!(part instanceof TextEditPart)) { filtered.add(part); } } return filtered; } }; selectAll.setId(ActionFactory.SELECT_ALL.getId()); getActionRegistry().registerAction(selectAll); // // Delete and Rename are retargetable actions defined by core. // delete = new Action() { public void run() { Transaction transaction = null; TransactionManager manager = getTransactionManager(); try { transaction = manager.startTransaction(Transaction.DELETE_TRANS, new ModelRoot[] { Ooaofooa.getDefaultInstance(), Ooaofgraphics.getDefaultInstance() }); IStructuredSelection structuredSelection = Selection.getInstance().getStructuredSelection(); Iterator<?> iterator = structuredSelection.iterator(); while (iterator.hasNext()) { NonRootModelElement element = (NonRootModelElement) iterator.next(); if (element instanceof GraphicalElement_c) { ((GraphicalElement_c) element).Dispose(); Selection.getInstance().removeFromSelection(element); } } if (!Selection.getInstance().getStructuredSelection().isEmpty()) { CorePlugin.getDeleteAction().run(); } manager.endTransaction(transaction); } catch (TransactionException e) { if (transaction != null && manager != null && manager.getActiveTransaction() == transaction) manager.cancelTransaction(transaction); CorePlugin.logError("Unable to start transaction", e); } for (Object part : getGraphicalViewer().getSelectedEditParts()) { if (part instanceof EditPart) { if (((EditPart) part).getParent() != null) { ((EditPart) part).getParent().refresh(); } } } } @Override public boolean isEnabled() { return CanvasEditorContextMenuProvider .enableDelete((IStructuredSelection) getSite().getSelectionProvider().getSelection()); } }; delete.setText("Delete"); delete.setToolTipText("Delete the Model Element"); delete.setId(ActionFactory.DELETE.getId()); getActionRegistry().registerAction(delete); // rename = CorePlugin.getRenameAction(treeViewer); <- need to // generalize renameAction first rename = new Action() { public void run() { Object selection = Selection.getInstance().getStructuredSelection().getFirstElement(); if (selection != null) { String oldName = Cl_c.Getname(selection); Shell sh = getSite().getShell(); RenameAction.handleRename(selection, oldName, sh); } } @Override public boolean isEnabled() { if (CanvasCutAction.selectionContainsOnlyCoreElements()) { return RenameAction.canRenameAction(); } return false; } }; rename.setText("Rename"); rename.setToolTipText("Rename the Model Element"); rename.setEnabled(true); // Retargetable Actions work removes this line rename.setId(ActionFactory.RENAME.getId()); getActionRegistry().registerAction(rename); print = new Action() { public void run() { handlePrint(); } }; print.setText("Print"); print.setToolTipText("Print the Diagram"); print.setEnabled(true); print.setId(ActionFactory.PRINT.getId()); getActionRegistry().registerAction(print); ActionRegistry registry = getActionRegistry(); IAction action; action = new Action() { @Override public void run() { zoomAll(); } }; action.setText("Zoom Page"); action.setImageDescriptor(CorePlugin.getImageDescriptor("zoomAll.gif")); // $NON-NLS-1$ action.setId(GraphicalActionConstants.ZOOM_PAGE); action.setToolTipText("Click to zoom the entire contents"); registry.registerAction(action); action = new Action() { @Override public void run() { zoomSelected(); } }; action.setText("Zoom Selection"); action.setImageDescriptor(CorePlugin.getImageDescriptor("zoomSel.gif")); // $NON-NLS-1$ action.setId(GraphicalActionConstants.ZOOM_SEL); action.setToolTipText("Click to zoom the current selection"); registry.registerAction(action); action = new MatchWidthAction(this); registry.registerAction(action); getSelectionActions().add(action.getId()); action = new MatchHeightAction(this); registry.registerAction(action); getSelectionActions().add(action.getId()); action = new DirectEditAction((IWorkbenchPart) this); registry.registerAction(action); getSelectionActions().add(action.getId()); action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.LEFT); registry.registerAction(action); getSelectionActions().add(action.getId()); action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.RIGHT); registry.registerAction(action); getSelectionActions().add(action.getId()); action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.TOP); registry.registerAction(action); getSelectionActions().add(action.getId()); action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.BOTTOM); registry.registerAction(action); getSelectionActions().add(action.getId()); action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.CENTER); registry.registerAction(action); getSelectionActions().add(action.getId()); action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.MIDDLE); registry.registerAction(action); getSelectionActions().add(action.getId()); }
From source file:com.mentor.nucleus.bp.ui.graphics.editor.GraphicalEditor.java
License:Open Source License
/** * Fire up an editor//w w w .j a v a 2 s . co m */ public static void handleOpen(Point location, Model_c model, IStructuredSelection selection) { if (!selection.isEmpty()) { Object current = selection.iterator().next(); if (current instanceof EditPart) { current = ((EditPart) current).getModel(); if (current instanceof FloatingText_c) { FloatingText_c text = (FloatingText_c) current; Connector_c connector = Connector_c.getOneGD_CONOnR8(text); if (connector != null) current = connector; Shape_c shape = Shape_c.getOneGD_SHPOnR27(text); if (shape != null) current = shape; } if (current instanceof Model_c) { current = ((Model_c) current).getRepresents(); } else if (current instanceof Shape_c) { GraphicalElement_c elem = GraphicalElement_c.getOneGD_GEOnR2((Shape_c) current); current = elem.getRepresents(); } else if (current instanceof Connector_c) { GraphicalElement_c elem = GraphicalElement_c.getOneGD_GEOnR2((Connector_c) current); current = elem.getRepresents(); } } // if a mouse event was given, and the selected element is a // model-class if (location != null && current instanceof ModelClass_c) { // find the graphical element that represents the selected // model-class final Object finalCurrent = current; GraphicalElement_c element = GraphicalElement_c.GraphicalElementInstance(model.getModelRoot(), new ClassQueryInterface_c() { public boolean evaluate(Object candidate) { return ((GraphicalElement_c) candidate).getRepresents() == finalCurrent; } }); // ask the shape associated with the above graphical-element // what // the mouse-event represents a double-click on, since the shape // may be displaying an icon which is a link to a different // model // element Shape_c shape = Shape_c.getOneGD_SHPOnR2(element); Graphelement_c graphElement = Graphelement_c.getOneDIM_GEOnR23(element); current = shape.Getrepresents((int) (location.x - graphElement.getPositionx()), (int) (location.y - graphElement.getPositiony())); } // see if the current element should open // something other than itself current = EditorUtil.getElementToEdit(current); String name = current.getClass().getName(); // // Get the registry // IExtensionRegistry reg = Platform.getExtensionRegistry(); // // Get all the plugins that have extended this point // IExtensionPoint extPt = reg.getExtensionPoint("com.mentor.nucleus.bp.core.editors"); //$NON-NLS-1$ IExtension[] exts = extPt.getExtensions(); // Repeat for each extension until we find a default editor for (int i = 0; i < exts.length; i++) { IConfigurationElement[] elems = exts[i].getConfigurationElements(); for (int j = 0; j < elems.length; j++) { // Find the editor elements if (elems[j].getName().equals("editor")) { //$NON-NLS-1$ IConfigurationElement[] edElems = elems[j].getChildren(); for (int k = 0; k < edElems.length; k++) { // // Is this editor the default for the current model // element ? // if (edElems[k].getName().equals("defaultFor") && //$NON-NLS-1$ edElems[k].getAttribute("class").equals(name)) { try { // // Get the class supplied for the input // // always use this bundle, other graphical // plug-ins // will provide their own open method Bundle bundle = Platform.getBundle(elems[j].getContributor().getName()); Class<?> inputClass = bundle.loadClass(elems[j].getAttribute("input")); //$NON-NLS-1$ Class<?>[] type = new Class[1]; type[0] = Object.class; // // Dynamically get the method // createInstance, the supplied class must // implement this // Method createInstance = inputClass.getMethod("createInstance", type); //$NON-NLS-1$ Object[] args = new Object[1]; args[0] = current; // // Invoke the method. // The method is static; no instance is // needed, so first argument is null // IEditorInput input = (IEditorInput) createInstance.invoke(null, args); // // pass the input to the Eclipse editor, // along with the class name supplied by // the extending plugin. // if (input != null) { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .openEditor(input, elems[j].getAttribute("class")); //$NON-NLS-1$ } return; } catch (ClassNotFoundException e) { CanvasPlugin.logError("Input Class not found", e); //$NON-NLS-1$ } catch (NoSuchMethodException e) { CanvasPlugin.logError("Class does not implement static method createInstance", //$NON-NLS-1$ e); } catch (InvocationTargetException e) { CanvasPlugin.logError( "Exception occured on invocation of static method createInstance of the Target", //$NON-NLS-1$ e.getTargetException()); } catch (IllegalAccessException e) { CanvasPlugin.logError("Target does not support static method createInstance", //$NON-NLS-1$ e); } catch (PartInitException e) { CanvasPlugin.logError("Could not activate Editor", e); //$NON-NLS-1$ } } } } } } } }
From source file:com.mentor.nucleus.bp.ui.graphics.providers.CanvasEditorContextMenuProvider.java
License:Open Source License
public static boolean enableDelete(IStructuredSelection graphicalSelection) { boolean enableDel = false; List<Object> elements = new ArrayList<Object>(); IStructuredSelection selection = Selection.getInstance().getStructuredSelection(); if (!selection.isEmpty()) { if (graphicalSelection.getFirstElement() instanceof DiagramEditPart) return false; enableDel = true;/*from w w w .ja v a2 s . c o m*/ // Iterate through removing elements that are only graphical for (Iterator<?> iter = selection.iterator(); iter.hasNext();) { Object current = iter.next(); if (current instanceof GraphicalElement_c) { GraphicalElement_c ge = (GraphicalElement_c) current; if (ge.getRepresents() == null) { elements.add(current); Selection.getInstance().removeFromSelection(ge); } } } } selection = Selection.getInstance().getStructuredSelection(); if (!selection.isEmpty()) { // Check the remaining items against the usual DeleteAction, enableDel = DeleteAction.canDeleteAction(); } // Add the graphical only elements back to the selection for (int i = 0; i < elements.size(); ++i) { Selection.getInstance().addToSelection(elements.get(i)); } return enableDel; }
From source file:com.mentor.nucleus.bp.ui.search.pages.ModelSearchPage.java
License:Open Source License
private NonRootModelElement[] getElementsFromSelection(NonRootModelElement[] coreSelected) { // if the selection contains files, folders, or projects // locate the NonRootModelElement instances ISelection selection = getContainer().getSelection(); // if the selection does not contain projects/files/folders // then default to core selection boolean foundResource = false; IStructuredSelection ss = (IStructuredSelection) selection; for (Iterator<?> selIterator = ss.iterator(); selIterator.hasNext();) { Object next = selIterator.next(); if (next instanceof IResource) { foundResource = true;// w ww.ja v a2s. c om break; } } if (selection.equals(Selection.getInstance().getSelection()) || foundResource == false) { return coreSelected; } else { // not a bp selection, proceed List<NonRootModelElement> elementSelection = new ArrayList<NonRootModelElement>(); for (Iterator<?> iterator = ss.iterator(); iterator.hasNext();) { Object next = iterator.next(); processSelectedObject(next, elementSelection); } return elementSelection.toArray(new NonRootModelElement[elementSelection.size()]); } }
From source file:com.mentor.nucleus.bp.ui.search.pages.ModelSearchPage.java
License:Open Source License
private NonRootModelElement[] getSystemsFromSelection() { // process the selection, finding all systems within IStructuredSelection selection = (IStructuredSelection) getContainer().getSelection(); List<NonRootModelElement> selected = new ArrayList<NonRootModelElement>(); for (Iterator<?> iterator = selection.iterator(); iterator.hasNext();) { Object next = iterator.next(); if (next instanceof NonRootModelElement) { SystemModel_c system = getProjectForElement((NonRootModelElement) next); if (!selected.contains(system)) { selected.add(system);//from w w w .jav a 2 s . com } } else { // only concerned with IProject, IFolder, and IFile if (next instanceof IProject) { SystemModel_c system = getSystemFromProject((IProject) next); if (!selected.contains(system)) { selected.add(system); } } else { if (next instanceof IResource) { IProject project = ((IResource) next).getProject(); SystemModel_c system = getSystemFromProject(project); if (!selected.contains(system)) { selected.add(system); } } } } } return selected.toArray(new NonRootModelElement[selected.size()]); }
From source file:com.mentor.nucleus.bp.ui.text.activity.ParseAllActivitiesAction.java
License:Open Source License
public void run(IAction action) { IRunnableWithProgress rwp = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { IStructuredSelection selection = Selection.getInstance().getStructuredSelection(); for (Iterator iterator = selection.iterator(); iterator.hasNext();) { Object context = iterator.next(); if (context instanceof Domain_c) { ModelRoot.disableChangeNotification(); try { AllActivityModifier aam = new AllActivityModifier((Domain_c) context, monitor); aam.processAllActivities(AllActivityModifier.PARSE); } finally { ModelRoot.enableChangeNotification(); }// ww w .j a va2 s .com } else if (context instanceof Component_c) { ModelRoot.disableChangeNotification(); try { AllActivityModifier aam = new AllActivityModifier((Component_c) context, monitor); aam.processAllActivities(AllActivityModifier.PARSE); } finally { ModelRoot.enableChangeNotification(); } } else if (context instanceof Package_c) { ModelRoot.disableChangeNotification(); try { AllActivityModifier aam = new AllActivityModifier((Package_c) context, monitor); aam.processAllActivities(AllActivityModifier.PARSE); } finally { ModelRoot.enableChangeNotification(); } } } } }; try { // can't fork this as we need this to run in main thread when // a domain load is forced new ProgressMonitorDialog(Display.getCurrent().getActiveShell()).run(false, true, rwp); } catch (InterruptedException ie) { TextPlugin.logError("ParseAllActivitiesAction", ie); } catch (InvocationTargetException ite) { TextPlugin.logError("ParseAllActivitiesAction", ite); } }
From source file:com.mentor.nucleus.bp.utilities.actions.CheckModelIntegrity.java
License:Open Source License
@Override public void run(IAction action) { UUID managerId = UUID.randomUUID(); IntegrityManager_c manager = new IntegrityManager_c(Ooaofooa.getDefaultInstance(), managerId, null, null); List<IntegrityIssue_c> issues = new ArrayList<IntegrityIssue_c>(); IStructuredSelection ss = (IStructuredSelection) selection; for (Iterator<?> iterator = ss.iterator(); iterator.hasNext();) { NonRootModelElement element = (NonRootModelElement) iterator.next(); issues.addAll(Arrays.asList(IntegrityChecker.runIntegrityCheck(element, manager))); }//from w ww.j ava 2s. c o m SystemModel_c system = SystemModel_c.getOneS_SYSOnR1301(manager); if (system != null) { system.unrelateAcrossR1301From(manager); } IntegrityIssue_c[] relatedIssues = IntegrityIssue_c.getManyMI_IIsOnR1300(manager); for (IntegrityIssue_c issue : relatedIssues) { issue.Dispose(); } manager.delete(); }
From source file:com.mercatis.lighthouse3.ui.environment.handlers.RefreshHandler.java
License:Apache License
public Object execute(ExecutionEvent event) throws ExecutionException { Object activePart = HandlerUtil.getActivePart(event); if (!(activePart instanceof CommonNavigator)) return null; final CommonNavigator navigator = (CommonNavigator) activePart; ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection == null || !(selection instanceof IStructuredSelection)) return null; IStructuredSelection structuredSelection = (IStructuredSelection) selection; Iterator<?> it = structuredSelection.iterator(); while (it.hasNext()) { Object obj = it.next();//from w w w. ja v a2 s .com DomainBoundEntityAdapter adapter = (DomainBoundEntityAdapter) Platform.getAdapterManager() .getAdapter(obj, DomainBoundEntityAdapter.class); LighthouseDomain domain = adapter.getLighthouseDomain(obj); RefreshJob job = new RefreshJob(domain); job.addJobChangeListener(new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { navigator.getCommonViewer().refresh(); } }); } }); job.schedule(); } return null; }
From source file:com.mercatis.lighthouse3.ui.event.views.controls.GeneralEventControl.java
License:Apache License
public GeneralEventControl(Composite parent, FormToolkit toolkit) { component = new Composite(parent, SWT.FILL); toolkit.adapt(component);/*from www . j av a 2s . c o m*/ GridLayout layout = new GridLayout(1, false); component.setLayout(layout); GridData defaultSectionData = new GridData(); defaultSectionData.grabExcessHorizontalSpace = true; defaultSectionData.horizontalAlignment = SWT.FILL; GridData generalSectionData = new GridData(SWT.FILL, SWT.FILL, true, true); generalSectionData.minimumHeight = 300; // the section for the general event information final Section generalSection = toolkit.createSection(component, Section.TITLE_BAR | Section.EXPANDED); generalSection.setLayoutData(generalSectionData); generalSection.setText("Event Details"); final Composite generalComposite = toolkit.createComposite(generalSection, SWT.FILL); generalComposite.setLayout(new GridLayout(2, false)); generalComposite.setLayoutData(generalSectionData); GridData horizontalGrowData = new GridData(SWT.FILL, SWT.FILL, true, true); horizontalGrowData.horizontalAlignment = SWT.FILL; horizontalGrowData.grabExcessHorizontalSpace = true; horizontalGrowData.verticalAlignment = SWT.CENTER; horizontalGrowData.grabExcessVerticalSpace = false; toolkit.createLabel(generalComposite, "Deployment:"); deploymentLink = toolkit.createHyperlink(generalComposite, "", SWT.FILL); deploymentLink.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); deploymentLink.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(final HyperlinkEvent e) { Deployment deployment = (Deployment) event.getContext(); LighthouseDomain lighthouseDomain = CommonBaseActivator.getPlugin().getDomainService() .getLighthouseDomainByEntity(deployment); GenericEditorInput<Deployment> input = new GenericEditorInput<Deployment>(lighthouseDomain, deployment); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { IDE.openEditor(page, input, DeploymentEditor.class.getName()); } catch (PartInitException ex) { CommonUIActivator.getPlugin().getLog() .log(new Status(IStatus.ERROR, CommonUIActivator.PLUGIN_ID, ex.getMessage(), ex)); } } }); toolkit.createLabel(generalComposite, "Code:"); codeText = toolkit.createText(generalComposite, ""); codeText.setLayoutData(horizontalGrowData); codeText.setEditable(false); toolkit.createLabel(generalComposite, "Level:"); levelText = toolkit.createText(generalComposite, ""); levelText.setLayoutData(horizontalGrowData); levelText.setEditable(false); toolkit.createLabel(generalComposite, "Date:"); dateText = toolkit.createText(generalComposite, ""); dateText.setLayoutData(horizontalGrowData); dateText.setEditable(false); toolkit.createLabel(generalComposite, "Origin:"); originText = toolkit.createText(generalComposite, ""); originText.setLayoutData(horizontalGrowData); originText.setEditable(false); toolkit.createLabel(generalComposite, "Message:"); messageText = toolkit.createText(generalComposite, "", SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); GridData messageTextData = new GridData(SWT.FILL, SWT.FILL, true, true); messageTextData.horizontalSpan = 2; messageTextData.heightHint = 100; messageText.setLayoutData(messageTextData); messageText.setEditable(false); generalSection.setClient(generalComposite); // the section for the transaction ids final Section Section transactionIdsSection = toolkit.createSection(component, Section.TITLE_BAR | Section.EXPANDED); transactionIdsSection.setText("Transaction Ids"); transactionIdsSection.setLayoutData(defaultSectionData); GridData listViewerData = new GridData(SWT.FILL, SWT.FILL, true, true); listViewerData.heightHint = 100; final Composite transactionIdsComposite = toolkit.createComposite(transactionIdsSection, SWT.FILL); transactionIdsComposite.setLayout(new GridLayout(1, false)); transactionIdsListViewer = new ListViewer(transactionIdsComposite, SWT.V_SCROLL | SWT.BORDER | SWT.H_SCROLL); transactionIdsListViewer.setContentProvider(new ArrayContentProvider()); transactionIdsListViewer.getControl().setLayoutData(listViewerData); transactionIdsSection.setClient(transactionIdsComposite); // the section for the tags final Section tagsSection = Section tagsSection = toolkit.createSection(component, Section.TITLE_BAR | Section.EXPANDED); tagsSection.setText("Tags"); tagsSection.setLayoutData(defaultSectionData); final Composite tagsComposite = toolkit.createComposite(tagsSection, SWT.FILL); tagsComposite.setLayout(new GridLayout(2, false)); tagsListViewer = new ListViewer(tagsComposite, SWT.V_SCROLL | SWT.BORDER | SWT.H_SCROLL); tagsListViewer.setContentProvider(new ArrayContentProvider()); tagsListViewer.getControl().setLayoutData(listViewerData); final Button removeTagButton = toolkit.createButton(tagsComposite, "-", SWT.PUSH); removeTagButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) tagsListViewer.getSelection(); Iterator<String> selectionIterator = selection.iterator(); while (selectionIterator.hasNext()) { String tag = selectionIterator.next(); if (tag != null && tag.length() > 0) { event.removeTag(tag); } } CommonBaseActivator.getPlugin().getEventService().updateEvent(event); EventUpdateService.getInstance().fireEventUpdate(event); } }); removeTagButton.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); tagText = toolkit.createText(tagsComposite, "", SWT.BORDER); tagText.setLayoutData(horizontalGrowData); tagText.setEditable(false); final Button addTagButton = toolkit.createButton(tagsComposite, "+", SWT.PUSH); addTagButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { String tag = tagText.getText(); if (tag != null && tag.length() > 0) { event.tag(tagText.getText()); tagText.setText(""); CommonBaseActivator.getPlugin().getEventService().updateEvent(event); EventUpdateService.getInstance().fireEventUpdate(event); } } }); tagsSection.setClient(tagsComposite); }