Search in sources :

Example 36 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project cubrid-manager by CUBRID.

the class MonitorStatisticEditor method createPartControl.

public void createPartControl(Composite parent) {
    parent.setLayout(new GridLayout(1, false));
    createToolBar(parent);
    scrolledComp = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    scrolledComp.setLayout(new FillLayout());
    scrolledComp.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    scrolledComp.getVerticalBar().setIncrement(10);
    scrolledComp.addListener(SWT.Activate, new Listener() {

        @Override
        public void handleEvent(Event event) {
            scrolledComp.setFocus();
        }
    });
    chartAreaRootComp = new Composite(scrolledComp, SWT.NONE);
    {
        final GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        chartAreaRootComp.setLayoutData(gd);
        GridLayout layout = new GridLayout(3, false);
        chartAreaRootComp.setLayout(layout);
        chartAreaRootComp.setBackground(COLOR_CHART_AREA_BACKGROUND);
    }
    statisticDataMap = refreshData(statisticItemList);
    createDataChart(chartAreaRootComp);
    createAddChart(chartAreaRootComp);
    createHiddenItems();
    scrolledComp.setExpandHorizontal(true);
    scrolledComp.setExpandVertical(true);
    scrolledComp.setContent(chartAreaRootComp);
    scrolledComp.setMinWidth(CHART_AREA_WIDTH);
    updateScrolledCompositeHeight();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FillLayout(org.eclipse.swt.layout.FillLayout)

Example 37 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project eclipse.platform.text by eclipse.

the class EncodingChangeTests method testChangeEncodingViaFile.

@Test
public void testChangeEncodingViaFile() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
    try {
        fFile.setCharset(NON_DEFAULT_ENCODING, null);
    } catch (CoreException ex) {
        fail();
    }
    try {
        fEditor = IDE.openEditor(page, fFile);
        if (fEditor instanceof TextEditor) {
            TextEditor editor = (TextEditor) fEditor;
            Accessor accessor = new Accessor(editor, StatusTextEditor.class);
            while (editor.getSite().getShell().getDisplay().readAndDispatch()) {
            }
            ScrolledComposite composite = (ScrolledComposite) accessor.get("fStatusControl");
            assertNull(composite);
            DefaultEncodingSupport encodingSupport = (DefaultEncodingSupport) editor.getAdapter(IEncodingSupport.class);
            assertEquals(NON_DEFAULT_ENCODING, encodingSupport.getEncoding());
        } else
            fail();
    } catch (PartInitException e) {
        fail();
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) DefaultEncodingSupport(org.eclipse.ui.editors.text.DefaultEncodingSupport) StatusTextEditor(org.eclipse.ui.texteditor.StatusTextEditor) TextEditor(org.eclipse.ui.editors.text.TextEditor) CoreException(org.eclipse.core.runtime.CoreException) IEncodingSupport(org.eclipse.ui.editors.text.IEncodingSupport) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) PartInitException(org.eclipse.ui.PartInitException) Accessor(org.eclipse.text.tests.Accessor) Test(org.junit.Test)

Example 38 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project eclipse.platform.text by eclipse.

the class EncodingChangeTests method testChangeEncodingViaEncodingSupport.

@Test
public void testChangeEncodingViaEncodingSupport() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
    try {
        fEditor = IDE.openEditor(page, fFile);
        if (fEditor instanceof TextEditor) {
            TextEditor editor = (TextEditor) fEditor;
            while (editor.getSite().getShell().getDisplay().readAndDispatch()) {
            }
            DefaultEncodingSupport encodingSupport = (DefaultEncodingSupport) editor.getAdapter(IEncodingSupport.class);
            encodingSupport.setEncoding(NON_DEFAULT_ENCODING);
            Accessor accessor = new Accessor(editor, StatusTextEditor.class);
            while (editor.getSite().getShell().getDisplay().readAndDispatch()) {
            }
            ScrolledComposite composite = (ScrolledComposite) accessor.get("fStatusControl");
            assertNull(composite);
            String actual = null;
            try {
                actual = fFile.getCharset(false);
            } catch (CoreException e1) {
                fail();
            }
            assertEquals(NON_DEFAULT_ENCODING, actual);
        } else
            fail();
    } catch (PartInitException e) {
        fail();
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) DefaultEncodingSupport(org.eclipse.ui.editors.text.DefaultEncodingSupport) StatusTextEditor(org.eclipse.ui.texteditor.StatusTextEditor) TextEditor(org.eclipse.ui.editors.text.TextEditor) CoreException(org.eclipse.core.runtime.CoreException) IEncodingSupport(org.eclipse.ui.editors.text.IEncodingSupport) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) PartInitException(org.eclipse.ui.PartInitException) Accessor(org.eclipse.text.tests.Accessor) Test(org.junit.Test)

Example 39 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project eclipse.platform.text by eclipse.

the class EncodingChangeTests method testAInvalidEncoding.

@Test
public void testAInvalidEncoding() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
    try {
        fFile.setCharset("nonexistent", null);
    } catch (CoreException e2) {
        fail();
    }
    try {
        fEditor = IDE.openEditor(page, fFile);
        if (fEditor instanceof TextEditor) {
            TextEditor editor = (TextEditor) fEditor;
            Accessor accessor = new Accessor(editor, StatusTextEditor.class);
            while (editor.getSite().getShell().getDisplay().readAndDispatch()) {
            }
            ITextFileBuffer fileBuffer = FileBuffers.getTextFileBufferManager().getTextFileBuffer(fFile.getFullPath(), LocationKind.IFILE);
            DefaultEncodingSupport encodingSupport = (DefaultEncodingSupport) editor.getAdapter(IEncodingSupport.class);
            String expected = encodingSupport.getStatusMessage(fileBuffer.getStatus());
            Composite composite = (Composite) accessor.get("fStatusControl");
            ScrolledComposite scrolledComposite = (ScrolledComposite) composite.getChildren()[0];
            StyledText statusText = (StyledText) ((Composite) scrolledComposite.getContent()).getChildren()[5];
            String actual = statusText.getText();
            assertEquals(expected, actual);
        } else
            fail();
    } catch (PartInitException e) {
        fail();
    }
}
Also used : DefaultEncodingSupport(org.eclipse.ui.editors.text.DefaultEncodingSupport) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IEncodingSupport(org.eclipse.ui.editors.text.IEncodingSupport) Accessor(org.eclipse.text.tests.Accessor) IWorkbench(org.eclipse.ui.IWorkbench) StatusTextEditor(org.eclipse.ui.texteditor.StatusTextEditor) TextEditor(org.eclipse.ui.editors.text.TextEditor) CoreException(org.eclipse.core.runtime.CoreException) ITextFileBuffer(org.eclipse.core.filebuffers.ITextFileBuffer) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) PartInitException(org.eclipse.ui.PartInitException) Test(org.junit.Test)

Example 40 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project linuxtools by eclipse.

the class AddBoxPage method createControl.

@Override
public void createControl(Composite parent) {
    ScrolledComposite scrollTop = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    scrollTop.setExpandVertical(true);
    scrollTop.setExpandHorizontal(true);
    final Composite container = new Composite(scrollTop, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(3).margins(6, 6).applyTo(container);
    // Box name
    final Label boxNameLabel = new Label(container, SWT.NONE);
    boxNameLabel.setText(// $NON-NLS-1$
    WizardMessages.getString("ImagePull.name.label"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(boxNameLabel);
    final Text boxNameText = new Text(container, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(boxNameText);
    boxNameText.setToolTipText(// $NON-NLS-1$
    WizardMessages.getString("ImagePull.name.tooltip"));
    // Name binding
    final IObservableValue<String> boxNameObservable = BeanProperties.value(AddBoxPageModel.class, AddBoxPageModel.BOX_NAME).observe(model);
    dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(boxNameText), boxNameObservable, new UpdateValueStrategy(), null);
    // Box location
    final Label boxLocLabel = new Label(container, SWT.NONE);
    boxLocLabel.setText(// $NON-NLS-1$
    WizardMessages.getString("ImagePull.loc.label"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(boxLocLabel);
    final Text boxLocText = new Text(container, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(boxLocText);
    boxLocText.setToolTipText(// $NON-NLS-1$
    WizardMessages.getString("ImagePull.loc.tooltip"));
    // Location binding
    final IObservableValue<String> imageNameObservable = BeanProperties.value(AddBoxPageModel.class, AddBoxPageModel.BOX_LOC).observe(model);
    dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(boxLocText), imageNameObservable, new UpdateValueStrategy(), null);
    // search
    final Button searchButton = new Button(container, SWT.NONE);
    searchButton.setText(// $NON-NLS-1$
    WizardMessages.getString("ImagePull.search.label"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(searchButton);
    searchButton.addSelectionListener(onSearchImage());
    dbc.addValidationStatusProvider(new CreateBoxValidationStatusProvider(boxNameObservable, imageNameObservable));
    // setup validation support
    WizardPageSupport.create(this, dbc);
    scrollTop.setContent(container);
    Point point = container.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    scrollTop.setSize(point);
    scrollTop.setMinSize(point);
    setControl(container);
}
Also used : UpdateValueStrategy(org.eclipse.core.databinding.UpdateValueStrategy) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Button(org.eclipse.swt.widgets.Button) Label(org.eclipse.swt.widgets.Label) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point)

Aggregations

ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)89 Composite (org.eclipse.swt.widgets.Composite)67 GridData (org.eclipse.swt.layout.GridData)55 GridLayout (org.eclipse.swt.layout.GridLayout)51 Label (org.eclipse.swt.widgets.Label)39 Point (org.eclipse.swt.graphics.Point)27 Button (org.eclipse.swt.widgets.Button)21 Text (org.eclipse.swt.widgets.Text)20 FillLayout (org.eclipse.swt.layout.FillLayout)19 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)14 Control (org.eclipse.swt.widgets.Control)13 Group (org.eclipse.swt.widgets.Group)13 ControlEvent (org.eclipse.swt.events.ControlEvent)10 Rectangle (org.eclipse.swt.graphics.Rectangle)9 HistoryComposite (com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite)8 ArrayList (java.util.ArrayList)7 Combo (org.eclipse.swt.widgets.Combo)7 Image (org.eclipse.swt.graphics.Image)6 FormAttachment (org.eclipse.swt.layout.FormAttachment)6