Search in sources :

Example 11 with ISourceProviderService

use of org.eclipse.ui.services.ISourceProviderService in project yamcs-studio by yamcs.

the class ArchiveView method isRefreshEnabled.

public boolean isRefreshEnabled() {
    // Not necessarily on the SWT thread. This is a bit of a risk. Maybe we should do a blocking
    // Display.getDefault().syncExec
    IWorkbenchWindow window = getViewSite().getWorkbenchWindow();
    ISourceProviderService service = (ISourceProviderService) window.getService(ISourceProviderService.class);
    RefreshStateProvider commandState = (RefreshStateProvider) service.getSourceProvider(RefreshStateProvider.STATE_KEY_ENABLED);
    return (Boolean) commandState.getCurrentState().get(RefreshStateProvider.STATE_KEY_ENABLED);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ISourceProviderService(org.eclipse.ui.services.ISourceProviderService)

Example 12 with ISourceProviderService

use of org.eclipse.ui.services.ISourceProviderService in project yamcs-studio by yamcs.

the class ArchiveView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    ResourceManager resourceManager = new LocalResourceManager(JFaceResources.getResources(), parent);
    seekImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/seek.png"));
    playImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/play.png"));
    pauseImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/pause.png"));
    forwardImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/forward.png"));
    forward2xImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/forward2x.png"));
    forward4xImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/forward4x.png"));
    forward8xImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/forward8x.png"));
    forward16xImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/forward16x.png"));
    leaveReplayImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/redo.png"));
    createActions();
    indexReceiver = new ArchiveIndexReceiver();
    parent.setLayout(new FillLayout());
    Composite contentArea = new Composite(parent, SWT.NONE);
    contentArea.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout gl = new GridLayout();
    gl.marginWidth = 0;
    gl.marginHeight = 0;
    contentArea.setLayout(gl);
    Composite locationComp = new Composite(contentArea, SWT.EMBEDDED);
    locationComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    java.awt.Frame frame = SWT_AWT.new_Frame(locationComp);
    archivePanel = new ArchivePanel(this);
    archivePanel.setPreferredSize(new Dimension(300, 400));
    frame.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            archivePanel.onWindowResized();
        }
    });
    frame.add(archivePanel);
    replayComposite = new Composite(contentArea, SWT.NONE);
    replayCompositeGridData = new GridData(GridData.FILL_HORIZONTAL);
    replayComposite.setLayoutData(replayCompositeGridData);
    gl = new GridLayout(4, false);
    gl.marginHeight = 0;
    gl.verticalSpacing = 0;
    gl.horizontalSpacing = 0;
    replayComposite.setLayout(gl);
    // current time / jump date / jump time / jump button
    Composite timeComposite = new Composite(replayComposite, SWT.NONE);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.LEFT;
    // gd.widthHint = 140;
    // gd.grabExcessHorizontalSpace = true;
    timeComposite.setLayoutData(gd);
    gl = new GridLayout(4, false);
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.verticalSpacing = 0;
    gl.horizontalSpacing = 0;
    timeComposite.setLayout(gl);
    replayTimeLabel = new Label(timeComposite, SWT.NONE);
    FontData[] fd = replayTimeLabel.getFont().getFontData();
    fd[0].setHeight(fd[0].getHeight() - 2);
    // TODO dispose this font!
    replayTimeLabel.setFont(new Font(parent.getDisplay(), fd));
    // ugh...
    replayTimeLabel.setText("                             ");
    seekDate = new DateTime(timeComposite, SWT.DATE | SWT.LONG | SWT.DROP_DOWN | SWT.BORDER);
    seekTime = new DateTime(timeComposite, SWT.TIME | SWT.LONG | SWT.BORDER);
    seekButton = new Button(timeComposite, SWT.PUSH);
    seekButton.setImage(seekImage);
    seekButton.setToolTipText("Seek Specified Time");
    seekButton.addListener(SWT.Selection, evt -> {
        long seekInstant = TimeEncoding.fromCalendar(RCPUtils.toCalendar(seekDate, seekTime));
        archivePanel.seekReplay(seekInstant);
    });
    // play / pause / forward
    Composite controlsComposite = new Composite(replayComposite, SWT.NONE);
    gd = new GridData();
    gd.horizontalAlignment = SWT.CENTER;
    gd.grabExcessHorizontalSpace = true;
    controlsComposite.setLayoutData(gd);
    gl = new GridLayout(3, false);
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.verticalSpacing = 0;
    gl.horizontalSpacing = 0;
    controlsComposite.setLayout(gl);
    playButton = new Button(controlsComposite, SWT.PUSH);
    playButton.setImage(playImage);
    playButton.setToolTipText("Play");
    playButton.addListener(SWT.Selection, evt -> {
        if (playButton.getImage().equals(playImage))
            RCPUtils.runCommand("org.yamcs.studio.core.ui.processor.playCommand");
        else
            RCPUtils.runCommand("org.yamcs.studio.core.ui.processor.pauseCommand");
    });
    forwardButton = new Button(controlsComposite, SWT.PUSH);
    forwardButton.setImage(forwardImage);
    forwardButton.setToolTipText("Forward");
    forwardButton.addListener(SWT.Selection, evt -> {
        RCPUtils.runCommand("org.yamcs.studio.core.ui.processor.forwardCommand");
    });
    Composite buttonWrapper = new Composite(replayComposite, SWT.NONE);
    gd = new GridData();
    gd.horizontalAlignment = SWT.RIGHT;
    gd.widthHint = 140;
    buttonWrapper.setLayoutData(gd);
    gl = new GridLayout();
    gl.horizontalSpacing = 0;
    gl.verticalSpacing = 0;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    buttonWrapper.setLayout(gl);
    leaveReplayButton = new Button(buttonWrapper, SWT.PUSH);
    leaveReplayButton.setImage(leaveReplayImage);
    leaveReplayButton.setToolTipText("Back to Realtime");
    leaveReplayButton.addListener(SWT.Selection, evt -> {
        RCPUtils.runCommand("org.yamcs.studio.core.ui.processor.leaveReplay");
    });
    gd = new GridData();
    gd.horizontalAlignment = SWT.RIGHT;
    buttonWrapper.setLayoutData(gd);
    ISourceProviderService service = (ISourceProviderService) getSite().getService(ISourceProviderService.class);
    processorState = (ProcessorStateProvider) service.getSourceProvider(ProcessorStateProvider.STATE_KEY_PROCESSING);
    processorState.addSourceProviderListener(this);
    connectionState = (ConnectionStateProvider) service.getSourceProvider(ConnectionStateProvider.STATE_KEY_CONNECTED);
    connectionState.addSourceProviderListener(this);
    indexReceiver.setIndexListener(this);
    TimeCatalogue.getInstance().addTimeListener(this);
    YamcsPlugin.getDefault().addYamcsConnectionListener(this);
    ManagementCatalogue.getInstance().addInstanceListener(this);
    updateState();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) LocalResourceManager(org.eclipse.jface.resource.LocalResourceManager) FontData(org.eclipse.swt.graphics.FontData) Label(org.eclipse.swt.widgets.Label) ResourceManager(org.eclipse.jface.resource.ResourceManager) LocalResourceManager(org.eclipse.jface.resource.LocalResourceManager) FillLayout(org.eclipse.swt.layout.FillLayout) Dimension(java.awt.Dimension) Font(org.eclipse.swt.graphics.Font) DateTime(org.eclipse.swt.widgets.DateTime) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter) ISourceProviderService(org.eclipse.ui.services.ISourceProviderService)

Aggregations

ISourceProviderService (org.eclipse.ui.services.ISourceProviderService)12 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)10 Dimension (java.awt.Dimension)1 ComponentAdapter (java.awt.event.ComponentAdapter)1 ComponentEvent (java.awt.event.ComponentEvent)1 LocalResourceManager (org.eclipse.jface.resource.LocalResourceManager)1 ResourceManager (org.eclipse.jface.resource.ResourceManager)1 Font (org.eclipse.swt.graphics.Font)1 FontData (org.eclipse.swt.graphics.FontData)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 DateTime (org.eclipse.swt.widgets.DateTime)1 Label (org.eclipse.swt.widgets.Label)1 ProcessorStateProvider (org.yamcs.studio.core.ui.processor.ProcessorStateProvider)1