Search in sources :

Example 1 with TextConsoleViewer

use of org.eclipse.ui.console.TextConsoleViewer in project netxms by netxms.

the class ScriptingConsole method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    console = new IOConsole("Console", Activator.getImageDescriptor("icons/console.png"));
    viewer = new TextConsoleViewer(parent, console);
    viewer.setEditable(true);
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            actionCopy.setEnabled(viewer.canDoOperation(TextConsoleViewer.COPY));
        }
    });
    createActions();
    contributeToActionBars();
    createPopupMenu();
    activateContext();
    createInterpreter();
    runInterpreter();
}
Also used : TextConsoleViewer(org.eclipse.ui.console.TextConsoleViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IOConsole(org.eclipse.ui.console.IOConsole)

Example 2 with TextConsoleViewer

use of org.eclipse.ui.console.TextConsoleViewer in project n4js by eclipse.

the class N4IDEXpectView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
    fillLayout.marginHeight = 5;
    fillLayout.marginWidth = 5;
    parent.setLayout(fillLayout);
    // main container
    container = new Composite(parent, SWT.BORDER);
    container.setLayout(new FillLayout());
    // create container for stack trace data
    Composite stacktraceDataContainer = new Composite(parent, SWT.BORDER);
    FormLayout formLayout = new FormLayout();
    formLayout.marginHeight = 5;
    formLayout.marginWidth = 5;
    formLayout.spacing = 5;
    stacktraceDataContainer.setLayout(formLayout);
    Composite stackLabelContainer = new Composite(stacktraceDataContainer, SWT.NO_SCROLL | SWT.SHADOW_NONE);
    stackLabelContainer.setLayout(new GridLayout());
    FormData stackLabelFormData = new FormData();
    stackLabelFormData.top = new FormAttachment(0);
    stackLabelFormData.left = new FormAttachment(0);
    stackLabelFormData.right = new FormAttachment(100);
    stackLabelFormData.bottom = new FormAttachment(20);
    stackLabelContainer.setLayoutData(stackLabelFormData);
    Composite stackTraceContainer = new Composite(stacktraceDataContainer, SWT.NO_SCROLL | SWT.SHADOW_NONE);
    stackTraceContainer.setLayout(new FillLayout());
    FormData stackTraceFormData = new FormData();
    stackTraceFormData.top = new FormAttachment(stackLabelContainer);
    stackTraceFormData.left = new FormAttachment(0);
    stackTraceFormData.right = new FormAttachment(100);
    stackTraceFormData.bottom = new FormAttachment(100);
    stackTraceContainer.setLayoutData(stackTraceFormData);
    // Create viewer for test tree in main container
    testTreeViewer = new TreeViewer(container);
    testTreeViewer.setContentProvider(new XpectContentProvider());
    testTreeViewer.setLabelProvider(new XpectLabelProvider(this.testsExecutionStatus));
    testTreeViewer.setInput(null);
    // create stack trace label
    stacktraceLabel = new Label(stackLabelContainer, SWT.SHADOW_OUT);
    FontData fontData = stacktraceLabel.getFont().getFontData()[0];
    Display display = Display.getCurrent();
    // may be null if outside the UI thread
    if (display == null)
        display = Display.getDefault();
    Font font = new Font(display, new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
    // Make stack trace label bold
    stacktraceLabel.setFont(font);
    stacktraceLabel.setText(NO_TRACE_MSG);
    // create stack trace console
    MessageConsole messageConsole = new MessageConsole("trace", null);
    stacktraceConsole = new TraceConsole(messageConsole);
    stacktraceConsoleViewer = new TextConsoleViewer(stackTraceContainer, messageConsole);
    // context menu
    getSite().setSelectionProvider(testTreeViewer);
    MenuManager contextMenu = new MenuManager();
    contextMenu.setRemoveAllWhenShown(true);
    getSite().registerContextMenu(contextMenu, testTreeViewer);
    Control control = testTreeViewer.getControl();
    Menu menu = contextMenu.createContextMenu(control);
    control.setMenu(menu);
    activateContext();
    createSelectionActions();
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) MessageConsole(org.eclipse.ui.console.MessageConsole) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) FontData(org.eclipse.swt.graphics.FontData) Label(org.eclipse.swt.widgets.Label) FillLayout(org.eclipse.swt.layout.FillLayout) Font(org.eclipse.swt.graphics.Font) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) TextConsoleViewer(org.eclipse.ui.console.TextConsoleViewer) MenuManager(org.eclipse.jface.action.MenuManager) Menu(org.eclipse.swt.widgets.Menu) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display)

Aggregations

TextConsoleViewer (org.eclipse.ui.console.TextConsoleViewer)2 MenuManager (org.eclipse.jface.action.MenuManager)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Font (org.eclipse.swt.graphics.Font)1 FontData (org.eclipse.swt.graphics.FontData)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 Display (org.eclipse.swt.widgets.Display)1 Label (org.eclipse.swt.widgets.Label)1 Menu (org.eclipse.swt.widgets.Menu)1 IOConsole (org.eclipse.ui.console.IOConsole)1 MessageConsole (org.eclipse.ui.console.MessageConsole)1