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.CheckBoxSelectIemsEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEvent; 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.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.ShowItemEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowItemEventHandler; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowItemEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEvent; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEvent;
@ -43,7 +45,6 @@ public class CkanContentModeratorWidgetController {
private ContentModeratorToolbar toolbar; private ContentModeratorToolbar toolbar;
private MainTabPanel mainTabPanel = new MainTabPanel(); private MainTabPanel mainTabPanel = new MainTabPanel();
private Boolean isContentModeratorEnabled = null; private Boolean isContentModeratorEnabled = null;
private ContentModeratorPaginatedView paginatedView;
public final static HandlerManager eventBus = new HandlerManager(null); public final static HandlerManager eventBus = new HandlerManager(null);
private HomeView howeView; private HomeView howeView;
@ -119,6 +120,14 @@ public class CkanContentModeratorWidgetController {
howeView.setCheckedCheckboxSelectAll(false); 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; package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus; 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.Dropdown;
import com.github.gwtbootstrap.client.ui.NavLink; import com.github.gwtbootstrap.client.ui.NavLink;
@ -23,12 +24,28 @@ public class ContentModeratorToolbar extends Composite {
@UiField @UiField
Dropdown dropdownSelectStatus; Dropdown dropdownSelectStatus;
@UiField
NavLink closeAllTabs;
private HandlerManager eventBus; private HandlerManager eventBus;
public ContentModeratorToolbar(HandlerManager eventBus) { public ContentModeratorToolbar(HandlerManager eventBus) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
this.eventBus = eventBus; this.eventBus = eventBus;
fillItemStatusOptions(); fillItemStatusOptions();
bindEvents();
}
private void bindEvents() {
closeAllTabs.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
eventBus.fireEvent(new CloseAllTabsEvent());
}
});
} }
private void fillItemStatusOptions() { private void fillItemStatusOptions() {

View File

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

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui; package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util.UtilFunct; 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.Composite;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
// TODO: Auto-generated Javadoc
/** /**
* The Class MainTabPanel. * The Class MainTabPanel.
* *
@ -71,7 +73,7 @@ public class MainTabPanel extends Composite {
* @param w the w * @param w the w
* @return the tab * @return the tab
*/ */
public Tab addTab(String heading, Widget w){ public Tab addTab(String heading, Widget w) {
Tab tab = new Tab(); Tab tab = new Tab();
tab.setIcon(IconType.BOOK); tab.setIcon(IconType.BOOK);
tab.addClickHandler(new ClickHandler() { tab.addClickHandler(new ClickHandler() {
@ -85,7 +87,7 @@ public class MainTabPanel extends Composite {
String shortTitle = UtilFunct.ellipsis(heading, 20, false); String shortTitle = UtilFunct.ellipsis(heading, 20, false);
tab.asWidget().setTitle(heading); tab.asWidget().setTitle(heading);
tab.setHeading(shortTitle); tab.setHeading(shortTitle);
if(w!=null) if (w != null)
tab.add(w); tab.add(w);
results.add(tab); results.add(tab);
@ -96,7 +98,7 @@ public class MainTabPanel extends Composite {
@Override @Override
public void execute() { 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(); 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);
}
}
} }