Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
package org.eclipse.jface.layout;

import java.io.Serializable;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.RowLayout;
Expand Down Expand Up @@ -215,6 +214,20 @@ public RowLayoutFactory fill(boolean fill) {
return this;
}

/**
* Center specifies whether the controls in a row should be centered vertically
* in each cell for horizontal layouts, or centered horizontally in each cell
* for vertical layouts.
*
* @param center the center status
* @return this
* @since 3.20
*/
public RowLayoutFactory center(boolean center) {
layout.center = center;
return this;
}

/**
* Justify specifies whether the controls in a row should be fully
* justified, with any extra space placed between the controls.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
package org.eclipse.jface.viewers;

import java.io.Serializable;

import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.swt.internal.widgets.ICellToolTipAdapter;
import org.eclipse.swt.internal.widgets.ICellToolTipProvider;
Expand All @@ -30,17 +29,21 @@ final class CellToolTipProvider implements ICellToolTipProvider, Serializable {

static void attach( ColumnViewer viewer, CellLabelProvider labelProvider ) {
ICellToolTipAdapter adapter = getAdapter( viewer );
if( labelProvider != null ) {
CellToolTipProvider provider = new CellToolTipProvider( viewer );
adapter.setCellToolTipProvider( provider );
} else {
adapter.setCellToolTipProvider( null );
if (adapter != null) {
if (labelProvider != null) {
CellToolTipProvider provider = new CellToolTipProvider(viewer);
adapter.setCellToolTipProvider(provider);
} else {
adapter.setCellToolTipProvider(null);
}
}
}

public void getToolTipText( final Item item, final int columnIndex ) {
@Override
public void getToolTipText( final Item item, final int columnIndex ) {
SafeRunnable.run( new SafeRunnable() {
public void run() {
@Override
public void run() {
Object element = item.getData();
ViewerColumn column = viewer.getViewerColumn( columnIndex );
CellLabelProvider labelProvider = column.getLabelProvider();
Expand Down
24 changes: 15 additions & 9 deletions bundles/org.eclipse.rap.rwt/js/rwt/widgets/Browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ rwt.qx.Class.define( "rwt.widgets.Browser", {
try {
result = this._parseEvalResult( this._eval( script ) );
} catch( ex ) {
console.log(ex);
success = false;
}
var connection = rwt.remote.Connection.getInstance();
Expand Down Expand Up @@ -198,7 +199,7 @@ rwt.qx.Class.define( "rwt.widgets.Browser", {
// not accessible when it appears it should be
// => user navigated to external site.
this._throwSecurityException( true );
}
}
}
},

Expand All @@ -215,21 +216,26 @@ rwt.qx.Class.define( "rwt.widgets.Browser", {
},

_eval : function( script ) {
var win = this.getContentWindow();
if( !win[ "eval" ] && win[ "execScript" ] ) {
// Workaround for IE bug, see: http://www.thismuchiknow.co.uk/?p=25
win.execScript( "null;", "JScript" );
}
return win[ "eval" ]( script );
var win = this.getContentWindow();

if (win !== null) {
if( !win[ "eval" ] && win[ "execScript" ] ) {
// Workaround for IE bug, see: http://www.thismuchiknow.co.uk/?p=25
win.execScript( "null;", "JScript" );
}
return win[ "eval" ]( script );
} else {
console.error("Window is null, can not execute scipts:\n" + script);
}
},

_parseEvalResult : function( value ) {
var result = null;
var win = this.getContentWindow();
// NOTE: This mimics the behavior of the evaluate method in SWT:
if( value instanceof win.Function || value instanceof Function ) {
if( (win !== null && value instanceof win.Function) || value instanceof Function ) {
result = this.toJSON( [ [] ] );
} else if( value instanceof win.Array || value instanceof Array ) {
} else if( (win !== null && value instanceof win.Array) || value instanceof Array ) {
result = this.toJSON( [ value ] );
} else if( typeof value !== "object" && typeof value !== "function" ) {
// above: some browser say regular expressions of the type "function"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@
import static org.eclipse.rap.rwt.internal.protocol.ClientMessageConst.EVENT_PARAM_Y;
import static org.eclipse.rap.rwt.internal.protocol.ClientMessageConst.EVENT_TRAVERSE;
import static org.eclipse.rap.rwt.internal.protocol.ProtocolUtil.wasEventSent;
import static org.eclipse.rap.rwt.internal.service.ContextProvider.getApplicationContext;
import static org.eclipse.swt.internal.events.EventLCAUtil.translateButton;
import static org.eclipse.swt.internal.widgets.ControlUtil.getControlAdapter;

import org.eclipse.rap.json.JsonArray;
import org.eclipse.rap.json.JsonObject;
import org.eclipse.rap.json.JsonValue;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Cursor;
Expand Down Expand Up @@ -333,7 +336,18 @@ static Event createMouseEvent( int eventType, Control control, JsonObject proper
event.x = point.x;
event.y = point.y;
event.time = properties.get( EVENT_PARAM_TIME ).asInt();
event.stateMask = readStateMask( properties ) | translateButton( event.button );

if (isSwtMode()) {
event.stateMask = readStateMask( properties );
// [pw] The button mask confuses NatTable MouseEventMatcher since
// the button mask is not there in SWT except in MouseUp event,
// see Widget.class line 1351 (in swt)
if ( SWT.MouseUp == eventType ) {
event.stateMask |= translateButton( event.button );
}
} else {
event.stateMask = readStateMask( properties ) | translateButton( event.button );
}
// TODO: send count by the client
event.count = determineCount( eventType, control );
return event;
Expand Down Expand Up @@ -540,4 +554,7 @@ private static int translateCursor( String cursor ) {
return result;
}

private static boolean isSwtMode() {
return getApplicationContext().getLifeCycleFactory().getLifeCycle() instanceof RWTLifeCycle;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TypedListener;


Expand Down Expand Up @@ -80,6 +81,7 @@ public class Browser extends Composite {
private BrowserCallback browserCallback;
private transient IBrowserAdapter browserAdapter;
private final List<BrowserFunction> functions;
private boolean clientInited = false;

/**
* Constructs a new instance of this class given its parent
Expand Down Expand Up @@ -258,6 +260,33 @@ public boolean execute( String script ) {
if( executeScript != null ) {
throw new IllegalStateException( "Another script is already pending" );
}

boolean showedShell = false;
Shell shell = getShell();

try {
// Show the shell, so that the browser is created in the browser
if (!clientInited && shell != null && !shell.getVisible()) {
showedShell = true;
//shell.setMinimized(true);
shell.setVisible(true);
internalExecute( "" );
}

internalExecute( script );
} finally {
// if we showed it, we have to hide it again
if (showedShell) {
//shell.setMinimized(false);
shell.setVisible(false);
internalExecute( "" );
}
clientInited = true;
}
return executeResult.booleanValue();
}

protected void internalExecute( String script ) {
executeScript = script;
executeResult = null;
while( executeResult == null ) {
Expand All @@ -268,7 +297,6 @@ public boolean execute( String script ) {
}
executeScript = null;
executePending = false;
return executeResult.booleanValue();
}

/**
Expand Down Expand Up @@ -728,6 +756,7 @@ public void handleEvent( Event event ) {
case EventTypes.LOCALTION_CHANGING: {
LocationListener locationListener = ( LocationListener )getEventListener();
LocationEvent locationEvent = new LocationEvent( event );
locationEvent.doit = event.doit;
locationListener.changing( locationEvent );
event.doit = locationEvent.doit;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ public String toString() {
return string.substring( 0, string.length() - 1 ) // remove trailing '}'
+ " button="
+ button
+ " stateMask="
+ stateMask
+ " stateMask=0x" + Integer.toHexString( stateMask )
+ " x="
+ x
+ " y="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ class ControlGC extends GCDelegate {

ControlGC( Control control ) {
this.control = control;
background = control.getBackground();
foreground = control.getForeground();
font = control.getFont();
font = control.getFontInternal();
background = control.getBackgroundInternal();
foreground = control.getForegroundInternal();
alpha = 255;
lineWidth = 0;
lineCap = SWT.CAP_FLAT;
lineJoin = SWT.JOIN_MITER;
lineStyle = SWT.LINE_SOLID;
}

@Override
void setBackground( Color color ) {
if( !background.equals( color ) ) {
Expand Down Expand Up @@ -207,7 +207,8 @@ void setClipping( Path path ) {
@Override
Rectangle getClipping() {
if( clippingRect == null ) {
return control.getBounds();
Rectangle bounds = control.getBounds();
return new Rectangle( 0, 0, bounds.width, bounds.height );
}
return new Rectangle( clippingRect.x, clippingRect.y, clippingRect.width, clippingRect.height );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.internal.graphics.FontUtil;
import org.eclipse.swt.widgets.Control;


Expand Down Expand Up @@ -1726,9 +1727,9 @@ public void drawText( String string, int x, int y, int flags ) {
checkDisposed();
if( string == null ) {
SWT.error( SWT.ERROR_NULL_ARGUMENT );
}
if( string.length() != 0 ) {
delegate.drawText( string, x, y, flags );
} else if( string.length() != 0 ) {
int normalizedHeight = (int) Math.round(getFont().getFontData()[0].getHeight() / FontUtil.LINE_HEIGHT_FACTOR);
delegate.drawText(string, x, y + FontUtil.getVerticalOffset(normalizedHeight), flags);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,48 @@
******************************************************************************/
package org.eclipse.swt.internal.graphics;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.rap.rwt.internal.service.ServletLog;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;


public class FontUtil {


public static final double LINE_HEIGHT_FACTOR = 1.4;
private static final Map<Integer, Integer> VERTICAL_OFFSET_MAP = new HashMap<>();
static {
VERTICAL_OFFSET_MAP.put( Integer.valueOf(7), Integer.valueOf(2) );
VERTICAL_OFFSET_MAP.put( Integer.valueOf(8), Integer.valueOf(2) );
VERTICAL_OFFSET_MAP.put( Integer.valueOf(9), Integer.valueOf(2) );
VERTICAL_OFFSET_MAP.put( Integer.valueOf(10), Integer.valueOf(4) );
VERTICAL_OFFSET_MAP.put( Integer.valueOf(11), Integer.valueOf(4) );
VERTICAL_OFFSET_MAP.put( Integer.valueOf(12), Integer.valueOf(6) );
VERTICAL_OFFSET_MAP.put( Integer.valueOf(13), Integer.valueOf(6) );
VERTICAL_OFFSET_MAP.put( Integer.valueOf(14), Integer.valueOf(6) );
VERTICAL_OFFSET_MAP.put( Integer.valueOf(15), Integer.valueOf(9) );
}

public static FontData getData( Font font ) {
return font.getFontData()[ 0 ];
}


/**
* + * returns the vertical offset needed for a given character height to simulate Windows
* behavior in + * RAP + * + * @param charHeight + * @return vertical offset in px (default 0 when
* charHeight not in between 7 and 15) +
*/
public static int getVerticalOffset( int charHeight ) {
Integer charHeightInteger = Integer.valueOf( charHeight );
if( VERTICAL_OFFSET_MAP.containsKey( charHeightInteger ) ) {
return VERTICAL_OFFSET_MAP.get( charHeightInteger ).intValue();
}
ServletLog.log( "charHeight must be between 7 and 15 for vertival offset estimation", null );
return 0;
}

private FontUtil() {
// prevent instance creation
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
******************************************************************************/
package org.eclipse.swt.widgets;

import java.io.Serializable;

import org.eclipse.rap.rwt.internal.lifecycle.WidgetLCA;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
Expand Down Expand Up @@ -182,6 +184,10 @@ void internalSetRedraw( boolean redraw, int x, int y, int width, int height ) {
}

private void repaint( Rectangle paintRect ) {
getDisplay().asyncExec( new RepaintRunnable(paintRect));
}

private void repaintSync( Rectangle paintRect ) {
if( gcAdapter != null ) {
gcAdapter.clearGCOperations();
gcAdapter.setForceRedraw( true );
Expand All @@ -190,11 +196,26 @@ private void repaint( Rectangle paintRect ) {
Event paintEvent = new Event();
paintEvent.gc = gc;
paintEvent.setBounds( paintRect );
notifyListeners( SWT.Paint, paintEvent );
notifyListenersInternal( SWT.Paint, paintEvent, true );
gc.dispose();
if( gcAdapter != null ) {
gcAdapter.setPaintRect( paintRect );
}
}

private class RepaintRunnable implements Runnable, Serializable {
private static final long serialVersionUID = 687991492884005033L;
private Rectangle paintRect;

RepaintRunnable(Rectangle paintRect) {
this.paintRect = paintRect;
}

@Override
public void run() {
if( !isDisposed() ) {
repaintSync( paintRect );
}
}
}
}
Loading