Example usage for org.eclipse.jface.action IStatusLineManager update

List of usage examples for org.eclipse.jface.action IStatusLineManager update

Introduction

In this page you can find the example usage for org.eclipse.jface.action IStatusLineManager update.

Prototype

void update(boolean force);

Source Link

Document

Updates this manager's underlying widget(s) with any changes which have been made to it or its items.

Usage

From source file:com.bdaum.zoom.css.internal.CssActivator.java

License:Open Source License

public void updateStatusLine(IStatusLineManager statusLineManager) {
    statusLineManager.update(true);
    while (statusLineManager instanceof SubStatusLineManager)
        statusLineManager = (IStatusLineManager) ((SubStatusLineManager) statusLineManager).getParent();
    setColors(((StatusLineManager) statusLineManager).getControl());
}

From source file:com.drgarbage.bytecodevisualizer.view.OperandStackViewPage.java

License:Apache License

private void setMesssageInStatusLine() {
    if (methodInput == null) {
        return;/*from   w  w  w.j  a v  a  2s .  c om*/
    }

    IActionBars bars = getSite().getActionBars();

    IStatusLineManager slm = bars.getStatusLineManager();

    /* 
     * DO NOT DELETE THIS LINE. 
     * This is probably a bug in the StatusLineManeger implementation.
     * The setMessage() is first visible if the error message has 
     * been cleaned by the setErrorMessage(""); 
     */
    slm.setErrorMessage("");

    if (operandStack.getMaxStackSize() > methodInput.getMaxStack()) {

        StringBuffer buf = new StringBuffer();
        buf.append(CoreMessages.Error);
        buf.append(JavaLexicalConstants.COLON);
        buf.append(JavaLexicalConstants.SPACE);
        buf.append(BytecodeVisualizerMessages.OperandStackAnalysis_Error_StackOverflow);
        buf.append(JavaLexicalConstants.COMMA);
        buf.append(JavaLexicalConstants.SPACE);
        buf.append("max_stack is "); //$NON-NLS-1$
        buf.append(methodInput.getMaxStack());
        buf.append(", calculated max stack size is "); //$NON-NLS-1$
        buf.append(operandStack.getMaxStackSize());
        buf.append(JavaLexicalConstants.DOT);

        slm.setErrorMessage(
                PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK),
                buf.toString());
    } else if (operandStack.getMaxStackSize() < methodInput.getMaxStack()) {
        StringBuffer buf = new StringBuffer();
        buf.append(CoreMessages.Warning);
        buf.append(JavaLexicalConstants.COLON);
        buf.append(JavaLexicalConstants.SPACE);
        buf.append(BytecodeVisualizerMessages.OperandStackAnalysis_Warning_StackUnderflow);
        buf.append(JavaLexicalConstants.COMMA);
        buf.append(JavaLexicalConstants.SPACE);
        buf.append("max_stack is "); //$NON-NLS-1$
        buf.append(methodInput.getMaxStack());
        buf.append(", calculated max stack size is "); //$NON-NLS-1$
        buf.append(operandStack.getMaxStackSize());
        buf.append(JavaLexicalConstants.DOT);

        slm.setMessage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK),
                buf.toString());
    } else {
        StringBuffer buf = new StringBuffer();
        buf.append("max_stack: "); //$NON-NLS-1$
        buf.append(methodInput.getMaxStack());
        buf.append(", max_locals: "); //$NON-NLS-1$
        buf.append(methodInput.getMaxLocals());

        slm.setMessage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK),
                buf.toString());
    }

    slm.update(true);
}

From source file:com.mulgasoft.emacsplus.EmacsPlusUtils.java

License:Open Source License

private static void forceUpdate(IStatusLineManager ism) {
    ism.update(true);
}

From source file:com.nokia.tools.s60.editor.actions.BrowseForFileAction.java

License:Open Source License

@Override
protected void doRun(Object element) {
    final IContentData data = getContentData(element);
    if (data != null || element instanceof IAnimationFrame) {
        String path = null;//from w  w w .j av  a  2 s . c  o  m
        if (data != null) {
            path = selectFileForData(data);
        } else {
            List<String> files = selectFiles(null, null);
            if (files.size() > 0) {
                path = files.get(0);
            }
        }
        if (path == null) {
            // cancel pressed
            return;
        }
        final String p = path;
        /* check for file existence, show warning in status bar if not */
        if (!new File(path).exists()) {
            // shows warning in the status bar and exit
            if (getWorkbenchPart() != null) {
                IWorkbenchPartSite site = getWorkbenchPart().getSite();
                if (site instanceof IWorkbenchPartSite) {
                    try {
                        IActionBars bars = (IActionBars) site.getClass()
                                .getMethod("getActionBars", (Class[]) null).invoke(site, (Object[]) null);
                        IStatusLineManager manager = bars.getStatusLineManager();
                        if (manager != null) {
                            String message = Messages.bind(Messages.BrowseForFileAction_notfound, path);
                            manager.setErrorMessage(message);
                            manager.update(false);
                        }
                    } catch (Exception e) {
                    }
                }
            }
            return;
        }

        if (data != null) {
            ISkinnableEntityAdapter sa = (ISkinnableEntityAdapter) data
                    .getAdapter(ISkinnableEntityAdapter.class);
            if (sa != null) {

                if (sa.isMultiPiece() || PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
                        .getActivePart() instanceof LayersView) {

                    ILayer layer = getLayer(false, element);
                    IPasteTargetAdapter pasteAdapter = getPasteTargetAdapter(element);
                    if (layer != null && pasteAdapter != null) {
                        try {

                            // Adding a layer, if one doesnot exist
                            IImage img = layer.getParent();
                            if (layer.isBackground()) {
                                if (img.getLayerCount() > 1) {
                                    layer = img.getLayer(1);
                                } else {
                                    // add layer when only BG present 
                                    layer = img.addLayer();
                                }
                            }
                            // Backup suppression status
                            boolean isSuppressNotification = sa.isSuppressNotification();
                            sa.setSuppressNotification(true);
                            pasteAdapter.paste(path, layer);
                            sa.setSuppressNotification(isSuppressNotification);
                            updateGraphicWithCommand(layer, layer);
                        } catch (Exception e) {
                            S60WorkspacePlugin.error(e);
                        }
                    }
                    return;
                }

                IMediaFileAdapter fileAdapter = (IMediaFileAdapter) data.getAdapter(IMediaFileAdapter.class);

                ForwardUndoCompoundCommand command = new ForwardUndoCompoundCommand(
                        com.nokia.tools.s60.editor.commands.Messages.PasteImage_Label);
                if (fileAdapter != null) {
                    command.add(new DropImageCommand(getContentData(element), path, null));
                } else {
                    command.add(new PasteImageCommand(data, getEditPart(element), path));
                }
                Command stretchModeCommand = sa.getApplyStretchModeCommand(sa.getStretchMode());
                if (stretchModeCommand.canExecute()) {
                    command.add(stretchModeCommand);
                }
                execute(command, getEditPart(element));
                return;
            }
        }

        final IImageHolder holder = getImageHolder(element);
        if (holder != null) {
            EditPart part = getEditPart(element);
            final IPasteTargetAdapter pasteAdapter = getPasteTargetAdapter(element);
            execute(new UndoableImageHolderActionCommand(holder, new Runnable() {

                public void run() {
                    try {
                        pasteAdapter.paste(Collections.singletonList(new File(p)), null);
                    } catch (HeadlessException e) {
                        e.printStackTrace();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }), part);
            return;
        }
    }
}

From source file:com.nokia.tools.screen.ui.propertysheet.tabbed.WidgetSection.java

License:Open Source License

protected void setErrorMessage(String message) {
    IStatusLineManager statusLine = getStatusLine();
    if (statusLine != null) {
        statusLine.setErrorMessage(message);
        statusLine.update(true);
    }//from www . ja v  a  2s.  c o m
}

From source file:com.nokia.tools.screen.ui.propertysheet.tabbed.WidgetSection.java

License:Open Source License

protected void clearErrorMessage() {
    IStatusLineManager statusLine = getStatusLine();
    if (statusLine != null) {
        statusLine.setErrorMessage(null);
        statusLine.update(false);
    }//from w ww  .j  a v  a 2  s  .  co m
}

From source file:com.sonatype.buildserver.eclipse.ui.StatusNotification.java

License:Open Source License

private void updateAffordance(final boolean triggerFlash) {
    if (notificationAffordance == null)
        createNotificationAffordance();/*from   w ww .j  a  v a  2s  . c o  m*/
    Display.getDefault().syncExec(new Runnable() {
        public void run() {
            synchronized (notificationAffordance) {
                synchronized (jobs) {
                    JobWrapper job = jobs.isEmpty() ? null : jobs.first();
                    notificationAffordance.setVisible(job != null);
                    if (job != null) {
                        final Image image = HudsonImages.getResultImage(job.getJob());
                        final String imagePath = HudsonImages.getResultImagePath(job.getBuildResult());
                        notificationAffordance.setImage(image);
                        notificationAffordance.setText(job.getJob().getJobName());
                        if (triggerFlash) {
                            if (animation != null) {
                                animation.cancel();
                            }
                            CLabel lbl = notificationAffordance.getLabel();
                            if (lbl != null) { // in some weird circumstances
                                //this can be null, very bad API interactions in swt :(
                                Flasher flasher = new Flasher(lbl.getShell(), loadAnimatedFor(imagePath));
                                animation = new AnimationEngine(flasher, 8000, 200 // delay between frames in milliseconds
                                );
                                animation.schedule();
                            }
                        }
                    } else {
                        if (animation != null) {
                            animation.cancel();
                        }
                    }
                }
                IStatusLineManager manager = notificationAffordance.getStatusLineManager();
                if (manager != null) {
                    manager.update(true);
                }
            }
        }
    });
}

From source file:com.xored.glance.internal.ui.panels.SearchStatusLine.java

License:Open Source License

@Override
public void closePanel() {
    if (item != null) {
        fireClose();/* w w  w.jav a  2  s .c o m*/
        IStatusLineManager manager = getManager();
        if (manager != null) {
            manager.remove(item);
            manager.update(false);
        }
        item = null;
    }
}

From source file:com.xored.glance.internal.ui.panels.SearchStatusLine.java

License:Open Source License

private void init() {
    item = new SearchItem();
    IStatusLineManager manager = getManager();
    if (manager != null) {
        manager.remove(item);//  w  ww. ja v a2 s  . c o  m
        manager.appendToGroup(StatusLineManager.BEGIN_GROUP, item);
        manager.update(true);
    }
}

From source file:fr.inria.portolan.visualization.prefuse.ui.PrefuseEditor.java

License:Open Source License

public void init(IEditorSite site, IEditorInput input) throws PartInitException {

    this.setSite(site);
    this.setPartName(input.getName());

    if (input instanceof ModelEditorInput) {
        // get the progress monitor of Eclipse status bar (not possible to use a Job)
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        IWorkbenchPart part = window.getActivePage().getActivePart();
        IStatusLineManager manager = null;
        if (part.getSite() instanceof IViewSite) {
            manager = ((IViewSite) (part.getSite())).getActionBars().getStatusLineManager();
        } else {//from   ww w. ja  v a 2s. c om
            manager = ((IEditorSite) (part.getSite())).getActionBars().getStatusLineManager();
        }
        IProgressMonitor monitor = manager.getProgressMonitor();
        manager.update(true);
        try {
            IFile model = ((ModelEditorInput) input).getModelFile();
            String metamodelURI = ((ModelEditorInput) input).getMetamodelURI();
            monitor.beginTask("Cartography to GraphML: " + model.getName(), IProgressMonitor.UNKNOWN);
            monitor.worked(1);
            IFile graphml = ChainFromCartographyToGraphML.processModel(model, metamodelURI,
                    new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN));
            GraphInput graphInput = new GraphInput(graphml);
            this.input = graphInput;
            this.setInput(graphInput);

        } catch (PortolanException e) {
            throw new PartInitException("Lacking some of Portolan preferences or project properties");
        } finally {
            monitor.done();
        }
    } else if (input instanceof GraphInput) {
        this.input = (GraphInput) input;
        this.setInput(input);
    } else if (input instanceof IFileEditorInput) {
        GraphInput graphInput = new GraphInput(((IFileEditorInput) input).getFile());
        this.input = graphInput;
        this.setInput(graphInput);
    } else
        throw new PartInitException("Input should be a GraphML XML file");
}