finished support for tables and images

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@71073 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-03-07 17:59:50 +00:00
parent d1b7b9fbcf
commit 76b573fa6a
6 changed files with 106 additions and 23 deletions

View File

@ -1166,6 +1166,12 @@ public class Presenter {
public void refreshWorkspace() { public void refreshWorkspace() {
toolBoxPanel.refreshRoot(); toolBoxPanel.refreshRoot();
} }
/**
* show the upload file popup
*/
public void showUploadFilePopup() {
toolBoxPanel.showUploadFile();
}
/** /**
* *
* @return the current selected rich text area * @return the current selected rich text area

View File

@ -5,6 +5,8 @@ package org.gcube.portlets.user.reportgenerator.client;
//import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspace; //import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspace;
import org.gcube.portlets.user.workspace.client.AppControllerExplorer; import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
import org.gcube.portlets.user.workspace.client.event.FileUploadEvent;
import org.gcube.portlets.user.workspace.client.event.FileUploadEvent.UploadType;
import org.gcube.portlets.user.workspace.client.view.tree.AsyncTreePanel; import org.gcube.portlets.user.workspace.client.view.tree.AsyncTreePanel;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
@ -17,6 +19,7 @@ import com.google.gwt.user.client.ui.SimplePanel;
public class ToolboxPanel extends SimplePanel { public class ToolboxPanel extends SimplePanel {
private AppControllerExplorer appController; private AppControllerExplorer appController;
private AsyncTreePanel tp;
/** /**
* *
*/ */
@ -32,6 +35,7 @@ public class ToolboxPanel extends SimplePanel {
public ToolboxPanel(AppControllerExplorer appController) { public ToolboxPanel(AppControllerExplorer appController) {
this.appController = appController; this.appController = appController;
AsyncTreePanel tp = appController.getTree(TOOLBOX_WIDTH, TOOLBOX_HEIGHT); AsyncTreePanel tp = appController.getTree(TOOLBOX_WIDTH, TOOLBOX_HEIGHT);
this.tp = tp;
add(tp); add(tp);
} }
@ -41,6 +45,12 @@ public class ToolboxPanel extends SimplePanel {
public void refreshRoot() { public void refreshRoot() {
appController.refreshRoot(); appController.refreshRoot();
} }
/**
* show upload file popup
*/
public void showUploadFile() {
AppControllerExplorer.getEventBus().fireEvent(new FileUploadEvent(tp.getRootItem(), UploadType.FILE));
}
/** /**
* lalala * lalala
* @return the toolbox height * @return the toolbox height

View File

@ -354,6 +354,7 @@ public class TemplateComponent {
idInBasket = id; idInBasket = id;
if (((String) content).compareTo("") == 0) if (((String) content).compareTo("") == 0)
content = DEFAULT_IMAGE_PATH; content = DEFAULT_IMAGE_PATH;
metadata = da.getMetadata();
break; break;
case BODY: case BODY:
if (this.isLocked()) { if (this.isLocked()) {

View File

@ -1,5 +1,8 @@
package org.gcube.portlets.user.reportgenerator.client.targets; package org.gcube.portlets.user.reportgenerator.client.targets;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.d4sreporting.common.shared.BasicComponent; import org.gcube.portlets.d4sreporting.common.shared.BasicComponent;
import org.gcube.portlets.d4sreporting.common.shared.Metadata; import org.gcube.portlets.d4sreporting.common.shared.Metadata;
import org.gcube.portlets.user.reportgenerator.client.ReportGenerator; import org.gcube.portlets.user.reportgenerator.client.ReportGenerator;
@ -18,10 +21,13 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback; import com.google.gwt.core.client.RunAsyncCallback;
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;
import com.google.gwt.event.dom.client.MouseOutEvent;
import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Image;
@ -43,6 +49,8 @@ public class ClientImage extends Composite {
private final String METADATA_DESC_KEY = "description"; private final String METADATA_DESC_KEY = "description";
private final String METADATA_SOURCE_KEY = "source"; private final String METADATA_SOURCE_KEY = "source";
private FocusPanel focusPanel = new FocusPanel();
private VerticalPanel mainPanel = new VerticalPanel(); private VerticalPanel mainPanel = new VerticalPanel();
private SimplePanel imagePanel = new SimplePanel(); private SimplePanel imagePanel = new SimplePanel();
private Image currImage; private Image currImage;
@ -59,10 +67,11 @@ public class ClientImage extends Composite {
private TextBox descTB = new TextBox(); private TextBox descTB = new TextBox();
private TextBox sourceTB = new TextBox(); private TextBox sourceTB = new TextBox();
private Button resetB = new Button("Clear Image"); private Button resetB = new Button("Reset Image");
private Button addImageB = new Button("Select Image"); private Button addImageB = new Button("Select Image");
private Button uploadImageB = new Button("Upload Image"); private Button uploadImageB = new Button("Upload Image");
private BasicComponent basicComponent;
/** /**
* *
* @param presenter * @param presenter
@ -71,7 +80,7 @@ public class ClientImage extends Composite {
*/ */
public ClientImage(BasicComponent co, Presenter presenter, int width) { public ClientImage(BasicComponent co, Presenter presenter, int width) {
this.presenter = presenter; this.presenter = presenter;
this.basicComponent = co;
HorizontalPanel controlPanel = getControlPanel(); HorizontalPanel controlPanel = getControlPanel();
VerticalPanel attributesPanel = getAttributesPanel(co); VerticalPanel attributesPanel = getAttributesPanel(co);
mainPanel.add(controlPanel); mainPanel.add(controlPanel);
@ -106,7 +115,15 @@ public class ClientImage extends Composite {
} }
} }
initWidget(mainPanel); focusPanel.add(mainPanel);
initWidget(focusPanel);
focusPanel.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
saveStatus();
}
});
} }
private HorizontalPanel getControlPanel() { private HorizontalPanel getControlPanel() {
@ -115,6 +132,10 @@ public class ClientImage extends Composite {
resetB.addClickHandler(new ClickHandler() { resetB.addClickHandler(new ClickHandler() {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
titleTB.setText("");
descTB.setText("");
sourceTB.setText("");
showImage(new Image(TemplateComponent.DEFAULT_IMAGE_NAME), 300, 100);
} }
}); });
@ -128,13 +149,14 @@ public class ClientImage extends Composite {
uploadImageB.addClickHandler(new ClickHandler() { uploadImageB.addClickHandler(new ClickHandler() {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
presenter.showUploadFilePopup();
} }
}); });
toReturn.setSpacing(3); toReturn.setSpacing(3);
toReturn.add(uploadImageB);
toReturn.add(resetB); toReturn.add(resetB);
toReturn.add(uploadImageB);
toReturn.add(addImageB); toReturn.add(addImageB);
return toReturn; return toReturn;
@ -180,29 +202,60 @@ public class ClientImage extends Composite {
mainPanel.add(w); mainPanel.add(w);
} }
/** /**
* called when dropped an image on the area * called by the select image ws light tree
* @param toShow the image to show
*/
public void showImage(Image toShow, int width, int height) {
int checkedWidth = width;
int checkedHeight = height;
Double maxWidth = new Double(700);
GWT.log("OriginalImage W="+checkedWidth+ " H="+checkedHeight);
if (width > 700) {
Double resizeFactor = maxWidth / ((double) width);
checkedWidth = new Double(width * resizeFactor).intValue();
checkedHeight = new Double(height * resizeFactor).intValue();
}
imagePanel.clear();
this.currImage = toShow;
GWT.log("ResizedImage W="+checkedWidth+ " H="+checkedHeight);
toShow.setWidth(checkedWidth+"px");
imagePanel.setSize(checkedWidth+"px", checkedHeight+"px");
imagePanel.add(toShow);
saveStatus();
}
/**
* called by the constructor
* @param toShow the image to show * @param toShow the image to show
*/ */
public void showImage(Image toShow) { public void showImage(Image toShow) {
imagePanel.clear(); showImage(toShow, toShow.getWidth(), toShow.getHeight());
this.currImage = toShow; }
toShow.setWidth(toShow.getWidth()+"px"); private void saveStatus() {
imagePanel.setSize(toShow.getWidth()+"px", toShow.getHeight()+"px"); Metadata title = new Metadata(METADATA_TITLE_KEY, titleTB.getText());
imagePanel.add(toShow); Metadata desc = new Metadata(METADATA_DESC_KEY, descTB.getText());
Metadata source = new Metadata(METADATA_SOURCE_KEY, sourceTB.getText());
List<Metadata> mds = new ArrayList<Metadata>();
mds.add(title);
mds.add(desc);
mds.add(source);
basicComponent.setMetadata(mds);
presenter.storeChangeInSession(this); presenter.storeChangeInSession(this);
GWT.log("Saved in Session");
} }
public List<Metadata> getMetadata() {
return basicComponent.getMetadata();
}
/** /**
* *
* @param url . * @param url .
* @param id the id in the folder * @param id the id in the folder
*/ */
public void dropImage(String url, String id) public void dropImage(String url, String id, int width, int height) {
{
GWT.log("URL:" + url, null); GWT.log("URL:" + url, null);
idInBasket = id; idInBasket = id;
showImage(new Image(url)); showImage(new Image(url), width, height);
} }
public void fetchImage(String identifier, final boolean isInteralImage, boolean fullDetails) { public void fetchImage(String identifier, final boolean isInteralImage, boolean fullDetails) {
@ -211,10 +264,14 @@ public class ClientImage extends Composite {
public void onSuccess(GWTWorkspaceItem result) { public void onSuccess(GWTWorkspaceItem result) {
if (isInteralImage) { if (isInteralImage) {
GWTImageDocument image = (GWTImageDocument) result; GWTImageDocument image = (GWTImageDocument) result;
dropImage(image.getImageUrl(), image.getId()); int width = image.getWidth();
int height = image.getHeight();
dropImage(image.getImageUrl(), image.getId(), width, height);
} else { } else {
GWTExternalImage image = (GWTExternalImage) result; GWTExternalImage image = (GWTExternalImage) result;
dropImage(image.getImageUrl(), image.getId()); int width = image.getWidth();
int height = image.getHeight();
dropImage(image.getImageUrl(), image.getId(), width, height);
} }
} }
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -286,6 +343,11 @@ public class ClientImage extends Composite {
return expectedContent; return expectedContent;
} }
public BasicComponent getBasicComponent() {
return basicComponent;
}
/** /**
* *
* @param expectedContent . * @param expectedContent .

View File

@ -111,8 +111,10 @@ public class GenericTable extends Composite {
VerticalPanel attributesPanel = getAttributesPanel(sTable); VerticalPanel attributesPanel = getAttributesPanel(sTable);
attributesPanel.setStyleName("tableAttributesPanel"); attributesPanel.setStyleName("tableAttributesPanel");
if (! isLocked) {
controlPanel.setStyleName("tableControlPanel"); controlPanel.setStyleName("tableControlPanel");
myPanel.add(controlPanel); myPanel.add(controlPanel);
}
myPanel.add(myTable); myPanel.add(myTable);
myPanel.add(attributesPanel); myPanel.add(attributesPanel);
myPanel.setStyleName("tablePanel"); myPanel.setStyleName("tablePanel");
@ -604,6 +606,8 @@ public class GenericTable extends Composite {
protected void resetMe() { protected void resetMe() {
titleTB.setText("");
descTB.setText("");
myTable.removeAllRows(); myTable.removeAllRows();
/** /**
* construct the table * construct the table

View File

@ -14,7 +14,7 @@
.addEntryButton { .addEntryButton {
background-image: none !important; background-image: none !important;
background-repeat: none !important; background-repeat: none !important;
background-color: #02990C !important background-color: #02990C !important;
color: #FFF !important; color: #FFF !important;
} }