Search in sources :

Example 51 with IStatusLineManager

use of org.eclipse.jface.action.IStatusLineManager in project Malai by arnobl.

the class EventEditor method getContentOutlinePage.

/**
 * This accesses a cached version of the content outliner.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public IContentOutlinePage getContentOutlinePage() {
    if (contentOutlinePage == null) {
        // 
        class MyContentOutlinePage extends ContentOutlinePage {

            @Override
            public void createControl(Composite parent) {
                super.createControl(parent);
                contentOutlineViewer = getTreeViewer();
                contentOutlineViewer.addSelectionChangedListener(this);
                // Set up the tree viewer.
                // 
                contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
                contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
                contentOutlineViewer.setInput(editingDomain.getResourceSet());
                // Make sure our popups work.
                // 
                createContextMenuFor(contentOutlineViewer);
                if (!editingDomain.getResourceSet().getResources().isEmpty()) {
                    // Select the root object in the view.
                    // 
                    contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
                }
            }

            @Override
            public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) {
                super.makeContributions(menuManager, toolBarManager, statusLineManager);
                contentOutlineStatusLineManager = statusLineManager;
            }

            @Override
            public void setActionBars(IActionBars actionBars) {
                super.setActionBars(actionBars);
                getActionBarContributor().shareGlobalActions(this, actionBars);
            }
        }
        contentOutlinePage = new MyContentOutlinePage();
        // Listen to selection so that we can handle it is a special way.
        // 
        contentOutlinePage.addSelectionChangedListener(new ISelectionChangedListener() {

            // This ensures that we handle selections correctly.
            // 
            public void selectionChanged(SelectionChangedEvent event) {
                handleContentOutlineSelection(event.getSelection());
            }
        });
    }
    return contentOutlinePage;
}
Also used : ContentOutlinePage(org.eclipse.ui.views.contentoutline.ContentOutlinePage) IContentOutlinePage(org.eclipse.ui.views.contentoutline.IContentOutlinePage) Composite(org.eclipse.swt.widgets.Composite) IToolBarManager(org.eclipse.jface.action.IToolBarManager) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) 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) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IMenuManager(org.eclipse.jface.action.IMenuManager) IActionBars(org.eclipse.ui.IActionBars)

Example 52 with IStatusLineManager

use of org.eclipse.jface.action.IStatusLineManager in project archi by archimatetool.

the class AbstractModelView method updateStatusBarWithSelection.

/**
 * Update Status Bar with selected image and text
 * @param selected
 */
protected void updateStatusBarWithSelection(Object selected) {
    IStatusLineManager status = getViewSite().getActionBars().getStatusLineManager();
    if (selected instanceof IArchimateModelObject) {
        IArchimateModelObject object = (IArchimateModelObject) selected;
        Image image = ArchiLabelProvider.INSTANCE.getImage(object);
        // $NON-NLS-1$
        String text = "";
        List<String> list = new ArrayList<String>();
        do {
            list.add(ArchiLabelProvider.INSTANCE.getLabelNormalised(object));
            object = (IArchimateModelObject) object.eContainer();
        } while ((object != null));
        for (int i = list.size() - 1; i >= 0; i--) {
            text += list.get(i);
            if (i != 0) {
                // $NON-NLS-1$
                text += " > ";
            }
        }
        status.setMessage(image, text);
    } else {
        // $NON-NLS-1$
        status.setMessage(null, "");
    }
}
Also used : IArchimateModelObject(com.archimatetool.model.IArchimateModelObject) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) ArrayList(java.util.ArrayList) Image(org.eclipse.swt.graphics.Image)

Example 53 with IStatusLineManager

use of org.eclipse.jface.action.IStatusLineManager in project archi by archimatetool.

the class AbstractDiagramEditor method updateStatusBarWithSelection.

/**
 * Update Status Bar with selected image and text
 * @param selected
 */
protected void updateStatusBarWithSelection(Object selected) {
    IStatusLineManager status = getEditorSite().getActionBars().getStatusLineManager();
    if (selected instanceof EditPart) {
        selected = ((EditPart) selected).getModel();
        Image image = ArchiLabelProvider.INSTANCE.getImage(selected);
        String text = ArchiLabelProvider.INSTANCE.getLabelNormalised(selected);
        status.setMessage(image, text);
    } else {
        // $NON-NLS-1$
        status.setMessage(null, "");
    }
}
Also used : IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) Image(org.eclipse.swt.graphics.Image)

Example 54 with IStatusLineManager

use of org.eclipse.jface.action.IStatusLineManager in project dbeaver by serge-rider.

the class DatabaseDebugDetailPane method display.

@Override
public void display(IStructuredSelection selection) {
    // clear status line
    IStatusLineManager statusLine = ActionBars.extractStatusLineManager(partSite);
    if (statusLine != null) {
        statusLine.setErrorMessage(null);
    }
    EDITOR editor = getEditor();
    Object input = null;
    if (selection != null && selection.size() == 1) {
        input = selection.getFirstElement();
    // update even if the same in case attributes have changed
    }
    try {
        editor.setInput(input);
    } catch (CoreException e) {
        log.log(e.getStatus());
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager)

Example 55 with IStatusLineManager

use of org.eclipse.jface.action.IStatusLineManager in project dbeaver by serge-rider.

the class BaseBrowserView method createBrowser.

private Browser createBrowser(Composite parent, final IActionBars actionBars) {
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    parent.setLayout(gridLayout);
    browser = new Browser(parent, SWT.NONE);
    GridData data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.FILL;
    data.grabExcessHorizontalSpace = true;
    data.grabExcessVerticalSpace = true;
    browser.setLayoutData(data);
    browser.addProgressListener(new ProgressAdapter() {

        IProgressMonitor monitor = actionBars.getStatusLineManager().getProgressMonitor();

        boolean working = false;

        int workedSoFar;

        @Override
        public void changed(ProgressEvent event) {
            if (event.total == 0)
                return;
            if (!working) {
                if (event.current == event.total)
                    return;
                // $NON-NLS-1$
                monitor.beginTask("", event.total);
                workedSoFar = 0;
                working = true;
            }
            monitor.worked(event.current - workedSoFar);
            workedSoFar = event.current;
        }

        @Override
        public void completed(ProgressEvent event) {
            monitor.done();
            working = false;
        }
    });
    browser.addStatusTextListener(new StatusTextListener() {

        IStatusLineManager status = actionBars.getStatusLineManager();

        @Override
        public void changed(StatusTextEvent event) {
            status.setMessage(event.text);
        }
    });
    browser.addLocationListener(new LocationAdapter() {

        @Override
        public void changed(LocationEvent event) {
            backAction.setEnabled(browser.isBackEnabled());
            forwardAction.setEnabled(browser.isForwardEnabled());
        // if (event.top)
        // location.setText(event.location);
        }
    });
    browser.addTitleListener(new TitleListener() {

        @Override
        public void changed(TitleEvent event) {
            setPartName(event.title);
        }
    });
    /*
        browser.addOpenWindowListener(new OpenWindowListener() {
            public void open(WindowEvent event) {
                BaseBrowserView.this.openWindow(event);
            }
        });
*/
    // TODO: should handle VisibilityWindowListener.show and .hide events
    browser.addCloseWindowListener(new CloseWindowListener() {

        @Override
        public void close(WindowEvent event) {
            BaseBrowserView.this.close();
        }
    });
    /*
        location.addSelectionListener(new SelectionAdapter() {
            public void widgetDefaultSelected(SelectionEvent e) {
                browser.setUrl(location.getText());
            }
        });
*/
    // Hook the navigation actons as handlers for the retargetable actions
    // defined in BrowserActionBuilder.
    // $NON-NLS-1$
    actionBars.setGlobalActionHandler("back", backAction);
    // $NON-NLS-1$
    actionBars.setGlobalActionHandler("forward", forwardAction);
    // $NON-NLS-1$
    actionBars.setGlobalActionHandler("stop", stopAction);
    // $NON-NLS-1$
    actionBars.setGlobalActionHandler("refresh", refreshAction);
    IToolBarManager toolBarManager = actionBars.getToolBarManager();
    toolBarManager.add(backAction);
    toolBarManager.add(forwardAction);
    toolBarManager.add(stopAction);
    toolBarManager.add(refreshAction);
    backAction.setEnabled(false);
    forwardAction.setEnabled(false);
    return browser;
}
Also used : IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) GridLayout(org.eclipse.swt.layout.GridLayout) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IToolBarManager(org.eclipse.jface.action.IToolBarManager) GridData(org.eclipse.swt.layout.GridData)

Aggregations

IStatusLineManager (org.eclipse.jface.action.IStatusLineManager)68 IToolBarManager (org.eclipse.jface.action.IToolBarManager)33 IActionBars (org.eclipse.ui.IActionBars)33 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)32 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)31 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)31 AdapterFactoryContentProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider)30 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)30 IMenuManager (org.eclipse.jface.action.IMenuManager)30 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)30 Composite (org.eclipse.swt.widgets.Composite)30 ContentOutlinePage (org.eclipse.ui.views.contentoutline.ContentOutlinePage)30 IContentOutlinePage (org.eclipse.ui.views.contentoutline.IContentOutlinePage)30 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 ArrayList (java.util.ArrayList)4 IContributionItem (org.eclipse.jface.action.IContributionItem)4 IFile (org.eclipse.core.resources.IFile)3 IAction (org.eclipse.jface.action.IAction)3 StatusLineContributionItem (org.eclipse.jface.action.StatusLineContributionItem)3