Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Reload BasicUI if sitemap has been changed
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Triller <stefan.triller@telekom.de>
  • Loading branch information
triller-telekom committed Jul 17, 2017
1 parent 8776d5e commit a373b6c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
Expand Up @@ -267,14 +267,10 @@ public void modelChanged(String modelName, EventType type) {
for (Entry<String, PageChangeListener> listenerEntry : pageChangeListeners.entrySet()) {
String sitemapWithPage = listenerEntry.getKey();
String sitemapName = extractSitemapName(sitemapWithPage);
String pageId = extractPageId(sitemapWithPage);

if (sitemapName.equals(changedSitemapName)) {
EList<Widget> widgets = collectWidgets(sitemapName, pageId);
listenerEntry.getValue().sitemapContentChanged(widgets);
listenerEntry.getValue().sitemapContentChanged();
}
}

}

}
Expand Up @@ -213,8 +213,13 @@ private boolean definesVisibility(Widget w, String name) {
return false;
}

public void sitemapContentChanged(EList<Widget> widgets) {
updateItemsAndWidgets(widgets);
public void sitemapContentChanged() {
for (SitemapSubscriptionCallback callback : distinctCallbacks) {
SitemapChangedEvent changeEvent = new SitemapChangedEvent();
changeEvent.pageId = pageId;
changeEvent.sitemapName = sitemapName;
callback.onEvent(changeEvent);
}
}

}
@@ -0,0 +1,18 @@
/**
* Copyright (c) 2014-2017 by the respective copyright holders.
* 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
*/
package org.eclipse.smarthome.io.rest.sitemap.internal;

/**
* Event to notify the browser that the sitemap has been changed
*
* @author Stefan Triller - Initial Contribution
*
*/
public class SitemapChangedEvent extends SitemapEvent {
public final String TYPE = "SITEMAP_CHANGED";
}
Expand Up @@ -515,7 +515,7 @@ public Widget getWidget(Sitemap sitemap, String id) {
for (int i = 2; i < id.length(); i += 2) {
w = ((LinkableWidget) w).getChildren().get(Integer.valueOf(id.substring(i, i + 2)));
}
} catch (NumberFormatException e) {
} catch (NumberFormatException | IndexOutOfBoundsException e) {
// no valid number, so the requested page id does not exist
}
}
Expand Down

0 comments on commit a373b6c

Please sign in to comment.