@Override public void run () { if (isDisposed()) return; redraw(); if (!BusyIndicator.this.busy) return; update(); if (isDisposed()) return; imageIndex = (imageIndex + 1) % IMAGE_COUNT; dpy.timerExec(MILLISECONDS_OF_DELAY, this); } };
/** * Sets the form's busy state. Busy form will display 'busy' animation in * the area of the title image. * * @param busy * the form's busy state */ public boolean setBusy(boolean busy) { if (busy) ensureBusyLabelExists(); else if (busyLabel == null) return false; if (busy == busyLabel.isBusy()) return false; busyLabel.setBusy(busy); if (busyLabel.getImage() == null) { layout(); return true; } return false; }
public void updateImage(Image newImage, boolean doLayout) { Image theImage = newImage != null ? newImage : this.image; if (theImage != null) { ensureBusyLabelExists(); } else if (busyLabel != null) { if (!busyLabel.isBusy()) { busyLabel.dispose(); busyLabel = null; } } if (busyLabel != null) { busyLabel.setImage(theImage); } if (doLayout) layout(); }
/** * Set the image. The value <code>null</code> clears it. */ public void setImage(Image image) { if (image != this.image && !isDisposed()) { this.image = image; redraw(); } }
/** * BusyWidget constructor comment. * * @param parent * org.eclipse.swt.widgets.Composite * @param style * int */ public BusyIndicator(Composite parent, int style) { super(parent, style | SWT.DOUBLE_BUFFERED); dpy = getDisplay(); timer = new Runnable() { @Override public void run () { if (isDisposed()) return; redraw(); if (!BusyIndicator.this.busy) return; update(); if (isDisposed()) return; imageIndex = (imageIndex + 1) % IMAGE_COUNT; dpy.timerExec(MILLISECONDS_OF_DELAY, this); } }; addPaintListener(event -> onPaint(event)); addDisposeListener(e -> clearImages()); }
private void ensureBusyLabelExists() { if (busyLabel == null) { busyLabel = new BusyIndicator(this, SWT.NULL); busyLabel.setBackground(getColor(FormHeading.COLOR_BASE_BG)); HoverListener listener = new HoverListener(); busyLabel.addMouseTrackListener(listener); busyLabel.addMouseMoveListener(listener); if (menuManager != null) busyLabel.setMenu(menuManager.createContextMenu(this)); if (dragSupport) addDragSupport(busyLabel, dragOperations, dragTransferTypes, dragListener); IMessageToolTipManager mng = ((FormHeading) getParent()) .getMessageToolTipManager(); if (mng != null) mng.createToolTip(busyLabel, true); } }
void onPaint(PaintEvent event) { Rectangle rect = getClientArea(); if (rect.width == 0 || rect.height == 0) return; Image activeImage; if (isBusy()) { activeImage = getImage(imageIndex); } else { clearImages(); activeImage = image; } if (activeImage != null) { GC gc = event.gc; Rectangle ibounds = activeImage.getBounds(); gc.drawImage(activeImage, rect.width / 2 - ibounds.width / 2, rect.height / 2 - ibounds.height / 2); } }
super(parent, style | SWT.DOUBLE_BUFFERED); dpy = getDisplay(); timer = new Runnable() { @Override addPaintListener(new PaintListener() { @Override public void paintControl(PaintEvent event) { addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) {
connectionTest = new Label(main, SWT.NONE); connectionTest.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); busyIndicator = new BusyIndicator(main, SWT.NONE); busyIndicator.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
bsize = busyLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT); int yloc = y + VMARGIN; if (bsize != null) { busyLabel.setBounds(xloc,
private void updateSizeAndLocations() { if (busyLabel == null || busyLabel.isDisposed()) return; if (titleLabel == null || titleLabel.isDisposed()) return; Point size = titleLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); int y = (titleLabel.getParent().getSize().y - size.y) / 2; titleLabel.setBounds(busyLabel.getLocation().x, y, size.x, size.y); }
/** * Cancels the checking if it is active. */ public void cancel() { if (null != checkCmrJob) { checkCmrJob.cancel(); } busyIndicator.setBusy(false); main.layout(); }
Image emptyImage = new Image(heading.getDisplay(), size.x, size.y); UIUtils.hookDisposal(titleLabel, emptyImage); busyLabel.setImage(emptyImage); busyLabel.addControlListener(new ControlAdapter() { public void controlMoved(ControlEvent e) { updateSizeAndLocations();
private void ensureBusyLabelExists() { if (busyLabel == null) { busyLabel = new BusyIndicator(this, SWT.NULL); busyLabel.setBackground(getColor(FormHeading.COLOR_BASE_BG)); HoverListener listener = new HoverListener(); busyLabel.addMouseTrackListener(listener); busyLabel.addMouseMoveListener(listener); if (menuManager != null) busyLabel.setMenu(menuManager.createContextMenu(this)); if (dragSupport) addDragSupport(busyLabel, dragOperations, dragTransferTypes, dragListener); IMessageToolTipManager mng = ((FormHeading) getParent()) .getMessageToolTipManager(); if (mng != null) mng.createToolTip(busyLabel, true); } }
void onPaint(PaintEvent event) { Rectangle rect = getClientArea(); if (rect.width == 0 || rect.height == 0) return; Image activeImage; if (isBusy()) { activeImage = getImage(imageIndex); } else { clearImages(); activeImage = image; } if (activeImage != null) { GC gc = event.gc; Rectangle ibounds = activeImage.getBounds(); gc.drawImage(activeImage, rect.width / 2 - ibounds.width / 2, rect.height / 2 - ibounds.height / 2); } }
/** * Set the image. The value <code>null</code> clears it. */ public void setImage(Image image) { if (image != this.image && !isDisposed()) { this.image = image; redraw(); } }
testConnection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); final BusyIndicator busyIndicator = new BusyIndicator(main, SWT.NONE); busyIndicator.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
bsize = busyLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT); int yloc = y + VMARGIN; if (bsize != null) { busyLabel.setBounds(xloc,
/** * Updates the representation with a given {@link CmrRepositoryDefinition}. * * @param cmrRepositoryDefinition * {@link CmrRepositoryDefinition}. */ public void update(final CmrRepositoryDefinition cmrRepositoryDefinition) { name.setText(cmrRepositoryDefinition.getName()); ip.setText(cmrRepositoryDefinition.getIp() + ":" + cmrRepositoryDefinition.getPort()); description.setText(cmrRepositoryDefinition.getDescription()); connectionTest.setText("Checking.."); busyIndicator.setBusy(true); version.setText(""); main.layout(); checkCmrJob = new CheckCmrJob(cmrRepositoryDefinition); checkCmrJob.schedule(); }
@Override public void run () { if (isDisposed()) return; redraw(); if (!BusyIndicator.this.busy) return; update(); if (isDisposed()) return; imageIndex = (imageIndex + 1) % IMAGE_COUNT; dpy.timerExec(MILLISECONDS_OF_DELAY, this); } };