task_21363 #1

Closed
francesco.mangiacrapa wants to merge 53 commits from task_21363 into master
11 changed files with 306 additions and 130 deletions
Showing only changes of commit 9977824106 - Show all commits

View File

@ -9,8 +9,11 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEv
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CloseAllTabsEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CloseAllTabsEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStausEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStausEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.IFrameInstanciedEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.IFrameInstanciedEvent.OPERATION;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.IFrameInstanciedEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStatusEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStatusEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowItemEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowItemEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEvent;
@ -104,6 +107,28 @@ public class CkanContentModeratorWidgetController {
}
});
eventBus.addHandler(IFrameInstanciedEvent.TYPE, new IFrameInstanciedEventHandler() {
@Override
public void onIFrameAction(IFrameInstanciedEvent iFrameInstanciedEent) {
OPERATION operation = iFrameInstanciedEent.getOperation();
if (operation != null) {
switch (operation) {
case INIT:
break;
case ONLOAD:
break;
default:
break;
}
}
}
});
eventBus.addHandler(CheckBoxSelectIemsEvent.TYPE, new CheckBoxSelectIemsEventHandler() {
@Override
@ -130,15 +155,15 @@ public class CkanContentModeratorWidgetController {
}
});
eventBus.addHandler(SelectItemsWithItemStausEvent.TYPE, new SelectItemsWithItemStausEventHandler() {
eventBus.addHandler(SelectItemsWithItemStatusEvent.TYPE, new SelectItemsWithItemStatusEventHandler() {
@Override
public void onValueChanged(SelectItemsWithItemStausEvent statusSelectedEvent) {
if(statusSelectedEvent.getItemStatus()!=null) {
public void onValueChanged(SelectItemsWithItemStatusEvent statusSelectedEvent) {
GWT.log("On value changed: "+statusSelectedEvent.getItemStatus());
if (statusSelectedEvent.getItemStatus() != null) {
howeView.loadItemsWithStatus(statusSelectedEvent.getItemStatus());
mainTabPanel.selectTab(0);
}
}
});

View File

@ -4,26 +4,48 @@ import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.user.client.ui.Frame;
/**
* The Class NotifyLogoutEvent.
* The Class IFrameInstanciedEvent.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 23, 2016
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 28, 2021
*/
public class IFrameInstanciedEvent extends GwtEvent<IFrameInstanciedEventHandler> {
public static Type<IFrameInstanciedEventHandler> TYPE = new Type<IFrameInstanciedEventHandler>();
private Frame iFrame;
private OPERATION operation;
/**
* The Enum OPERATION.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 28, 2021
*/
public static enum OPERATION {
INIT, ONLOAD
}
/**
* Instantiates a new insert metadata event.
*
* @param iFrame the i frame
* @param operation the operation
*/
public IFrameInstanciedEvent(Frame iFrame) {
public IFrameInstanciedEvent(Frame iFrame, OPERATION operation) {
this.iFrame = iFrame;
this.operation = operation;
}
/* (non-Javadoc)
/**
* Gets the associated type.
*
* @return the associated type
*/
/*
* (non-Javadoc)
*
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
*/
@Override
@ -31,16 +53,39 @@ public class IFrameInstanciedEvent extends GwtEvent<IFrameInstanciedEventHandler
return TYPE;
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
/**
* Dispatch.
*
* @param handler the handler
*/
/*
* (non-Javadoc)
*
* @see
* com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.
* EventHandler)
*/
@Override
protected void dispatch(IFrameInstanciedEventHandler handler) {
handler.onNewInstance(this);
handler.onIFrameAction(this);
}
/**
* Gets the i frame.
*
* @return the i frame
*/
public Frame getiFrame() {
return iFrame;
}
/**
* Gets the operation.
*
* @return the operation
*/
public OPERATION getOperation() {
return operation;
}
}

View File

@ -3,21 +3,21 @@ package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface IFrameInstanciedEentHandler.
* The Interface IFrameInstanciedEventHandler.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 23, 2016
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 28, 2021
*/
public interface IFrameInstanciedEventHandler extends EventHandler {
/**
* On new instance.
* On I frame action.
*
* @param iFrameInstanciedEent the i frame instancied eent
*/
void onNewInstance(IFrameInstanciedEvent iFrameInstanciedEent);
void onIFrameAction(IFrameInstanciedEvent iFrameInstanciedEent);
}

View File

@ -4,16 +4,15 @@ import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class SelectItemsWithItemStausEvent.
* The Class SelectItemsWithItemStatusEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 25, 2021
* Jun 28, 2021
*/
public class SelectItemsWithItemStausEvent extends GwtEvent<SelectItemsWithItemStausEventHandler> {
public static Type<SelectItemsWithItemStausEventHandler> TYPE = new Type<SelectItemsWithItemStausEventHandler>();
public class SelectItemsWithItemStatusEvent extends GwtEvent<SelectItemsWithItemStatusEventHandler> {
public static Type<SelectItemsWithItemStatusEventHandler> TYPE = new Type<SelectItemsWithItemStatusEventHandler>();
private ItemStatus itemStatus;
/**
@ -21,7 +20,7 @@ public class SelectItemsWithItemStausEvent extends GwtEvent<SelectItemsWithItemS
*
* @param itemStatus the item status
*/
public SelectItemsWithItemStausEvent(ItemStatus itemStatus) {
public SelectItemsWithItemStatusEvent(ItemStatus itemStatus) {
this.itemStatus = itemStatus;
}
@ -31,7 +30,7 @@ public class SelectItemsWithItemStausEvent extends GwtEvent<SelectItemsWithItemS
* @return the associated type
*/
@Override
public Type<SelectItemsWithItemStausEventHandler> getAssociatedType() {
public Type<SelectItemsWithItemStatusEventHandler> getAssociatedType() {
return TYPE;
}
@ -41,7 +40,7 @@ public class SelectItemsWithItemStausEvent extends GwtEvent<SelectItemsWithItemS
* @param handler the handler
*/
@Override
protected void dispatch(SelectItemsWithItemStausEventHandler handler) {
protected void dispatch(SelectItemsWithItemStatusEventHandler handler) {
handler.onValueChanged(this);
}

View File

@ -4,18 +4,18 @@ import com.google.gwt.event.shared.EventHandler;
/**
* The Interface SelectItemsWithItemStausEventHandler.
* The Interface SelectItemsWithItemStatusEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 25, 2021
* Jun 28, 2021
*/
public interface SelectItemsWithItemStausEventHandler extends EventHandler {
public interface SelectItemsWithItemStatusEventHandler extends EventHandler {
/**
* On value changed.
*
* @param statusSelectedEvent the status selected event
*/
void onValueChanged(SelectItemsWithItemStausEvent statusSelectedEvent);
void onValueChanged(SelectItemsWithItemStatusEvent statusSelectedEvent);
}

View File

@ -4,6 +4,7 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.IFrameInstanciedEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.IFrameInstanciedEvent.OPERATION;
import org.gcube.portlets.widgets.ckancontentmoderator.client.resources.ContentModeratorWidgetResources;
import com.google.gwt.core.shared.GWT;
@ -107,6 +108,7 @@ public class CkanFramePanel extends FlowPanel{
public void onLoad(LoadEvent arg0) {
CkanFramePanel.this.remove(loading);
eventBus.fireEvent(new IFrameInstanciedEvent(frame, OPERATION.ONLOAD));
if(messageToSend!=null)
sendMessage(messageToSend, iFrameRandomName);
@ -114,7 +116,7 @@ public class CkanFramePanel extends FlowPanel{
});
add(frame);
frame.setVisible(true);
eventBus.fireEvent(new IFrameInstanciedEvent(frame));
eventBus.fireEvent(new IFrameInstanciedEvent(frame, OPERATION.INIT));
return frame;
}

View File

@ -25,10 +25,12 @@ import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.AsyncDataProvider;
import com.google.gwt.view.client.HasData;
import com.google.gwt.view.client.MultiSelectionModel;
import com.google.gwt.view.client.Range;
import com.google.gwt.view.client.SelectionModel;
import com.google.gwt.view.client.SingleSelectionModel;
// TODO: Auto-generated Javadoc
/**
* The Class ContentModeratorPaginatedView.
*
@ -53,9 +55,8 @@ public class ContentModeratorPaginatedView {
/**
* Instantiates a new content moderator paginated view.
*
* @param eventbus
*
* @param eventbus the eventbus
* @param theStatus the the status
* @param displayFields the display fields
* @param sortByField the sort by field
@ -70,7 +71,7 @@ public class ContentModeratorPaginatedView {
orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator();
initPagination(ITEMS_PER_PAGE);
//loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, false);
// loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, false);
loadItemsForStatus(theStatus);
}
@ -145,9 +146,8 @@ public class ContentModeratorPaginatedView {
* @param resetStore the reset store
*/
private void loadNewPage(final int startIdx, final int limit, final boolean resetStore) {
//initFirstRangeChanged = resetStore;
GWT.log("loading data with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:"
+ resetStore + "]");
// initFirstRangeChanged = resetStore;
GWT.log("loadNewPage with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:"+ resetStore + "]");
// showLoading(true);
int newStartIndex = startIdx;
@ -158,14 +158,17 @@ public class ContentModeratorPaginatedView {
serverStartIndex = 0;
GWT.log("Store reset performed start index is: " + newStartIndex);
getAsycnDataProvider().updateRowCount(ITEMS_PER_PAGE, false);
// newLoading = false;
}
loadItemsForStatus(itemStatus, newStartIndex, limit, serverStartIndex);
}
/**
* Load items for status.
*
* @param itemStatus the item status
*/
public void loadItemsForStatus(ItemStatus itemStatus) {
this.itemStatus = itemStatus;
getCellTable().setVisibleRangeAndClearData(new Range(0, ITEMS_PER_PAGE), false);
@ -178,18 +181,16 @@ public class ContentModeratorPaginatedView {
* @param result the new new page result
*/
private void setNewPageResult(SearchedData result) {
GWT.log("setNewPageResult: "+result);
serverStartIndex = result.getServerEndIndex();
// if (initFirstRangeChanged) {
// getCellTable().setVisibleRangeAndClearData(new Range(result.getClientStartIndex(), ITEMS_PER_PAGE), false);
// }
SelectionModel<? super CatalogueDataset> sm = getCellTable().getSelectionModel();
if (sm instanceof SingleSelectionModel) {
SingleSelectionModel<CatalogueDataset> ssm = (SingleSelectionModel<CatalogueDataset>) sm;
ssm.clear();
}else if (sm instanceof MultiSelectionModel) {
MultiSelectionModel<CatalogueDataset> msm = (MultiSelectionModel<CatalogueDataset>) sm;
msm.clear();
}
getAsycnDataProvider().updateRowCount((int) result.getTotalItems(), true);
@ -209,7 +210,7 @@ public class ContentModeratorPaginatedView {
GWT.log("Search finished!!!");
getAsycnDataProvider().updateRowCount(getCellTable().getRowCount(), true);
}
//initFirstRangeChanged = false;
// initFirstRangeChanged = false;
}
@ -244,6 +245,31 @@ public class ContentModeratorPaginatedView {
}
/**
* Select items.
*
* @param select the select
* @param limitToPage the limit to page
*/
public void selectItems(boolean select, boolean limitToPage) {
SortedCellTable<CatalogueDataset> table = getCellTable();
int rowSize = table.getVisibleItemCount();
for (int i = 0; i < rowSize; i++) {
CatalogueDataset item = table.getVisibleItem(i);
itemsTable.getSelectionModel().setSelected(item, select);
}
}
/**
* Gets the select items.
*
* @return the select items
*/
public List<CatalogueDataset> getSelectItems() {
return itemsTable.getSelectedItems();
}
/**
* A custom {@link AsyncDataProvider}.
*
@ -281,14 +307,4 @@ public class ContentModeratorPaginatedView {
}
public void selectItems(boolean select, boolean limitToPage) {
SortedCellTable<CatalogueDataset> table = getCellTable();
int rowSize = table.getVisibleItemCount();
for (int i = 0; i < rowSize; i++) {
CatalogueDataset item = table.getVisibleItem(i);
itemsTable.getSelectionModel().setSelected(item, select);
}
}
}

View File

@ -2,7 +2,7 @@ package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CloseAllTabsEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStausEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStatusEvent;
import com.github.gwtbootstrap.client.ui.Dropdown;
import com.github.gwtbootstrap.client.ui.Label;
@ -39,10 +39,10 @@ public class ContentModeratorToolbar extends Composite {
public ContentModeratorToolbar(HandlerManager eventBus, ItemStatus status) {
initWidget(uiBinder.createAndBindUi(this));
this.eventBus = eventBus;
//statusInfo.setReadOnly(true);
setActiveStatus(status);
fillItemStatusOptions();
bindEvents();
setActiveStatus(status);
}
private void bindEvents() {
@ -59,24 +59,25 @@ public class ContentModeratorToolbar extends Composite {
private void fillItemStatusOptions() {
for (final ItemStatus status : ItemStatus.values()) {
NavLink link = new NavLink();
link.setText(status.getLabel());
link.addClickHandler(new ClickHandler() {
NavLink navLink = new NavLink();
navLink.setText(status.getLabel());
navLink.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
GWT.log("clicked: "+status);
setActiveStatus(status);
eventBus.fireEvent(new SelectItemsWithItemStausEvent(activeStatus));
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(status));
}
});
dropdownSelectStatus.add(link);
dropdownSelectStatus.add(navLink);
}
}
private void setActiveStatus(ItemStatus status) {
this.activeStatus = status;
statusInfo.setText(activeStatus.getLabel());
this.statusInfo.setText(activeStatus.getLabel());
}

View File

@ -14,7 +14,12 @@ import com.github.gwtbootstrap.client.ui.CheckBox;
import com.github.gwtbootstrap.client.ui.Dropdown;
import com.github.gwtbootstrap.client.ui.Heading;
import com.github.gwtbootstrap.client.ui.NavLink;
import com.github.gwtbootstrap.client.ui.base.AlertBase;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.github.gwtbootstrap.client.ui.event.ClosedEvent;
import com.github.gwtbootstrap.client.ui.event.ClosedHandler;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
@ -24,6 +29,7 @@ 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.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
// TODO: Auto-generated Javadoc
@ -32,7 +38,7 @@ import com.google.gwt.user.client.ui.Widget;
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 22, 2021
* Jun 22, 2021
*/
public class HomeView extends Composite {
@ -51,28 +57,26 @@ public class HomeView extends Composite {
@UiField
Heading pageHeader;
@UiField
AlertBlock actionConfirmAlert;
@UiField
Button buttActionConfirmYes;
@UiField
Button buttonActionConfirmNo;
private List<NavLink> setStatusOptions = new ArrayList<>();
@UiField
HTMLPanel confirmPanel;
private ScrollPanel confirmPanelContainer = new ScrollPanel();
private List<NavLink> setStatusOptions = new ArrayList<NavLink>();
private ItemStatus displayingItemStatus;
private HandlerManager eventBus;
private List<CatalogueDataset> selectedItems;
/**
* The Interface HomeViewUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 22, 2021
* Jun 22, 2021
*/
interface HomeViewUiBinder extends UiBinder<Widget, HomeView> {
}
@ -80,10 +84,10 @@ public class HomeView extends Composite {
/**
* Instantiates a new home view.
*
* @param eventBus the event bus
* @param status the status
* @param eventBus the event bus
* @param status the status
* @param displayFields the display fields
* @param sortByField the sort by field
* @param sortByField the sort by field
*/
public HomeView(HandlerManager eventBus, ItemStatus status, DISPLAY_FIELD[] displayFields,
DISPLAY_FIELD sortByField) {
@ -95,9 +99,9 @@ public class HomeView extends Composite {
cmsPanel.addToBottom(paginatedView.getPagerPanel());
panelContainer.add(cmsPanel.getPanel());
setVisibleUpdateStatusAction(false);
fillSetStatusOptions();
bindEvents();
confirmPanel.add(confirmPanelContainer);
}
/**
@ -113,7 +117,7 @@ public class HomeView extends Composite {
}
}
private void setDisplayingWithStatus(ItemStatus status) {
this.displayingItemStatus = status;
this.pageHeader.setSubtext(status.getLabel());
@ -133,25 +137,32 @@ public class HomeView extends Composite {
}
});
buttActionConfirmYes.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
}
});
buttonActionConfirmNo.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
actionConfirmAlert.setVisible(false);
}
});
for (final NavLink navLink : setStatusOptions) {
navLink.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
selectedItems = paginatedView.getSelectItems();
int count = selectedItems.size();
String msg = "Going to update status of";
if (count > 0) {
if (count == 1) {
msg += " one item";
} else {
msg += " " + count + " items";
}
msg += " from <b>" + displayingItemStatus.getLabel() + "</b> to <b>" + navLink.getText()
+ "</b>. Confirm?";
}else
return;
showConfirm(msg);
}
});
}
}
/**
@ -175,7 +186,7 @@ public class HomeView extends Composite {
/**
* Mark items as checked.
*
* @param select the select
* @param select the select
* @param limitToPage the limit to page
*/
public void markItemsAsChecked(boolean select, boolean limitToPage) {
@ -190,15 +201,52 @@ public class HomeView extends Composite {
public void setCheckedCheckboxSelectAll(boolean bool) {
cbSelectAll.setValue(bool);
}
/**
* Show confirm.
*
* @param msg the msg
*/
public void showConfirm(String msg) {
actionConfirmAlert.setVisible(true);
confirmPanelContainer.clear();
final AlertBlock newAlertBlock = new AlertBlock(AlertType.DEFAULT);
newAlertBlock.setAnimation(true);
newAlertBlock.setClose(true);
newAlertBlock.addClosedHandler(new ClosedHandler<AlertBase>() {
@Override
public void onClosed(ClosedEvent<AlertBase> event) {
confirmPanelContainer.clear();
}
});
Button buttActionConfirmYes = new Button(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
confirmPanelContainer.clear();
}
});
buttActionConfirmYes.getElement().getStyle().setMarginLeft(10, Unit.PX);
buttActionConfirmYes.setText("YES");
newAlertBlock.add(buttActionConfirmYes);
Button buttonActionConfirmNo = new Button(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
confirmPanelContainer.clear();
}
});
buttonActionConfirmNo.getElement().getStyle().setMarginLeft(10, Unit.PX);
buttonActionConfirmNo.setText("NO");
newAlertBlock.add(buttonActionConfirmNo);
newAlertBlock.setHTML(msg);
confirmPanelContainer.add(newAlertBlock);
}
/**
@ -207,10 +255,19 @@ public class HomeView extends Composite {
* @param itemStatus the item status
*/
public void loadItemsWithStatus(ItemStatus itemStatus) {
GWT.log("loadItemsWithStatus started");
setDisplayingWithStatus(itemStatus);
setCheckedCheckboxSelectAll(false);
setVisibleUpdateStatusAction(false);
try {
confirmPanelContainer.clear();
}catch (Exception e) {
GWT.log("error: "+e.getMessage() + " cause: "+e.getCause().toString());
}
paginatedView.loadItemsForStatus(itemStatus);
GWT.log("loadItemsWithStatus end");
}
}

View File

@ -35,13 +35,7 @@
ui:field="dropdownSetStatus" addStyleNames="{style.margin-left-20}">
</b:Dropdown>
</g:HorizontalPanel>
<b:AlertBlock type="DEFAULT" close="true"
animation="true" ui:field="actionConfirmAlert" visible="false">
<b:Button ui:field="buttActionConfirmYes">Yes</b:Button>
<b:Button ui:field="buttonActionConfirmNo">No</b:Button>
</b:AlertBlock>
<g:HTMLPanel ui:field="confirmPanel"></g:HTMLPanel>
<g:HTMLPanel ui:field="panelContainer"></g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -13,8 +13,11 @@ import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.LoadEvent;
import com.google.gwt.event.dom.client.LoadHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
@ -73,16 +76,28 @@ public class MainTabPanel extends Composite {
* @return the tab
*/
public Tab addTab(String heading, Widget w) {
Tab tab = new Tab();
tab.setIcon(IconType.BOOK);
final Tab tab = new Tab();
if (w instanceof CkanFramePanel) {
tab.setCustomIconStyle("icon-rotate-right icon-spin");
CkanFramePanel ckanFramePanel = (CkanFramePanel) w;
ckanFramePanel.getFrame().addLoadHandler(new LoadHandler() {
@Override
public void onLoad(LoadEvent event) {
tab.setIcon(IconType.BOOK);
setNoSpinner(tab);
}
});
}
tab.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
}
});
String shortTitle = UtilFunct.ellipsis(heading, 20, false);
tab.asWidget().setTitle(heading);
tab.setHeading(shortTitle);
@ -91,13 +106,13 @@ public class MainTabPanel extends Composite {
results.add(tab);
mainTabPanel.add(tab);
//activeTabPanels(false);
// activeTabPanels(false);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
//mainTabPanel.selectTab(results.size() - 1);
// mainTabPanel.selectTab(results.size() - 1);
}
});
@ -133,11 +148,12 @@ public class MainTabPanel extends Composite {
int tabSize = results.size();
GWT.log("tab size is: " + tabSize);
for (int i = 1; i < tabSize; i++) {
//each remove shifts any subsequent elements to the left, so I'm removing always the first element
mainTabPanel.remove(1);
// each remove shifts any subsequent elements to the left, so I'm removing
// always the first element
mainTabPanel.remove(1);
results.remove(1);
}
//selecting Home Tab
// selecting Home Tab
selectTab(0);
}
@ -147,5 +163,26 @@ public class MainTabPanel extends Composite {
}
}
/**
* Sets the no spinner.
*
* @param tab the new no spinner
*/
private void setNoSpinner(Tab tab) {
try{
tab.asTabLink().getAnchor().removeStyleName("icon-spin");
tab.asTabLink().getAnchor().removeStyleName("icon-rotate-right");
Element anchorElem = tab.asTabLink().getAnchor().asWidget().getElement();
anchorElem.getFirstChildElement().removeClassName("icon-spin");
anchorElem.getFirstChildElement().removeClassName("icon-rotate-right");
}catch(Exception e){
//silent
}
tab.asTabLink().getAnchor().setIcon(IconType.BOOK);
//tab.asTabLink().getAnchor().setVisible(false);
//if(tab.asTabLink().getAnchor().setVisible(false);)
}
}