Headerbar
class is the top bar component of the UI
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ *
+ * @version July 2011 (3.0)
+ */
+public class Headerbar extends Composite{
+
+ private static final String ADD_BIBLIO_ENTRY = "Add citation";
+ private static final String VIEW_BIBLIO = "View Bibliography";
+ private static final String MANAGE_BIBLIO = "Delete citation(s)";
+ private static final String EXPORT_OPENXML = "Export to OpenXML (docx)";
+ private static final String EXPORT_HTML = "Export to HTML";
+ private static final String EXPORT_FIMES = "Export to FiMES XML";
+
+ private static final String VIEW_USER_COMMENTS = "View user comments";
+
+ String location;
+
+ private Presenter presenter;
+
+ /**
+ * the template Model
+ */
+ private TemplateModel templateModel;
+
+ /**
+ * mainLayout Panel
+ */
+ private CellPanel mainLayout = new HorizontalPanel();
+
+
+ //private MenuItem optionPDF;
+
+ private MenuItem importModel;
+
+ private MenuItem addBiblioEntry;
+
+ private MenuItem viewBiblio;
+
+ private MenuItem manageBiblio;
+
+ private MenuItem optionHTML;
+
+ private MenuItem optionDOCX;
+
+ private MenuItem optionFimes;
+
+ private MenuItem viewMetadata;
+
+ private MenuItem viewComments;
+
+ private MenuItem discardSection;
+
+
+
+ MenuBar menuBar = new MenuBar();
+
+ MenuItem fileMenu;
+ MenuItem viewMenu;
+ MenuItem sectionsMenu;
+ MenuItem biblioMenu;
+ MenuItem exportMenu;
+ MenuItemSeparator separator1;
+ MenuItemSeparator separator2;
+ MenuItemSeparator separator3;
+ MenuItemSeparator separator4;
+
+ /**
+ * Constructor
+ * @param c the controller instance for this UI component
+ */
+ public Headerbar(Presenter c) {
+ this.presenter = c;
+ this.templateModel = presenter.getModel();
+
+ menuBar.setAutoOpen(false);
+ // menuBar.setWidth("100px");
+ menuBar.setAnimationEnabled(true);
+ fileMenu = getFileMenu();
+ menuBar.addItem(fileMenu);
+ separator1 = menuBar.addSeparator();
+ viewMenu = getViewMenu();
+ menuBar.addItem(viewMenu);
+ separator2 = menuBar.addSeparator();
+ sectionsMenu = getSectionMenu();
+ menuBar.addItem(sectionsMenu);
+ separator3 = menuBar.addSeparator();
+ biblioMenu = getBiblioMenu();
+ menuBar.addItem(biblioMenu);
+ separator4 = menuBar.addSeparator();
+ exportMenu = getExportsMenu();
+ menuBar.addItem(exportMenu);
+
+ mainLayout.setSize("100%", "24px");
+ mainLayout.setStyleName("menubar");
+
+ mainLayout.add(menuBar);
+
+ //design the part for the template name and the pages handling
+
+ HorizontalPanel captionPanel = new HorizontalPanel();
+ captionPanel.setWidth("100%");
+
+ HorizontalPanel pageHandlerPanel = new HorizontalPanel();
+ pageHandlerPanel.setHeight("24");
+ pageHandlerPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+
+ captionPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ mainLayout.add(captionPanel);
+ mainLayout.add(pageHandlerPanel);
+ mainLayout.setCellHorizontalAlignment(menuBar, HasHorizontalAlignment.ALIGN_LEFT);
+ mainLayout.setCellHorizontalAlignment(captionPanel, HasHorizontalAlignment.ALIGN_LEFT);
+ mainLayout.setCellWidth(menuBar, "200");
+ mainLayout.setCellWidth(pageHandlerPanel, "200");
+ initWidget(mainLayout);
+ }
+
+ public void setMenuForWorkflowDocument(boolean canUpdate) {
+ presenter.setMenuForWorkflowDocument(true);
+ menuBar.removeItem(fileMenu);
+ menuBar.removeItem(viewMenu);
+ menuBar.removeItem(sectionsMenu);
+ menuBar.removeItem(biblioMenu);
+ menuBar.removeSeparator(separator1);
+ menuBar.removeSeparator(separator2);
+ menuBar.removeItem(exportMenu);
+
+ MenuBar workflowMenu = new MenuBar(true);
+ workflowMenu.setAnimationEnabled(true);
+
+ MenuItem menu = new MenuItem(" CommonCommands
class contains the menu commands for the UI
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ *
+ * @version December 2012 (2.7)
+ */
+public class CommonCommands {
+ /**
+ *
+ */
+ public Command openTemplate;
+ /**
+ *
+ */
+ public Command importTemplateCommand;
+ /**
+ *
+ */
+ public Command insertImage;
+ /**
+ *
+ */
+ public Command saveTemplate;
+ /**
+ *
+ */
+ public Command pickColor;
+
+ private Presenter presenter;
+
+ /**
+ *
+ * @param presenter .
+ */
+ public CommonCommands(final Presenter presenter) {
+ this.presenter = presenter;
+ openTemplate = new Command() {
+ public void execute() {
+ final int left = presenter.getHeader().getMainLayout().getAbsoluteLeft() + 50;
+ final int top = presenter.getHeader().getMainLayout().getAbsoluteTop() + 25;
+
+ GWT.runAsync(WorkspaceLightTreeLoadPopup.class, new RunAsyncCallback() {
+ public void onSuccess() {
+ WorkspaceLightTreeLoadPopup wpTreepopup = new WorkspaceLightTreeLoadPopup("Open Template", true, true);
+ wpTreepopup.setShowableTypes(ItemType.REPORT_TEMPLATE);
+ wpTreepopup.setSelectableTypes(ItemType.REPORT_TEMPLATE);
+
+
+ wpTreepopup.addPopupHandler(new PopupHandler() {
+ public void onPopup(PopupEvent event) {
+ if (! event.isCanceled()) {
+ if (event.getSelectedItem() != null) {
+ presenter.openTemplate(event.getSelectedItem().getName(), event.getSelectedItem().getId(), true);
+ }
+ }
+
+ }
+ });
+
+ wpTreepopup.setPopupPosition(left, top);
+ wpTreepopup.show();
+ }
+
+ public void onFailure(Throwable reason) {
+ Window.alert("There are networks problem, please check your connection.");
+ }
+ });
+ }
+ };
+
+
+ insertImage = new Command() {
+ public void execute() {
+ int left = presenter.getHeader().getMainLayout().getAbsoluteLeft() + 50;
+ int top = presenter.getHeader().getMainLayout().getAbsoluteTop() + 25;
+ ImageUploaderDialog dlg = new ImageUploaderDialog(presenter);
+ dlg.setAnimationEnabled(true);
+ dlg.setPopupPosition(left, top);
+ dlg.show();
+ }
+ };
+
+ pickColor = new Command() {
+ public void execute() {
+ int left = presenter.getHeader().getMainLayout().getAbsoluteLeft() + 600;
+ int top = presenter.getHeader().getMainLayout().getAbsoluteTop() + 50;
+ final PopupPanel pp = new PopupPanel(true);
+
+ ColorPalette colorPalette = new ColorPalette();
+ colorPalette.addListener(Events.Select, new ListeneronModuleLoad()
.
+ *
+ *
+ * ReportGen
class is the Entry point class, defines the main layout of the UI
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ *
+ * @version June 2011 (3.0)
+ */
+public class ReportGenerator implements EntryPoint {
+
+ /**
+ *
+ */
+ public static final int HEADER_HEIGHT = 25;
+ /**
+ *
+ */
+ public static final int PAGE_LEFT = 5;
+ /**
+ *
+ */
+ public static final int TOOLBOX_LEFT = 15;
+ /**
+ *
+ */
+ public static final int TEMPLATE_LEFT = 230;
+ /**
+ *
+ */
+ public static final int TEMPLATE_TOP = HEADER_HEIGHT + 60;
+ /**
+ *
+ */
+ public static ReportGenerator singleton = null;
+ /**
+ *
+ * @return .
+ */
+ public static ReportGenerator get() {
+ return singleton;
+ }
+ /**
+ * the controller
+ */
+ private Presenter presenter;
+
+ private VerticalPanel mainLayout = new VerticalPanel();
+
+ private ToolboxPanel toolBoxPanel;
+
+ private Headerbar header;
+
+ private TitleBar titlebar;
+
+ private WorkspacePanel workSpacePanel;
+
+ private VerticalPanel eastPanel = new VerticalPanel();
+
+ private VerticalPanel toolbarPanel = new VerticalPanel();
+
+ private ScrollPanel bottomScrollerPanel = new ScrollPanel();
+
+ private AppControllerExplorer treeController;
+
+ private HTML divHidden = new HTML();
+ /**
+ * This is the entry point method.
+ */
+ public void onModuleLoad() {
+ singleton = this;
+ presenter = new Presenter();
+ treeController = new AppControllerExplorer();
+ mainLayout.setWidth("100%");
+ mainLayout.setHeight("100%");
+ //
+ workSpacePanel = new WorkspacePanel(presenter);
+ titlebar = new TitleBar(presenter);
+ header = new Headerbar(presenter);
+ toolBoxPanel = new ToolboxPanel(treeController);
+
+ presenter.setHeader(header);
+ presenter.setTitleBar(titlebar);
+ presenter.setWp(workSpacePanel);
+ presenter.setToolBoxPanel(toolBoxPanel);
+
+ mainLayout.add(titlebar);
+ mainLayout.add(header);
+ mainLayout.add(toolbarPanel);
+
+ toolbarPanel.setWidth("100%");
+ toolbarPanel.setHeight("40");
+
+
+ CellPanel cellPanel = new HorizontalPanel();
+ cellPanel.setStyleName("cella");
+ cellPanel.add(toolBoxPanel);
+ cellPanel.add(bottomScrollerPanel);
+
+ cellPanel.setCellWidth(toolBoxPanel, "230");
+
+ mainLayout.add(cellPanel);
+
+ divHidden.setStyleName("d4sFrame");
+ divHidden.setWidth("500");
+ divHidden.setStyleName("d4sRichTextArea");
+ divHidden.addStyleName("setVisibilityOff");
+ divHidden.addStyleName("hasRichTextToolbar");
+
+ eastPanel.add(workSpacePanel);
+ eastPanel.add(divHidden);
+ bottomScrollerPanel.add(eastPanel);
+ presenter.addTextToolBar();
+
+ // Add image and button to the RootPanel
+ RootPanel.get("ReportGeneratorDIV").add(mainLayout);
+
+ int scrollerWidth = Window.getClientWidth()- TEMPLATE_LEFT - 30;
+ bottomScrollerPanel.setPixelSize(scrollerWidth, 1000);
+
+ if ( Window.getClientWidth() < 1070 ) {
+ int scrollerWidth2 = Window.getClientWidth()- TEMPLATE_LEFT;
+ bottomScrollerPanel.setPixelSize(scrollerWidth2, 1000);
+ }
+
+ Window.addResizeHandler(new ResizeHandler() {
+ public void onResize(ResizeEvent event) {
+ int scrollerHeight = event.getHeight() - bottomScrollerPanel.getAbsoluteTop();
+ if (scrollerHeight < toolBoxPanel.getTreePanelHeight())
+ scrollerHeight = toolBoxPanel.getTreePanelHeight();
+ int scrollerWidth = Window.getClientWidth()- TEMPLATE_LEFT - 30;
+ bottomScrollerPanel.setPixelSize(scrollerWidth , 1000);
+
+
+ if ( Window.getClientWidth() < 1060 ) {
+ int scrollerWidth2 = Window.getClientWidth()- TEMPLATE_LEFT;
+ bottomScrollerPanel.setPixelSize(scrollerWidth2, 1000);
+ }
+ }
+
+ });
+
+ showGuidedTour() ;
+
+ }
+ private void showGuidedTour() {
+
+ GWT.runAsync(GCUBEGuidedTour.class, new RunAsyncCallback() {
+ public void onSuccess() {
+ TourStep step1 = new GCUBETemplate1Text1Image(true) {
+
+ @Override
+ public String setStepTitle() {
+ return "gCube Reporting";
+ }
+
+ @Override
+ public String setStepImage() {
+ return "images/tour/tour1.jpg";
+ }
+
+ @Override
+ public String setStepBody() {
+ return new Intro().getHTML();
+ }
+ };
+
+ TourStep step2 = new GCUBETemplate1Text1Image(false) {
+
+ @Override
+ public String setStepTitle() {
+ return "Structure View";
+ }
+
+ @Override
+ public String setStepImage() {
+ return "images/tour/tour2.jpg";
+ }
+ @Override
+ public String setStepBody() {
+ return " TitleBar
class is the top top bar component of the UI
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ *
+ * @version July 2011 (3.0)
+ */
+ public class TitleBar extends Composite{
+
+
+ private Presenter presenter;
+
+ /**
+ * the template Model
+ */
+ private TemplateModel templateModel;
+
+ /**
+ * mainLayout Panel
+ */
+ private CellPanel mainLayout = new HorizontalPanel();
+
+ /**
+ * contains the current template name
+ */
+ private HTML templateNameBox = new HTML();
+
+ /**
+ * contains the last edit date and the the last edit person username
+ */
+ private HTML editedOn = new HTML();
+ /**
+ * contains the page displayer
+ */
+ private HTML pageDisplayer = new HTML();
+
+
+ private HTML prevButton = new HTML(" ", true);
+ private HTML nextButton = new HTML(" ", true);
+
+
+ /**
+ * Constructor
+ * @param c the controller instance for this UI component
+ */
+ public TitleBar(Presenter c) {
+ this.presenter = c;
+ this.templateModel = presenter.getModel();
+
+
+ //initialize the template
+ setTemplateName(templateModel.getTemplateName());
+
+ setPageDisplayer(1, 1);
+
+
+ mainLayout.setSize("90%", "24px");
+// mainLayout.setStyleName("newresultset-header");
+
+
+
+ //design the part for the template name and the pages handling
+
+ HorizontalPanel captionPanel = new HorizontalPanel();
+ HorizontalPanel innerCaptionPanel = new HorizontalPanel();
+ captionPanel.setWidth("100%");
+
+ //hide the buttons at the beginning
+ nextButton.addStyleName("setVisibilityOff");
+ prevButton.addStyleName("setVisibilityOff");
+
+ HorizontalPanel pageHandlerPanel = new HorizontalPanel();
+ pageHandlerPanel.setHeight("24");
+ pageHandlerPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+
+ pageHandlerPanel.add(prevButton);
+ pageHandlerPanel.add(pageDisplayer);
+ pageHandlerPanel.add(nextButton);
+ pageHandlerPanel.setWidth("100%");
+
+ templateNameBox.setStyleName("menubar-font");
+
+ captionPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
+ innerCaptionPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
+ innerCaptionPanel.setVerticalAlignment(HasAlignment.ALIGN_BOTTOM);
+ innerCaptionPanel.add(templateNameBox);
+ innerCaptionPanel.add(editedOn);
+ captionPanel.add(innerCaptionPanel);
+ mainLayout.add(captionPanel);
+ mainLayout.add(pageHandlerPanel);
+ editedOn.setStyleName("docEditedBy");
+ mainLayout.setCellHorizontalAlignment(captionPanel, HasHorizontalAlignment.ALIGN_LEFT);
+
+ mainLayout.setCellWidth(pageHandlerPanel, "200");
+ initWidget(mainLayout);
+
+ nextButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) { presenter.nextPageButtonClicked();
+ }
+ });
+
+ prevButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) { presenter.prevPageButtonClicked(); }
+ });
+ }
+
+ /**
+ * changes the pages label in the UI : e.g. Page x of y
+ * @param currentPage .
+ * @param totalPages .
+ */
+ public void setPageDisplayer(int currentPage, int totalPages) {
+ pageDisplayer.setHTML("Section "+ currentPage + " of " + totalPages);
+ }
+
+ /**
+ * changes the template name label in the UI
+ * @param name .
+ */
+ public void setTemplateName(String name) {
+ templateNameBox.setHTML(" " + name);
+ }
+
+ /**
+ * changes the template name label in the UI
+ * @param username .
+ * @param date .
+ */
+ public void setEditedOnBy(Date date, String username) {
+ String dt = DateTimeFormat.getShortDateFormat().format(date);
+
+ editedOn.setHTML(" edited on " + dt + " by " + username);
+ }
+ /**
+ * Shows the previous botton in the UI
+ */
+ public void showPrevButton() {
+ prevButton.removeStyleName("setVisibilityOff");
+ prevButton.addStyleName("setVisibilityOn");
+ }
+ /**
+ * Shows the next botton in the UI
+ */
+ public void showNextButton() {
+ nextButton.removeStyleName("setVisibilityOff");
+ nextButton.addStyleName("setVisibilityOn");
+ }
+
+ /**
+ * Hide the previous botton in the UI
+ */
+ public void hidePrevButton() {
+ prevButton.removeStyleName("setVisibilityOn");
+ prevButton.addStyleName("setVisibilityOff");
+ }
+ /**
+ * Hide the next botton in the UI
+ */
+ public void hideNextButton() {
+ nextButton.removeStyleName("setVisibilityOn");
+ nextButton.addStyleName("setVisibilityOff");
+ }
+ /**
+ * temporary command
+ * @return the command instance
+ */
+ public Command getNullCommand() {
+ Command openNothing = new Command() {
+
+ public void execute() {
+ Window.alert("Feature not supported yet");
+
+ }
+ };
+
+ return openNothing;
+ }
+
+
+ }
+
+
diff --git a/src/main/java/org/gcube/portlets/user/reportgenerator/client/ToolboxPanel.java b/src/main/java/org/gcube/portlets/user/reportgenerator/client/ToolboxPanel.java
new file mode 100644
index 0000000..2837cd9
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/reportgenerator/client/ToolboxPanel.java
@@ -0,0 +1,53 @@
+package org.gcube.portlets.user.reportgenerator.client;
+
+//
+//import org.gcube.portlets.user.workspace.client.tree.WorkspaceTreePanel;
+//import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspace;
+
+import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
+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.SimplePanel;
+
+/**
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ *
+ * @version April 2012 (1.1)
+ */
+
+public class ToolboxPanel extends SimplePanel {
+ private AppControllerExplorer appController;
+ /**
+ *
+ */
+ public static final int TOOLBOX_WIDTH = 235;
+ /**
+ *
+ */
+ public static final int TOOLBOX_HEIGHT= 800;
+
+ /**
+ * constructor
+ */
+ public ToolboxPanel(AppControllerExplorer appController) {
+ this.appController = appController;
+ AsyncTreePanel tp = appController.getTree(TOOLBOX_WIDTH, TOOLBOX_HEIGHT);
+ add(tp);
+ }
+
+ /**
+ * refresh the root
+ */
+ public void refreshRoot() {
+ appController.refreshRoot();
+ }
+ /**
+ * lalala
+ * @return the toolbox height
+ */
+ public int getTreePanelHeight() {
+ return TOOLBOX_HEIGHT;
+ }
+}
diff --git a/src/main/java/org/gcube/portlets/user/reportgenerator/client/WorkspacePanel.java b/src/main/java/org/gcube/portlets/user/reportgenerator/client/WorkspacePanel.java
new file mode 100644
index 0000000..1f38199
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/reportgenerator/client/WorkspacePanel.java
@@ -0,0 +1,160 @@
+package org.gcube.portlets.user.reportgenerator.client;
+
+
+
+import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
+import org.gcube.portlets.user.reportgenerator.client.model.TemplateModel;
+import org.gcube.portlets.user.reportgenerator.client.targets.DoubleColumnPanel;
+
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+
+/**
+ * WorkspacePanel
class is the UI Component for displaying the template
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version October 2008 (0.2)
+ */
+
+public class WorkspacePanel extends Composite {
+ /**
+ * the model
+ */
+ private TemplateModel templateModel;
+
+ /**
+ * the controller
+ */
+ private Presenter presenter;
+ /**
+ *
+ */
+ public static WorkspacePanel singleton = null;
+
+
+ /**
+ * used to place two compoenents on the same Y
+ */
+ private boolean waitForNextOne = false;
+
+ /**
+ * elements arrive one by one, to place two on the same Y this bufferedWidget is used;
+ */
+ private Widget bufferedWidget;
+ /**
+ *
+ * @return .
+ */
+ public static WorkspacePanel get() {
+ return singleton;
+ }
+
+ /**
+ * the panel for the layout of the working space
+ */
+ private FlowPanel mainLayout = new FlowPanel();
+
+ /**
+ *
+ * @param c the controller instance
+ */
+ public WorkspacePanel(Presenter c) {
+ singleton = this;
+ presenter = c;
+
+ templateModel = presenter.getModel();
+
+ mainLayout.setSize(""+templateModel.getPageWidth(), ""+templateModel.getPageHeight());
+
+ //mainLayout.setStyleName("wpFlow");
+ //mainLayout.addStyleName("position-relative");
+
+
+ initWidget(mainLayout);
+
+
+ }
+
+ /**
+ *
+ * @param w .
+ * @param isDoubleColumnLayout .
+ */
+ public void addComponentToLayout(Widget w, boolean isDoubleColumnLayout) {
+ waitForNextOne = isDoubleColumnLayout;
+
+ if (! waitForNextOne) {
+ mainLayout.add(w);
+ bufferedWidget = null;
+ }
+ else {
+ if (bufferedWidget == null)
+ bufferedWidget = w;
+ else {
+ DoubleColumnPanel toAdd = new DoubleColumnPanel(bufferedWidget, w);
+ mainLayout.add(toAdd);
+ bufferedWidget = null;
+ }
+ }
+ //mainLayout.add(w, x, y);
+ }
+
+ /**
+ *
+ * @param w the widget to remove
+ * @return true if the romove is successfull
+ */
+ public boolean removeComponentFromLayout(Widget w) {
+ return mainLayout.remove(w);
+ }
+
+ /**
+ *
+ * @param model .
+ */
+ public void setModel(TemplateModel model ) {
+ this.templateModel = model;
+ }
+
+ /**
+ * resizes the workspace panel
+ * @param width .
+ * @param height .
+ */
+ public void resizeWorkspace(int width, int height) {
+ mainLayout.setPixelSize(width, height);
+ }
+
+ /**
+ *
+ * @param toMove .
+ * @param left .
+ * @param top .
+ */
+ public void moveWidget(Widget toMove, int left, int top) {
+ // mainLayout.setWidgetPosition(toMove, left, top);
+// GWT.log("MOVED? " + top, null);
+ }
+
+ /**
+ *
+ * @param toResize the widget to resize
+ * @param newWidth .
+ * @param newHeight .
+ */
+ public void resizeWidget(Widget toResize, int newWidth, int newHeight) {
+ toResize.setPixelSize(newWidth, newHeight);
+ }
+
+ /**
+ *
+ * @return .
+ */
+ public FlowPanel getMainLayout() {
+ return mainLayout;
+ }
+
+}
+
diff --git a/src/main/java/org/gcube/portlets/user/reportgenerator/client/components/FancyFileUpload.java b/src/main/java/org/gcube/portlets/user/reportgenerator/client/components/FancyFileUpload.java
new file mode 100644
index 0000000..115f9fa
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/reportgenerator/client/components/FancyFileUpload.java
@@ -0,0 +1,492 @@
+package org.gcube.portlets.user.reportgenerator.client.components;
+
+import org.gcube.portlets.user.reportgenerator.client.dialog.ImageUploaderDialog;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ChangeListener;
+import com.google.gwt.user.client.ui.ChangeListenerCollection;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FileUpload;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.FormHandler;
+import com.google.gwt.user.client.ui.FormPanel;
+import com.google.gwt.user.client.ui.FormSubmitCompleteEvent;
+import com.google.gwt.user.client.ui.FormSubmitEvent;
+import com.google.gwt.user.client.ui.HasText;
+import com.google.gwt.user.client.ui.HasWordWrap;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.SourcesChangeEvents;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * FancyFileUpload
class is use to upload images from client in the UI
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version October 2008 (0.2)
+ */
+public class FancyFileUpload extends Composite implements HasText, HasWordWrap, SourcesChangeEvents{
+
+ /**
+ * State definitions
+ */
+ public final int EMPTY_STATE = 1;
+ /**
+ *
+ */
+ public final int PENDING_STATE = 2;
+ /**
+ *
+ */
+ public final int UPLOADING_STATE = 3;
+ /**
+ *
+ */
+ public final int UPLOADED_STATE = 4;
+ /**
+ *
+ */
+ public final int DELETED_STATE = 5;
+ /**
+ *
+ */
+ public final int FAILED_STATE = 6;
+
+ /**
+ * Initial State of the widget.
+ */
+ private int widgetState = EMPTY_STATE;
+
+ /**
+ * Default delay to check an empty FileUpload widget for
+ * arrival of a filename.
+ *
+ */
+ private int searchUpdateDelay = 500;
+
+ /**
+ * Default delay for pending state, when delay over the form is
+submitted.
+ */
+ private int pendingUpdateDelay = 5000;
+
+ /**
+ * the panel where this widget is in
+ */
+ private ImageUploaderDialog theOwner;
+
+
+ /**
+ * OK message expected from file upload servlet to indicate successful
+upload.
+ */
+ //private String retursOKMessage = "OK"; + + private FormPanel uploadForm = new FormPanel(); + private VerticalPanel mainPanel = new VerticalPanel(); + + /** + * Internal timer for checking fileupload text for a value. + */ + private Timer t; + + /** + * Internal timer for checking if pending delay is over. + */ + private Timer p; + + /** + * Widget representing file to be uploaded. + */ + private UploadDisplay uploadItem; + + /** + * FileName to be uploaded + */ + String fileName = ""; + + + /** + * Class used for the display of filename to be uploaded, + * and handling the update of the display states. + * + * + */ + protected class UploadDisplay extends Composite{ + + /** + * FileUpload Widget + */ + FileUpload uploadFileWidget = new FileUpload(); + + /** + * Label to display after file widget is filled with a filename + */ + Label uploadFileName = new Label(); + + + /** + * Panel to hold the widget + */ + FlowPanel mainPanel = new FlowPanel(); + + /** + * Panel to hold pending, loading, loaded or failed state details. + */ + HorizontalPanel pendingPanel = new HorizontalPanel(); + + /** + * Constructor + * + */ + public UploadDisplay(){ + + mainPanel.add(uploadFileWidget); + pendingPanel.add(uploadFileName); + uploadFileName.setStyleName("HTMLObjectStyle-font"); + uploadFileName.setWordWrap(true); + uploadFileWidget.setWidth("100%"); + + mainPanel.add(pendingPanel); + pendingPanel.setVisible(false); + initWidget(mainPanel); + } + + /** + * Set the widget into pending mode by altering style + * of pending panel and displaying it. Hide the FileUpload + * widget and finally set the state to Pending. + * + */ + private void setPending(){ + uploadFileName.setText("Please wait, fetching image from your file system.. ");//uploadFileWidget.getFilename()); + uploadFileWidget.setVisible(false); + pendingPanel.setVisible(true); + pendingPanel.setStyleName("fancyfileupload-pending"); + widgetState = PENDING_STATE; + } + + /** + * Set the widget into Loading mode by changing the style name + * and updating the widget State to Uploading. + * + */ + private void setLoading(){ + pendingPanel.setStyleName("fancyfileupload-loading"); + widgetState = UPLOADING_STATE; + } + + /** + * Set the widget to Loaded mode by changing the style name + * and updating the widget State to Loaded. + * + */ + private void setLoaded(){ + pendingPanel.setStyleName("fancyfileupload-loaded"); + uploadFileName.setText("Image Successfully uploaded"); + widgetState = UPLOADED_STATE; + } + + + /** + * Set the widget to Failed mode by changing the style name + * and updating the widget State to Failed. + * Additionally, hide the pending panel and display the FileUpload + * widget. + * + */ + private void setFailed(){ + widgetState = FAILED_STATE; + uploadFileName.setText("Operation Failed"); + } + + } + + /** + * Perform the uploading of a file by changing state of display widget + * and then calling form.submit() method. + * + */ + private void uploadFiles(){ + fileName = uploadItem.uploadFileWidget.getFilename(); + + uploadItem.setLoading(); + uploadForm.submit(); + + } + + + /** + * Put the widget into a Pending state, set the Pending delay timer + * to call the upload file method when ran out. + * + */ + private void pendingUpload(){ + // Fire an onChange event to anyone who is listening + uploadItem.setPending(); + p = new Timer(){ + public void run() { + uploadFiles(); + } + }; + p.schedule(pendingUpdateDelay); + } + + /** + * Method to check if FileUpload Widget has a filename within it. + * If so, cancel the timer that was set to call this method and then + * call the pendingUpload() method. + * If not, do nothing. + * + */ + private void checkForFileName(){ +// GWT.log(uploadItem.uploadFileWidget.getFilename()+" :"+fileName,null); +// if (!uploadItem.uploadFileWidget.getFilename().equals("")){ +// if (!uploadItem.uploadFileWidget.getFilename().equals(fileName)){ +// t.cancel(); +// pendingUpload(); +// } +// } + } + + /** + * This method sets up a repeating schedule to call the +checkforfilename + * method to see if the FileUpload widget has any text in it. + * + */ + private void startWaiting(){ + t = null; + t = new Timer(){ + public void run() { + checkForFileName(); + } + }; + t.scheduleRepeating(searchUpdateDelay); + } + + /** + * + * @param owner the caller + * @param templateName . + */ + public FancyFileUpload(ImageUploaderDialog owner, String templateName){ + + this.theOwner = owner; + // Set Form details + // Set the action to call on submit + + uploadForm.setAction(GWT.getModuleBaseURL() + "ImagesUploadServlet?currTemplateName=" + templateName); + + + // Set the form encoding to multipart to indicate a file upload + uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); + // Set the method to Post + uploadForm.setMethod(FormPanel.METHOD_POST); + uploadForm.setWidget(mainPanel); + + // Create a new upload display widget + uploadItem = new UploadDisplay(); + // Set the name of the upload file form element + uploadItem.uploadFileWidget.setName("uploadFormElement"); + // Add the new widget to the panel. + mainPanel.add(uploadItem); + HorizontalPanel wrapper = new HorizontalPanel(); + wrapper.setSpacing(4); + // Add a 'submit' button. + wrapper.add(new Button("Submit", new ClickListener() { + public void onClick(Widget sender) { + String fName = uploadItem.uploadFileWidget.getFilename(); + + + int slashPosition = fName.lastIndexOf("/"); + + String fileNameToCheck = "" ; + + if (slashPosition == -1) //it is windows + slashPosition = fName.lastIndexOf("\\"); + + if (slashPosition != -1) + fileNameToCheck = fName.substring(slashPosition+1, fName.length()); + + if (fName.equals("")) { + Window.alert("The text box must not be empty"); + } + else if (fileNameToCheck.indexOf(" ") > -1) { + Window.alert("File name cannot contain empty spaces"); + + } + else { + t.cancel(); + pendingUpload(); + } + } + })); + + // Add a 'close' button. + wrapper.add(new Button("Cancel", new ClickListener() { + public void onClick(Widget sender) { + theOwner.hide(); + } + })); + mainPanel.add(wrapper); + + // Start the waiting for a name to appear in the file upload widget. + startWaiting(); + // Initialise the widget. + initWidget(uploadForm); + + // Add an event handler to the form. + uploadForm.addFormHandler(new FormHandler() { + public void onSubmitComplete(FormSubmitCompleteEvent event) { + // Fire an onChange Event + fireChangeEvent(); + // Cancel all timers to be absolutely sure nothing is going on. + t.cancel(); + p.cancel(); + // Ensure that the form encoding is set correctly. + uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); + // Check the result to see if an OK message is returned from the server. + + if(event.getResults().toString().contains("OK") || event.getResults().toString().startsWith("OK")) { + uploadItem.setLoaded(); + String fName = uploadItem.uploadFileWidget.getFilename(); + + String nameToPass = ""; + if (fName.lastIndexOf("/") == -1) //windows + nameToPass = fName.substring(fName.lastIndexOf("\\")+1); + else + nameToPass = fName.substring(fName.lastIndexOf("/")+1); + + theOwner.insertImage(nameToPass); + theOwner.hide(); + + } else { + // If no, set the widget to failed state. + uploadItem.setFailed(); + Window.alert("There were some errors during File Uploading processing,Please try again"); + } + } + + public void onSubmit(FormSubmitEvent event) { + //No validation in this version. + } + }); + } + + /** + * Fire a change event to anyone listening to us. + * + */ + private void fireChangeEvent(){ + if (changeListeners != null) + changeListeners.fireChange(this); + } + + /** + * Get the text from the widget - which in reality will be retrieving any + * value set in the Label element of the display widget. + * @return . + */ + public String getText() { + return uploadItem.uploadFileName.getText(); + } + + /** + * Cannot set the text of a File Upload Widget, so raise an exception. + * @param text . + */ + public void setText(String text) { + throw new RuntimeException("Cannot set text of a FileUpload Widget"); + } + + /** + * Retrieve the status of the upload widget. + * @return Status of upload widget. + * + */ + public int getUploadState(){ + return widgetState; + } + + /** + * Set the delay for checking for a filename to appear in the FileUpload widget + * Might be useful if there are performance issues. + * @param newDelay . + */ + public void setCheckForFileNameDelay(int newDelay){ + searchUpdateDelay = newDelay; + } + + /** + * Set the delay value indicating how long a file will remain in +pending mode + * prior to the upload action taking place. + * @param newDelay . + */ + public void setPendingDelay(int newDelay){ + pendingUpdateDelay = newDelay; + } + + /** + * Return the delay value set for checking a file. + * @return . + */ + public int getCheckForFileNameDelay(){ + return searchUpdateDelay; + } + + /** + * Return value set for pending delay. + * @return . + */ + public int getPendingDelay(){ + return pendingUpdateDelay; + } + + /** + * Return if the label in the display widget is wordwrapped or not. + * @return . + */ + public boolean getWordWrap() { + return uploadItem.uploadFileName.getWordWrap(); + } + + /** + * Set the word wrap value of the label in the display widget. + * @param wrap . + */ + public void setWordWrap(boolean wrap) { + uploadItem.uploadFileName.setWordWrap(wrap); + } + + /** + * + */ + private ChangeListenerCollection changeListeners; + + /** + * Add a change listener + * @param listener , + */ + public void addChangeListener(ChangeListener listener) { + if (changeListeners == null) + changeListeners = new ChangeListenerCollection(); + changeListeners.add(listener); + } + + /** + * Remove a change listener + * @param listener . + */ + public void removeChangeListener(ChangeListener listener) { + if (changeListeners != null) + changeListeners.remove(listener); + } + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/reportgenerator/client/dialog/AddBiblioEntryDialog.java b/src/main/java/org/gcube/portlets/user/reportgenerator/client/dialog/AddBiblioEntryDialog.java new file mode 100644 index 0000000..b39f9bd --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/reportgenerator/client/dialog/AddBiblioEntryDialog.java @@ -0,0 +1,70 @@ +package org.gcube.portlets.user.reportgenerator.client.dialog; + +import org.gcube.portlets.user.reportgenerator.client.events.AddBiblioEvent; + +import com.extjs.gxt.ui.client.event.ComponentEvent; +import com.extjs.gxt.ui.client.widget.Dialog; +import com.extjs.gxt.ui.client.widget.Window; +import com.extjs.gxt.ui.client.widget.button.Button; +import com.extjs.gxt.ui.client.widget.form.FormPanel; +import com.extjs.gxt.ui.client.widget.form.TextArea; +import com.extjs.gxt.ui.client.widget.form.TextField; +import com.extjs.gxt.ui.client.widget.layout.FitLayout; +import com.extjs.gxt.ui.client.widget.layout.FormData; +import com.google.gwt.event.shared.HandlerManager; +/** + * The
AddBiblioEntryDialog
class
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version July 2011 (3.0)
+ */
+public class AddBiblioEntryDialog extends Window {
+
+ public AddBiblioEntryDialog(final HandlerManager eventBus) {
+ setHeading("Add Citation");
+ setClosable(true);
+ setWidth(400);
+ setHeight(250);
+ setPlain(true);
+ setLayout(new FitLayout());
+
+ final TextField ManageBiblioDialog
class
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version July 2011 (3.0)
+ */
+public class DeleteCitationsDialog extends Window {
+
+ TabPanel tabPanel = new TabPanel();
+//
+ public DeleteCitationsDialog(final HandlerManager eventBus, TemplateSection bibliosection) {
+ setTitle("Delete Citations");
+ setClosable(true);
+ setWidth(400);
+ setHeight(250);
+ setPlain(true);
+ setLayout(new FitLayout());
+
+ Button deleteButton = new Button("Delete") {
+ @Override
+ protected void onClick(final ComponentEvent ce) {
+ if (tabPanel.getItemCount() > 1) {
+ eventBus.fireEvent(new RemovedCitationEvent(tabPanel.getSelectedItem().getTitle()));
+ tabPanel.remove(tabPanel.getSelectedItem());
+ }
+ else {
+ MessageBox.alert("","You cannot have a Bibliography with no citations, if you want to remove it use Section > Discard current", null);
+ }
+ }
+ };
+//
+ Button cancelButton = new Button("Close") {
+ @Override
+ protected void onClick(final ComponentEvent ce) {
+ close();
+ }
+ };
+
+ addButton(deleteButton);
+ addButton(cancelButton);
+//
+ ArrayList ImageUploaderDialog
class is the Dialog for uploading images
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version October 2008 (0.2)
+ */
+public class ImageUploaderDialog extends DialogBox {
+
+ private int width;
+ private int height;
+
+ private Presenter presenter;
+
+
+ private String currTemplateName = "";
+
+ private HorizontalPanel topLabel = new HorizontalPanel();
+
+ private EventListener listener = new EventListener();
+ private RadioButton local = new RadioButton("");
+ private RadioButton web = new RadioButton("");
+
+ /**
+ * the container panel
+ */
+ private VerticalPanel mainLayout = new VerticalPanel();
+ private VerticalPanel dialogPanel = new VerticalPanel();
+
+
+
+ /**
+ * Creates the dialog
+ * @param presenter my controller
+ */
+ public ImageUploaderDialog(Presenter presenter) {
+
+
+ // Create a dialog box and set the caption text
+ this.width = 400;
+ this.height = 200;
+ this.presenter = presenter;
+ setText("Insert Image");
+
+ local.setHTML(" From this computer");
+ topLabel.add(local);
+ local.setChecked(true);
+
+ web.setHTML(" From the web (URL)");
+ topLabel.add(web);
+ web.addClickListener(listener);
+ local.addClickListener(listener);
+
+ currTemplateName = presenter.getModel().getTemplateName();
+
+
+
+ dialogPanel.add(getFromLocalPanel());
+ dialogPanel.setPixelSize(this.width, this.height);
+
+ mainLayout.add(topLabel);
+ mainLayout.add(dialogPanel);
+ setWidget(mainLayout);
+
+ }
+
+ private VerticalPanel getFromLocalPanel() {
+ VerticalPanel toReturn = new VerticalPanel();
+ FancyFileUpload uploader = new FancyFileUpload(this, currTemplateName);
+ HTML theLabel = new HTML("Browse your computer for the image file to upload:");
+ toReturn.add(theLabel);
+ toReturn.add(uploader);
+ toReturn.setSpacing(4);
+ toReturn.setStyleName("uploadDialog");
+ toReturn.setPixelSize(this.width, this.height);
+
+ return toReturn;
+ }
+
+ private VerticalPanel getFromURLPanel() {
+ VerticalPanel toReturn = new VerticalPanel();
+
+ toReturn.setSpacing(5);
+
+ HTML theLabel = new HTML("Enter image web address:");
+ final TextBox urlTextbox = new TextBox();
+ urlTextbox.setWidth("90%");
+
+ final HTML previewBox = new HTML(" ImporterDialog
class is is the Dialog for importing template or report sections
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version October 2009 (1.4)
+ */
+public class ImporterDialog extends DialogBox {
+
+ /**
+ * this layout panel
+ */
+ private VerticalPanel dialogPanel = new VerticalPanel();
+ Image loading = new Image(ReportConstants.LOADING_BAR);
+
+ VerticalPanel toReplace = new VerticalPanel();
+ SerializableModel toimportFrom = null;
+ ListBox listbox = new ListBox();
+
+ ListBox listboxCurr = new ListBox();
+ CheckBox lastSection = new CheckBox();
+
+ Presenter presenter;
+
+ /**
+ *
+ * @param item the item to import
+ * @param presenter the c
+ */
+ public ImporterDialog(Item item, final Presenter presenter) {
+ this.presenter = presenter;
+
+ dialogPanel.setSpacing(4);
+ setText("Import from Template or Report");
+ toReplace.setWidth("100%");
+
+ HTML templateNameLabel = new HTML("Importing Template, please hold ...");
+ toReplace.add(templateNameLabel);
+ toReplace.add(loading);
+
+
+ HorizontalPanel buttonsPanel = new HorizontalPanel();
+ HorizontalPanel buttonsContainer = new HorizontalPanel();
+
+ // Add a cancel button at the bottom of the dialog
+ Button cancelButton = new Button("Close",new ClickListener() {
+ public void onClick(Widget sender) { hide(); }
+ });
+
+ Button applyButton = new Button("Import",new ClickListener() {
+ public void onClick(Widget sender) {
+ boolean result = false;
+ if (lastSection.isChecked())
+ result = Window.confirm("You are about to import section " + (listbox.getSelectedIndex()+1) + " as last section in the current document");
+ else
+ result = Window.confirm("You are about to import section " + (listbox.getSelectedIndex()+1) + " before section " + (listboxCurr.getSelectedIndex()+1) + " of the current document");
+
+ if (result)
+ presenter.importSection(toimportFrom, listbox.getSelectedIndex()+1, listboxCurr.getSelectedIndex()+1, lastSection.isChecked());
+ hide();
+ }
+ });
+
+ buttonsPanel.setWidth("100%");
+ buttonsPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
+ buttonsContainer.setSpacing(10);
+ buttonsContainer.add(applyButton);
+ buttonsContainer.add(cancelButton);
+ buttonsPanel.add(buttonsContainer);
+
+ dialogPanel.add(toReplace);
+
+
+ dialogPanel.add(buttonsPanel);
+ dialogPanel.setPixelSize(350, 275);
+ setWidget(dialogPanel);
+
+
+ AsyncCallback"+ + ""+ + " |
OpenTemplateDialog
class is is the Dialog for showing template properties
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version October 2008 (0.2)
+ */
+public class PagePropertiesDialog extends GCubeDialog {
+
+ /**
+ * this layout panel
+ */
+ private VerticalPanel dialogPanel = new VerticalPanel();
+
+ private TextBox templateNameLabelBox = new TextBox();
+
+
+ /**
+ *
+ * @param templateModel .
+ * @param presenter .
+ */
+ public PagePropertiesDialog(final TemplateModel templateModel, final Presenter presenter) {
+ setText("Report Properties");
+ dialogPanel.setSpacing(4);
+
+ HTML spacer = new HTML(" TemplateModel
class represents the current Template state, the model in the the MVC pattern
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version July 2011 (3.0)
+ */
+public class TemplateModel {
+
+ private ReportServiceAsync modelService = (ReportServiceAsync) GWT.create(ReportService.class);
+ private ServiceDefTarget endpoint = (ServiceDefTarget) modelService;
+ /**
+ * default w and h
+ */
+
+ public static final int OLD_TEMPLATE_WIDTH = 950;
+ /**
+ *
+ */
+ public static final int TEMPLATE_WIDTH = 750;
+ /**
+ * TEMPLATE_HEIGHT
+ */
+ public static final int TEMPLATE_HEIGHT= 1000;
+ /**
+ * DEFAULT_NAME
+ */
+ public static final String DEFAULT_NAME = "No template loaded";
+ public static final String BIBLIO_SECTION = "isBibliography";
+ public static final String USER_COMMENT = "isComment";
+ public static final String USER_COMMENT_HEIGHT = "isCommentHeight";
+
+ /**
+ * The name of the template
+ */
+ private String templateName;
+ /**
+ *
+ */
+ private int pageWidth;
+
+ /**
+ *
+ */
+ private int pageHeight;
+
+ /**
+ *
+ */
+ private int currentPage;
+
+ /**
+ * Total number of template pages
+ */
+ private int totalPages;
+
+ /**
+ * Template left margin
+ */
+ private int marginLeft;
+ /**
+ * Template right margin
+ */
+ private int marginRight;
+ /**
+ * Template top margin
+ */
+ private int marginTop;
+ /**
+ * Template bottom margin
+ */
+ private int marginBottom;
+
+ /**
+ * columnWidth is the actual page width without margins, when columns is equal to 1 (which is always true in my case, since UI doesn't allow multi columns)
+ */
+ private int columnWidth;
+
+ /**
+ * each object of this Hahsmap its a TemplateSection
class represents a Template Section that can be associated to any Template
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version October 2009 (1.4)
+ */
+
+public class TemplateSection {
+
+ /**
+ * holds the metadata(s) for the sections
+ */
+ private List AttributeArea
class
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version April 2011 (1.0)
+ */
+public class AttributeArea extends Composite {
+
+ private HorizontalPanel myPanel;
+ private HTML attrName;
+ private CheckBox[] boxes;
+
+ /**
+ * Coming form a template constructor
+ */
+ public AttributeArea(final Presenter presenter, int left, int top, int width, final int height, String textToDisplay) {
+ myPanel = new HorizontalPanel();
+ myPanel.setTitle("Attribute Area");
+ myPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
+ myPanel.setPixelSize(width, 20);
+ myPanel.addStyleName("attributeArea");
+
+ attrName = new HTML(getAttributeName(textToDisplay));
+ attrName.getElement().getStyle().setMarginLeft(10, Unit.PX);
+ attrName.getElement().getStyle().setMarginRight(5, Unit.PX);
+ HorizontalPanel boxesPanel = new HorizontalPanel();
+ boxesPanel.add(attrName);
+ myPanel.add(boxesPanel);
+ myPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
+ boxes = getCheckboxes(textToDisplay);
+ for (int i = 0; i < boxes.length; i++) {
+ boxesPanel.add(boxes[i]);
+ }
+ initWidget(myPanel);
+ }
+ /**
+ * Coming form a report constructor
+ */
+ public AttributeArea(final Presenter presenter, int left, int top, int width, final int height, SerializableAttributeArea sata) {
+ myPanel = new HorizontalPanel();
+ myPanel.setTitle("Attribute Area");
+ myPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
+ myPanel.setPixelSize(width, 20);
+ myPanel.addStyleName("attributeArea");
+
+ attrName = new HTML(sata.getAttrName(), true);
+ attrName.getElement().getStyle().setMarginLeft(10, Unit.PX);
+ attrName.getElement().getStyle().setMarginRight(5, Unit.PX);
+ HorizontalPanel boxesPanel = new HorizontalPanel();
+ boxesPanel.add(attrName);
+ myPanel.add(boxesPanel);
+ myPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
+ int values = sata.getValues().size();
+ boxes = new CheckBox[values];
+ int j = 0;
+ for (SerializableAttribute attr: sata.getValues()) {
+ CheckBox toAdd = new CheckBox(attr.getName());
+ toAdd.setStyleName("checkAttribute");
+ toAdd.setValue(attr.getValue());
+ boxes[j] = toAdd;
+ j++;
+ }
+
+ //adding it to the panel
+ for (int i = 0; i < boxes.length; i++) {
+ boxesPanel.add(boxes[i]);
+ }
+ initWidget(myPanel);
+ }
+ /**
+ *
+ * @param toParse
+ * @return
+ */
+ private String getAttributeName(String toParse) {
+ if (toParse == null)
+ return "";
+ String toReturn = "";
+ try {
+ toReturn = toParse.substring(0, toParse.indexOf(":"));
+ } catch (StringIndexOutOfBoundsException e) {
+ GWT.log("Could not find : returning empty");
+ }
+ return toReturn;
+ }
+ /**
+ *
+ * @param toParse
+ * @return
+ */
+ private CheckBox[] getCheckboxes(String toParse) {
+ String toSplit = toParse.substring(toParse.indexOf(":")+1, toParse.length());
+ String[] values = toSplit.split("\\|");
+ GWT.log("toSplit" + toSplit);
+ GWT.log("values" + values.length);
+ CheckBox[] boxes = new CheckBox[values.length];
+ for (int i = 0; i < values.length; i++) {
+ boxes[i] = new CheckBox();
+ boxes[i].setStyleName("checkAttribute");
+ boxes[i].setText(" " + values[i].trim());
+ }
+ return boxes;
+ }
+ /**
+ *
+ * @return
+ */
+ public ComponentType getType() {
+ return ComponentType.ATTRIBUTE;
+ }
+ /**
+ *
+ * @return
+ */
+ public CheckBox[] getBoxes() {
+ return boxes;
+ }
+ /**
+ *
+ * @return
+ */
+ public String getAttrName() {
+ return attrName.getText();
+ }
+
+
+}
+
diff --git a/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/BasicTextArea.java b/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/BasicTextArea.java
new file mode 100644
index 0000000..1762722
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/BasicTextArea.java
@@ -0,0 +1,111 @@
+package org.gcube.portlets.user.reportgenerator.client.targets;
+
+import org.gcube.portlets.d4sreporting.common.client.ComponentType;
+import org.gcube.portlets.user.reportgenerator.client.ReportGenerator;
+import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.KeyUpEvent;
+import com.google.gwt.event.dom.client.KeyUpHandler;
+import com.google.gwt.event.dom.client.MouseOutEvent;
+import com.google.gwt.event.dom.client.MouseOutHandler;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HasVerticalAlignment;
+import com.google.gwt.user.client.ui.TextArea;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+/**
+ * BasicTextArea
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version July 2011 (3.0)
+ */
+public class BasicTextArea extends ReportTextArea {
+ private TextArea textArea = new TextArea();
+ private VerticalPanel myPanel;
+ private Presenter presenter;
+
+ int currHeight = 0;
+
+
+ public BasicTextArea(ComponentType type, final Presenter presenter, int left, int top, int width, final int height, boolean hasComments) {
+ super(type, presenter, left, top, width, height, hasComments);
+ this.presenter = presenter;
+ myPanel = getResizablePanel();
+
+ textArea.setPixelSize(width, height);
+
+ textArea.addMouseOutHandler(new MouseOutHandler() {
+
+ public void onMouseOut(MouseOutEvent event) {
+ presenter.storeChangeInSession((Widget) event.getSource());
+ }
+ });
+ switch (type) {
+ case TITLE:
+ textArea.setStyleName("titleArea");
+ myPanel.setTitle("Title");
+ break;
+ case HEADING_1:
+ textArea.setStyleName("headgin1Area");
+ myPanel.setTitle("Heading: Level 1");
+ break;
+ case HEADING_2:
+ textArea.setStyleName("headgin2Area");
+ myPanel.setTitle("Heading Level 2");
+ break;
+ case HEADING_3:
+ textArea.setStyleName("headgin3Area");
+ myPanel.setTitle("Heading: Level 3");
+ break;
+ default:
+ break;
+ }
+ myPanel.add(textArea);
+ myPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
+ myPanel.setPixelSize(width, height);
+
+ textArea.addMouseOutHandler(new MouseOutHandler() {
+
+ public void onMouseOut(MouseOutEvent event) {
+ presenter.storeChangeInSession((Widget) event.getSource());
+
+ }
+ });
+
+ textArea.addKeyUpHandler(new KeyUpHandler() {
+
+ public void onKeyUp(KeyUpEvent event) {
+ HTML div = ReportGenerator.get().getDivHidden();
+ GWT.log("element.getHTML():\n" + textArea.getText(), null);
+ div.setHTML(textArea.getText());
+ int newHeight = div.getOffsetHeight();
+ if (newHeight > height-10 && newHeight != currHeight) {
+ resizeMe(myPanel.getOffsetWidth(), newHeight);
+ }
+
+ }
+ });
+
+
+ }
+ /**
+ * resize the panel
+ * @param w
+ * @param h
+ */
+ private void resizeMe(int w, int h) {
+ resizePanel(w, h);
+ //Window.alert("myInstance.top: " + myInstance.top);
+ presenter.resizeTemplateComponentInModel(this, myPanel.getOffsetWidth(), h+5);
+ }
+
+ public String getText() {
+ return textArea.getText();
+ }
+ public void setText(String text) {
+ textArea.setText(text);
+ }
+
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/Coords.java b/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/Coords.java
new file mode 100644
index 0000000..ad1ebd3
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/Coords.java
@@ -0,0 +1,26 @@
+package org.gcube.portlets.user.reportgenerator.client.targets;
+
+public class Coords {
+
+ private int X;
+ private int Y;
+ public Coords(int x, int y) {
+ super();
+ X = x;
+ Y = y;
+ }
+ public int getX() {
+ return X;
+ }
+ public void setX(int x) {
+ X = x;
+ }
+ public int getY() {
+ return Y;
+ }
+ public void setY(int y) {
+ Y = y;
+ }
+
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/D4sRichTextarea.java b/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/D4sRichTextarea.java
new file mode 100644
index 0000000..dd61df4
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/D4sRichTextarea.java
@@ -0,0 +1,227 @@
+package org.gcube.portlets.user.reportgenerator.client.targets;
+
+import org.gcube.portlets.d4sreporting.common.client.ComponentType;
+import org.gcube.portlets.user.reportgenerator.client.ReportGenerator;
+import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
+
+import com.extjs.gxt.ui.client.widget.MessageBox;
+import com.google.gwt.event.dom.client.KeyDownEvent;
+import com.google.gwt.event.dom.client.KeyDownHandler;
+import com.google.gwt.event.dom.client.KeyUpEvent;
+import com.google.gwt.event.dom.client.KeyUpHandler;
+import com.google.gwt.event.dom.client.MouseDownEvent;
+import com.google.gwt.event.dom.client.MouseDownHandler;
+import com.google.gwt.event.dom.client.MouseOutEvent;
+import com.google.gwt.event.dom.client.MouseOutHandler;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HasVerticalAlignment;
+import com.google.gwt.user.client.ui.RichTextArea;
+import com.google.gwt.user.client.ui.TextArea;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+
+/**
+ * D4sRichTextArea
class is a template component that goes into the workspace
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version October 2008 (0.2)
+ */
+public class D4sRichTextarea extends ReportTextArea {
+
+ /**
+ * the text area
+ */
+ private RichTextArea area = new RichTextArea();
+
+
+ TextArea text = new TextArea();
+ /**
+ * a flag
+ */
+ boolean firstClick = true;
+
+ int currHeight = 0;
+
+ VerticalPanel myPanel;
+ /**
+ *
+ *
+ */
+ public D4sRichTextarea() {}
+
+ /**
+ *
+ * @param presenter .
+ * @param left left
+ * @param top top
+ * @param width .
+ * @param height .
+ * @param type .
+ */
+ public D4sRichTextarea(ComponentType type, final Presenter presenter, int left, int top, int width, final int height, boolean hasComments) {
+ super(type, presenter, left, top, width, height, hasComments);
+ currHeight = height;
+ myPanel = getResizablePanel();
+
+ area.setPixelSize(width-6, height-2);
+ area.setStyleName("d4sRichTextArea");
+
+
+ switch (type) {
+ case TITLE:
+ area.addStyleName("");
+ break;
+ case HEADING_1:
+ area.addStyleName("");
+ break;
+ case HEADING_2:
+ area.addStyleName("");
+ break;
+ case HEADING_3:
+ area.addStyleName("");
+ break;
+ case BODY:
+ area.addStyleName("bodyArea");
+ break;
+ default:
+ break;
+ }
+
+
+ myPanel.add(area);
+ //repositionMyPanel(0, 15);
+ myPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
+ myPanel.setPixelSize(width, height-15);
+ setStyleName("d4sFrame");
+
+ area.addMouseDownHandler(new MouseDownHandler() {
+ public void onMouseDown(MouseDownEvent event) {
+ if (event.getNativeButton() == Event.BUTTON_RIGHT) {
+ event.preventDefault();
+ event.stopPropagation();
+ MessageBox.alert("Warning","Please, use CTRL+V (CMD+V) for pasting into this area", null);
+ }
+ if (firstClick) {
+ presenter.enableTextToolBar(area);
+ presenter.enableBiblioEntry(area);
+ firstClick = false;
+ ReportGenerator.get().getDivHidden().setPixelSize(area.getOffsetWidth(), -1);
+ }
+ HTML div = ReportGenerator.get().getDivHidden();
+ div.setHTML(area.getHTML());
+ int newHeight = div.getOffsetHeight()+20 ;
+ if (newHeight > height-10 && newHeight != currHeight) {
+ presenter.shiftComponentsByTextArea(myInstance.top, newHeight - currHeight);
+ resizePanel(myPanel.getOffsetWidth(), div.getOffsetHeight());
+ //Window.alert("myInstance.top: " + myInstance.top);
+ presenter.resizeTemplateComponentInModel(myInstance, myPanel.getOffsetWidth(), newHeight);
+ }
+ }
+ });
+
+ area.addMouseOutHandler(new MouseOutHandler() {
+ public void onMouseOut(MouseOutEvent event) {
+ firstClick = true;
+ presenter.storeChangeInSession((Widget) event.getSource());
+ }
+
+ });
+ //TODO: aggiorna
+// area.addKeyDownHandler(new KeyDownHandler() {
+// public void onKeyDown(KeyDownEvent event) {
+//// if (event.isAnyModifierKeyDown() && event.getNativeKeyCode() == 86) { //event.getNativeKeyCode() == 86 is the V (to avoid ctrl V or cmd V)
+//// MessageBox.show(new MessageBoxConfig() {
+//// {
+//// setTitle("Paste operation");
+//// setMsg("Please enter your text here (PLAIN)");
+//// setWidth(500);
+//// setButtons(MessageBox.OKCANCEL);
+//// setMultiline(true);
+//// setCallback(new MessageBox.PromptCallback() {
+//// public void execute(String btnID, String text) {
+//// if (btnID.compareTo("ok") == 0) {
+//// area.setText(text);
+////
+//// //resize if needed
+//// HTML div = ReportGenerator.get().getDivHidden();
+//// //GWT.log("element.getHTML():\n" + area.getHTML(), null);
+//// div.setHTML(area.getHTML());
+//// int newHeight = div.getOffsetHeight()+20 ;
+//// if (newHeight > height-10 && newHeight != currHeight) {
+//// resizePanel(myPanel.getOffsetWidth(), div.getOffsetHeight());
+//// }
+//// }
+////
+//// }
+//// });
+//// }
+//// });
+// event.stopPropagation();
+// event.preventDefault();
+// }
+//
+// }
+// });
+ area.addKeyUpHandler(new KeyUpHandler() {
+ public void onKeyUp(KeyUpEvent event) {
+ HTML div = ReportGenerator.get().getDivHidden();
+ div.setHTML(area.getHTML());
+ int newHeight = div.getOffsetHeight()+20 ;
+ if (newHeight > height-10 && newHeight != currHeight) {
+ presenter.shiftComponentsByTextArea(myInstance.top, newHeight - currHeight);
+ resizePanel(myPanel.getOffsetWidth(), div.getOffsetHeight());
+ //Window.alert("myInstance.top: " + myInstance.top);
+ presenter.resizeTemplateComponentInModel(myInstance, myPanel.getOffsetWidth(), newHeight);
+ }
+ }
+ });
+ }
+
+ /**
+ * used to resize the panel
+ * @param width w
+ * @param height h
+ */
+ @Override
+ public void resizePanel(int width, int height) {
+ if (height > 15 && width > 15) {
+ mainPanel.setPixelSize(width, height+20);
+ resizablePanel.setPixelSize(width, height+20);
+ mainPanel.setWidgetPosition(topPanel, width-30 , 0);
+ area.setPixelSize(width-4, height+20);
+ currHeight = height + 20;
+ }
+ }
+
+ /**
+ *
+ * @return .
+ */
+ public String getHTML() {
+ return area.getHTML();
+ }
+
+ /**
+ * @param html the html
+ */
+ public void setHTML(String html) {
+ area.setHTML(html);
+ }
+ /**
+ *
+ * @return .
+ */
+ public RichTextArea getArea() {
+ return area;
+ }
+
+ /**
+ *
+ * @param firstClick .
+ */
+ public void setFirstClick(boolean firstClick) {
+ this.firstClick = firstClick;
+ }
+}
diff --git a/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/DoubleColumnPanel.java b/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/DoubleColumnPanel.java
new file mode 100644
index 0000000..361f996
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/DoubleColumnPanel.java
@@ -0,0 +1,42 @@
+package org.gcube.portlets.user.reportgenerator.client.targets;
+
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+
+/**
+ * DoubleColumnPanel
class is a Widget that places to widget in the same y
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version October 2009 (1.4)
+ */
+public class DoubleColumnPanel extends Composite {
+
+ private Widget left;
+ private Widget right;
+
+ private HorizontalPanel mainPanel = new HorizontalPanel();
+
+
+ /**
+ *
+ * @param left .
+ * @param right .
+ */
+ public DoubleColumnPanel(Widget left, Widget right) {
+ super();
+
+ this.left = left;
+ this.right = right;
+
+ mainPanel.add(left);
+ mainPanel.add(right);
+ mainPanel.setWidth("800");
+ initWidget(mainPanel);
+
+ }
+
+
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/DropImageListener.java b/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/DropImageListener.java
new file mode 100644
index 0000000..99ef935
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/DropImageListener.java
@@ -0,0 +1,122 @@
+/**
+ *
+ */
+package org.gcube.portlets.user.reportgenerator.client.targets;
+
+
+
+import java.util.List;
+
+import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum;
+import org.gcube.portlets.user.workspace.client.model.FileModel;
+import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
+import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItemType;
+import org.gcube.portlets.user.workspace.client.workspace.folder.GWTFolderItem;
+import org.gcube.portlets.user.workspace.client.workspace.folder.GWTFolderItemType;
+import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTExternalImage;
+import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTImageDocument;
+
+import com.extjs.gxt.ui.client.dnd.DropTarget;
+import com.extjs.gxt.ui.client.dnd.Insert;
+import com.extjs.gxt.ui.client.dnd.DND.Operation;
+import com.extjs.gxt.ui.client.event.DNDEvent;
+import com.extjs.gxt.ui.client.store.TreeStoreModel;
+import com.extjs.gxt.ui.client.widget.Html;
+import com.extjs.gxt.ui.client.widget.treepanel.TreePanel;
+import com.google.gwt.core.client.GWT;
+
+
+
+/**
+ * @author Massimiliano Assante assante@isti.cnr.it
+ *
+ */
+public class DropImageListener extends DropTarget {
+ /**
+ *
+ */
+ public static final String TIFF = "image/tiff";
+
+ protected DroppingArea panel;
+
+ /**
+ *
+ * @param panel .
+ * @param config .
+ */
+ public DropImageListener(DroppingArea panel) {
+ super(panel);
+ this.panel = panel;
+ //IMPORTANT
+ setOperation(Operation.COPY);
+ }
+ @Override
+ protected void showFeedback(DNDEvent event) {
+ if (!isValidDropTarget(event)) {
+ Insert.get().hide();
+ event.getStatus().setStatus(false);
+ return;
+ }
+ super.showFeedback(event);
+ }
+
+
+ @SuppressWarnings("unchecked")
+ private boolean isValidDropTarget(DNDEvent event) {
+ GWT.log("isValidDropTarget");
+ TreePanel DroppingArea
class is a Widget you can drop image on
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version May 20012 (3.5)
+ */
+public class DroppingArea extends Component {
+
+ private String expectedContent = "";
+
+ private VerticalPanel mainPanel;
+ private Image droppedImage;
+ private Presenter presenter;
+
+ private String idInBasket;
+
+ private String currentUser;
+ private String currentScope;
+
+ Label label;
+
+ private int width, height;
+
+ /**
+ * @param presenter .
+ * @param width .
+ * @param height .
+ * @param tag the label to display
+ */
+ public DroppingArea(Presenter presenter, int width, int height, String tag) {
+ if (tag.equals("")) {
+ tag = "No suggestions available";
+ }
+ this.width = width;
+ this.height = height;
+ this.presenter = presenter;
+ mainPanel = new VerticalPanel();
+ super.setWidth(width+"px");
+ super.setHeight(height+"px");
+ mainPanel.setWidth(width+"px");
+ mainPanel.setHeight(height+"px");
+ setElement(mainPanel.getElement());
+
+ addStyleName("droppingArea-Image");
+
+ mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
+ mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+
+ label = new Label(tag);
+ label.addStyleName("label");
+ mainPanel.add(label);
+
+ droppedImage = null;
+ }
+
+ public void add(Widget w) {
+ mainPanel.add(w);
+ }
+ /**
+ * called when dropped an image on the area
+ * @param toShow the image to show
+ */
+ public void showImage(Image toShow) {
+
+ //mainPanel.remove(label);
+ mainPanel.clear();
+ this.droppedImage = toShow;
+ toShow.setPixelSize(width, height);
+
+ mainPanel.add(toShow);
+ presenter.storeChangeInSession(this);
+
+ }
+
+ /**
+ *
+ * @param url .
+ * @param id the id in the folder
+ */
+ public void dropImage(String url, String id)
+ {
+ GWT.log("URL:" + url, null);
+ idInBasket = id;
+ showImage(new Image(url));
+ }
+
+ public void fetchImage(String identifier, boolean isInteralImage, boolean fullDetails) {
+ this.mask("fetching image, pleas wait", "loading-indicator");
+ ReportGenerator.get().getWSTreeService().getImageById(identifier, isInteralImage, fullDetails, new AsyncCallback ImageArea
class is the Widget that goes into the workspace
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version October 2008 (0.2)
+ */
+public class ImageArea extends Composite {
+
+ private String templateName;
+ private String imageName;
+
+ private String currentUser;
+ private String currentScope;
+
+ VerticalPanel myPanel;
+ Image myImage = new Image();
+
+ /**
+ * Creates an image with a specified URL. The load event will be fired once
+ * the image at the given URL has been retrieved by the browser.
+ *
+ * @param presenter .
+ * @param param the imageName of the image to be displayed or the URL to be displayed depending on the isURL param
+ * @param myTemplate the template name that owns the image, useful when template it's saved with another name
+ * to eventually copy the images in the new template images folder
+ * @param isURL true if passing a URL, false is passing image name
+ * @param w width
+ * @param h height
+ */
+ public ImageArea(Presenter presenter, String param, String myTemplate, boolean isURL, int w, int h) {
+ myPanel = new VerticalPanel();
+ currentUser = presenter.getCurrentUser();
+ currentScope = presenter.getCurrentScope();
+ //Window.alert("Image Area");
+
+ if (isURL) {
+ //need to get the name from the URL
+ int lastSlash = param.lastIndexOf("/");
+ if (lastSlash > -1) {
+ imageName = param.substring(lastSlash+1, param.length());
+ }
+ else
+ imageName = param;
+ this.templateName = "CURRENT_OPEN";
+ //Window.alert(param);
+ myImage.setUrl(param);
+
+ } else {
+ imageName = param;
+ this.templateName = myTemplate;
+
+ String imgURL = getImageURL(imageName, "CURRENT_OPEN");
+
+
+ myImage.setUrl(imgURL);
+ }
+ myImage.setPixelSize(w, h);
+ myPanel.setStyleName("d4sFrame");
+ myPanel.add(myImage);
+ initWidget(myPanel);
+ }
+
+ /**
+ *
+ * @return .
+ */
+ public String getUrl() {
+ return myImage.getUrl();
+ }
+
+ /**
+ * return a URL which is lookable for on the web
+ * @param imageName .
+ * @param templateName .
+ * @return .
+ */
+ public String getImageURL(String imageName, String templateName) {
+
+
+ /**
+ * Images will be stored under webapps/usersArea...
+ * GWT.getModuleBaseURL() returns * e.g. http://dlib28.isti.cnr.it/templatecreator/html/
+ * need to get just http://dlib28.isti.cnr.it/
+ */
+ //remove "/html/" and get e.g. http://dlib28.isti.cnr.it/templatecreator
+ String host = GWT.getModuleBaseURL().substring(0, GWT.getModuleBaseURL().length()-6);
+
+ //loog for last slash
+ int lastSlash = host.lastIndexOf("/");
+
+ //get what i need : e.g. http://dlib28.isti.cnr.it/ or host = "http://localhost:8080/";
+ host = host.substring(0, lastSlash +1 );
+ //host = "http://localhost:8080/";
+
+ String imgURL = host + "usersArea/" + currentScope + "/templates/"
+ + currentUser + "/" + "CURRENT_OPEN" + "/images/" + imageName;
+ GWT.log(imgURL);
+ return imgURL;
+ }
+ /**
+ *
+ * @return a string containing the owner template name
+ */
+ public String getTemplateName() {
+ return templateName;
+ }
+
+ /**
+ *
+ * @param myTemplate the template owner
+ */
+ public void setTemplateName(String myTemplate) {
+ this.templateName = myTemplate;
+ }
+
+ /**
+ *
+ * @return .
+ */
+ public String getImageName() {
+ return imageName;
+ }
+
+ /**
+ *
+ * @param imageName .
+ */
+ public void setImageName(String imageName) {
+ this.imageName = imageName;
+ }
+ /**
+ *
+ * @return the scope in which the application is running on
+ */
+ public String getCurrentScope() {
+ return currentScope;
+ }
+
+ /**
+ *
+ * @return the user username who is using the application
+ */
+ public String getCurrentUser() {
+ return currentUser;
+ }
+
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/ReportTextArea.java b/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/ReportTextArea.java
new file mode 100644
index 0000000..6683054
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/ReportTextArea.java
@@ -0,0 +1,260 @@
+package org.gcube.portlets.user.reportgenerator.client.targets;
+
+import org.gcube.portlets.d4sreporting.common.client.ComponentType;
+import org.gcube.portlets.d4sreporting.common.client.ImageConstants;
+import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
+import org.gcube.portlets.user.reportgenerator.client.dialog.CommentDialog;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.ui.AbsolutePanel;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HasHorizontalAlignment;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+
+/**
+ * ReportTextArea
class represent the generic Widget that can be placed in the UI Component
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version July 2011 (3.0)
+ */
+public class ReportTextArea extends Composite {
+
+ /**
+ * the allowance when mouse cursor is on borders
+ */
+ public final int DELTA = 7;
+
+
+ /**
+ * variables of the components
+ */
+ protected int left, top, width, height;
+
+ /**
+ * the controller instance of the widget
+ */
+ private Presenter presenter;
+
+ private ComponentType type;
+
+ protected AbsolutePanel mainPanel;
+
+ protected HorizontalPanel topPanel;
+
+ protected VerticalPanel resizablePanel;
+
+ protected Image commentImage;
+ /**
+ *
+ * @return .
+ */
+ public VerticalPanel getResizablePanel() {
+ return resizablePanel;
+ }
+ protected ReportTextArea myInstance;
+
+ /**
+ * default constructor
+ *
+ */
+ public ReportTextArea() {
+ super();
+ }
+
+ /**
+ *
+ * @param presenter .
+ * @param left left
+ * @param top top
+ * @param width .
+ * @param height .
+ * @param type a
+ */
+ public ReportTextArea(ComponentType type, final Presenter presenter, int left, int top, int width, int height, boolean hasComments) {
+ myInstance = this;
+
+
+ this.type = type;
+ this.presenter = presenter;
+ this.left = left;
+ this.top = top;
+ this.width = width;
+ this.height = height;
+
+ mainPanel = new AbsolutePanel();
+
+ topPanel = new HorizontalPanel();
+ resizablePanel = new VerticalPanel();
+
+ mainPanel.setPixelSize(width, height);
+
+ topPanel.setPixelSize(30, 15);
+ resizablePanel.setPixelSize(width, height);
+
+ commentImage = new Image((hasComments) ? ImageConstants.IMAGE_COMMENTS : ImageConstants.IMAGE_COMMENTS_GRAY);
+ commentImage.setTitle("Show user comments");
+ topPanel.add(commentImage);
+
+ commentImage.setStyleName("selectable");
+ commentImage.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ String previousComments = "";
+ int commentHeight = -1;
+ previousComments = presenter.getComponentComments(myInstance).getComment();
+ commentHeight = presenter.getComponentComments(myInstance).getAreaHeight();
+ CommentDialog dlg = new CommentDialog(presenter.getEventBus(), myInstance, presenter.getCurrentUser(), previousComments, commentHeight);
+ dlg.setPopupPosition(commentImage.getAbsoluteLeft()+20, commentImage.getAbsoluteTop());
+ dlg.show();
+ }
+ });
+
+ topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
+
+ mainPanel.add(resizablePanel, 0, 0);
+ mainPanel.add(topPanel, width-18, 0);
+ mainPanel.setStyleName("d4sFrame");
+ initWidget(mainPanel);
+ }
+
+
+ /**
+ *
+ * @return .
+ */
+ public ComponentType getType() {
+ return type;
+ }
+
+ /**
+ *
+ * @param type .
+ */
+ public void setType(ComponentType type) {
+ this.type = type;
+ }
+
+
+ /**
+ * used to resize the panel
+ * @param width w
+ * @param height h
+ */
+ public void resizePanel(int width, int height) {
+ if (height > 15 && width > 15) {
+ mainPanel.setPixelSize(width, height);
+ resizablePanel.setPixelSize(width, height);
+ mainPanel.setWidgetPosition(topPanel, width-15, 0);
+ }
+ }
+
+
+ /***
+ *
+ * @param height g
+ */
+ public void setHeight(int height) {
+
+ if (height > this.height) {
+ mainPanel.setHeight(""+(height+20));
+ resizablePanel.setHeight(""+(height+20));
+ mainPanel.setWidgetPosition(topPanel, width-15, 0);
+ }
+
+ }
+ /**
+ *
+ * @param left .
+ * @param top .
+ */
+ public void repositionMyPanel(int left, int top) {
+ //mainPanel.setWidgetPosition(resizablePanel, left, top);
+ }
+
+
+ /**
+ * @return .
+ */
+ public int getLeft() {
+ return left;
+ }
+
+
+ /**
+ *
+ * @param left .
+ */
+ public void setLeft(int left) {
+ this.left = left;
+ }
+
+ /**
+ *
+ * @return -.
+ */
+ public int getTop() {
+ return top;
+ }
+
+ /**
+ *
+ * @param top .
+ */
+ public void setTop(int top) {
+ this.top = top;
+ }
+
+ /**
+ *
+ * @return the controller instance of the widget
+ */
+ public Presenter getController() {
+ return presenter;
+ }
+
+
+ /**
+ *
+ * @return .
+ */
+ public ReportTextArea getMyInstance() {
+ return myInstance;
+ }
+
+ /**
+ *
+ * @param myInstance .
+ */
+ public void setMyInstance(ReportTextArea myInstance) {
+ this.myInstance = myInstance;
+ }
+
+ public void removeCommentView() {
+ commentImage.setUrl(ImageConstants.IMAGE_COMMENTS_GRAY);
+ }
+ public void addCommentView() {
+ commentImage.setUrl(ImageConstants.IMAGE_COMMENTS);
+ }
+
+ public void showComment(String comment) {
+// final Window window = new Window();
+// window.setTitle("");
+// window.setMaximizable(true);
+// window.setResizable(true);
+// window.setLayout(new FitLayout());
+// window.setWidth(200);
+// window.setHeight(100);
+// window.setModal(false);
+//
+// Panel windowPanel = new Panel();
+// windowPanel.setBaseCls("comment-popup");
+// windowPanel.setHtml(comment);
+// windowPanel.setShadow(true);
+// window.add(windowPanel);
+// window.setPosition(commentImage.getAbsoluteLeft()+25, commentImage.getAbsoluteTop());
+// window.show();
+ }
+}
diff --git a/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/TSArea.java b/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/TSArea.java
new file mode 100644
index 0000000..aad5dc5
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/reportgenerator/client/targets/TSArea.java
@@ -0,0 +1,314 @@
+package org.gcube.portlets.user.reportgenerator.client.targets;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.gcube.portlets.d4sreporting.common.shared.SerializableTSFilter;
+import org.gcube.portlets.d4sreporting.common.shared.SerializableTSinfo;
+import org.gcube.portlets.d4sreporting.common.shared.SerializableTable;
+import org.gcube.portlets.d4sreporting.common.shared.SerializableTimeSeries;
+import org.gcube.portlets.user.reportgenerator.client.ReportGenerator;
+import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
+import org.gcube.portlets.user.reportgenerator.client.dialog.TimeSeriesDialog;
+import org.gcube.portlets.user.reportgenerator.client.dialog.TimeSeriesFilter;
+import org.gcube.portlets.user.reportgenerator.client.dialog.TimeSeriesSampleDialog;
+import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
+import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTTimeSeries;
+
+import com.extjs.gxt.ui.client.widget.Composite;
+import com.extjs.gxt.ui.client.widget.VerticalPanel;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+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.FlexTable;
+import com.google.gwt.user.client.ui.Grid;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Label;
+
+
+
+/**
+ * TSArea
class is a Widget you can drop a Workspace Time Series on
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version July 2011 (3.0)
+ */
+public class TSArea extends Composite {
+
+ private VerticalPanel mainPanel;
+ private SerializableTimeSeries sts = new SerializableTimeSeries();
+ private String idInBasket;
+ private Presenter presenter;
+ private FlexTable flexTable;
+ private TSArea singleton;
+
+ VerticalPanel tableContainer = new VerticalPanel();
+ Grid metadata = new Grid(3, 2);
+
+ Label label;
+ /**
+ * @param presenter .
+ * @param width .
+ * @param height .
+ * @param sts the time series
+ */
+ public TSArea(Presenter presenter, int width, int height, SerializableTimeSeries sts) {
+ singleton = this;
+ this.presenter = presenter;
+ mainPanel = new VerticalPanel();
+ //setElement(mainPanel.getElement());
+
+ mainPanel.setStyleName("timeseriesArea");
+ mainPanel.addStyleName("timeseriesArea_bg");
+ mainPanel.setWidth(width);
+ mainPanel.setHeight(height);
+
+ mainPanel.add(new HTML(" ", true));
+ this.sts = sts;
+ if (sts != null) {
+ if (sts.getTsMetadata() != null) {
+ showTS(sts.getTsMetadata());
+ }
+ }
+ initComponent(mainPanel);
+ mainPanel.layout(true);
+ }
+
+
+ /**
+ * called when dropped a TS on the area
+ * @param toShow the TS to show
+ */
+ public void showTS(SerializableTSinfo toShow) {
+ mainPanel.removeAll();
+ mainPanel.removeStyleName("timeseriesArea_bg");
+ tableContainer.removeAll();
+
+ metadata.setWidget(0, 0, new HTML("TS name:", true));
+ metadata.setWidget(0, 1, new HTML(toShow.getTitle()));
+ metadata.setWidget(1, 0, new HTML("Creation Date: ", true));
+ metadata.setWidget(1, 1, new HTML(toShow.getTimeSeriesCreationDate()));
+ metadata.setWidget(2, 0, new HTML("Total rows:", true));
+ metadata.setWidget(2, 1, new HTML(""+toShow.getDimension()));
+
+
+ List ImagesUploadServlet
class is the server code delgated to receinve the byte stream and store i
+ *
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version October 2008 (0.2)
+ */
+
+public class ImagesUploadServlet extends HttpServlet {
+
+ static GCUBEClientLog _log = new GCUBEClientLog(ImagesUploadServlet.class);
+
+ final String returnOKMessage = "OK";
+
+ private static final long serialVersionUID = 1L;
+
+ private String currentUser;
+
+ private String currentScope;
+
+ /**
+ *
+ * @param message the msg
+ */
+ public static void logger (String message) {
+ System.out.println("***" + message);
+ }
+ /**
+ * return the user template folder
+ * @param templateName
+ * @param currentDL .
+ * @param currentUser .
+ * @return .
+ */
+ private String getTemplateFolder(String currentDL, String currentUser) {
+ _log.debug("getTemplateFolder Method called");
+ // platform indipendent slash
+ String sl = File.separator;
+ //e.g. /home/massi/workspace/templategen/tomcat/webapps/ROOT
+ String path = System.getenv("CATALINA_HOME");
+ path += sl + "webapps" + sl +"usersArea" + sl + currentDL +
+ sl + "templates" + sl + currentUser + sl ;
+ _log.debug("Returning Path= " + path);
+ return path;
+
+ }
+ /**
+ * file upload handler
+ * @param request .
+ * @param response .
+ * @throws ServletException .
+ * @throws IOException .
+ */
+
+ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+// logger("ImagesUploadServlet received:");
+//
+// currentUser = getUsername(request);
+// currentScope = getVreName(request);
+//
+// String currTemplateName = request.getParameter("currTemplateName");
+//
+// logger("currentUser: "+currentUser);
+// logger("currentVRE: "+currentScope);
+// logger("currTemplateName: "+currTemplateName);
+// logger("CALLING :getTemplateFolder ");
+// logger("RETURNED :getTemplateFolder ");
+// //platform indipendent slash
+// String sl = File.separator;
+// String startDirectory = getTemplateFolder(currentScope, currentUser); //e.g. /home/massi/workspace/templategen/tomcat/webapps/ROOT
+// int lastSlash = startDirectory.lastIndexOf(sl);
+// startDirectory = startDirectory.substring(0, lastSlash);
+//
+// startDirectory += sl + "CURRENT_OPEN" + sl + "images";
+//
+// logger("RETURNED : " + startDirectory);
+// logger("WRITING... :");
+//
+// String fileName = "";
+// PrintWriter out = response.getWriter();
+//
+// if (!ServletFileUpload.isMultipartContent(request))
+// return;
+//
+// FileItemFactory factory = new DiskFileItemFactory();
+// ServletFileUpload upload = new ServletFileUpload(factory);
+//
+// List items = null;
+// try {
+// items = upload.parseRequest(request);
+// }
+// catch (FileUploadException e) {
+// e.printStackTrace();
+// return;
+// }
+// File uploadedFile = null;
+// for (Iterator i = items.iterator(); i.hasNext();) {
+// FileItem item = (FileItem) i.next();
+//
+// if (item.isFormField())
+// continue;
+// fileName = item.getName();
+// if (fileName != null && fileName.compareTo("")!=0) {
+// fileName = FilenameUtils.getName(fileName);
+//
+// uploadedFile = new File(startDirectory + File.separator + fileName);
+// try {
+// if(!uploadedFile.exists()){
+// File toCreate = new File(startDirectory);
+// boolean success = toCreate.mkdirs();
+// if (success)
+// Logger.debug("New file \"" + uploadedFile + "\" has been created ");
+// }
+// item.write(uploadedFile);
+// }
+// catch (Exception e) { e.printStackTrace(); }
+//
+// }
+// }
+//
+// out.print(returnOKMessage);
+// out.close();
+
+ } //end service
+
+ /**
+ *
+ * @param httpServletRequest .
+ * @return .
+ */
+ public String getUsername(HttpServletRequest httpServletRequest) {
+
+ HttpSession session = httpServletRequest.getSession();
+ String user = (String) session.getAttribute("username");
+ if(session.getAttribute("username")== null)
+ {
+ user = "massi";
+ logger("D4ScienceSession user NULL set to: " + user);
+ }
+ logger("D4ScienceSession user: " + user);
+
+ ASLSession d4session = SessionManager.getInstance().getASLSession(session.getId(), user);
+ d4session.setAttribute("username", user);
+ return user;
+ }
+
+ /**
+ * @param httpServletRequest .
+ * @return the shared session
+ */
+ public String getVreName(HttpServletRequest httpServletRequest) {
+ HttpSession session = httpServletRequest.getSession();
+
+ ASLSession d4session = SessionManager.getInstance().getASLSession(session.getId(), getUsername(httpServletRequest));
+ String scope = d4session.getScopeName();
+ //need to remove the initial / of the scope
+ if (scope.charAt(0) == '/')
+ scope = scope.substring(1, scope.length());
+ logger("ImagesUploadServlet SCOPE: " + scope);
+ //String scope = "gcube/devsec";
+ return scope;
+ }
+}
diff --git a/src/main/java/org/gcube/portlets/user/reportgenerator/server/servlet/ReportServiceImpl.java b/src/main/java/org/gcube/portlets/user/reportgenerator/server/servlet/ReportServiceImpl.java
new file mode 100644
index 0000000..f39eab1
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/reportgenerator/server/servlet/ReportServiceImpl.java
@@ -0,0 +1,1751 @@
+package org.gcube.portlets.user.reportgenerator.server.servlet;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+import java.util.Vector;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import net.sf.csv4j.CSVFileProcessor;
+import net.sf.csv4j.CSVLineProcessor;
+import net.sf.csv4j.ParseException;
+import net.sf.csv4j.ProcessingException;
+
+import org.apache.commons.io.IOUtils;
+import org.gcube.application.framework.accesslogger.library.impl.AccessLogger;
+import org.gcube.application.framework.core.session.ASLSession;
+import org.gcube.application.framework.core.session.SessionManager;
+import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
+import org.gcube.applicationsupportlayer.social.NotificationsManager;
+import org.gcube.common.core.scope.GCUBEScope.MalformedScopeExpressionException;
+import org.gcube.common.core.utils.logging.GCUBEClientLog;
+import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
+import org.gcube.portlets.admin.wfdocslibrary.client.WfDocsLibrary;
+import org.gcube.portlets.admin.wfdocslibrary.server.db.MyDerbyStore;
+import org.gcube.portlets.admin.wfdocslibrary.server.db.Store;
+import org.gcube.portlets.d4sreporting.common.client.ComponentType;
+import org.gcube.portlets.d4sreporting.common.server.ServiceUtil;
+import org.gcube.portlets.d4sreporting.common.shared.SerializableComponent;
+import org.gcube.portlets.d4sreporting.common.shared.SerializableModel;
+import org.gcube.portlets.d4sreporting.common.shared.SerializableSection;
+import org.gcube.portlets.d4sreporting.common.shared.SerializableTable;
+import org.gcube.portlets.d4sreporting.common.shared.SerializableTimeSeries;
+import org.gcube.portlets.d4sreporting.common.shared.TableCell;
+import org.gcube.portlets.docxgenerator.DocxGenerator;
+import org.gcube.portlets.user.homelibrary.home.HomeLibrary;
+import org.gcube.portlets.user.homelibrary.home.exceptions.HomeNotFoundException;
+import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException;
+import org.gcube.portlets.user.homelibrary.home.workspace.Workspace;
+import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder;
+import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem;
+import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItemType;
+import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
+import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
+import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ItemNotFoundException;
+import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
+import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItem;
+import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItemType;
+import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalImage;
+import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.Report;
+import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ReportTemplate;
+import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.ImageDocument;
+import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ts.TimeSeries;
+import org.gcube.portlets.user.reportgenerator.client.ReportConstants;
+import org.gcube.portlets.user.reportgenerator.client.ReportService;
+import org.gcube.portlets.user.reportgenerator.client.model.ExportManifestationType;
+import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.CreateReportLogEntry;
+import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.GenerateReportLogEntry;
+import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.OpenReportLogEntry;
+import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.OpenWorkflowLogEntry;
+import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.SaveWorkflowLogEntry;
+import org.gcube.portlets.user.reportgenerator.shared.SessionInfo;
+
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+import com.liferay.portal.service.LockLocalServiceUtil;
+import com.liferay.portlet.documentlibrary.model.DLFileEntry;
+
+
+
+/**
+ *
+ * class implementing services
+ * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
+ * @version Feb 2012 (3.3)
+ */
+@SuppressWarnings("serial")
+public class ReportServiceImpl extends RemoteServiceServlet implements ReportService {
+
+ public static GCUBEClientLog logger = new GCUBEClientLog(ReportServiceImpl.class);
+ /**
+ * EXPORT DIR
+ */
+ private static final String EXPORTS_DIR = "EXPORTS";
+
+ /**
+ *
+ */
+ public static final String USERNAME_ATTRIBUTE = "user";
+ /**
+ *
+ */
+ public static final String GIF = "image/gif";
+ /**
+ *
+ */
+ public static final String PNG = "image/png";
+ /**
+ *
+ */
+ public static final String JPEG = "image/jpeg";
+ /**
+ *
+ */
+ public static final String JPG = "image/jpg";
+ /**
+ *
+ */
+ public static final String TIFF = "image/tiff";
+ /**
+ *
+ */
+ public static final String BMP = "image/bmp";
+
+ /**
+ *
+ */
+ public static final String CURRENT_REPORT_ID_ATTRIBUTE = "CURRENT_REPORT_ID_ATTRIBUTE";
+ /**
+ *
+ */
+ public static final String CURRENT_REPORT_INSTANCE = "myReport";
+ /**
+ *
+ */
+ public static final String PREVIOUS_REPORT_INSTANCE = "myPreviousReport";
+
+
+ private String currentHost = "";
+
+ /**
+ * the WF DB Store
+ */
+ private Store store;
+
+
+ //set to true if wanna test workflow menu mode
+ boolean testWorkflow = false;
+
+ /**
+ * Called then servlet is intialized
+ */
+ public void init() {
+ logger.info("Initializing Servlet ReportServiceImpl...");
+ store = new MyDerbyStore();
+ }
+
+ /**
+ * the current ASLSession
+ * @return .
+ */
+ private ASLSession getASLSession() {
+ String sessionID = this.getThreadLocalRequest().getSession().getId();
+ String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
+
+
+ logger.error("Report PORTLET SessionID= " + sessionID);
+
+ if (user == null) {
+ user = "massimiliano.assante";
+ this.getThreadLocalRequest().getSession().setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, user);
+ SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec");
+ }
+ return SessionManager.getInstance().getASLSession(sessionID, user);
+ }
+ /**
+ * Retrieve the user saved template names
+ *
+ * @return a String[] containing the template names
+ */
+ public String[] getUserTemplateNames() {
+ ServiceUtil myUtil = new ServiceUtil(getASLSession());
+ Vector