use of org.eclipse.swt.events.PaintEvent in project SIMVA-SoS by SESoS.
the class ChartComposite method forceRedraw.
/**
* Forces a redraw of the canvas by invoking a new PaintEvent.
*/
public void forceRedraw() {
Event ev = new Event();
ev.gc = new GC(this.canvas);
ev.x = 0;
ev.y = 0;
ev.width = this.canvas.getBounds().width;
ev.height = this.canvas.getBounds().height;
ev.count = 0;
this.canvas.notifyListeners(SWT.Paint, ev);
ev.gc.dispose();
}
use of org.eclipse.swt.events.PaintEvent in project pentaho-kettle by pentaho.
the class PropsUI method setLook.
public void setLook(final Control control, int style) {
if (this.isOSLookShown() && style != WIDGET_STYLE_FIXED) {
return;
}
final GUIResource gui = GUIResource.getInstance();
Font font = null;
Color background = null;
switch(style) {
case WIDGET_STYLE_DEFAULT:
background = gui.getColorBackground();
if (control instanceof Group && OS.indexOf("mac") > -1) {
control.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent paintEvent) {
paintEvent.gc.setBackground(gui.getColorBackground());
paintEvent.gc.fillRectangle(2, 0, control.getBounds().width - 8, control.getBounds().height - 20);
}
});
}
// GUIResource.getInstance().getFontDefault();
font = null;
break;
case WIDGET_STYLE_FIXED:
if (!this.isOSLookShown()) {
background = gui.getColorBackground();
}
font = gui.getFontFixed();
break;
case WIDGET_STYLE_TABLE:
background = gui.getColorBackground();
// gui.getFontGrid();
font = null;
break;
case WIDGET_STYLE_NOTEPAD:
background = gui.getColorBackground();
font = gui.getFontNote();
break;
case WIDGET_STYLE_GRAPH:
background = gui.getColorBackground();
font = gui.getFontGraph();
break;
case WIDGET_STYLE_TOOLBAR:
background = GUIResource.getInstance().getColorDemoGray();
break;
case WIDGET_STYLE_TAB:
background = GUIResource.getInstance().getColorWhite();
CTabFolder tabFolder = (CTabFolder) control;
tabFolder.setSimple(false);
tabFolder.setBorderVisible(true);
// need to make a copy of the tab selection background color to get around PDI-13940
Color c = GUIResource.getInstance().getColorTab();
Color tabColor = new Color(c.getDevice(), c.getRed(), c.getGreen(), c.getBlue());
tabFolder.setSelectionBackground(tabColor);
break;
default:
background = gui.getColorBackground();
// gui.getFontDefault();
font = null;
break;
}
if (font != null && !font.isDisposed()) {
control.setFont(font);
}
if (background != null && !background.isDisposed()) {
if (control instanceof Button) {
Button b = (Button) control;
if ((b.getStyle() & SWT.PUSH) != 0) {
return;
}
}
control.setBackground(background);
}
}
use of org.eclipse.swt.events.PaintEvent in project pentaho-kettle by pentaho.
the class JobMetricsDelegate method setupContent.
public void setupContent() {
if (metricsComposite.isDisposed()) {
return;
}
//
for (Control control : metricsComposite.getChildren()) {
if (!control.isDisposed()) {
control.dispose();
}
}
emptyGraph = false;
canvas = new Canvas(metricsComposite, SWT.NONE);
spoon.props.setLook(canvas);
FormData fdCanvas = new FormData();
fdCanvas.left = new FormAttachment(0, 0);
fdCanvas.right = new FormAttachment(100, 0);
fdCanvas.top = new FormAttachment(0, 0);
fdCanvas.bottom = new FormAttachment(100, 0);
canvas.setLayoutData(fdCanvas);
metricsComposite.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent event) {
updateGraph();
}
});
metricsComposite.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
if (image != null) {
image.dispose();
}
}
});
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent event) {
if (jobGraph.job != null && (jobGraph.job.isFinished() || jobGraph.job.isStopped())) {
refreshImage(event.gc);
if (!Const.isRunningOnWebspoonMode()) {
if (image != null && !image.isDisposed()) {
event.gc.drawImage(image, 0, 0);
}
}
} else {
Rectangle bounds = canvas.getBounds();
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
event.gc.setForeground(GUIResource.getInstance().getColorWhite());
event.gc.setBackground(GUIResource.getInstance().getColorWhite());
event.gc.fillRectangle(new Rectangle(0, 0, bounds.width, bounds.height));
event.gc.setForeground(GUIResource.getInstance().getColorBlack());
String metricsMessage = BaseMessages.getString(PKG, "JobMetricsDelegate.JobIsNotRunning.Message");
org.eclipse.swt.graphics.Point extent = event.gc.textExtent(metricsMessage);
event.gc.drawText(metricsMessage, (bounds.width - extent.x) / 2, (bounds.height - extent.y) / 2);
}
}
});
// Refresh automatically every 5 seconds as well.
//
final Timer timer = new Timer("JobMetricsDelegate Timer");
timer.schedule(new TimerTask() {
public void run() {
updateGraph();
}
}, 0, 5000);
// When the tab is closed, we remove the update timer
//
jobMetricsTab.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent arg0) {
timer.cancel();
}
});
if (Const.isRunningOnWebspoonMode()) {
// When the browser tab/window is closed, we remove the update timer
jobMetricsTab.getDisplay().disposeExec(new Runnable() {
@Override
public void run() {
timer.cancel();
}
});
}
// Show tool tips with details...
//
canvas.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent event) {
if (drawAreas == null) {
return;
}
for (int i = drawAreas.size() - 1; i >= 0; i--) {
MetricsDrawArea drawArea = drawAreas.get(i);
if (drawArea.getArea().contains(event.x, event.y)) {
MetricsDuration duration = drawArea.getDuration();
if (duration == null) {
continue;
}
System.out.println(duration.toString());
LoggingObjectInterface loggingObject = LoggingRegistry.getInstance().getLoggingObject(duration.getLogChannelId());
if (loggingObject == null) {
return;
}
System.out.println(loggingObject.getObjectType() + " : " + loggingObject.getObjectName());
}
}
}
});
canvas.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent arg0) {
// force a refresh
lastRefreshTime = 0;
}
});
}
use of org.eclipse.swt.events.PaintEvent in project pentaho-kettle by pentaho.
the class EnterPrintDialog method open.
public int open() {
Shell parent = getParent();
Display display = parent.getDisplay();
retval = SWT.OK;
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.SHEET | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "EnterPrintDialog.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Canvas
wlCanvas = new Label(shell, SWT.NONE);
wlCanvas.setText(BaseMessages.getString(PKG, "EnterPrintDialog.PrintArea.Label"));
props.setLook(wlCanvas);
fdlCanvas = new FormData();
fdlCanvas.left = new FormAttachment(0, 0);
fdlCanvas.top = new FormAttachment(0, margin);
wlCanvas.setLayoutData(fdlCanvas);
wCanvas = new Canvas(shell, SWT.BORDER);
props.setLook(wCanvas);
wCanvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent pe) {
repaint(pe.gc, pe.width, pe.height);
}
});
fdCanvas = new FormData();
fdCanvas.left = new FormAttachment(0, 0);
fdCanvas.top = new FormAttachment(wlCanvas, margin);
fdCanvas.right = new FormAttachment(100, 0);
fdCanvas.bottom = new FormAttachment(100, -220);
wCanvas.setLayoutData(fdCanvas);
// Rows
wlRows = new Label(shell, SWT.NONE);
wlRows.setText(BaseMessages.getString(PKG, "EnterPrintDialog.Rows.Label"));
props.setLook(wlRows);
fdlRows = new FormData();
fdlRows.left = new FormAttachment(0, 0);
fdlRows.right = new FormAttachment(middle, -margin);
fdlRows.top = new FormAttachment(wCanvas, margin);
wlRows.setLayoutData(fdlRows);
wRows = new Slider(shell, SWT.HORIZONTAL);
wRows.setIncrement(1);
wRows.setMinimum(1);
wRows.setMaximum(11);
wRows.setThumb(1);
wRows.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent se) {
Slider sl = (Slider) se.widget;
nrrows = sl.getSelection();
wCanvas.redraw();
}
});
props.setLook(wRows);
fdRows = new FormData();
fdRows.left = new FormAttachment(middle, 0);
fdRows.top = new FormAttachment(wCanvas, margin);
fdRows.right = new FormAttachment(100, 0);
wRows.setLayoutData(fdRows);
// Cols
wlCols = new Label(shell, SWT.NONE);
wlCols.setText(BaseMessages.getString(PKG, "EnterPrintDialog.Cols.Label"));
props.setLook(wlCols);
fdlCols = new FormData();
fdlCols.left = new FormAttachment(0, 0);
fdlCols.right = new FormAttachment(middle, -margin);
fdlCols.top = new FormAttachment(wRows, margin);
wlCols.setLayoutData(fdlCols);
wCols = new Slider(shell, SWT.HORIZONTAL);
wCols.setIncrement(1);
wCols.setMinimum(1);
wCols.setMaximum(11);
wCols.setThumb(1);
wCols.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent se) {
Slider sl = (Slider) se.widget;
nrcols = sl.getSelection();
wCanvas.redraw();
}
});
props.setLook(wCols);
fdCols = new FormData();
fdCols.left = new FormAttachment(middle, 0);
fdCols.top = new FormAttachment(wRows, margin);
fdCols.right = new FormAttachment(100, 0);
wCols.setLayoutData(fdCols);
// Scale
wlScale = new Label(shell, SWT.NONE);
wlScale.setText(BaseMessages.getString(PKG, "EnterPrintDialog.Scaling.Label"));
props.setLook(wlScale);
fdlScale = new FormData();
fdlScale.left = new FormAttachment(0, 0);
fdlScale.right = new FormAttachment(middle, -margin);
fdlScale.top = new FormAttachment(wCols, margin);
wlScale.setLayoutData(fdlScale);
wScale = new Slider(shell, SWT.HORIZONTAL);
wScale.setIncrement(10);
wScale.setMinimum(10);
wScale.setMaximum(500);
wScale.setThumb(10);
wScale.setPageIncrement(25);
wScale.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent se) {
Slider sl = (Slider) se.widget;
scale = sl.getSelection();
wCanvas.redraw();
}
});
props.setLook(wScale);
fdScale = new FormData();
fdScale.left = new FormAttachment(middle, 0);
fdScale.top = new FormAttachment(wCols, margin);
fdScale.right = new FormAttachment(100, 0);
wScale.setLayoutData(fdScale);
// Left
wlLeft = new Label(shell, SWT.NONE);
wlLeft.setText(BaseMessages.getString(PKG, "EnterPrintDialog.LeftMargin.Label"));
props.setLook(wlLeft);
fdlLeft = new FormData();
fdlLeft.left = new FormAttachment(0, 0);
fdlLeft.right = new FormAttachment(middle, -margin);
fdlLeft.top = new FormAttachment(wScale, margin);
wlLeft.setLayoutData(fdlLeft);
wLeft = new Text(shell, SWT.BORDER);
wLeft.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
Text w = (Text) e.widget;
leftMargin = Const.toDouble(w.getText(), 0.00);
}
});
props.setLook(wLeft);
fdLeft = new FormData();
fdLeft.left = new FormAttachment(middle, 0);
fdLeft.top = new FormAttachment(wScale, margin);
fdLeft.right = new FormAttachment(100, 0);
wLeft.setLayoutData(fdLeft);
// Right
wlRight = new Label(shell, SWT.NONE);
wlRight.setText(BaseMessages.getString(PKG, "EnterPrintDialog.RightMargin.Label"));
props.setLook(wlRight);
fdlRight = new FormData();
fdlRight.left = new FormAttachment(0, 0);
fdlRight.right = new FormAttachment(middle, -margin);
fdlRight.top = new FormAttachment(wLeft, margin);
wlRight.setLayoutData(fdlRight);
wRight = new Text(shell, SWT.BORDER);
wRight.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
Text w = (Text) e.widget;
rightMargin = Const.toDouble(w.getText(), 0.00);
}
});
props.setLook(wRight);
fdRight = new FormData();
fdRight.left = new FormAttachment(middle, 0);
fdRight.top = new FormAttachment(wLeft, margin);
fdRight.right = new FormAttachment(100, 0);
wRight.setLayoutData(fdRight);
// Top
wlTop = new Label(shell, SWT.NONE);
wlTop.setText(BaseMessages.getString(PKG, "EnterPrintDialog.TopMargin.Label"));
props.setLook(wlTop);
fdlTop = new FormData();
fdlTop.left = new FormAttachment(0, 0);
fdlTop.right = new FormAttachment(middle, -margin);
fdlTop.top = new FormAttachment(wRight, margin);
wlTop.setLayoutData(fdlTop);
wTop = new Text(shell, SWT.BORDER);
wTop.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
Text w = (Text) e.widget;
topMargin = Const.toDouble(w.getText(), 0.00);
}
});
props.setLook(wTop);
fdTop = new FormData();
fdTop.left = new FormAttachment(middle, 0);
fdTop.top = new FormAttachment(wRight, margin);
fdTop.right = new FormAttachment(100, 0);
wTop.setLayoutData(fdTop);
// Bottom
wlBottom = new Label(shell, SWT.NONE);
wlBottom.setText(BaseMessages.getString(PKG, "EnterPrintDialog.BottomMargin.Label"));
props.setLook(wlBottom);
fdlBottom = new FormData();
fdlBottom.left = new FormAttachment(0, 0);
fdlBottom.right = new FormAttachment(middle, -margin);
fdlBottom.top = new FormAttachment(wTop, margin);
wlBottom.setLayoutData(fdlBottom);
wBottom = new Text(shell, SWT.BORDER);
wBottom.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
Text w = (Text) e.widget;
bottomMargin = Const.toDouble(w.getText(), 0.00);
}
});
props.setLook(wBottom);
fdBottom = new FormData();
fdBottom.left = new FormAttachment(middle, 0);
fdBottom.top = new FormAttachment(wTop, margin);
fdBottom.right = new FormAttachment(100, 0);
wBottom.setLayoutData(fdBottom);
// Some buttons
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
fdOK = new FormData();
fdOK.left = new FormAttachment(33, 0);
fdOK.bottom = new FormAttachment(100, 0);
wOK.setLayoutData(fdOK);
fdCancel = new FormData();
fdCancel.left = new FormAttachment(66, 0);
fdCancel.bottom = new FormAttachment(100, 0);
wCancel.setLayoutData(fdCancel);
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
wOK.addListener(SWT.Selection, lsOK);
wCancel.addListener(SWT.Selection, lsCancel);
// Detect [X] or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
getData();
BaseStepDialog.setSize(shell);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return retval;
}
use of org.eclipse.swt.events.PaintEvent in project pentaho-kettle by pentaho.
the class CheckBoxToolTip method createToolTipContentArea.
protected Composite createToolTipContentArea(Event event, Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
FormLayout compLayout = new FormLayout();
compLayout.marginHeight = 5;
compLayout.marginWidth = 5;
composite.setLayout(compLayout);
composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
Label imageLabel = new Label(composite, SWT.NONE);
imageLabel.setImage(image);
imageLabel.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
FormData fdImageLabel = new FormData();
fdImageLabel.left = new FormAttachment(0, 0);
fdImageLabel.top = new FormAttachment(0, 0);
imageLabel.setLayoutData(fdImageLabel);
Label titleLabel = new Label(composite, SWT.LEFT);
titleLabel.setText(title);
titleLabel.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
titleLabel.setFont(GUIResource.getInstance().getFontBold());
FormData fdTitleLabel = new FormData();
fdTitleLabel.left = new FormAttachment(imageLabel, 20);
fdTitleLabel.top = new FormAttachment(0, 0);
titleLabel.setLayoutData(fdTitleLabel);
Label line = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
line.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
FormData fdLine = new FormData();
fdLine.left = new FormAttachment(imageLabel, 5);
fdLine.right = new FormAttachment(100, -5);
fdLine.top = new FormAttachment(titleLabel, 5);
line.setLayoutData(fdLine);
// Text messageLabel = new Text(composite, SWT.LEFT | ( showingScrollBars ? SWT.H_SCROLL | SWT.V_SCROLL : SWT.NONE )
// );
/*
* Text messageLabel = new Text(composite, SWT.SINGLE | SWT.LEFT); messageLabel.setText(message);
* messageLabel.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); FormData fdMessageLabel = new
* FormData(); fdMessageLabel.left = new FormAttachment(imageLabel, 20); fdMessageLabel.top = new
* FormAttachment(line, 5); if (showingScrollBars) { fdMessageLabel.right = new FormAttachment(imageLabel, 500);
* fdMessageLabel.bottom= new FormAttachment(line, 400); } messageLabel.setLayoutData(fdMessageLabel);
*/
Label messageLabel = new Label(composite, SWT.LEFT);
messageLabel.setText(message);
messageLabel.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
FormData fdMessageLabel = new FormData();
fdMessageLabel.left = new FormAttachment(imageLabel, 20);
fdMessageLabel.top = new FormAttachment(line, 5);
messageLabel.setLayoutData(fdMessageLabel);
final Button disable = new Button(composite, SWT.CHECK);
disable.setText(checkBoxMessage);
disable.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
disable.setSelection(false);
FormData fdDisable = new FormData();
fdDisable.left = new FormAttachment(0, 0);
fdDisable.top = new FormAttachment(messageLabel, 20);
fdDisable.bottom = new FormAttachment(100, 0);
disable.setLayoutData(fdDisable);
disable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
for (CheckBoxToolTipListener listener : listeners) {
listener.checkBoxSelected(false);
}
hide();
}
});
disable.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent arg0) {
checkBoxBounds = disable.getBounds();
}
});
composite.layout();
checkBoxBounds = disable.getBounds();
return composite;
}
Aggregations