Search in sources :

Example 6 with LocalResourceManager

use of org.eclipse.jface.resource.LocalResourceManager 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)

Example 7 with LocalResourceManager

use of org.eclipse.jface.resource.LocalResourceManager in project yamcs-studio by yamcs.

the class StyleEditor method createPartControl.

@Override
public void createPartControl(Composite parent) {
    tk = new FormToolkit(parent.getDisplay());
    Composite formWrapper = tk.createComposite(parent);
    GridLayout gl = new GridLayout();
    formWrapper.setLayout(gl);
    form = tk.createScrolledForm(formWrapper);
    form.setText("Style Editor");
    form.setLayoutData(new GridData(GridData.FILL_BOTH));
    gl = new GridLayout();
    form.getBody().setLayout(gl);
    Section section = tk.createSection(form.getBody(), Section.TITLE_BAR);
    section.setText("Colors");
    section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    StyleDefinition def = loadData(parent.getDisplay());
    ManagedForm managedForm = new ManagedForm(tk, form);
    resourceManager = new LocalResourceManager(JFaceResources.getResources());
    new ThemeColorBlock(def, parent.getDisplay(), resourceManager).createContent(managedForm);
    ManagedForm fontsMForm = new ManagedForm(tk, form);
    section = tk.createSection(form.getBody(), Section.TITLE_BAR);
    section.setText("Fonts");
    section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    new ThemeColorBlock(def, parent.getDisplay(), resourceManager).createContent(fontsMForm);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) LocalResourceManager(org.eclipse.jface.resource.LocalResourceManager) ManagedForm(org.eclipse.ui.forms.ManagedForm) GridData(org.eclipse.swt.layout.GridData) Section(org.eclipse.ui.forms.widgets.Section)

Aggregations

LocalResourceManager (org.eclipse.jface.resource.LocalResourceManager)7 ResourceManager (org.eclipse.jface.resource.ResourceManager)5 GridData (org.eclipse.swt.layout.GridData)5 GridLayout (org.eclipse.swt.layout.GridLayout)5 Composite (org.eclipse.swt.widgets.Composite)5 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Image (org.eclipse.swt.graphics.Image)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 Button (org.eclipse.swt.widgets.Button)2 Label (org.eclipse.swt.widgets.Label)2 Dimension (java.awt.Dimension)1 ComponentAdapter (java.awt.event.ComponentAdapter)1 ComponentEvent (java.awt.event.ComponentEvent)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Command (org.eclipse.core.commands.Command)1 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1