You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by ha...@apache.org on 2021/01/02 23:09:30 UTC
[incubator-hop] branch master updated: HOP-1491: Integrate Hop Web
codes
This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hop.git
The following commit(s) were added to refs/heads/master by this push:
new 42e01d8 HOP-1491: Integrate Hop Web codes
new d1c6385 Merge pull request #525 from HiromuHota/HOP-1491
42e01d8 is described below
commit 42e01d8f3a08af6092ed19f77aec98c8193ba7fa
Author: Hiromu Hota <hi...@gmail.com>
AuthorDate: Sat Jan 2 09:11:22 2021 -0800
HOP-1491: Integrate Hop Web codes
---
.../java/org/apache/hop/ui/core/gui/GuiResource.java | 2 +-
.../java/org/apache/hop/ui/core/widget/TableView.java | 17 +++++++++++++++++
ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java | 18 +++++++++++++++++-
.../org/apache/hop/ui/hopgui/HopGuiEnvironment.java | 10 ++++++++++
.../hop/ui/hopgui/file/pipeline/HopGuiLogBrowser.java | 11 ++++++++++-
5 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/ui/src/main/java/org/apache/hop/ui/core/gui/GuiResource.java b/ui/src/main/java/org/apache/hop/ui/core/gui/GuiResource.java
index f166431..a3dd711 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/gui/GuiResource.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/gui/GuiResource.java
@@ -263,7 +263,7 @@ public class GuiResource {
* GuiResource also contains the clipboard as it has to be allocated only once! I don't want to put it in a separate
* singleton just for this one member.
*/
- private static Clipboard clipboard;
+ private Clipboard clipboard;
protected GuiResource() {
this(Display.getCurrent());
diff --git a/ui/src/main/java/org/apache/hop/ui/core/widget/TableView.java b/ui/src/main/java/org/apache/hop/ui/core/widget/TableView.java
index c2c976f..4bf895c 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/widget/TableView.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/widget/TableView.java
@@ -18,6 +18,7 @@
package org.apache.hop.ui.core.widget;
+import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.hop.core.Condition;
import org.apache.hop.core.Const;
@@ -117,6 +118,10 @@ public class TableView extends Composite {
private static final Class<?> PKG = TableView.class; // Needed by Translator
+ // define CANCEL_KEYS here so that RWT needs not to be imported.
+ // HiromuHota/pentaho-kettle#123
+ private static final String CANCEL_KEYS = "org.eclipse.rap.rwt.cancelKeys";
+
private Composite parent;
private ColumnInfo[] columns;
private int rows;
@@ -1193,6 +1198,7 @@ public class TableView extends Composite {
lsTraverse = e -> e.doit = false;
table.addTraverseListener( lsTraverse );
+ table.setData( CANCEL_KEYS, new String[] { "TAB", "SHIFT+TAB" } );
// Clean up the clipboard
addDisposeListener( e -> {
@@ -1794,6 +1800,12 @@ public class TableView extends Composite {
return null;
}
+ // Table.getSelection() of RWT are ordered reversely.
+ // HiromuHota/pentaho-kettle#156
+ if (EnvironmentUtils.getInstance().isWeb()) {
+ ArrayUtils.reverse(items);
+ }
+
for ( int r = 0; r < items.length; r++ ) {
TableItem ti = items[ r ];
for ( int c = 1; c < table.getColumnCount(); c++ ) {
@@ -2178,6 +2190,7 @@ public class TableView extends Composite {
textWidget.setToolTipText( "" );
}
textWidget.addTraverseListener( lsTraverse );
+ textWidget.setData( CANCEL_KEYS, new String[] { "TAB", "SHIFT+TAB" } );
textWidget.addFocusListener( lsFocusText );
} else {
Text textWidget = new Text( table, SWT.NONE );
@@ -2201,6 +2214,7 @@ public class TableView extends Composite {
textWidget.setToolTipText( "" );
}
textWidget.addTraverseListener( lsTraverse );
+ textWidget.setData( CANCEL_KEYS, new String[] { "TAB", "SHIFT+TAB" } );
textWidget.addFocusListener( lsFocusText );
}
props.setLook( text, Props.WIDGET_STYLE_TABLE );
@@ -2323,6 +2337,7 @@ public class TableView extends Composite {
}
props.setLook( widget, Props.WIDGET_STYLE_TABLE );
widget.addTraverseListener( lsTraverse );
+ widget.setData( CANCEL_KEYS, new String[] { "TAB", "SHIFT+TAB" } );
widget.addModifyListener( lsModCombo );
widget.addFocusListener( lsFocusCombo );
@@ -2351,6 +2366,7 @@ public class TableView extends Composite {
CCombo widget = (CCombo) combo;
props.setLook( widget, Props.WIDGET_STYLE_TABLE );
widget.addTraverseListener( lsTraverse );
+ widget.setData( CANCEL_KEYS, new String[] { "TAB", "SHIFT+TAB" } );
widget.addModifyListener( lsModCombo );
widget.addFocusListener( lsFocusCombo );
@@ -2420,6 +2436,7 @@ public class TableView extends Composite {
button.setToolTipText( "" );
}
button.addTraverseListener( lsTraverse ); // hop to next field
+ button.setData( CANCEL_KEYS, new String[] { "TAB", "SHIFT+TAB" } );
button.addTraverseListener( arg0 -> closeActiveButton() );
editor.horizontalAlignment = SWT.LEFT;
diff --git a/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java b/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
index 8dcf9eb..9713546 100644
--- a/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
+++ b/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
@@ -91,6 +91,7 @@ import org.apache.hop.ui.hopgui.perspective.search.HopSearchPerspective;
import org.apache.hop.ui.hopgui.search.HopGuiSearchLocation;
import org.apache.hop.ui.hopgui.shared.Sleak;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
+import org.apache.hop.ui.util.EnvironmentUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.graphics.DeviceData;
@@ -259,6 +260,7 @@ public class HopGui
updateMetadataManagers();
HopNamespace.setNamespace(DEFAULT_HOP_GUI_NAMESPACE);
+ shell = new Shell(display, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
}
private void updateMetadataManagers() {
@@ -329,7 +331,6 @@ public class HopGui
/** Build the shell */
protected void open() {
- shell = new Shell(display, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
shell.setImage(GuiResource.getInstance().getImageHopUi());
shell.setText(BaseMessages.getString(PKG, "HopGui.Application.Name"));
@@ -352,6 +353,9 @@ public class HopGui
//
// shell.pack();
shell.open();
+ if (EnvironmentUtils.getInstance().isWeb()) {
+ shell.setMaximized(true);
+ }
openingLastFiles = true; // TODO: make this configurable.
@@ -369,6 +373,10 @@ public class HopGui
if (openingLastFiles) {
auditDelegate.openLastFiles();
}
+ // On RAP, return here otherwise UIThread doesn't get terminated properly.
+ if ( EnvironmentUtils.getInstance().isWeb() ) {
+ return;
+ }
boolean retry = true;
while (retry) {
try {
@@ -495,6 +503,10 @@ public class HopGui
mainMenuWidgets.registerGuiPluginObject(this);
mainMenuWidgets.createMenuWidgets(ID_MAIN_MENU, shell, mainMenu);
+ if ( EnvironmentUtils.getInstance().isWeb() ) {
+ mainMenuWidgets.enableMenuItem(HopGui.ID_MAIN_MENU_FILE_EXIT, false);
+ }
+
shell.setMenuBar(mainMenu);
setUndoMenu(null);
}
@@ -1132,6 +1144,10 @@ public class HopGui
return shell;
}
+ public void setShell( Shell shell ) {
+ this.shell = shell;
+ }
+
/**
* Gets display
*
diff --git a/ui/src/main/java/org/apache/hop/ui/hopgui/HopGuiEnvironment.java b/ui/src/main/java/org/apache/hop/ui/hopgui/HopGuiEnvironment.java
index ea77546..b9dfaaf 100644
--- a/ui/src/main/java/org/apache/hop/ui/hopgui/HopGuiEnvironment.java
+++ b/ui/src/main/java/org/apache/hop/ui/hopgui/HopGuiEnvironment.java
@@ -41,6 +41,8 @@ import org.apache.hop.ui.hopgui.file.HopFileTypePluginType;
import org.apache.hop.ui.hopgui.file.HopFileTypeRegistry;
import org.apache.hop.ui.hopgui.file.IHopFileType;
import org.apache.hop.ui.hopgui.perspective.HopPerspectivePluginType;
+import org.apache.hop.ui.util.EnvironmentUtils;
+import org.eclipse.swt.SWT;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -114,10 +116,18 @@ public class HopGuiEnvironment extends HopClientEnvironment {
}
GuiKeyboardShortcut shortcut = method.getAnnotation( GuiKeyboardShortcut.class );
if ( shortcut != null ) {
+ // RAP does not support ESC as a shortcut key.
+ if (EnvironmentUtils.getInstance().isWeb() && shortcut.key() == SWT.ESC) {
+ continue;
+ }
guiRegistry.addKeyboardShortcut( guiPluginClassName, method, shortcut );
}
GuiOsxKeyboardShortcut osxShortcut = method.getAnnotation( GuiOsxKeyboardShortcut.class );
if ( osxShortcut != null ) {
+ // RAP does not support ESC as a shortcut key.
+ if (EnvironmentUtils.getInstance().isWeb() && osxShortcut.key() == SWT.ESC) {
+ continue;
+ }
guiRegistry.addKeyboardShortcut( guiPluginClassName, method, osxShortcut );
}
GuiContextAction contextAction = method.getAnnotation( GuiContextAction.class );
diff --git a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiLogBrowser.java b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiLogBrowser.java
index 75337d7..78370e0 100644
--- a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiLogBrowser.java
+++ b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiLogBrowser.java
@@ -97,7 +97,7 @@ public class HopGuiLogBrowser {
final Timer logRefreshTimer = new Timer( "log sniffer Timer" );
TimerTask timerTask = new TimerTask() {
public void run() {
- if ( text.isDisposed() ) {
+ if ( text.isDisposed() || text.getDisplay().isDisposed() ) {
return;
}
@@ -220,6 +220,15 @@ public class HopGuiLogBrowser {
//
text.addDisposeListener( event -> logRefreshTimer.cancel() );
+ // Make sure the timer goes down when the Display is disposed
+ // Lambda expression cannot be used here as it causes SecurityException in RAP.
+ text.getDisplay().disposeExec( new Runnable() {
+ @Override
+ public void run() {
+ logRefreshTimer.cancel();
+ }
+ } );
+
final Menu menu = new Menu( text );
MenuItem item = new MenuItem( menu, SWT.NONE );
item.setText( BaseMessages.getString( PKG, "LogBrowser.CopySelectionToClipboard.MenuItem" ) );