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:
parent
d1b7b9fbcf
commit
76b573fa6a
|
@ -1166,6 +1166,12 @@ public class Presenter {
|
|||
public void refreshWorkspace() {
|
||||
toolBoxPanel.refreshRoot();
|
||||
}
|
||||
/**
|
||||
* show the upload file popup
|
||||
*/
|
||||
public void showUploadFilePopup() {
|
||||
toolBoxPanel.showUploadFile();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return the current selected rich text area
|
||||
|
|
|
@ -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.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 com.google.gwt.user.client.ui.HTML;
|
||||
|
@ -17,6 +19,7 @@ import com.google.gwt.user.client.ui.SimplePanel;
|
|||
|
||||
public class ToolboxPanel extends SimplePanel {
|
||||
private AppControllerExplorer appController;
|
||||
private AsyncTreePanel tp;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -32,6 +35,7 @@ public class ToolboxPanel extends SimplePanel {
|
|||
public ToolboxPanel(AppControllerExplorer appController) {
|
||||
this.appController = appController;
|
||||
AsyncTreePanel tp = appController.getTree(TOOLBOX_WIDTH, TOOLBOX_HEIGHT);
|
||||
this.tp = tp;
|
||||
add(tp);
|
||||
}
|
||||
|
||||
|
@ -41,6 +45,12 @@ public class ToolboxPanel extends SimplePanel {
|
|||
public void refreshRoot() {
|
||||
appController.refreshRoot();
|
||||
}
|
||||
/**
|
||||
* show upload file popup
|
||||
*/
|
||||
public void showUploadFile() {
|
||||
AppControllerExplorer.getEventBus().fireEvent(new FileUploadEvent(tp.getRootItem(), UploadType.FILE));
|
||||
}
|
||||
/**
|
||||
* lalala
|
||||
* @return the toolbox height
|
||||
|
|
|
@ -354,6 +354,7 @@ public class TemplateComponent {
|
|||
idInBasket = id;
|
||||
if (((String) content).compareTo("") == 0)
|
||||
content = DEFAULT_IMAGE_PATH;
|
||||
metadata = da.getMetadata();
|
||||
break;
|
||||
case BODY:
|
||||
if (this.isLocked()) {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
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.Metadata;
|
||||
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.event.dom.client.ClickEvent;
|
||||
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.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
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.HorizontalPanel;
|
||||
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_SOURCE_KEY = "source";
|
||||
|
||||
|
||||
private FocusPanel focusPanel = new FocusPanel();
|
||||
private VerticalPanel mainPanel = new VerticalPanel();
|
||||
private SimplePanel imagePanel = new SimplePanel();
|
||||
private Image currImage;
|
||||
|
@ -59,10 +67,11 @@ public class ClientImage extends Composite {
|
|||
private TextBox descTB = 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 uploadImageB = new Button("Upload Image");
|
||||
|
||||
private BasicComponent basicComponent;
|
||||
/**
|
||||
*
|
||||
* @param presenter
|
||||
|
@ -71,7 +80,7 @@ public class ClientImage extends Composite {
|
|||
*/
|
||||
public ClientImage(BasicComponent co, Presenter presenter, int width) {
|
||||
this.presenter = presenter;
|
||||
|
||||
this.basicComponent = co;
|
||||
HorizontalPanel controlPanel = getControlPanel();
|
||||
VerticalPanel attributesPanel = getAttributesPanel(co);
|
||||
mainPanel.add(controlPanel);
|
||||
|
@ -106,15 +115,27 @@ 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() {
|
||||
final HorizontalPanel toReturn = new HorizontalPanel();
|
||||
|
||||
resetB.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
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() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
presenter.showUploadFilePopup();
|
||||
}
|
||||
});
|
||||
|
||||
toReturn.setSpacing(3);
|
||||
|
||||
toReturn.add(uploadImageB);
|
||||
toReturn.add(resetB);
|
||||
toReturn.add(uploadImageB);
|
||||
toReturn.add(addImageB);
|
||||
|
||||
return toReturn;
|
||||
|
@ -180,29 +202,60 @@ public class ClientImage extends Composite {
|
|||
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
|
||||
*/
|
||||
public void showImage(Image toShow) {
|
||||
imagePanel.clear();
|
||||
this.currImage = toShow;
|
||||
toShow.setWidth(toShow.getWidth()+"px");
|
||||
imagePanel.setSize(toShow.getWidth()+"px", toShow.getHeight()+"px");
|
||||
imagePanel.add(toShow);
|
||||
presenter.storeChangeInSession(this);
|
||||
|
||||
showImage(toShow, toShow.getWidth(), toShow.getHeight());
|
||||
}
|
||||
private void saveStatus() {
|
||||
Metadata title = new Metadata(METADATA_TITLE_KEY, titleTB.getText());
|
||||
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);
|
||||
GWT.log("Saved in Session");
|
||||
}
|
||||
|
||||
public List<Metadata> getMetadata() {
|
||||
return basicComponent.getMetadata();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param url .
|
||||
* @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);
|
||||
idInBasket = id;
|
||||
showImage(new Image(url));
|
||||
showImage(new Image(url), width, height);
|
||||
}
|
||||
|
||||
public void fetchImage(String identifier, final boolean isInteralImage, boolean fullDetails) {
|
||||
|
@ -211,10 +264,14 @@ public class ClientImage extends Composite {
|
|||
public void onSuccess(GWTWorkspaceItem result) {
|
||||
if (isInteralImage) {
|
||||
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 {
|
||||
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) {
|
||||
|
@ -286,6 +343,11 @@ public class ClientImage extends Composite {
|
|||
return expectedContent;
|
||||
}
|
||||
|
||||
|
||||
public BasicComponent getBasicComponent() {
|
||||
return basicComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param expectedContent .
|
||||
|
|
|
@ -111,8 +111,10 @@ public class GenericTable extends Composite {
|
|||
VerticalPanel attributesPanel = getAttributesPanel(sTable);
|
||||
attributesPanel.setStyleName("tableAttributesPanel");
|
||||
|
||||
controlPanel.setStyleName("tableControlPanel");
|
||||
myPanel.add(controlPanel);
|
||||
if (! isLocked) {
|
||||
controlPanel.setStyleName("tableControlPanel");
|
||||
myPanel.add(controlPanel);
|
||||
}
|
||||
myPanel.add(myTable);
|
||||
myPanel.add(attributesPanel);
|
||||
myPanel.setStyleName("tablePanel");
|
||||
|
@ -437,7 +439,7 @@ public class GenericTable extends Composite {
|
|||
ArrayList<TableCell> toReturn = new ArrayList<TableCell>();
|
||||
for (int j = 0; j < myTable.getCellCount(i); j++) {
|
||||
GenTableCell tb = (GenTableCell) myTable.getWidget(i, j);
|
||||
int colspan = tb.getColspan();
|
||||
int colspan = tb.getColspan();
|
||||
|
||||
toReturn.add(new TableCell(tb.getText(), colspan, tb.getWidth(), tb.getHeight()));
|
||||
}
|
||||
|
@ -604,6 +606,8 @@ public class GenericTable extends Composite {
|
|||
|
||||
|
||||
protected void resetMe() {
|
||||
titleTB.setText("");
|
||||
descTB.setText("");
|
||||
myTable.removeAllRows();
|
||||
/**
|
||||
* construct the table
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
.addEntryButton {
|
||||
background-image: none !important;
|
||||
background-repeat: none !important;
|
||||
background-color: #02990C !important
|
||||
background-color: #02990C !important;
|
||||
color: #FFF !important;
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue