task_21363 #1

Closed
francesco.mangiacrapa wants to merge 53 commits from task_21363 into master
6 changed files with 129 additions and 13 deletions
Showing only changes of commit 814a0c6661 - Show all commits

View File

@ -7,6 +7,8 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CheckBoxSel
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CheckBoxSelectIemsEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEvent;
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.ShowItemEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowItemEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEvent;
@ -43,7 +45,6 @@ public class CkanContentModeratorWidgetController {
private ContentModeratorToolbar toolbar;
private MainTabPanel mainTabPanel = new MainTabPanel();
private Boolean isContentModeratorEnabled = null;
private ContentModeratorPaginatedView paginatedView;
public final static HandlerManager eventBus = new HandlerManager(null);
private HomeView howeView;
@ -119,6 +120,14 @@ public class CkanContentModeratorWidgetController {
howeView.setCheckedCheckboxSelectAll(false);
}
});
eventBus.addHandler(CloseAllTabsEvent.TYPE, new CloseAllTabsEventHandler() {
@Override
public void onClick(CloseAllTabsEvent closeAllTabsEvent) {
mainTabPanel.closeTabs();
}
});
}
/**

View File

@ -0,0 +1,45 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
import com.google.gwt.event.shared.GwtEvent;
// TODO: Auto-generated Javadoc
/**
* The Class CloseAllTabsEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 22, 2021
*/
public class CloseAllTabsEvent extends GwtEvent<CloseAllTabsEventHandler> {
public static Type<CloseAllTabsEventHandler> TYPE = new Type<CloseAllTabsEventHandler>();
/**
* Instantiates a new close all tabs event.
*/
public CloseAllTabsEvent() {
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<CloseAllTabsEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(CloseAllTabsEventHandler handler) {
handler.onClick(this);
}
}

View File

@ -0,0 +1,21 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface CloseAllTabsEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 22, 2021
*/
public interface CloseAllTabsEventHandler extends EventHandler {
/**
* On click.
*
* @param closeAllTabsEvent the close all tabs event
*/
void onClick(CloseAllTabsEvent closeAllTabsEvent);
}

View File

@ -1,6 +1,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 com.github.gwtbootstrap.client.ui.Dropdown;
import com.github.gwtbootstrap.client.ui.NavLink;
@ -23,12 +24,28 @@ public class ContentModeratorToolbar extends Composite {
@UiField
Dropdown dropdownSelectStatus;
@UiField
NavLink closeAllTabs;
private HandlerManager eventBus;
public ContentModeratorToolbar(HandlerManager eventBus) {
initWidget(uiBinder.createAndBindUi(this));
this.eventBus = eventBus;
fillItemStatusOptions();
bindEvents();
}
private void bindEvents() {
closeAllTabs.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
eventBus.fireEvent(new CloseAllTabsEvent());
}
});
}
private void fillItemStatusOptions() {

View File

@ -13,7 +13,7 @@
<b:Dropdown text="Select Items with status..."
ui:field="dropdownSelectStatus">
</b:Dropdown>
<b:NavLink>Close All Tabs
<b:NavLink ui:field="closeAllTabs">Close All Tabs
</b:NavLink>
</b:NavPills>
</g:HTMLPanel>

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util.UtilFunct;
@ -18,6 +19,7 @@ import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
// TODO: Auto-generated Javadoc
/**
* The Class MainTabPanel.
*
@ -71,7 +73,7 @@ public class MainTabPanel extends Composite {
* @param w the w
* @return the tab
*/
public Tab addTab(String heading, Widget w){
public Tab addTab(String heading, Widget w) {
Tab tab = new Tab();
tab.setIcon(IconType.BOOK);
tab.addClickHandler(new ClickHandler() {
@ -85,7 +87,7 @@ public class MainTabPanel extends Composite {
String shortTitle = UtilFunct.ellipsis(heading, 20, false);
tab.asWidget().setTitle(heading);
tab.setHeading(shortTitle);
if(w!=null)
if (w != null)
tab.add(w);
results.add(tab);
@ -96,7 +98,7 @@ public class MainTabPanel extends Composite {
@Override
public void execute() {
mainTabPanel.selectTab(results.size()-1); //+1 because the first tab is "Home"
mainTabPanel.selectTab(results.size() - 1);
}
});
@ -125,4 +127,26 @@ public class MainTabPanel extends Composite {
return results.size();
}
/**
* Close tabs.
*/
public void closeTabs() {
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);
results.remove(1);
}
//selecting Home Tab
selectTab(0);
}
private void selectTab(int tabIndex) {
if (tabIndex <= results.size()) {
mainTabPanel.selectTab(tabIndex);
}
}
}