193 lines
5.7 KiB
Java
193 lines
5.7 KiB
Java
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
|
|
import org.gcube.portlets.widgets.wsexplorer.client.explore.WorkspaceResourcesBExplorerPanel;
|
|
import org.gcube.portlets.widgets.wsexplorer.client.explore.WorkspaceResourcesExplorerPanel;
|
|
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectBNotification.WorskpaceExplorerSelectBNotificationListener;
|
|
import org.gcube.portlets.widgets.wsexplorer.client.view.grid.ItemsTable.DISPLAY_FIELD;
|
|
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
import com.google.gwt.core.client.GWT;
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
|
import com.google.gwt.uibinder.client.UiBinder;
|
|
import com.google.gwt.uibinder.client.UiField;
|
|
import com.google.gwt.user.client.Window;
|
|
import com.google.gwt.user.client.ui.Composite;
|
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
/**
|
|
* The Class SelectResourceByWEMainPanel.
|
|
*
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
*
|
|
* Mar 5, 2021
|
|
*/
|
|
public class SelectResourceByWEMainPanel extends Composite {
|
|
|
|
/** The ui binder. */
|
|
private static SelectResourceByWEMainPanelUiBinder uiBinder = GWT.create(SelectResourceByWEMainPanelUiBinder.class);
|
|
|
|
private static boolean frozen = false;
|
|
private final ResourceElementBean initialBean;
|
|
|
|
@UiField
|
|
VerticalPanel wsContainer;
|
|
@UiField
|
|
VerticalPanel selectResourcesContainer;
|
|
|
|
@UiField
|
|
Button buttSelectResource;
|
|
|
|
private Item selectedWEItem;
|
|
|
|
Map<String, SelectResourceWidget> mapSelectedResources = new HashMap<String, SelectResourceWidget>();
|
|
|
|
/**
|
|
* The Interface SelectResourceByWEMainPanelUiBinder.
|
|
*
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
*
|
|
* Mar 5, 2021
|
|
*/
|
|
interface SelectResourceByWEMainPanelUiBinder extends UiBinder<Widget, SelectResourceByWEMainPanel> {
|
|
}
|
|
|
|
/**
|
|
* Instantiates a new select resource by WE main panel.
|
|
*/
|
|
public SelectResourceByWEMainPanel(ResourceElementBean initialBean) {
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
|
|
this.frozen = false;
|
|
|
|
this.initialBean = initialBean;
|
|
|
|
WorkspaceResourcesExplorerPanel rp = null;
|
|
|
|
DISPLAY_FIELD[] displayFields = new DISPLAY_FIELD[] { DISPLAY_FIELD.ICON, DISPLAY_FIELD.NAME,
|
|
DISPLAY_FIELD.OWNER };
|
|
|
|
try {
|
|
String wsRootId = initialBean.isFolder() ? initialBean.getOriginalIdInWorkspace()
|
|
: initialBean.getParent().getOriginalIdInWorkspace();
|
|
// WorkspaceResourcesBExplorerPanel(String folderId, boolean showOnlyFolders,
|
|
// List<String> showProperties, FilterCriteria filter, boolean showGcubeInfo,
|
|
// DISPLAY_FIELD sortByColumn) throws Exception {
|
|
WorkspaceResourcesBExplorerPanel workspaceExplorerPanel = new WorkspaceResourcesBExplorerPanel(wsRootId,
|
|
false);
|
|
WorskpaceExplorerSelectBNotificationListener wsResourceExplorerListener = new WorskpaceExplorerSelectBNotificationListener() {
|
|
|
|
|
|
|
|
@Override
|
|
public void onSelectedItem(Item item) {
|
|
GWT.log("Listener Selected Item " + item);
|
|
selectedWEItem = item;
|
|
}
|
|
|
|
@Override
|
|
public void onFailed(Throwable throwable) {
|
|
// Log.error(throwable.getLocalizedMessage());
|
|
throwable.printStackTrace();
|
|
}
|
|
|
|
|
|
@Override
|
|
public void onAborted() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onNotValidSelection() {
|
|
selectedWEItem = null;
|
|
}
|
|
|
|
@Override
|
|
public void onBreadcrumbChanged(Item item) {
|
|
GWT.log("Breadcrumb Changed: " + item);
|
|
|
|
}
|
|
};
|
|
|
|
workspaceExplorerPanel.addWorkspaceExplorerSelectNotificationListener(wsResourceExplorerListener);
|
|
wsContainer.add(workspaceExplorerPanel);
|
|
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
if(!initialBean.isFolder()) {
|
|
addSelectResource(initialBean.getOriginalIdInWorkspace(), initialBean.getName(),initialBean.getFullPath());
|
|
}
|
|
|
|
|
|
buttSelectResource.addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
if(selectedWEItem!=null) {
|
|
addSelectResource(selectedWEItem.getId(), selectedWEItem.getName(), selectedWEItem.getPath());
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
public void addSelectResource(String wsItemId, String name, String path) {
|
|
|
|
SelectResourceWidget selWidg = mapSelectedResources.get(wsItemId);
|
|
if (selWidg != null) {
|
|
Window.alert("Item '" + name + "' already selected");
|
|
return;
|
|
}
|
|
|
|
ResourceElementBean rb = new ResourceElementBean();
|
|
rb.setOriginalIdInWorkspace(wsItemId);
|
|
rb.setName(name);
|
|
rb.setFullPath(path);
|
|
rb.setEditableName(name);
|
|
selWidg = new SelectResourceWidget(rb);
|
|
|
|
mapSelectedResources.put(wsItemId, selWidg);
|
|
|
|
selectResourcesContainer.add(selWidg);
|
|
|
|
}
|
|
|
|
public ResourceElementBean getResourcesToPublish() {
|
|
// TODO Auto-generated method stub
|
|
Window.alert("getResourcesToPublish() must be implemented");
|
|
|
|
/*List<ResourceElementBean> current = dataProviderRight.getList();
|
|
|
|
ResourceElementBean toReturn = new ResourceElementBean();
|
|
List<ResourceElementBean> children = new ArrayList<ResourceElementBean>();
|
|
|
|
for (ResourceElementBean resource : current) {
|
|
if(resource.isToBeAdded() && !resource.isFolder()){ // be sure ...
|
|
ResourceElementBean beanWithoutChildren = new ResourceElementBean(resource);
|
|
beanWithoutChildren.setName(resource.getEditableName());
|
|
children.add(beanWithoutChildren);
|
|
}
|
|
}
|
|
|
|
toReturn.setToPublish(children);
|
|
return toReturn;*/
|
|
return null;
|
|
|
|
}
|
|
|
|
public void freeze() {
|
|
// TODO Auto-generated method stub
|
|
Window.alert("freeze() must be implemented");
|
|
}
|
|
|
|
}
|