100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Started work on map overlay panels
Christian Bauer262216e5a563
diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsDashboardActivity.java b/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsDashboardActivity.javaindex 35ce225f7..faee780c4 100644--- a/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsDashboardActivity.java+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsDashboardActivity.java@@ -41,6 +41,12 @@ public class AssetsDashboardActivitysuper(environment, view, assetBrowserPresenter, assetResource, assetMapper);}+ @Override+ public void onStop() {+ super.onStop();+ getView().setPresenter(null);+ }+@Overrideprotected void onAssetLoaded() {}diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/asset/AssetViewImpl.ui.xml b/manager/client/src/main/java/org/openremote/manager/client/assets/asset/AssetViewImpl.ui.xmlindex 3f2006806..6d1c8b6a0 100644--- a/manager/client/src/main/java/org/openremote/manager/client/assets/asset/AssetViewImpl.ui.xml+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/asset/AssetViewImpl.ui.xml@@ -211,6 +211,7 @@</w:field></w:FormGroup></w:Form>+<w:MapWidget ui:field="mapWidget"addStyleNames="{style.mapWidget} {widgetStyle.ItemWithBorder}"/></g:HTMLPanel>diff --git a/manager/client/src/main/java/org/openremote/manager/client/map/MapActivity.java b/manager/client/src/main/java/org/openremote/manager/client/map/MapActivity.javaindex aae1f00ad..22b2c0ea9 100644--- a/manager/client/src/main/java/org/openremote/manager/client/map/MapActivity.java+++ b/manager/client/src/main/java/org/openremote/manager/client/map/MapActivity.java@@ -76,6 +76,12 @@ public class MapActivity extends AssetBrowsingActivity<MapView, MapPlace> implem);}+ @Override+ public void onStop() {+ super.onStop();+ view.setPresenter(null);+ }+@Overrideprotected void onAssetLoaded() {showAssetOnMap();diff --git a/manager/client/src/main/java/org/openremote/manager/client/map/MapInfoPanel.java b/manager/client/src/main/java/org/openremote/manager/client/map/MapInfoPanel.javanew file mode 100644index 000000000..a6c79c8d3--- /dev/null+++ b/manager/client/src/main/java/org/openremote/manager/client/map/MapInfoPanel.java@@ -0,0 +1,48 @@+/*+ * Copyright 2016, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.manager.client.map;++import com.google.gwt.core.client.GWT;+import com.google.gwt.uibinder.client.UiBinder;+import com.google.gwt.uibinder.client.UiField;+import com.google.gwt.user.client.ui.PopupPanel;+import org.openremote.manager.client.i18n.ManagerMessages;+import org.openremote.manager.client.style.WidgetStyle;+import org.openremote.manager.client.widget.AbstractAppPanel;++public class MapInfoPanel extends AbstractAppPanel {++ interface UI extends UiBinder<PopupPanel, MapInfoPanel> {+ }++ @UiField+ ManagerMessages managerMessages;++ @UiField+ WidgetStyle widgetStyle;++ public MapInfoPanel() {+ super(GWT.create(UI.class));+ }++ public void addStyleName(String styleName) {+ getPopupPanel().addStyleName(styleName);+ }+}diff --git a/manager/client/src/main/java/org/openremote/manager/client/map/MapInfoPanel.ui.xml b/manager/client/src/main/java/org/openremote/manager/client/map/MapInfoPanel.ui.xmlnew file mode 100644index 000000000..f02d892ce--- /dev/null+++ b/manager/client/src/main/java/org/openremote/manager/client/map/MapInfoPanel.ui.xml@@ -0,0 +1,28 @@+<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"+ xmlns:g="urn:import:com.google.gwt.user.client.ui"+ xmlns:w="urn:import:org.openremote.manager.client.widget">++ <ui:with field="managerMessages" type="org.openremote.manager.client.i18n.ManagerMessages"/>+ <ui:with field="widgetStyle" type="org.openremote.manager.client.style.WidgetStyle"/>++ <ui:style>+ .popup {+ z-index: 10;+ }++ .content {+ overflow: auto;+ padding: 0.4em;+ }+ </ui:style>++ <g:PopupPanel glassEnabled="false" addStyleNames="{style.popup} {widgetStyle.PopupPanel}">+ <g:HTMLPanel styleName="flex layout vertical"+ addStyleNames="{style.content} {widgetStyle.PopupPanelContent}">++ <div>TODO: Asset Info Panel</div>++ </g:HTMLPanel>+ </g:PopupPanel>++</ui:UiBinder>diff --git a/manager/client/src/main/java/org/openremote/manager/client/map/MapViewImpl.java b/manager/client/src/main/java/org/openremote/manager/client/map/MapViewImpl.javaindex c881aeea2..0169560c1 100644--- a/manager/client/src/main/java/org/openremote/manager/client/map/MapViewImpl.java+++ b/manager/client/src/main/java/org/openremote/manager/client/map/MapViewImpl.java@@ -21,11 +21,13 @@ package org.openremote.manager.client.map;import com.google.gwt.core.client.GWT;import com.google.gwt.core.client.Scheduler;+import com.google.gwt.resources.client.CssResource;import com.google.gwt.uibinder.client.UiBinder;import com.google.gwt.uibinder.client.UiField;import com.google.gwt.user.client.ui.Composite;import com.google.gwt.user.client.ui.HTMLPanel;import com.google.gwt.user.client.ui.Label;+import com.google.inject.Provider;import elemental.json.JsonObject;import org.openremote.manager.client.assets.browser.AssetBrowser;import org.openremote.manager.client.widget.FlexSplitPanel;@@ -42,6 +44,24 @@ public class MapViewImpl extends Composite implements MapView {interface UI extends UiBinder<FlexSplitPanel, MapViewImpl> {}+ public interface Style extends CssResource {++ String mapLoadingLabel();++ String navItem();++ String mapControls();++ String mapWidget();++ String infoPanel1();++ String infoPanel2();+ }++ @UiField+ Style style;+@UiFieldFlexSplitPanel splitPanel;@@ -55,12 +75,16 @@ public class MapViewImpl extends Composite implements MapView {MapWidget mapWidget;final AssetBrowser assetBrowser;+ final Provider<MapInfoPanel> infoPanelProvider;+ final MapInfoPanel infoPanel1;+ final MapInfoPanel infoPanel2;Presenter presenter;@Inject- public MapViewImpl(AssetBrowser assetBrowser) {+ public MapViewImpl(AssetBrowser assetBrowser, Provider<MapInfoPanel> infoPanelProvider) {this.assetBrowser = assetBrowser;+ this.infoPanelProvider = infoPanelProvider;UI ui = GWT.create(UI.class);initWidget(ui.createAndBindUi(this));@@ -69,6 +93,11 @@ public class MapViewImpl extends Composite implements MapView {mapLoadingLabel.setVisible(true);mapWidget.setVisible(false);++ infoPanel1 = infoPanelProvider.get();+ infoPanel1.addStyleName(style.infoPanel1());+ infoPanel2 = infoPanelProvider.get();+ infoPanel2.addStyleName(style.infoPanel2());}@Override@@ -77,10 +106,14 @@ public class MapViewImpl extends Composite implements MapView {if (presenter != null) {assetBrowser.asWidget().removeFromParent();sidebarContainer.add(assetBrowser.asWidget());+ if (isMapInitialised()) {+ showInfoPanels();+ }} else {sidebarContainer.clear();hideFeaturesAll();hideFeaturesSelection();+ hideInfoPanels();}}@@ -92,6 +125,7 @@ public class MapViewImpl extends Composite implements MapView {mapWidget.addNavigationControl();mapWidget.setVisible(true);mapWidget.resize();+ showInfoPanels();});}@@ -103,6 +137,7 @@ public class MapViewImpl extends Composite implements MapView {@Overridepublic void refresh() {mapWidget.resize();+ showInfoPanels();}@Override@@ -129,4 +164,14 @@ public class MapViewImpl extends Composite implements MapView {public void flyTo(double[] coordinates) {mapWidget.flyTo(coordinates);}++ protected void showInfoPanels() {+ infoPanel1.showTopLeftOf(mapWidget, 10, 10);+ infoPanel2.showBottomRightOf(mapWidget, 10, 30);+ }++ protected void hideInfoPanels() {+ infoPanel1.hide();+ infoPanel2.hide();+ }}diff --git a/manager/client/src/main/java/org/openremote/manager/client/map/MapViewImpl.ui.xml b/manager/client/src/main/java/org/openremote/manager/client/map/MapViewImpl.ui.xmlindex e5f79eb10..938730a7d 100644--- a/manager/client/src/main/java/org/openremote/manager/client/map/MapViewImpl.ui.xml+++ b/manager/client/src/main/java/org/openremote/manager/client/map/MapViewImpl.ui.xml@@ -5,7 +5,7 @@<ui:with field="managerMessages" type="org.openremote.manager.client.i18n.ManagerMessages"/><ui:with field="widgetStyle" type="org.openremote.manager.client.style.WidgetStyle"/>- <ui:style>+ <ui:style type="org.openremote.manager.client.map.MapViewImpl.Style">.navItem {margin: 0 1em;}@@ -23,6 +23,16 @@.mapControls {z-index: 1;}++ .infoPanel1 {+ width: 8em;+ height: 5em;+ }++ .infoPanel2 {+ width: 15em;+ height: 6em;+ }</ui:style><w:FlexSplitPanel ui:field="splitPanel"diff --git a/manager/client/src/main/java/org/openremote/manager/client/user/UserControlsImpl.ui.xml b/manager/client/src/main/java/org/openremote/manager/client/user/UserControlsImpl.ui.xmlindex 7ae9e07c9..9f26a7ac0 100644--- a/manager/client/src/main/java/org/openremote/manager/client/user/UserControlsImpl.ui.xml+++ b/manager/client/src/main/java/org/openremote/manager/client/user/UserControlsImpl.ui.xml@@ -28,10 +28,6 @@padding: 0.4em;}- .grid {- flex: auto;- }-.footer {padding: 0.4em;}diff --git a/manager/client/src/main/java/org/openremote/manager/client/widget/AbstractAppPanel.java b/manager/client/src/main/java/org/openremote/manager/client/widget/AbstractAppPanel.javaindex 3ce601a32..485071bc8 100644--- a/manager/client/src/main/java/org/openremote/manager/client/widget/AbstractAppPanel.java+++ b/manager/client/src/main/java/org/openremote/manager/client/widget/AbstractAppPanel.java@@ -29,6 +29,12 @@ public abstract class AbstractAppPanel implements AppPanel {final protected PopupPanel popupPanel;protected UIObject target;+ protected int marginTop;+ protected int marginRight;+ protected int marginBottom;+ protected int marginLeft;+ protected UIObject bottomRightTarget;+ protected UIObject topLeftTarget;public AbstractAppPanel(UiBinder<PopupPanel, AbstractAppPanel> binder) {this.popupPanel = binder.createAndBindUi(this);@@ -44,8 +50,14 @@ public abstract class AbstractAppPanel implements AppPanel {});Window.addResizeHandler(event -> {- if (isShowing() && target != null) {- popupPanel.showRelativeTo(target);+ if (isShowing()) {+ if (target != null) {+ popupPanel.showRelativeTo(target);+ } else if (bottomRightTarget != null) {+ showBottomRightOf(bottomRightTarget, marginRight, marginBottom);+ } else if (topLeftTarget != null) {+ showTopLeftOf(topLeftTarget, marginTop, marginLeft);+ }}});}@@ -81,6 +93,32 @@ public abstract class AbstractAppPanel implements AppPanel {this.target = target;}+ public void showBottomRightOf(UIObject bottomRightTarget, int marginRight, int marginBottom) {+ this.bottomRightTarget = bottomRightTarget;+ this.marginRight = marginRight;+ this.marginBottom = marginBottom;+ getPopupPanel().setPopupPositionAndShow((offsetWidth, offsetHeight) -> {+ int bottom = bottomRightTarget.getAbsoluteTop() + bottomRightTarget.getOffsetHeight();+ int right = bottomRightTarget.getAbsoluteLeft() + bottomRightTarget.getOffsetWidth();+ int top = bottom - offsetHeight - marginBottom;+ int left = right - offsetWidth - marginRight;+ getPopupPanel().setPopupPosition(left, top);+ }+ );+ }++ public void showTopLeftOf(UIObject topLeftTarget, int marginTop, int marginLeft) {+ this.topLeftTarget = topLeftTarget;+ this.marginTop = marginTop;+ this.marginLeft = marginLeft;+ getPopupPanel().setPopupPositionAndShow((offsetWidth, offsetHeight) -> {+ int top = topLeftTarget.getAbsoluteTop() + marginTop;+ int left = topLeftTarget.getAbsoluteLeft() + marginLeft;+ getPopupPanel().setPopupPosition(left, top);+ }+ );+ }+@Overridepublic void toggle() {if (isShowing()) {