|
|
|
@ -4,10 +4,15 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
import org.gcube.portlets.d4sreporting.common.shared.ComponentType;
|
|
|
|
|
import org.gcube.portlets.d4sreporting.common.shared.Metadata;
|
|
|
|
|
import org.gcube.portlets.user.gcubewidgets.client.popup.GCubeDialog;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.ReportGenerator;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
|
|
|
|
|
|
|
|
|
|
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
|
|
|
|
|
import com.extjs.gxt.ui.client.widget.MessageBox;
|
|
|
|
|
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.event.dom.client.KeyDownEvent;
|
|
|
|
|
import com.google.gwt.event.dom.client.KeyDownHandler;
|
|
|
|
|
import com.google.gwt.event.dom.client.KeyUpEvent;
|
|
|
|
@ -17,20 +22,19 @@ 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.Composite;
|
|
|
|
|
import com.google.gwt.user.client.Timer;
|
|
|
|
|
import com.google.gwt.user.client.ui.Button;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <code> D4sRichTextArea </code> 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 properties associated
|
|
|
|
@ -122,18 +126,75 @@ public class D4sRichTextarea extends ReportTextArea {
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
resizePanel(myPanel.getOffsetWidth(), div.getOffsetHeight());
|
|
|
|
|
//Window.alert("myInstance.top: " + myInstance.top);
|
|
|
|
|
presenter.resizeTemplateComponentInModel(myInstance, myPanel.getOffsetWidth()+5, newHeight);
|
|
|
|
|
}
|
|
|
|
|
if (! (event.isAnyModifierKeyDown() && event.getNativeKeyCode() == 86)) { //event.getNativeKeyCode() == 86 is the V (to avoid ctrl V or cmd V)
|
|
|
|
|
HTML div = ReportGenerator.get().getDivHidden();
|
|
|
|
|
div.setHTML(area.getHTML());
|
|
|
|
|
int newHeight = div.getOffsetHeight()+20 ;
|
|
|
|
|
if (newHeight > height-10 && newHeight != currHeight) {
|
|
|
|
|
resizePanel(myPanel.getOffsetWidth(), div.getOffsetHeight());
|
|
|
|
|
//Window.alert("myInstance.top: " + myInstance.top);
|
|
|
|
|
presenter.resizeTemplateComponentInModel(myInstance, myPanel.getOffsetWidth()+5, newHeight);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
area.addKeyDownHandler(new KeyDownHandler() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onKeyDown(KeyDownEvent event) {
|
|
|
|
|
if (event.isAnyModifierKeyDown() && event.getNativeKeyCode() == 86) { //event.getNativeKeyCode() == 86 is the V (to avoid ctrl V or cmd V)
|
|
|
|
|
final GCubeDialog dlg = new GCubeDialog(true);
|
|
|
|
|
int width = 500;
|
|
|
|
|
dlg.setWidth(width+"px");
|
|
|
|
|
dlg.setText("Paste operation");
|
|
|
|
|
HTML tip = new HTML("Please enter your text here:");
|
|
|
|
|
final TextArea ta = new TextArea();
|
|
|
|
|
Button cancel = new Button("Cancel");
|
|
|
|
|
Button paste = new Button("Paste it");
|
|
|
|
|
HorizontalPanel hp = new HorizontalPanel();
|
|
|
|
|
hp.add(cancel);
|
|
|
|
|
hp.add(paste);
|
|
|
|
|
|
|
|
|
|
ta.setWidth(width-20+"px");
|
|
|
|
|
ta.setHeight("120px");
|
|
|
|
|
|
|
|
|
|
VerticalPanel mainPanel = new VerticalPanel();
|
|
|
|
|
mainPanel.add(tip);
|
|
|
|
|
mainPanel.add(ta);
|
|
|
|
|
mainPanel.add(hp);
|
|
|
|
|
dlg.add(mainPanel);
|
|
|
|
|
|
|
|
|
|
cancel.addClickHandler(new ClickHandler() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
dlg.hide();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
paste.addClickHandler(new ClickHandler() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
area.setHTML(area.getHTML()+ta.getText());
|
|
|
|
|
dlg.hide();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
dlg.center();
|
|
|
|
|
|
|
|
|
|
Timer t = new Timer() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
ta.setFocus(true);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
t.schedule(100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* used to resize the panel
|
|
|
|
|
* @param width w
|
|
|
|
|