use of org.eclipse.swt.widgets.Canvas in project dbeaver by dbeaver.
the class ERDOutlinePage method createControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControl(Composite parent) {
// create canvas and lws
overview = new Canvas(parent, SWT.NONE);
LightweightSystem lws = new LightweightSystem(overview);
// create thumbnail
thumbnail = new ScrollableThumbnail((Viewport) rootEditPart.getFigure());
thumbnail.setBorder(new MarginBorder(3));
thumbnail.setSource(rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS));
lws.setContents(thumbnail);
}
use of org.eclipse.swt.widgets.Canvas in project dbeaver by dbeaver.
the class EmptyPresentation method createPresentation.
@Override
public void createPresentation(@NotNull final IResultSetController controller, @NotNull Composite parent) {
super.createPresentation(controller, parent);
UIUtils.createHorizontalLine(parent);
placeholder = new Canvas(parent, SWT.NONE);
placeholder.setLayoutData(new GridData(GridData.FILL_BOTH));
placeholder.setBackground(controller.getDefaultBackground());
final Font normalFont = parent.getFont();
FontData[] fontData = normalFont.getFontData();
fontData[0].setStyle(fontData[0].getStyle() | SWT.BOLD);
fontData[0].setHeight(18);
final Font largeFont = new Font(normalFont.getDevice(), fontData[0]);
placeholder.addDisposeListener(e -> UIUtils.dispose(largeFont));
placeholder.addPaintListener(e -> {
if (controller.isRefreshInProgress()) {
return;
}
e.gc.setFont(largeFont);
e.gc.setForeground(UIStyles.getDefaultTextForeground());
// int fontSize = largeFont.getFontData()[0].getHeight();
String emptyDataMessage = controller.getDecorator().getEmptyDataMessage();
if (!CommonUtils.isEmpty(emptyDataMessage)) {
Point emSize = e.gc.textExtent(emptyDataMessage);
UIUtils.drawMessageOverControl(placeholder, e, emptyDataMessage, -emSize.y);
}
e.gc.setFont(normalFont);
String emptyDataDescription = controller.getDecorator().getEmptyDataDescription();
if (!CommonUtils.isEmpty(emptyDataDescription)) {
UIUtils.drawMessageOverControl(placeholder, e, emptyDataDescription, 10);
}
});
trackPresentationControl();
}
use of org.eclipse.swt.widgets.Canvas in project yamcs-studio by yamcs.
the class OPIColorDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
var parent_Composite = (Composite) super.createDialogArea(parent);
var mainComposite = new Composite(parent_Composite, SWT.None);
mainComposite.setLayout(new GridLayout(2, false));
var gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.heightHint = 300;
mainComposite.setLayoutData(gridData);
var leftComposite = new Composite(mainComposite, SWT.None);
leftComposite.setLayout(new GridLayout(1, false));
var gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 220;
leftComposite.setLayoutData(gd);
createLabel(leftComposite, "Choose from Predefined Colors:");
preDefinedColorsViewer = createPredefinedColorsTableViewer(leftComposite);
preDefinedColorsViewer.setInput(MediaService.getInstance().getAllPredefinedColors());
var rightComposite = new Composite(mainComposite, SWT.None);
rightComposite.setLayout(new GridLayout(1, false));
gd = new GridData(SWT.LEFT, SWT.BEGINNING, true, true);
rightComposite.setLayoutData(gd);
createLabel(rightComposite, "");
var colorDialogButton = new Button(rightComposite, SWT.PUSH);
colorDialogButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
colorDialogButton.setText("Choose from Color Dialog");
colorDialogButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
var dialog = new ColorDialog(Display.getCurrent().getActiveShell());
dialog.setRGB(opiColor.getRGBValue());
var rgb = dialog.open();
if (rgb != null) {
opiColor.setColorValue(rgb);
preDefinedColorsViewer.setSelection(null);
setRGBEditValue(rgb);
outputTextLabel.setText(opiColor.getColorName());
colorCanvas.setBackground(CustomMediaFactory.getInstance().getColor(opiColor.getRGBValue()));
}
}
});
createRGBEditGroup(rightComposite);
var group = new Group(rightComposite, SWT.None);
group.setLayoutData(new GridData(SWT.FILL, SWT.END, true, true));
group.setLayout(new GridLayout(3, false));
group.setText("Output");
colorCanvas = new Canvas(group, SWT.BORDER);
colorCanvas.setBackground(CustomMediaFactory.getInstance().getColor(opiColor.getRGBValue()));
gd = new GridData(SWT.LEFT, SWT.TOP, false, false);
gd.widthHint = 30;
gd.heightHint = 30;
colorCanvas.setLayoutData(gd);
outputTextLabel = new Label(group, SWT.None);
outputTextLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
outputTextLabel.setText(opiColor.getColorName());
if (opiColor.isPreDefined()) {
preDefinedColorsViewer.setSelection(new StructuredSelection(opiColor));
} else {
preDefinedColorsViewer.setSelection(null);
}
return parent_Composite;
}
use of org.eclipse.swt.widgets.Canvas in project yamcs-studio by yamcs.
the class OverviewOutlinePage method createControl.
@Override
public void createControl(Composite parent) {
overview = new Canvas(parent, SWT.NONE);
var lws = new LightweightSystem(overview);
thumbnail = new ScrollableThumbnail((Viewport) rootEP.getFigure());
thumbnail.setBorder(new MarginBorder(3));
thumbnail.setSource(rootEP.getLayer(LayerConstants.PRINTABLE_LAYERS));
lws.setContents(thumbnail);
disposeListener = e -> {
if (thumbnail != null) {
thumbnail.deactivate();
thumbnail = null;
}
};
rootEP.getViewer().getControl().addDisposeListener(disposeListener);
}
use of org.eclipse.swt.widgets.Canvas in project pentaho-kettle by pentaho.
the class Sleak method create.
public void create(Composite parent) {
list = new List(parent, SWT.BORDER | SWT.V_SCROLL);
list.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
refreshObject();
}
});
text = new Text(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
canvas = new Canvas(parent, SWT.BORDER);
canvas.addListener(SWT.Paint, new Listener() {
public void handleEvent(Event event) {
paintCanvas(event);
}
});
check = new Button(parent, SWT.CHECK);
check.setText("Stack");
check.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
toggleStackTrace();
}
});
start = new Button(parent, SWT.PUSH);
start.setText("Snap");
start.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
refreshAll();
}
});
stop = new Button(parent, SWT.PUSH);
stop.setText("Diff");
stop.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
refreshDifference();
}
});
label = new Label(parent, SWT.BORDER);
label.setText("0 object(s)");
parent.addListener(SWT.Resize, new Listener() {
public void handleEvent(Event e) {
layout();
}
});
check.setSelection(false);
text.setVisible(false);
layout();
}
Aggregations