Managed Error cases
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/workspace-explorer-app@131489 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
cc88c81a83
commit
a65f6c45ae
|
@ -7,12 +7,14 @@ package org.gcube.portlets.user.workspaceexplorerapp.client;
|
|||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Element;
|
||||
import com.google.gwt.dom.client.NodeList;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.logical.shared.ResizeEvent;
|
||||
import com.google.gwt.event.logical.shared.ResizeHandler;
|
||||
import com.google.gwt.user.client.DOM;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.ui.RootPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
/**
|
||||
* The Class WorkspaceExplorerApp.
|
||||
|
@ -31,9 +33,9 @@ public class WorkspaceExplorerApp implements EntryPoint {
|
|||
public void onModuleLoad() {
|
||||
|
||||
|
||||
boolean jQueryLoaded = isjQueryLoaded();
|
||||
/*boolean jQueryLoaded = isjQueryLoaded();
|
||||
// GWT.log("Injected : "+Resources.RESOURCES.jquery().getText());
|
||||
GWT.log("jQueryLoaded: "+jQueryLoaded);
|
||||
GWT.log("jQueryLoaded: "+jQueryLoaded);*/
|
||||
|
||||
/*if (!jQueryLoaded) {
|
||||
ScriptInjector.fromString(Resources.RESOURCES.jquery().getText())
|
||||
|
@ -46,6 +48,7 @@ public class WorkspaceExplorerApp implements EntryPoint {
|
|||
.inject();*/
|
||||
|
||||
appController = new WorkspaceExplorerAppController();
|
||||
mainPanel = new WorkspaceExplorerAppMainPanel(appController.getEventBus(), appController.getDisplayFields());
|
||||
appController.go(this);
|
||||
Window.addResizeHandler(new ResizeHandler() {
|
||||
|
||||
|
@ -55,7 +58,6 @@ public class WorkspaceExplorerApp implements EntryPoint {
|
|||
}
|
||||
});
|
||||
|
||||
mainPanel = new WorkspaceExplorerAppMainPanel(appController.getEventBus(), appController.getDisplayFields());
|
||||
RootPanel.get(WorkspaceExplorerAppConstants.APPLICATION_DIV).add(mainPanel);
|
||||
|
||||
// WorkspaceExplorerFoooterPanel footerPanel = new WorkspaceExplorerFoooterPanel();
|
||||
|
@ -82,20 +84,32 @@ public class WorkspaceExplorerApp implements EntryPoint {
|
|||
GWT.log("headerH " + headerH);
|
||||
int footerH = DOM.getElementById("footer_we").getClientHeight();
|
||||
GWT.log("footerH " + footerH);
|
||||
int breadcrumbsH = DOM.getElementById("breadcrumbs_we").getClientHeight();
|
||||
GWT.log("breadcrumbs_we " + breadcrumbsH);
|
||||
|
||||
com.google.gwt.user.client.Element eBread = DOM.getElementById("breadcrumbs_we");
|
||||
int breadcrumbsH = 0;
|
||||
if(eBread!=null){
|
||||
breadcrumbsH = eBread.getClientHeight();
|
||||
GWT.log("breadcrumbs_we " + breadcrumbsH);
|
||||
}
|
||||
|
||||
int windowHeight = Window.getClientHeight();
|
||||
GWT.log("rootHeight " + windowHeight);
|
||||
int diff = windowHeight - (headerH+footerH+breadcrumbsH)-10;
|
||||
int containerH = diff>0?diff:50;
|
||||
DOM.getElementById(WorkspaceExplorerAppConstants.APPLICATION_DIV).getElementsByTagName("main").getItem(0).getStyle().setHeight(containerH, Unit.PX);
|
||||
// DOM.getElementById(WorkspaceExplorerAppConstants.APPLICATION_DIV).getStyle().setHeight(containerH, Unit.PX);
|
||||
GWT.log("containerH " + containerH);
|
||||
NodeList<Element> listE = DOM.getElementById(WorkspaceExplorerAppConstants.APPLICATION_DIV).getElementsByTagName("main");
|
||||
|
||||
if(listE!=null && listE.getLength()>0){
|
||||
Element el = listE.getItem(0);
|
||||
el.getStyle().setHeight(containerH, Unit.PX);
|
||||
// DOM.getElementById(WorkspaceExplorerAppConstants.APPLICATION_DIV).getStyle().setHeight(containerH, Unit.PX);
|
||||
GWT.log("containerH " + containerH);
|
||||
|
||||
Element table = DOM.getElementById("data_grid_explorer");
|
||||
if(table!=null){
|
||||
int headerTableH = 0;
|
||||
table.getStyle().setHeight(containerH-headerTableH, Unit.PX);
|
||||
}
|
||||
|
||||
Element table = DOM.getElementById("data_grid_explorer");
|
||||
if(table!=null){
|
||||
int headerTableH = 0;
|
||||
table.getStyle().setHeight(containerH-headerTableH, Unit.PX);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,6 +120,16 @@ public class WorkspaceExplorerApp implements EntryPoint {
|
|||
* @param workspaceExplorerAppPanel the workspace explorer app panel
|
||||
*/
|
||||
public void updateExplorerPanel(WorkspaceExplorerAppPanel workspaceExplorerAppPanel){
|
||||
mainPanel.updateMainPanel(workspaceExplorerAppPanel);
|
||||
mainPanel.updateToExplorerPanel(workspaceExplorerAppPanel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update to error.
|
||||
*
|
||||
* @param widget the widget
|
||||
*/
|
||||
public void updateToError(Widget widget){
|
||||
mainPanel.updateToError(widget);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
|
||||
package org.gcube.portlets.user.workspaceexplorerapp.client;
|
||||
|
||||
import gwt.material.design.client.ui.MaterialToast;
|
||||
|
||||
import org.gcube.portlets.user.workspaceexplorerapp.client.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
|
||||
import org.gcube.portlets.user.workspaceexplorerapp.client.grid.DisplayField;
|
||||
import org.gcube.portlets.user.workspaceexplorerapp.client.resources.WorkspaceExplorerResources;
|
||||
import org.gcube.portlets.user.workspaceexplorerapp.shared.Item;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Alert;
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.dom.client.ContextMenuEvent;
|
||||
|
@ -17,6 +18,7 @@ import com.google.gwt.event.dom.client.ContextMenuHandler;
|
|||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.RootPanel;
|
||||
|
||||
/**
|
||||
|
@ -27,9 +29,7 @@ import com.google.gwt.user.client.ui.RootPanel;
|
|||
*/
|
||||
public class WorkspaceExplorerAppController {
|
||||
|
||||
// private VerticalPanel mainPanel = new VerticalPanel();
|
||||
|
||||
private WorkspaceExplorerAppPanel mainPanel;
|
||||
private WorkspaceExplorerAppPanel workspaceERP;
|
||||
private WorkspaceResourcesExplorerPanel wsResourcesExplorerPanel;
|
||||
private final HandlerManager eventBus = new HandlerManager(null);
|
||||
private WorkspaceExplorerApp app;
|
||||
|
@ -56,8 +56,10 @@ public class WorkspaceExplorerAppController {
|
|||
|
||||
//TODO CHECK FOLDER ID
|
||||
if(folderId==null){
|
||||
Window.alert("Folder Id not found, It is not possible to retrieve a folder without a valid id");
|
||||
//return;
|
||||
String msg = "Folder Id not found, It is not possible to retrieve a folder without a valid id";
|
||||
// Window.alert("Folder Id not found, It is not possible to retrieve a folder without a valid id");
|
||||
showErrorPanel(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
RootPanel.get().addDomHandler(new ContextMenuHandler() {
|
||||
|
@ -69,7 +71,6 @@ public class WorkspaceExplorerAppController {
|
|||
}
|
||||
}, ContextMenuEvent.getType());
|
||||
|
||||
MaterialToast.fireToast("Checking permissions...");
|
||||
WorkspaceExplorerAppConstants.workspaceNavigatorService.getFolderIdFromEncrypted(folderId, new AsyncCallback<String>() {
|
||||
|
||||
@Override
|
||||
|
@ -80,13 +81,15 @@ public class WorkspaceExplorerAppController {
|
|||
initWorkspaceExplorer(folderId);
|
||||
}
|
||||
catch (Exception e) {
|
||||
Window.alert("Folder Id not valid. An occurred when converting folder id");
|
||||
// Window.alert("Folder Id not valid. An occurred when converting folder id");
|
||||
showErrorPanel("Folder Id not valid. An occurred when converting folder id");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert(caught.getMessage());
|
||||
// Window.alert(caught.getMessage());
|
||||
showErrorPanel(caught.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -96,6 +99,23 @@ public class WorkspaceExplorerAppController {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show error panel.
|
||||
*
|
||||
* @param message the message
|
||||
*/
|
||||
private void showErrorPanel(String message){
|
||||
Image error = new Image(WorkspaceExplorerResources.INSTANCE.eUnhappy().getSafeUri());
|
||||
error.getElement().getStyle().setPaddingLeft(5, Unit.PX);
|
||||
Alert alert = new Alert();
|
||||
alert.setType(AlertType.ERROR);
|
||||
alert.add(error);
|
||||
alert.setClose(false);
|
||||
alert.setHeading(message);
|
||||
app.updateToError(alert);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inits the workspace explorer.
|
||||
*
|
||||
|
@ -146,21 +166,11 @@ public class WorkspaceExplorerAppController {
|
|||
}
|
||||
}.schedule(1000);*/
|
||||
|
||||
mainPanel = new WorkspaceExplorerAppPanel(wsResourcesExplorerPanel);
|
||||
app.updateExplorerPanel(mainPanel);
|
||||
workspaceERP = new WorkspaceExplorerAppPanel(wsResourcesExplorerPanel);
|
||||
app.updateExplorerPanel(workspaceERP);
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * Gets the main panel.
|
||||
// *
|
||||
// * @return the mainPanel
|
||||
// */
|
||||
// public WorkspaceExplorerAppPanel getMainPanel() {
|
||||
// return mainPanel;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Gets the event bus.
|
||||
*
|
||||
|
@ -176,6 +186,6 @@ public class WorkspaceExplorerAppController {
|
|||
* @return the display fields
|
||||
*/
|
||||
public DisplayField[] getDisplayFields(){
|
||||
return new DisplayField[]{DisplayField.ICON, DisplayField.NAME, DisplayField.OWNER, DisplayField.CREATION_DATE};
|
||||
return WorkspaceResourcesExplorerPanel.displayFields;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,8 +84,8 @@ public class WorkspaceExplorerAppMainPanel extends Composite {
|
|||
* Note that depending on the widget that is used, it may be necessary to
|
||||
* implement HasHTML instead of HasText.
|
||||
*
|
||||
* @param workspaceExplorerAppPanel the workspace explorer app panel
|
||||
* @param handlerManager the handler manager
|
||||
* @param displayFields the display fields
|
||||
*/
|
||||
public WorkspaceExplorerAppMainPanel(HandlerManager handlerManager, DisplayField[] displayFields) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
|
@ -153,9 +153,27 @@ public class WorkspaceExplorerAppMainPanel extends Composite {
|
|||
});
|
||||
}
|
||||
|
||||
public void updateMainPanel(WorkspaceExplorerAppPanel workspaceExplorerAppPanel){
|
||||
/**
|
||||
* Update to explorer panel.
|
||||
*
|
||||
* @param workspaceExplorerAppPanel the workspace explorer app panel
|
||||
*/
|
||||
public void updateToExplorerPanel(WorkspaceExplorerAppPanel workspaceExplorerAppPanel){
|
||||
explorer_main_container.clear();
|
||||
explorer_main_container.add(workspaceExplorerAppPanel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Update to error.
|
||||
*
|
||||
* @param error the error
|
||||
*/
|
||||
public void updateToError(Widget error){
|
||||
explorer_main_container.clear();
|
||||
explorer_main_container.add(error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ import com.google.gwt.user.client.ui.Widget;
|
|||
|
||||
|
||||
/**
|
||||
* The Class SplitPanel.
|
||||
* The Class WorkspaceExplorerAppPanel.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jun 23, 2015
|
||||
* Sep 19, 2016
|
||||
*/
|
||||
public class WorkspaceExplorerAppPanel extends SimplePanel{
|
||||
|
||||
|
@ -19,15 +19,13 @@ public class WorkspaceExplorerAppPanel extends SimplePanel{
|
|||
/**
|
||||
* Instantiates a new workspace explorer app panel.
|
||||
*
|
||||
* @param splitterSize the splitter size
|
||||
* @param navigation the navigation
|
||||
* @param wsExplorer the ws explorer
|
||||
* @param aPanel the a panel
|
||||
*/
|
||||
public WorkspaceExplorerAppPanel(Widget wsExplorerPanel) {
|
||||
public WorkspaceExplorerAppPanel(Widget aPanel) {
|
||||
ensureDebugId("WorkspaceExplorerAppPanel");
|
||||
this.getElement().setId("WorkspaceExplorerAppPanel");
|
||||
this.getElement().setAttribute("id","WorkspaceExplorerAppPanel");
|
||||
setWidth("100%");
|
||||
add(wsExplorerPanel);
|
||||
add(aPanel);
|
||||
}
|
||||
}
|
|
@ -64,7 +64,7 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
|
|||
// private ScrollPanel southPanel = new ScrollPanel();
|
||||
private String folderId;
|
||||
private String folderName;
|
||||
private DisplayField[] displayFields = new DisplayField[]{DisplayField.ICON, DisplayField.NAME, DisplayField.OWNER, DisplayField.CREATION_DATE};
|
||||
public static final DisplayField[] displayFields = new DisplayField[]{DisplayField.ICON, DisplayField.NAME, DisplayField.OWNER, DisplayField.CREATION_DATE};
|
||||
|
||||
/**
|
||||
* Instantiates a new workspace folder explorer select panel.
|
||||
|
@ -102,15 +102,6 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
|
|||
initPanel("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the displayFields
|
||||
*/
|
||||
public DisplayField[] getDisplayFields() {
|
||||
|
||||
return displayFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new workspace explorer select panel.
|
||||
*
|
||||
|
|
|
@ -33,4 +33,23 @@ public interface WorkspaceExplorerResources extends ClientBundle {
|
|||
@Source("_32/groups_folder.png")
|
||||
ImageResource shared_folder();
|
||||
|
||||
|
||||
/**
|
||||
* Warning.
|
||||
*
|
||||
* @return the image resource
|
||||
*/
|
||||
@Source("warning.png")
|
||||
ImageResource warning();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* E unhappy.
|
||||
*
|
||||
* @return the image resource
|
||||
*/
|
||||
@Source("e-unhappy.png")
|
||||
ImageResource eUnhappy();
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 860 B |
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
Loading…
Reference in New Issue