public Class<? extends XtextEditor> bindXtextEditor() { return XbaseEditor.class; }
/** * Create contents of the wizard. * * @param parent */ @SuppressWarnings("restriction") public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NULL); setControl(container); container.setLayout(new BorderLayout(0, 0)); Composite composite = new Composite(container, SWT.NONE); composite.setLayoutData(BorderLayout.NORTH); composite.setLayout(new FillLayout(SWT.HORIZONTAL)); GridLayout layout = new GridLayout(); composite.setLayout(layout); layout.numColumns = 2; Label desc = new Label(composite, SWT.RIGHT); desc.setText("Description"); Text descField = new Text(composite, SWT.None); descField.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { description = descField.getText(); } }); descField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); tree = new TreeViewer(container, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); tree.setContentProvider(new PatternContentProvider()); tree.setLabelProvider(new PatternLabelProvider()); tree.expandAll(); IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); if (editor instanceof XbaseEditor) { XbaseEditor xeditor = (XbaseEditor) editor; IXtextDocument document = xeditor.getDocument(); Object root = document.readOnly(new IUnitOfWork<Object, XtextResource>() { @Override public Object exec(XtextResource state) throws Exception { return state.getContents().get(0); } }); if (root != null && root instanceof PatternModel) { model = (PatternModel) root; if(model.getPatterns().isEmpty()) setPageComplete(false); else setPageComplete(true); tree.setInput(root); } } }