Search in sources :

Example 51 with ControlEvent

use of org.eclipse.swt.events.ControlEvent in project InformationSystem by ObeoNetwork.

the class RequirementEditor method createPages.

/**
 * This is the method used by the framework to install your own controls.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void createPages() {
    // Creates the model from the editor input
    // 
    createModel();
    // 
    if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
        // Create a page for the selection tree view.
        // 
        Tree tree = new Tree(getContainer(), SWT.MULTI);
        selectionViewer = new TreeViewer(tree);
        setCurrentViewer(selectionViewer);
        selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
        selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
        selectionViewer.setInput(editingDomain.getResourceSet());
        selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
        new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
        createContextMenuFor(selectionViewer);
        int pageIndex = addPage(tree);
        setPageText(pageIndex, getString("_UI_SelectionPage_label"));
        getSite().getShell().getDisplay().asyncExec(new Runnable() {

            public void run() {
                setActivePage(0);
            }
        });
    }
    // Ensures that this editor will only display the page's tab
    // area if there are more than one page
    // 
    getContainer().addControlListener(new ControlAdapter() {

        boolean guard = false;

        @Override
        public void controlResized(ControlEvent event) {
            if (!guard) {
                guard = true;
                hideTabs();
                guard = false;
            }
        }
    });
    getSite().getShell().getDisplay().asyncExec(new Runnable() {

        public void run() {
            updateProblemIndication();
        }
    });
}
Also used : AdapterFactoryTreeEditor(org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor) ControlAdapter(org.eclipse.swt.events.ControlAdapter) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Tree(org.eclipse.swt.widgets.Tree) AdapterFactoryContentProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider) AdapterFactoryLabelProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider) ControlEvent(org.eclipse.swt.events.ControlEvent) Point(org.eclipse.swt.graphics.Point)

Example 52 with ControlEvent

use of org.eclipse.swt.events.ControlEvent in project gemoc-studio by eclipse.

the class FsmEditor method createPages.

/**
 * This is the method used by the framework to install your own controls.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void createPages() {
    // Creates the model from the editor input
    // 
    createModel();
    // 
    if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
        // Create a page for the selection tree view.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), FsmEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    Tree tree = new Tree(composite, SWT.MULTI);
                    TreeViewer newTreeViewer = new TreeViewer(tree);
                    return newTreeViewer;
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            selectionViewer = (TreeViewer) viewerPane.getViewer();
            selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            selectionViewer.setInput(editingDomain.getResourceSet());
            selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
            viewerPane.setTitle(editingDomain.getResourceSet());
            new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
            createContextMenuFor(selectionViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_SelectionPage_label"));
        }
        // Create a page for the parent tree view.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), FsmEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    Tree tree = new Tree(composite, SWT.MULTI);
                    TreeViewer newTreeViewer = new TreeViewer(tree);
                    return newTreeViewer;
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            parentViewer = (TreeViewer) viewerPane.getViewer();
            parentViewer.setAutoExpandLevel(30);
            parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory));
            parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(parentViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_ParentPage_label"));
        }
        // This is the page for the list viewer
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), FsmEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new ListViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            listViewer = (ListViewer) viewerPane.getViewer();
            listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(listViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_ListPage_label"));
        }
        // This is the page for the tree viewer
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), FsmEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new TreeViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            treeViewer = (TreeViewer) viewerPane.getViewer();
            treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory);
            createContextMenuFor(treeViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_TreePage_label"));
        }
        // This is the page for the table viewer.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), FsmEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new TableViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            tableViewer = (TableViewer) viewerPane.getViewer();
            Table table = tableViewer.getTable();
            TableLayout layout = new TableLayout();
            table.setLayout(layout);
            table.setHeaderVisible(true);
            table.setLinesVisible(true);
            TableColumn objectColumn = new TableColumn(table, SWT.NONE);
            layout.addColumnData(new ColumnWeightData(3, 100, true));
            objectColumn.setText(getString("_UI_ObjectColumn_label"));
            objectColumn.setResizable(true);
            TableColumn selfColumn = new TableColumn(table, SWT.NONE);
            layout.addColumnData(new ColumnWeightData(2, 100, true));
            selfColumn.setText(getString("_UI_SelfColumn_label"));
            selfColumn.setResizable(true);
            tableViewer.setColumnProperties(new String[] { "a", "b" });
            tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(tableViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_TablePage_label"));
        }
        // This is the page for the table tree viewer.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), FsmEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new TreeViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            treeViewerWithColumns = (TreeViewer) viewerPane.getViewer();
            Tree tree = treeViewerWithColumns.getTree();
            tree.setLayoutData(new FillLayout());
            tree.setHeaderVisible(true);
            tree.setLinesVisible(true);
            TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE);
            objectColumn.setText(getString("_UI_ObjectColumn_label"));
            objectColumn.setResizable(true);
            objectColumn.setWidth(250);
            TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE);
            selfColumn.setText(getString("_UI_SelfColumn_label"));
            selfColumn.setResizable(true);
            selfColumn.setWidth(200);
            treeViewerWithColumns.setColumnProperties(new String[] { "a", "b" });
            treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(treeViewerWithColumns);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label"));
        }
        getSite().getShell().getDisplay().asyncExec(new Runnable() {

            public void run() {
                setActivePage(0);
            }
        });
    }
    // Ensures that this editor will only display the page's tab
    // area if there are more than one page
    // 
    getContainer().addControlListener(new ControlAdapter() {

        boolean guard = false;

        @Override
        public void controlResized(ControlEvent event) {
            if (!guard) {
                guard = true;
                hideTabs();
                guard = false;
            }
        }
    });
    getSite().getShell().getDisplay().asyncExec(new Runnable() {

        public void run() {
            updateProblemIndication();
        }
    });
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ListViewer(org.eclipse.jface.viewers.ListViewer) AdapterFactoryTreeEditor(org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) ViewerPane(org.eclipse.emf.common.ui.ViewerPane) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AdapterFactoryContentProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider) AdapterFactoryLabelProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) ListViewer(org.eclipse.jface.viewers.ListViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) Viewer(org.eclipse.jface.viewers.Viewer) FillLayout(org.eclipse.swt.layout.FillLayout) TableColumn(org.eclipse.swt.widgets.TableColumn) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree) ControlEvent(org.eclipse.swt.events.ControlEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 53 with ControlEvent

use of org.eclipse.swt.events.ControlEvent in project gemoc-studio by eclipse.

the class AbstractTimelineView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    final Composite container;
    if (hasDetailViewer()) {
        final SashForm mainSashForm = new SashForm(parent, SWT.HORIZONTAL);
        container = mainSashForm;
        detailViewer = createDetailViewer(container);
    } else {
        container = parent;
    }
    timelineViewer = new ScrollingGraphicalViewer();
    Composite timelineComposite = new Composite(container, SWT.NONE);
    timelineComposite.setLayout(new FillLayout(SWT.HORIZONTAL | SWT.VERTICAL));
    if (hasDetailViewer()) {
        ((SashForm) container).setWeights(new int[] { DETAIL_RATIO, TIMELINE_RATIO });
    }
    GridLayout layout = new GridLayout(1, false);
    timelineComposite.setLayout(layout);
    timelineViewer.createControl(timelineComposite);
    timelineSlider = new Slider(timelineComposite, SWT.HORIZONTAL);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = SWT.FILL;
    timelineSlider.setLayoutData(gridData);
    gridData.grabExcessHorizontalSpace = true;
    rootEditPart = new ScalableFreeformRootEditPart();
    rootEditPart.setViewer(timelineViewer);
    timelineViewer.setRootEditPart(rootEditPart);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.verticalAlignment = SWT.FILL;
    gridData.grabExcessVerticalSpace = true;
    timelineViewer.getControl().setLayoutData(gridData);
    timelineViewer.setEditPartFactory(getTimelineEditPartFactory());
    timelineWindow = new TimelineWindow(provider);
    timelineViewer.setContents(timelineWindow);
    timelineSlider.setPageIncrement(timelineWindow.getLength());
    timelineSlider.setThumb(timelineWindow.getLength());
    timelineSlider.setSelection(timelineWindow.getStart());
    if (provider != null) {
        timelineSlider.setMaximum(timelineWindow.getMaxTimelineIndex() + nbVirtualChoices);
        timelineSlider.setVisible(timelineWindow.getLength() < timelineWindow.getMaxTimelineIndex() + nbVirtualChoices);
    } else {
        timelineSlider.setVisible(false);
    }
    timelineSlider.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (follow) {
                toggleFollow();
            }
            timelineWindow.setStart(timelineSlider.getSelection());
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            if (follow) {
                toggleFollow();
            }
            timelineWindow.setStart(timelineSlider.getSelection());
        }
    });
    timelineWindowListener = new TimelineWindowListener();
    timelineWindow.addTimelineWindowListener(timelineWindowListener);
    if (provider != null) {
        provider.addTimelineListener(timelineWindowListener);
    }
    timelineViewer.getControl().setBackground(ColorConstants.listBackground);
    if (hasDetailViewer()) {
        timelineViewer.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                final ISelection selection = event.getSelection();
                if (selection instanceof IStructuredSelection) {
                    final Object firstElement = ((IStructuredSelection) selection).getFirstElement();
                    if (firstElement instanceof PossibleStepEditPart) {
                        final PossibleStepEditPart possibleStepEditPart = (PossibleStepEditPart) firstElement;
                        detailViewer.setInput(possibleStepEditPart.getModel().getPossibleStep());
                    }
                }
            }
        });
    }
    timelineViewer.getControl().addKeyListener(new TimelineKeyListener());
    final TimelineMouseListener listener = new TimelineMouseListener();
    timelineViewer.getControl().addMouseListener(listener);
    timelineViewer.getControl().addMouseMoveListener(listener);
    timelineViewer.getControl().addMouseWheelListener(new TimelineMouseWheelListener());
    rootEditPart.getZoomManager().addZoomListener(new ZoomListener() {

        @Override
        public void zoomChanged(double zoom) {
            timelineWindow.setLength(getWindowLength());
        }
    });
    timelineViewer.getControl().addControlListener(new ControlListener() {

        @Override
        public void controlResized(ControlEvent e) {
            timelineWindow.setLength(getWindowLength());
            final Canvas canevas = (Canvas) timelineViewer.getControl();
            canevas.getHorizontalBar().setVisible(false);
        }

        @Override
        public void controlMoved(ControlEvent e) {
        // nothing to do here
        }
    });
    final ICommandService cmdService = (ICommandService) getSite().getService(ICommandService.class);
    String commandID = getFollowCommandID();
    if (commandID != null) {
        final Command followCommand = cmdService.getCommand(commandID);
        if (followCommand != null) {
            final State state = followCommand.getState(RegistryToggleState.STATE_ID);
            follow = state != null && ((Boolean) state.getValue()).booleanValue();
        }
    }
    createMenuManager();
}
Also used : Slider(org.eclipse.swt.widgets.Slider) TimelineWindow(org.eclipse.gemoc.timeline.model.TimelineWindow) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ICommandService(org.eclipse.ui.commands.ICommandService) ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) GridLayout(org.eclipse.swt.layout.GridLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) ControlListener(org.eclipse.swt.events.ControlListener) PossibleStepEditPart(org.eclipse.gemoc.timeline.editpart.PossibleStepEditPart) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) FigureCanvas(org.eclipse.draw2d.FigureCanvas) Canvas(org.eclipse.swt.widgets.Canvas) FillLayout(org.eclipse.swt.layout.FillLayout) SashForm(org.eclipse.swt.custom.SashForm) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) Command(org.eclipse.core.commands.Command) State(org.eclipse.core.commands.State) RegistryToggleState(org.eclipse.ui.handlers.RegistryToggleState) ZoomListener(org.eclipse.gef.editparts.ZoomListener) GridData(org.eclipse.swt.layout.GridData) ControlEvent(org.eclipse.swt.events.ControlEvent) ITimelineWindowListener(org.eclipse.gemoc.timeline.model.ITimelineWindowListener) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 54 with ControlEvent

use of org.eclipse.swt.events.ControlEvent in project gemoc-studio by eclipse.

the class GexpressionsEditor method createPages.

/**
 * This is the method used by the framework to install your own controls.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void createPages() {
    // Creates the model from the editor input
    // 
    createModel();
    // 
    if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
        // Create a page for the selection tree view.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), GexpressionsEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    Tree tree = new Tree(composite, SWT.MULTI);
                    TreeViewer newTreeViewer = new TreeViewer(tree);
                    return newTreeViewer;
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            selectionViewer = (TreeViewer) viewerPane.getViewer();
            selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            selectionViewer.setInput(editingDomain.getResourceSet());
            selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
            viewerPane.setTitle(editingDomain.getResourceSet());
            new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
            createContextMenuFor(selectionViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_SelectionPage_label"));
        }
        // Create a page for the parent tree view.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), GexpressionsEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    Tree tree = new Tree(composite, SWT.MULTI);
                    TreeViewer newTreeViewer = new TreeViewer(tree);
                    return newTreeViewer;
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            parentViewer = (TreeViewer) viewerPane.getViewer();
            parentViewer.setAutoExpandLevel(30);
            parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory));
            parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(parentViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_ParentPage_label"));
        }
        // This is the page for the list viewer
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), GexpressionsEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new ListViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            listViewer = (ListViewer) viewerPane.getViewer();
            listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(listViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_ListPage_label"));
        }
        // This is the page for the tree viewer
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), GexpressionsEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new TreeViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            treeViewer = (TreeViewer) viewerPane.getViewer();
            treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory);
            createContextMenuFor(treeViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_TreePage_label"));
        }
        // This is the page for the table viewer.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), GexpressionsEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new TableViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            tableViewer = (TableViewer) viewerPane.getViewer();
            Table table = tableViewer.getTable();
            TableLayout layout = new TableLayout();
            table.setLayout(layout);
            table.setHeaderVisible(true);
            table.setLinesVisible(true);
            TableColumn objectColumn = new TableColumn(table, SWT.NONE);
            layout.addColumnData(new ColumnWeightData(3, 100, true));
            objectColumn.setText(getString("_UI_ObjectColumn_label"));
            objectColumn.setResizable(true);
            TableColumn selfColumn = new TableColumn(table, SWT.NONE);
            layout.addColumnData(new ColumnWeightData(2, 100, true));
            selfColumn.setText(getString("_UI_SelfColumn_label"));
            selfColumn.setResizable(true);
            tableViewer.setColumnProperties(new String[] { "a", "b" });
            tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(tableViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_TablePage_label"));
        }
        // This is the page for the table tree viewer.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), GexpressionsEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new TreeViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            treeViewerWithColumns = (TreeViewer) viewerPane.getViewer();
            Tree tree = treeViewerWithColumns.getTree();
            tree.setLayoutData(new FillLayout());
            tree.setHeaderVisible(true);
            tree.setLinesVisible(true);
            TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE);
            objectColumn.setText(getString("_UI_ObjectColumn_label"));
            objectColumn.setResizable(true);
            objectColumn.setWidth(250);
            TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE);
            selfColumn.setText(getString("_UI_SelfColumn_label"));
            selfColumn.setResizable(true);
            selfColumn.setWidth(200);
            treeViewerWithColumns.setColumnProperties(new String[] { "a", "b" });
            treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(treeViewerWithColumns);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label"));
        }
        getSite().getShell().getDisplay().asyncExec(new Runnable() {

            public void run() {
                setActivePage(0);
            }
        });
    }
    // Ensures that this editor will only display the page's tab
    // area if there are more than one page
    // 
    getContainer().addControlListener(new ControlAdapter() {

        boolean guard = false;

        @Override
        public void controlResized(ControlEvent event) {
            if (!guard) {
                guard = true;
                hideTabs();
                guard = false;
            }
        }
    });
    getSite().getShell().getDisplay().asyncExec(new Runnable() {

        public void run() {
            updateProblemIndication();
        }
    });
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ListViewer(org.eclipse.jface.viewers.ListViewer) AdapterFactoryTreeEditor(org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) ViewerPane(org.eclipse.emf.common.ui.ViewerPane) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AdapterFactoryContentProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider) AdapterFactoryLabelProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) ListViewer(org.eclipse.jface.viewers.ListViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) Viewer(org.eclipse.jface.viewers.Viewer) FillLayout(org.eclipse.swt.layout.FillLayout) TableColumn(org.eclipse.swt.widgets.TableColumn) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree) ControlEvent(org.eclipse.swt.events.ControlEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 55 with ControlEvent

use of org.eclipse.swt.events.ControlEvent in project BiglyBT by BiglySoftware.

the class SB_Dashboard method build.

protected void build(Composite dashboard_composite) {
    try {
        building++;
        if (dashboard_composite == null) {
            return;
        }
        Utils.disposeComposite(dashboard_composite, false);
        int[][] layout = getDashboardLayout();
        layout = compactLayout(layout, 0, 0);
        Map<Integer, DashboardItem> item_map = new HashMap<>();
        for (DashboardItem item : items) {
            item_map.put(item.getUID(), item);
        }
        for (int[] row : layout) {
            for (int i = 0; i < row.length; i++) {
                int c = row[i];
                if (!item_map.containsKey(c)) {
                    row[i] = -1;
                }
            }
        }
        boolean use_tabs = getUseTabs();
        final List<SashForm> sashes = new ArrayList<>();
        List<Control> controls = new ArrayList<>();
        build(item_map, dashboard_composite, use_tabs, sashes, controls, layout, 0, 0, layout.length, layout.length);
        int[][] sash_weights = getSashWeights();
        if (sash_weights.length == sashes.size()) {
            for (int i = 0; i < sash_weights.length; i++) {
                int[] weights = sash_weights[i];
                SashForm sf = sashes.get(i);
                int[] sf_weights = sf.getWeights();
                if (sf_weights.length == weights.length) {
                    try {
                        sf.setWeights(weights);
                    } catch (Throwable e) {
                        // in case something borks
                        Debug.out(e);
                    }
                }
                sf.setData(sf_weights.length);
            }
        } else {
            // something's changed
            setSashWeights(new int[0][0]);
            for (SashForm sf : sashes) {
                int[] weights = sf.getWeights();
                sf.setData(weights.length);
            }
        }
        for (Control c : controls) {
            c.addControlListener(new ControlListener() {

                @Override
                public void controlResized(ControlEvent arg0) {
                    if (building > 0) {
                        return;
                    }
                    int[][] weights = new int[sashes.size()][];
                    for (int i = 0; i < sashes.size(); i++) {
                        SashForm sf = sashes.get(i);
                        if (sf.isDisposed()) {
                            return;
                        }
                        weights[i] = sf.getWeights();
                        Object d = sf.getData();
                        if (d == null || ((Integer) d) != weights[i].length) {
                            return;
                        }
                    }
                    setSashWeights(weights);
                }

                @Override
                public void controlMoved(ControlEvent arg0) {
                // TODO Auto-generated method stub
                }
            });
        }
        dashboard_composite.getParent().layout(true, true);
    } finally {
        SimpleTimer.addEvent("delayer", SystemTime.getOffsetTime(2500), new TimerEventPerformer() {

            @Override
            public void perform(TimerEvent event) {
                Utils.execSWTThread(new Runnable() {

                    @Override
                    public void run() {
                        building--;
                    }
                });
            }
        });
    }
}
Also used : Point(org.eclipse.swt.graphics.Point) SashForm(org.eclipse.swt.custom.SashForm) Control(org.eclipse.swt.widgets.Control) TimerEventPerformer(com.biglybt.core.util.TimerEventPerformer) ControlListener(org.eclipse.swt.events.ControlListener) TimerEvent(com.biglybt.core.util.TimerEvent) ControlEvent(org.eclipse.swt.events.ControlEvent)

Aggregations

ControlEvent (org.eclipse.swt.events.ControlEvent)187 ControlAdapter (org.eclipse.swt.events.ControlAdapter)135 Composite (org.eclipse.swt.widgets.Composite)76 GridData (org.eclipse.swt.layout.GridData)67 ControlListener (org.eclipse.swt.events.ControlListener)54 GridLayout (org.eclipse.swt.layout.GridLayout)50 SelectionEvent (org.eclipse.swt.events.SelectionEvent)49 TableColumn (org.eclipse.swt.widgets.TableColumn)42 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)41 Point (org.eclipse.swt.graphics.Point)38 Table (org.eclipse.swt.widgets.Table)37 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)36 FillLayout (org.eclipse.swt.layout.FillLayout)35 Tree (org.eclipse.swt.widgets.Tree)35 TreeViewer (org.eclipse.jface.viewers.TreeViewer)33 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)32 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)31 AdapterFactoryTreeEditor (org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor)30 AdapterFactoryContentProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider)30 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)30