Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.scout.rt.ui.rap.mobile/src/org')
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/Activator.java86
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/MobileFormToolkit.java70
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/MobileScoutFormToolkit.java140
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/AbstractRwtScoutActionBar.java650
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/ActionButtonBar.java1160
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/IRwtScoutActionButton.java66
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/RwtScoutActionButton.java768
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/BusyBlockDialog.java244
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/BusyBlockDialogJob.java150
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/MobileWaitForBlockingJob.java58
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/RwtMobileBusyHandler.java72
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/AbstractRwtScoutFormHeader.java206
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileForm.java54
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileFormFooter.java222
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileFormHeader.java268
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileOutlineFormHeader.java134
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileToolButtonBar.java58
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/MobileDateFieldFactory.java110
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/RwtScoutMobileDateField.java90
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/RwtScoutMobileDateTimeCompositeField.java64
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/RwtScoutMobileTimeField.java90
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/chooser/MobileDateChooserDialog.java152
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/chooser/MobileTimeChooser.java62
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/chooser/MobileTimeChooserDialog.java118
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/groupbox/MobileGroupBoxFieldFactory.java90
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/groupbox/RwtScoutMobileGroupBox.java60
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/smartfield/MobileSmartFieldFactory.java90
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/smartfield/RwtScoutMobileSmartField.java340
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tabbox/MobileTabBoxFactory.java156
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tabbox/RwtScoutMobileTabBox.java146
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/IRwtScoutList.java42
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/IRwtScoutListModel.java52
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/ListEx.java98
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/MobileTableFieldFactory.java90
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtMobileTableStatus.java84
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutList.java1222
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutListModel.java382
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutMobileTableField.java346
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutTableActionBar.java340
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/treefield/MobileTreeFieldFactory.java90
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/treefield/RwtScoutMobileTreeField.java54
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/treefield/RwtScoutTreeActionBar.java308
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/MobileBrowserWindowHandler.java86
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/FormBasedDesktopFormBoundsProvider.java124
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/MobileViewArea.java154
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/RwtScoutMobileDesktop.java72
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/RwtScoutMobileDesktopForm.java54
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/RwtScoutMobileViewStack.java122
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/SimpleSash.java82
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/dialog/FixedSizeDialogBoundsProvider.java126
-rw-r--r--org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/dialog/RwtScoutMobileDialog.java180
51 files changed, 5041 insertions, 5041 deletions
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/Activator.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/Activator.java
index 1d60667e73..2bbad370cf 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/Activator.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/Activator.java
@@ -1,43 +1,43 @@
-/*******************************************************************************
- * Copyright (c) 2011 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile;
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- public static final String PLUGIN_ID = "org.eclipse.scout.rt.ui.rap.mobile";
-
- private static Activator m_plugin;
-
- public Activator() {
- }
-
- public static Activator getDefault() {
- return m_plugin;
- }
-
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- m_plugin = this;
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- m_plugin = null;
- super.stop(context);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ public static final String PLUGIN_ID = "org.eclipse.scout.rt.ui.rap.mobile";
+
+ private static Activator m_plugin;
+
+ public Activator() {
+ }
+
+ public static Activator getDefault() {
+ return m_plugin;
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ m_plugin = this;
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ m_plugin = null;
+ super.stop(context);
+ }
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/MobileFormToolkit.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/MobileFormToolkit.java
index 8ca36d853b..3c31a29c82 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/MobileFormToolkit.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/MobileFormToolkit.java
@@ -1,35 +1,35 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-
-public class MobileFormToolkit extends FormToolkit {
-
- public MobileFormToolkit(Display display) {
- super(display);
- }
-
- /**
- * The default method in FormToolkit registers a mouse down listener on the composite which sets the focus on the
- * first field. This is annoying on touchscrens therefore it's removed.
- */
- @Override
- public void adapt(Composite composite) {
- composite.setBackground(getColors().getBackground());
- if (composite.getParent() != null) {
- composite.setMenu(composite.getParent().getMenu());
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class MobileFormToolkit extends FormToolkit {
+
+ public MobileFormToolkit(Display display) {
+ super(display);
+ }
+
+ /**
+ * The default method in FormToolkit registers a mouse down listener on the composite which sets the focus on the
+ * first field. This is annoying on touchscrens therefore it's removed.
+ */
+ @Override
+ public void adapt(Composite composite) {
+ composite.setBackground(getColors().getBackground());
+ if (composite.getParent() != null) {
+ composite.setMenu(composite.getParent().getMenu());
+ }
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/MobileScoutFormToolkit.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/MobileScoutFormToolkit.java
index 8c42219c14..4a5d92acef 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/MobileScoutFormToolkit.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/MobileScoutFormToolkit.java
@@ -1,70 +1,70 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile;
-
-import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
-import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
-import org.eclipse.scout.rt.ui.rap.mobile.action.ActionButtonBar;
-import org.eclipse.scout.rt.ui.rap.util.ScoutFormToolkit;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.forms.widgets.Form;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-
-/**
- * @since 3.9.0
- */
-public class MobileScoutFormToolkit extends ScoutFormToolkit {
-
- public MobileScoutFormToolkit(FormToolkit kit) {
- super(kit);
- }
-
- @Override
- public Form createForm(Composite parent) {
- Form f = super.createForm(parent);
- decorateFormHeading(f);
- return f;
- }
-
- /**
- * Creates a {@link ActionButtonBar}.
- * <p>
- * On mobile devices it additionally removes the tooltips because
- * <ul>
- * <li>displaying a tooltip is buggy with rap (it appears often on simple touch down events but should actually only
- * on long pressed ones)</li>
- * <li>displaying a tooltip is not common on mobile devices</li>
- * </ul>
- */
- public ActionButtonBar createActionButtonBar(Composite parent, IMenu[] menus, int style) {
- if (menus != null) {
- for (IMenu menu : menus) {
- menu.setTooltipText(null);
- }
- }
-
- return new ActionButtonBar(parent, getUiEnvironment(), menus, style);
- }
-
- /**
- * @see #createActionButtonBar(Composite, IMenu[], int)
- */
- public ActionButtonBar createActionButtonBar(Composite parent, IMenu[] menus) {
- return createActionButtonBar(parent, menus, SWT.NONE);
- }
-
- protected IRwtEnvironment getUiEnvironment() {
- return (IRwtEnvironment) Display.getCurrent().getData(IRwtEnvironment.class.getName());
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile;
+
+import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
+import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
+import org.eclipse.scout.rt.ui.rap.mobile.action.ActionButtonBar;
+import org.eclipse.scout.rt.ui.rap.util.ScoutFormToolkit;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.forms.widgets.Form;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * @since 3.9.0
+ */
+public class MobileScoutFormToolkit extends ScoutFormToolkit {
+
+ public MobileScoutFormToolkit(FormToolkit kit) {
+ super(kit);
+ }
+
+ @Override
+ public Form createForm(Composite parent) {
+ Form f = super.createForm(parent);
+ decorateFormHeading(f);
+ return f;
+ }
+
+ /**
+ * Creates a {@link ActionButtonBar}.
+ * <p>
+ * On mobile devices it additionally removes the tooltips because
+ * <ul>
+ * <li>displaying a tooltip is buggy with rap (it appears often on simple touch down events but should actually only
+ * on long pressed ones)</li>
+ * <li>displaying a tooltip is not common on mobile devices</li>
+ * </ul>
+ */
+ public ActionButtonBar createActionButtonBar(Composite parent, IMenu[] menus, int style) {
+ if (menus != null) {
+ for (IMenu menu : menus) {
+ menu.setTooltipText(null);
+ }
+ }
+
+ return new ActionButtonBar(parent, getUiEnvironment(), menus, style);
+ }
+
+ /**
+ * @see #createActionButtonBar(Composite, IMenu[], int)
+ */
+ public ActionButtonBar createActionButtonBar(Composite parent, IMenu[] menus) {
+ return createActionButtonBar(parent, menus, SWT.NONE);
+ }
+
+ protected IRwtEnvironment getUiEnvironment() {
+ return (IRwtEnvironment) Display.getCurrent().getData(IRwtEnvironment.class.getName());
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/AbstractRwtScoutActionBar.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/AbstractRwtScoutActionBar.java
index 1eb07629d3..bfeee35042 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/AbstractRwtScoutActionBar.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/AbstractRwtScoutActionBar.java
@@ -1,325 +1,325 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.action;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.rwt.lifecycle.WidgetUtil;
-import org.eclipse.scout.commons.beans.IPropertyObserver;
-import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
-import org.eclipse.scout.rt.ui.rap.basic.RwtScoutComposite;
-import org.eclipse.scout.rt.ui.rap.mobile.MobileScoutFormToolkit;
-import org.eclipse.scout.rt.ui.rap.util.RwtLayoutUtility;
-import org.eclipse.scout.rt.ui.rap.util.ScoutFormToolkit;
-import org.eclipse.scout.rt.ui.rap.window.desktop.IRwtScoutActionBar;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 3.9.0
- */
-public abstract class AbstractRwtScoutActionBar<T extends IPropertyObserver> extends RwtScoutComposite<T> implements IRwtScoutActionBar<T> {
- private static final String VARIANT_ACTION_BAR_CONTAINER = "actionBarContainer";
-
- private Composite m_leftContainer;
- private ActionButtonBar m_leftButtonBar;
- private Composite m_centerContainer;
- private Composite m_rightContainer;
- private ActionButtonBar m_rightButtonBar;
-
- private boolean m_alwaysVisible = false;
- private Integer m_heightHint;
- private int m_menuOpeningDirection = SWT.DOWN;
- private int m_rightActionBarOrientation = SWT.LEFT_TO_RIGHT;
- private CLabel m_titleField;
-
- @Override
- protected void initializeUi(Composite parent) {
- Composite container = getUiEnvironment().getFormToolkit().createComposite(parent);
- container.setData(WidgetUtil.CUSTOM_VARIANT, getActionBarContainerVariant());
- setUiContainer(container);
-
- createContent();
- }
-
- protected void createContent() {
- m_leftContainer = createLeftContainer(getUiContainer());
- m_centerContainer = createCenterContainer(getUiContainer());
- m_rightContainer = createRightContainer(getUiContainer());
-
- initLayout(getUiContainer());
- computeContainerVisibility();
- }
-
- private void computeContainerVisibility() {
- if (m_leftContainer == null || m_centerContainer == null || m_rightContainer == null) {
- getUiContainer().setVisible(false);
- return;
- }
-
- boolean makeInvisible = !isAlwaysVisible() && !hasContentOnLeftContainer() && !hasContentOnCenterContainer() && !hasContentOnRightContainer();
- getUiContainer().setVisible(!makeInvisible);
- }
-
- protected void initLayout(Composite container) {
- GridLayout containerLayout = RwtLayoutUtility.createGridLayoutNoSpacing(3, false);
- container.setLayout(containerLayout);
-
- {
- GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
- m_leftContainer.setLayoutData(gridData);
- }
-
- {
- GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
- m_centerContainer.setLayoutData(gridData);
- }
-
- {
- GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
- m_rightContainer.setLayoutData(gridData);
- }
-
- adjustGridDataBasedOnTitle();
- }
-
- protected String getActionBarContainerVariant() {
- return VARIANT_ACTION_BAR_CONTAINER;
- }
-
- protected Composite createLeftContainer(Composite parent) {
- m_leftButtonBar = createLeftActionButtonBar(parent, m_leftButtonBar);
-
- return m_leftButtonBar;
- }
-
- protected boolean hasContentOnLeftContainer() {
- if (m_leftButtonBar == null) {
- return false;
- }
-
- return m_leftButtonBar.hasButtons();
- }
-
- protected ActionButtonBar createLeftActionButtonBar(Composite parent, ActionButtonBar existingButtonBar) {
- List<IMenu> menuList = new LinkedList<IMenu>();
- collectMenusForLeftButtonBar(menuList);
-
- ActionButtonBar leftButtonBar = createActionButtonBar(parent, existingButtonBar, menuList, SWT.LEFT | getMenuOpeningDirection());
- adaptLeftButtonBar(leftButtonBar);
-
- return leftButtonBar;
- }
-
- protected void adaptLeftButtonBar(ActionButtonBar buttonBar) {
- }
-
- protected Composite createCenterContainer(Composite parent) {
- return createCenterTitleBar(parent, m_centerContainer);
- }
-
- protected boolean hasContentOnCenterContainer() {
- return getTitle() != null;
- }
-
- protected Composite createCenterTitleBar(Composite parent, Composite existingTitleBar) {
- Composite centerTitleBar = createTitleBar(parent, existingTitleBar);
- adaptCenterTitleBar(centerTitleBar);
-
- return centerTitleBar;
- }
-
- protected void adaptCenterTitleBar(Composite buttonBar) {
- }
-
- protected Composite createRightContainer(Composite parent) {
- m_rightButtonBar = createRightActionButtonBar(parent, m_rightButtonBar);
-
- return m_rightButtonBar;
- }
-
- protected ActionButtonBar createRightActionButtonBar(Composite parent, ActionButtonBar existingButtonBar) {
- List<IMenu> menuList = new LinkedList<IMenu>();
- collectMenusForRightButtonBar(menuList);
-
- ActionButtonBar rightButtonBar = createActionButtonBar(parent, existingButtonBar, menuList, SWT.RIGHT | getMenuOpeningDirection() | getRightActionBarOrientation());
- adaptRightButtonBar(rightButtonBar);
-
- return rightButtonBar;
- }
-
- protected boolean hasContentOnRightContainer() {
- if (m_rightButtonBar == null) {
- return false;
- }
-
- return m_rightButtonBar.hasButtons();
- }
-
- protected void adaptRightButtonBar(ActionButtonBar buttonBar) {
- }
-
- private Composite createTitleBar(Composite parent, Composite existingTitleBar) {
- if (existingTitleBar != null) {
- existingTitleBar.dispose();
- existingTitleBar = null;
- }
-
- return createTitleBar(parent);
- }
-
- protected Composite createTitleBar(Composite parent) {
- m_titleField = getUiEnvironment().getFormToolkit().createCLabel(parent, null, SWT.CENTER);
- m_titleField.setData(WidgetUtil.CUSTOM_VARIANT, getActionBarContainerVariant());
-
- return m_titleField;
- }
-
- private ActionButtonBar createActionButtonBar(Composite parent, ActionButtonBar existingButtonBar, List<IMenu> menuList, int style) {
- if (existingButtonBar != null) {
- existingButtonBar.dispose();
- existingButtonBar = null;
- }
-
- return createActionButtonBar(parent, menuList, style);
- }
-
- protected ActionButtonBar createActionButtonBar(Composite parent, List<IMenu> menus, int style) {
- ScoutFormToolkit formToolkit = getUiEnvironment().getFormToolkit();
- //TODO check for MobileScoutFormToolkit can be removed as soon as ActionButtonBar is moved to core plugin
- if (formToolkit instanceof MobileScoutFormToolkit) {
- IMenu[] menuArray = cleanMenus(menus);
- return ((MobileScoutFormToolkit) formToolkit).createActionButtonBar(parent, menuArray, style);
- }
-
- return null;
- }
-
- /**
- * Removes duplicate menus from the list.
- */
- protected IMenu[] cleanMenus(List<IMenu> menus) {
- List<IMenu> cleanedMenus = new LinkedList<IMenu>();
-
- for (IMenu menu : menus) {
- if (!cleanedMenus.contains(menu)) {
- cleanedMenus.add(menu);
- }
- }
-
- return cleanedMenus.toArray(new IMenu[cleanedMenus.size()]);
- }
-
- public void rebuildContentFromScout() {
- if (isUiDisposed()) {
- return;
- }
-
- Runnable job = new Runnable() {
- @Override
- public void run() {
- if (isUiDisposed()) {
- return;
- }
-
- createContent();
- getUiContainer().getParent().layout(true, true);
- }
- };
- getUiEnvironment().invokeUiLater(job);
- }
-
- protected void setTitle(String title) {
- if (title == null) {
- return;
- }
-
- if (getTitleField() != null) {
- getTitleField().setText(title);
- }
-
- adjustGridDataBasedOnTitle();
- }
-
- /**
- * If there is a title, the center part grabs the excess horizontal space, the other parts NOT. This makes sure the
- * title always uses as much space as possible. This means action button piling is not possible anymore if a title is
- * set.
- * <p>
- * If no title is set the center part will be excluded and the left and the right part grab the excess horizontal
- * space.
- */
- protected void adjustGridDataBasedOnTitle() {
- boolean hasTitle = getTitle() != null;
-
- ((GridData) m_leftContainer.getLayoutData()).grabExcessHorizontalSpace = !hasTitle;
- ((GridData) m_centerContainer.getLayoutData()).exclude = !hasTitle;
- ((GridData) m_rightContainer.getLayoutData()).grabExcessHorizontalSpace = !hasTitle;
- }
-
- public String getTitle() {
- if (getTitleField() == null) {
- return null;
- }
-
- return getTitleField().getText();
- }
-
- public boolean isAlwaysVisible() {
- return m_alwaysVisible;
- }
-
- public void setAlwaysVisible(boolean alwaysVisible) {
- m_alwaysVisible = alwaysVisible;
- }
-
- @Override
- public Integer getHeightHint() {
- return m_heightHint;
- }
-
- @Override
- public void setHeightHint(Integer heightHint) {
- m_heightHint = heightHint;
- }
-
- public int getMenuOpeningDirection() {
- return m_menuOpeningDirection;
- }
-
- public void setMenuOpeningDirection(int menuOpeningDirection) {
- m_menuOpeningDirection = menuOpeningDirection;
- }
-
- public int getRightActionBarOrientation() {
- return m_rightActionBarOrientation;
- }
-
- public void setRightActionBarOrientation(int orientation) {
- m_rightActionBarOrientation = orientation;
- }
-
- public CLabel getTitleField() {
- return m_titleField;
- }
-
- protected void collectMenusForLeftButtonBar(List<IMenu> menuList) {
-
- }
-
- protected void collectMenusForRightButtonBar(List<IMenu> menuList) {
-
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.action;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.rwt.lifecycle.WidgetUtil;
+import org.eclipse.scout.commons.beans.IPropertyObserver;
+import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
+import org.eclipse.scout.rt.ui.rap.basic.RwtScoutComposite;
+import org.eclipse.scout.rt.ui.rap.mobile.MobileScoutFormToolkit;
+import org.eclipse.scout.rt.ui.rap.util.RwtLayoutUtility;
+import org.eclipse.scout.rt.ui.rap.util.ScoutFormToolkit;
+import org.eclipse.scout.rt.ui.rap.window.desktop.IRwtScoutActionBar;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 3.9.0
+ */
+public abstract class AbstractRwtScoutActionBar<T extends IPropertyObserver> extends RwtScoutComposite<T> implements IRwtScoutActionBar<T> {
+ private static final String VARIANT_ACTION_BAR_CONTAINER = "actionBarContainer";
+
+ private Composite m_leftContainer;
+ private ActionButtonBar m_leftButtonBar;
+ private Composite m_centerContainer;
+ private Composite m_rightContainer;
+ private ActionButtonBar m_rightButtonBar;
+
+ private boolean m_alwaysVisible = false;
+ private Integer m_heightHint;
+ private int m_menuOpeningDirection = SWT.DOWN;
+ private int m_rightActionBarOrientation = SWT.LEFT_TO_RIGHT;
+ private CLabel m_titleField;
+
+ @Override
+ protected void initializeUi(Composite parent) {
+ Composite container = getUiEnvironment().getFormToolkit().createComposite(parent);
+ container.setData(WidgetUtil.CUSTOM_VARIANT, getActionBarContainerVariant());
+ setUiContainer(container);
+
+ createContent();
+ }
+
+ protected void createContent() {
+ m_leftContainer = createLeftContainer(getUiContainer());
+ m_centerContainer = createCenterContainer(getUiContainer());
+ m_rightContainer = createRightContainer(getUiContainer());
+
+ initLayout(getUiContainer());
+ computeContainerVisibility();
+ }
+
+ private void computeContainerVisibility() {
+ if (m_leftContainer == null || m_centerContainer == null || m_rightContainer == null) {
+ getUiContainer().setVisible(false);
+ return;
+ }
+
+ boolean makeInvisible = !isAlwaysVisible() && !hasContentOnLeftContainer() && !hasContentOnCenterContainer() && !hasContentOnRightContainer();
+ getUiContainer().setVisible(!makeInvisible);
+ }
+
+ protected void initLayout(Composite container) {
+ GridLayout containerLayout = RwtLayoutUtility.createGridLayoutNoSpacing(3, false);
+ container.setLayout(containerLayout);
+
+ {
+ GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
+ m_leftContainer.setLayoutData(gridData);
+ }
+
+ {
+ GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
+ m_centerContainer.setLayoutData(gridData);
+ }
+
+ {
+ GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
+ m_rightContainer.setLayoutData(gridData);
+ }
+
+ adjustGridDataBasedOnTitle();
+ }
+
+ protected String getActionBarContainerVariant() {
+ return VARIANT_ACTION_BAR_CONTAINER;
+ }
+
+ protected Composite createLeftContainer(Composite parent) {
+ m_leftButtonBar = createLeftActionButtonBar(parent, m_leftButtonBar);
+
+ return m_leftButtonBar;
+ }
+
+ protected boolean hasContentOnLeftContainer() {
+ if (m_leftButtonBar == null) {
+ return false;
+ }
+
+ return m_leftButtonBar.hasButtons();
+ }
+
+ protected ActionButtonBar createLeftActionButtonBar(Composite parent, ActionButtonBar existingButtonBar) {
+ List<IMenu> menuList = new LinkedList<IMenu>();
+ collectMenusForLeftButtonBar(menuList);
+
+ ActionButtonBar leftButtonBar = createActionButtonBar(parent, existingButtonBar, menuList, SWT.LEFT | getMenuOpeningDirection());
+ adaptLeftButtonBar(leftButtonBar);
+
+ return leftButtonBar;
+ }
+
+ protected void adaptLeftButtonBar(ActionButtonBar buttonBar) {
+ }
+
+ protected Composite createCenterContainer(Composite parent) {
+ return createCenterTitleBar(parent, m_centerContainer);
+ }
+
+ protected boolean hasContentOnCenterContainer() {
+ return getTitle() != null;
+ }
+
+ protected Composite createCenterTitleBar(Composite parent, Composite existingTitleBar) {
+ Composite centerTitleBar = createTitleBar(parent, existingTitleBar);
+ adaptCenterTitleBar(centerTitleBar);
+
+ return centerTitleBar;
+ }
+
+ protected void adaptCenterTitleBar(Composite buttonBar) {
+ }
+
+ protected Composite createRightContainer(Composite parent) {
+ m_rightButtonBar = createRightActionButtonBar(parent, m_rightButtonBar);
+
+ return m_rightButtonBar;
+ }
+
+ protected ActionButtonBar createRightActionButtonBar(Composite parent, ActionButtonBar existingButtonBar) {
+ List<IMenu> menuList = new LinkedList<IMenu>();
+ collectMenusForRightButtonBar(menuList);
+
+ ActionButtonBar rightButtonBar = createActionButtonBar(parent, existingButtonBar, menuList, SWT.RIGHT | getMenuOpeningDirection() | getRightActionBarOrientation());
+ adaptRightButtonBar(rightButtonBar);
+
+ return rightButtonBar;
+ }
+
+ protected boolean hasContentOnRightContainer() {
+ if (m_rightButtonBar == null) {
+ return false;
+ }
+
+ return m_rightButtonBar.hasButtons();
+ }
+
+ protected void adaptRightButtonBar(ActionButtonBar buttonBar) {
+ }
+
+ private Composite createTitleBar(Composite parent, Composite existingTitleBar) {
+ if (existingTitleBar != null) {
+ existingTitleBar.dispose();
+ existingTitleBar = null;
+ }
+
+ return createTitleBar(parent);
+ }
+
+ protected Composite createTitleBar(Composite parent) {
+ m_titleField = getUiEnvironment().getFormToolkit().createCLabel(parent, null, SWT.CENTER);
+ m_titleField.setData(WidgetUtil.CUSTOM_VARIANT, getActionBarContainerVariant());
+
+ return m_titleField;
+ }
+
+ private ActionButtonBar createActionButtonBar(Composite parent, ActionButtonBar existingButtonBar, List<IMenu> menuList, int style) {
+ if (existingButtonBar != null) {
+ existingButtonBar.dispose();
+ existingButtonBar = null;
+ }
+
+ return createActionButtonBar(parent, menuList, style);
+ }
+
+ protected ActionButtonBar createActionButtonBar(Composite parent, List<IMenu> menus, int style) {
+ ScoutFormToolkit formToolkit = getUiEnvironment().getFormToolkit();
+ //TODO check for MobileScoutFormToolkit can be removed as soon as ActionButtonBar is moved to core plugin
+ if (formToolkit instanceof MobileScoutFormToolkit) {
+ IMenu[] menuArray = cleanMenus(menus);
+ return ((MobileScoutFormToolkit) formToolkit).createActionButtonBar(parent, menuArray, style);
+ }
+
+ return null;
+ }
+
+ /**
+ * Removes duplicate menus from the list.
+ */
+ protected IMenu[] cleanMenus(List<IMenu> menus) {
+ List<IMenu> cleanedMenus = new LinkedList<IMenu>();
+
+ for (IMenu menu : menus) {
+ if (!cleanedMenus.contains(menu)) {
+ cleanedMenus.add(menu);
+ }
+ }
+
+ return cleanedMenus.toArray(new IMenu[cleanedMenus.size()]);
+ }
+
+ public void rebuildContentFromScout() {
+ if (isUiDisposed()) {
+ return;
+ }
+
+ Runnable job = new Runnable() {
+ @Override
+ public void run() {
+ if (isUiDisposed()) {
+ return;
+ }
+
+ createContent();
+ getUiContainer().getParent().layout(true, true);
+ }
+ };
+ getUiEnvironment().invokeUiLater(job);
+ }
+
+ protected void setTitle(String title) {
+ if (title == null) {
+ return;
+ }
+
+ if (getTitleField() != null) {
+ getTitleField().setText(title);
+ }
+
+ adjustGridDataBasedOnTitle();
+ }
+
+ /**
+ * If there is a title, the center part grabs the excess horizontal space, the other parts NOT. This makes sure the
+ * title always uses as much space as possible. This means action button piling is not possible anymore if a title is
+ * set.
+ * <p>
+ * If no title is set the center part will be excluded and the left and the right part grab the excess horizontal
+ * space.
+ */
+ protected void adjustGridDataBasedOnTitle() {
+ boolean hasTitle = getTitle() != null;
+
+ ((GridData) m_leftContainer.getLayoutData()).grabExcessHorizontalSpace = !hasTitle;
+ ((GridData) m_centerContainer.getLayoutData()).exclude = !hasTitle;
+ ((GridData) m_rightContainer.getLayoutData()).grabExcessHorizontalSpace = !hasTitle;
+ }
+
+ public String getTitle() {
+ if (getTitleField() == null) {
+ return null;
+ }
+
+ return getTitleField().getText();
+ }
+
+ public boolean isAlwaysVisible() {
+ return m_alwaysVisible;
+ }
+
+ public void setAlwaysVisible(boolean alwaysVisible) {
+ m_alwaysVisible = alwaysVisible;
+ }
+
+ @Override
+ public Integer getHeightHint() {
+ return m_heightHint;
+ }
+
+ @Override
+ public void setHeightHint(Integer heightHint) {
+ m_heightHint = heightHint;
+ }
+
+ public int getMenuOpeningDirection() {
+ return m_menuOpeningDirection;
+ }
+
+ public void setMenuOpeningDirection(int menuOpeningDirection) {
+ m_menuOpeningDirection = menuOpeningDirection;
+ }
+
+ public int getRightActionBarOrientation() {
+ return m_rightActionBarOrientation;
+ }
+
+ public void setRightActionBarOrientation(int orientation) {
+ m_rightActionBarOrientation = orientation;
+ }
+
+ public CLabel getTitleField() {
+ return m_titleField;
+ }
+
+ protected void collectMenusForLeftButtonBar(List<IMenu> menuList) {
+
+ }
+
+ protected void collectMenusForRightButtonBar(List<IMenu> menuList) {
+
+ }
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/ActionButtonBar.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/ActionButtonBar.java
index 56e1ead05d..bd93165b18 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/ActionButtonBar.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/ActionButtonBar.java
@@ -1,580 +1,580 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.action;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.rwt.lifecycle.WidgetUtil;
-import org.eclipse.scout.rt.client.mobile.Icons;
-import org.eclipse.scout.rt.client.ui.action.IAction;
-import org.eclipse.scout.rt.client.ui.action.menu.AbstractMenu;
-import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
-import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
-import org.eclipse.scout.rt.ui.rap.RwtMenuUtility;
-import org.eclipse.scout.rt.ui.rap.util.RwtLayoutUtility;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.9.0
- */
-public class ActionButtonBar extends Composite {
- public static final int ORIENTATION_LEFT_TO_RIGHT = SWT.LEFT_TO_RIGHT;
- public static final int ORIENTATION_RIGHT_TO_LEFT = 1 << 26;
-
- private static final long serialVersionUID = 1L;
- private static final String VARIANT_ACTION_BAR = "actionBar";
- private static final int BUTTON_SPACING = 6;
-
- private IMenu[] m_menus;
- private List<IMenu> m_displayedMenus;
- private IRwtEnvironment m_uiEnvironment;
- private Job m_handleButtonPilingJob;
-
- private Composite m_buttonBar;
- private int m_style;
- private boolean m_pilingEnabled;
- private int m_minNumberOfAlwaysVisibleButtons;
- private int m_maxNumberOfAlwaysVisibleButtons;
- private P_ScoutPropertyChangeListener m_scoutPropertyChangeListener;
-
- public ActionButtonBar(Composite parent, IRwtEnvironment uiEnvironment, IMenu[] menus) {
- this(parent, uiEnvironment, menus, SWT.DEFAULT);
- }
-
- /**
- * @param style
- * Style flag to set the horizontalAlignment of the action bar. <br/>
- * Accepted values: {@link SWT#LEFT}, {@link SWT#CENTER}, {@link SWT#RIGHT}
- */
- public ActionButtonBar(Composite parent, IRwtEnvironment uiEnvironment, IMenu[] menus, int style) {
- super(parent, SWT.NONE);
-
- m_menus = menus;
- m_uiEnvironment = uiEnvironment;
- if (style == SWT.DEFAULT) {
- style = SWT.LEFT;
- }
- m_style = style;
-
- m_pilingEnabled = true;
- m_minNumberOfAlwaysVisibleButtons = 0;
- m_maxNumberOfAlwaysVisibleButtons = Integer.MAX_VALUE;
-
- m_displayedMenus = new LinkedList<IMenu>();
- m_displayedMenus.addAll(Arrays.asList(m_menus));
-
- if (menus != null && menus.length > 0) {
- // attaching the listeners must happen before creating the buttons to avoid events getting lost
- attachScoutPropertyChangeListener();
- }
-
- createButtonBar();
-
- if (menus != null && menus.length > 0) {
- addListener(SWT.Resize, new P_ResizeListener());
- scheduleHandleButtonPilingInUiThread();
- }
-
- initLayout(this);
- }
-
- private void attachScoutPropertyChangeListener() {
- if (m_menus == null || m_menus.length == 0) {
- return;
- }
-
- if (m_scoutPropertyChangeListener != null) {
- return;
- }
-
- m_scoutPropertyChangeListener = new P_ScoutPropertyChangeListener();
-
- for (IMenu menu : m_menus) {
- menu.addPropertyChangeListener(m_scoutPropertyChangeListener);
- }
-
- addDisposeListener(new DisposeListener() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void widgetDisposed(DisposeEvent event) {
- detachScoutPropertyChangeListener();
- }
-
- });
- }
-
- private void detachScoutPropertyChangeListener() {
- if (m_menus == null || m_menus.length == 0) {
- return;
- }
-
- if (m_scoutPropertyChangeListener == null) {
- return;
- }
-
- for (IMenu menu : m_menus) {
- menu.removePropertyChangeListener(m_scoutPropertyChangeListener);
- }
-
- m_scoutPropertyChangeListener = null;
- }
-
- private void initLayout(Composite composite) {
- GridLayout gridLayout = RwtLayoutUtility.createGridLayoutNoSpacing(1, true);
- composite.setLayout(gridLayout);
- }
-
- private void rebuildButtonBar() {
- if (m_buttonBar != null) {
- m_buttonBar.dispose();
- }
-
- createButtonBar();
-
- getParent().layout(true, true);
- }
-
- private void createButtonBar() {
- m_buttonBar = createButtonBar(this, m_displayedMenus);
- }
-
- private Composite createButtonBar(Composite parent, List<IMenu> actions) {
- Composite buttonBar = getUiEnvironment().getFormToolkit().createComposite(parent);
- buttonBar.setData(WidgetUtil.CUSTOM_VARIANT, VARIANT_ACTION_BAR);
- initButtonBarLayout(buttonBar);
-
- createButtons(buttonBar, actions);
-
- return buttonBar;
- }
-
- public int getActionsOrientation() {
- if ((m_style & ORIENTATION_RIGHT_TO_LEFT) != 0) {
- return ORIENTATION_RIGHT_TO_LEFT;
- }
-
- return ORIENTATION_LEFT_TO_RIGHT;
- }
-
- private void initButtonBarLayout(Composite buttonBar) {
- RowLayout layout = new RowLayout(SWT.HORIZONTAL);
- layout.marginBottom = 5;
- layout.marginTop = 5;
- layout.marginLeft = 5;
- layout.marginRight = 5;
- layout.spacing = BUTTON_SPACING;
- layout.wrap = false;
- buttonBar.setLayout(layout);
-
- int horizontalAlignment = getHorizontalAlignment();
- buttonBar.setLayoutData(new GridData(horizontalAlignment, SWT.CENTER, true, true));
- }
-
- private int getHorizontalAlignment() {
- if ((m_style & SWT.LEFT) != 0) {
- return SWT.LEFT;
- }
- else if ((m_style & SWT.CENTER) != 0) {
- return SWT.CENTER;
- }
- else if ((m_style & SWT.RIGHT) != 0) {
- return SWT.RIGHT;
- }
-
- return SWT.DEFAULT;
- }
-
- private void createButtons(Composite buttonBar, List<IMenu> actions) {
- if (actions.size() == 0 || !isAnyActionVisible(actions)) {
- return;
- }
-
- if (getActionsOrientation() == ORIENTATION_RIGHT_TO_LEFT) {
- actions = reverseActions(actions);
- }
-
- for (IMenu menu : actions) {
- createButton(buttonBar, menu);
- }
- }
-
- private List<IMenu> reverseActions(List<IMenu> actions) {
- List<IMenu> reversedMenuList = new LinkedList<IMenu>(actions);
- Collections.reverse(reversedMenuList);
-
- return reversedMenuList;
- }
-
- protected void createButton(Composite parent, IAction action) {
- if (action == null) {
- return;
- }
- if (action.isSeparator()) {
- return;
- }
- if (!action.isVisible()) {
- return;
- }
- if (RwtMenuUtility.hasChildActions(action) && !RwtMenuUtility.hasVisibleChildActions(action)) {
- return;
- }
-
- IRwtScoutActionButton button = new RwtScoutActionButton();
- button.setMenuOpeningDirection(getMenuOpeningDirection());
- button.createUiField(parent, action, getUiEnvironment());
- }
-
- protected int getMenuOpeningDirection() {
- if ((m_style & SWT.UP) != 0) {
- return SWT.UP;
- }
-
- return SWT.DOWN;
- }
-
- public void handleButtonPiling() {
- if (isButtonBarTooSmall(m_buttonBar) || getNumberOfDisplayedButtons() > m_maxNumberOfAlwaysVisibleButtons) {
- pileButtons();
- }
- else {
- breakPileButtonsApart();
- }
- }
-
- private void scheduleHandleButtonPilingInUiThread() {
- if (m_buttonBar == null || m_buttonBar.isDisposed()) {
- return;
- }
-
- getUiEnvironment().getDisplay().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- if (m_buttonBar == null || m_buttonBar.isDisposed()) {
- return;
- }
-
- handleButtonPiling();
- }
-
- });
- }
-
- private void breakPileButtonsApart() {
- boolean brokeApart = false;
-
- do {
- brokeApart = breakPileButtonApart();
- }
- while (brokeApart);
- }
-
- private void pileButtons() {
- boolean stackingSuccessful = false;
-
- do {
- stackingSuccessful = createPileButton();
- }
- while (stackingSuccessful && (isButtonBarTooSmall(m_buttonBar) || getNumberOfDisplayedButtons() > m_maxNumberOfAlwaysVisibleButtons));
- }
-
- private boolean isButtonBarTooSmall(Composite buttonBar) {
- Rectangle actualSize = buttonBar.getBounds();
- Point preferredSize = buttonBar.computeSize(SWT.DEFAULT, actualSize.height, false);
-
- if (actualSize.width < preferredSize.x) {
- return true;
- }
-
- return false;
- }
-
- protected boolean breakPileButtonApart() {
- if (m_displayedMenus == null || m_displayedMenus.size() == 0) {
- return false;
- }
-
- if (getNumberOfDisplayedButtons() >= m_maxNumberOfAlwaysVisibleButtons) {
- return false;
- }
-
- List<IMenu> displayedMenusCopy = new LinkedList<IMenu>();
- displayedMenusCopy.addAll(m_displayedMenus);
-
- IMenu lastDisplayedMenu = displayedMenusCopy.remove(displayedMenusCopy.size() - 1);
- if (!(lastDisplayedMenu instanceof PileMenu)) {
- return false;
- }
-
- PileMenu pileMenu = (PileMenu) lastDisplayedMenu;
-
- List<IMenu> currentPileMenus = pileMenu.getChildActions();
- IMenu firstMenu = currentPileMenus.remove(0);
- displayedMenusCopy.add(firstMenu);
-
- if (currentPileMenus.size() > 0) {
- PileMenu newPileMenu = createPileMenu(currentPileMenus);
- displayedMenusCopy.add(newPileMenu);
- }
-
- if (isEnoughSpaceToBreakApart(displayedMenusCopy)) {
- m_displayedMenus = displayedMenusCopy;
- rebuildButtonBar();
- return true;
- }
-
- return false;
- }
-
- /**
- * Creates and layouts an invisible composite to compute if there is enough space to fully display the buttons for the
- * given actions.
- */
- private boolean isEnoughSpaceToBreakApart(List<IMenu> menusToDisplay) {
- Shell shell = new Shell();
- try {
- shell.setSize(getBounds().width, getBounds().height);
- initLayout(shell);
-
- Composite buttonBar = createButtonBar(shell, menusToDisplay);
-
- shell.layout();
-
- return (!isButtonBarTooSmall(buttonBar));
- }
- finally {
- shell.dispose();
- }
- }
-
- private PileMenu createPileMenu(List<IMenu> childActions) {
- PileMenu pileMenu = new PileMenu();
- pileMenu.setChildActions(childActions);
- if (getMenuOpeningDirection() == SWT.UP) {
- pileMenu.setIconId(Icons.MoreActionsUp);
- }
- else {
- pileMenu.setIconId(Icons.MoreActionsDown);
- }
-
- return pileMenu;
- }
-
- protected boolean createPileButton() {
- if (!isPilingAllowed()) {
- return false;
- }
-
- List<IMenu> newPiledActions = new LinkedList<IMenu>();
- IMenu lastMenu = m_displayedMenus.remove(m_displayedMenus.size() - 1);
- if (lastMenu instanceof PileMenu) {
- if (m_displayedMenus.size() > getMinNumberOfAlwaysVisibleButtons()) {
- IMenu secondLastMenu = m_displayedMenus.remove(m_displayedMenus.size() - 1);
- newPiledActions.add(secondLastMenu);
- }
- //add every existing piled actions to the new list
- newPiledActions.addAll(lastMenu.getChildActions());
- }
- else {
- newPiledActions.add(lastMenu);
- }
-
- IMenu pileMenu = createPileMenu(newPiledActions);
- m_displayedMenus.add(pileMenu);
-
- rebuildButtonBar();
-
- return true;
- }
-
- private boolean isPilingAllowed() {
- if (!isPilingEnabled()) {
- return false;
- }
-
- if (m_displayedMenus.size() == 0) {
- return false;
- }
-
- if (getNumberOfDisplayedButtons() <= getMinNumberOfAlwaysVisibleButtons()) {
- return false;
- }
-
- return true;
- }
-
- /**
- * @return The number of currently displayed buttons. Pile buttons and separators are not counted.
- */
- private int getNumberOfDisplayedButtons() {
- int size = 0;
- for (IAction action : m_displayedMenus) {
- if (!action.isSeparator() && !(action instanceof PileMenu)) {
- size++;
- }
- }
-
- return size;
- }
-
- private class PileMenu extends AbstractMenu {
-
- }
-
- public int getMinNumberOfAlwaysVisibleButtons() {
- return m_minNumberOfAlwaysVisibleButtons;
- }
-
- public void setMinNumberOfAlwaysVisibleButtons(int minNumberOfAlwaysVisibleButtons) {
- m_minNumberOfAlwaysVisibleButtons = minNumberOfAlwaysVisibleButtons;
- }
-
- public void setMaxNumberOfAlwaysVisibleButtons(int maxNumberOfAlwaysVisibleButtons) {
- m_maxNumberOfAlwaysVisibleButtons = maxNumberOfAlwaysVisibleButtons;
- }
-
- public int getMaxNumberOfAlwaysVisibleButtons() {
- return m_maxNumberOfAlwaysVisibleButtons;
- }
-
- public void setPilingEnabled(boolean pilingEnabled) {
- m_pilingEnabled = pilingEnabled;
- }
-
- public boolean isPilingEnabled() {
- return m_pilingEnabled;
- }
-
- public IRwtEnvironment getUiEnvironment() {
- return m_uiEnvironment;
- }
-
- public IMenu[] getMenus() {
- return m_menus;
- }
-
- public boolean hasButtons() {
- return getMenus() != null && getMenus().length > 0;
- }
-
- public boolean isEqualMenuList(List<IMenu> menuList) {
- if (getMenus() == null || menuList == null) {
- return false;
- }
-
- return menuList.equals(Arrays.asList(getMenus()));
- }
-
- public boolean isAnyActionVisible(List<IMenu> menuList) {
- if (menuList == null) {
- return false;
- }
-
- for (IMenu menu : menuList) {
- if (menu.isVisible()) {
- return true;
- }
- }
-
- return false;
- }
-
- private void setActionVisibleFromScout(IAction action, boolean visible) {
- rebuildButtonBar();
- }
-
- private void handleScoutPropertyChange(final PropertyChangeEvent evt) {
- if (IAction.PROP_VISIBLE.equals(evt.getPropertyName())) {
- IAction action = (IAction) evt.getSource();
- setActionVisibleFromScout(action, (Boolean) evt.getNewValue());
- }
- }
-
- private class P_ScoutPropertyChangeListener implements PropertyChangeListener {
-
- @Override
- public void propertyChange(final PropertyChangeEvent evt) {
- Runnable t = new Runnable() {
- @Override
- public void run() {
- if (isDisposed()) {
- return;
- }
-
- handleScoutPropertyChange(evt);
- }
- };
- getUiEnvironment().invokeUiLater(t);
- }
-
- }
-
- private class P_ResizeListener implements Listener {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void handleEvent(Event event) {
- if (event.type == SWT.Resize) {
- buttonBarResized();
- }
- }
-
- private void buttonBarResized() {
- if (m_buttonBar == null || m_buttonBar.isDisposed()) {
- return;
- }
-
- if (m_handleButtonPilingJob != null) {
- m_handleButtonPilingJob.cancel();
- }
-
- m_handleButtonPilingJob = new Job("Handling button piling") {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- scheduleHandleButtonPilingInUiThread();
-
- return Status.OK_STATUS;
- }
-
- };
-
- // Pile handling is executed delayed to avoid flickering during resize and to avoid too many attempts to compute the necessity of the piling.
- m_handleButtonPilingJob.setSystem(true);
- m_handleButtonPilingJob.schedule(200);
- }
-
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.action;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.rwt.lifecycle.WidgetUtil;
+import org.eclipse.scout.rt.client.mobile.Icons;
+import org.eclipse.scout.rt.client.ui.action.IAction;
+import org.eclipse.scout.rt.client.ui.action.menu.AbstractMenu;
+import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
+import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
+import org.eclipse.scout.rt.ui.rap.RwtMenuUtility;
+import org.eclipse.scout.rt.ui.rap.util.RwtLayoutUtility;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @since 3.9.0
+ */
+public class ActionButtonBar extends Composite {
+ public static final int ORIENTATION_LEFT_TO_RIGHT = SWT.LEFT_TO_RIGHT;
+ public static final int ORIENTATION_RIGHT_TO_LEFT = 1 << 26;
+
+ private static final long serialVersionUID = 1L;
+ private static final String VARIANT_ACTION_BAR = "actionBar";
+ private static final int BUTTON_SPACING = 6;
+
+ private IMenu[] m_menus;
+ private List<IMenu> m_displayedMenus;
+ private IRwtEnvironment m_uiEnvironment;
+ private Job m_handleButtonPilingJob;
+
+ private Composite m_buttonBar;
+ private int m_style;
+ private boolean m_pilingEnabled;
+ private int m_minNumberOfAlwaysVisibleButtons;
+ private int m_maxNumberOfAlwaysVisibleButtons;
+ private P_ScoutPropertyChangeListener m_scoutPropertyChangeListener;
+
+ public ActionButtonBar(Composite parent, IRwtEnvironment uiEnvironment, IMenu[] menus) {
+ this(parent, uiEnvironment, menus, SWT.DEFAULT);
+ }
+
+ /**
+ * @param style
+ * Style flag to set the horizontalAlignment of the action bar. <br/>
+ * Accepted values: {@link SWT#LEFT}, {@link SWT#CENTER}, {@link SWT#RIGHT}
+ */
+ public ActionButtonBar(Composite parent, IRwtEnvironment uiEnvironment, IMenu[] menus, int style) {
+ super(parent, SWT.NONE);
+
+ m_menus = menus;
+ m_uiEnvironment = uiEnvironment;
+ if (style == SWT.DEFAULT) {
+ style = SWT.LEFT;
+ }
+ m_style = style;
+
+ m_pilingEnabled = true;
+ m_minNumberOfAlwaysVisibleButtons = 0;
+ m_maxNumberOfAlwaysVisibleButtons = Integer.MAX_VALUE;
+
+ m_displayedMenus = new LinkedList<IMenu>();
+ m_displayedMenus.addAll(Arrays.asList(m_menus));
+
+ if (menus != null && menus.length > 0) {
+ // attaching the listeners must happen before creating the buttons to avoid events getting lost
+ attachScoutPropertyChangeListener();
+ }
+
+ createButtonBar();
+
+ if (menus != null && menus.length > 0) {
+ addListener(SWT.Resize, new P_ResizeListener());
+ scheduleHandleButtonPilingInUiThread();
+ }
+
+ initLayout(this);
+ }
+
+ private void attachScoutPropertyChangeListener() {
+ if (m_menus == null || m_menus.length == 0) {
+ return;
+ }
+
+ if (m_scoutPropertyChangeListener != null) {
+ return;
+ }
+
+ m_scoutPropertyChangeListener = new P_ScoutPropertyChangeListener();
+
+ for (IMenu menu : m_menus) {
+ menu.addPropertyChangeListener(m_scoutPropertyChangeListener);
+ }
+
+ addDisposeListener(new DisposeListener() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void widgetDisposed(DisposeEvent event) {
+ detachScoutPropertyChangeListener();
+ }
+
+ });
+ }
+
+ private void detachScoutPropertyChangeListener() {
+ if (m_menus == null || m_menus.length == 0) {
+ return;
+ }
+
+ if (m_scoutPropertyChangeListener == null) {
+ return;
+ }
+
+ for (IMenu menu : m_menus) {
+ menu.removePropertyChangeListener(m_scoutPropertyChangeListener);
+ }
+
+ m_scoutPropertyChangeListener = null;
+ }
+
+ private void initLayout(Composite composite) {
+ GridLayout gridLayout = RwtLayoutUtility.createGridLayoutNoSpacing(1, true);
+ composite.setLayout(gridLayout);
+ }
+
+ private void rebuildButtonBar() {
+ if (m_buttonBar != null) {
+ m_buttonBar.dispose();
+ }
+
+ createButtonBar();
+
+ getParent().layout(true, true);
+ }
+
+ private void createButtonBar() {
+ m_buttonBar = createButtonBar(this, m_displayedMenus);
+ }
+
+ private Composite createButtonBar(Composite parent, List<IMenu> actions) {
+ Composite buttonBar = getUiEnvironment().getFormToolkit().createComposite(parent);
+ buttonBar.setData(WidgetUtil.CUSTOM_VARIANT, VARIANT_ACTION_BAR);
+ initButtonBarLayout(buttonBar);
+
+ createButtons(buttonBar, actions);
+
+ return buttonBar;
+ }
+
+ public int getActionsOrientation() {
+ if ((m_style & ORIENTATION_RIGHT_TO_LEFT) != 0) {
+ return ORIENTATION_RIGHT_TO_LEFT;
+ }
+
+ return ORIENTATION_LEFT_TO_RIGHT;
+ }
+
+ private void initButtonBarLayout(Composite buttonBar) {
+ RowLayout layout = new RowLayout(SWT.HORIZONTAL);
+ layout.marginBottom = 5;
+ layout.marginTop = 5;
+ layout.marginLeft = 5;
+ layout.marginRight = 5;
+ layout.spacing = BUTTON_SPACING;
+ layout.wrap = false;
+ buttonBar.setLayout(layout);
+
+ int horizontalAlignment = getHorizontalAlignment();
+ buttonBar.setLayoutData(new GridData(horizontalAlignment, SWT.CENTER, true, true));
+ }
+
+ private int getHorizontalAlignment() {
+ if ((m_style & SWT.LEFT) != 0) {
+ return SWT.LEFT;
+ }
+ else if ((m_style & SWT.CENTER) != 0) {
+ return SWT.CENTER;
+ }
+ else if ((m_style & SWT.RIGHT) != 0) {
+ return SWT.RIGHT;
+ }
+
+ return SWT.DEFAULT;
+ }
+
+ private void createButtons(Composite buttonBar, List<IMenu> actions) {
+ if (actions.size() == 0 || !isAnyActionVisible(actions)) {
+ return;
+ }
+
+ if (getActionsOrientation() == ORIENTATION_RIGHT_TO_LEFT) {
+ actions = reverseActions(actions);
+ }
+
+ for (IMenu menu : actions) {
+ createButton(buttonBar, menu);
+ }
+ }
+
+ private List<IMenu> reverseActions(List<IMenu> actions) {
+ List<IMenu> reversedMenuList = new LinkedList<IMenu>(actions);
+ Collections.reverse(reversedMenuList);
+
+ return reversedMenuList;
+ }
+
+ protected void createButton(Composite parent, IAction action) {
+ if (action == null) {
+ return;
+ }
+ if (action.isSeparator()) {
+ return;
+ }
+ if (!action.isVisible()) {
+ return;
+ }
+ if (RwtMenuUtility.hasChildActions(action) && !RwtMenuUtility.hasVisibleChildActions(action)) {
+ return;
+ }
+
+ IRwtScoutActionButton button = new RwtScoutActionButton();
+ button.setMenuOpeningDirection(getMenuOpeningDirection());
+ button.createUiField(parent, action, getUiEnvironment());
+ }
+
+ protected int getMenuOpeningDirection() {
+ if ((m_style & SWT.UP) != 0) {
+ return SWT.UP;
+ }
+
+ return SWT.DOWN;
+ }
+
+ public void handleButtonPiling() {
+ if (isButtonBarTooSmall(m_buttonBar) || getNumberOfDisplayedButtons() > m_maxNumberOfAlwaysVisibleButtons) {
+ pileButtons();
+ }
+ else {
+ breakPileButtonsApart();
+ }
+ }
+
+ private void scheduleHandleButtonPilingInUiThread() {
+ if (m_buttonBar == null || m_buttonBar.isDisposed()) {
+ return;
+ }
+
+ getUiEnvironment().getDisplay().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ if (m_buttonBar == null || m_buttonBar.isDisposed()) {
+ return;
+ }
+
+ handleButtonPiling();
+ }
+
+ });
+ }
+
+ private void breakPileButtonsApart() {
+ boolean brokeApart = false;
+
+ do {
+ brokeApart = breakPileButtonApart();
+ }
+ while (brokeApart);
+ }
+
+ private void pileButtons() {
+ boolean stackingSuccessful = false;
+
+ do {
+ stackingSuccessful = createPileButton();
+ }
+ while (stackingSuccessful && (isButtonBarTooSmall(m_buttonBar) || getNumberOfDisplayedButtons() > m_maxNumberOfAlwaysVisibleButtons));
+ }
+
+ private boolean isButtonBarTooSmall(Composite buttonBar) {
+ Rectangle actualSize = buttonBar.getBounds();
+ Point preferredSize = buttonBar.computeSize(SWT.DEFAULT, actualSize.height, false);
+
+ if (actualSize.width < preferredSize.x) {
+ return true;
+ }
+
+ return false;
+ }
+
+ protected boolean breakPileButtonApart() {
+ if (m_displayedMenus == null || m_displayedMenus.size() == 0) {
+ return false;
+ }
+
+ if (getNumberOfDisplayedButtons() >= m_maxNumberOfAlwaysVisibleButtons) {
+ return false;
+ }
+
+ List<IMenu> displayedMenusCopy = new LinkedList<IMenu>();
+ displayedMenusCopy.addAll(m_displayedMenus);
+
+ IMenu lastDisplayedMenu = displayedMenusCopy.remove(displayedMenusCopy.size() - 1);
+ if (!(lastDisplayedMenu instanceof PileMenu)) {
+ return false;
+ }
+
+ PileMenu pileMenu = (PileMenu) lastDisplayedMenu;
+
+ List<IMenu> currentPileMenus = pileMenu.getChildActions();
+ IMenu firstMenu = currentPileMenus.remove(0);
+ displayedMenusCopy.add(firstMenu);
+
+ if (currentPileMenus.size() > 0) {
+ PileMenu newPileMenu = createPileMenu(currentPileMenus);
+ displayedMenusCopy.add(newPileMenu);
+ }
+
+ if (isEnoughSpaceToBreakApart(displayedMenusCopy)) {
+ m_displayedMenus = displayedMenusCopy;
+ rebuildButtonBar();
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Creates and layouts an invisible composite to compute if there is enough space to fully display the buttons for the
+ * given actions.
+ */
+ private boolean isEnoughSpaceToBreakApart(List<IMenu> menusToDisplay) {
+ Shell shell = new Shell();
+ try {
+ shell.setSize(getBounds().width, getBounds().height);
+ initLayout(shell);
+
+ Composite buttonBar = createButtonBar(shell, menusToDisplay);
+
+ shell.layout();
+
+ return (!isButtonBarTooSmall(buttonBar));
+ }
+ finally {
+ shell.dispose();
+ }
+ }
+
+ private PileMenu createPileMenu(List<IMenu> childActions) {
+ PileMenu pileMenu = new PileMenu();
+ pileMenu.setChildActions(childActions);
+ if (getMenuOpeningDirection() == SWT.UP) {
+ pileMenu.setIconId(Icons.MoreActionsUp);
+ }
+ else {
+ pileMenu.setIconId(Icons.MoreActionsDown);
+ }
+
+ return pileMenu;
+ }
+
+ protected boolean createPileButton() {
+ if (!isPilingAllowed()) {
+ return false;
+ }
+
+ List<IMenu> newPiledActions = new LinkedList<IMenu>();
+ IMenu lastMenu = m_displayedMenus.remove(m_displayedMenus.size() - 1);
+ if (lastMenu instanceof PileMenu) {
+ if (m_displayedMenus.size() > getMinNumberOfAlwaysVisibleButtons()) {
+ IMenu secondLastMenu = m_displayedMenus.remove(m_displayedMenus.size() - 1);
+ newPiledActions.add(secondLastMenu);
+ }
+ //add every existing piled actions to the new list
+ newPiledActions.addAll(lastMenu.getChildActions());
+ }
+ else {
+ newPiledActions.add(lastMenu);
+ }
+
+ IMenu pileMenu = createPileMenu(newPiledActions);
+ m_displayedMenus.add(pileMenu);
+
+ rebuildButtonBar();
+
+ return true;
+ }
+
+ private boolean isPilingAllowed() {
+ if (!isPilingEnabled()) {
+ return false;
+ }
+
+ if (m_displayedMenus.size() == 0) {
+ return false;
+ }
+
+ if (getNumberOfDisplayedButtons() <= getMinNumberOfAlwaysVisibleButtons()) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * @return The number of currently displayed buttons. Pile buttons and separators are not counted.
+ */
+ private int getNumberOfDisplayedButtons() {
+ int size = 0;
+ for (IAction action : m_displayedMenus) {
+ if (!action.isSeparator() && !(action instanceof PileMenu)) {
+ size++;
+ }
+ }
+
+ return size;
+ }
+
+ private class PileMenu extends AbstractMenu {
+
+ }
+
+ public int getMinNumberOfAlwaysVisibleButtons() {
+ return m_minNumberOfAlwaysVisibleButtons;
+ }
+
+ public void setMinNumberOfAlwaysVisibleButtons(int minNumberOfAlwaysVisibleButtons) {
+ m_minNumberOfAlwaysVisibleButtons = minNumberOfAlwaysVisibleButtons;
+ }
+
+ public void setMaxNumberOfAlwaysVisibleButtons(int maxNumberOfAlwaysVisibleButtons) {
+ m_maxNumberOfAlwaysVisibleButtons = maxNumberOfAlwaysVisibleButtons;
+ }
+
+ public int getMaxNumberOfAlwaysVisibleButtons() {
+ return m_maxNumberOfAlwaysVisibleButtons;
+ }
+
+ public void setPilingEnabled(boolean pilingEnabled) {
+ m_pilingEnabled = pilingEnabled;
+ }
+
+ public boolean isPilingEnabled() {
+ return m_pilingEnabled;
+ }
+
+ public IRwtEnvironment getUiEnvironment() {
+ return m_uiEnvironment;
+ }
+
+ public IMenu[] getMenus() {
+ return m_menus;
+ }
+
+ public boolean hasButtons() {
+ return getMenus() != null && getMenus().length > 0;
+ }
+
+ public boolean isEqualMenuList(List<IMenu> menuList) {
+ if (getMenus() == null || menuList == null) {
+ return false;
+ }
+
+ return menuList.equals(Arrays.asList(getMenus()));
+ }
+
+ public boolean isAnyActionVisible(List<IMenu> menuList) {
+ if (menuList == null) {
+ return false;
+ }
+
+ for (IMenu menu : menuList) {
+ if (menu.isVisible()) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private void setActionVisibleFromScout(IAction action, boolean visible) {
+ rebuildButtonBar();
+ }
+
+ private void handleScoutPropertyChange(final PropertyChangeEvent evt) {
+ if (IAction.PROP_VISIBLE.equals(evt.getPropertyName())) {
+ IAction action = (IAction) evt.getSource();
+ setActionVisibleFromScout(action, (Boolean) evt.getNewValue());
+ }
+ }
+
+ private class P_ScoutPropertyChangeListener implements PropertyChangeListener {
+
+ @Override
+ public void propertyChange(final PropertyChangeEvent evt) {
+ Runnable t = new Runnable() {
+ @Override
+ public void run() {
+ if (isDisposed()) {
+ return;
+ }
+
+ handleScoutPropertyChange(evt);
+ }
+ };
+ getUiEnvironment().invokeUiLater(t);
+ }
+
+ }
+
+ private class P_ResizeListener implements Listener {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void handleEvent(Event event) {
+ if (event.type == SWT.Resize) {
+ buttonBarResized();
+ }
+ }
+
+ private void buttonBarResized() {
+ if (m_buttonBar == null || m_buttonBar.isDisposed()) {
+ return;
+ }
+
+ if (m_handleButtonPilingJob != null) {
+ m_handleButtonPilingJob.cancel();
+ }
+
+ m_handleButtonPilingJob = new Job("Handling button piling") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ scheduleHandleButtonPilingInUiThread();
+
+ return Status.OK_STATUS;
+ }
+
+ };
+
+ // Pile handling is executed delayed to avoid flickering during resize and to avoid too many attempts to compute the necessity of the piling.
+ m_handleButtonPilingJob.setSystem(true);
+ m_handleButtonPilingJob.schedule(200);
+ }
+
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/IRwtScoutActionButton.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/IRwtScoutActionButton.java
index d16b57b940..58fcfc05b4 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/IRwtScoutActionButton.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/IRwtScoutActionButton.java
@@ -1,33 +1,33 @@
-/*******************************************************************************
- * Copyright (c) 2011 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.action;
-
-import org.eclipse.scout.rt.client.ui.action.IAction;
-import org.eclipse.scout.rt.ui.rap.basic.IRwtScoutComposite;
-import org.eclipse.swt.SWT;
-
-/**
- * @since 3.9.0
- */
-public interface IRwtScoutActionButton extends IRwtScoutComposite<IAction> {
-
- /**
- * Returns either{@link SWT#DOWN} or {@link SWT#UP}.
- */
- public int getMenuOpeningDirection();
-
- /**
- * Accepts {@link SWT#DOWN} or {@link SWT#UP}.<br/>
- * Default is {@link SWT#DOWN}
- */
- public void setMenuOpeningDirection(int menuOpeningDirection);
-
-}
+/*******************************************************************************
+ * Copyright (c) 2011 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.action;
+
+import org.eclipse.scout.rt.client.ui.action.IAction;
+import org.eclipse.scout.rt.ui.rap.basic.IRwtScoutComposite;
+import org.eclipse.swt.SWT;
+
+/**
+ * @since 3.9.0
+ */
+public interface IRwtScoutActionButton extends IRwtScoutComposite<IAction> {
+
+ /**
+ * Returns either{@link SWT#DOWN} or {@link SWT#UP}.
+ */
+ public int getMenuOpeningDirection();
+
+ /**
+ * Accepts {@link SWT#DOWN} or {@link SWT#UP}.<br/>
+ * Default is {@link SWT#DOWN}
+ */
+ public void setMenuOpeningDirection(int menuOpeningDirection);
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/RwtScoutActionButton.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/RwtScoutActionButton.java
index 9d59f301f8..d5a73db48f 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/RwtScoutActionButton.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/action/RwtScoutActionButton.java
@@ -1,384 +1,384 @@
-/*******************************************************************************
- * Copyright (c) 2011 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.action;
-
-import java.util.List;
-
-import org.eclipse.scout.commons.OptimisticLock;
-import org.eclipse.scout.commons.StringUtility;
-import org.eclipse.scout.commons.logger.IScoutLogger;
-import org.eclipse.scout.commons.logger.ScoutLogManager;
-import org.eclipse.scout.rt.client.ui.action.IAction;
-import org.eclipse.scout.rt.client.ui.action.tree.IActionNode;
-import org.eclipse.scout.rt.client.ui.form.fields.button.ButtonListener;
-import org.eclipse.scout.rt.ui.rap.LogicalGridData;
-import org.eclipse.scout.rt.ui.rap.LogicalGridLayout;
-import org.eclipse.scout.rt.ui.rap.RwtMenuUtility;
-import org.eclipse.scout.rt.ui.rap.basic.RwtScoutComposite;
-import org.eclipse.scout.rt.ui.rap.ext.MenuAdapterEx;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MenuAdapter;
-import org.eclipse.swt.events.MenuEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutActionButton extends RwtScoutComposite<IAction> implements IRwtScoutActionButton {
- private static IScoutLogger LOG = ScoutLogManager.getLogger(RwtScoutActionButton.class);
-
- private ButtonListener m_scoutButtonListener;
- private OptimisticLock m_selectionLock;
- //ticket 86811: avoid double-action in queue
- private boolean m_handleActionPending;
- private boolean m_selectionAlreadyRemoved;
- private int m_menuOpeningDirection = SWT.DOWN;
- private Menu m_contextMenu;
- private boolean m_ellipsisRemovalEnabled;
-
- public RwtScoutActionButton() {
- m_selectionLock = new OptimisticLock();
- m_ellipsisRemovalEnabled = true;
- }
-
- @Override
- protected void initializeUi(Composite parent) {
- Composite container = getUiEnvironment().getFormToolkit().createComposite(parent);
-
- int style = createButtonStyle();
- Button uiButton = getUiEnvironment().getFormToolkit().createButton(container, "", style);
- uiButton.addSelectionListener(new P_RwtSelectionListener());
-
- if (hasChildActions()) {
- m_contextMenu = new Menu(uiButton.getShell(), SWT.POP_UP);
- m_contextMenu.addMenuListener(new P_ContextMenuListener());
- uiButton.setMenu(m_contextMenu);
- }
-
- initLayout(container, uiButton);
-
- setUiField(uiButton);
- setUiContainer(container);
- }
-
- protected void initLayout(Composite container, Button uiButton) {
- container.setLayout(new LogicalGridLayout(0, 0));
-
- LogicalGridData data = new LogicalGridData();
- data.useUiWidth = true;
- data.useUiHeight = false; // make button as height as logical grid row height
- uiButton.setLayoutData(data);
- }
-
- protected int createButtonStyle() {
- int style = SWT.CENTER;
- if (hasChildActions()) {
- style |= SWT.TOGGLE;
- }
- else {
- style |= SWT.PUSH;
- }
-
- return style;
- }
-
- @Override
- protected void attachScout() {
- super.attachScout();
- IAction action = getScoutObject();
- setIconIdFromScout(action.getIconId());
- setTextFromScout(action.getText());
- setTooltipTextFromScout(action.getTooltipText());
- setEnabledFromScout(action.isEnabled());
- }
-
- @Override
- protected void detachScout() {
- super.detachScout();
- }
-
- @Override
- public Button getUiField() {
- return (Button) super.getUiField();
- }
-
- protected void setIconIdFromScout(String iconId) {
- if (iconId == null) {
- return;
- }
-
- Image icon = getUiEnvironment().getIcon(iconId);
- Button button = getUiField();
- button.setImage(icon);
- }
-
- protected void setTextFromScout(String text) {
- if (text == null) {
- text = "";
- }
-
- if (isEllipsisRemovalEnabled()) {
- text = removeEllipsis(text);
- }
-
- Button button = getUiField();
- button.setText(text);
- }
-
- /**
- * Removes the ellipsis at the end of the text to save space which can be essential on small screens.
- */
- protected String removeEllipsis(String text) {
- if (!StringUtility.hasText(text)) {
- return text;
- }
-
- if (text.endsWith("...")) {
- text = text.substring(0, text.length() - 3);
- }
-
- return text;
- }
-
- protected void setTooltipTextFromScout(String tooltipText) {
- getUiField().setToolTipText(tooltipText);
- }
-
- protected void setEnabledFromScout(boolean enabled) {
- getUiField().setEnabled(enabled);
- }
-
- public void setEllipsisRemovalEnabled(boolean ellipsisRemovalEnabled) {
- m_ellipsisRemovalEnabled = ellipsisRemovalEnabled;
- }
-
- public boolean isEllipsisRemovalEnabled() {
- return m_ellipsisRemovalEnabled;
- }
-
- protected void handleUiSelection() {
- if (hasChildActions()) {
- handleUiPopupMenu();
- }
- else {
- handleUiAction();
- }
- }
-
- protected void handleUiAction() {
- if (m_handleActionPending) {
- return;
- }
-
- m_handleActionPending = true;
- Runnable t = new Runnable() {
- @Override
- public void run() {
- try {
- getScoutObject().getUIFacade().fireActionFromUI();
- }
- finally {
- m_handleActionPending = false;
- }
- }
- };
- getUiEnvironment().invokeScoutLater(t, 0);
- }
-
- protected void handleUiPopupMenu() {
- Menu menu = getUiField().getMenu();
- if (menu == null) {
- return;
- }
-
- //Toggling the selection should open or close the menu.
- if (!getUiField().getSelection()) {
- return;
- }
-
- menu.addMenuListener(new MenuAdapter() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void menuHidden(MenuEvent e) {
- try {
- //Remove selection if menu hides (toggle state must reflect the menu state (open or close))
- //Note: Keyboard events (ESC, Space) are not considered at the moment because it's optimized for mobile.
- //If this class should be available for web client in the future keyboard handling should be considered to properly support toggling.
- if (!getUiField().isFocusControl()) {
- getUiField().setSelection(false);
- }
- }
- finally {
- ((Menu) e.getSource()).removeMenuListener(this);
- }
- }
- });
-
- showMenu(menu);
- }
-
- private void showMenu(Menu menu) {
- Point menuPosition = null;
-
- if (getMenuOpeningDirection() == SWT.UP) {
- menuPosition = computeMenuPositionForTop();
- }
- else {
- menuPosition = computeMenuPositionForBottom();
- }
-
- menu.setLocation(menuPosition);
- menu.setVisible(true);
- }
-
- private Point computeMenuPositionForTop() {
- Rectangle buttonBounds = getUiField().getBounds();
- int menuLocationX = buttonBounds.x;
- int menuLocationY = buttonBounds.y - estimateMenuHeight();
- return getUiField().getParent().toDisplay(menuLocationX, menuLocationY);
- }
-
- private Point computeMenuPositionForBottom() {
- Rectangle buttonBounds = getUiField().getBounds();
- int menuLocationX = buttonBounds.x;
- int menuLocationY = buttonBounds.y + buttonBounds.height;
- return getUiField().getParent().toDisplay(menuLocationX, menuLocationY);
- }
-
- /**
- * Estimates the menu height based on the actions to be displayed. If the font or padding properties changes
- * (scout.css) it breaks.
- */
- private int estimateMenuHeight() {
- List<? extends IActionNode> actions = RwtMenuUtility.cleanup(getChildActions());
- if (actions == null || actions.size() == 0) {
- return 0;
- }
-
- int height = 0;
- int itemNum = 0;
- for (IActionNode<?> actionNode : actions) {
- if (actionNode.isSeparator()) {
- if (itemNum != 0 && itemNum != actions.size() - 1 && !actions.get(itemNum - 1).isSeparator()) {
- height += 4 + 7; // separator padding and height
- }
- }
- else {
- height += 14 + 15; // menu item padding and height
- }
- itemNum++;
- }
- if (height > 0) {
- height += 8 + 4; // menu padding and border width
- }
-
- return height;
- }
-
- public boolean hasChildActions() {
- return RwtMenuUtility.hasChildActions(getScoutObject());
- }
-
- private List<? extends IActionNode> getChildActions() {
- return RwtMenuUtility.getChildActions(getScoutObject());
- }
-
- @Override
- public int getMenuOpeningDirection() {
- return m_menuOpeningDirection;
- }
-
- @Override
- public void setMenuOpeningDirection(int menuOpeningDirection) {
- if (menuOpeningDirection != SWT.TOP) {
- menuOpeningDirection = SWT.DOWN;
- }
-
- m_menuOpeningDirection = menuOpeningDirection;
- }
-
- /**
- * in rwt thread
- */
- @Override
- protected void handleScoutPropertyChange(String name, Object newValue) {
- super.handleScoutPropertyChange(name, newValue);
-
- if (IAction.PROP_ICON_ID.equals(name)) {
- setIconIdFromScout((String) newValue);
- }
- else if (IAction.PROP_TEXT.equals(name)) {
- setTextFromScout((String) newValue);
- }
- else if (IAction.PROP_TOOLTIP_TEXT.equals(name)) {
- setTextFromScout((String) newValue);
- }
- else if (IAction.PROP_ENABLED.equals(name)) {
- setEnabledFromScout(((Boolean) newValue).booleanValue());
- }
-
- }
-
- private class P_RwtSelectionListener extends SelectionAdapter {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- handleUiSelection();
- }
-
- }
-
- private class P_ContextMenuListener extends MenuAdapterEx {
- private static final long serialVersionUID = 1L;
-
- public P_ContextMenuListener() {
- super(getUiField(), getUiField());
- }
-
- @Override
- protected Menu getContextMenu() {
- return m_contextMenu;
- }
-
- @Override
- protected void setContextMenu(Menu contextMenu) {
- m_contextMenu = contextMenu;
- }
-
- @Override
- public void menuShown(MenuEvent e) {
- if (m_contextMenu != null) {
- for (MenuItem item : m_contextMenu.getItems()) {
- disposeMenuItem(item);
- }
- }
-
- List<? extends IActionNode> actions = getChildActions();
- if (actions == null) {
- return;
- }
-
- RwtMenuUtility.fillContextMenu(actions, getUiEnvironment(), m_contextMenu);
- }
-
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2011 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.action;
+
+import java.util.List;
+
+import org.eclipse.scout.commons.OptimisticLock;
+import org.eclipse.scout.commons.StringUtility;
+import org.eclipse.scout.commons.logger.IScoutLogger;
+import org.eclipse.scout.commons.logger.ScoutLogManager;
+import org.eclipse.scout.rt.client.ui.action.IAction;
+import org.eclipse.scout.rt.client.ui.action.tree.IActionNode;
+import org.eclipse.scout.rt.client.ui.form.fields.button.ButtonListener;
+import org.eclipse.scout.rt.ui.rap.LogicalGridData;
+import org.eclipse.scout.rt.ui.rap.LogicalGridLayout;
+import org.eclipse.scout.rt.ui.rap.RwtMenuUtility;
+import org.eclipse.scout.rt.ui.rap.basic.RwtScoutComposite;
+import org.eclipse.scout.rt.ui.rap.ext.MenuAdapterEx;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutActionButton extends RwtScoutComposite<IAction> implements IRwtScoutActionButton {
+ private static IScoutLogger LOG = ScoutLogManager.getLogger(RwtScoutActionButton.class);
+
+ private ButtonListener m_scoutButtonListener;
+ private OptimisticLock m_selectionLock;
+ //ticket 86811: avoid double-action in queue
+ private boolean m_handleActionPending;
+ private boolean m_selectionAlreadyRemoved;
+ private int m_menuOpeningDirection = SWT.DOWN;
+ private Menu m_contextMenu;
+ private boolean m_ellipsisRemovalEnabled;
+
+ public RwtScoutActionButton() {
+ m_selectionLock = new OptimisticLock();
+ m_ellipsisRemovalEnabled = true;
+ }
+
+ @Override
+ protected void initializeUi(Composite parent) {
+ Composite container = getUiEnvironment().getFormToolkit().createComposite(parent);
+
+ int style = createButtonStyle();
+ Button uiButton = getUiEnvironment().getFormToolkit().createButton(container, "", style);
+ uiButton.addSelectionListener(new P_RwtSelectionListener());
+
+ if (hasChildActions()) {
+ m_contextMenu = new Menu(uiButton.getShell(), SWT.POP_UP);
+ m_contextMenu.addMenuListener(new P_ContextMenuListener());
+ uiButton.setMenu(m_contextMenu);
+ }
+
+ initLayout(container, uiButton);
+
+ setUiField(uiButton);
+ setUiContainer(container);
+ }
+
+ protected void initLayout(Composite container, Button uiButton) {
+ container.setLayout(new LogicalGridLayout(0, 0));
+
+ LogicalGridData data = new LogicalGridData();
+ data.useUiWidth = true;
+ data.useUiHeight = false; // make button as height as logical grid row height
+ uiButton.setLayoutData(data);
+ }
+
+ protected int createButtonStyle() {
+ int style = SWT.CENTER;
+ if (hasChildActions()) {
+ style |= SWT.TOGGLE;
+ }
+ else {
+ style |= SWT.PUSH;
+ }
+
+ return style;
+ }
+
+ @Override
+ protected void attachScout() {
+ super.attachScout();
+ IAction action = getScoutObject();
+ setIconIdFromScout(action.getIconId());
+ setTextFromScout(action.getText());
+ setTooltipTextFromScout(action.getTooltipText());
+ setEnabledFromScout(action.isEnabled());
+ }
+
+ @Override
+ protected void detachScout() {
+ super.detachScout();
+ }
+
+ @Override
+ public Button getUiField() {
+ return (Button) super.getUiField();
+ }
+
+ protected void setIconIdFromScout(String iconId) {
+ if (iconId == null) {
+ return;
+ }
+
+ Image icon = getUiEnvironment().getIcon(iconId);
+ Button button = getUiField();
+ button.setImage(icon);
+ }
+
+ protected void setTextFromScout(String text) {
+ if (text == null) {
+ text = "";
+ }
+
+ if (isEllipsisRemovalEnabled()) {
+ text = removeEllipsis(text);
+ }
+
+ Button button = getUiField();
+ button.setText(text);
+ }
+
+ /**
+ * Removes the ellipsis at the end of the text to save space which can be essential on small screens.
+ */
+ protected String removeEllipsis(String text) {
+ if (!StringUtility.hasText(text)) {
+ return text;
+ }
+
+ if (text.endsWith("...")) {
+ text = text.substring(0, text.length() - 3);
+ }
+
+ return text;
+ }
+
+ protected void setTooltipTextFromScout(String tooltipText) {
+ getUiField().setToolTipText(tooltipText);
+ }
+
+ protected void setEnabledFromScout(boolean enabled) {
+ getUiField().setEnabled(enabled);
+ }
+
+ public void setEllipsisRemovalEnabled(boolean ellipsisRemovalEnabled) {
+ m_ellipsisRemovalEnabled = ellipsisRemovalEnabled;
+ }
+
+ public boolean isEllipsisRemovalEnabled() {
+ return m_ellipsisRemovalEnabled;
+ }
+
+ protected void handleUiSelection() {
+ if (hasChildActions()) {
+ handleUiPopupMenu();
+ }
+ else {
+ handleUiAction();
+ }
+ }
+
+ protected void handleUiAction() {
+ if (m_handleActionPending) {
+ return;
+ }
+
+ m_handleActionPending = true;
+ Runnable t = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ getScoutObject().getUIFacade().fireActionFromUI();
+ }
+ finally {
+ m_handleActionPending = false;
+ }
+ }
+ };
+ getUiEnvironment().invokeScoutLater(t, 0);
+ }
+
+ protected void handleUiPopupMenu() {
+ Menu menu = getUiField().getMenu();
+ if (menu == null) {
+ return;
+ }
+
+ //Toggling the selection should open or close the menu.
+ if (!getUiField().getSelection()) {
+ return;
+ }
+
+ menu.addMenuListener(new MenuAdapter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void menuHidden(MenuEvent e) {
+ try {
+ //Remove selection if menu hides (toggle state must reflect the menu state (open or close))
+ //Note: Keyboard events (ESC, Space) are not considered at the moment because it's optimized for mobile.
+ //If this class should be available for web client in the future keyboard handling should be considered to properly support toggling.
+ if (!getUiField().isFocusControl()) {
+ getUiField().setSelection(false);
+ }
+ }
+ finally {
+ ((Menu) e.getSource()).removeMenuListener(this);
+ }
+ }
+ });
+
+ showMenu(menu);
+ }
+
+ private void showMenu(Menu menu) {
+ Point menuPosition = null;
+
+ if (getMenuOpeningDirection() == SWT.UP) {
+ menuPosition = computeMenuPositionForTop();
+ }
+ else {
+ menuPosition = computeMenuPositionForBottom();
+ }
+
+ menu.setLocation(menuPosition);
+ menu.setVisible(true);
+ }
+
+ private Point computeMenuPositionForTop() {
+ Rectangle buttonBounds = getUiField().getBounds();
+ int menuLocationX = buttonBounds.x;
+ int menuLocationY = buttonBounds.y - estimateMenuHeight();
+ return getUiField().getParent().toDisplay(menuLocationX, menuLocationY);
+ }
+
+ private Point computeMenuPositionForBottom() {
+ Rectangle buttonBounds = getUiField().getBounds();
+ int menuLocationX = buttonBounds.x;
+ int menuLocationY = buttonBounds.y + buttonBounds.height;
+ return getUiField().getParent().toDisplay(menuLocationX, menuLocationY);
+ }
+
+ /**
+ * Estimates the menu height based on the actions to be displayed. If the font or padding properties changes
+ * (scout.css) it breaks.
+ */
+ private int estimateMenuHeight() {
+ List<? extends IActionNode> actions = RwtMenuUtility.cleanup(getChildActions());
+ if (actions == null || actions.size() == 0) {
+ return 0;
+ }
+
+ int height = 0;
+ int itemNum = 0;
+ for (IActionNode<?> actionNode : actions) {
+ if (actionNode.isSeparator()) {
+ if (itemNum != 0 && itemNum != actions.size() - 1 && !actions.get(itemNum - 1).isSeparator()) {
+ height += 4 + 7; // separator padding and height
+ }
+ }
+ else {
+ height += 14 + 15; // menu item padding and height
+ }
+ itemNum++;
+ }
+ if (height > 0) {
+ height += 8 + 4; // menu padding and border width
+ }
+
+ return height;
+ }
+
+ public boolean hasChildActions() {
+ return RwtMenuUtility.hasChildActions(getScoutObject());
+ }
+
+ private List<? extends IActionNode> getChildActions() {
+ return RwtMenuUtility.getChildActions(getScoutObject());
+ }
+
+ @Override
+ public int getMenuOpeningDirection() {
+ return m_menuOpeningDirection;
+ }
+
+ @Override
+ public void setMenuOpeningDirection(int menuOpeningDirection) {
+ if (menuOpeningDirection != SWT.TOP) {
+ menuOpeningDirection = SWT.DOWN;
+ }
+
+ m_menuOpeningDirection = menuOpeningDirection;
+ }
+
+ /**
+ * in rwt thread
+ */
+ @Override
+ protected void handleScoutPropertyChange(String name, Object newValue) {
+ super.handleScoutPropertyChange(name, newValue);
+
+ if (IAction.PROP_ICON_ID.equals(name)) {
+ setIconIdFromScout((String) newValue);
+ }
+ else if (IAction.PROP_TEXT.equals(name)) {
+ setTextFromScout((String) newValue);
+ }
+ else if (IAction.PROP_TOOLTIP_TEXT.equals(name)) {
+ setTextFromScout((String) newValue);
+ }
+ else if (IAction.PROP_ENABLED.equals(name)) {
+ setEnabledFromScout(((Boolean) newValue).booleanValue());
+ }
+
+ }
+
+ private class P_RwtSelectionListener extends SelectionAdapter {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleUiSelection();
+ }
+
+ }
+
+ private class P_ContextMenuListener extends MenuAdapterEx {
+ private static final long serialVersionUID = 1L;
+
+ public P_ContextMenuListener() {
+ super(getUiField(), getUiField());
+ }
+
+ @Override
+ protected Menu getContextMenu() {
+ return m_contextMenu;
+ }
+
+ @Override
+ protected void setContextMenu(Menu contextMenu) {
+ m_contextMenu = contextMenu;
+ }
+
+ @Override
+ public void menuShown(MenuEvent e) {
+ if (m_contextMenu != null) {
+ for (MenuItem item : m_contextMenu.getItems()) {
+ disposeMenuItem(item);
+ }
+ }
+
+ List<? extends IActionNode> actions = getChildActions();
+ if (actions == null) {
+ return;
+ }
+
+ RwtMenuUtility.fillContextMenu(actions, getUiEnvironment(), m_contextMenu);
+ }
+
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/BusyBlockDialog.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/BusyBlockDialog.java
index c54882e389..9c17adeb9a 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/BusyBlockDialog.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/BusyBlockDialog.java
@@ -1,122 +1,122 @@
-/*******************************************************************************
- * Copyright (c) 2011 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.busy;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.rwt.lifecycle.WidgetUtil;
-import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
-import org.eclipse.scout.rt.ui.rap.util.RwtLayoutUtility;
-import org.eclipse.scout.rt.ui.rap.util.RwtUtility;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Dialog which shows a waiting message and a button to abort waiting.
- *
- * @since 3.9.0
- */
-public class BusyBlockDialog extends Dialog {
- private static final long serialVersionUID = 1L;
- private static final String DIALOG_VARIANT = "busy-dialog";
-
- private IRwtEnvironment m_uiEnvironment;
- private IProgressMonitor m_progressMonitor;
- private Label m_messageLabel;
-
- public BusyBlockDialog(Shell parentShell, IRwtEnvironment uiEnvironment, IProgressMonitor progressMonitor) {
- super(parentShell);
- m_uiEnvironment = uiEnvironment;
- m_progressMonitor = progressMonitor;
- setShellStyle(SWT.APPLICATION_MODAL);
- setBlockOnOpen(false);
- }
-
- protected String getDialogVariant() {
- return DIALOG_VARIANT;
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- getShell().setData(WidgetUtil.CUSTOM_VARIANT, getDialogVariant());
-
- Composite container = getUiEnvironment().getFormToolkit().createComposite(parent);
- container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- container.setData(WidgetUtil.CUSTOM_VARIANT, getDialogVariant());
-
- GridLayout dialogAreaLayout = RwtLayoutUtility.createGridLayoutNoSpacing(1, false);
- dialogAreaLayout.marginTop = 12;
- dialogAreaLayout.marginBottom = 8;
- dialogAreaLayout.marginWidth = 12;
- container.setLayout(dialogAreaLayout);
-
- m_messageLabel = getUiEnvironment().getFormToolkit().createLabel(container, RwtUtility.getNlsText(Display.getCurrent(), "MobileBusyBlockingMessage"), SWT.WRAP | SWT.CENTER);
- GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
- m_messageLabel.setLayoutData(gridData);
- m_messageLabel.setData(WidgetUtil.CUSTOM_VARIANT, getDialogVariant());
- return container;
- }
-
- @Override
- protected Control createButtonBar(Composite parent) {
- Composite buttonArea = getUiEnvironment().getFormToolkit().createComposite(parent);
- buttonArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
-
- GridLayout layout = RwtLayoutUtility.createGridLayoutNoSpacing(1, false);
- layout.marginHeight = 8;
- buttonArea.setLayout(layout);
-
- Button cancelButton = createButton(buttonArea, RwtUtility.getNlsText(Display.getCurrent(), "MobileBusyBlockingAbort"), null);
- cancelButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
-
- return buttonArea;
- }
-
- protected Button createButton(Composite parent, String text, String iconId) {
- Button b = getUiEnvironment().getFormToolkit().createButton(parent, text, SWT.PUSH);
- if (iconId != null) {
- b.setImage(getUiEnvironment().getIcon(iconId));
- }
- b.addSelectionListener(new P_RwtButtonListener());
- return b;
- }
-
- private IRwtEnvironment getUiEnvironment() {
- return m_uiEnvironment;
- }
-
- private void handleUiButtonSelection() {
- m_progressMonitor.setCanceled(true);
- }
-
- private class P_RwtButtonListener extends SelectionAdapter {
- private static final long serialVersionUID = 1L;
-
- public P_RwtButtonListener() {
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- handleUiButtonSelection();
- }
-
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2011 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.busy;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.rwt.lifecycle.WidgetUtil;
+import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
+import org.eclipse.scout.rt.ui.rap.util.RwtLayoutUtility;
+import org.eclipse.scout.rt.ui.rap.util.RwtUtility;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Dialog which shows a waiting message and a button to abort waiting.
+ *
+ * @since 3.9.0
+ */
+public class BusyBlockDialog extends Dialog {
+ private static final long serialVersionUID = 1L;
+ private static final String DIALOG_VARIANT = "busy-dialog";
+
+ private IRwtEnvironment m_uiEnvironment;
+ private IProgressMonitor m_progressMonitor;
+ private Label m_messageLabel;
+
+ public BusyBlockDialog(Shell parentShell, IRwtEnvironment uiEnvironment, IProgressMonitor progressMonitor) {
+ super(parentShell);
+ m_uiEnvironment = uiEnvironment;
+ m_progressMonitor = progressMonitor;
+ setShellStyle(SWT.APPLICATION_MODAL);
+ setBlockOnOpen(false);
+ }
+
+ protected String getDialogVariant() {
+ return DIALOG_VARIANT;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ getShell().setData(WidgetUtil.CUSTOM_VARIANT, getDialogVariant());
+
+ Composite container = getUiEnvironment().getFormToolkit().createComposite(parent);
+ container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ container.setData(WidgetUtil.CUSTOM_VARIANT, getDialogVariant());
+
+ GridLayout dialogAreaLayout = RwtLayoutUtility.createGridLayoutNoSpacing(1, false);
+ dialogAreaLayout.marginTop = 12;
+ dialogAreaLayout.marginBottom = 8;
+ dialogAreaLayout.marginWidth = 12;
+ container.setLayout(dialogAreaLayout);
+
+ m_messageLabel = getUiEnvironment().getFormToolkit().createLabel(container, RwtUtility.getNlsText(Display.getCurrent(), "MobileBusyBlockingMessage"), SWT.WRAP | SWT.CENTER);
+ GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ m_messageLabel.setLayoutData(gridData);
+ m_messageLabel.setData(WidgetUtil.CUSTOM_VARIANT, getDialogVariant());
+ return container;
+ }
+
+ @Override
+ protected Control createButtonBar(Composite parent) {
+ Composite buttonArea = getUiEnvironment().getFormToolkit().createComposite(parent);
+ buttonArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
+
+ GridLayout layout = RwtLayoutUtility.createGridLayoutNoSpacing(1, false);
+ layout.marginHeight = 8;
+ buttonArea.setLayout(layout);
+
+ Button cancelButton = createButton(buttonArea, RwtUtility.getNlsText(Display.getCurrent(), "MobileBusyBlockingAbort"), null);
+ cancelButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
+
+ return buttonArea;
+ }
+
+ protected Button createButton(Composite parent, String text, String iconId) {
+ Button b = getUiEnvironment().getFormToolkit().createButton(parent, text, SWT.PUSH);
+ if (iconId != null) {
+ b.setImage(getUiEnvironment().getIcon(iconId));
+ }
+ b.addSelectionListener(new P_RwtButtonListener());
+ return b;
+ }
+
+ private IRwtEnvironment getUiEnvironment() {
+ return m_uiEnvironment;
+ }
+
+ private void handleUiButtonSelection() {
+ m_progressMonitor.setCanceled(true);
+ }
+
+ private class P_RwtButtonListener extends SelectionAdapter {
+ private static final long serialVersionUID = 1L;
+
+ public P_RwtButtonListener() {
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleUiButtonSelection();
+ }
+
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/BusyBlockDialogJob.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/BusyBlockDialogJob.java
index 2dddd12ab5..4e451ff3b7 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/BusyBlockDialogJob.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/BusyBlockDialogJob.java
@@ -1,75 +1,75 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.busy;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.scout.commons.holders.Holder;
-import org.eclipse.scout.commons.logger.IScoutLogger;
-import org.eclipse.scout.commons.logger.ScoutLogManager;
-import org.eclipse.scout.rt.client.busy.BusyJob;
-import org.eclipse.scout.rt.ui.rap.busy.RwtBusyHandler;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class BusyBlockDialogJob extends BusyJob {
- private static final IScoutLogger LOG = ScoutLogManager.getLogger(BusyBlockDialogJob.class);
-
- public BusyBlockDialogJob(String name, RwtBusyHandler handler) {
- super(name, handler);
- setSystem(true);
- }
-
- @Override
- protected RwtBusyHandler getBusyHandler() {
- return (RwtBusyHandler) super.getBusyHandler();
- }
-
- @Override
- protected void runBusy(IProgressMonitor monitor) {
- //nop
- }
-
- @Override
- protected void runBlocking(final IProgressMonitor monitor) {
- final Display display = getBusyHandler().getDisplay();
- final Holder<BusyBlockDialog> dialogHolder = new Holder<BusyBlockDialog>(BusyBlockDialog.class);
- try {
- display.syncExec(new Runnable() {
- @Override
- public void run() {
- Shell parentShell = getBusyHandler().getUiEnvironment().getParentShellIgnoringPopups(SWT.SYSTEM_MODAL | SWT.APPLICATION_MODAL | SWT.MODELESS);
- if (parentShell == null || parentShell.isDisposed()) {
- return;
- }
- BusyBlockDialog dialog = new BusyBlockDialog(parentShell, getBusyHandler().getUiEnvironment(), monitor);
- dialog.open();
- dialogHolder.setValue(dialog);
- }
- });
- //
- BusyBlockDialogJob.super.runBlocking(monitor);
- //
- }
- finally {
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- BusyBlockDialog dialog = dialogHolder.getValue();
- if (dialog != null) {
- dialog.close();
- }
- }
- });
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.busy;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.scout.commons.holders.Holder;
+import org.eclipse.scout.commons.logger.IScoutLogger;
+import org.eclipse.scout.commons.logger.ScoutLogManager;
+import org.eclipse.scout.rt.client.busy.BusyJob;
+import org.eclipse.scout.rt.ui.rap.busy.RwtBusyHandler;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class BusyBlockDialogJob extends BusyJob {
+ private static final IScoutLogger LOG = ScoutLogManager.getLogger(BusyBlockDialogJob.class);
+
+ public BusyBlockDialogJob(String name, RwtBusyHandler handler) {
+ super(name, handler);
+ setSystem(true);
+ }
+
+ @Override
+ protected RwtBusyHandler getBusyHandler() {
+ return (RwtBusyHandler) super.getBusyHandler();
+ }
+
+ @Override
+ protected void runBusy(IProgressMonitor monitor) {
+ //nop
+ }
+
+ @Override
+ protected void runBlocking(final IProgressMonitor monitor) {
+ final Display display = getBusyHandler().getDisplay();
+ final Holder<BusyBlockDialog> dialogHolder = new Holder<BusyBlockDialog>(BusyBlockDialog.class);
+ try {
+ display.syncExec(new Runnable() {
+ @Override
+ public void run() {
+ Shell parentShell = getBusyHandler().getUiEnvironment().getParentShellIgnoringPopups(SWT.SYSTEM_MODAL | SWT.APPLICATION_MODAL | SWT.MODELESS);
+ if (parentShell == null || parentShell.isDisposed()) {
+ return;
+ }
+ BusyBlockDialog dialog = new BusyBlockDialog(parentShell, getBusyHandler().getUiEnvironment(), monitor);
+ dialog.open();
+ dialogHolder.setValue(dialog);
+ }
+ });
+ //
+ BusyBlockDialogJob.super.runBlocking(monitor);
+ //
+ }
+ finally {
+ display.asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ BusyBlockDialog dialog = dialogHolder.getValue();
+ if (dialog != null) {
+ dialog.close();
+ }
+ }
+ });
+ }
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/MobileWaitForBlockingJob.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/MobileWaitForBlockingJob.java
index 9a0ba105e6..7d5c2e50bd 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/MobileWaitForBlockingJob.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/MobileWaitForBlockingJob.java
@@ -1,29 +1,29 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.busy;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.scout.rt.ui.rap.busy.RwtBusyHandler;
-import org.eclipse.scout.rt.ui.rap.busy.WaitForBlockingJob;
-
-public class MobileWaitForBlockingJob extends WaitForBlockingJob {
-
- public MobileWaitForBlockingJob(String name, RwtBusyHandler handler) {
- super(name, handler);
- }
-
- @Override
- protected void runBlocking(IProgressMonitor monitor) {
- //schedule blocking job
- new BusyBlockDialogJob(getName(), getBusyHandler()).schedule();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.busy;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.scout.rt.ui.rap.busy.RwtBusyHandler;
+import org.eclipse.scout.rt.ui.rap.busy.WaitForBlockingJob;
+
+public class MobileWaitForBlockingJob extends WaitForBlockingJob {
+
+ public MobileWaitForBlockingJob(String name, RwtBusyHandler handler) {
+ super(name, handler);
+ }
+
+ @Override
+ protected void runBlocking(IProgressMonitor monitor) {
+ //schedule blocking job
+ new BusyBlockDialogJob(getName(), getBusyHandler()).schedule();
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/RwtMobileBusyHandler.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/RwtMobileBusyHandler.java
index 364b78c085..f30439f6c3 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/RwtMobileBusyHandler.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/busy/RwtMobileBusyHandler.java
@@ -1,36 +1,36 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.busy;
-
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.scout.rt.client.IClientSession;
-import org.eclipse.scout.rt.shared.TEXTS;
-import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
-import org.eclipse.scout.rt.ui.rap.busy.RwtBusyHandler;
-
-/**
- * Displays a waiting dialog on blocking instead of the blocking header.
- *
- * @see {@link BusyBlockDialog}
- * @since 3.9.0
- */
-public class RwtMobileBusyHandler extends RwtBusyHandler {
-
- public RwtMobileBusyHandler(IClientSession session, IRwtEnvironment env) {
- super(session, env);
- }
-
- @Override
- protected void runBusy(Job job) {
- new MobileWaitForBlockingJob(TEXTS.get("BusyJob"), this).schedule();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.busy;
+
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.scout.rt.client.IClientSession;
+import org.eclipse.scout.rt.shared.TEXTS;
+import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
+import org.eclipse.scout.rt.ui.rap.busy.RwtBusyHandler;
+
+/**
+ * Displays a waiting dialog on blocking instead of the blocking header.
+ *
+ * @see {@link BusyBlockDialog}
+ * @since 3.9.0
+ */
+public class RwtMobileBusyHandler extends RwtBusyHandler {
+
+ public RwtMobileBusyHandler(IClientSession session, IRwtEnvironment env) {
+ super(session, env);
+ }
+
+ @Override
+ protected void runBusy(Job job) {
+ new MobileWaitForBlockingJob(TEXTS.get("BusyJob"), this).schedule();
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/AbstractRwtScoutFormHeader.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/AbstractRwtScoutFormHeader.java
index 0172cdd522..a539366ec9 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/AbstractRwtScoutFormHeader.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/AbstractRwtScoutFormHeader.java
@@ -1,103 +1,103 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.scout.commons.job.JobEx;
-import org.eclipse.scout.commons.logger.IScoutLogger;
-import org.eclipse.scout.commons.logger.ScoutLogManager;
-import org.eclipse.scout.rt.client.mobile.ui.form.AbstractMobileForm;
-import org.eclipse.scout.rt.client.mobile.ui.form.FormHeaderActionFetcher;
-import org.eclipse.scout.rt.client.mobile.ui.form.IActionFetcher;
-import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
-import org.eclipse.scout.rt.client.ui.form.IForm;
-import org.eclipse.scout.rt.ui.rap.mobile.action.AbstractRwtScoutActionBar;
-import org.eclipse.scout.rt.ui.rap.mobile.action.ActionButtonBar;
-import org.eclipse.scout.rt.ui.rap.window.desktop.IRwtScoutFormHeader;
-
-/**
- * @since 3.9.0
- */
-public class AbstractRwtScoutFormHeader extends AbstractRwtScoutActionBar<IForm> implements IRwtScoutFormHeader {
- private static IScoutLogger LOG = ScoutLogManager.getLogger(AbstractRwtScoutFormHeader.class);
- private static final String VARIANT_FORM_HEADER = "mobileFormHeader";
-
- @Override
- protected String getActionBarContainerVariant() {
- return VARIANT_FORM_HEADER;
- }
-
- @Override
- public boolean isAlwaysVisible() {
- return true;
- }
-
- @Override
- protected void attachScout() {
- super.attachScout();
-
- setTitle(getScoutObject().getTitle());
- }
-
- @Override
- protected void adaptLeftButtonBar(ActionButtonBar buttonBar) {
- buttonBar.setPilingEnabled(false);
- }
-
- @Override
- protected void adaptRightButtonBar(ActionButtonBar buttonBar) {
- buttonBar.setMinNumberOfAlwaysVisibleButtons(1);
- buttonBar.setMaxNumberOfAlwaysVisibleButtons(1);
- }
-
- @Override
- protected void handleScoutPropertyChange(String name, Object newValue) {
- super.handleScoutPropertyChange(name, newValue);
-
- if (name.equals(IForm.PROP_TITLE)) {
- setTitle((String) newValue);
- }
- }
-
- public List<IMenu> fetchActions() {
- final List<IMenu> actionList = new LinkedList<IMenu>();
- Runnable t = new Runnable() {
- @Override
- public void run() {
- //Don't fetch actions if the form has already been removed from the desktop.
- if (!getScoutObject().isShowing()) {
- return;
- }
-
- IActionFetcher actionFetcher = AbstractMobileForm.getHeaderActionFetcher(getScoutObject());
- if (actionFetcher == null) {
- actionFetcher = new FormHeaderActionFetcher(getScoutObject());
- }
- List<IMenu> actions = actionFetcher.fetch();
- if (actions != null) {
- actionList.addAll(actions);
- }
- }
- };
-
- JobEx job = getUiEnvironment().invokeScoutLater(t, 5000);
- try {
- job.join(2000);
- }
- catch (InterruptedException ex) {
- LOG.warn("Exception occured while collecting menus.", ex);
- }
-
- return actionList;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.scout.commons.job.JobEx;
+import org.eclipse.scout.commons.logger.IScoutLogger;
+import org.eclipse.scout.commons.logger.ScoutLogManager;
+import org.eclipse.scout.rt.client.mobile.ui.form.AbstractMobileForm;
+import org.eclipse.scout.rt.client.mobile.ui.form.FormHeaderActionFetcher;
+import org.eclipse.scout.rt.client.mobile.ui.form.IActionFetcher;
+import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
+import org.eclipse.scout.rt.client.ui.form.IForm;
+import org.eclipse.scout.rt.ui.rap.mobile.action.AbstractRwtScoutActionBar;
+import org.eclipse.scout.rt.ui.rap.mobile.action.ActionButtonBar;
+import org.eclipse.scout.rt.ui.rap.window.desktop.IRwtScoutFormHeader;
+
+/**
+ * @since 3.9.0
+ */
+public class AbstractRwtScoutFormHeader extends AbstractRwtScoutActionBar<IForm> implements IRwtScoutFormHeader {
+ private static IScoutLogger LOG = ScoutLogManager.getLogger(AbstractRwtScoutFormHeader.class);
+ private static final String VARIANT_FORM_HEADER = "mobileFormHeader";
+
+ @Override
+ protected String getActionBarContainerVariant() {
+ return VARIANT_FORM_HEADER;
+ }
+
+ @Override
+ public boolean isAlwaysVisible() {
+ return true;
+ }
+
+ @Override
+ protected void attachScout() {
+ super.attachScout();
+
+ setTitle(getScoutObject().getTitle());
+ }
+
+ @Override
+ protected void adaptLeftButtonBar(ActionButtonBar buttonBar) {
+ buttonBar.setPilingEnabled(false);
+ }
+
+ @Override
+ protected void adaptRightButtonBar(ActionButtonBar buttonBar) {
+ buttonBar.setMinNumberOfAlwaysVisibleButtons(1);
+ buttonBar.setMaxNumberOfAlwaysVisibleButtons(1);
+ }
+
+ @Override
+ protected void handleScoutPropertyChange(String name, Object newValue) {
+ super.handleScoutPropertyChange(name, newValue);
+
+ if (name.equals(IForm.PROP_TITLE)) {
+ setTitle((String) newValue);
+ }
+ }
+
+ public List<IMenu> fetchActions() {
+ final List<IMenu> actionList = new LinkedList<IMenu>();
+ Runnable t = new Runnable() {
+ @Override
+ public void run() {
+ //Don't fetch actions if the form has already been removed from the desktop.
+ if (!getScoutObject().isShowing()) {
+ return;
+ }
+
+ IActionFetcher actionFetcher = AbstractMobileForm.getHeaderActionFetcher(getScoutObject());
+ if (actionFetcher == null) {
+ actionFetcher = new FormHeaderActionFetcher(getScoutObject());
+ }
+ List<IMenu> actions = actionFetcher.fetch();
+ if (actions != null) {
+ actionList.addAll(actions);
+ }
+ }
+ };
+
+ JobEx job = getUiEnvironment().invokeScoutLater(t, 5000);
+ try {
+ job.join(2000);
+ }
+ catch (InterruptedException ex) {
+ LOG.warn("Exception occured while collecting menus.", ex);
+ }
+
+ return actionList;
+ }
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileForm.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileForm.java
index dd82d08a80..ec53181011 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileForm.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileForm.java
@@ -1,27 +1,27 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form;
-
-import org.eclipse.scout.rt.ui.rap.form.RwtScoutForm;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutMobileForm extends RwtScoutForm {
-
- @Override
- public void setInitialFocus() {
- // If a textfield gets the focus the keyboard pops up.
- // This does not seem to work when opening a form, at least with iOS. The focus is set but no keyboard is shown.
- // But a keyboard popup on the form opening isn't the wanted behaviour anyway. So that's why this function does nothing.
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form;
+
+import org.eclipse.scout.rt.ui.rap.form.RwtScoutForm;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutMobileForm extends RwtScoutForm {
+
+ @Override
+ public void setInitialFocus() {
+ // If a textfield gets the focus the keyboard pops up.
+ // This does not seem to work when opening a form, at least with iOS. The focus is set but no keyboard is shown.
+ // But a keyboard popup on the form opening isn't the wanted behaviour anyway. So that's why this function does nothing.
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileFormFooter.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileFormFooter.java
index 53b3baa676..75d32fa950 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileFormFooter.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileFormFooter.java
@@ -1,111 +1,111 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.scout.commons.job.JobEx;
-import org.eclipse.scout.commons.logger.IScoutLogger;
-import org.eclipse.scout.commons.logger.ScoutLogManager;
-import org.eclipse.scout.rt.client.mobile.ui.form.AbstractMobileAction;
-import org.eclipse.scout.rt.client.mobile.ui.form.AbstractMobileForm;
-import org.eclipse.scout.rt.client.mobile.ui.form.FormFooterActionFetcher;
-import org.eclipse.scout.rt.client.mobile.ui.form.IActionFetcher;
-import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
-import org.eclipse.scout.rt.client.ui.form.IForm;
-import org.eclipse.scout.rt.ui.rap.mobile.action.AbstractRwtScoutActionBar;
-import org.eclipse.scout.rt.ui.rap.window.desktop.IRwtScoutFormFooter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutMobileFormFooter extends AbstractRwtScoutActionBar<IForm> implements IRwtScoutFormFooter {
- private static final IScoutLogger LOG = ScoutLogManager.getLogger(RwtScoutMobileFormFooter.class);
- private static final String VARIANT_FORM_FOOTER = "mobileFormFooter";
-
- private List<IMenu> m_actions;
-
- @Override
- protected void initializeUi(Composite parent) {
- setMenuOpeningDirection(SWT.UP);
- m_actions = fetchActions();
-
- super.initializeUi(parent);
- }
-
- @Override
- protected String getActionBarContainerVariant() {
- return VARIANT_FORM_FOOTER;
- }
-
- @Override
- protected void collectMenusForLeftButtonBar(final List<IMenu> menuList) {
- if (m_actions == null) {
- return;
-
- }
-
- for (IMenu action : m_actions) {
- if (AbstractMobileAction.getHorizontalAlignment(action) < 0) {
- menuList.add(action);
- }
- }
- }
-
- @Override
- protected void collectMenusForRightButtonBar(List<IMenu> menuList) {
- if (m_actions == null) {
- return;
-
- }
-
- for (IMenu action : m_actions) {
- if (AbstractMobileAction.getHorizontalAlignment(action) > 0) {
- menuList.add(action);
- }
- }
- }
-
- public List<IMenu> fetchActions() {
- final List<IMenu> actionList = new LinkedList<IMenu>();
- Runnable t = new Runnable() {
- @Override
- public void run() {
- //Don't fetch actions if the form has already been removed from the desktop.
- if (!getScoutObject().isShowing()) {
- return;
- }
-
- IActionFetcher actionFetcher = AbstractMobileForm.getFooterActionFetcher(getScoutObject());
- if (actionFetcher == null) {
- actionFetcher = new FormFooterActionFetcher(getScoutObject());
- }
- List<IMenu> actions = actionFetcher.fetch();
- if (actions != null) {
- actionList.addAll(actions);
- }
- }
- };
-
- JobEx job = getUiEnvironment().invokeScoutLater(t, 5000);
- try {
- job.join(2000);
- }
- catch (InterruptedException ex) {
- LOG.warn("Exception occured while collecting menus.", ex);
- }
-
- return actionList;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.scout.commons.job.JobEx;
+import org.eclipse.scout.commons.logger.IScoutLogger;
+import org.eclipse.scout.commons.logger.ScoutLogManager;
+import org.eclipse.scout.rt.client.mobile.ui.form.AbstractMobileAction;
+import org.eclipse.scout.rt.client.mobile.ui.form.AbstractMobileForm;
+import org.eclipse.scout.rt.client.mobile.ui.form.FormFooterActionFetcher;
+import org.eclipse.scout.rt.client.mobile.ui.form.IActionFetcher;
+import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
+import org.eclipse.scout.rt.client.ui.form.IForm;
+import org.eclipse.scout.rt.ui.rap.mobile.action.AbstractRwtScoutActionBar;
+import org.eclipse.scout.rt.ui.rap.window.desktop.IRwtScoutFormFooter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutMobileFormFooter extends AbstractRwtScoutActionBar<IForm> implements IRwtScoutFormFooter {
+ private static final IScoutLogger LOG = ScoutLogManager.getLogger(RwtScoutMobileFormFooter.class);
+ private static final String VARIANT_FORM_FOOTER = "mobileFormFooter";
+
+ private List<IMenu> m_actions;
+
+ @Override
+ protected void initializeUi(Composite parent) {
+ setMenuOpeningDirection(SWT.UP);
+ m_actions = fetchActions();
+
+ super.initializeUi(parent);
+ }
+
+ @Override
+ protected String getActionBarContainerVariant() {
+ return VARIANT_FORM_FOOTER;
+ }
+
+ @Override
+ protected void collectMenusForLeftButtonBar(final List<IMenu> menuList) {
+ if (m_actions == null) {
+ return;
+
+ }
+
+ for (IMenu action : m_actions) {
+ if (AbstractMobileAction.getHorizontalAlignment(action) < 0) {
+ menuList.add(action);
+ }
+ }
+ }
+
+ @Override
+ protected void collectMenusForRightButtonBar(List<IMenu> menuList) {
+ if (m_actions == null) {
+ return;
+
+ }
+
+ for (IMenu action : m_actions) {
+ if (AbstractMobileAction.getHorizontalAlignment(action) > 0) {
+ menuList.add(action);
+ }
+ }
+ }
+
+ public List<IMenu> fetchActions() {
+ final List<IMenu> actionList = new LinkedList<IMenu>();
+ Runnable t = new Runnable() {
+ @Override
+ public void run() {
+ //Don't fetch actions if the form has already been removed from the desktop.
+ if (!getScoutObject().isShowing()) {
+ return;
+ }
+
+ IActionFetcher actionFetcher = AbstractMobileForm.getFooterActionFetcher(getScoutObject());
+ if (actionFetcher == null) {
+ actionFetcher = new FormFooterActionFetcher(getScoutObject());
+ }
+ List<IMenu> actions = actionFetcher.fetch();
+ if (actions != null) {
+ actionList.addAll(actions);
+ }
+ }
+ };
+
+ JobEx job = getUiEnvironment().invokeScoutLater(t, 5000);
+ try {
+ job.join(2000);
+ }
+ catch (InterruptedException ex) {
+ LOG.warn("Exception occured while collecting menus.", ex);
+ }
+
+ return actionList;
+ }
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileFormHeader.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileFormHeader.java
index 3cb559bc63..52a4b792e1 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileFormHeader.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileFormHeader.java
@@ -1,134 +1,134 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.scout.commons.holders.BooleanHolder;
-import org.eclipse.scout.commons.logger.IScoutLogger;
-import org.eclipse.scout.commons.logger.ScoutLogManager;
-import org.eclipse.scout.rt.client.ClientSyncJob;
-import org.eclipse.scout.rt.client.mobile.transformation.IDeviceTransformationService;
-import org.eclipse.scout.rt.client.mobile.ui.form.AbstractMobileAction;
-import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
-import org.eclipse.scout.rt.ui.rap.mobile.action.ActionButtonBar;
-import org.eclipse.scout.service.SERVICES;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutMobileFormHeader extends AbstractRwtScoutFormHeader {
- private static final IScoutLogger LOG = ScoutLogManager.getLogger(RwtScoutMobileFormHeader.class);
-
- private List<IMenu> m_actions;
-
- @Override
- protected void initializeUi(Composite parent) {
- setRightActionBarOrientation(ActionButtonBar.ORIENTATION_RIGHT_TO_LEFT);
-
- m_actions = fetchActions();
-
- super.initializeUi(parent);
- }
-
- @Override
- protected void collectMenusForLeftButtonBar(final List<IMenu> menuList) {
- List<IMenu> collectedMenus = new LinkedList<IMenu>(menuList);
- if (m_actions != null) {
- for (IMenu action : m_actions) {
- if (AbstractMobileAction.getHorizontalAlignment(action) < 0) {
- collectedMenus.add(action);
- }
- }
- }
-
- final List<IMenu> menuListToAdapt = new LinkedList<IMenu>(menuList);
- menuListToAdapt.addAll(collectedMenus);
- final BooleanHolder filled = new BooleanHolder(false);
- ClientSyncJob job = new ClientSyncJob("Adapting form header left menus", getUiEnvironment().getClientSession()) {
- @Override
- protected void runVoid(IProgressMonitor monitor) throws Throwable {
- SERVICES.getService(IDeviceTransformationService.class).getDeviceTransformer().adaptFormHeaderLeftActions(getScoutObject(), menuListToAdapt);
-
- synchronized (RwtScoutMobileFormHeader.this) {
- if (!filled.getValue()) {
- menuList.addAll(menuListToAdapt);
- filled.setValue(true);
- }
- }
- }
- };
- job.schedule();
- try {
- job.join(5000);
- }
- catch (InterruptedException e) {
- LOG.warn("Failed to adapt form header left menus.", e);
- }
-
- synchronized (RwtScoutMobileFormHeader.this) {
- if (!filled.getValue()) {
- LOG.warn("Failed to adapt form header left menus, timeout reached.");
- menuList.addAll(collectedMenus);
- filled.setValue(true);
- }
- }
-
- }
-
- @Override
- protected void collectMenusForRightButtonBar(final List<IMenu> menuList) {
- List<IMenu> collectedMenus = new LinkedList<IMenu>(menuList);
- if (m_actions != null) {
- for (IMenu action : m_actions) {
- if (AbstractMobileAction.getHorizontalAlignment(action) > 0) {
- collectedMenus.add(action);
- }
- }
-
- }
-
- final List<IMenu> menuListToAdapt = new LinkedList<IMenu>(menuList);
- menuListToAdapt.addAll(collectedMenus);
- final BooleanHolder filled = new BooleanHolder(false);
- ClientSyncJob job = new ClientSyncJob("Adapting form header left menus", getUiEnvironment().getClientSession()) {
- @Override
- protected void runVoid(IProgressMonitor monitor) throws Throwable {
- SERVICES.getService(IDeviceTransformationService.class).getDeviceTransformer().adaptFormHeaderRightActions(getScoutObject(), menuListToAdapt);
-
- synchronized (RwtScoutMobileFormHeader.this) {
- if (!filled.getValue()) {
- menuList.addAll(menuListToAdapt);
- filled.setValue(true);
- }
- }
- }
- };
- job.schedule();
- try {
- job.join(5000);
- }
- catch (InterruptedException e) {
- LOG.warn("Failed to adapt form header right menus.", e);
- }
-
- synchronized (RwtScoutMobileFormHeader.this) {
- if (!filled.getValue()) {
- LOG.warn("Failed to adapt form header right menus, timeout reached.");
- menuList.addAll(collectedMenus);
- filled.setValue(true);
- }
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.scout.commons.holders.BooleanHolder;
+import org.eclipse.scout.commons.logger.IScoutLogger;
+import org.eclipse.scout.commons.logger.ScoutLogManager;
+import org.eclipse.scout.rt.client.ClientSyncJob;
+import org.eclipse.scout.rt.client.mobile.transformation.IDeviceTransformationService;
+import org.eclipse.scout.rt.client.mobile.ui.form.AbstractMobileAction;
+import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
+import org.eclipse.scout.rt.ui.rap.mobile.action.ActionButtonBar;
+import org.eclipse.scout.service.SERVICES;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutMobileFormHeader extends AbstractRwtScoutFormHeader {
+ private static final IScoutLogger LOG = ScoutLogManager.getLogger(RwtScoutMobileFormHeader.class);
+
+ private List<IMenu> m_actions;
+
+ @Override
+ protected void initializeUi(Composite parent) {
+ setRightActionBarOrientation(ActionButtonBar.ORIENTATION_RIGHT_TO_LEFT);
+
+ m_actions = fetchActions();
+
+ super.initializeUi(parent);
+ }
+
+ @Override
+ protected void collectMenusForLeftButtonBar(final List<IMenu> menuList) {
+ List<IMenu> collectedMenus = new LinkedList<IMenu>(menuList);
+ if (m_actions != null) {
+ for (IMenu action : m_actions) {
+ if (AbstractMobileAction.getHorizontalAlignment(action) < 0) {
+ collectedMenus.add(action);
+ }
+ }
+ }
+
+ final List<IMenu> menuListToAdapt = new LinkedList<IMenu>(menuList);
+ menuListToAdapt.addAll(collectedMenus);
+ final BooleanHolder filled = new BooleanHolder(false);
+ ClientSyncJob job = new ClientSyncJob("Adapting form header left menus", getUiEnvironment().getClientSession()) {
+ @Override
+ protected void runVoid(IProgressMonitor monitor) throws Throwable {
+ SERVICES.getService(IDeviceTransformationService.class).getDeviceTransformer().adaptFormHeaderLeftActions(getScoutObject(), menuListToAdapt);
+
+ synchronized (RwtScoutMobileFormHeader.this) {
+ if (!filled.getValue()) {
+ menuList.addAll(menuListToAdapt);
+ filled.setValue(true);
+ }
+ }
+ }
+ };
+ job.schedule();
+ try {
+ job.join(5000);
+ }
+ catch (InterruptedException e) {
+ LOG.warn("Failed to adapt form header left menus.", e);
+ }
+
+ synchronized (RwtScoutMobileFormHeader.this) {
+ if (!filled.getValue()) {
+ LOG.warn("Failed to adapt form header left menus, timeout reached.");
+ menuList.addAll(collectedMenus);
+ filled.setValue(true);
+ }
+ }
+
+ }
+
+ @Override
+ protected void collectMenusForRightButtonBar(final List<IMenu> menuList) {
+ List<IMenu> collectedMenus = new LinkedList<IMenu>(menuList);
+ if (m_actions != null) {
+ for (IMenu action : m_actions) {
+ if (AbstractMobileAction.getHorizontalAlignment(action) > 0) {
+ collectedMenus.add(action);
+ }
+ }
+
+ }
+
+ final List<IMenu> menuListToAdapt = new LinkedList<IMenu>(menuList);
+ menuListToAdapt.addAll(collectedMenus);
+ final BooleanHolder filled = new BooleanHolder(false);
+ ClientSyncJob job = new ClientSyncJob("Adapting form header left menus", getUiEnvironment().getClientSession()) {
+ @Override
+ protected void runVoid(IProgressMonitor monitor) throws Throwable {
+ SERVICES.getService(IDeviceTransformationService.class).getDeviceTransformer().adaptFormHeaderRightActions(getScoutObject(), menuListToAdapt);
+
+ synchronized (RwtScoutMobileFormHeader.this) {
+ if (!filled.getValue()) {
+ menuList.addAll(menuListToAdapt);
+ filled.setValue(true);
+ }
+ }
+ }
+ };
+ job.schedule();
+ try {
+ job.join(5000);
+ }
+ catch (InterruptedException e) {
+ LOG.warn("Failed to adapt form header right menus.", e);
+ }
+
+ synchronized (RwtScoutMobileFormHeader.this) {
+ if (!filled.getValue()) {
+ LOG.warn("Failed to adapt form header right menus, timeout reached.");
+ menuList.addAll(collectedMenus);
+ filled.setValue(true);
+ }
+ }
+ }
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileOutlineFormHeader.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileOutlineFormHeader.java
index 646f4f2a36..df3fb883d5 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileOutlineFormHeader.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileOutlineFormHeader.java
@@ -1,67 +1,67 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
-import org.eclipse.scout.rt.client.ui.desktop.IDesktop;
-import org.eclipse.scout.rt.ui.rap.util.RwtLayoutUtility;
-import org.eclipse.scout.rt.ui.rap.window.desktop.toolbar.RwtScoutToolButtonBar;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutMobileOutlineFormHeader extends AbstractRwtScoutFormHeader {
- private RwtScoutToolButtonBar m_uiToolButtonBar;
-
- @Override
- protected void collectMenusForLeftButtonBar(List<IMenu> menuList) {
- IMenu[] desktopMenus = getDesktopMenus();
- if (desktopMenus != null) {
- menuList.addAll(Arrays.asList(desktopMenus));
- }
- }
-
- @Override
- protected void setTitle(String title) {
- // No title because there is not enough space
- }
-
- @Override
- protected Composite createRightContainer(Composite parent) {
- Composite container = getUiEnvironment().getFormToolkit().createComposite(parent);
- GridLayout gridLayout = RwtLayoutUtility.createGridLayoutNoSpacing(1, false);
- container.setLayout(gridLayout);
-
- m_uiToolButtonBar = new RwtScoutMobileToolButtonBar();
- m_uiToolButtonBar.createUiField(container, getDesktop(), getUiEnvironment());
-
- GridData gridData = new GridData(SWT.RIGHT, SWT.CENTER, true, true);
- m_uiToolButtonBar.getUiContainer().setLayoutData(gridData);
-
- return container;
- }
-
- protected IDesktop getDesktop() {
- return getUiEnvironment().getClientSession().getDesktop();
- }
-
- private IMenu[] getDesktopMenus() {
- return getDesktop().getMenus();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
+import org.eclipse.scout.rt.client.ui.desktop.IDesktop;
+import org.eclipse.scout.rt.ui.rap.util.RwtLayoutUtility;
+import org.eclipse.scout.rt.ui.rap.window.desktop.toolbar.RwtScoutToolButtonBar;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutMobileOutlineFormHeader extends AbstractRwtScoutFormHeader {
+ private RwtScoutToolButtonBar m_uiToolButtonBar;
+
+ @Override
+ protected void collectMenusForLeftButtonBar(List<IMenu> menuList) {
+ IMenu[] desktopMenus = getDesktopMenus();
+ if (desktopMenus != null) {
+ menuList.addAll(Arrays.asList(desktopMenus));
+ }
+ }
+
+ @Override
+ protected void setTitle(String title) {
+ // No title because there is not enough space
+ }
+
+ @Override
+ protected Composite createRightContainer(Composite parent) {
+ Composite container = getUiEnvironment().getFormToolkit().createComposite(parent);
+ GridLayout gridLayout = RwtLayoutUtility.createGridLayoutNoSpacing(1, false);
+ container.setLayout(gridLayout);
+
+ m_uiToolButtonBar = new RwtScoutMobileToolButtonBar();
+ m_uiToolButtonBar.createUiField(container, getDesktop(), getUiEnvironment());
+
+ GridData gridData = new GridData(SWT.RIGHT, SWT.CENTER, true, true);
+ m_uiToolButtonBar.getUiContainer().setLayoutData(gridData);
+
+ return container;
+ }
+
+ protected IDesktop getDesktop() {
+ return getUiEnvironment().getClientSession().getDesktop();
+ }
+
+ private IMenu[] getDesktopMenus() {
+ return getDesktop().getMenus();
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileToolButtonBar.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileToolButtonBar.java
index 604a75712a..5a088d30d4 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileToolButtonBar.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/RwtScoutMobileToolButtonBar.java
@@ -1,29 +1,29 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form;
-
-import org.eclipse.scout.rt.ui.rap.window.desktop.toolbar.RwtScoutToolButtonBar;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutMobileToolButtonBar extends RwtScoutToolButtonBar {
-
- @Override
- public boolean isShowingCollapseButtonEnabled() {
- return false;
- }
-
- @Override
- public boolean isShowingLabelEnabled() {
- return false;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form;
+
+import org.eclipse.scout.rt.ui.rap.window.desktop.toolbar.RwtScoutToolButtonBar;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutMobileToolButtonBar extends RwtScoutToolButtonBar {
+
+ @Override
+ public boolean isShowingCollapseButtonEnabled() {
+ return false;
+ }
+
+ @Override
+ public boolean isShowingLabelEnabled() {
+ return false;
+ }
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/MobileDateFieldFactory.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/MobileDateFieldFactory.java
index 6fe9eb046d..4b71f2b575 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/MobileDateFieldFactory.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/MobileDateFieldFactory.java
@@ -1,55 +1,55 @@
-/*******************************************************************************
- * Copyright (c) 2011 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield;
-
-import org.eclipse.scout.rt.client.ui.form.fields.datefield.IDateField;
-import org.eclipse.scout.rt.ui.rap.form.fields.IRwtScoutFormField;
-import org.eclipse.scout.rt.ui.rap.form.fields.datefield.DateFieldFactory;
-import org.eclipse.scout.rt.ui.rap.form.fields.datefield.IRwtScoutDateField;
-import org.eclipse.scout.rt.ui.rap.form.fields.datefield.IRwtScoutTimeField;
-import org.eclipse.scout.rt.ui.rap.form.fields.datefield.RwtScoutDateField;
-import org.eclipse.scout.rt.ui.rap.form.fields.datefield.RwtScoutDateTimeCompositeField;
-import org.eclipse.scout.rt.ui.rap.form.fields.datefield.RwtScoutTimeField;
-import org.eclipse.scout.rt.ui.rap.util.DeviceUtility;
-
-public class MobileDateFieldFactory extends DateFieldFactory {
-
- @Override
- protected IRwtScoutFormField<IDateField> createRwtScoutDateTimeField() {
- if (DeviceUtility.isMobileOrTabletDevice()) {
- return new RwtScoutMobileDateTimeCompositeField();
- }
- else {
- return new RwtScoutDateTimeCompositeField();
- }
- }
-
- @Override
- protected IRwtScoutDateField createRwtScoutDateField() {
- if (DeviceUtility.isMobileOrTabletDevice()) {
- return new RwtScoutMobileDateField();
- }
- else {
- return new RwtScoutDateField();
- }
- }
-
- @Override
- protected IRwtScoutTimeField createRwtScoutTimeField() {
- if (DeviceUtility.isMobileOrTabletDevice()) {
- return new RwtScoutMobileTimeField();
- }
- else {
- return new RwtScoutTimeField();
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2011 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield;
+
+import org.eclipse.scout.rt.client.ui.form.fields.datefield.IDateField;
+import org.eclipse.scout.rt.ui.rap.form.fields.IRwtScoutFormField;
+import org.eclipse.scout.rt.ui.rap.form.fields.datefield.DateFieldFactory;
+import org.eclipse.scout.rt.ui.rap.form.fields.datefield.IRwtScoutDateField;
+import org.eclipse.scout.rt.ui.rap.form.fields.datefield.IRwtScoutTimeField;
+import org.eclipse.scout.rt.ui.rap.form.fields.datefield.RwtScoutDateField;
+import org.eclipse.scout.rt.ui.rap.form.fields.datefield.RwtScoutDateTimeCompositeField;
+import org.eclipse.scout.rt.ui.rap.form.fields.datefield.RwtScoutTimeField;
+import org.eclipse.scout.rt.ui.rap.util.DeviceUtility;
+
+public class MobileDateFieldFactory extends DateFieldFactory {
+
+ @Override
+ protected IRwtScoutFormField<IDateField> createRwtScoutDateTimeField() {
+ if (DeviceUtility.isMobileOrTabletDevice()) {
+ return new RwtScoutMobileDateTimeCompositeField();
+ }
+ else {
+ return new RwtScoutDateTimeCompositeField();
+ }
+ }
+
+ @Override
+ protected IRwtScoutDateField createRwtScoutDateField() {
+ if (DeviceUtility.isMobileOrTabletDevice()) {
+ return new RwtScoutMobileDateField();
+ }
+ else {
+ return new RwtScoutDateField();
+ }
+ }
+
+ @Override
+ protected IRwtScoutTimeField createRwtScoutTimeField() {
+ if (DeviceUtility.isMobileOrTabletDevice()) {
+ return new RwtScoutMobileTimeField();
+ }
+ else {
+ return new RwtScoutTimeField();
+ }
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/RwtScoutMobileDateField.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/RwtScoutMobileDateField.java
index 7868191b13..6cf2712d89 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/RwtScoutMobileDateField.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/RwtScoutMobileDateField.java
@@ -1,45 +1,45 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield;
-
-import java.util.Date;
-
-import org.eclipse.scout.rt.ui.rap.form.fields.datefield.RwtScoutDateField;
-import org.eclipse.scout.rt.ui.rap.form.fields.datefield.chooser.DateChooserDialog;
-import org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield.chooser.MobileDateChooserDialog;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutMobileDateField extends RwtScoutDateField {
-
- @Override
- protected DateChooserDialog createDateChooserDialog(Shell parentShell, Date currentDate) {
- return new MobileDateChooserDialog(parentShell, currentDate);
- }
-
- @Override
- protected void setEnabledFromScout(boolean b) {
- super.setEnabledFromScout(b);
-
- // Disable field to avoid the appearance of the keyboard. Choosing a date is only possible with the date picker popup.
- getUiField().setEnabled(false);
- }
-
- @Override
- protected void handleUiFocusLostOnDatePickerPopup(FocusEvent event) {
- // Since the popup hides the ui field it is not necessary to reset the focus
- // It's also not necessary to close the popup on focus lost because the it can be closed with the "x" at the title bar.
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield;
+
+import java.util.Date;
+
+import org.eclipse.scout.rt.ui.rap.form.fields.datefield.RwtScoutDateField;
+import org.eclipse.scout.rt.ui.rap.form.fields.datefield.chooser.DateChooserDialog;
+import org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield.chooser.MobileDateChooserDialog;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutMobileDateField extends RwtScoutDateField {
+
+ @Override
+ protected DateChooserDialog createDateChooserDialog(Shell parentShell, Date currentDate) {
+ return new MobileDateChooserDialog(parentShell, currentDate);
+ }
+
+ @Override
+ protected void setEnabledFromScout(boolean b) {
+ super.setEnabledFromScout(b);
+
+ // Disable field to avoid the appearance of the keyboard. Choosing a date is only possible with the date picker popup.
+ getUiField().setEnabled(false);
+ }
+
+ @Override
+ protected void handleUiFocusLostOnDatePickerPopup(FocusEvent event) {
+ // Since the popup hides the ui field it is not necessary to reset the focus
+ // It's also not necessary to close the popup on focus lost because the it can be closed with the "x" at the title bar.
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/RwtScoutMobileDateTimeCompositeField.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/RwtScoutMobileDateTimeCompositeField.java
index 8d34423a6b..7158496f39 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/RwtScoutMobileDateTimeCompositeField.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/RwtScoutMobileDateTimeCompositeField.java
@@ -1,32 +1,32 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield;
-
-import org.eclipse.scout.rt.ui.rap.form.fields.datefield.RwtScoutDateField;
-import org.eclipse.scout.rt.ui.rap.form.fields.datefield.RwtScoutDateTimeCompositeField;
-import org.eclipse.scout.rt.ui.rap.form.fields.datefield.RwtScoutTimeField;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutMobileDateTimeCompositeField extends RwtScoutDateTimeCompositeField {
-
- @Override
- protected RwtScoutDateField createRwtScoutDateField() {
- return new RwtScoutMobileDateField();
- }
-
- @Override
- protected RwtScoutTimeField createRwtScoutTimeField() {
- return new RwtScoutMobileTimeField();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield;
+
+import org.eclipse.scout.rt.ui.rap.form.fields.datefield.RwtScoutDateField;
+import org.eclipse.scout.rt.ui.rap.form.fields.datefield.RwtScoutDateTimeCompositeField;
+import org.eclipse.scout.rt.ui.rap.form.fields.datefield.RwtScoutTimeField;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutMobileDateTimeCompositeField extends RwtScoutDateTimeCompositeField {
+
+ @Override
+ protected RwtScoutDateField createRwtScoutDateField() {
+ return new RwtScoutMobileDateField();
+ }
+
+ @Override
+ protected RwtScoutTimeField createRwtScoutTimeField() {
+ return new RwtScoutMobileTimeField();
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/RwtScoutMobileTimeField.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/RwtScoutMobileTimeField.java
index c8ef09e73c..8a873b1287 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/RwtScoutMobileTimeField.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/RwtScoutMobileTimeField.java
@@ -1,45 +1,45 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield;
-
-import java.util.Date;
-
-import org.eclipse.scout.rt.ui.rap.form.fields.datefield.RwtScoutTimeField;
-import org.eclipse.scout.rt.ui.rap.form.fields.datefield.chooser.TimeChooserDialog;
-import org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield.chooser.MobileTimeChooserDialog;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutMobileTimeField extends RwtScoutTimeField {
-
- @Override
- protected TimeChooserDialog createTimeChooserDialog(Shell parentShell, Date currentTime) {
- return new MobileTimeChooserDialog(parentShell, currentTime);
- }
-
- @Override
- protected void setEnabledFromScout(boolean b) {
- super.setEnabledFromScout(b);
-
- // Disable field to avoid the appearance of the keyboard. Choosing a date is only possible with the date picker popup.
- getUiField().setEnabled(false);
- }
-
- @Override
- protected void handleUiFocusLostOnDatePickerPopup(FocusEvent event) {
- // Since the popup hides the ui field it is not necessary to reset the focus
- // It's also not necessary to close the popup on focus lost because the it can be closed with the "x" at the title bar.
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield;
+
+import java.util.Date;
+
+import org.eclipse.scout.rt.ui.rap.form.fields.datefield.RwtScoutTimeField;
+import org.eclipse.scout.rt.ui.rap.form.fields.datefield.chooser.TimeChooserDialog;
+import org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield.chooser.MobileTimeChooserDialog;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutMobileTimeField extends RwtScoutTimeField {
+
+ @Override
+ protected TimeChooserDialog createTimeChooserDialog(Shell parentShell, Date currentTime) {
+ return new MobileTimeChooserDialog(parentShell, currentTime);
+ }
+
+ @Override
+ protected void setEnabledFromScout(boolean b) {
+ super.setEnabledFromScout(b);
+
+ // Disable field to avoid the appearance of the keyboard. Choosing a date is only possible with the date picker popup.
+ getUiField().setEnabled(false);
+ }
+
+ @Override
+ protected void handleUiFocusLostOnDatePickerPopup(FocusEvent event) {
+ // Since the popup hides the ui field it is not necessary to reset the focus
+ // It's also not necessary to close the popup on focus lost because the it can be closed with the "x" at the title bar.
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/chooser/MobileDateChooserDialog.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/chooser/MobileDateChooserDialog.java
index ace4608d49..3c3b7d8839 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/chooser/MobileDateChooserDialog.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/chooser/MobileDateChooserDialog.java
@@ -1,76 +1,76 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield.chooser;
-
-import java.util.Date;
-
-import org.eclipse.scout.rt.ui.rap.form.fields.datefield.chooser.DateChooserDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.9.0
- */
-public class MobileDateChooserDialog extends DateChooserDialog {
- private static final int DATE_CELL_WIDTH = 38;
- private static final int DATE_CELL_HEIGHT = 33;
- private static final int CONTROL_BUTTON_WIDTH = 30;
- private static final int CONTROL_BUTTON_HEIGHT = 30;
-
- private static final long serialVersionUID = 1L;
-
- public MobileDateChooserDialog(Shell parentShell, Date date) {
- super(parentShell, date);
- }
-
- @Override
- protected int getShellStyle() {
- return SWT.APPLICATION_MODAL | SWT.CLOSE;
- }
-
- /**
- * Position the popup in the center of the parent shell
- */
- @Override
- protected Point getLocation(Control field) {
- Rectangle parentShellBounds = getParentShell().getBounds();
- Point dialogSize = getShell().getSize();
-
- int x = parentShellBounds.x + (parentShellBounds.width - dialogSize.x) / 2;
- int y = parentShellBounds.y + (parentShellBounds.height - dialogSize.y) / 2;
-
- return new Point(x, y);
- }
-
- @Override
- protected int getDateCellHeight() {
- return DATE_CELL_HEIGHT;
- }
-
- @Override
- protected int getDateCellWidth() {
- return DATE_CELL_WIDTH;
- }
-
- @Override
- protected int getControlButtonHeight() {
- return CONTROL_BUTTON_HEIGHT;
- }
-
- @Override
- protected int getControlButtonWidth() {
- return CONTROL_BUTTON_WIDTH;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield.chooser;
+
+import java.util.Date;
+
+import org.eclipse.scout.rt.ui.rap.form.fields.datefield.chooser.DateChooserDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @since 3.9.0
+ */
+public class MobileDateChooserDialog extends DateChooserDialog {
+ private static final int DATE_CELL_WIDTH = 38;
+ private static final int DATE_CELL_HEIGHT = 33;
+ private static final int CONTROL_BUTTON_WIDTH = 30;
+ private static final int CONTROL_BUTTON_HEIGHT = 30;
+
+ private static final long serialVersionUID = 1L;
+
+ public MobileDateChooserDialog(Shell parentShell, Date date) {
+ super(parentShell, date);
+ }
+
+ @Override
+ protected int getShellStyle() {
+ return SWT.APPLICATION_MODAL | SWT.CLOSE;
+ }
+
+ /**
+ * Position the popup in the center of the parent shell
+ */
+ @Override
+ protected Point getLocation(Control field) {
+ Rectangle parentShellBounds = getParentShell().getBounds();
+ Point dialogSize = getShell().getSize();
+
+ int x = parentShellBounds.x + (parentShellBounds.width - dialogSize.x) / 2;
+ int y = parentShellBounds.y + (parentShellBounds.height - dialogSize.y) / 2;
+
+ return new Point(x, y);
+ }
+
+ @Override
+ protected int getDateCellHeight() {
+ return DATE_CELL_HEIGHT;
+ }
+
+ @Override
+ protected int getDateCellWidth() {
+ return DATE_CELL_WIDTH;
+ }
+
+ @Override
+ protected int getControlButtonHeight() {
+ return CONTROL_BUTTON_HEIGHT;
+ }
+
+ @Override
+ protected int getControlButtonWidth() {
+ return CONTROL_BUTTON_WIDTH;
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/chooser/MobileTimeChooser.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/chooser/MobileTimeChooser.java
index 4443d788cd..d08bbc7562 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/chooser/MobileTimeChooser.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/chooser/MobileTimeChooser.java
@@ -1,31 +1,31 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield.chooser;
-
-import org.eclipse.scout.rt.ui.rap.form.fields.datefield.chooser.TimeChooser;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 3.9.0
- */
-public class MobileTimeChooser extends TimeChooser {
- private static final int TABLE_CELL_HEIGHT = 30;
-
- public MobileTimeChooser(Composite parent) {
- super(parent);
- }
-
- @Override
- protected int getTableCellHeight() {
- return TABLE_CELL_HEIGHT;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield.chooser;
+
+import org.eclipse.scout.rt.ui.rap.form.fields.datefield.chooser.TimeChooser;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 3.9.0
+ */
+public class MobileTimeChooser extends TimeChooser {
+ private static final int TABLE_CELL_HEIGHT = 30;
+
+ public MobileTimeChooser(Composite parent) {
+ super(parent);
+ }
+
+ @Override
+ protected int getTableCellHeight() {
+ return TABLE_CELL_HEIGHT;
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/chooser/MobileTimeChooserDialog.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/chooser/MobileTimeChooserDialog.java
index b4a39815c8..e3f6425993 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/chooser/MobileTimeChooserDialog.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/datefield/chooser/MobileTimeChooserDialog.java
@@ -1,59 +1,59 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield.chooser;
-
-import java.util.Date;
-
-import org.eclipse.scout.rt.ui.rap.form.fields.datefield.chooser.TimeChooser;
-import org.eclipse.scout.rt.ui.rap.form.fields.datefield.chooser.TimeChooserDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.9.0
- */
-public class MobileTimeChooserDialog extends TimeChooserDialog {
-
- private static final long serialVersionUID = 1L;
-
- public MobileTimeChooserDialog(Shell parentShell, Date date) {
- super(parentShell, date);
- }
-
- @Override
- protected int getShellStyle() {
- return SWT.APPLICATION_MODAL | SWT.CLOSE;
- }
-
- /**
- * Position the popup in the center of the parent shell
- */
- @Override
- protected Point getLocation(Control field) {
- Rectangle parentShellBounds = getParentShell().getBounds();
- Point dialogSize = getShell().getSize();
-
- int x = parentShellBounds.x + (parentShellBounds.width - dialogSize.x) / 2;
- int y = parentShellBounds.y + (parentShellBounds.height - dialogSize.y) / 2;
-
- return new Point(x, y);
- }
-
- @Override
- protected TimeChooser createTimeChooser(Composite parent) {
- return new MobileTimeChooser(parent);
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.datefield.chooser;
+
+import java.util.Date;
+
+import org.eclipse.scout.rt.ui.rap.form.fields.datefield.chooser.TimeChooser;
+import org.eclipse.scout.rt.ui.rap.form.fields.datefield.chooser.TimeChooserDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @since 3.9.0
+ */
+public class MobileTimeChooserDialog extends TimeChooserDialog {
+
+ private static final long serialVersionUID = 1L;
+
+ public MobileTimeChooserDialog(Shell parentShell, Date date) {
+ super(parentShell, date);
+ }
+
+ @Override
+ protected int getShellStyle() {
+ return SWT.APPLICATION_MODAL | SWT.CLOSE;
+ }
+
+ /**
+ * Position the popup in the center of the parent shell
+ */
+ @Override
+ protected Point getLocation(Control field) {
+ Rectangle parentShellBounds = getParentShell().getBounds();
+ Point dialogSize = getShell().getSize();
+
+ int x = parentShellBounds.x + (parentShellBounds.width - dialogSize.x) / 2;
+ int y = parentShellBounds.y + (parentShellBounds.height - dialogSize.y) / 2;
+
+ return new Point(x, y);
+ }
+
+ @Override
+ protected TimeChooser createTimeChooser(Composite parent) {
+ return new MobileTimeChooser(parent);
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/groupbox/MobileGroupBoxFieldFactory.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/groupbox/MobileGroupBoxFieldFactory.java
index 0737ed0a11..a25e2b429a 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/groupbox/MobileGroupBoxFieldFactory.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/groupbox/MobileGroupBoxFieldFactory.java
@@ -1,45 +1,45 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.groupbox;
-
-import org.eclipse.scout.rt.client.ui.form.fields.IFormField;
-import org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox;
-import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
-import org.eclipse.scout.rt.ui.rap.extension.IFormFieldFactory;
-import org.eclipse.scout.rt.ui.rap.form.fields.IRwtScoutFormField;
-import org.eclipse.scout.rt.ui.rap.form.fields.groupbox.IRwtScoutGroupBox;
-import org.eclipse.scout.rt.ui.rap.form.fields.groupbox.RwtScoutGroupBox;
-import org.eclipse.scout.rt.ui.rap.util.DeviceUtility;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 3.9.0
- */
-public class MobileGroupBoxFieldFactory implements IFormFieldFactory {
-
- @Override
- public IRwtScoutFormField<?> createUiFormField(Composite parent, IFormField model, IRwtEnvironment uiEnvironment) {
- IRwtScoutGroupBox field;
-
- if (DeviceUtility.isMobileOrTabletDevice()) {
- field = new RwtScoutMobileGroupBox();
- }
- else {
- field = new RwtScoutGroupBox();
- }
-
- IGroupBox groupBox = (IGroupBox) model;
- field.createUiField(parent, groupBox, uiEnvironment);
-
- return field;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.groupbox;
+
+import org.eclipse.scout.rt.client.ui.form.fields.IFormField;
+import org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox;
+import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
+import org.eclipse.scout.rt.ui.rap.extension.IFormFieldFactory;
+import org.eclipse.scout.rt.ui.rap.form.fields.IRwtScoutFormField;
+import org.eclipse.scout.rt.ui.rap.form.fields.groupbox.IRwtScoutGroupBox;
+import org.eclipse.scout.rt.ui.rap.form.fields.groupbox.RwtScoutGroupBox;
+import org.eclipse.scout.rt.ui.rap.util.DeviceUtility;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 3.9.0
+ */
+public class MobileGroupBoxFieldFactory implements IFormFieldFactory {
+
+ @Override
+ public IRwtScoutFormField<?> createUiFormField(Composite parent, IFormField model, IRwtEnvironment uiEnvironment) {
+ IRwtScoutGroupBox field;
+
+ if (DeviceUtility.isMobileOrTabletDevice()) {
+ field = new RwtScoutMobileGroupBox();
+ }
+ else {
+ field = new RwtScoutGroupBox();
+ }
+
+ IGroupBox groupBox = (IGroupBox) model;
+ field.createUiField(parent, groupBox, uiEnvironment);
+
+ return field;
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/groupbox/RwtScoutMobileGroupBox.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/groupbox/RwtScoutMobileGroupBox.java
index d13146cce3..d7c2f5fdee 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/groupbox/RwtScoutMobileGroupBox.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/groupbox/RwtScoutMobileGroupBox.java
@@ -1,30 +1,30 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.groupbox;
-
-import org.eclipse.scout.rt.ui.rap.form.fields.groupbox.RwtScoutGroupBox;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutMobileGroupBox extends RwtScoutGroupBox {
-
- @Override
- protected Composite createButtonbar(Composite parent) {
- if (getScoutObject().getForm().getRootGroupBox() == getScoutObject()) {
- //Button bar of the main box must not be visible
- return null;
- }
-
- return super.createButtonbar(parent);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.groupbox;
+
+import org.eclipse.scout.rt.ui.rap.form.fields.groupbox.RwtScoutGroupBox;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutMobileGroupBox extends RwtScoutGroupBox {
+
+ @Override
+ protected Composite createButtonbar(Composite parent) {
+ if (getScoutObject().getForm().getRootGroupBox() == getScoutObject()) {
+ //Button bar of the main box must not be visible
+ return null;
+ }
+
+ return super.createButtonbar(parent);
+ }
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/smartfield/MobileSmartFieldFactory.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/smartfield/MobileSmartFieldFactory.java
index 9916ddf602..7e2b06082a 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/smartfield/MobileSmartFieldFactory.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/smartfield/MobileSmartFieldFactory.java
@@ -1,45 +1,45 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.smartfield;
-
-import org.eclipse.scout.rt.client.ui.form.fields.IFormField;
-import org.eclipse.scout.rt.client.ui.form.fields.smartfield.ISmartField;
-import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
-import org.eclipse.scout.rt.ui.rap.extension.IFormFieldFactory;
-import org.eclipse.scout.rt.ui.rap.form.fields.IRwtScoutFormField;
-import org.eclipse.scout.rt.ui.rap.form.fields.smartfield.IRwtScoutSmartField;
-import org.eclipse.scout.rt.ui.rap.form.fields.smartfield.RwtScoutSmartField;
-import org.eclipse.scout.rt.ui.rap.util.DeviceUtility;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 3.9.0
- */
-public class MobileSmartFieldFactory implements IFormFieldFactory {
-
- @Override
- public IRwtScoutFormField<?> createUiFormField(Composite parent, IFormField model, IRwtEnvironment uiEnvironment) {
- IRwtScoutSmartField field;
-
- if (DeviceUtility.isMobileOrTabletDevice()) {
- field = new RwtScoutMobileSmartField();
- }
- else {
- field = new RwtScoutSmartField();
- }
-
- ISmartField<?> formField = (ISmartField) model;
- field.createUiField(parent, formField, uiEnvironment);
-
- return field;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.smartfield;
+
+import org.eclipse.scout.rt.client.ui.form.fields.IFormField;
+import org.eclipse.scout.rt.client.ui.form.fields.smartfield.ISmartField;
+import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
+import org.eclipse.scout.rt.ui.rap.extension.IFormFieldFactory;
+import org.eclipse.scout.rt.ui.rap.form.fields.IRwtScoutFormField;
+import org.eclipse.scout.rt.ui.rap.form.fields.smartfield.IRwtScoutSmartField;
+import org.eclipse.scout.rt.ui.rap.form.fields.smartfield.RwtScoutSmartField;
+import org.eclipse.scout.rt.ui.rap.util.DeviceUtility;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 3.9.0
+ */
+public class MobileSmartFieldFactory implements IFormFieldFactory {
+
+ @Override
+ public IRwtScoutFormField<?> createUiFormField(Composite parent, IFormField model, IRwtEnvironment uiEnvironment) {
+ IRwtScoutSmartField field;
+
+ if (DeviceUtility.isMobileOrTabletDevice()) {
+ field = new RwtScoutMobileSmartField();
+ }
+ else {
+ field = new RwtScoutSmartField();
+ }
+
+ ISmartField<?> formField = (ISmartField) model;
+ field.createUiField(parent, formField, uiEnvironment);
+
+ return field;
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/smartfield/RwtScoutMobileSmartField.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/smartfield/RwtScoutMobileSmartField.java
index 7889ac47d4..b8793775bd 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/smartfield/RwtScoutMobileSmartField.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/smartfield/RwtScoutMobileSmartField.java
@@ -1,170 +1,170 @@
-/*******************************************************************************
- * Copyright (c) 2012 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.smartfield;
-
-import org.eclipse.rwt.lifecycle.WidgetUtil;
-import org.eclipse.scout.commons.CompareUtility;
-import org.eclipse.scout.commons.logger.IScoutLogger;
-import org.eclipse.scout.commons.logger.ScoutLogManager;
-import org.eclipse.scout.rt.client.mobile.ui.form.fields.smartfield.MobileSmartFieldProposalFormProvider;
-import org.eclipse.scout.rt.client.ui.form.fields.IFormField;
-import org.eclipse.scout.rt.client.ui.form.fields.smartfield.ISmartField;
-import org.eclipse.scout.rt.ui.rap.LogicalGridLayout;
-import org.eclipse.scout.rt.ui.rap.ext.StatusLabelEx;
-import org.eclipse.scout.rt.ui.rap.ext.StyledTextEx;
-import org.eclipse.scout.rt.ui.rap.ext.custom.StyledText;
-import org.eclipse.scout.rt.ui.rap.form.fields.LogicalGridDataBuilder;
-import org.eclipse.scout.rt.ui.rap.form.fields.RwtScoutValueFieldComposite;
-import org.eclipse.scout.rt.ui.rap.form.fields.smartfield.IRwtScoutSmartField;
-import org.eclipse.scout.rt.ui.rap.util.RwtLayoutUtility;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-
-public class RwtScoutMobileSmartField extends RwtScoutValueFieldComposite<ISmartField<?>> implements IRwtScoutSmartField {
- private static final IScoutLogger LOG = ScoutLogManager.getLogger(RwtScoutMobileSmartField.class);
-
- private Composite m_browseIconContainer;
- private Composite m_smartContainer;
-
- public RwtScoutMobileSmartField() {
- }
-
- @Override
- protected void initializeUi(Composite parent) {
- Composite container = getUiEnvironment().getFormToolkit().createComposite(parent);
- StatusLabelEx label = getUiEnvironment().getFormToolkit().createStatusLabel(container, getScoutObject());
-
- m_smartContainer = getUiEnvironment().getFormToolkit().createComposite(container, SWT.BORDER);
- m_smartContainer.setData(WidgetUtil.CUSTOM_VARIANT, getSmartfieldVariant());
-
- StyledText textField = new StyledTextEx(m_smartContainer, SWT.SINGLE);
- getUiEnvironment().getFormToolkit().adapt(textField, false, false);
-
- // correction to look like a normal text
- textField.setData(WidgetUtil.CUSTOM_VARIANT, getSmartfieldVariant());
-
- m_browseIconContainer = getUiEnvironment().getFormToolkit().createComposite(m_smartContainer);
-
- setUiContainer(container);
- setUiLabel(label);
- setUiField(textField);
-
- // layout
- container.setLayout(new LogicalGridLayout(1, 0));
-
- // m_browseIconContainer and m_browseIconContainer are only necessary to position the icon at the right of the field
- // If Bug 361799 gets fixed this could be replaced by background-position and background-repeat
- m_smartContainer.setLayoutData(LogicalGridDataBuilder.createField(((IFormField) getScoutObject()).getGridData()));
- m_smartContainer.setLayout(RwtLayoutUtility.createGridLayoutNoSpacing(2, false));
-
- GridData textLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
- textField.setLayoutData(textLayoutData);
-
- GridData buttonLayoutData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
- buttonLayoutData.heightHint = 20;
- buttonLayoutData.widthHint = 20;
- m_browseIconContainer.setLayoutData(buttonLayoutData);
-
- textField.addMouseListener(new P_FieldSelectionListener());
- m_browseIconContainer.addMouseListener(new P_FieldSelectionListener());
- m_smartContainer.addMouseListener(new P_FieldSelectionListener());
- }
-
- protected String getSmartfieldVariant() {
- return VARIANT_SMARTFIELD;
- }
-
- protected String getSmartfieldDisabledVariant() {
- return VARIANT_SMARTFIELD_DISABLED;
- }
-
- @Override
- public StyledText getUiField() {
- return (StyledText) super.getUiField();
- }
-
- @Override
- protected void attachScout() {
- super.attachScout();
-
- setIconIdFromScout(getScoutObject().getIconId());
- getScoutObject().setProposalFormProvider(new MobileSmartFieldProposalFormProvider());
- }
-
- @Override
- protected void setDisplayTextFromScout(String s) {
- if (!CompareUtility.equals(s, getUiField().getText())) {
- if (s == null) {
- s = "";
- }
- StyledText field = getUiField();
- field.setText(s);
- }
- }
-
- @Override
- protected void setEnabledFromScout(boolean b) {
- super.setEnabledFromScout(b);
-
- getUiField().setEnabled(false);
-
- if (b) {
- m_smartContainer.setData(WidgetUtil.CUSTOM_VARIANT, getSmartfieldVariant());
- }
- else {
- m_smartContainer.setData(WidgetUtil.CUSTOM_VARIANT, getSmartfieldDisabledVariant());
- }
- }
-
- protected void setIconIdFromScout(String s) {
- m_browseIconContainer.setData(WidgetUtil.CUSTOM_VARIANT, s);
- }
-
- @Override
- protected void setBackgroundFromScout(String scoutColor) {
- setBackgroundFromScout(scoutColor, m_smartContainer);
- }
-
- @Override
- protected void handleScoutPropertyChange(String name, Object newValue) {
- super.handleScoutPropertyChange(name, newValue);
- if (name.equals(ISmartField.PROP_ICON_ID)) {
- setIconIdFromScout((String) newValue);
- }
- }
-
- protected void requestProposalSupportFromUi(final String text, final boolean selectCurrentValue) {
- Runnable t = new Runnable() {
- @Override
- public void run() {
- getScoutObject().getUIFacade().openProposalFromUI(text, selectCurrentValue);
- }
- };
- getUiEnvironment().invokeScoutLater(t, 0);
- }
-
- private class P_FieldSelectionListener extends MouseAdapter {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void mouseUp(MouseEvent e) {
- if (!getScoutObject().isEnabled()) {
- return;
- }
-
- requestProposalSupportFromUi(ISmartField.BROWSE_ALL_TEXT, true);
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2012 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.smartfield;
+
+import org.eclipse.rwt.lifecycle.WidgetUtil;
+import org.eclipse.scout.commons.CompareUtility;
+import org.eclipse.scout.commons.logger.IScoutLogger;
+import org.eclipse.scout.commons.logger.ScoutLogManager;
+import org.eclipse.scout.rt.client.mobile.ui.form.fields.smartfield.MobileSmartFieldProposalFormProvider;
+import org.eclipse.scout.rt.client.ui.form.fields.IFormField;
+import org.eclipse.scout.rt.client.ui.form.fields.smartfield.ISmartField;
+import org.eclipse.scout.rt.ui.rap.LogicalGridLayout;
+import org.eclipse.scout.rt.ui.rap.ext.StatusLabelEx;
+import org.eclipse.scout.rt.ui.rap.ext.StyledTextEx;
+import org.eclipse.scout.rt.ui.rap.ext.custom.StyledText;
+import org.eclipse.scout.rt.ui.rap.form.fields.LogicalGridDataBuilder;
+import org.eclipse.scout.rt.ui.rap.form.fields.RwtScoutValueFieldComposite;
+import org.eclipse.scout.rt.ui.rap.form.fields.smartfield.IRwtScoutSmartField;
+import org.eclipse.scout.rt.ui.rap.util.RwtLayoutUtility;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+
+public class RwtScoutMobileSmartField extends RwtScoutValueFieldComposite<ISmartField<?>> implements IRwtScoutSmartField {
+ private static final IScoutLogger LOG = ScoutLogManager.getLogger(RwtScoutMobileSmartField.class);
+
+ private Composite m_browseIconContainer;
+ private Composite m_smartContainer;
+
+ public RwtScoutMobileSmartField() {
+ }
+
+ @Override
+ protected void initializeUi(Composite parent) {
+ Composite container = getUiEnvironment().getFormToolkit().createComposite(parent);
+ StatusLabelEx label = getUiEnvironment().getFormToolkit().createStatusLabel(container, getScoutObject());
+
+ m_smartContainer = getUiEnvironment().getFormToolkit().createComposite(container, SWT.BORDER);
+ m_smartContainer.setData(WidgetUtil.CUSTOM_VARIANT, getSmartfieldVariant());
+
+ StyledText textField = new StyledTextEx(m_smartContainer, SWT.SINGLE);
+ getUiEnvironment().getFormToolkit().adapt(textField, false, false);
+
+ // correction to look like a normal text
+ textField.setData(WidgetUtil.CUSTOM_VARIANT, getSmartfieldVariant());
+
+ m_browseIconContainer = getUiEnvironment().getFormToolkit().createComposite(m_smartContainer);
+
+ setUiContainer(container);
+ setUiLabel(label);
+ setUiField(textField);
+
+ // layout
+ container.setLayout(new LogicalGridLayout(1, 0));
+
+ // m_browseIconContainer and m_browseIconContainer are only necessary to position the icon at the right of the field
+ // If Bug 361799 gets fixed this could be replaced by background-position and background-repeat
+ m_smartContainer.setLayoutData(LogicalGridDataBuilder.createField(((IFormField) getScoutObject()).getGridData()));
+ m_smartContainer.setLayout(RwtLayoutUtility.createGridLayoutNoSpacing(2, false));
+
+ GridData textLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ textField.setLayoutData(textLayoutData);
+
+ GridData buttonLayoutData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
+ buttonLayoutData.heightHint = 20;
+ buttonLayoutData.widthHint = 20;
+ m_browseIconContainer.setLayoutData(buttonLayoutData);
+
+ textField.addMouseListener(new P_FieldSelectionListener());
+ m_browseIconContainer.addMouseListener(new P_FieldSelectionListener());
+ m_smartContainer.addMouseListener(new P_FieldSelectionListener());
+ }
+
+ protected String getSmartfieldVariant() {
+ return VARIANT_SMARTFIELD;
+ }
+
+ protected String getSmartfieldDisabledVariant() {
+ return VARIANT_SMARTFIELD_DISABLED;
+ }
+
+ @Override
+ public StyledText getUiField() {
+ return (StyledText) super.getUiField();
+ }
+
+ @Override
+ protected void attachScout() {
+ super.attachScout();
+
+ setIconIdFromScout(getScoutObject().getIconId());
+ getScoutObject().setProposalFormProvider(new MobileSmartFieldProposalFormProvider());
+ }
+
+ @Override
+ protected void setDisplayTextFromScout(String s) {
+ if (!CompareUtility.equals(s, getUiField().getText())) {
+ if (s == null) {
+ s = "";
+ }
+ StyledText field = getUiField();
+ field.setText(s);
+ }
+ }
+
+ @Override
+ protected void setEnabledFromScout(boolean b) {
+ super.setEnabledFromScout(b);
+
+ getUiField().setEnabled(false);
+
+ if (b) {
+ m_smartContainer.setData(WidgetUtil.CUSTOM_VARIANT, getSmartfieldVariant());
+ }
+ else {
+ m_smartContainer.setData(WidgetUtil.CUSTOM_VARIANT, getSmartfieldDisabledVariant());
+ }
+ }
+
+ protected void setIconIdFromScout(String s) {
+ m_browseIconContainer.setData(WidgetUtil.CUSTOM_VARIANT, s);
+ }
+
+ @Override
+ protected void setBackgroundFromScout(String scoutColor) {
+ setBackgroundFromScout(scoutColor, m_smartContainer);
+ }
+
+ @Override
+ protected void handleScoutPropertyChange(String name, Object newValue) {
+ super.handleScoutPropertyChange(name, newValue);
+ if (name.equals(ISmartField.PROP_ICON_ID)) {
+ setIconIdFromScout((String) newValue);
+ }
+ }
+
+ protected void requestProposalSupportFromUi(final String text, final boolean selectCurrentValue) {
+ Runnable t = new Runnable() {
+ @Override
+ public void run() {
+ getScoutObject().getUIFacade().openProposalFromUI(text, selectCurrentValue);
+ }
+ };
+ getUiEnvironment().invokeScoutLater(t, 0);
+ }
+
+ private class P_FieldSelectionListener extends MouseAdapter {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ if (!getScoutObject().isEnabled()) {
+ return;
+ }
+
+ requestProposalSupportFromUi(ISmartField.BROWSE_ALL_TEXT, true);
+ }
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tabbox/MobileTabBoxFactory.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tabbox/MobileTabBoxFactory.java
index 4648eadec9..90c11906e8 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tabbox/MobileTabBoxFactory.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tabbox/MobileTabBoxFactory.java
@@ -1,78 +1,78 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tabbox;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.scout.commons.holders.BooleanHolder;
-import org.eclipse.scout.commons.logger.IScoutLogger;
-import org.eclipse.scout.commons.logger.ScoutLogManager;
-import org.eclipse.scout.rt.client.ClientSyncJob;
-import org.eclipse.scout.rt.client.mobile.transformation.IDeviceTransformationService;
-import org.eclipse.scout.rt.client.ui.form.fields.IFormField;
-import org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox;
-import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
-import org.eclipse.scout.rt.ui.rap.extension.IFormFieldFactory;
-import org.eclipse.scout.rt.ui.rap.form.fields.IRwtScoutFormField;
-import org.eclipse.scout.rt.ui.rap.form.fields.tabbox.IRwtScoutTabBox;
-import org.eclipse.scout.rt.ui.rap.form.fields.tabbox.RwtScoutTabBox;
-import org.eclipse.scout.rt.ui.rap.util.DeviceUtility;
-import org.eclipse.scout.service.SERVICES;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 3.9.0
- */
-public class MobileTabBoxFactory implements IFormFieldFactory {
- private static final IScoutLogger LOG = ScoutLogManager.getLogger(MobileTabBoxFactory.class);
-
- private IRwtEnvironment m_uiEnvironment;
-
- @Override
- public IRwtScoutFormField<?> createUiFormField(Composite parent, IFormField model, IRwtEnvironment uiEnvironment) {
- m_uiEnvironment = uiEnvironment;
- IRwtScoutTabBox field;
- ITabBox formField = (ITabBox) model;
-
- if (DeviceUtility.isMobileOrTabletDevice() && acceptMobileTabBoxTransformation(formField)) {
- field = new RwtScoutMobileTabBox();
- }
- else {
- field = new RwtScoutTabBox();
- }
-
- field.createUiField(parent, formField, uiEnvironment);
-
- return field;
- }
-
- private boolean acceptMobileTabBoxTransformation(final ITabBox tabBox) {
- final BooleanHolder accepted = new BooleanHolder(false);
- ClientSyncJob job = new ClientSyncJob("Getting permission to create mobile tabbox.", m_uiEnvironment.getClientSession()) {
-
- @Override
- protected void runVoid(IProgressMonitor monitor) throws Throwable {
- accepted.setValue(SERVICES.getService(IDeviceTransformationService.class).getDeviceTransformer().acceptMobileTabBoxTransformation(tabBox));
- }
-
- };
- job.schedule();
- try {
- job.join(5000);
- }
- catch (InterruptedException e) {
- LOG.warn("Failed to getting permission to create mobile tabbox.", e);
- }
-
- return accepted.getValue();
-
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tabbox;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.scout.commons.holders.BooleanHolder;
+import org.eclipse.scout.commons.logger.IScoutLogger;
+import org.eclipse.scout.commons.logger.ScoutLogManager;
+import org.eclipse.scout.rt.client.ClientSyncJob;
+import org.eclipse.scout.rt.client.mobile.transformation.IDeviceTransformationService;
+import org.eclipse.scout.rt.client.ui.form.fields.IFormField;
+import org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox;
+import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
+import org.eclipse.scout.rt.ui.rap.extension.IFormFieldFactory;
+import org.eclipse.scout.rt.ui.rap.form.fields.IRwtScoutFormField;
+import org.eclipse.scout.rt.ui.rap.form.fields.tabbox.IRwtScoutTabBox;
+import org.eclipse.scout.rt.ui.rap.form.fields.tabbox.RwtScoutTabBox;
+import org.eclipse.scout.rt.ui.rap.util.DeviceUtility;
+import org.eclipse.scout.service.SERVICES;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 3.9.0
+ */
+public class MobileTabBoxFactory implements IFormFieldFactory {
+ private static final IScoutLogger LOG = ScoutLogManager.getLogger(MobileTabBoxFactory.class);
+
+ private IRwtEnvironment m_uiEnvironment;
+
+ @Override
+ public IRwtScoutFormField<?> createUiFormField(Composite parent, IFormField model, IRwtEnvironment uiEnvironment) {
+ m_uiEnvironment = uiEnvironment;
+ IRwtScoutTabBox field;
+ ITabBox formField = (ITabBox) model;
+
+ if (DeviceUtility.isMobileOrTabletDevice() && acceptMobileTabBoxTransformation(formField)) {
+ field = new RwtScoutMobileTabBox();
+ }
+ else {
+ field = new RwtScoutTabBox();
+ }
+
+ field.createUiField(parent, formField, uiEnvironment);
+
+ return field;
+ }
+
+ private boolean acceptMobileTabBoxTransformation(final ITabBox tabBox) {
+ final BooleanHolder accepted = new BooleanHolder(false);
+ ClientSyncJob job = new ClientSyncJob("Getting permission to create mobile tabbox.", m_uiEnvironment.getClientSession()) {
+
+ @Override
+ protected void runVoid(IProgressMonitor monitor) throws Throwable {
+ accepted.setValue(SERVICES.getService(IDeviceTransformationService.class).getDeviceTransformer().acceptMobileTabBoxTransformation(tabBox));
+ }
+
+ };
+ job.schedule();
+ try {
+ job.join(5000);
+ }
+ catch (InterruptedException e) {
+ LOG.warn("Failed to getting permission to create mobile tabbox.", e);
+ }
+
+ return accepted.getValue();
+
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tabbox/RwtScoutMobileTabBox.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tabbox/RwtScoutMobileTabBox.java
index d17d37ac1a..a56c89e3de 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tabbox/RwtScoutMobileTabBox.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tabbox/RwtScoutMobileTabBox.java
@@ -1,73 +1,73 @@
-/*******************************************************************************
- * Copyright (c) 2011 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tabbox;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.scout.commons.holders.Holder;
-import org.eclipse.scout.commons.logger.IScoutLogger;
-import org.eclipse.scout.commons.logger.ScoutLogManager;
-import org.eclipse.scout.rt.client.ClientSyncJob;
-import org.eclipse.scout.rt.client.mobile.ui.form.fields.tabbox.TabBoxGroupBox;
-import org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox;
-import org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox;
-import org.eclipse.scout.rt.ui.rap.LogicalGridLayout;
-import org.eclipse.scout.rt.ui.rap.form.fields.IRwtScoutFormField;
-import org.eclipse.scout.rt.ui.rap.form.fields.RwtScoutFieldComposite;
-import org.eclipse.scout.rt.ui.rap.form.fields.tabbox.IRwtScoutTabBox;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-
-public class RwtScoutMobileTabBox extends RwtScoutFieldComposite<ITabBox> implements IRwtScoutTabBox {
- private static final IScoutLogger LOG = ScoutLogManager.getLogger(RwtScoutMobileTabBox.class);
-
- @Override
- protected void initializeUi(Composite parent) {
- Composite container = getUiEnvironment().getFormToolkit().createComposite(parent, SWT.TOP);
- container.setLayout(new LogicalGridLayout(0, 0));
-
- IGroupBox groupBox = wrapTabBox();
- IRwtScoutFormField group = getUiEnvironment().createFormField(container, groupBox);
-
- setUiLabel(null);
- setUiField(group.getUiContainer());
- setUiContainer(container);
- }
-
- private IGroupBox wrapTabBox() {
- final Holder<IGroupBox> holder = new Holder<IGroupBox>(IGroupBox.class);
-
- ClientSyncJob job = new ClientSyncJob("", getUiEnvironment().getClientSession()) {
- @Override
- protected void runVoid(IProgressMonitor monitor) throws Throwable {
- TabBoxGroupBox groupBox = new TabBoxGroupBox(getScoutObject());
- groupBox.initField();
-
- holder.setValue(groupBox);
- }
- };
-
- job.schedule();
- try {
- job.join();
- }
- catch (InterruptedException e) {
- LOG.error("TabBox wrapping interrupted. ", e);
- }
-
- return holder.getValue();
- }
-
- @Override
- protected void setEnabledFromScout(boolean b) {
- // void here
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2011 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tabbox;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.scout.commons.holders.Holder;
+import org.eclipse.scout.commons.logger.IScoutLogger;
+import org.eclipse.scout.commons.logger.ScoutLogManager;
+import org.eclipse.scout.rt.client.ClientSyncJob;
+import org.eclipse.scout.rt.client.mobile.ui.form.fields.tabbox.TabBoxGroupBox;
+import org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox;
+import org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox;
+import org.eclipse.scout.rt.ui.rap.LogicalGridLayout;
+import org.eclipse.scout.rt.ui.rap.form.fields.IRwtScoutFormField;
+import org.eclipse.scout.rt.ui.rap.form.fields.RwtScoutFieldComposite;
+import org.eclipse.scout.rt.ui.rap.form.fields.tabbox.IRwtScoutTabBox;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+public class RwtScoutMobileTabBox extends RwtScoutFieldComposite<ITabBox> implements IRwtScoutTabBox {
+ private static final IScoutLogger LOG = ScoutLogManager.getLogger(RwtScoutMobileTabBox.class);
+
+ @Override
+ protected void initializeUi(Composite parent) {
+ Composite container = getUiEnvironment().getFormToolkit().createComposite(parent, SWT.TOP);
+ container.setLayout(new LogicalGridLayout(0, 0));
+
+ IGroupBox groupBox = wrapTabBox();
+ IRwtScoutFormField group = getUiEnvironment().createFormField(container, groupBox);
+
+ setUiLabel(null);
+ setUiField(group.getUiContainer());
+ setUiContainer(container);
+ }
+
+ private IGroupBox wrapTabBox() {
+ final Holder<IGroupBox> holder = new Holder<IGroupBox>(IGroupBox.class);
+
+ ClientSyncJob job = new ClientSyncJob("", getUiEnvironment().getClientSession()) {
+ @Override
+ protected void runVoid(IProgressMonitor monitor) throws Throwable {
+ TabBoxGroupBox groupBox = new TabBoxGroupBox(getScoutObject());
+ groupBox.initField();
+
+ holder.setValue(groupBox);
+ }
+ };
+
+ job.schedule();
+ try {
+ job.join();
+ }
+ catch (InterruptedException e) {
+ LOG.error("TabBox wrapping interrupted. ", e);
+ }
+
+ return holder.getValue();
+ }
+
+ @Override
+ protected void setEnabledFromScout(boolean b) {
+ // void here
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/IRwtScoutList.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/IRwtScoutList.java
index 63ddcd230d..138b431918 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/IRwtScoutList.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/IRwtScoutList.java
@@ -1,21 +1,21 @@
-/*******************************************************************************
- * Copyright (c) 2011 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
-
-import org.eclipse.jface.viewers.ListViewer;
-import org.eclipse.scout.rt.ui.rap.basic.table.IRwtScoutTable;
-
-public interface IRwtScoutList extends IRwtScoutTable {
-
- @Override
- ListViewer getUiTableViewer();
-
-}
+/*******************************************************************************
+ * Copyright (c) 2011 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
+
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.scout.rt.ui.rap.basic.table.IRwtScoutTable;
+
+public interface IRwtScoutList extends IRwtScoutTable {
+
+ @Override
+ ListViewer getUiTableViewer();
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/IRwtScoutListModel.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/IRwtScoutListModel.java
index 079dcc4e4d..e61d4faf35 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/IRwtScoutListModel.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/IRwtScoutListModel.java
@@ -1,26 +1,26 @@
-/*******************************************************************************
- * Copyright (c) 2011 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.scout.rt.ui.rap.basic.table.RwtScoutTableEvent;
-
-public interface IRwtScoutListModel extends IStructuredContentProvider, ILabelProvider {
-
- void setMultiline(boolean multiline);
-
- boolean isMultiline();
-
- void consumeTableModelEvent(RwtScoutTableEvent uiTableEvent);
-
- IRwtScoutList getRwtScoutList();
-}
+/*******************************************************************************
+ * Copyright (c) 2011 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.scout.rt.ui.rap.basic.table.RwtScoutTableEvent;
+
+public interface IRwtScoutListModel extends IStructuredContentProvider, ILabelProvider {
+
+ void setMultiline(boolean multiline);
+
+ boolean isMultiline();
+
+ void consumeTableModelEvent(RwtScoutTableEvent uiTableEvent);
+
+ IRwtScoutList getRwtScoutList();
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/ListEx.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/ListEx.java
index 74841796e7..6bca648739 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/ListEx.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/ListEx.java
@@ -1,49 +1,49 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.List;
-
-public class ListEx extends List {
-
- private static final long serialVersionUID = 1L;
-
- public ListEx(Composite parent, int style) {
- super(parent, style);
- }
-
- @SuppressWarnings("null")
- public String getItem(Point point) {
- checkWidget();
- if (point == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- String result = null;
- Rectangle itemArea = getClientArea();
- if (itemArea.contains(point)) {
- int itemHeight = getItemHeight();
- int index = (point.y / itemHeight) - 1;
- if (point.y % itemHeight != 0) {
- index++;
- }
- index += getTopIndex();
- if (index >= 0 && index < getItemCount()) {
- result = getItem(index);
- }
- }
- return result;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.List;
+
+public class ListEx extends List {
+
+ private static final long serialVersionUID = 1L;
+
+ public ListEx(Composite parent, int style) {
+ super(parent, style);
+ }
+
+ @SuppressWarnings("null")
+ public String getItem(Point point) {
+ checkWidget();
+ if (point == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ String result = null;
+ Rectangle itemArea = getClientArea();
+ if (itemArea.contains(point)) {
+ int itemHeight = getItemHeight();
+ int index = (point.y / itemHeight) - 1;
+ if (point.y % itemHeight != 0) {
+ index++;
+ }
+ index += getTopIndex();
+ if (index >= 0 && index < getItemCount()) {
+ result = getItem(index);
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/MobileTableFieldFactory.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/MobileTableFieldFactory.java
index 019843f7fe..1a081e81ae 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/MobileTableFieldFactory.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/MobileTableFieldFactory.java
@@ -1,45 +1,45 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
-
-import org.eclipse.scout.rt.client.ui.form.fields.IFormField;
-import org.eclipse.scout.rt.client.ui.form.fields.tablefield.ITableField;
-import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
-import org.eclipse.scout.rt.ui.rap.extension.IFormFieldFactory;
-import org.eclipse.scout.rt.ui.rap.form.fields.IRwtScoutFormField;
-import org.eclipse.scout.rt.ui.rap.form.fields.tablefield.IRwtScoutTableField;
-import org.eclipse.scout.rt.ui.rap.form.fields.tablefield.RwtScoutTableField;
-import org.eclipse.scout.rt.ui.rap.util.DeviceUtility;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 3.9.0
- */
-public class MobileTableFieldFactory implements IFormFieldFactory {
-
- @Override
- public IRwtScoutFormField<?> createUiFormField(Composite parent, IFormField model, IRwtEnvironment uiEnvironment) {
- IRwtScoutTableField field;
-
- if (DeviceUtility.isMobileOrTabletDevice()) {
- field = new RwtScoutMobileTableField();
- }
- else {
- field = new RwtScoutTableField();
- }
-
- ITableField<?> tableField = (ITableField) model;
- field.createUiField(parent, tableField, uiEnvironment);
-
- return field;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
+
+import org.eclipse.scout.rt.client.ui.form.fields.IFormField;
+import org.eclipse.scout.rt.client.ui.form.fields.tablefield.ITableField;
+import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
+import org.eclipse.scout.rt.ui.rap.extension.IFormFieldFactory;
+import org.eclipse.scout.rt.ui.rap.form.fields.IRwtScoutFormField;
+import org.eclipse.scout.rt.ui.rap.form.fields.tablefield.IRwtScoutTableField;
+import org.eclipse.scout.rt.ui.rap.form.fields.tablefield.RwtScoutTableField;
+import org.eclipse.scout.rt.ui.rap.util.DeviceUtility;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 3.9.0
+ */
+public class MobileTableFieldFactory implements IFormFieldFactory {
+
+ @Override
+ public IRwtScoutFormField<?> createUiFormField(Composite parent, IFormField model, IRwtEnvironment uiEnvironment) {
+ IRwtScoutTableField field;
+
+ if (DeviceUtility.isMobileOrTabletDevice()) {
+ field = new RwtScoutMobileTableField();
+ }
+ else {
+ field = new RwtScoutTableField();
+ }
+
+ ITableField<?> tableField = (ITableField) model;
+ field.createUiField(parent, tableField, uiEnvironment);
+
+ return field;
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtMobileTableStatus.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtMobileTableStatus.java
index aa8d1a7b4a..06dffeec54 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtMobileTableStatus.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtMobileTableStatus.java
@@ -1,42 +1,42 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
-
-import org.eclipse.scout.rt.client.mobile.ui.form.outline.IMainPageForm;
-import org.eclipse.scout.rt.client.ui.form.IForm;
-import org.eclipse.scout.rt.client.ui.form.fields.tablefield.ITableField;
-import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
-import org.eclipse.scout.rt.ui.rap.form.fields.tablefield.RwtTableStatus;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-
-public class RwtMobileTableStatus extends RwtTableStatus {
-
- public RwtMobileTableStatus(Composite parent, IRwtEnvironment uiEnvironment, ITableField<?> model) {
- super(parent, uiEnvironment, model);
- }
-
- @Override
- protected String getVariant(ITableField<?> table) {
- IForm form = table.getForm();
- if (form instanceof IMainPageForm) {
- return VARIANT_OUTLINE_TABLE_STATUS;
- }
-
- return super.getVariant(table);
- }
-
- @Override
- protected int getLabelHorizontalAlignment() {
- return SWT.CENTER;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
+
+import org.eclipse.scout.rt.client.mobile.ui.form.outline.IMainPageForm;
+import org.eclipse.scout.rt.client.ui.form.IForm;
+import org.eclipse.scout.rt.client.ui.form.fields.tablefield.ITableField;
+import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
+import org.eclipse.scout.rt.ui.rap.form.fields.tablefield.RwtTableStatus;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+public class RwtMobileTableStatus extends RwtTableStatus {
+
+ public RwtMobileTableStatus(Composite parent, IRwtEnvironment uiEnvironment, ITableField<?> model) {
+ super(parent, uiEnvironment, model);
+ }
+
+ @Override
+ protected String getVariant(ITableField<?> table) {
+ IForm form = table.getForm();
+ if (form instanceof IMainPageForm) {
+ return VARIANT_OUTLINE_TABLE_STATUS;
+ }
+
+ return super.getVariant(table);
+ }
+
+ @Override
+ protected int getLabelHorizontalAlignment() {
+ return SWT.CENTER;
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutList.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutList.java
index ca194e5ac0..f9a52ac669 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutList.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutList.java
@@ -1,611 +1,611 @@
-/*******************************************************************************
- * Copyright (c) 2011 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.TreeSet;
-
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ListViewer;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.rwt.RWT;
-import org.eclipse.rwt.lifecycle.WidgetUtil;
-import org.eclipse.scout.commons.CompareUtility;
-import org.eclipse.scout.commons.StringUtility;
-import org.eclipse.scout.rt.client.ui.IEventHistory;
-import org.eclipse.scout.rt.client.ui.basic.table.ITable;
-import org.eclipse.scout.rt.client.ui.basic.table.ITableRow;
-import org.eclipse.scout.rt.client.ui.basic.table.RowIndexComparator;
-import org.eclipse.scout.rt.client.ui.basic.table.TableEvent;
-import org.eclipse.scout.rt.client.ui.basic.table.TableListener;
-import org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn;
-import org.eclipse.scout.rt.ui.rap.basic.RwtScoutComposite;
-import org.eclipse.scout.rt.ui.rap.basic.table.RwtScoutTable;
-import org.eclipse.scout.rt.ui.rap.basic.table.RwtScoutTableEvent;
-import org.eclipse.scout.rt.ui.rap.keystroke.RwtKeyStroke;
-import org.eclipse.scout.rt.ui.rap.util.RwtUtility;
-import org.eclipse.scout.rt.ui.rap.util.UiRedrawHandler;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.HyperlinkEvent;
-import org.eclipse.swt.events.HyperlinkListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.internal.widgets.MarkupValidator;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.TableItem;
-
-/**
- * List with basic functionalities which processes a {@link ITable} but only the first column.<br/>
- * Compared to {@link RwtScoutTable} there are a lot of missing features:
- * <ul>
- * <li>It's not possible to display images, nor changing the font or color as jface list does not support it</li>
- * <li>There is no keyboard navigation support</li>
- * <li>There is no drag and drop support</li>
- * <li>There are no header menus nor context menus displayed</li>
- * <li>It cannot handle a lot of rows.</li>
- * </ul>
- * One essential difference to the table widget is that scrolling works better. On tables scrolling is done row by row
- * as only the displayed rows are rendered. On a list widget every row is rendered at beginning which makes scrolling
- * smoother. That's why it is the preferred widget on touch devices.
- */
-@SuppressWarnings("restriction")
-public class RwtScoutList extends RwtScoutComposite<ITable> implements IRwtScoutList {
- private P_ScoutTableListener m_scoutTableListener;
- private UiRedrawHandler m_redrawHandler;
- private ListViewer m_uiViewer;
- private String m_variant = "";
-
- public RwtScoutList() {
- }
-
- public RwtScoutList(String variant) {
- m_variant = variant;
- }
-
- @Override
- protected void initializeUi(Composite parent) {
- m_redrawHandler = new UiRedrawHandler(parent);
- int style;
- if (getScoutObject() != null && getScoutObject().isMultiSelect()) {
- style = SWT.MULTI;
- }
- else {
- style = SWT.SINGLE;
- }
- style |= SWT.V_SCROLL;
- ListEx list = new ListEx(parent, style);
-
- if (StringUtility.hasText(m_variant)) {
- list.setData(WidgetUtil.CUSTOM_VARIANT, m_variant);
- }
- list.setData(RWT.MARKUP_ENABLED, Boolean.TRUE);
- list.setData(MarkupValidator.MARKUP_VALIDATION_DISABLED, Boolean.TRUE);
-
- ListViewer viewer = new ListViewer(list);
- viewer.setUseHashlookup(true);
- setUiTableViewer(viewer);
- setUiField(list);
-
- RwtScoutListModel listModel = createUiListModel();
- listModel.setMultiline(getScoutObject().isMultilineText());
- viewer.setContentProvider(listModel);
- viewer.setLabelProvider(listModel);
- viewer.setInput(listModel);
-
- // ui listeners
- viewer.addSelectionChangedListener(new P_RwtSelectionListener());
- P_RwtTableListener rwtTableListener = new P_RwtTableListener();
- list.addListener(SWT.MouseUp, rwtTableListener);
- list.addListener(SWT.MouseDoubleClick, rwtTableListener);
-
- //HyperlinkListener is not part of the official rap api so this line might generate compile errors
- //See https://bugs.eclipse.org/bugs/show_bug.cgi?id=347436
- list.addHyperlinkListener(new P_RwtHyperlinkListener());
-
- getUiEnvironment().addKeyStroke(list, new RwtKeyStroke((int) ' ') {
-
- @Override
- public void handleUiAction(Event e) {
- handleUiToggleAcction(e);
- }
- }, false);
-
- }
-
- @Override
- public boolean isUiDisposed() {
- return getUiField() == null || getUiField().isDisposed();
- }
-
- protected RwtScoutListModel createUiListModel() {
- return new RwtScoutListModel(getScoutObject(), this);
- }
-
- @Override
- protected void attachScout() {
- super.attachScout();
-
- if (getScoutObject() == null) {
- return;
- }
-
- if (m_scoutTableListener == null) {
- m_scoutTableListener = new P_ScoutTableListener();
- getScoutObject().addUITableListener(m_scoutTableListener);
- }
- setHeaderVisibleFromScout(getScoutObject().isHeaderVisible());
- setSelectionFromScout(getScoutObject().getSelectedRows());
- setRowHeightFromScout();
-
- //handle events from recent history
- final IEventHistory<TableEvent> h = getScoutObject().getEventHistory();
- if (h != null) {
- getUiEnvironment().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- for (TableEvent e : h.getRecentEvents()) {
- handleScoutTableEventInUi(e);
- }
- }
- });
- }
- }
-
- @Override
- protected void detachScout() {
- super.detachScout();
-
- if (getScoutObject() == null) {
- return;
- }
-
- if (m_scoutTableListener != null) {
- getScoutObject().removeTableListener(m_scoutTableListener);
- m_scoutTableListener = null;
- }
- }
-
- @Override
- public ListEx getUiField() {
- return (ListEx) super.getUiField();
- }
-
- @Override
- public ListViewer getUiTableViewer() {
- return m_uiViewer;
- }
-
- public void setUiTableViewer(ListViewer uiViewer) {
- m_uiViewer = uiViewer;
- }
-
- public ITableRow getUiSelectedRow() {
- ITableRow[] rows = getUiSelectedRows();
- if (rows.length > 0) {
- return rows[0];
- }
- return null;
- }
-
- public ITableRow[] getUiSelectedRows() {
- StructuredSelection uiSelection = (StructuredSelection) getUiTableViewer().getSelection();
- TreeSet<ITableRow> sortedRows = new TreeSet<ITableRow>(new RowIndexComparator());
- if (uiSelection != null && !uiSelection.isEmpty()) {
- for (Object o : uiSelection.toArray()) {
- ITableRow row = (ITableRow) o;
- sortedRows.add(row);
- }
- }
- return sortedRows.toArray(new ITableRow[sortedRows.size()]);
- }
-
- protected void setRowHeightFromScout() {
- int h = getScoutObject().getRowHeightHint();
- if (h <= 0 && getScoutObject().isMultilineText()) {
- h = 40; // Enough for 2 lines fully visible (further lines are cut off) --> cannot be dynamic at the moment, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=346768
- }
- if (h >= 0) {
- getUiField().setData(RWT.CUSTOM_ITEM_HEIGHT, h);
- }
- if (isCreated()) {
- getUiTableViewer().refresh();
- }
- }
-
- /**
- * scout property observer
- */
- @Override
- protected void handleScoutPropertyChange(String propName, Object newValue) {
- if (propName.equals(ITable.PROP_HEADER_VISIBLE)) {
- setHeaderVisibleFromScout(((Boolean) newValue).booleanValue());
- }
- else if (propName.equals(ITable.PROP_ROW_HEIGHT_HINT)) {
- setRowHeightFromScout();
- }
- else if (propName.equals(ITable.PROP_SCROLL_TO_SELECTION)) {
- updateScrollToSelectionFromScout();
- }
- }
-
- /**
- * scout table observer
- */
- protected boolean isHandleScoutTableEvent(TableEvent[] a) {
- for (TableEvent element : a) {
- switch (element.getType()) {
- case TableEvent.TYPE_REQUEST_FOCUS:
- case TableEvent.TYPE_REQUEST_FOCUS_IN_CELL:
- case TableEvent.TYPE_ROWS_INSERTED:
- case TableEvent.TYPE_ROWS_UPDATED:
- case TableEvent.TYPE_ROWS_DELETED:
- case TableEvent.TYPE_ALL_ROWS_DELETED:
- case TableEvent.TYPE_ROW_ORDER_CHANGED:
- case TableEvent.TYPE_ROW_FILTER_CHANGED:
- case TableEvent.TYPE_COLUMN_ORDER_CHANGED:
- case TableEvent.TYPE_COLUMN_HEADERS_UPDATED:
- case TableEvent.TYPE_COLUMN_STRUCTURE_CHANGED:
- case TableEvent.TYPE_ROWS_SELECTED:
- case TableEvent.TYPE_SCROLL_TO_SELECTION: {
- return true;
- }
- }
- }
- return false;
- }
-
- protected void handleScoutTableEventInUi(TableEvent e) {
- if (isUiDisposed()) {
- return;
- }
- RwtScoutTableEvent uiTableEvent = null;
- /*
- * check the scout observer to filter all events that are used here
- * @see isHandleScoutTableEvent()
- */
- switch (e.getType()) {
- case TableEvent.TYPE_REQUEST_FOCUS: {
- getUiField().setFocus();
- break;
- }
- case TableEvent.TYPE_SCROLL_TO_SELECTION: {
- scrollToSelection();
- break;
- }
- case TableEvent.TYPE_ROWS_INSERTED:
- case TableEvent.TYPE_ROWS_UPDATED:
- case TableEvent.TYPE_ROWS_DELETED:
- case TableEvent.TYPE_ALL_ROWS_DELETED:
- case TableEvent.TYPE_ROW_FILTER_CHANGED:
- case TableEvent.TYPE_ROW_ORDER_CHANGED: {
- uiTableEvent = new RwtScoutTableEvent();
- break;
- }
- case TableEvent.TYPE_ROWS_SELECTED: {
- setSelectionFromScout(e.getRows());
- break;
- }
- }
- //
- if (uiTableEvent != null) {
- ((RwtScoutListModel) getUiTableViewer().getContentProvider()).consumeTableModelEvent(uiTableEvent);
- getUiTableViewer().refresh();
- }
- // refresh selection, indexes might have changed
- switch (e.getType()) {
- case TableEvent.TYPE_ROW_FILTER_CHANGED:
- setSelectionFromScout(e.getTable().getSelectedRows());
- break;
- case TableEvent.TYPE_ROWS_INSERTED:
- case TableEvent.TYPE_ROWS_UPDATED:
- case TableEvent.TYPE_ROWS_DELETED:
- case TableEvent.TYPE_ALL_ROWS_DELETED:
- case TableEvent.TYPE_ROW_ORDER_CHANGED: {
- setSelectionFromScout(e.getTable().getSelectedRows());
- break;
- }
- }
- }
-
- protected void setHeaderVisibleFromScout(boolean headerVisible) {
- //FIXME CGU create header to allow sorting
-// getUiField().setHeaderVisible(headerVisible);
- }
-
- @Override
- public void setEnabledFromScout(boolean enabledFromScout) {
- getUiField().setEnabled(enabledFromScout);
- }
-
- protected void setSelectionFromScout(ITableRow[] selectedRows) {
- if (getUiField().isDisposed()) {
- return;
- }
- ITableRow[] uiSelection = getUiSelectedRows();
- if (CompareUtility.equals(uiSelection, selectedRows)) {
- // no change
- return;
- }
- else {
- if (selectedRows == null) {
- selectedRows = new ITableRow[0];
- }
- getUiTableViewer().setSelection(new StructuredSelection(selectedRows), true);
- updateScrollToSelectionFromScout();
- }
- }
-
- private void updateScrollToSelectionFromScout() {
- if (getScoutObject().isScrollToSelection()) {
- scrollToSelection();
- }
- }
-
- protected void scrollToSelection() {
- if (getUiField() != null && !getUiField().isDisposed()) {
- getUiField().showSelection();
- }
- }
-
- protected void setContextColumnFromUi() {
- if (getScoutObject() == null) {
- return;
- }
-
- // notify Scout
- final IColumn finalCol = getScoutObject().getColumnSet().getVisibleColumn(0);
- Runnable t = new Runnable() {
- @Override
- public void run() {
- getScoutObject().getUIFacade().setContextColumnFromUI(finalCol);
- }
- };
- getUiEnvironment().invokeScoutLater(t, 0);
- // end notify
- }
-
- private int getVisualCellIndex(TableItem tableItem, int columnIndex) {
- int visualCellIndex = columnIndex;
- final int[] columnOrder = tableItem.getParent().getColumnOrder();
- for (int element : columnOrder) {
- if (element == columnIndex) {
- visualCellIndex = columnIndex;
- }
- }
- return visualCellIndex;
- }
-
- protected void setSelectionFromUi(final StructuredSelection selection) {
- if (getUpdateUiFromScoutLock().isAcquired()) {
- return;
- }
- //
- if (getScoutObject() != null) {
- // notify Scout
- Runnable t = new Runnable() {
- @Override
- public void run() {
- try {
- addIgnoredScoutEvent(TableEvent.class, "" + TableEvent.TYPE_ROWS_SELECTED);
- //
- getScoutObject().getUIFacade().setSelectedRowsFromUI(RwtUtility.getItemsOfSelection(ITableRow.class, selection));
- }
- finally {
- removeIgnoredScoutEvent(TableEvent.class, "" + TableEvent.TYPE_ROWS_SELECTED);
- }
- }
- };
- getUiEnvironment().invokeScoutLater(t, 0);
- // end notify
- }
- }
-
- protected void handleUiRowClick(final ITableRow row) {
- if (getScoutObject() != null) {
- if (row != null) {
- // notify Scout
- Runnable t = new Runnable() {
- @Override
- public void run() {
- getScoutObject().getUIFacade().fireRowClickFromUI(row);
- }
- };
- getUiEnvironment().invokeScoutLater(t, 0);
- // end notify
- }
- }
- }
-
- protected void handleUiRowAction(final ITableRow row) {
- if (getScoutObject() != null) {
- if (!getScoutObject().isCheckable() && row != null) {
- // notify Scout
- Runnable t = new Runnable() {
- @Override
- public void run() {
- getScoutObject().getUIFacade().fireRowActionFromUI(row);
- }
- };
- getUiEnvironment().invokeScoutLater(t, 0);
- // end notify
- }
- }
- }
-
- protected void handleUiHyperlinkAction(String urlText) {
- if (getScoutObject() != null) {
- final URL url;
- try {
- url = new URL(urlText);
- }
- catch (MalformedURLException e) {
- //nop
- return;
- }
- // notify Scout
- Runnable t = new Runnable() {
- @Override
- public void run() {
- ITable table = getScoutObject();
- table.getUIFacade().fireHyperlinkActionFromUI(table.getSelectedRow(), table.getContextColumn(), url);
- }
- };
- getUiEnvironment().invokeScoutLater(t, 0);
- // end notify
- }
- }
-
- protected void handleUiToggleAcction(Event e) {
- if (e.doit && getScoutObject().isCheckable()) {
- if (e.stateMask == 0) {
- switch (e.keyCode) {
- case ' ':
- ITableRow[] selectedRows = RwtUtility.getItemsOfSelection(ITableRow.class, (StructuredSelection) getUiTableViewer().getSelection());
- if (selectedRows != null && selectedRows.length > 0) {
- handleUiRowClick(selectedRows[0]);
- }
- e.doit = false;
- break;
- }
- }
- }
- }
-
- private class P_ScoutTableListener implements TableListener {
- @Override
- public void tableChanged(final TableEvent e) {
- if (isHandleScoutTableEvent(new TableEvent[]{e})) {
- if (isIgnoredScoutEvent(TableEvent.class, "" + e.getType())) {
- return;
- }
- Runnable t = new Runnable() {
- @Override
- public void run() {
- try {
- getUpdateUiFromScoutLock().acquire();
- //
- handleScoutTableEventInUi(e);
- }
- finally {
- getUpdateUiFromScoutLock().release();
- }
- }
- };
- getUiEnvironment().invokeUiLater(t);
- }
- }
-
- @Override
- public void tableChangedBatch(final TableEvent[] a) {
- if (isHandleScoutTableEvent(a)) {
- final ArrayList<TableEvent> filteredList = new ArrayList<TableEvent>();
- for (int i = 0; i < a.length; i++) {
- if (!isIgnoredScoutEvent(TableEvent.class, "" + a[i].getType())) {
- filteredList.add(a[i]);
- }
- }
- if (filteredList.size() == 0) {
- return;
- }
- Runnable t = new Runnable() {
- @Override
- public void run() {
- if (isUiDisposed()) {
- return;
- }
- m_redrawHandler.pushControlChanging();
- try {
- try {
- getUpdateUiFromScoutLock().acquire();
- //
- for (TableEvent element : filteredList) {
- handleScoutTableEventInUi(element);
- }
- }
- finally {
- getUpdateUiFromScoutLock().release();
- }
- }
- finally {
- m_redrawHandler.popControlChanging();
- }
- }
- };
- getUiEnvironment().invokeUiLater(t);
- }
- }
- }
-
- private class P_RwtTableListener implements Listener {
- private static final long serialVersionUID = 1L;
-
- private Boolean m_doubleClicked = Boolean.FALSE;
-
- @Override
- public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.MouseUp: {
- setContextColumnFromUi();
-
- synchronized (m_doubleClicked) {
- if (m_doubleClicked == Boolean.TRUE) {
- m_doubleClicked = Boolean.FALSE;
- break;
- }
- }
- Point eventPosition = new Point(event.x, event.y);
- if (getUiField().getItem(eventPosition) == null) {
- getUiTableViewer().setSelection(null);
- setSelectionFromUi(new StructuredSelection());
- }
- else {
- StructuredSelection selection = (StructuredSelection) getUiTableViewer().getSelection();
- if (selection != null && selection.size() == 1) {
- handleUiRowClick((ITableRow) selection.getFirstElement());
- }
- }
- break;
- }
- case SWT.MouseDoubleClick: {
- synchronized (m_doubleClicked) {
- m_doubleClicked = Boolean.TRUE;
- }
- StructuredSelection selection = (StructuredSelection) getUiTableViewer().getSelection();
- if (selection != null && selection.size() == 1) {
- handleUiRowAction((ITableRow) selection.getFirstElement());
- }
- break;
- }
- }
- }
- }
-
- public class P_RwtSelectionListener implements ISelectionChangedListener {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- setSelectionFromUi((StructuredSelection) event.getSelection());
- }
- }
-
- public class P_RwtHyperlinkListener implements HyperlinkListener {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void activated(HyperlinkEvent event) {
- handleUiHyperlinkAction(event.url);
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2011 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.TreeSet;
+
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.rwt.RWT;
+import org.eclipse.rwt.lifecycle.WidgetUtil;
+import org.eclipse.scout.commons.CompareUtility;
+import org.eclipse.scout.commons.StringUtility;
+import org.eclipse.scout.rt.client.ui.IEventHistory;
+import org.eclipse.scout.rt.client.ui.basic.table.ITable;
+import org.eclipse.scout.rt.client.ui.basic.table.ITableRow;
+import org.eclipse.scout.rt.client.ui.basic.table.RowIndexComparator;
+import org.eclipse.scout.rt.client.ui.basic.table.TableEvent;
+import org.eclipse.scout.rt.client.ui.basic.table.TableListener;
+import org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn;
+import org.eclipse.scout.rt.ui.rap.basic.RwtScoutComposite;
+import org.eclipse.scout.rt.ui.rap.basic.table.RwtScoutTable;
+import org.eclipse.scout.rt.ui.rap.basic.table.RwtScoutTableEvent;
+import org.eclipse.scout.rt.ui.rap.keystroke.RwtKeyStroke;
+import org.eclipse.scout.rt.ui.rap.util.RwtUtility;
+import org.eclipse.scout.rt.ui.rap.util.UiRedrawHandler;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.HyperlinkEvent;
+import org.eclipse.swt.events.HyperlinkListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.internal.widgets.MarkupValidator;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.TableItem;
+
+/**
+ * List with basic functionalities which processes a {@link ITable} but only the first column.<br/>
+ * Compared to {@link RwtScoutTable} there are a lot of missing features:
+ * <ul>
+ * <li>It's not possible to display images, nor changing the font or color as jface list does not support it</li>
+ * <li>There is no keyboard navigation support</li>
+ * <li>There is no drag and drop support</li>
+ * <li>There are no header menus nor context menus displayed</li>
+ * <li>It cannot handle a lot of rows.</li>
+ * </ul>
+ * One essential difference to the table widget is that scrolling works better. On tables scrolling is done row by row
+ * as only the displayed rows are rendered. On a list widget every row is rendered at beginning which makes scrolling
+ * smoother. That's why it is the preferred widget on touch devices.
+ */
+@SuppressWarnings("restriction")
+public class RwtScoutList extends RwtScoutComposite<ITable> implements IRwtScoutList {
+ private P_ScoutTableListener m_scoutTableListener;
+ private UiRedrawHandler m_redrawHandler;
+ private ListViewer m_uiViewer;
+ private String m_variant = "";
+
+ public RwtScoutList() {
+ }
+
+ public RwtScoutList(String variant) {
+ m_variant = variant;
+ }
+
+ @Override
+ protected void initializeUi(Composite parent) {
+ m_redrawHandler = new UiRedrawHandler(parent);
+ int style;
+ if (getScoutObject() != null && getScoutObject().isMultiSelect()) {
+ style = SWT.MULTI;
+ }
+ else {
+ style = SWT.SINGLE;
+ }
+ style |= SWT.V_SCROLL;
+ ListEx list = new ListEx(parent, style);
+
+ if (StringUtility.hasText(m_variant)) {
+ list.setData(WidgetUtil.CUSTOM_VARIANT, m_variant);
+ }
+ list.setData(RWT.MARKUP_ENABLED, Boolean.TRUE);
+ list.setData(MarkupValidator.MARKUP_VALIDATION_DISABLED, Boolean.TRUE);
+
+ ListViewer viewer = new ListViewer(list);
+ viewer.setUseHashlookup(true);
+ setUiTableViewer(viewer);
+ setUiField(list);
+
+ RwtScoutListModel listModel = createUiListModel();
+ listModel.setMultiline(getScoutObject().isMultilineText());
+ viewer.setContentProvider(listModel);
+ viewer.setLabelProvider(listModel);
+ viewer.setInput(listModel);
+
+ // ui listeners
+ viewer.addSelectionChangedListener(new P_RwtSelectionListener());
+ P_RwtTableListener rwtTableListener = new P_RwtTableListener();
+ list.addListener(SWT.MouseUp, rwtTableListener);
+ list.addListener(SWT.MouseDoubleClick, rwtTableListener);
+
+ //HyperlinkListener is not part of the official rap api so this line might generate compile errors
+ //See https://bugs.eclipse.org/bugs/show_bug.cgi?id=347436
+ list.addHyperlinkListener(new P_RwtHyperlinkListener());
+
+ getUiEnvironment().addKeyStroke(list, new RwtKeyStroke((int) ' ') {
+
+ @Override
+ public void handleUiAction(Event e) {
+ handleUiToggleAcction(e);
+ }
+ }, false);
+
+ }
+
+ @Override
+ public boolean isUiDisposed() {
+ return getUiField() == null || getUiField().isDisposed();
+ }
+
+ protected RwtScoutListModel createUiListModel() {
+ return new RwtScoutListModel(getScoutObject(), this);
+ }
+
+ @Override
+ protected void attachScout() {
+ super.attachScout();
+
+ if (getScoutObject() == null) {
+ return;
+ }
+
+ if (m_scoutTableListener == null) {
+ m_scoutTableListener = new P_ScoutTableListener();
+ getScoutObject().addUITableListener(m_scoutTableListener);
+ }
+ setHeaderVisibleFromScout(getScoutObject().isHeaderVisible());
+ setSelectionFromScout(getScoutObject().getSelectedRows());
+ setRowHeightFromScout();
+
+ //handle events from recent history
+ final IEventHistory<TableEvent> h = getScoutObject().getEventHistory();
+ if (h != null) {
+ getUiEnvironment().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ for (TableEvent e : h.getRecentEvents()) {
+ handleScoutTableEventInUi(e);
+ }
+ }
+ });
+ }
+ }
+
+ @Override
+ protected void detachScout() {
+ super.detachScout();
+
+ if (getScoutObject() == null) {
+ return;
+ }
+
+ if (m_scoutTableListener != null) {
+ getScoutObject().removeTableListener(m_scoutTableListener);
+ m_scoutTableListener = null;
+ }
+ }
+
+ @Override
+ public ListEx getUiField() {
+ return (ListEx) super.getUiField();
+ }
+
+ @Override
+ public ListViewer getUiTableViewer() {
+ return m_uiViewer;
+ }
+
+ public void setUiTableViewer(ListViewer uiViewer) {
+ m_uiViewer = uiViewer;
+ }
+
+ public ITableRow getUiSelectedRow() {
+ ITableRow[] rows = getUiSelectedRows();
+ if (rows.length > 0) {
+ return rows[0];
+ }
+ return null;
+ }
+
+ public ITableRow[] getUiSelectedRows() {
+ StructuredSelection uiSelection = (StructuredSelection) getUiTableViewer().getSelection();
+ TreeSet<ITableRow> sortedRows = new TreeSet<ITableRow>(new RowIndexComparator());
+ if (uiSelection != null && !uiSelection.isEmpty()) {
+ for (Object o : uiSelection.toArray()) {
+ ITableRow row = (ITableRow) o;
+ sortedRows.add(row);
+ }
+ }
+ return sortedRows.toArray(new ITableRow[sortedRows.size()]);
+ }
+
+ protected void setRowHeightFromScout() {
+ int h = getScoutObject().getRowHeightHint();
+ if (h <= 0 && getScoutObject().isMultilineText()) {
+ h = 40; // Enough for 2 lines fully visible (further lines are cut off) --> cannot be dynamic at the moment, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=346768
+ }
+ if (h >= 0) {
+ getUiField().setData(RWT.CUSTOM_ITEM_HEIGHT, h);
+ }
+ if (isCreated()) {
+ getUiTableViewer().refresh();
+ }
+ }
+
+ /**
+ * scout property observer
+ */
+ @Override
+ protected void handleScoutPropertyChange(String propName, Object newValue) {
+ if (propName.equals(ITable.PROP_HEADER_VISIBLE)) {
+ setHeaderVisibleFromScout(((Boolean) newValue).booleanValue());
+ }
+ else if (propName.equals(ITable.PROP_ROW_HEIGHT_HINT)) {
+ setRowHeightFromScout();
+ }
+ else if (propName.equals(ITable.PROP_SCROLL_TO_SELECTION)) {
+ updateScrollToSelectionFromScout();
+ }
+ }
+
+ /**
+ * scout table observer
+ */
+ protected boolean isHandleScoutTableEvent(TableEvent[] a) {
+ for (TableEvent element : a) {
+ switch (element.getType()) {
+ case TableEvent.TYPE_REQUEST_FOCUS:
+ case TableEvent.TYPE_REQUEST_FOCUS_IN_CELL:
+ case TableEvent.TYPE_ROWS_INSERTED:
+ case TableEvent.TYPE_ROWS_UPDATED:
+ case TableEvent.TYPE_ROWS_DELETED:
+ case TableEvent.TYPE_ALL_ROWS_DELETED:
+ case TableEvent.TYPE_ROW_ORDER_CHANGED:
+ case TableEvent.TYPE_ROW_FILTER_CHANGED:
+ case TableEvent.TYPE_COLUMN_ORDER_CHANGED:
+ case TableEvent.TYPE_COLUMN_HEADERS_UPDATED:
+ case TableEvent.TYPE_COLUMN_STRUCTURE_CHANGED:
+ case TableEvent.TYPE_ROWS_SELECTED:
+ case TableEvent.TYPE_SCROLL_TO_SELECTION: {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ protected void handleScoutTableEventInUi(TableEvent e) {
+ if (isUiDisposed()) {
+ return;
+ }
+ RwtScoutTableEvent uiTableEvent = null;
+ /*
+ * check the scout observer to filter all events that are used here
+ * @see isHandleScoutTableEvent()
+ */
+ switch (e.getType()) {
+ case TableEvent.TYPE_REQUEST_FOCUS: {
+ getUiField().setFocus();
+ break;
+ }
+ case TableEvent.TYPE_SCROLL_TO_SELECTION: {
+ scrollToSelection();
+ break;
+ }
+ case TableEvent.TYPE_ROWS_INSERTED:
+ case TableEvent.TYPE_ROWS_UPDATED:
+ case TableEvent.TYPE_ROWS_DELETED:
+ case TableEvent.TYPE_ALL_ROWS_DELETED:
+ case TableEvent.TYPE_ROW_FILTER_CHANGED:
+ case TableEvent.TYPE_ROW_ORDER_CHANGED: {
+ uiTableEvent = new RwtScoutTableEvent();
+ break;
+ }
+ case TableEvent.TYPE_ROWS_SELECTED: {
+ setSelectionFromScout(e.getRows());
+ break;
+ }
+ }
+ //
+ if (uiTableEvent != null) {
+ ((RwtScoutListModel) getUiTableViewer().getContentProvider()).consumeTableModelEvent(uiTableEvent);
+ getUiTableViewer().refresh();
+ }
+ // refresh selection, indexes might have changed
+ switch (e.getType()) {
+ case TableEvent.TYPE_ROW_FILTER_CHANGED:
+ setSelectionFromScout(e.getTable().getSelectedRows());
+ break;
+ case TableEvent.TYPE_ROWS_INSERTED:
+ case TableEvent.TYPE_ROWS_UPDATED:
+ case TableEvent.TYPE_ROWS_DELETED:
+ case TableEvent.TYPE_ALL_ROWS_DELETED:
+ case TableEvent.TYPE_ROW_ORDER_CHANGED: {
+ setSelectionFromScout(e.getTable().getSelectedRows());
+ break;
+ }
+ }
+ }
+
+ protected void setHeaderVisibleFromScout(boolean headerVisible) {
+ //FIXME CGU create header to allow sorting
+// getUiField().setHeaderVisible(headerVisible);
+ }
+
+ @Override
+ public void setEnabledFromScout(boolean enabledFromScout) {
+ getUiField().setEnabled(enabledFromScout);
+ }
+
+ protected void setSelectionFromScout(ITableRow[] selectedRows) {
+ if (getUiField().isDisposed()) {
+ return;
+ }
+ ITableRow[] uiSelection = getUiSelectedRows();
+ if (CompareUtility.equals(uiSelection, selectedRows)) {
+ // no change
+ return;
+ }
+ else {
+ if (selectedRows == null) {
+ selectedRows = new ITableRow[0];
+ }
+ getUiTableViewer().setSelection(new StructuredSelection(selectedRows), true);
+ updateScrollToSelectionFromScout();
+ }
+ }
+
+ private void updateScrollToSelectionFromScout() {
+ if (getScoutObject().isScrollToSelection()) {
+ scrollToSelection();
+ }
+ }
+
+ protected void scrollToSelection() {
+ if (getUiField() != null && !getUiField().isDisposed()) {
+ getUiField().showSelection();
+ }
+ }
+
+ protected void setContextColumnFromUi() {
+ if (getScoutObject() == null) {
+ return;
+ }
+
+ // notify Scout
+ final IColumn finalCol = getScoutObject().getColumnSet().getVisibleColumn(0);
+ Runnable t = new Runnable() {
+ @Override
+ public void run() {
+ getScoutObject().getUIFacade().setContextColumnFromUI(finalCol);
+ }
+ };
+ getUiEnvironment().invokeScoutLater(t, 0);
+ // end notify
+ }
+
+ private int getVisualCellIndex(TableItem tableItem, int columnIndex) {
+ int visualCellIndex = columnIndex;
+ final int[] columnOrder = tableItem.getParent().getColumnOrder();
+ for (int element : columnOrder) {
+ if (element == columnIndex) {
+ visualCellIndex = columnIndex;
+ }
+ }
+ return visualCellIndex;
+ }
+
+ protected void setSelectionFromUi(final StructuredSelection selection) {
+ if (getUpdateUiFromScoutLock().isAcquired()) {
+ return;
+ }
+ //
+ if (getScoutObject() != null) {
+ // notify Scout
+ Runnable t = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ addIgnoredScoutEvent(TableEvent.class, "" + TableEvent.TYPE_ROWS_SELECTED);
+ //
+ getScoutObject().getUIFacade().setSelectedRowsFromUI(RwtUtility.getItemsOfSelection(ITableRow.class, selection));
+ }
+ finally {
+ removeIgnoredScoutEvent(TableEvent.class, "" + TableEvent.TYPE_ROWS_SELECTED);
+ }
+ }
+ };
+ getUiEnvironment().invokeScoutLater(t, 0);
+ // end notify
+ }
+ }
+
+ protected void handleUiRowClick(final ITableRow row) {
+ if (getScoutObject() != null) {
+ if (row != null) {
+ // notify Scout
+ Runnable t = new Runnable() {
+ @Override
+ public void run() {
+ getScoutObject().getUIFacade().fireRowClickFromUI(row);
+ }
+ };
+ getUiEnvironment().invokeScoutLater(t, 0);
+ // end notify
+ }
+ }
+ }
+
+ protected void handleUiRowAction(final ITableRow row) {
+ if (getScoutObject() != null) {
+ if (!getScoutObject().isCheckable() && row != null) {
+ // notify Scout
+ Runnable t = new Runnable() {
+ @Override
+ public void run() {
+ getScoutObject().getUIFacade().fireRowActionFromUI(row);
+ }
+ };
+ getUiEnvironment().invokeScoutLater(t, 0);
+ // end notify
+ }
+ }
+ }
+
+ protected void handleUiHyperlinkAction(String urlText) {
+ if (getScoutObject() != null) {
+ final URL url;
+ try {
+ url = new URL(urlText);
+ }
+ catch (MalformedURLException e) {
+ //nop
+ return;
+ }
+ // notify Scout
+ Runnable t = new Runnable() {
+ @Override
+ public void run() {
+ ITable table = getScoutObject();
+ table.getUIFacade().fireHyperlinkActionFromUI(table.getSelectedRow(), table.getContextColumn(), url);
+ }
+ };
+ getUiEnvironment().invokeScoutLater(t, 0);
+ // end notify
+ }
+ }
+
+ protected void handleUiToggleAcction(Event e) {
+ if (e.doit && getScoutObject().isCheckable()) {
+ if (e.stateMask == 0) {
+ switch (e.keyCode) {
+ case ' ':
+ ITableRow[] selectedRows = RwtUtility.getItemsOfSelection(ITableRow.class, (StructuredSelection) getUiTableViewer().getSelection());
+ if (selectedRows != null && selectedRows.length > 0) {
+ handleUiRowClick(selectedRows[0]);
+ }
+ e.doit = false;
+ break;
+ }
+ }
+ }
+ }
+
+ private class P_ScoutTableListener implements TableListener {
+ @Override
+ public void tableChanged(final TableEvent e) {
+ if (isHandleScoutTableEvent(new TableEvent[]{e})) {
+ if (isIgnoredScoutEvent(TableEvent.class, "" + e.getType())) {
+ return;
+ }
+ Runnable t = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ getUpdateUiFromScoutLock().acquire();
+ //
+ handleScoutTableEventInUi(e);
+ }
+ finally {
+ getUpdateUiFromScoutLock().release();
+ }
+ }
+ };
+ getUiEnvironment().invokeUiLater(t);
+ }
+ }
+
+ @Override
+ public void tableChangedBatch(final TableEvent[] a) {
+ if (isHandleScoutTableEvent(a)) {
+ final ArrayList<TableEvent> filteredList = new ArrayList<TableEvent>();
+ for (int i = 0; i < a.length; i++) {
+ if (!isIgnoredScoutEvent(TableEvent.class, "" + a[i].getType())) {
+ filteredList.add(a[i]);
+ }
+ }
+ if (filteredList.size() == 0) {
+ return;
+ }
+ Runnable t = new Runnable() {
+ @Override
+ public void run() {
+ if (isUiDisposed()) {
+ return;
+ }
+ m_redrawHandler.pushControlChanging();
+ try {
+ try {
+ getUpdateUiFromScoutLock().acquire();
+ //
+ for (TableEvent element : filteredList) {
+ handleScoutTableEventInUi(element);
+ }
+ }
+ finally {
+ getUpdateUiFromScoutLock().release();
+ }
+ }
+ finally {
+ m_redrawHandler.popControlChanging();
+ }
+ }
+ };
+ getUiEnvironment().invokeUiLater(t);
+ }
+ }
+ }
+
+ private class P_RwtTableListener implements Listener {
+ private static final long serialVersionUID = 1L;
+
+ private Boolean m_doubleClicked = Boolean.FALSE;
+
+ @Override
+ public void handleEvent(Event event) {
+ switch (event.type) {
+ case SWT.MouseUp: {
+ setContextColumnFromUi();
+
+ synchronized (m_doubleClicked) {
+ if (m_doubleClicked == Boolean.TRUE) {
+ m_doubleClicked = Boolean.FALSE;
+ break;
+ }
+ }
+ Point eventPosition = new Point(event.x, event.y);
+ if (getUiField().getItem(eventPosition) == null) {
+ getUiTableViewer().setSelection(null);
+ setSelectionFromUi(new StructuredSelection());
+ }
+ else {
+ StructuredSelection selection = (StructuredSelection) getUiTableViewer().getSelection();
+ if (selection != null && selection.size() == 1) {
+ handleUiRowClick((ITableRow) selection.getFirstElement());
+ }
+ }
+ break;
+ }
+ case SWT.MouseDoubleClick: {
+ synchronized (m_doubleClicked) {
+ m_doubleClicked = Boolean.TRUE;
+ }
+ StructuredSelection selection = (StructuredSelection) getUiTableViewer().getSelection();
+ if (selection != null && selection.size() == 1) {
+ handleUiRowAction((ITableRow) selection.getFirstElement());
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ public class P_RwtSelectionListener implements ISelectionChangedListener {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ setSelectionFromUi((StructuredSelection) event.getSelection());
+ }
+ }
+
+ public class P_RwtHyperlinkListener implements HyperlinkListener {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void activated(HyperlinkEvent event) {
+ handleUiHyperlinkAction(event.url);
+ }
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutListModel.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutListModel.java
index 550cad8b7b..06d6b0a955 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutListModel.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutListModel.java
@@ -1,191 +1,191 @@
-/*******************************************************************************
- * Copyright (c) 2011 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
-
-import java.util.HashMap;
-
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.jface.util.SafeRunnable;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.scout.commons.StringUtility;
-import org.eclipse.scout.rt.client.ui.basic.cell.ICell;
-import org.eclipse.scout.rt.client.ui.basic.table.ITable;
-import org.eclipse.scout.rt.client.ui.basic.table.ITableRow;
-import org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn;
-import org.eclipse.scout.rt.ui.rap.basic.table.RwtScoutTableEvent;
-import org.eclipse.scout.rt.ui.rap.util.HtmlTextUtility;
-import org.eclipse.swt.graphics.Image;
-
-public class RwtScoutListModel implements IRwtScoutListModel {
- private static final long serialVersionUID = 1L;
-
- private transient ListenerList listenerList = null;
- private final ITable m_scoutTable;
- private HashMap<ITableRow, HashMap<IColumn<?>, ICell>> m_cachedCells;
- private final RwtScoutList m_uiList;
- private boolean m_multiline;
-
- public RwtScoutListModel(ITable scoutTable, RwtScoutList uiTable) {
- m_scoutTable = scoutTable;
- m_uiList = uiTable;
- rebuildCache();
- }
-
- @Override
- public void setMultiline(boolean multiline) {
- m_multiline = multiline;
- }
-
- @Override
- public boolean isMultiline() {
- return m_multiline;
- }
-
- @Override
- public Object[] getElements(Object inputElement) {
- if (m_scoutTable != null) {
- return m_scoutTable.getFilteredRows();
- }
- else {
- return new Object[0];
- }
- }
-
- @Override
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- @Override
- public void addListener(ILabelProviderListener listener) {
- if (listenerList == null) {
- listenerList = new ListenerList(ListenerList.IDENTITY);
- }
- listenerList.add(listener);
- }
-
- @Override
- public void removeListener(ILabelProviderListener listener) {
- if (listenerList != null) {
- listenerList.remove(listener);
- if (listenerList.isEmpty()) {
- listenerList = null;
- }
- }
- }
-
- private Object[] getListeners() {
- final ListenerList list = listenerList;
- if (list == null) {
- return new Object[0];
- }
-
- return list.getListeners();
- }
-
- @Override
- public void dispose() {
- if (listenerList != null) {
- listenerList.clear();
- }
- }
-
- protected void fireLabelProviderChanged(final LabelProviderChangedEvent event) {
- Object[] listeners = getListeners();
- for (int i = 0; i < listeners.length; ++i) {
- final ILabelProviderListener l = (ILabelProviderListener) listeners[i];
- SafeRunnable.run(new SafeRunnable() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void run() {
- l.labelProviderChanged(event);
- }
- });
- }
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- @Override
- public void consumeTableModelEvent(RwtScoutTableEvent uiTableEvent) {
- rebuildCache();
- }
-
- protected ICell getCell(Object row) {
- IColumn<?> column = m_scoutTable.getColumnSet().getVisibleColumns()[0];
- if (column != null) {
- if (m_cachedCells.get(row) == null) {
- rebuildCache();
- }
- return m_cachedCells.get(row).get(column);
- }
- else {
- return null;
- }
- }
-
- private void rebuildCache() {
- m_cachedCells = new HashMap<ITableRow, HashMap<IColumn<?>, ICell>>();
- if (m_scoutTable != null) {
- for (ITableRow scoutRow : m_scoutTable.getRows()) {
- HashMap<IColumn<?>, ICell> cells = new HashMap<IColumn<?>, ICell>();
- for (IColumn<?> col : m_scoutTable.getColumnSet().getVisibleColumns()) {
- cells.put(col, m_scoutTable.getCell(scoutRow, col));
- }
- m_cachedCells.put(scoutRow, cells);
- }
- }
- }
-
- @Override
- public RwtScoutList getRwtScoutList() {
- return m_uiList;
- }
-
- @Override
- public Image getImage(Object element) {
- //Has no effect on ListViewer
- return null;
- }
-
- @Override
- public String getText(Object element) {
- ICell cell = getCell(element);
- if (cell == null) {
- return "";
- }
-
- String text = cell.getText();
- if (text == null) {
- text = "";
- }
- if (HtmlTextUtility.isTextWithHtmlMarkup(text)) {
- text = m_uiList.getUiEnvironment().adaptHtmlCell(m_uiList, text);
- text = m_uiList.getUiEnvironment().convertLinksWithLocalUrlsInHtmlCell(m_uiList, text);
- }
- else if (text.indexOf("\n") >= 0) {
- if (isMultiline()) {
- //transform to html
- text = "<html>" + HtmlTextUtility.transformPlainTextToHtml(text) + "</html>";
- text = m_uiList.getUiEnvironment().adaptHtmlCell(m_uiList, text);
- }
- else {
- text = StringUtility.replace(text, "\n", " ");
- }
- }
- return text;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
+
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.jface.util.SafeRunnable;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.scout.commons.StringUtility;
+import org.eclipse.scout.rt.client.ui.basic.cell.ICell;
+import org.eclipse.scout.rt.client.ui.basic.table.ITable;
+import org.eclipse.scout.rt.client.ui.basic.table.ITableRow;
+import org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn;
+import org.eclipse.scout.rt.ui.rap.basic.table.RwtScoutTableEvent;
+import org.eclipse.scout.rt.ui.rap.util.HtmlTextUtility;
+import org.eclipse.swt.graphics.Image;
+
+public class RwtScoutListModel implements IRwtScoutListModel {
+ private static final long serialVersionUID = 1L;
+
+ private transient ListenerList listenerList = null;
+ private final ITable m_scoutTable;
+ private HashMap<ITableRow, HashMap<IColumn<?>, ICell>> m_cachedCells;
+ private final RwtScoutList m_uiList;
+ private boolean m_multiline;
+
+ public RwtScoutListModel(ITable scoutTable, RwtScoutList uiTable) {
+ m_scoutTable = scoutTable;
+ m_uiList = uiTable;
+ rebuildCache();
+ }
+
+ @Override
+ public void setMultiline(boolean multiline) {
+ m_multiline = multiline;
+ }
+
+ @Override
+ public boolean isMultiline() {
+ return m_multiline;
+ }
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ if (m_scoutTable != null) {
+ return m_scoutTable.getFilteredRows();
+ }
+ else {
+ return new Object[0];
+ }
+ }
+
+ @Override
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+ if (listenerList == null) {
+ listenerList = new ListenerList(ListenerList.IDENTITY);
+ }
+ listenerList.add(listener);
+ }
+
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+ if (listenerList != null) {
+ listenerList.remove(listener);
+ if (listenerList.isEmpty()) {
+ listenerList = null;
+ }
+ }
+ }
+
+ private Object[] getListeners() {
+ final ListenerList list = listenerList;
+ if (list == null) {
+ return new Object[0];
+ }
+
+ return list.getListeners();
+ }
+
+ @Override
+ public void dispose() {
+ if (listenerList != null) {
+ listenerList.clear();
+ }
+ }
+
+ protected void fireLabelProviderChanged(final LabelProviderChangedEvent event) {
+ Object[] listeners = getListeners();
+ for (int i = 0; i < listeners.length; ++i) {
+ final ILabelProviderListener l = (ILabelProviderListener) listeners[i];
+ SafeRunnable.run(new SafeRunnable() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void run() {
+ l.labelProviderChanged(event);
+ }
+ });
+ }
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ @Override
+ public void consumeTableModelEvent(RwtScoutTableEvent uiTableEvent) {
+ rebuildCache();
+ }
+
+ protected ICell getCell(Object row) {
+ IColumn<?> column = m_scoutTable.getColumnSet().getVisibleColumns()[0];
+ if (column != null) {
+ if (m_cachedCells.get(row) == null) {
+ rebuildCache();
+ }
+ return m_cachedCells.get(row).get(column);
+ }
+ else {
+ return null;
+ }
+ }
+
+ private void rebuildCache() {
+ m_cachedCells = new HashMap<ITableRow, HashMap<IColumn<?>, ICell>>();
+ if (m_scoutTable != null) {
+ for (ITableRow scoutRow : m_scoutTable.getRows()) {
+ HashMap<IColumn<?>, ICell> cells = new HashMap<IColumn<?>, ICell>();
+ for (IColumn<?> col : m_scoutTable.getColumnSet().getVisibleColumns()) {
+ cells.put(col, m_scoutTable.getCell(scoutRow, col));
+ }
+ m_cachedCells.put(scoutRow, cells);
+ }
+ }
+ }
+
+ @Override
+ public RwtScoutList getRwtScoutList() {
+ return m_uiList;
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ //Has no effect on ListViewer
+ return null;
+ }
+
+ @Override
+ public String getText(Object element) {
+ ICell cell = getCell(element);
+ if (cell == null) {
+ return "";
+ }
+
+ String text = cell.getText();
+ if (text == null) {
+ text = "";
+ }
+ if (HtmlTextUtility.isTextWithHtmlMarkup(text)) {
+ text = m_uiList.getUiEnvironment().adaptHtmlCell(m_uiList, text);
+ text = m_uiList.getUiEnvironment().convertLinksWithLocalUrlsInHtmlCell(m_uiList, text);
+ }
+ else if (text.indexOf("\n") >= 0) {
+ if (isMultiline()) {
+ //transform to html
+ text = "<html>" + HtmlTextUtility.transformPlainTextToHtml(text) + "</html>";
+ text = m_uiList.getUiEnvironment().adaptHtmlCell(m_uiList, text);
+ }
+ else {
+ text = StringUtility.replace(text, "\n", " ");
+ }
+ }
+ return text;
+ }
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutMobileTableField.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutMobileTableField.java
index a6fb5f5459..c66ab33ecc 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutMobileTableField.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutMobileTableField.java
@@ -1,173 +1,173 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.scout.commons.holders.Holder;
-import org.eclipse.scout.commons.logger.IScoutLogger;
-import org.eclipse.scout.commons.logger.ScoutLogManager;
-import org.eclipse.scout.rt.client.ClientSyncJob;
-import org.eclipse.scout.rt.client.mobile.ui.basic.table.MobileTable;
-import org.eclipse.scout.rt.client.mobile.ui.form.fields.table.IMobileTableField;
-import org.eclipse.scout.rt.client.ui.basic.table.ITable;
-import org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox;
-import org.eclipse.scout.rt.ui.rap.basic.table.IRwtScoutTable;
-import org.eclipse.scout.rt.ui.rap.form.fields.tablefield.IRwtTableStatus;
-import org.eclipse.scout.rt.ui.rap.form.fields.tablefield.RwtScoutTableField;
-import org.eclipse.scout.rt.ui.rap.window.desktop.IRwtScoutActionBar;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutMobileTableField extends RwtScoutTableField {
- private static final IScoutLogger LOG = ScoutLogManager.getLogger(RwtScoutMobileTableField.class);
-
- private MobileTable m_mobileTable;
- private boolean m_columnTransformationEnabled;
-
- public RwtScoutMobileTableField() {
- this(true);
- }
-
- public RwtScoutMobileTableField(boolean columnTransformationEnabled) {
- m_columnTransformationEnabled = columnTransformationEnabled;
- }
-
- @Override
- protected IRwtScoutTable createRwtScoutTable() {
- return new RwtScoutList();
- }
-
- @Override
- protected void setTableFromScout(ITable table) {
- if (!m_columnTransformationEnabled) {
- super.setTableFromScout(table);
- return;
- }
-
- disposeMobileTable();
-
- if (table == null) {
- super.setTableFromScout(table);
- return;
- }
- else {
- m_mobileTable = wrapTable(table);
- super.setTableFromScout(m_mobileTable);
- }
- }
-
- private MobileTable wrapTable(final ITable table) {
- final Holder<MobileTable> holder = new Holder<MobileTable>(MobileTable.class);
-
- ClientSyncJob job = new ClientSyncJob("", getUiEnvironment().getClientSession()) {
- @Override
- protected void runVoid(IProgressMonitor monitor) throws Throwable {
- MobileTable wrapperTable = new MobileTable(table);
- try {
- wrapperTable.setTableChanging(true);
- wrapperTable.setTableRowFormDisplayHint(getScoutObject().getForm().getDisplayHint());
- wrapperTable.setTableRowFormDisplayViewId(getScoutObject().getForm().getDisplayViewId());
- wrapperTable.initTable();
- }
- finally {
- wrapperTable.setTableChanging(false);
- }
- holder.setValue(wrapperTable);
- }
- };
- job.schedule();
-
- try {
- //TODO CGU: this freezes the gui if initializing of the table takes a while. Async table creation possible?
- job.join();
- }
- catch (InterruptedException e) {
- LOG.error("Table wrapping interrupted. ", e);
- }
-
- return holder.getValue();
- }
-
- @Override
- protected IRwtScoutActionBar createRwtScoutActionBar() {
- boolean actionBarVisible = true;
- if (getScoutObject() instanceof IMobileTableField) {
- actionBarVisible = ((IMobileTableField) getScoutObject()).isActionBarVisible();
- }
-
- if (actionBarVisible) {
- RwtScoutTableActionBar actionBar = new RwtScoutTableActionBar();
- actionBar.createUiField(getUiContainer(), getScoutObject(), getUiEnvironment());
- return actionBar;
- }
-
- return null;
- }
-
- @Override
- protected void detachScout() {
- disposeMobileTable();
-
- super.detachScout();
- }
-
- private void disposeMobileTable() {
- if (m_mobileTable == null) {
- return;
- }
-
- Runnable job = new Runnable() {
-
- @Override
- public void run() {
- if (m_mobileTable == null) {
- return;
- }
-
- m_mobileTable.dispose();
- m_mobileTable = null;
- }
-
- };
-
- getUiEnvironment().invokeScoutLater(job, 0);
- }
-
- /**
- * Returns true if the table is directly embedded into the field. In other words: Returns true if there is no parent
- * groupbox with a visible border.
- */
- @Override
- protected boolean dontCreateTableContainer() {
- if (getScoutObject() == null) {
- return false;
- }
-
- return !isAnyBorderVisible(getScoutObject().getParentGroupBox());
- }
-
- private boolean isAnyBorderVisible(IGroupBox groupBox) {
- while (groupBox != null) {
- if (groupBox.isBorderVisible()) {
- return true;
- }
- groupBox = groupBox.getParentGroupBox();
- }
-
- return false;
- }
-
- @Override
- protected IRwtTableStatus createRwtTableStatus() {
- return new RwtMobileTableStatus(getUiContainer(), getUiEnvironment(), getScoutObject());
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.scout.commons.holders.Holder;
+import org.eclipse.scout.commons.logger.IScoutLogger;
+import org.eclipse.scout.commons.logger.ScoutLogManager;
+import org.eclipse.scout.rt.client.ClientSyncJob;
+import org.eclipse.scout.rt.client.mobile.ui.basic.table.MobileTable;
+import org.eclipse.scout.rt.client.mobile.ui.form.fields.table.IMobileTableField;
+import org.eclipse.scout.rt.client.ui.basic.table.ITable;
+import org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox;
+import org.eclipse.scout.rt.ui.rap.basic.table.IRwtScoutTable;
+import org.eclipse.scout.rt.ui.rap.form.fields.tablefield.IRwtTableStatus;
+import org.eclipse.scout.rt.ui.rap.form.fields.tablefield.RwtScoutTableField;
+import org.eclipse.scout.rt.ui.rap.window.desktop.IRwtScoutActionBar;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutMobileTableField extends RwtScoutTableField {
+ private static final IScoutLogger LOG = ScoutLogManager.getLogger(RwtScoutMobileTableField.class);
+
+ private MobileTable m_mobileTable;
+ private boolean m_columnTransformationEnabled;
+
+ public RwtScoutMobileTableField() {
+ this(true);
+ }
+
+ public RwtScoutMobileTableField(boolean columnTransformationEnabled) {
+ m_columnTransformationEnabled = columnTransformationEnabled;
+ }
+
+ @Override
+ protected IRwtScoutTable createRwtScoutTable() {
+ return new RwtScoutList();
+ }
+
+ @Override
+ protected void setTableFromScout(ITable table) {
+ if (!m_columnTransformationEnabled) {
+ super.setTableFromScout(table);
+ return;
+ }
+
+ disposeMobileTable();
+
+ if (table == null) {
+ super.setTableFromScout(table);
+ return;
+ }
+ else {
+ m_mobileTable = wrapTable(table);
+ super.setTableFromScout(m_mobileTable);
+ }
+ }
+
+ private MobileTable wrapTable(final ITable table) {
+ final Holder<MobileTable> holder = new Holder<MobileTable>(MobileTable.class);
+
+ ClientSyncJob job = new ClientSyncJob("", getUiEnvironment().getClientSession()) {
+ @Override
+ protected void runVoid(IProgressMonitor monitor) throws Throwable {
+ MobileTable wrapperTable = new MobileTable(table);
+ try {
+ wrapperTable.setTableChanging(true);
+ wrapperTable.setTableRowFormDisplayHint(getScoutObject().getForm().getDisplayHint());
+ wrapperTable.setTableRowFormDisplayViewId(getScoutObject().getForm().getDisplayViewId());
+ wrapperTable.initTable();
+ }
+ finally {
+ wrapperTable.setTableChanging(false);
+ }
+ holder.setValue(wrapperTable);
+ }
+ };
+ job.schedule();
+
+ try {
+ //TODO CGU: this freezes the gui if initializing of the table takes a while. Async table creation possible?
+ job.join();
+ }
+ catch (InterruptedException e) {
+ LOG.error("Table wrapping interrupted. ", e);
+ }
+
+ return holder.getValue();
+ }
+
+ @Override
+ protected IRwtScoutActionBar createRwtScoutActionBar() {
+ boolean actionBarVisible = true;
+ if (getScoutObject() instanceof IMobileTableField) {
+ actionBarVisible = ((IMobileTableField) getScoutObject()).isActionBarVisible();
+ }
+
+ if (actionBarVisible) {
+ RwtScoutTableActionBar actionBar = new RwtScoutTableActionBar();
+ actionBar.createUiField(getUiContainer(), getScoutObject(), getUiEnvironment());
+ return actionBar;
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void detachScout() {
+ disposeMobileTable();
+
+ super.detachScout();
+ }
+
+ private void disposeMobileTable() {
+ if (m_mobileTable == null) {
+ return;
+ }
+
+ Runnable job = new Runnable() {
+
+ @Override
+ public void run() {
+ if (m_mobileTable == null) {
+ return;
+ }
+
+ m_mobileTable.dispose();
+ m_mobileTable = null;
+ }
+
+ };
+
+ getUiEnvironment().invokeScoutLater(job, 0);
+ }
+
+ /**
+ * Returns true if the table is directly embedded into the field. In other words: Returns true if there is no parent
+ * groupbox with a visible border.
+ */
+ @Override
+ protected boolean dontCreateTableContainer() {
+ if (getScoutObject() == null) {
+ return false;
+ }
+
+ return !isAnyBorderVisible(getScoutObject().getParentGroupBox());
+ }
+
+ private boolean isAnyBorderVisible(IGroupBox groupBox) {
+ while (groupBox != null) {
+ if (groupBox.isBorderVisible()) {
+ return true;
+ }
+ groupBox = groupBox.getParentGroupBox();
+ }
+
+ return false;
+ }
+
+ @Override
+ protected IRwtTableStatus createRwtTableStatus() {
+ return new RwtMobileTableStatus(getUiContainer(), getUiEnvironment(), getScoutObject());
+ }
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutTableActionBar.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutTableActionBar.java
index bd7d367465..bc160a19d9 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutTableActionBar.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/tablefield/RwtScoutTableActionBar.java
@@ -1,170 +1,170 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
-
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.scout.rt.client.mobile.ui.action.ActionButtonBarUtility;
-import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
-import org.eclipse.scout.rt.client.ui.basic.table.ITable;
-import org.eclipse.scout.rt.client.ui.basic.table.TableAdapter;
-import org.eclipse.scout.rt.client.ui.basic.table.TableEvent;
-import org.eclipse.scout.rt.client.ui.form.fields.smartfield.ISmartFieldProposalForm;
-import org.eclipse.scout.rt.client.ui.form.fields.tablefield.ITableField;
-import org.eclipse.scout.rt.ui.rap.LogicalGridData;
-import org.eclipse.scout.rt.ui.rap.RwtMenuUtility;
-import org.eclipse.scout.rt.ui.rap.form.fields.LogicalGridDataBuilder;
-import org.eclipse.scout.rt.ui.rap.mobile.action.AbstractRwtScoutActionBar;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutTableActionBar extends AbstractRwtScoutActionBar<ITableField<? extends ITable>> {
- private static final String VARIANT_SMART_FIELD_ACTION_BAR = "smartFieldActionBar";
- private P_TableRowSelectionListener m_rowSelectionListener;
- private ITable m_table;
-
- public RwtScoutTableActionBar() {
- setMenuOpeningDirection(SWT.UP);
- }
-
- @Override
- protected void initLayout(Composite container) {
- super.initLayout(container);
-
- int tableStatusGridH = 1;
- LogicalGridData tableGridData = LogicalGridDataBuilder.createField(getScoutObject().getGridData());
- LogicalGridData gd = new LogicalGridData();
- gd.gridx = tableGridData.gridx;
- gd.gridy = tableGridData.gridy + tableGridData.gridh + tableStatusGridH;
- gd.gridw = tableGridData.gridw;
- gd.topInset = 0;
- gd.gridh = 1;
- if (getHeightHint() != null) {
- gd.heightHint = getHeightHint();
- }
- else {
- gd.useUiHeight = true;
- }
- gd.weightx = tableGridData.weightx;
- gd.weighty = 0.0;
- gd.fillHorizontal = true;
- container.setLayoutData(gd);
- }
-
- @Override
- protected String getActionBarContainerVariant() {
- if (getScoutObject().getForm() instanceof ISmartFieldProposalForm) {
- return VARIANT_SMART_FIELD_ACTION_BAR;
- }
-
- return super.getActionBarContainerVariant();
- }
-
- @Override
- protected void collectMenusForLeftButtonBar(List<IMenu> menuList) {
- ITable table = getScoutObject().getTable();
- if (table == null) {
- return;
- }
-
- IMenu[] emptySpaceMenus = RwtMenuUtility.collectEmptySpaceMenus(table, getUiEnvironment());
- if (emptySpaceMenus != null) {
- menuList.addAll(Arrays.asList(emptySpaceMenus));
- }
-
- if (table.getSelectedRowCount() > 0) {
- IMenu[] rowMenus = RwtMenuUtility.collectRowMenus(table, getUiEnvironment());
- if (rowMenus != null) {
- List<IMenu> rowMenuList = new LinkedList<IMenu>(Arrays.asList(rowMenus));
-
- ActionButtonBarUtility.distributeRowActions(menuList, emptySpaceMenus, rowMenuList);
-
- //Add remaining row menus
- menuList.addAll(rowMenuList);
- }
- }
- }
-
- @Override
- protected void collectMenusForRightButtonBar(List<IMenu> menuList) {
-
- }
-
- @Override
- protected void attachScout() {
- super.attachScout();
-
- m_table = getScoutObject().getTable();
-
- addRowSelectionListener(m_table);
- }
-
- @Override
- protected void detachScout() {
- super.detachScout();
-
- removeRowSelectionListener(m_table);
-
- m_table = null;
- }
-
- private void addRowSelectionListener(ITable table) {
- if (m_rowSelectionListener != null || table == null) {
- return;
- }
-
- m_rowSelectionListener = new P_TableRowSelectionListener();
- table.addTableListener(m_rowSelectionListener);
- }
-
- private void removeRowSelectionListener(ITable table) {
- if (m_rowSelectionListener == null || table == null) {
- return;
- }
-
- table.removeTableListener(m_rowSelectionListener);
- m_rowSelectionListener = null;
- }
-
- @Override
- protected void handleScoutPropertyChange(String name, Object newValue) {
- super.handleScoutPropertyChange(name, newValue);
-
- if (name.equals(ITableField.PROP_TABLE)) {
- removeRowSelectionListener(m_table);
-
- m_table = (ITable) newValue;
-
- addRowSelectionListener(m_table);
- }
- }
-
- private class P_TableRowSelectionListener extends TableAdapter {
-
- @Override
- public void tableChanged(TableEvent e) {
- if (e.getType() == TableEvent.TYPE_ROWS_SELECTED) {
- rowSelected();
- }
- }
-
- private void rowSelected() {
- rebuildContentFromScout();
- }
-
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.tablefield;
+
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.scout.rt.client.mobile.ui.action.ActionButtonBarUtility;
+import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
+import org.eclipse.scout.rt.client.ui.basic.table.ITable;
+import org.eclipse.scout.rt.client.ui.basic.table.TableAdapter;
+import org.eclipse.scout.rt.client.ui.basic.table.TableEvent;
+import org.eclipse.scout.rt.client.ui.form.fields.smartfield.ISmartFieldProposalForm;
+import org.eclipse.scout.rt.client.ui.form.fields.tablefield.ITableField;
+import org.eclipse.scout.rt.ui.rap.LogicalGridData;
+import org.eclipse.scout.rt.ui.rap.RwtMenuUtility;
+import org.eclipse.scout.rt.ui.rap.form.fields.LogicalGridDataBuilder;
+import org.eclipse.scout.rt.ui.rap.mobile.action.AbstractRwtScoutActionBar;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutTableActionBar extends AbstractRwtScoutActionBar<ITableField<? extends ITable>> {
+ private static final String VARIANT_SMART_FIELD_ACTION_BAR = "smartFieldActionBar";
+ private P_TableRowSelectionListener m_rowSelectionListener;
+ private ITable m_table;
+
+ public RwtScoutTableActionBar() {
+ setMenuOpeningDirection(SWT.UP);
+ }
+
+ @Override
+ protected void initLayout(Composite container) {
+ super.initLayout(container);
+
+ int tableStatusGridH = 1;
+ LogicalGridData tableGridData = LogicalGridDataBuilder.createField(getScoutObject().getGridData());
+ LogicalGridData gd = new LogicalGridData();
+ gd.gridx = tableGridData.gridx;
+ gd.gridy = tableGridData.gridy + tableGridData.gridh + tableStatusGridH;
+ gd.gridw = tableGridData.gridw;
+ gd.topInset = 0;
+ gd.gridh = 1;
+ if (getHeightHint() != null) {
+ gd.heightHint = getHeightHint();
+ }
+ else {
+ gd.useUiHeight = true;
+ }
+ gd.weightx = tableGridData.weightx;
+ gd.weighty = 0.0;
+ gd.fillHorizontal = true;
+ container.setLayoutData(gd);
+ }
+
+ @Override
+ protected String getActionBarContainerVariant() {
+ if (getScoutObject().getForm() instanceof ISmartFieldProposalForm) {
+ return VARIANT_SMART_FIELD_ACTION_BAR;
+ }
+
+ return super.getActionBarContainerVariant();
+ }
+
+ @Override
+ protected void collectMenusForLeftButtonBar(List<IMenu> menuList) {
+ ITable table = getScoutObject().getTable();
+ if (table == null) {
+ return;
+ }
+
+ IMenu[] emptySpaceMenus = RwtMenuUtility.collectEmptySpaceMenus(table, getUiEnvironment());
+ if (emptySpaceMenus != null) {
+ menuList.addAll(Arrays.asList(emptySpaceMenus));
+ }
+
+ if (table.getSelectedRowCount() > 0) {
+ IMenu[] rowMenus = RwtMenuUtility.collectRowMenus(table, getUiEnvironment());
+ if (rowMenus != null) {
+ List<IMenu> rowMenuList = new LinkedList<IMenu>(Arrays.asList(rowMenus));
+
+ ActionButtonBarUtility.distributeRowActions(menuList, emptySpaceMenus, rowMenuList);
+
+ //Add remaining row menus
+ menuList.addAll(rowMenuList);
+ }
+ }
+ }
+
+ @Override
+ protected void collectMenusForRightButtonBar(List<IMenu> menuList) {
+
+ }
+
+ @Override
+ protected void attachScout() {
+ super.attachScout();
+
+ m_table = getScoutObject().getTable();
+
+ addRowSelectionListener(m_table);
+ }
+
+ @Override
+ protected void detachScout() {
+ super.detachScout();
+
+ removeRowSelectionListener(m_table);
+
+ m_table = null;
+ }
+
+ private void addRowSelectionListener(ITable table) {
+ if (m_rowSelectionListener != null || table == null) {
+ return;
+ }
+
+ m_rowSelectionListener = new P_TableRowSelectionListener();
+ table.addTableListener(m_rowSelectionListener);
+ }
+
+ private void removeRowSelectionListener(ITable table) {
+ if (m_rowSelectionListener == null || table == null) {
+ return;
+ }
+
+ table.removeTableListener(m_rowSelectionListener);
+ m_rowSelectionListener = null;
+ }
+
+ @Override
+ protected void handleScoutPropertyChange(String name, Object newValue) {
+ super.handleScoutPropertyChange(name, newValue);
+
+ if (name.equals(ITableField.PROP_TABLE)) {
+ removeRowSelectionListener(m_table);
+
+ m_table = (ITable) newValue;
+
+ addRowSelectionListener(m_table);
+ }
+ }
+
+ private class P_TableRowSelectionListener extends TableAdapter {
+
+ @Override
+ public void tableChanged(TableEvent e) {
+ if (e.getType() == TableEvent.TYPE_ROWS_SELECTED) {
+ rowSelected();
+ }
+ }
+
+ private void rowSelected() {
+ rebuildContentFromScout();
+ }
+
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/treefield/MobileTreeFieldFactory.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/treefield/MobileTreeFieldFactory.java
index bf8a394bcb..19c5645bfd 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/treefield/MobileTreeFieldFactory.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/treefield/MobileTreeFieldFactory.java
@@ -1,45 +1,45 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.treefield;
-
-import org.eclipse.scout.rt.client.ui.form.fields.IFormField;
-import org.eclipse.scout.rt.client.ui.form.fields.treefield.ITreeField;
-import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
-import org.eclipse.scout.rt.ui.rap.extension.IFormFieldFactory;
-import org.eclipse.scout.rt.ui.rap.form.fields.IRwtScoutFormField;
-import org.eclipse.scout.rt.ui.rap.form.fields.treefield.IRwtScoutTreeField;
-import org.eclipse.scout.rt.ui.rap.form.fields.treefield.RwtScoutTreeField;
-import org.eclipse.scout.rt.ui.rap.util.DeviceUtility;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 3.9.0
- */
-public class MobileTreeFieldFactory implements IFormFieldFactory {
-
- @Override
- public IRwtScoutFormField<?> createUiFormField(Composite parent, IFormField model, IRwtEnvironment uiEnvironment) {
- IRwtScoutTreeField field;
-
- if (DeviceUtility.isMobileOrTabletDevice()) {
- field = new RwtScoutMobileTreeField();
- }
- else {
- field = new RwtScoutTreeField();
- }
-
- ITreeField treeField = (ITreeField) model;
- field.createUiField(parent, treeField, uiEnvironment);
-
- return field;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.treefield;
+
+import org.eclipse.scout.rt.client.ui.form.fields.IFormField;
+import org.eclipse.scout.rt.client.ui.form.fields.treefield.ITreeField;
+import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
+import org.eclipse.scout.rt.ui.rap.extension.IFormFieldFactory;
+import org.eclipse.scout.rt.ui.rap.form.fields.IRwtScoutFormField;
+import org.eclipse.scout.rt.ui.rap.form.fields.treefield.IRwtScoutTreeField;
+import org.eclipse.scout.rt.ui.rap.form.fields.treefield.RwtScoutTreeField;
+import org.eclipse.scout.rt.ui.rap.util.DeviceUtility;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 3.9.0
+ */
+public class MobileTreeFieldFactory implements IFormFieldFactory {
+
+ @Override
+ public IRwtScoutFormField<?> createUiFormField(Composite parent, IFormField model, IRwtEnvironment uiEnvironment) {
+ IRwtScoutTreeField field;
+
+ if (DeviceUtility.isMobileOrTabletDevice()) {
+ field = new RwtScoutMobileTreeField();
+ }
+ else {
+ field = new RwtScoutTreeField();
+ }
+
+ ITreeField treeField = (ITreeField) model;
+ field.createUiField(parent, treeField, uiEnvironment);
+
+ return field;
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/treefield/RwtScoutMobileTreeField.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/treefield/RwtScoutMobileTreeField.java
index 620d8540cf..44968babb2 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/treefield/RwtScoutMobileTreeField.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/treefield/RwtScoutMobileTreeField.java
@@ -1,27 +1,27 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.treefield;
-
-import org.eclipse.scout.rt.ui.rap.form.fields.treefield.RwtScoutTreeField;
-import org.eclipse.scout.rt.ui.rap.window.desktop.IRwtScoutActionBar;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutMobileTreeField extends RwtScoutTreeField {
-
- @Override
- protected IRwtScoutActionBar createRwtScoutActionBar() {
- RwtScoutTreeActionBar actionBar = new RwtScoutTreeActionBar();
- actionBar.createUiField(getUiContainer(), getScoutObject(), getUiEnvironment());
- return actionBar;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.treefield;
+
+import org.eclipse.scout.rt.ui.rap.form.fields.treefield.RwtScoutTreeField;
+import org.eclipse.scout.rt.ui.rap.window.desktop.IRwtScoutActionBar;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutMobileTreeField extends RwtScoutTreeField {
+
+ @Override
+ protected IRwtScoutActionBar createRwtScoutActionBar() {
+ RwtScoutTreeActionBar actionBar = new RwtScoutTreeActionBar();
+ actionBar.createUiField(getUiContainer(), getScoutObject(), getUiEnvironment());
+ return actionBar;
+ }
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/treefield/RwtScoutTreeActionBar.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/treefield/RwtScoutTreeActionBar.java
index ee41cc9385..2846c8e423 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/treefield/RwtScoutTreeActionBar.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/form/fields/treefield/RwtScoutTreeActionBar.java
@@ -1,154 +1,154 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.form.fields.treefield;
-
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.scout.rt.client.mobile.ui.action.ActionButtonBarUtility;
-import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
-import org.eclipse.scout.rt.client.ui.basic.tree.ITree;
-import org.eclipse.scout.rt.client.ui.basic.tree.TreeAdapter;
-import org.eclipse.scout.rt.client.ui.basic.tree.TreeEvent;
-import org.eclipse.scout.rt.client.ui.form.fields.treefield.ITreeField;
-import org.eclipse.scout.rt.ui.rap.LogicalGridData;
-import org.eclipse.scout.rt.ui.rap.RwtMenuUtility;
-import org.eclipse.scout.rt.ui.rap.form.fields.LogicalGridDataBuilder;
-import org.eclipse.scout.rt.ui.rap.mobile.action.AbstractRwtScoutActionBar;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutTreeActionBar extends AbstractRwtScoutActionBar<ITreeField> {
- private P_TreeNodeSelectionListener m_nodeSelectionListener;
- private ITree m_tree;
-
- public RwtScoutTreeActionBar() {
- setMenuOpeningDirection(SWT.UP);
- }
-
- @Override
- protected void initLayout(Composite container) {
- super.initLayout(container);
-
- LogicalGridData tableGridData = LogicalGridDataBuilder.createField(getScoutObject().getGridData());
- LogicalGridData gd = new LogicalGridData();
- gd.gridx = tableGridData.gridx;
- gd.gridy = tableGridData.gridy + tableGridData.gridh;
- gd.gridw = tableGridData.gridw;
- gd.topInset = 0;
- gd.gridh = 1;
- if (getHeightHint() != null) {
- gd.heightHint = getHeightHint();
- }
- else {
- gd.useUiHeight = true;
- }
- gd.weightx = tableGridData.weightx;
- gd.weighty = 0.0;
- gd.fillHorizontal = true;
- container.setLayoutData(gd);
- }
-
- @Override
- protected void collectMenusForLeftButtonBar(List<IMenu> menuList) {
- ITree tree = getScoutObject().getTree();
- if (tree == null) {
- return;
- }
-
- IMenu[] emptySpaceMenus = RwtMenuUtility.collectEmptySpaceMenus(tree, getUiEnvironment());
- if (emptySpaceMenus != null) {
- menuList.addAll(Arrays.asList(emptySpaceMenus));
- }
-
- IMenu[] rowMenus = RwtMenuUtility.collectNodeMenus(tree, getUiEnvironment());
- if (rowMenus != null) {
- List<IMenu> rowMenuList = new LinkedList<IMenu>(Arrays.asList(rowMenus));
-
- ActionButtonBarUtility.distributeRowActions(menuList, emptySpaceMenus, rowMenuList);
-
- //Add remaining row menus
- menuList.addAll(rowMenuList);
- }
- }
-
- @Override
- protected void collectMenusForRightButtonBar(List<IMenu> menuList) {
- }
-
- @Override
- protected void attachScout() {
- super.attachScout();
-
- m_tree = getScoutObject().getTree();
-
- addRowSelectionListener(m_tree);
- }
-
- @Override
- protected void detachScout() {
- super.detachScout();
-
- removeRowSelectionListener(m_tree);
-
- m_tree = null;
- }
-
- private void addRowSelectionListener(ITree tree) {
- if (m_nodeSelectionListener != null || tree == null) {
- return;
- }
-
- m_nodeSelectionListener = new P_TreeNodeSelectionListener();
- tree.addTreeListener(m_nodeSelectionListener);
- }
-
- private void removeRowSelectionListener(ITree tree) {
- if (m_nodeSelectionListener == null || tree == null) {
- return;
- }
-
- tree.removeTreeListener(m_nodeSelectionListener);
- m_nodeSelectionListener = null;
- }
-
- @Override
- protected void handleScoutPropertyChange(String name, Object newValue) {
- super.handleScoutPropertyChange(name, newValue);
- if (name.equals(ITreeField.PROP_TREE)) {
- removeRowSelectionListener(m_tree);
-
- m_tree = (ITree) newValue;
-
- addRowSelectionListener(m_tree);
- }
- }
-
- private class P_TreeNodeSelectionListener extends TreeAdapter {
-
- @Override
- public void treeChanged(TreeEvent e) {
- if (e.getType() == TreeEvent.TYPE_NODES_SELECTED) {
- rowSelected();
- }
- }
-
- private void rowSelected() {
- rebuildContentFromScout();
- }
-
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.form.fields.treefield;
+
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.scout.rt.client.mobile.ui.action.ActionButtonBarUtility;
+import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
+import org.eclipse.scout.rt.client.ui.basic.tree.ITree;
+import org.eclipse.scout.rt.client.ui.basic.tree.TreeAdapter;
+import org.eclipse.scout.rt.client.ui.basic.tree.TreeEvent;
+import org.eclipse.scout.rt.client.ui.form.fields.treefield.ITreeField;
+import org.eclipse.scout.rt.ui.rap.LogicalGridData;
+import org.eclipse.scout.rt.ui.rap.RwtMenuUtility;
+import org.eclipse.scout.rt.ui.rap.form.fields.LogicalGridDataBuilder;
+import org.eclipse.scout.rt.ui.rap.mobile.action.AbstractRwtScoutActionBar;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutTreeActionBar extends AbstractRwtScoutActionBar<ITreeField> {
+ private P_TreeNodeSelectionListener m_nodeSelectionListener;
+ private ITree m_tree;
+
+ public RwtScoutTreeActionBar() {
+ setMenuOpeningDirection(SWT.UP);
+ }
+
+ @Override
+ protected void initLayout(Composite container) {
+ super.initLayout(container);
+
+ LogicalGridData tableGridData = LogicalGridDataBuilder.createField(getScoutObject().getGridData());
+ LogicalGridData gd = new LogicalGridData();
+ gd.gridx = tableGridData.gridx;
+ gd.gridy = tableGridData.gridy + tableGridData.gridh;
+ gd.gridw = tableGridData.gridw;
+ gd.topInset = 0;
+ gd.gridh = 1;
+ if (getHeightHint() != null) {
+ gd.heightHint = getHeightHint();
+ }
+ else {
+ gd.useUiHeight = true;
+ }
+ gd.weightx = tableGridData.weightx;
+ gd.weighty = 0.0;
+ gd.fillHorizontal = true;
+ container.setLayoutData(gd);
+ }
+
+ @Override
+ protected void collectMenusForLeftButtonBar(List<IMenu> menuList) {
+ ITree tree = getScoutObject().getTree();
+ if (tree == null) {
+ return;
+ }
+
+ IMenu[] emptySpaceMenus = RwtMenuUtility.collectEmptySpaceMenus(tree, getUiEnvironment());
+ if (emptySpaceMenus != null) {
+ menuList.addAll(Arrays.asList(emptySpaceMenus));
+ }
+
+ IMenu[] rowMenus = RwtMenuUtility.collectNodeMenus(tree, getUiEnvironment());
+ if (rowMenus != null) {
+ List<IMenu> rowMenuList = new LinkedList<IMenu>(Arrays.asList(rowMenus));
+
+ ActionButtonBarUtility.distributeRowActions(menuList, emptySpaceMenus, rowMenuList);
+
+ //Add remaining row menus
+ menuList.addAll(rowMenuList);
+ }
+ }
+
+ @Override
+ protected void collectMenusForRightButtonBar(List<IMenu> menuList) {
+ }
+
+ @Override
+ protected void attachScout() {
+ super.attachScout();
+
+ m_tree = getScoutObject().getTree();
+
+ addRowSelectionListener(m_tree);
+ }
+
+ @Override
+ protected void detachScout() {
+ super.detachScout();
+
+ removeRowSelectionListener(m_tree);
+
+ m_tree = null;
+ }
+
+ private void addRowSelectionListener(ITree tree) {
+ if (m_nodeSelectionListener != null || tree == null) {
+ return;
+ }
+
+ m_nodeSelectionListener = new P_TreeNodeSelectionListener();
+ tree.addTreeListener(m_nodeSelectionListener);
+ }
+
+ private void removeRowSelectionListener(ITree tree) {
+ if (m_nodeSelectionListener == null || tree == null) {
+ return;
+ }
+
+ tree.removeTreeListener(m_nodeSelectionListener);
+ m_nodeSelectionListener = null;
+ }
+
+ @Override
+ protected void handleScoutPropertyChange(String name, Object newValue) {
+ super.handleScoutPropertyChange(name, newValue);
+ if (name.equals(ITreeField.PROP_TREE)) {
+ removeRowSelectionListener(m_tree);
+
+ m_tree = (ITree) newValue;
+
+ addRowSelectionListener(m_tree);
+ }
+ }
+
+ private class P_TreeNodeSelectionListener extends TreeAdapter {
+
+ @Override
+ public void treeChanged(TreeEvent e) {
+ if (e.getType() == TreeEvent.TYPE_NODES_SELECTED) {
+ rowSelected();
+ }
+ }
+
+ private void rowSelected() {
+ rebuildContentFromScout();
+ }
+
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/MobileBrowserWindowHandler.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/MobileBrowserWindowHandler.java
index fb6272bceb..b3d8ea4248 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/MobileBrowserWindowHandler.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/MobileBrowserWindowHandler.java
@@ -1,43 +1,43 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.window;
-
-import org.eclipse.scout.commons.StringUtility;
-import org.eclipse.scout.rt.ui.rap.window.BrowserWindowHandler;
-
-/**
- * @since 3.9.0
- */
-public class MobileBrowserWindowHandler extends BrowserWindowHandler {
-
- @Override
- public void openLink(String link) {
- if (link == null) {
- return;
- }
-
- if (isMapsLink(link)) {
- //Open the link in the same browser window to open the maps app. Otherwise the popup gets blocked without notice.
- openLinkInSameBrowserWindow(link);
- }
- else {
- super.openLink(link);
- }
- }
-
- public boolean isMapsLink(String link) {
- if ((StringUtility.find(link, "http://maps.google.com") >= 0) || (StringUtility.find(link, "https://maps.google.com") >= 0)) {
- return true;
- }
-
- return false;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.window;
+
+import org.eclipse.scout.commons.StringUtility;
+import org.eclipse.scout.rt.ui.rap.window.BrowserWindowHandler;
+
+/**
+ * @since 3.9.0
+ */
+public class MobileBrowserWindowHandler extends BrowserWindowHandler {
+
+ @Override
+ public void openLink(String link) {
+ if (link == null) {
+ return;
+ }
+
+ if (isMapsLink(link)) {
+ //Open the link in the same browser window to open the maps app. Otherwise the popup gets blocked without notice.
+ openLinkInSameBrowserWindow(link);
+ }
+ else {
+ super.openLink(link);
+ }
+ }
+
+ public boolean isMapsLink(String link) {
+ if ((StringUtility.find(link, "http://maps.google.com") >= 0) || (StringUtility.find(link, "https://maps.google.com") >= 0)) {
+ return true;
+ }
+
+ return false;
+ }
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/FormBasedDesktopFormBoundsProvider.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/FormBasedDesktopFormBoundsProvider.java
index 4794896bf2..34211ead6f 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/FormBasedDesktopFormBoundsProvider.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/FormBasedDesktopFormBoundsProvider.java
@@ -1,62 +1,62 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.window.desktop;
-
-import org.eclipse.scout.rt.client.ui.form.IForm;
-import org.eclipse.scout.rt.client.ui.form.fields.GridData;
-import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
-import org.eclipse.scout.rt.ui.rap.window.IFormBoundsProvider;
-import org.eclipse.swt.graphics.Rectangle;
-
-/**
- * Reads the width and height specified in the {@link GridData} of the main group box ({@link IForm#getRootGroupBox()}).
- * If nothing is specified null will be returned.
- * <p>
- * The bounds are not cached.
- *
- * @since 3.9.0
- */
-public class FormBasedDesktopFormBoundsProvider implements IFormBoundsProvider {
- private final IForm m_form;
- private IRwtEnvironment m_uiEnvironment;
-
- public FormBasedDesktopFormBoundsProvider(IForm form, IRwtEnvironment uiEnvironment) {
- m_form = form;
- m_uiEnvironment = uiEnvironment;
- }
-
- @Override
- public Rectangle getBounds() {
- int maxWidth = -1;
- int maxHeight = -1;
-
- GridData gridData = m_form.getRootGroupBox().getGridData();
- if (gridData.widthInPixel > 0) {
- maxWidth = gridData.widthInPixel;
- }
- if (gridData.heightInPixel > 0) {
- maxHeight = gridData.heightInPixel;
- }
-
- if (maxWidth == -1 && maxHeight == -1) {
- return null;
- }
- else {
- return new Rectangle(-1, -1, maxWidth, maxHeight);
- }
- }
-
- @Override
- public void storeBounds(Rectangle bounds) {
- // nop
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.window.desktop;
+
+import org.eclipse.scout.rt.client.ui.form.IForm;
+import org.eclipse.scout.rt.client.ui.form.fields.GridData;
+import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
+import org.eclipse.scout.rt.ui.rap.window.IFormBoundsProvider;
+import org.eclipse.swt.graphics.Rectangle;
+
+/**
+ * Reads the width and height specified in the {@link GridData} of the main group box ({@link IForm#getRootGroupBox()}).
+ * If nothing is specified null will be returned.
+ * <p>
+ * The bounds are not cached.
+ *
+ * @since 3.9.0
+ */
+public class FormBasedDesktopFormBoundsProvider implements IFormBoundsProvider {
+ private final IForm m_form;
+ private IRwtEnvironment m_uiEnvironment;
+
+ public FormBasedDesktopFormBoundsProvider(IForm form, IRwtEnvironment uiEnvironment) {
+ m_form = form;
+ m_uiEnvironment = uiEnvironment;
+ }
+
+ @Override
+ public Rectangle getBounds() {
+ int maxWidth = -1;
+ int maxHeight = -1;
+
+ GridData gridData = m_form.getRootGroupBox().getGridData();
+ if (gridData.widthInPixel > 0) {
+ maxWidth = gridData.widthInPixel;
+ }
+ if (gridData.heightInPixel > 0) {
+ maxHeight = gridData.heightInPixel;
+ }
+
+ if (maxWidth == -1 && maxHeight == -1) {
+ return null;
+ }
+ else {
+ return new Rectangle(-1, -1, maxWidth, maxHeight);
+ }
+ }
+
+ @Override
+ public void storeBounds(Rectangle bounds) {
+ // nop
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/MobileViewArea.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/MobileViewArea.java
index 49a209bfcb..63f065b4ff 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/MobileViewArea.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/MobileViewArea.java
@@ -1,77 +1,77 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.window.desktop;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.scout.commons.holders.BooleanHolder;
-import org.eclipse.scout.rt.client.ClientSyncJob;
-import org.eclipse.scout.rt.client.mobile.transformation.IDeviceTransformationService;
-import org.eclipse.scout.rt.ui.rap.window.desktop.RwtScoutViewStack;
-import org.eclipse.scout.rt.ui.rap.window.desktop.viewarea.ViewArea;
-import org.eclipse.scout.service.SERVICES;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Sash;
-
-/**
- * @since 3.9.0
- */
-public class MobileViewArea extends ViewArea {
-
- private static final long serialVersionUID = 1L;
-
- public MobileViewArea(Composite parent) {
- super(parent);
- }
-
- @Override
- protected RwtScoutViewStack createRwtScoutViewStack(Composite parent) {
- return new RwtScoutMobileViewStack(parent, getUiEnvironment(), this);
- }
-
- @Override
- protected Sash createSash(Composite parent, int style) {
- SimpleSash simpleSash = new SimpleSash(parent, style);
- return simpleSash;
- }
-
- @Override
- protected int getSashWidth() {
- return 1;
- }
-
- @Override
- protected boolean acceptViewId(final String viewId) {
- final BooleanHolder accepted = new BooleanHolder(true);
-
- ClientSyncJob job = new ClientSyncJob("Adapting form header left menus", getUiEnvironment().getClientSession()) {
-
- @Override
- protected void runVoid(IProgressMonitor monitor) throws Throwable {
- IDeviceTransformationService service = SERVICES.getService(IDeviceTransformationService.class);
- if (service != null && service.getDeviceTransformer() != null) {
- List<String> acceptedViewIds = service.getDeviceTransformer().getAcceptedViewIds();
-
- //Accept all if null is returned.
- if (acceptedViewIds != null) {
- accepted.setValue(acceptedViewIds.contains(viewId));
- }
- }
- }
-
- };
- job.runNow(new NullProgressMonitor());
-
- return accepted.getValue();
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.window.desktop;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.scout.commons.holders.BooleanHolder;
+import org.eclipse.scout.rt.client.ClientSyncJob;
+import org.eclipse.scout.rt.client.mobile.transformation.IDeviceTransformationService;
+import org.eclipse.scout.rt.ui.rap.window.desktop.RwtScoutViewStack;
+import org.eclipse.scout.rt.ui.rap.window.desktop.viewarea.ViewArea;
+import org.eclipse.scout.service.SERVICES;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Sash;
+
+/**
+ * @since 3.9.0
+ */
+public class MobileViewArea extends ViewArea {
+
+ private static final long serialVersionUID = 1L;
+
+ public MobileViewArea(Composite parent) {
+ super(parent);
+ }
+
+ @Override
+ protected RwtScoutViewStack createRwtScoutViewStack(Composite parent) {
+ return new RwtScoutMobileViewStack(parent, getUiEnvironment(), this);
+ }
+
+ @Override
+ protected Sash createSash(Composite parent, int style) {
+ SimpleSash simpleSash = new SimpleSash(parent, style);
+ return simpleSash;
+ }
+
+ @Override
+ protected int getSashWidth() {
+ return 1;
+ }
+
+ @Override
+ protected boolean acceptViewId(final String viewId) {
+ final BooleanHolder accepted = new BooleanHolder(true);
+
+ ClientSyncJob job = new ClientSyncJob("Adapting form header left menus", getUiEnvironment().getClientSession()) {
+
+ @Override
+ protected void runVoid(IProgressMonitor monitor) throws Throwable {
+ IDeviceTransformationService service = SERVICES.getService(IDeviceTransformationService.class);
+ if (service != null && service.getDeviceTransformer() != null) {
+ List<String> acceptedViewIds = service.getDeviceTransformer().getAcceptedViewIds();
+
+ //Accept all if null is returned.
+ if (acceptedViewIds != null) {
+ accepted.setValue(acceptedViewIds.contains(viewId));
+ }
+ }
+ }
+
+ };
+ job.runNow(new NullProgressMonitor());
+
+ return accepted.getValue();
+ }
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/RwtScoutMobileDesktop.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/RwtScoutMobileDesktop.java
index f94f0c6f54..77ba87971d 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/RwtScoutMobileDesktop.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/RwtScoutMobileDesktop.java
@@ -1,36 +1,36 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.window.desktop;
-
-import org.eclipse.scout.rt.ui.rap.window.desktop.RwtScoutDesktop;
-import org.eclipse.scout.rt.ui.rap.window.desktop.viewarea.ViewArea;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutMobileDesktop extends RwtScoutDesktop {
-
- /**
- * On mobile devices every form has a form header, the outline form too, so no global toolbar is necessary because the
- * forms take care of that.
- */
- @Override
- protected Control createToolBar(Composite parent) {
- return null;
- }
-
- @Override
- protected ViewArea createViewArea(Composite parent) {
- return new MobileViewArea(parent);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.window.desktop;
+
+import org.eclipse.scout.rt.ui.rap.window.desktop.RwtScoutDesktop;
+import org.eclipse.scout.rt.ui.rap.window.desktop.viewarea.ViewArea;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutMobileDesktop extends RwtScoutDesktop {
+
+ /**
+ * On mobile devices every form has a form header, the outline form too, so no global toolbar is necessary because the
+ * forms take care of that.
+ */
+ @Override
+ protected Control createToolBar(Composite parent) {
+ return null;
+ }
+
+ @Override
+ protected ViewArea createViewArea(Composite parent) {
+ return new MobileViewArea(parent);
+ }
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/RwtScoutMobileDesktopForm.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/RwtScoutMobileDesktopForm.java
index 703474a5a6..2e40474166 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/RwtScoutMobileDesktopForm.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/RwtScoutMobileDesktopForm.java
@@ -1,27 +1,27 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.window.desktop;
-
-import org.eclipse.scout.rt.ui.rap.window.desktop.RwtScoutDesktopForm;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutMobileDesktopForm extends RwtScoutDesktopForm {
-
- @Override
- public boolean isEclipseFormUsed() {
- //Eclipse forms are too heavyweight and may even crash chrome on android.
- //Since the mobile forms don't use any feature of the eclipse forms there is no need to create them.
- return false;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.window.desktop;
+
+import org.eclipse.scout.rt.ui.rap.window.desktop.RwtScoutDesktopForm;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutMobileDesktopForm extends RwtScoutDesktopForm {
+
+ @Override
+ public boolean isEclipseFormUsed() {
+ //Eclipse forms are too heavyweight and may even crash chrome on android.
+ //Since the mobile forms don't use any feature of the eclipse forms there is no need to create them.
+ return false;
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/RwtScoutMobileViewStack.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/RwtScoutMobileViewStack.java
index a0aab54ad8..430c8df5aa 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/RwtScoutMobileViewStack.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/RwtScoutMobileViewStack.java
@@ -1,61 +1,61 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.window.desktop;
-
-import org.eclipse.scout.rt.client.ui.form.IForm;
-import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
-import org.eclipse.scout.rt.ui.rap.window.IFormBoundsProvider;
-import org.eclipse.scout.rt.ui.rap.window.desktop.IViewArea;
-import org.eclipse.scout.rt.ui.rap.window.desktop.RwtScoutDesktopForm;
-import org.eclipse.scout.rt.ui.rap.window.desktop.RwtScoutViewStack;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutMobileViewStack extends RwtScoutViewStack {
- private static final long serialVersionUID = 1L;
- private IViewArea m_viewArea;
-
- public RwtScoutMobileViewStack(Composite parent, IRwtEnvironment uiEnvironment, IViewArea viewArea) {
- super(parent, uiEnvironment);
-
- m_viewArea = viewArea;
- }
-
- @Override
- protected boolean isTabBarCreationEnabled() {
- return false;
- }
-
- @Override
- protected RwtScoutDesktopForm createRwtScoutDesktopForm() {
- return new RwtScoutMobileDesktopForm();
- }
-
- @Override
- protected IFormBoundsProvider createFormBoundsProvider(IForm scoutForm, IRwtEnvironment uiEnvironment) {
- return new FormBasedDesktopFormBoundsProvider(scoutForm, uiEnvironment);
- }
-
- @Override
- protected void setPartVisibleImpl(IForm form) {
- super.setPartVisibleImpl(form);
-
- //Make sure the preferred size is updated if the visible part changes.
- if (form != null && form.isCacheBounds()) {
- initPreferredSize(getFormBoundsProviders().get(form));
- m_viewArea.updateSashPositionForViewStack(this);
- m_viewArea.layout();
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.window.desktop;
+
+import org.eclipse.scout.rt.client.ui.form.IForm;
+import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
+import org.eclipse.scout.rt.ui.rap.window.IFormBoundsProvider;
+import org.eclipse.scout.rt.ui.rap.window.desktop.IViewArea;
+import org.eclipse.scout.rt.ui.rap.window.desktop.RwtScoutDesktopForm;
+import org.eclipse.scout.rt.ui.rap.window.desktop.RwtScoutViewStack;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutMobileViewStack extends RwtScoutViewStack {
+ private static final long serialVersionUID = 1L;
+ private IViewArea m_viewArea;
+
+ public RwtScoutMobileViewStack(Composite parent, IRwtEnvironment uiEnvironment, IViewArea viewArea) {
+ super(parent, uiEnvironment);
+
+ m_viewArea = viewArea;
+ }
+
+ @Override
+ protected boolean isTabBarCreationEnabled() {
+ return false;
+ }
+
+ @Override
+ protected RwtScoutDesktopForm createRwtScoutDesktopForm() {
+ return new RwtScoutMobileDesktopForm();
+ }
+
+ @Override
+ protected IFormBoundsProvider createFormBoundsProvider(IForm scoutForm, IRwtEnvironment uiEnvironment) {
+ return new FormBasedDesktopFormBoundsProvider(scoutForm, uiEnvironment);
+ }
+
+ @Override
+ protected void setPartVisibleImpl(IForm form) {
+ super.setPartVisibleImpl(form);
+
+ //Make sure the preferred size is updated if the visible part changes.
+ if (form != null && form.isCacheBounds()) {
+ initPreferredSize(getFormBoundsProviders().get(form));
+ m_viewArea.updateSashPositionForViewStack(this);
+ m_viewArea.layout();
+ }
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/SimpleSash.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/SimpleSash.java
index d1925d2490..cdbc6f606c 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/SimpleSash.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/desktop/SimpleSash.java
@@ -1,41 +1,41 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.window.desktop;
-
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Sash;
-
-/**
- * A sash with no functionality.
- *
- * @since 3.9.0
- */
-public class SimpleSash extends Sash {
- private static final long serialVersionUID = 1L;
-
- public SimpleSash(Composite parent, int style) {
- super(parent, style);
-
- setEnabled(false);
- }
-
- @Override
- public void addSelectionListener(SelectionListener listener) {
- // nop
- }
-
- @Override
- public void removeSelectionListener(SelectionListener listener) {
- // nop
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.window.desktop;
+
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Sash;
+
+/**
+ * A sash with no functionality.
+ *
+ * @since 3.9.0
+ */
+public class SimpleSash extends Sash {
+ private static final long serialVersionUID = 1L;
+
+ public SimpleSash(Composite parent, int style) {
+ super(parent, style);
+
+ setEnabled(false);
+ }
+
+ @Override
+ public void addSelectionListener(SelectionListener listener) {
+ // nop
+ }
+
+ @Override
+ public void removeSelectionListener(SelectionListener listener) {
+ // nop
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/dialog/FixedSizeDialogBoundsProvider.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/dialog/FixedSizeDialogBoundsProvider.java
index 9523013193..6e98e9ec6d 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/dialog/FixedSizeDialogBoundsProvider.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/dialog/FixedSizeDialogBoundsProvider.java
@@ -1,63 +1,63 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.window.dialog;
-
-import org.eclipse.scout.rt.client.ui.form.IForm;
-import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
-import org.eclipse.scout.rt.ui.rap.window.IFormBoundsProvider;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * Positions the form in the middle of the screen and makes it as height as the screen.
- * <p>
- * As default the height is set to the height of the display which means the dialog is as height as the screen.<br>
- * The width is set to a fix value which is {@link #DIALOG_WIDTH} but only if it does not exceed the width of the
- * screen.
- * <p>
- * The bounds are not cached.
- *
- * @since 3.9.0
- */
-public class FixedSizeDialogBoundsProvider implements IFormBoundsProvider {
- public static final int DIALOG_WIDTH = 700;
-
- private final IForm m_form;
- private int m_maxWidth = DIALOG_WIDTH;
- private int m_maxHeight = Integer.MAX_VALUE;
- private IRwtEnvironment m_uiEnvironment;
-
- public FixedSizeDialogBoundsProvider(IForm form, IRwtEnvironment uiEnvironment) {
- m_form = form;
- m_uiEnvironment = uiEnvironment;
- }
-
- @Override
- public Rectangle getBounds() {
- int maxWidth = m_maxWidth;
- int maxHeight = m_maxHeight;
-
- Rectangle displayBounds = Display.getCurrent().getBounds();
-
- int height = Math.min(maxHeight, displayBounds.height);
- int width = Math.min(maxWidth, displayBounds.width);
- int x = (displayBounds.width / 2) - (width / 2);
- int y = 0;
-
- return new Rectangle(x, y, width, height);
- }
-
- @Override
- public void storeBounds(Rectangle bounds) {
- // nop
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.window.dialog;
+
+import org.eclipse.scout.rt.client.ui.form.IForm;
+import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
+import org.eclipse.scout.rt.ui.rap.window.IFormBoundsProvider;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Positions the form in the middle of the screen and makes it as height as the screen.
+ * <p>
+ * As default the height is set to the height of the display which means the dialog is as height as the screen.<br>
+ * The width is set to a fix value which is {@link #DIALOG_WIDTH} but only if it does not exceed the width of the
+ * screen.
+ * <p>
+ * The bounds are not cached.
+ *
+ * @since 3.9.0
+ */
+public class FixedSizeDialogBoundsProvider implements IFormBoundsProvider {
+ public static final int DIALOG_WIDTH = 700;
+
+ private final IForm m_form;
+ private int m_maxWidth = DIALOG_WIDTH;
+ private int m_maxHeight = Integer.MAX_VALUE;
+ private IRwtEnvironment m_uiEnvironment;
+
+ public FixedSizeDialogBoundsProvider(IForm form, IRwtEnvironment uiEnvironment) {
+ m_form = form;
+ m_uiEnvironment = uiEnvironment;
+ }
+
+ @Override
+ public Rectangle getBounds() {
+ int maxWidth = m_maxWidth;
+ int maxHeight = m_maxHeight;
+
+ Rectangle displayBounds = Display.getCurrent().getBounds();
+
+ int height = Math.min(maxHeight, displayBounds.height);
+ int width = Math.min(maxWidth, displayBounds.width);
+ int x = (displayBounds.width / 2) - (width / 2);
+ int y = 0;
+
+ return new Rectangle(x, y, width, height);
+ }
+
+ @Override
+ public void storeBounds(Rectangle bounds) {
+ // nop
+ }
+
+}
diff --git a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/dialog/RwtScoutMobileDialog.java b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/dialog/RwtScoutMobileDialog.java
index ccca70b487..f9fce64ab3 100644
--- a/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/dialog/RwtScoutMobileDialog.java
+++ b/org.eclipse.scout.rt.ui.rap.mobile/src/org/eclipse/scout/rt/ui/rap/mobile/window/dialog/RwtScoutMobileDialog.java
@@ -1,90 +1,90 @@
-/*******************************************************************************
- * Copyright (c) 2010 BSI Business Systems Integration AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * BSI Business Systems Integration AG - initial API and implementation
- ******************************************************************************/
-package org.eclipse.scout.rt.ui.rap.mobile.window.dialog;
-
-import org.eclipse.scout.rt.client.ui.form.IForm;
-import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
-import org.eclipse.scout.rt.ui.rap.IRwtStandaloneEnvironment;
-import org.eclipse.scout.rt.ui.rap.window.IFormBoundsProvider;
-import org.eclipse.scout.rt.ui.rap.window.dialog.RwtScoutDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.9.0
- */
-public class RwtScoutMobileDialog extends RwtScoutDialog {
- private P_ResizeListener m_resizeListener;
-
- @Override
- protected IRwtStandaloneEnvironment getUiEnvironment() {
- return (IRwtStandaloneEnvironment) super.getUiEnvironment();
- }
-
- @Override
- public boolean isEclipseFormUsed() {
- //Eclipse forms are too heavyweight and may even crash chrome on android.
- //Since the mobile forms don't use any feature of the eclipse forms there is no need to create them.
- return false;
- }
-
- @Override
- public void createPart(IForm scoutForm, Shell parentShell, int style, IRwtEnvironment uiEnvironment) {
- scoutForm.setCacheBounds(true);
-
- super.createPart(scoutForm, parentShell, style, uiEnvironment);
-
- m_resizeListener = new P_ResizeListener();
- getUiEnvironment().getUiDesktop().getUiContainer().addListener(SWT.Resize, m_resizeListener);
- }
-
- @Override
- protected void closePartImpl() {
- super.closePartImpl();
-
- getUiEnvironment().getUiDesktop().getUiContainer().removeListener(SWT.Resize, m_resizeListener);
- }
-
- @Override
- protected IFormBoundsProvider createFormBoundsProvider(IForm scoutForm, IRwtEnvironment uiEnvironment) {
- return new FixedSizeDialogBoundsProvider(scoutForm, uiEnvironment);
- }
-
- /**
- * Adjusts the size of the dialog if the screen gets resized (e.g. on device rotation).
- */
- private class P_ResizeListener implements Listener {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void handleEvent(Event event) {
- if (getUiDialog().getShell().isDisposed()) {
- return;
- }
-
- Rectangle bounds = getBoundsProvider().getBounds();
- if (bounds != null) {
- if (bounds.x >= 0 || bounds.y >= 0) {
- getUiDialog().getShell().setLocation(new Point(bounds.x, bounds.y));
- }
- if (bounds.width >= 0 || bounds.height >= 0) {
- getUiDialog().getShell().setSize(new Point(bounds.width, bounds.height));
- }
- }
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.ui.rap.mobile.window.dialog;
+
+import org.eclipse.scout.rt.client.ui.form.IForm;
+import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
+import org.eclipse.scout.rt.ui.rap.IRwtStandaloneEnvironment;
+import org.eclipse.scout.rt.ui.rap.window.IFormBoundsProvider;
+import org.eclipse.scout.rt.ui.rap.window.dialog.RwtScoutDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @since 3.9.0
+ */
+public class RwtScoutMobileDialog extends RwtScoutDialog {
+ private P_ResizeListener m_resizeListener;
+
+ @Override
+ protected IRwtStandaloneEnvironment getUiEnvironment() {
+ return (IRwtStandaloneEnvironment) super.getUiEnvironment();
+ }
+
+ @Override
+ public boolean isEclipseFormUsed() {
+ //Eclipse forms are too heavyweight and may even crash chrome on android.
+ //Since the mobile forms don't use any feature of the eclipse forms there is no need to create them.
+ return false;
+ }
+
+ @Override
+ public void createPart(IForm scoutForm, Shell parentShell, int style, IRwtEnvironment uiEnvironment) {
+ scoutForm.setCacheBounds(true);
+
+ super.createPart(scoutForm, parentShell, style, uiEnvironment);
+
+ m_resizeListener = new P_ResizeListener();
+ getUiEnvironment().getUiDesktop().getUiContainer().addListener(SWT.Resize, m_resizeListener);
+ }
+
+ @Override
+ protected void closePartImpl() {
+ super.closePartImpl();
+
+ getUiEnvironment().getUiDesktop().getUiContainer().removeListener(SWT.Resize, m_resizeListener);
+ }
+
+ @Override
+ protected IFormBoundsProvider createFormBoundsProvider(IForm scoutForm, IRwtEnvironment uiEnvironment) {
+ return new FixedSizeDialogBoundsProvider(scoutForm, uiEnvironment);
+ }
+
+ /**
+ * Adjusts the size of the dialog if the screen gets resized (e.g. on device rotation).
+ */
+ private class P_ResizeListener implements Listener {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void handleEvent(Event event) {
+ if (getUiDialog().getShell().isDisposed()) {
+ return;
+ }
+
+ Rectangle bounds = getBoundsProvider().getBounds();
+ if (bounds != null) {
+ if (bounds.x >= 0 || bounds.y >= 0) {
+ getUiDialog().getShell().setLocation(new Point(bounds.x, bounds.y));
+ }
+ if (bounds.width >= 0 || bounds.height >= 0) {
+ getUiDialog().getShell().setSize(new Point(bounds.width, bounds.height));
+ }
+ }
+ }
+ }
+
+}

Back to the top