/** * @see * com.metamatrix.modeler.transformation.ui.builder.AbstractLanguageObjectEditor#createUi(org.eclipse.swt.widgets.Composite) */ @Override protected void createUi(Composite theParent) { pnlContent = new Composite(theParent, SWT.NONE); pnlContent.setLayoutData(new GridData(GridData.FILL_BOTH)); pnlContent.setLayout(new FillLayout()); // // pnlContent contents // viewer = ElementViewerFactory.createElementViewer(pnlContent); viewer.addDoubleClickListener( new IDoubleClickListener() { public void doubleClick(DoubleClickEvent theEvent) { handleDoubleClick(); } }); viewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent theEvent) { handleTreeSelection(); } }); viewer.expandAll(); }
/** Handler for tree selection. */ void handleTreeSelection() { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); ElementSymbol element = null; if (!selection.isEmpty()) { ICriteriaStrategy strategy = ElementViewerFactory.getCriteriaStrategy(viewer); strategy.setTreeViewer(viewer); // make sure this viewer is set before using strategy if (strategy.isValid(selection.getFirstElement())) { Object eObj = selection.getFirstElement(); if (eObj instanceof ElementSymbol) { element = ((ElementSymbol) eObj); } else { element = new ElementSymbol(strategy.getRuntimeFullName(eObj), true); // the viewer model contains EObjects. so the objects in the selection will // be EObjects. since the EObject is used later on in the QueryCriteriaStrategy.getNode() // method. save it here. element.setMetadataID(eObj); } } } model.selectElementSymbol(element); }
/** * Constructs a <code>ElementEditor</code> using the given model. * * @param theParent the parent container * @param theModel the editor's model * @throws IllegalArgumentException if any of the parameters are <code>null</code> */ public ElementEditor(Composite theParent, ElementEditorModel theModel) { super(theParent, ElementSymbol.class, theModel); controller = new ViewController(); model = theModel; model.addModelListener(controller); // set the viewer on the CriteriaStrategy strategy = ElementViewerFactory.getCriteriaStrategy(viewer); strategy.setTreeViewer(viewer); }