use of org.eclipse.swt.widgets.Widget in project eclipse.themes.darker by jinmingjian.
the class CSSPropertyDarkerButtonBackgroundColorHandler method applyCSSProperty.
public boolean applyCSSProperty(Object element, String property, CSSValue value, String pseudo, CSSEngine engine) throws Exception {
final Widget widget = SWTElementHelpers.getWidget(element);
final Display display = widget.getDisplay();
final Color color = (Color) engine.convert(value, Color.class, display);
if (widget instanceof Button) {
final Button b = (Button) widget;
if ((b.getStyle() & SWT.PUSH) != 0) {
b.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
b.setBackground(color);
e.gc.setBackground(color);
e.gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
e.gc.fillRoundRectangle(0, 0, b.getBounds().width, b.getBounds().height, 2, 2);
// e.gc.drawRoundRectangle(0, 0,
// b.getBounds().width,
// b.getBounds().height,
// 2, 2);
e.gc.drawString(b.getText(), 5, 5);
}
});
return true;
}
}
return false;
}
use of org.eclipse.swt.widgets.Widget in project dbeaver by serge-rider.
the class TreeLoadVisualizer method completeLoading.
@Override
public void completeLoading(Object[] children) {
final Control viewerControl = viewer.getControl();
if (viewerControl.isDisposed()) {
return;
}
try {
viewerControl.setRedraw(false);
Widget widget = viewer.testFindItem(parent);
if (widget != null && !widget.isDisposed()) {
TreeItem item = (TreeItem) viewer.testFindItem(placeHolder);
if (children == null) {
// Some error occurred. In good case children must be at least an empty array
viewer.collapseToLevel(parent, -1);
} else if (children.length != 0) {
viewer.add(parent, children);
}
if (item != null && !item.isDisposed()) {
if (item.getParentItem() != null && !item.getParentItem().isDisposed() || this.parent instanceof IWorkspaceRoot) {
viewer.remove(placeHolder);
}
}
}
} finally {
placeHolder.dispose(parent);
if (!viewerControl.isDisposed()) {
viewerControl.setRedraw(true);
}
}
}
use of org.eclipse.swt.widgets.Widget in project translationstudio8 by heartsome.
the class WizardFileSystemResourceExportPage2 method handleEvent.
/**
* Handle all events and enablements for widgets in this page
* @param e
* Event
*/
public void handleEvent(Event e) {
Widget source = e.widget;
if (source == destinationBrowseButton) {
handleDestinationBrowseButtonPressed();
}
updatePageCompletion();
}
use of org.eclipse.swt.widgets.Widget in project azure-tools-for-java by Microsoft.
the class DropDownHandler method pullDropdown.
public void pullDropdown(Event event) {
Widget widget = event.widget;
if (widget instanceof ToolItem) {
ToolItem toolItem = (ToolItem) widget;
Listener[] listeners = toolItem.getListeners(SWT.Selection);
if (listeners.length > 0) {
Listener listener = listeners[0];
Event eve = new Event();
eve.type = SWT.Selection;
eve.widget = toolItem;
eve.detail = SWT.DROP_DOWN;
eve.x = toolItem.getBounds().x;
eve.y = toolItem.getBounds().height;
listener.handleEvent(eve);
}
}
}
use of org.eclipse.swt.widgets.Widget in project tdi-studio-se by Talend.
the class SchemasTreeDnD method addDragAndDrop.
public void addDragAndDrop() {
// drag
DragSource source = new DragSource(getTree(), operations);
source.setTransfer(transferTypes);
source.addDragListener(new TreeDragSourceEffect(getTree()));
// drop
DropTarget target = new DropTarget(getTree(), operations);
target.setTransfer(transferTypes);
target.addDropListener(new TreeDropTargetEffect(getTree()) {
private SchemasKeyData source;
@Override
public void dragEnter(DropTargetEvent event) {
super.dragEnter(event);
Widget item = event.item;
if (item != null) {
TreeItem treeItem = (TreeItem) event.item;
Object data = treeItem.getData();
if (data != null && data instanceof SchemasKeyData) {
this.source = (SchemasKeyData) data;
event.feedback = DND.FEEDBACK_EXPAND;
return;
}
}
event.detail = DND.DROP_NONE;
}
@Override
public void drop(DropTargetEvent event) {
super.drop(event);
if (event.item != null && source != null) {
TreeItem item = (TreeItem) event.item;
Object data = item.getData();
if (data != null && data instanceof SchemasKeyData) {
SchemasKeyData target = (SchemasKeyData) data;
target.addChild(source);
schemaTreeViewer.refresh();
}
}
source = null;
}
});
}
Aggregations