256: Workspace explorer
Task-Url: https://support.d4science.org/issues/256 Refactor Updated Explorer git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@115741 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3f81a37a43
commit
f5933696b7
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.widgets.wsexplorer.client.load;
|
package org.gcube.portlets.widgets.wsexplorer.client.select;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -14,12 +14,15 @@ import org.gcube.portlets.widgets.wsexplorer.client.notification.WorskpaceExplor
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.Alert;
|
||||||
import com.github.gwtbootstrap.client.ui.Button;
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
import com.github.gwtbootstrap.client.ui.Modal;
|
import com.github.gwtbootstrap.client.ui.Modal;
|
||||||
import com.github.gwtbootstrap.client.ui.ModalFooter;
|
import com.github.gwtbootstrap.client.ui.ModalFooter;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
||||||
import com.github.gwtbootstrap.client.ui.event.HideEvent;
|
import com.github.gwtbootstrap.client.ui.event.HideEvent;
|
||||||
import com.github.gwtbootstrap.client.ui.event.HideHandler;
|
import com.github.gwtbootstrap.client.ui.event.HideHandler;
|
||||||
|
import com.google.gwt.dom.client.Style.Unit;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
|
|
||||||
|
@ -30,17 +33,18 @@ import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* Jun 30, 2015
|
* Jun 30, 2015
|
||||||
*/
|
*/
|
||||||
public class WorkspaceExplorerLoadDialog extends Modal implements HasWorskpaceExplorerNotificationListener{
|
public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpaceExplorerNotificationListener{
|
||||||
|
|
||||||
public static final String SELECT = "Select";
|
public static final String SELECT = "Select";
|
||||||
public static final String MAX_HEIGHT_DIALOG = "500px";
|
public static final String MAX_HEIGHT_DIALOG = "500px";
|
||||||
public static final int WIDHT_DIALOG = 720;
|
public static final int WIDHT_DIALOG = 720;
|
||||||
|
|
||||||
private Button selectButton;
|
private Button selectButton;
|
||||||
private WorkspaceExplorerLoadDialog INSTANCE = this;
|
private WorkspaceExplorerSelectDialog INSTANCE = this;
|
||||||
private boolean isSelect = false;
|
private boolean isSelect = false;
|
||||||
private String captionTxt;
|
private String captionTxt;
|
||||||
private ModalFooter footer = new ModalFooter();
|
private ModalFooter footer = new ModalFooter();
|
||||||
|
private Alert alertConfirm;
|
||||||
private WorkspaceExplorerController controller = new WorkspaceExplorerController();
|
private WorkspaceExplorerController controller = new WorkspaceExplorerController();
|
||||||
private List<WorskpaceExplorerNotificationListener> listeners = new ArrayList<WorskpaceExplorerNotificationListener>();
|
private List<WorskpaceExplorerNotificationListener> listeners = new ArrayList<WorskpaceExplorerNotificationListener>();
|
||||||
|
|
||||||
|
@ -51,7 +55,7 @@ public class WorkspaceExplorerLoadDialog extends Modal implements HasWorskpaceEx
|
||||||
* @param captionTxt the caption txt
|
* @param captionTxt the caption txt
|
||||||
* You can implement {@link WorskpaceExplorerNotificationListener} to receive events
|
* You can implement {@link WorskpaceExplorerNotificationListener} to receive events
|
||||||
*/
|
*/
|
||||||
public WorkspaceExplorerLoadDialog(String captionTxt) {
|
public WorkspaceExplorerSelectDialog(String captionTxt) {
|
||||||
WorkspaceExplorerController.eventBus.fireEvent(new LoadRootEvent());
|
WorkspaceExplorerController.eventBus.fireEvent(new LoadRootEvent());
|
||||||
initDialog(captionTxt);
|
initDialog(captionTxt);
|
||||||
}
|
}
|
||||||
|
@ -62,7 +66,7 @@ public class WorkspaceExplorerLoadDialog extends Modal implements HasWorskpaceEx
|
||||||
* @param captionTxt the caption txt
|
* @param captionTxt the caption txt
|
||||||
* @param showOnlyFolders the show only folders
|
* @param showOnlyFolders the show only folders
|
||||||
*/
|
*/
|
||||||
public WorkspaceExplorerLoadDialog(String captionTxt, boolean showOnlyFolders) {
|
public WorkspaceExplorerSelectDialog(String captionTxt, boolean showOnlyFolders) {
|
||||||
|
|
||||||
if(showOnlyFolders){
|
if(showOnlyFolders){
|
||||||
ItemType[] itemsType = new ItemType[2];
|
ItemType[] itemsType = new ItemType[2];
|
||||||
|
@ -85,7 +89,7 @@ public class WorkspaceExplorerLoadDialog extends Modal implements HasWorskpaceEx
|
||||||
*
|
*
|
||||||
* You can implement {@link WorskpaceExplorerNotificationListener} to receive events
|
* You can implement {@link WorskpaceExplorerNotificationListener} to receive events
|
||||||
*/
|
*/
|
||||||
public WorkspaceExplorerLoadDialog(String captionTxt, List<ItemType> selectableTypes, List<ItemType> showableTypes) {
|
public WorkspaceExplorerSelectDialog(String captionTxt, List<ItemType> selectableTypes, List<ItemType> showableTypes) {
|
||||||
if(selectableTypes!=null){
|
if(selectableTypes!=null){
|
||||||
ItemType[] itemsType = new ItemType[selectableTypes.size()];
|
ItemType[] itemsType = new ItemType[selectableTypes.size()];
|
||||||
itemsType = selectableTypes.toArray(itemsType);
|
itemsType = selectableTypes.toArray(itemsType);
|
||||||
|
@ -139,13 +143,66 @@ public class WorkspaceExplorerLoadDialog extends Modal implements HasWorskpaceEx
|
||||||
isSelect = true;
|
isSelect = true;
|
||||||
INSTANCE.hide();
|
INSTANCE.hide();
|
||||||
notifySelectedItem(item);
|
notifySelectedItem(item);
|
||||||
|
}else if(!controller.getWsExplorer().itemIsSelectable()){ //IGNORING ITEMS NOT SELECTABLE, USING BREADCRUMBS
|
||||||
|
Item itemB = controller.getBreadcrumbs().getLastParent();
|
||||||
|
if(itemB!=null){
|
||||||
|
setAlertConfirm("Selecting \""+itemB.getName()+"\", confirm?", true, itemB);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setAlertConfirm("", false, null);
|
||||||
footer.add(selectButton);
|
footer.add(selectButton);
|
||||||
add(footer);
|
add(footer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the alert confirm.
|
||||||
|
*
|
||||||
|
* @param html the html
|
||||||
|
* @param bool the bool
|
||||||
|
*/
|
||||||
|
private void setAlertConfirm(String html, boolean show, final Item item){
|
||||||
|
try{
|
||||||
|
footer.remove(alertConfirm);
|
||||||
|
}catch(Exception e){
|
||||||
|
//silent
|
||||||
|
}
|
||||||
|
|
||||||
|
alertConfirm = new Alert();
|
||||||
|
alertConfirm.setText(html);
|
||||||
|
alertConfirm.setVisible(show);
|
||||||
|
alertConfirm.setClose(true);
|
||||||
|
alertConfirm.setType(AlertType.INFO);
|
||||||
|
|
||||||
|
Button yes = new Button("Yes");
|
||||||
|
yes.setType(ButtonType.LINK);
|
||||||
|
yes.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
if(item!=null){
|
||||||
|
isSelect = true;
|
||||||
|
INSTANCE.hide();
|
||||||
|
notifySelectedItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Button no = new Button("No");
|
||||||
|
no.setType(ButtonType.LINK);
|
||||||
|
no.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
alertConfirm.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
alertConfirm.add(yes);
|
||||||
|
alertConfirm.add(no);
|
||||||
|
footer.insert(alertConfirm,0);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Notify selected item.
|
* Notify selected item.
|
||||||
*
|
*
|
|
@ -69,6 +69,12 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the alert.
|
||||||
|
*
|
||||||
|
* @param html the html
|
||||||
|
* @param type the type
|
||||||
|
*/
|
||||||
public void setAlert(String html, AlertType type){
|
public void setAlert(String html, AlertType type){
|
||||||
explorerPanel.clear();
|
explorerPanel.clear();
|
||||||
alert.setHTML(html);
|
alert.setHTML(html);
|
||||||
|
@ -238,6 +244,23 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Item is selectable.
|
||||||
|
*
|
||||||
|
* @return true, if successful
|
||||||
|
*/
|
||||||
|
public boolean itemIsSelectable(){
|
||||||
|
|
||||||
|
Item item = itTables.getSelectedItem();
|
||||||
|
if (item!=null){
|
||||||
|
boolean selectable = selectableTypes.contains(item.getType());
|
||||||
|
return (selectable)?true:false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the selectable types.
|
||||||
|
*
|
||||||
* @return the selectableTypes
|
* @return the selectableTypes
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -246,6 +269,8 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Sets the selectable types.
|
||||||
|
*
|
||||||
* @param selectableTypes the selectableTypes to set
|
* @param selectableTypes the selectableTypes to set
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -255,6 +280,8 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Gets the showable types.
|
||||||
|
*
|
||||||
* @return the showableTypes
|
* @return the showableTypes
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -263,6 +290,8 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Sets the showable types.
|
||||||
|
*
|
||||||
* @param showableTypes the showableTypes to set
|
* @param showableTypes the showableTypes to set
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue