Skip to content

Commit

Permalink
GADGETS-30: updated the tabLayout.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffyu committed Nov 9, 2012
1 parent de03fe8 commit e38009a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
Expand Up @@ -24,6 +24,7 @@
import com.google.gwt.http.client.Request; import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder; import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.Response; import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.*; import com.google.gwt.user.client.ui.*;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.gwtplatform.mvp.client.ViewImpl; import com.gwtplatform.mvp.client.ViewImpl;
Expand Down Expand Up @@ -105,7 +106,7 @@ public void onClick(ClickEvent event) {
new PlaceRequest(NameTokens.WIDGET_STORE) new PlaceRequest(NameTokens.WIDGET_STORE)
); );
} else { } 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!");
} }
} }
}); });
Expand Down
Expand Up @@ -98,14 +98,13 @@ public void onClick(ClickEvent clickEvent) {
String theURL = URLBuilder.getRemoveWidgetURL(Long.valueOf(widgetId)); String theURL = URLBuilder.getRemoveWidgetURL(Long.valueOf(widgetId));
RestfulInvoker.invoke(RequestBuilder.POST, theURL, RestfulInvoker.invoke(RequestBuilder.POST, theURL,
null, new RestfulInvoker.Response() { null, new RestfulInvoker.Response() {

public void onResponseReceived(Request request, Response response) {
public void onResponseReceived(Request request, Response response) { remove(id);
remove(id);
} }
}); });
} }
}); });

maxBtn.addClickHandler(new ClickHandler(){ maxBtn.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
maximizeWindow(id, portalId); maximizeWindow(id, portalId);
Expand Down
Expand Up @@ -142,6 +142,8 @@ public void insertTab(String pageId, String tabTitle, Widget widget) {


tabsBar.add(addTabAnchorItem); tabsBar.add(addTabAnchorItem);


hidePrompt(promptId);

} }


private String getTabContentId(String pageId) { private String getTabContentId(String pageId) {
Expand Down Expand Up @@ -179,12 +181,17 @@ private void setCurrentPage(Long indexId) {
} }


private void removePage(Long indexId) { private void removePage(Long indexId) {
String theIndexId = String.valueOf(indexId); final String theIndexId = String.valueOf(indexId);
String pageId = indexIdMap.get(theIndexId); String pageId = indexIdMap.get(theIndexId);
indexIdMap.remove(theIndexId);
RestfulInvoker.invoke(RequestBuilder.POST, URLBuilder.getRemovePageURL(Long.valueOf(pageId).longValue()), RestfulInvoker.invoke(RequestBuilder.POST, URLBuilder.getRemovePageURL(Long.valueOf(pageId).longValue()),
null, new RestfulInvoker.Response() { null, new RestfulInvoker.Response() {
public void onResponseReceived(Request request, Response response) { public void onResponseReceived(Request request, Response response) {
indexIdMap.remove(theIndexId);
if (indexIdMap.size() == 0) {
updateUserCurrentPageId(0);
showPrompt(promptId);
}
} }
}); });
} }
Expand Down Expand Up @@ -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; * 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) /*-{ private static native void registerCloseEvent(final TabLayout layout, String id) /*-{
$wnd.$('#'+id + ' span.ui-icon-close').live('click', function(){ $wnd.$('#'+id + ' span.ui-icon-close').live('click', function(){
if (confirm('Are you sure to delete the page?')) { var theTabs = $wnd.$('#'+id).tabs();
var theTabs = $wnd.$('#'+id).tabs(); var index = $wnd.$(this).parent().index();
var index = $wnd.$(this).parent().index(); if (index > -1) {
if (index > -1) { layout.@org.overlord.gadgets.web.client.widgets.TabLayout::removePage(Ljava/lang/Long;)(index);
layout.@org.overlord.gadgets.web.client.widgets.TabLayout::removePage(Ljava/lang/Long;)(index); theTabs.tabs('remove', index);
theTabs.tabs('remove', index);
}
} }
}); });
}-*/; }-*/;
Expand Down

0 comments on commit e38009a

Please sign in to comment.