@Override public void createPartControl(Composite parent) { final Composite main = new Composite(parent, SWT.NONE); main.setLayout(new GridLayout()); GridUtils.removeMargins(main); final Composite tools = new Composite(main, SWT.RIGHT); tools.setLayout(new GridLayout(2, false)); GridUtils.removeMargins(tools); tools.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); this.messageLabel = new CLabel(tools, SWT.NONE); final GridData gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false); gridData.widthHint = 230; messageLabel.setLayoutData(gridData); messageLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY)); messageLabel.setToolTipText( "Insert variables to the template xml on the right,\nthis will be replaced and sent to EDNA when the workflow is run."); ToolBarManager toolMan = new ToolBarManager(SWT.FLAT | SWT.LEFT); final ToolBar toolBar = toolMan.createControl(tools); toolBar.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); EdnaActorActions.createInputActions(toolMan); final SashForm sash = new SashForm(main, SWT.HORIZONTAL); sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); this.viewer = new TableViewer( sash, SWT.FULL_SELECTION | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); createColumns(viewer); viewer.getTable().setLinesVisible(true); viewer.getTable().setHeaderVisible(true); final Composite right = new Composite(sash, SWT.NONE); right.setLayout(new FillLayout()); super.createPartControl(right); sash.setWeights(new int[] {20, 80}); // Attached a painter to highlight the replacements final VariableCharacterMatcher matcher = new VariableCharacterMatcher(((SourceViewer) getSourceViewer())); final VariablePainter painter = new VariablePainter(getSourceViewer(), matcher); ((SourceViewer) getSourceViewer()).addPainter(painter); viewer.addSelectionChangedListener(matcher); viewer.addDoubleClickListener( new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { doInsert(); } }); ((SourceViewer) getSourceViewer()) .addSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { final ISelection sel = event.getSelection(); if (sel instanceof TextSelection) { XMLSubstitutionEditor.this.currentSelectedText = (TextSelection) sel; updateMessageLabel(); return; } XMLSubstitutionEditor.this.currentSelectedText = null; updateMessageLabel(); } }); toolMan.update(true); setWritable(true); getSite().setSelectionProvider(viewer); createUndoRedoActions(); createRightClickMenu(); }
private void createRightClickMenu() { final MenuManager menuManager = new MenuManager(); viewer.getControl().setMenu(menuManager.createContextMenu(viewer.getControl())); EdnaActorActions.createInputActions(menuManager); }