Search in sources :

Example 6 with Display

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;
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) ArrayList(java.util.ArrayList) Point(org.eclipse.swt.graphics.Point) Image(org.eclipse.swt.graphics.Image) Point(org.eclipse.swt.graphics.Point) List(java.util.List) ArrayList(java.util.ArrayList) GC(org.eclipse.swt.graphics.GC) Display(org.eclipse.swt.widgets.Display)

Example 7 with Display

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);
}
Also used : WorkbenchAdvisor(org.eclipse.ui.application.WorkbenchAdvisor) Display(org.eclipse.swt.widgets.Display)

Example 8 with Display

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();
            }
        }
    });
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) Display(org.eclipse.swt.widgets.Display)

Example 9 with Display

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();
    }
}
Also used : Display(org.eclipse.swt.widgets.Display)

Example 10 with Display

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);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) StyledText(org.eclipse.swt.custom.StyledText) FontData(org.eclipse.swt.graphics.FontData) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Font(org.eclipse.swt.graphics.Font) Display(org.eclipse.swt.widgets.Display)

Aggregations

Display (org.eclipse.swt.widgets.Display)191 Shell (org.eclipse.swt.widgets.Shell)49 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)28 InvocationTargetException (java.lang.reflect.InvocationTargetException)25 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)22 Point (org.eclipse.swt.graphics.Point)17 ITask (com.cubrid.common.core.task.ITask)15 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)15 Color (org.eclipse.swt.graphics.Color)15 GridLayout (org.eclipse.swt.layout.GridLayout)14 Button (org.eclipse.swt.widgets.Button)14 FillLayout (org.eclipse.swt.layout.FillLayout)13 GridData (org.eclipse.swt.layout.GridData)12 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)11 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)11 IStatus (org.eclipse.core.runtime.IStatus)11 Status (org.eclipse.core.runtime.Status)11 Composite (org.eclipse.swt.widgets.Composite)11 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)10 ArrayList (java.util.ArrayList)10