Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

GADGETS-30: updated the tabLayout.

  • Loading branch information...
commit e38009ab3a3b3f9241bb83ebfb7802de47eec79b 1 parent de03fe8
@jeffyu jeffyu authored
View
3  gadget-web/src/main/java/org/overlord/gadgets/web/client/view/IndexViewImpl.java
@@ -24,6 +24,7 @@
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.Response;
+import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.*;
import com.google.inject.Inject;
import com.gwtplatform.mvp.client.ViewImpl;
@@ -105,7 +106,7 @@ public void onClick(ClickEvent event) {
new PlaceRequest(NameTokens.WIDGET_STORE)
);
} else {
- alertWindow("You need to create a Page before adding widgets from Widget Store!");
+ Window.alert("You need to create a Page before adding widgets from Widget Store!");
}
}
});
View
7 gadget-web/src/main/java/org/overlord/gadgets/web/client/widgets/Portlet.java
@@ -98,14 +98,13 @@ public void onClick(ClickEvent clickEvent) {
String theURL = URLBuilder.getRemoveWidgetURL(Long.valueOf(widgetId));
RestfulInvoker.invoke(RequestBuilder.POST, theURL,
null, new RestfulInvoker.Response() {
-
- public void onResponseReceived(Request request, Response response) {
- remove(id);
+ public void onResponseReceived(Request request, Response response) {
+ remove(id);
}
});
}
});
-
+
maxBtn.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
maximizeWindow(id, portalId);
View
28 gadget-web/src/main/java/org/overlord/gadgets/web/client/widgets/TabLayout.java
@@ -142,6 +142,8 @@ public void insertTab(String pageId, String tabTitle, Widget widget) {
tabsBar.add(addTabAnchorItem);
+ hidePrompt(promptId);
+
}
private String getTabContentId(String pageId) {
@@ -179,12 +181,17 @@ private void setCurrentPage(Long indexId) {
}
private void removePage(Long indexId) {
- String theIndexId = String.valueOf(indexId);
+ final String theIndexId = String.valueOf(indexId);
String pageId = indexIdMap.get(theIndexId);
- indexIdMap.remove(theIndexId);
+
RestfulInvoker.invoke(RequestBuilder.POST, URLBuilder.getRemovePageURL(Long.valueOf(pageId).longValue()),
null, new RestfulInvoker.Response() {
public void onResponseReceived(Request request, Response response) {
+ indexIdMap.remove(theIndexId);
+ if (indexIdMap.size() == 0) {
+ updateUserCurrentPageId(0);
+ showPrompt(promptId);
+ }
}
});
}
@@ -247,16 +254,15 @@ private static native void showPrompt(String promptId) /*-{
/**
* TODO: This is a hack, somehow couldn't attach the click event to removetBtn;
- * */
+ * if (confirm('Are you sure to delete the page?')) not working properly, it will trigger confirm window multiple times.
+ **/
private static native void registerCloseEvent(final TabLayout layout, String id) /*-{
- $wnd.$('#'+id + ' span.ui-icon-close').live('click', function(){
- if (confirm('Are you sure to delete the page?')) {
- var theTabs = $wnd.$('#'+id).tabs();
- var index = $wnd.$(this).parent().index();
- if (index > -1) {
- layout.@org.overlord.gadgets.web.client.widgets.TabLayout::removePage(Ljava/lang/Long;)(index);
- theTabs.tabs('remove', index);
- }
+ $wnd.$('#'+id + ' span.ui-icon-close').live('click', function(){
+ var theTabs = $wnd.$('#'+id).tabs();
+ var index = $wnd.$(this).parent().index();
+ if (index > -1) {
+ layout.@org.overlord.gadgets.web.client.widgets.TabLayout::removePage(Ljava/lang/Long;)(index);
+ theTabs.tabs('remove', index);
}
});
}-*/;
Please sign in to comment.
Something went wrong with that request. Please try again.