private void createConfigurationToolBar(CoolBar coolBar) { CoolItem configCoolItem = new CoolItem(coolBar, SWT.NONE); ToolBar configToolBar = new ToolBar(coolBar, SWT.FLAT | SWT.HORIZONTAL); saveWidget = new SaveWidget(this); saveWidget.createToolItem(configToolBar); loadWidget = new LoadWidget(this); loadWidget.createToolItem(configToolBar); deleteButton = new ToolItem(configToolBar, SWT.PUSH | SWT.CENTER); deleteButton.setImage(ImageManager.getImage(OteTestManagerImage.FILE_DELETE)); deleteButton.setToolTipText("Deletes Selected (highlighted) Scripts"); deleteButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleDeleteButton(); } }); deleteButton.addListener( SWT.MouseUp, new Listener() { @Override public void handleEvent(Event e) { if (e.button == 3) { handleDeleteButton(); } } }); configToolBar.pack(); Point size = configToolBar.getSize(); configCoolItem.setControl(configToolBar); configCoolItem.setSize(configCoolItem.computeSize(size.x, size.y)); configCoolItem.setMinimumSize(size); }
private void createControlsToolBar(CoolBar coolBar) { CoolItem controlsCoolItem = new CoolItem(coolBar, SWT.NONE); ToolBar controlsToolBar = new ToolBar(coolBar, SWT.FLAT | SWT.HORIZONTAL); runButton = new ToolItem(controlsToolBar, SWT.PUSH | SWT.CENTER); runButton.setImage(ImageManager.getImage(OteTestManagerImage.SEL_RUN_EXEC)); runButton.setDisabledImage(ImageManager.getImage(OteTestManagerImage.UNSEL_RUN_EXEC)); runButton.setToolTipText("Runs the Checked Scripts"); runButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleRunButton(); } }); runButton.addListener( SWT.MouseUp, new Listener() { @Override public void handleEvent(Event e) { if (e.button == 3) { handleRunButton(); } } }); runButton.setEnabled(false); // Create and configure the "Abort" button abortButton = new ToolItem(controlsToolBar, SWT.PUSH | SWT.CENTER); abortButton.setImage(ImageManager.getImage(OteTestManagerImage.SEL_ABORT_STOP)); abortButton.setDisabledImage(ImageManager.getImage(OteTestManagerImage.UNSEL_ABORT_STOP)); abortButton.setToolTipText("Abort Currently Running Script"); abortButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleAbortButton(); abortBatchButton.setEnabled(false); abortButton.setEnabled(false); Timer timer = new Timer(); timer.schedule(new EnabledAbortsTimer(), 30000); } }); abortButton.addListener( SWT.MouseUp, new Listener() { @Override public void handleEvent(Event e) { if (e.button == 3) { handleAbortButton(); abortBatchButton.setEnabled(false); abortButton.setEnabled(false); Timer timer = new Timer(); timer.schedule(new EnabledAbortsTimer(), 30000); } } }); abortButton.setEnabled(false); abortBatchButton = new ToolItem(controlsToolBar, SWT.PUSH | SWT.CENTER); abortBatchButton.setImage(ImageManager.getImage(OteTestManagerImage.SEL_BATCH_ABORT_STOP)); abortBatchButton.setDisabledImage( ImageManager.getImage(OteTestManagerImage.UNSEL_BATCH_ABORT_STOP)); abortBatchButton.setToolTipText("Abort Script Batch"); abortBatchButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleBatchAbortButton(); abortBatchButton.setEnabled(false); abortButton.setEnabled(false); Timer timer = new Timer(); timer.schedule(new EnabledAbortsTimer(), 30000); } }); abortBatchButton.addListener( SWT.MouseUp, new Listener() { @Override public void handleEvent(Event e) { if (e.button == 3) { handleBatchAbortButton(); abortBatchButton.setEnabled(false); abortButton.setEnabled(false); Timer timer = new Timer(); timer.schedule(new EnabledAbortsTimer(), 30000); } } }); abortBatchButton.setEnabled(false); controlsToolBar.pack(); Point size = controlsToolBar.getSize(); controlsCoolItem.setControl(controlsToolBar); controlsCoolItem.setSize(controlsCoolItem.computeSize(size.x, size.y)); controlsCoolItem.setMinimumSize(size); }
/** * Calculates and sets the size of the given cool item. * * @param item item of cool bar */ private void calcSize(final CoolItem item) { final Control control = item.getControl(); Point pt = control.computeSize(SWT.DEFAULT, SWT.DEFAULT); pt = item.computeSize(pt.x, pt.y); item.setSize(pt); }