Search in sources :

Example 66 with Rectangle

use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.

the class InputDialog method setErrorMessage.

/**
	 * Sets or clears the error message. If not <code>null</code>, the OK button is disabled.
	 * @param errorMessage
	 *            the error message, or <code>null</code> to clear
	 * @since 3.0
	 */
public void setErrorMessage(String errorMessage) {
    this.errorMessage = errorMessage;
    if (errorMessageText != null && !errorMessageText.isDisposed()) {
        String msg = errorMessageText.getText();
        msg = msg == null ? "" : msg;
        //$NON-NLS-1$
        errorMessageText.setText(errorMessage == null ? "" : errorMessage);
        // Disable the error message text control if there is no error, or
        // no error text (empty or whitespace only). Hide it also to avoid
        // color change.
        // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=130281
        boolean hasError = errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
        errorMessageText.setEnabled(hasError);
        errorMessageText.setVisible(hasError);
        errorMessageText.getParent().update();
        String msg2 = errorMessageText.getText();
        if (!msg.equals(msg2) && initLocation != null && initSize != null) {
            Point p = getShell().computeSize(initSize.x, SWT.DEFAULT);
            getShell().setBounds(getConstrainedShellBounds(new Rectangle(initLocation.x, initLocation.y, initSize.x, p.y)));
        }
        // Access the ok button by id, in case clients have overridden button creation.
        // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=113643
        Control button = getButton(IDialogConstants.OK_ID);
        if (button != null) {
            button.setEnabled(errorMessage == null);
        }
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point)

Example 67 with Rectangle

use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.

the class HorizontalRowSelectionModel method getSelections.

public List<Rectangle> getSelections() {
    List<Rectangle> selectionRectangles = new ArrayList<Rectangle>();
    selectionsLock.readLock().lock();
    try {
        int width = selectionLayer.getColumnCount();
        for (int selectedRow : selectedRows) {
            if (selectedRow > -1) {
                selectionRectangles.add(new Rectangle(0, selectedRow, width, 1));
            }
        }
    } finally {
        selectionsLock.readLock().unlock();
    }
    return selectionRectangles;
}
Also used : ArrayList(java.util.ArrayList) Rectangle(org.eclipse.swt.graphics.Rectangle)

Example 68 with Rectangle

use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.

the class ExportToExcelCommandHandler method setClientAreaToMaximum.

private void setClientAreaToMaximum() {
    final Rectangle maxClientArea = new Rectangle(0, 0, gridLayer.getWidth(), gridLayer.getHeight());
    gridLayer.setClientAreaProvider(new IClientAreaProvider() {

        public Rectangle getClientArea() {
            return maxClientArea;
        }
    });
    gridLayer.doCommand(new PrintEntireGridCommand());
}
Also used : IClientAreaProvider(net.sourceforge.nattable.util.IClientAreaProvider) Rectangle(org.eclipse.swt.graphics.Rectangle) PrintEntireGridCommand(net.sourceforge.nattable.print.command.PrintEntireGridCommand)

Example 69 with Rectangle

use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.

the class NatTable method getPixelRectangleFromPositionRectangle.

protected Rectangle getPixelRectangleFromPositionRectangle(Rectangle positionRectangle) {
    int positionRectWidthInPixels = 0;
    int positionRectHeightInPixels = 0;
    Rectangle pixelRectangle = new Rectangle(0, 0, 0, 0);
    for (int i = positionRectangle.x; i < (positionRectangle.x + positionRectangle.width); i++) {
        positionRectWidthInPixels += getColumnWidthByPosition(i);
    }
    for (int i = positionRectangle.y; i < (positionRectangle.y + positionRectangle.height); i++) {
        positionRectHeightInPixels += getRowHeightByPosition(i);
    }
    pixelRectangle.x = getStartXOfColumnPosition(positionRectangle.x);
    pixelRectangle.y = getStartYOfRowPosition(positionRectangle.y);
    pixelRectangle.width = positionRectWidthInPixels;
    pixelRectangle.height = positionRectHeightInPixels;
    return pixelRectangle;
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle)

Example 70 with Rectangle

use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.

the class NatTable method internalSetLayer.

private void internalSetLayer(ILayer layer) {
    if (layer != null) {
        this.underlyingLayer = layer;
        underlyingLayer.setClientAreaProvider(new IClientAreaProvider() {

            public Rectangle getClientArea() {
                if (!isDisposed()) {
                    return NatTable.this.getClientArea();
                } else
                    return new Rectangle(0, 0, 0, 0);
            }
        });
        underlyingLayer.addLayerListener(this);
    }
}
Also used : IClientAreaProvider(net.sourceforge.nattable.util.IClientAreaProvider) Rectangle(org.eclipse.swt.graphics.Rectangle)

Aggregations

Rectangle (org.eclipse.swt.graphics.Rectangle)651 Point (org.eclipse.swt.graphics.Point)370 Image (org.eclipse.swt.graphics.Image)114 GC (org.eclipse.swt.graphics.GC)104 Test (org.junit.Test)80 Color (org.eclipse.swt.graphics.Color)61 Shell (org.eclipse.swt.widgets.Shell)54 Composite (org.eclipse.swt.widgets.Composite)53 SelectionEvent (org.eclipse.swt.events.SelectionEvent)51 TableItem (org.eclipse.swt.widgets.TableItem)47 GridLayout (org.eclipse.swt.layout.GridLayout)44 Display (org.eclipse.swt.widgets.Display)44 Button (org.eclipse.swt.widgets.Button)42 Menu (org.eclipse.swt.widgets.Menu)40 GridData (org.eclipse.swt.layout.GridData)38 Label (org.eclipse.swt.widgets.Label)37 SWT (org.eclipse.swt.SWT)34 Event (org.eclipse.swt.widgets.Event)34 Font (org.eclipse.swt.graphics.Font)30 Listener (org.eclipse.swt.widgets.Listener)29