Search in sources :

Example 1 with IStatusLineManager

use of org.eclipse.jface.action.IStatusLineManager in project tdi-studio-se by Talend.

the class AbstractFilteredTree method updateStatusLine.

/**
     * Updates the status line.
     * 
     * @param selection the selection
     */
public void updateStatusLine(IStructuredSelection selection) {
    IStatusLineManager manager = actionBars.getStatusLineManager();
    IContributionItem[] items = manager.getItems();
    StatusLineContributionItem selfTimeStatusLineItem = null;
    for (IContributionItem item : items) {
        if (item instanceof StatusLineContributionItem) {
            selfTimeStatusLineItem = (StatusLineContributionItem) item;
        }
    }
    // create the status line
    if (selfTimeStatusLineItem == null) {
        //$NON-NLS-1$
        selfTimeStatusLineItem = new StatusLineContributionItem("SelfTimeContributionItem");
        manager.add(selfTimeStatusLineItem);
    }
    // clear the status line
    if (selection == null) {
        selfTimeStatusLineItem.setText(Util.ZERO_LENGTH_STRING);
        return;
    }
    // set text on status line
    double percentage = 0;
    double time = 0;
    for (Object object : selection.toArray()) {
        if (object instanceof IMethodNode) {
            percentage += ((IMethodNode) object).getSelfTimeInPercentage();
            time += ((IMethodNode) object).getSelfTime();
        }
    }
    String text = Util.ZERO_LENGTH_STRING;
    if (percentage != 0) {
        //$NON-NLS-1$
        text = String.format("Self Time: %.0fms  %.1f", time, percentage) + '%';
    }
    selfTimeStatusLineItem.setText(text);
}
Also used : StatusLineContributionItem(org.eclipse.jface.action.StatusLineContributionItem) IMethodNode(org.talend.designer.runtime.visualization.internal.core.cpu.IMethodNode) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) IContributionItem(org.eclipse.jface.action.IContributionItem)

Example 2 with IStatusLineManager

use of org.eclipse.jface.action.IStatusLineManager in project ACS by ACS-Community.

the class ApplicationWorkbenchWindowAdvisor method postWindowOpen.

public void postWindowOpen() {
    final IStatusLineManager status = getWindowConfigurer().getActionBarConfigurer().getStatusLineManager();
    status.setMessage("Application starting...");
    final Display display = getWindowConfigurer().getWindow().getShell().getDisplay();
    // Disables the initial view
    IViewReference[] views = getWindowConfigurer().getWindow().getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
    for (int i = 0; i < views.length; i++) {
        if (views[i].getId().compareTo(AlarmSystemView.ID) == 0)
            ((IMyViewPart) views[i].getView(false)).setEnabled(false);
    }
    boolean authenticated = false;
    AuthenticationDialog d = new AuthenticationDialog(ApplicationWorkbenchWindowAdvisor.this.getWindowConfigurer().getWindow().getShell());
    UserAuthenticator.Role role = null;
    while (!authenticated) {
        d.open();
        UserAuthenticator userAuth = new UserAuthenticator();
        try {
            role = userAuth.authenticate(d.getUser(), d.getPassword());
        } catch (UserAuthenticatorException e) {
            d.setErrorMessage("Authentication unsuccessful");
            continue;
        } catch (IllegalArgumentException e) {
            d.setErrorMessage("Please authenticate yourselve");
            continue;
        } finally {
            status.setMessage("Authentication successful");
        }
        authenticated = true;
    }
    final UserAuthenticator.Role finalRole = role;
    new Thread(new Runnable() {

        @Override
        public void run() {
            AlarmSystemManager asm = AlarmSystemManager.getInstance(finalRole);
            try {
                display.asyncExec(new Runnable() {

                    public void run() {
                        status.setMessage("Connecting to Manager");
                    }
                });
                asm.connectToManager();
                display.asyncExec(new Runnable() {

                    public void run() {
                        status.setMessage("Connecting to CDB DAL");
                    }
                });
                asm.connectToDAL();
                display.asyncExec(new Runnable() {

                    public void run() {
                        status.setMessage("Loading contents from the CDB");
                    }
                });
                asm.loadFromCDB();
                final String error = asm.checkCDB();
                if (error.compareTo("") != 0) {
                    display.asyncExec(new Runnable() {

                        public void run() {
                            ErrorDialog edialog = new ErrorDialog(getWindowConfigurer().getWindow().getShell(), "CDB Error", "Error while checking CDB integrity", new Status(IStatus.ERROR, "cl.utfsm.acs.acg", error), IStatus.ERROR);
                            edialog.setBlockOnOpen(true);
                            edialog.open();
                        }
                    });
                }
            } catch (Exception e) {
                e.printStackTrace();
                display.asyncExec(new Runnable() {

                    public void run() {
                        status.setErrorMessage("Couldn't successfully connect to AS configuation");
                    }
                });
                return;
            }
            /*  If everything went OK:
				     * Show the other views
				     *  Enable the widgets and inform the user */
            display.asyncExec(new Runnable() {

                public void run() {
                    IWorkbenchPage page = getWindowConfigurer().getWindow().getActivePage();
                    try {
                        if (finalRole == Role.Administrator || finalRole == Role.Operator) {
                            page.showView(SourcesView.ID, null, IWorkbenchPage.VIEW_VISIBLE);
                            page.showView(CategoriesView.ID, null, IWorkbenchPage.VIEW_VISIBLE);
                            page.showView(AlarmsView.ID, null, IWorkbenchPage.VIEW_VISIBLE);
                            page.showView(ReductionsView.ID, null, IWorkbenchPage.VIEW_VISIBLE);
                            page.showView("org.eclipse.pde.runtime.LogView", null, IWorkbenchPage.VIEW_VISIBLE);
                        }
                    } catch (PartInitException e) {
                        status.setErrorMessage("Cannot open other views");
                    }
                    IViewReference[] views = page.getViewReferences();
                    for (int i = 0; i < views.length; i++) {
                        if (views[i].getId().compareTo(AlarmSystemView.ID) == 0)
                            ((IMyViewPart) views[i].getView(false)).setEnabled(true);
                        if (finalRole == Role.Operator)
                            if (views[i].getView(false) instanceof IMyViewPart)
                                ((IMyViewPart) views[i].getView(false)).setReadOnly(true);
                    }
                    status.setMessage("Application started successfully");
                }
            });
        }
    }).start();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) UserAuthenticatorException(cl.utfsm.acs.acg.core.UserAuthenticatorException) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) UserAuthenticator(cl.utfsm.acs.acg.core.UserAuthenticator) ErrorDialog(org.eclipse.jface.dialogs.ErrorDialog) Point(org.eclipse.swt.graphics.Point) PartInitException(org.eclipse.ui.PartInitException) UserAuthenticatorException(cl.utfsm.acs.acg.core.UserAuthenticatorException) IViewReference(org.eclipse.ui.IViewReference) AlarmSystemManager(cl.utfsm.acs.acg.core.AlarmSystemManager) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) Role(cl.utfsm.acs.acg.core.UserAuthenticator.Role) Display(org.eclipse.swt.widgets.Display)

Example 3 with IStatusLineManager

use of org.eclipse.jface.action.IStatusLineManager in project eclipse.platform.text by eclipse.

the class LockJob method setUp.

@Before
public void setUp() throws Exception {
    IFolder folder = ResourceHelper.createFolder("FileDocumentProviderTestProject/test");
    file = (File) ResourceHelper.createFile(folder, "file.txt", "");
    assertTrue(file.exists());
    fsManager = file.getLocalManager();
    assertTrue(fsManager.fastIsSynchronized(file));
    stopLockingFlag = new AtomicBoolean(false);
    stoppedByTest = new AtomicBoolean(false);
    fileProvider = new FileDocumentProviderMock();
    lockJob = new LockJob("Locking workspace", file, stopLockingFlag, stoppedByTest);
    // We need the editor only to get the default editor status line manager
    IWorkbench workbench = PlatformUI.getWorkbench();
    page = workbench.getActiveWorkbenchWindow().getActivePage();
    editor = IDE.openEditor(page, file);
    TestUtil.runEventLoop();
    IStatusLineManager statusLineManager = editor.getEditorSite().getActionBars().getStatusLineManager();
    // This is default monitor which almost all editors are using
    IProgressMonitor progressMonitor = statusLineManager.getProgressMonitor();
    assertNotNull(progressMonitor);
    assertFalse(progressMonitor instanceof NullProgressMonitor);
    assertFalse(progressMonitor instanceof EventLoopProgressMonitor);
    assertTrue(progressMonitor instanceof IProgressMonitorWithBlocking);
    // Because this monitor is not EventLoopProgressMonitor, it will not
    // process UI events while waiting on workspace lock
    fileProvider.setProgressMonitor(progressMonitor);
    TestUtil.waitForJobs(500, 5000);
    Job[] jobs = Job.getJobManager().find(null);
    String jobsList = Arrays.toString(jobs);
    System.out.println("Still running jobs: " + jobsList);
    if (!Job.getJobManager().isIdle()) {
        jobs = Job.getJobManager().find(null);
        for (Job job : jobs) {
            System.out.println("Going to cancel: " + job.getName() + " / " + job);
            job.cancel();
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) EventLoopProgressMonitor(org.eclipse.ui.internal.dialogs.EventLoopProgressMonitor) IWorkbench(org.eclipse.ui.IWorkbench) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IProgressMonitorWithBlocking(org.eclipse.core.runtime.IProgressMonitorWithBlocking) Job(org.eclipse.core.runtime.jobs.Job) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) IFolder(org.eclipse.core.resources.IFolder) Before(org.junit.Before)

Example 4 with IStatusLineManager

use of org.eclipse.jface.action.IStatusLineManager in project eclipse.platform.text by eclipse.

the class FindNextAction method statusNotFound.

/**
 * Sets the "no matches found" error message to the status line.
 *
 * @since 3.0
 */
private void statusNotFound() {
    fWorkbenchPart.getSite().getShell().getDisplay().beep();
    IStatusLineManager manager = getStatusLineManager();
    if (manager == null)
        return;
    manager.setMessage(EditorMessages.FindNext_Status_noMatch_label);
}
Also used : IStatusLineManager(org.eclipse.jface.action.IStatusLineManager)

Example 5 with IStatusLineManager

use of org.eclipse.jface.action.IStatusLineManager in project yamcs-studio by yamcs.

the class RCPUtils method setStatusMessage.

/**
 * Sets a message in the lower left status line. These messages are by
 * rcp-design associated with a view.
 *
 * @param viewId
 *            the view from which the message originates
 */
public static void setStatusMessage(String viewId, String message) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IViewSite site = window.getActivePage().findView(viewId).getViewSite();
    IStatusLineManager mgr = site.getActionBars().getStatusLineManager();
    mgr.setMessage(message);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewSite(org.eclipse.ui.IViewSite) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager)

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 IContributionItem (org.eclipse.jface.action.IContributionItem)4 ArrayList (java.util.ArrayList)3 IFile (org.eclipse.core.resources.IFile)3 IAction (org.eclipse.jface.action.IAction)3 StatusLineContributionItem (org.eclipse.jface.action.StatusLineContributionItem)3