Updated css

Updated DialogShowGcubeItem

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@128677 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-05-19 08:59:25 +00:00
parent 1c595c3ce2
commit a4a0cec916
3 changed files with 44 additions and 63 deletions

View File

@ -5,10 +5,12 @@ package org.gcube.portlets.widgets.wsexplorer.client.view.gcubeitem;
import java.util.Map; import java.util.Map;
import org.gcube.portlets.widgets.wsexplorer.client.Util;
import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceExplorerConstants; import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceExplorerConstants;
import org.gcube.portlets.widgets.wsexplorer.client.resources.WorkspaceExplorerResources; import org.gcube.portlets.widgets.wsexplorer.client.resources.WorkspaceExplorerResources;
import org.gcube.portlets.widgets.wsexplorer.shared.Item; import org.gcube.portlets.widgets.wsexplorer.shared.Item;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.dom.client.Style.Unit; 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;
@ -38,23 +40,27 @@ public class DialogShowGcubeItem extends DialogBox implements ClickHandler {
private DockPanel dock = new DockPanel(); private DockPanel dock = new DockPanel();
private Button yesButton; private Button yesButton;
private VerticalPanel vpContainer; private VerticalPanel vpCenterContainer;
private ImageResource loading = WorkspaceExplorerResources.ICONS.loading(); private ImageResource loading = WorkspaceExplorerResources.ICONS.loading();
private HorizontalPanel hpButtons = new HorizontalPanel(); private HorizontalPanel hpButtons = new HorizontalPanel();
/** /**
* Instantiates a new dialog show gcube items related to WorkspaceItemId. * Instantiates a new dialog show gcube items related to WorkspaceItemId.
* *
* @param caption the caption * @param caption the caption
* @param text the text * @param text the text
* @param item the worksapce item id * @param item the worksapce item id
* @param autoHide the auto hide
*/ */
public DialogShowGcubeItem(String caption, String text, Item item) { public DialogShowGcubeItem(String caption, String text, Item item, boolean autoHide) {
getElement().setClassName("gwt-DialogBoxNew"); getElement().setClassName("gwt-DialogBoxNew");
dock.setSpacing(4); dock.setSpacing(4);
dock.setWidth("100%"); dock.setWidth("100%");
setText(caption);
String title = Util.ellipsis(caption, 70, false);
setText(title);
setTitle(caption);
setAutoHideEnabled(autoHide);
yesButton = new Button("Ok"); yesButton = new Button("Ok");
yesButton.addClickHandler(new ClickHandler() { yesButton.addClickHandler(new ClickHandler() {
@ -65,9 +71,9 @@ public class DialogShowGcubeItem extends DialogBox implements ClickHandler {
} }
}); });
vpContainer = new VerticalPanel(); vpCenterContainer = new VerticalPanel();
// vpContainer.getElement().getStyle().setMargin(5.0, Unit.PX); // vpContainer.getElement().getStyle().setMargin(5.0, Unit.PX);
vpContainer.add(new HTML(text)); vpCenterContainer.add(new HTML(text));
hpButtons = new HorizontalPanel(); hpButtons = new HorizontalPanel();
hpButtons.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); hpButtons.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
hpButtons.setSpacing(3); hpButtons.setSpacing(3);
@ -77,31 +83,31 @@ public class DialogShowGcubeItem extends DialogBox implements ClickHandler {
dock.add(hpButtons, DockPanel.SOUTH); dock.add(hpButtons, DockPanel.SOUTH);
dock.setCellHorizontalAlignment(hpButtons, DockPanel.ALIGN_CENTER); dock.setCellHorizontalAlignment(hpButtons, DockPanel.ALIGN_CENTER);
dock.add(vpContainer, DockPanel.CENTER); dock.add(vpCenterContainer, DockPanel.CENTER);
setWidget(dock); setWidget(dock);
if(item.getGcubeProperties()!=null){ /*if(item.getGcubeProperties()!=null){
FlexTable table = buildGcubeItemView(item.getGcubeProperties()); FlexTable table = buildGcubeItemView(item.getGcubeProperties());
addToCenterPanel(table); addToCenterPanel(table);
}else{ }else{*/
addLoader("Re-loading Gcube Properties Info..."); showLoader("Loading Gcube Properties...");
WorkspaceExplorerConstants.workspaceNavigatorService.getGcubePropertiesForWorspaceId(item.getId(), new AsyncCallback<Map<String,String>>() { WorkspaceExplorerConstants.workspaceNavigatorService.getGcubePropertiesForWorspaceId(item.getId(), new AsyncCallback<Map<String,String>>() {
@Override @Override
public void onSuccess(Map<String, String> result) { public void onSuccess(Map<String, String> result) {
FlexTable table = buildGcubeItemView(result); FlexTable table = buildGcubeItemView(result);
removeLoader(); clearCenterContainer();
addToCenterPanel(table); addToCenterPanel(table);
} }
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
removeLoader(); clearCenterContainer();
} }
}); });
} //}
} }
/** /**
@ -127,13 +133,14 @@ public class DialogShowGcubeItem extends DialogBox implements ClickHandler {
table.setHTML(0, 2, "Value"); table.setHTML(0, 2, "Value");
table.getRowFormatter().getElement(0).addClassName("gcube-item-table-header"); table.getRowFormatter().getElement(0).addClassName("gcube-item-table-header");
int i = 0; int index = 1;
GWT.log("Properties are: "+map.keySet().size());
for (String key : map.keySet()) { for (String key : map.keySet()) {
String value = map.get(key); String value = map.get(key);
int index = i+1; table.setHTML(index, 0, index+"");
table.setHTML(index, 0, index+"-");
table.setHTML(index, 1, key); table.setHTML(index, 1, key);
table.setHTML(index, 2, value); table.setHTML(index, 2, value);
index++;
} }
return table; return table;
@ -152,32 +159,30 @@ public class DialogShowGcubeItem extends DialogBox implements ClickHandler {
} }
/** /**
* Adds the loader. * Show loader.
* *
* @param message the message * @param message the message
*/ */
private void addLoader(String message){ private void showLoader(String message){
try{ vpCenterContainer.clear();
dock.remove(hpButtons);
}catch(Exception e){}
vpContainer.clear();
HorizontalPanel hpMask = new HorizontalPanel(); HorizontalPanel hpMask = new HorizontalPanel();
hpMask.add(new Image(loading)); hpMask.add(new Image(loading));
HTML html = new HTML(message); HTML html = new HTML(message);
html.getElement().getStyle().setMarginLeft(5, Unit.PX); html.getElement().getStyle().setMarginLeft(5, Unit.PX);
hpMask.add(html); hpMask.add(html);
vpContainer.add(hpMask); vpCenterContainer.add(hpMask);
} }
/** /**
* Removes the loader. * Clear center container.
*/ */
private void removeLoader(){ private void clearCenterContainer(){
try{ try{
dock.add(hpButtons); vpCenterContainer.clear();
}catch(Exception e){} }catch(Exception e){}
vpContainer.clear();
} }
/** /**
@ -186,7 +191,7 @@ public class DialogShowGcubeItem extends DialogBox implements ClickHandler {
* @param w the w * @param w the w
*/ */
public void addToCenterPanel(Widget w) { public void addToCenterPanel(Widget w) {
vpContainer.add(w); vpCenterContainer.add(w);
} }
/** /**

View File

@ -145,7 +145,7 @@ public class ItemsTable<T extends Item> extends AbstractItemsCellTable<T> implem
}; };
icon.setSortable(false); icon.setSortable(false);
cellTable.addColumn(icon, ""); cellTable.addColumn(icon, "");
cellTable.setColumnWidth(icon, 10.0, Unit.PCT); cellTable.setColumnWidth(icon, 25.0, Unit.PX);
} }
if(this.displayFields.contains(DISPLAY_FIELD.NAME)){ if(this.displayFields.contains(DISPLAY_FIELD.NAME)){
@ -307,41 +307,16 @@ public class ItemsTable<T extends Item> extends AbstractItemsCellTable<T> implem
super.onBrowserEvent(context, elem, object, event); super.onBrowserEvent(context, elem, object, event);
if ("click".equals(event.getType())) { if ("click".equals(event.getType())) {
Item item = object; Item item = object;
DialogShowGcubeItem dg = new DialogShowGcubeItem("Gcube Properties for: "+item.getName(), null, item); DialogShowGcubeItem dg = new DialogShowGcubeItem("Gcube Properties for: "+item.getName(), null, item, true);
dg.setPopupPosition(event.getClientX(), event.getClientY()); // dg.setPopupPosition(event.getClientX()-Integer.parseInt(dg.getElement().getStyle().getWidth()), event.getClientY());
dg.show(); dg.center();
} }
} }
}; };
/*Column<T, ImageResource> showGcubeInfoClm = new Column<T, ImageResource>(showGcubeInfo) {
@Override
public ImageResource getValue(T dataObj) {
return info;
}
@Override
public void render(Context context, T object, SafeHtmlBuilder sb) {
super.render(context, object, sb);
}
@Override
public void onBrowserEvent(Context context, Element elem, T object, NativeEvent event) {
super.onBrowserEvent(context, elem, object, event);
if ("click".equals(event.getType())) {
Item item = object;
DialogShowGcubeItem dg = new DialogShowGcubeItem("Gcube Properties for: "+item.getName(), null, item);
dg.show();
}
}
};*/
showGcubeInfoClm.setSortable(false); showGcubeInfoClm.setSortable(false);
cellTable.addColumn(showGcubeInfoClm, ""); cellTable.addColumn(showGcubeInfoClm, "");
cellTable.setColumnWidth(showGcubeInfoClm, 10.0, Unit.PCT); cellTable.setColumnWidth(showGcubeInfoClm, 32.0, Unit.PX);
} }
/*final SingleSelectionModel<Item> selectionModel = new SingleSelectionModel<Item>(); /*final SingleSelectionModel<Item> selectionModel = new SingleSelectionModel<Item>();

View File

@ -171,19 +171,20 @@
} }
.gcube-item-table{ .gcube-item-table{
margin: 5px; margin-top: 10px;
margin-bottom: 10px;
} }
.gcube-item-table td{ .gcube-item-table td{
border-bottom: 1px solid #EEE; border-bottom: 1px solid #EEEEEE;
height: 50%; height: 50%;
vertical-align: middle;
text-align: center; text-align: center;
vertical-align: middle;
padding: 5px;
} }
.gcube-item-table-header{ .gcube-item-table-header{
background-color: #dedede;
text-align: center; text-align: center;
font-weight: bold;
} }
/******* END TABLE ********/ /******* END TABLE ********/