use of org.eclipse.swt.widgets.Display in project translationstudio8 by heartsome.
the class GridDragSourceEffect method getDragSourceImage.
Image getDragSourceImage(DragSourceEvent event) {
if (dragSourceImage != null)
dragSourceImage.dispose();
dragSourceImage = null;
Grid grid = (Grid) getControl();
Display display = grid.getDisplay();
Rectangle empty = new Rectangle(0, 0, 0, 0);
// Collect the currently selected items.
Point[] selection;
if (grid.getCellSelectionEnabled()) {
selection = grid.getCellSelection();
} else {
List l = new ArrayList();
GridItem[] selItems = grid.getSelection();
for (int i = 0; i < selItems.length; i++) {
for (int j = 0; j < grid.getColumnCount(); j++) {
if (grid.getColumn(j).isVisible()) {
l.add(new Point(j, grid.indexOf(selItems[i])));
}
}
}
selection = (Point[]) l.toArray(new Point[l.size()]);
}
if (selection.length == 0)
return null;
Rectangle bounds = null;
for (int i = 0; i < selection.length; i++) {
GridItem item = grid.getItem(selection[i].y);
Rectangle currBounds = item.getBounds(selection[i].x);
if (empty.equals(currBounds)) {
selection[i] = null;
} else {
if (bounds == null) {
bounds = currBounds;
} else {
bounds = bounds.union(currBounds);
}
}
}
if (bounds == null)
return null;
if (bounds.width <= 0 || bounds.height <= 0)
return null;
dragSourceImage = new Image(display, bounds.width, bounds.height);
GC gc = new GC(dragSourceImage);
for (int i = 0; i < selection.length; i++) {
if (selection[i] == null)
continue;
GridItem item = grid.getItem(selection[i].y);
GridColumn column = grid.getColumn(selection[i].x);
Rectangle currBounds = item.getBounds(selection[i].x);
GridCellRenderer r = column.getCellRenderer();
r.setBounds(currBounds.x - bounds.x, currBounds.y - bounds.y, currBounds.width, currBounds.height);
gc.setClipping(currBounds.x - bounds.x - 1, currBounds.y - bounds.y - 1, currBounds.width + 2, currBounds.height + 2);
r.setColumn(selection[i].x);
r.setSelected(false);
r.setFocus(false);
r.setRowFocus(false);
r.setCellFocus(false);
r.setRowHover(false);
r.setColumnHover(false);
r.setCellSelected(false);
r.setHoverDetail("");
r.setDragging(true);
r.paint(gc, item);
gc.setClipping((Rectangle) null);
}
gc.dispose();
return dragSourceImage;
}
use of org.eclipse.swt.widgets.Display in project translationstudio8 by heartsome.
the class Application method createUI.
@Override
public int createUI() {
Display display = PlatformUI.createDisplay();
WorkbenchAdvisor advisor = new ApplicationWorkbenchAdvisor();
return PlatformUI.createAndRunWorkbench(display, advisor);
}
use of org.eclipse.swt.widgets.Display in project translationstudio8 by heartsome.
the class Application method stop.
public void stop() {
final IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench == null) {
return;
}
final Display display = workbench.getDisplay();
display.syncExec(new Runnable() {
public void run() {
if (!display.isDisposed()) {
workbench.close();
}
}
});
}
use of org.eclipse.swt.widgets.Display in project translationstudio8 by heartsome.
the class Application method start.
public Object start(IApplicationContext context) {
Display display = PlatformUI.createDisplay();
try {
PreferenceUtil.initProductEdition();
deleteErrorMemoryInfo();
initSystemLan();
PreferenceUtil.checkCleanValue();
int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
if (returnCode == PlatformUI.RETURN_RESTART) {
return IApplication.EXIT_RESTART;
}
return IApplication.EXIT_OK;
} finally {
display.dispose();
}
}
use of org.eclipse.swt.widgets.Display in project translationstudio8 by heartsome.
the class SeparatorPanel method initComponents.
public void initComponents(String label) {
GridLayout gridLayout = new GridLayout(2, false);
setLayout(gridLayout);
GridData layoutData = new GridData();
layoutData.grabExcessHorizontalSpace = true;
layoutData.horizontalAlignment = GridData.FILL;
setLayoutData(layoutData);
// Text label
StyledText gridLinesLabel = new StyledText(this, SWT.NONE);
gridLinesLabel.setEditable(false);
Display display = Display.getDefault();
FontData data = display.getSystemFont().getFontData()[0];
Font font = new Font(display, data.getName(), data.getHeight(), SWT.BOLD);
gridLinesLabel.setFont(font);
gridLinesLabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
gridLinesLabel.setText(label);
// Separator line
Label separator = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
GridData separatorData = new GridData();
separatorData.grabExcessHorizontalSpace = true;
separatorData.horizontalAlignment = GridData.FILL;
separatorData.horizontalIndent = 5;
separator.setLayoutData(separatorData);
}
Aggregations