This is code for Making tree in GWT and by this we are also calling "write.java" in which "RICHTEXTEDITOR's" coding exists...
package com.client;
import com.google.gwt.user.client.ui.Button;
public class EnggHeads {
RootPanel rt;
AbsolutePanel absolutePanel_left;
AbsolutePanel absolutePanel_right;
public EnggHeads() {
rt=RootPanel.get();
HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel();
rt.add(horizontalSplitPanel, 0, 0);
horizontalSplitPanel.setSize("1000px", "1000px");
horizontalSplitPanel.setSplitPosition("150");
absolutePanel_right = new AbsolutePanel();
horizontalSplitPanel.setRightWidget(absolutePanel_right);
absolutePanel_right.setSize("100%", "590px");
AbsolutePanel absolutePanel_left = new AbsolutePanel();
horizontalSplitPanel.setLeftWidget(absolutePanel_left);
absolutePanel_left.setSize("100%", "100%");
TreeItem root = new TreeItem("Research Paper");
root.setHeight("124px");
Hyperlink hyper_upload=new Hyperlink("Upload", false, "newHistoryToken");
hyper_upload.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
absolutePanel_right.clear();
FileUploader1 f= new FileUploader1();
f.setVisible(true);
}
});
root.addItem(hyper_upload);
Hyperlink hh= new Hyperlink("Write", false, "newHistoryToken");
hh.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
absolutePanel_right.clear();
Write ff=new Write(); //This is calling of the class write in which richtexteditor code exists
ff.setVisible(true);
}
});
root.addItem(hh);
Tree t = new Tree();
t.addItem(root);
root.setState(true);
absolutePanel_left.add(t);
}
}
Step2:-
Make a folder images in war folder of your project and inser these below listed icons in that--
http://scripts.ringsworld.com/news-publishing/easynews17/icons/bold.gif.html
http://scripts.ringsworld.com/news-publishing/easynews17/icons/italic.gif.html
http://scripts.ringsworld.com/news-publishing/easynews17/icons/underline.gif.html
http://s613.photobucket.com/albums/tt219/brakesk8/?action=view¤t=justifycenter.gif&newest=1
http://s610.photobucket.com/albums/tt189/tonybee9119/icon/?action=view¤t=justifyright.gif¤ttag=icon
Step3:- Now after saving these images make another file "write.java"
package com.client;
import java.io.File;
import java.io.IOException;
import org.eclipse.swt.internal.win32.CREATESTRUCT;
import com.gargoylesoftware.htmlunit.javascript.host.Window;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RichTextArea;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.RichTextArea.ExtendedFormatter;
import com.gwtext.client.widgets.Toolbar;
import com.gwtext.client.widgets.ToolbarButton;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.gwtext.client.core.EventObject;
import com.google.gwt.user.datepicker.client.DateBox;
import com.gwtext.client.widgets.form.TimeField;
import com.google.gwt.user.datepicker.client.DateBox.DefaultFormat;
import com.google.gwt.i18n.client.DateTimeFormat;
@SuppressWarnings("deprecation")
public class Write extends Composite {
RootPanel rootpanel;
AbsolutePanel absolutePanel;
Label stream;
ListBox streamvalue ;
Label subject;
ListBox subjectvalue;
Label lblTypeAProblem;
RichTextArea richTextArea;
ExtendedFormatter formatter;
Toolbar tt;
ToolbarButton bold;
ToolbarButton italic;
ToolbarButton underline;
ToolbarButton leftjustification;
ToolbarButton rightjustification;
ToolbarButton centerjustification;
ListBox fontsize;
public Write() {
rootpanel=RootPanel.get();
absolutePanel = new AbsolutePanel();
rootpanel.add(absolutePanel, 191, -4);
absolutePanel.setSize("450px", "382px");
stream = new Label("Stream");
absolutePanel.add(stream, 201, 22);
richTextArea = new RichTextArea();
absolutePanel.add(richTextArea, 86, 170);
richTextArea.setSize("354px", "98px");
formatter=richTextArea.getExtendedFormatter();
tt=new Toolbar();
absolutePanel.add(tt, 88, 130);
tt.setSize("351px", "31px");
fontsize = new ListBox();
absolutePanel.add(fontsize, 244, 134);
fontsize.setSize("35px", "27px");
fontsize.addItem("1");
fontsize.addItem("2");
fontsize.addItem("3");
fontsize.addItem("4");
fontsize.addItem("5");
fontsize.addItem("6");
fontsize.addItem("7");
// tglbtnB = new ToggleButton("B");
bold=new ToolbarButton();
//bold.setToggleGroup("");
bold.setText("");
bold.setTooltip("Bold");
bold.setCls("button");
bold.setToggleGroup("format");
bold.setIconCls("G:/gwt-2.0.4/gwt-2.0.4/logcom/war/images/bold.gif");
tt.addButton(bold);
bold.setSize("34px", "30px");
italic=new ToolbarButton();
italic.setText("");
italic.setTooltip("Italic");
italic.setToggleGroup("format");
italic.setIcon("G:/gwt-2.0.4/gwt-2.0.4/logcom/war/images/italic.gif");
tt.addButton(italic);
underline=new ToolbarButton();
underline.setText("");
underline.setToggleGroup("format");
underline.setIcon("G:/gwt-2.0.4/gwt-2.0.4/logcom/war/images/underline.gif");
tt.addButton(underline);
leftjustification=new ToolbarButton();
leftjustification.setToggleGroup("justification");
leftjustification.setTooltip("left");
leftjustification.setText("");
leftjustification.setIcon("G:/gwt-2.0.4/gwt-2.0.4/logcom/war/images/justifyleft.gif");
tt.addButton(leftjustification);
centerjustification=new ToolbarButton();
centerjustification.setToggleGroup("justification");
centerjustification.setText("");
centerjustification.setIcon("G:/gwt-2.0.4/gwt-2.0.4/logcom/war/images/justifyCenter.gif");
centerjustification.setTooltip("Center");
tt.addButton(centerjustification);
rightjustification=new ToolbarButton();
rightjustification.setToggleGroup("justification");
rightjustification.setText("");
rightjustification.setIcon("G:/gwt-2.0.4/gwt-2.0.4/logcom/war/images/justifyRight.gif");
rightjustification.setTooltip("Right");
tt.addButton(rightjustification);
DateBox dateBox = new DateBox();
dateBox.setFormat(new DefaultFormat(DateTimeFormat.getFullDateFormat()));
absolutePanel.add(dateBox, 177, 549);
dateBox.setSize("98px", "23px");
Label lblEnterDatetime = new Label("Enter Date/Time");
absolutePanel.add(lblEnterDatetime, 56, 549);
TimeField timeField = new TimeField("New time field", "time_field", 100);
absolutePanel.add(timeField, 298, 548);
Label lblTitle = new Label("Title");
absolutePanel.add(lblTitle, 119, 52);
lblTitle.setSize("254px", "18px");
final TextBox txtbxTitle = new TextBox();
txtbxTitle.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
txtbxTitle.setText("");
}
});
txtbxTitle.setText("Title");
absolutePanel.add(txtbxTitle, 257, 46);
txtbxTitle.setSize("166px", "16px");
Label lblAuthor = new Label("Author");
absolutePanel.add(lblAuthor, 124, 82);
lblAuthor.setSize("257px", "18px");
final TextBox txtbxAuthorName = new TextBox();
txtbxAuthorName.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
txtbxAuthorName.setText("");
}
});
txtbxAuthorName.setText("Author name");
absolutePanel.add(txtbxAuthorName, 260, 80);
txtbxAuthorName.setSize("163px", "16px");
Button button_1 = new Button("New button");
button_1.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String ss=richTextArea.getText();
String st=txtbxTitle.getText();
String sa=txtbxAuthorName.getText();
com.google.gwt.user.client.Window.alert(ss);
}
});
button_1.setText("Submit");
absolutePanel.add(button_1, 213, 274);
button_1.setSize("100px", "28px");
bold.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
//richTextArea.setHTML("<b></b>");
formatter.toggleBold();
}
});
italic.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.toggleItalic();
}
});
underline.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.toggleUnderline();
}
});
leftjustification.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.setJustification(RichTextArea.Justification.LEFT);
}
});
centerjustification.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.setJustification(RichTextArea.Justification.CENTER);
}
});
rightjustification.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.setJustification(RichTextArea.Justification.RIGHT);
}
});
fontsize.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
if(fontsize.isItemSelected(0))
formatter.setFontSize(RichTextArea.FontSize.XX_SMALL);
if(fontsize.isItemSelected(1))
formatter.setFontSize(RichTextArea.FontSize.X_SMALL);
if(fontsize.isItemSelected(2))
formatter.setFontSize(RichTextArea.FontSize.SMALL);
if(fontsize.isItemSelected(3))
formatter.setFontSize(RichTextArea.FontSize.MEDIUM);
if(fontsize.isItemSelected(4))
formatter.setFontSize(RichTextArea.FontSize.LARGE);
if(fontsize.isItemSelected(5))
formatter.setFontSize(RichTextArea.FontSize.X_LARGE);
if(fontsize.isItemSelected(6))
formatter.setFontSize(RichTextArea.FontSize.XX_LARGE);
}
});
}
}
This is all about richtexteditor in gwt.You can also add additional functions in it as per your requirement..
Thanks for your attentions...
Vishal Dixit,Sonal Garg
Step1:- EnggHeads.java
package com.client;
import com.google.gwt.user.client.ui.Button;
public class EnggHeads {
RootPanel rt;
AbsolutePanel absolutePanel_left;
AbsolutePanel absolutePanel_right;
public EnggHeads() {
rt=RootPanel.get();
HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel();
rt.add(horizontalSplitPanel, 0, 0);
horizontalSplitPanel.setSize("1000px", "1000px");
horizontalSplitPanel.setSplitPosition("150");
absolutePanel_right = new AbsolutePanel();
horizontalSplitPanel.setRightWidget(absolutePanel_right);
absolutePanel_right.setSize("100%", "590px");
AbsolutePanel absolutePanel_left = new AbsolutePanel();
horizontalSplitPanel.setLeftWidget(absolutePanel_left);
absolutePanel_left.setSize("100%", "100%");
TreeItem root = new TreeItem("Research Paper");
root.setHeight("124px");
Hyperlink hyper_upload=new Hyperlink("Upload", false, "newHistoryToken");
hyper_upload.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
absolutePanel_right.clear();
FileUploader1 f= new FileUploader1();
f.setVisible(true);
}
});
root.addItem(hyper_upload);
Hyperlink hh= new Hyperlink("Write", false, "newHistoryToken");
hh.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
absolutePanel_right.clear();
Write ff=new Write(); //This is calling of the class write in which richtexteditor code exists
ff.setVisible(true);
}
});
root.addItem(hh);
Tree t = new Tree();
t.addItem(root);
root.setState(true);
absolutePanel_left.add(t);
}
}
Step2:-
Make a folder images in war folder of your project and inser these below listed icons in that--
http://scripts.ringsworld.com/news-publishing/easynews17/icons/bold.gif.html
http://scripts.ringsworld.com/news-publishing/easynews17/icons/italic.gif.html
http://scripts.ringsworld.com/news-publishing/easynews17/icons/underline.gif.html
http://s613.photobucket.com/albums/tt219/brakesk8/?action=view¤t=justifycenter.gif&newest=1
http://s610.photobucket.com/albums/tt189/tonybee9119/icon/?action=view¤t=justifyright.gif¤ttag=icon
Step3:- Now after saving these images make another file "write.java"
package com.client;
import java.io.File;
import java.io.IOException;
import org.eclipse.swt.internal.win32.CREATESTRUCT;
import com.gargoylesoftware.htmlunit.javascript.host.Window;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RichTextArea;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.RichTextArea.ExtendedFormatter;
import com.gwtext.client.widgets.Toolbar;
import com.gwtext.client.widgets.ToolbarButton;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.gwtext.client.core.EventObject;
import com.google.gwt.user.datepicker.client.DateBox;
import com.gwtext.client.widgets.form.TimeField;
import com.google.gwt.user.datepicker.client.DateBox.DefaultFormat;
import com.google.gwt.i18n.client.DateTimeFormat;
@SuppressWarnings("deprecation")
public class Write extends Composite {
RootPanel rootpanel;
AbsolutePanel absolutePanel;
Label stream;
ListBox streamvalue ;
Label subject;
ListBox subjectvalue;
Label lblTypeAProblem;
RichTextArea richTextArea;
ExtendedFormatter formatter;
Toolbar tt;
ToolbarButton bold;
ToolbarButton italic;
ToolbarButton underline;
ToolbarButton leftjustification;
ToolbarButton rightjustification;
ToolbarButton centerjustification;
ListBox fontsize;
public Write() {
rootpanel=RootPanel.get();
absolutePanel = new AbsolutePanel();
rootpanel.add(absolutePanel, 191, -4);
absolutePanel.setSize("450px", "382px");
stream = new Label("Stream");
absolutePanel.add(stream, 201, 22);
richTextArea = new RichTextArea();
absolutePanel.add(richTextArea, 86, 170);
richTextArea.setSize("354px", "98px");
formatter=richTextArea.getExtendedFormatter();
tt=new Toolbar();
absolutePanel.add(tt, 88, 130);
tt.setSize("351px", "31px");
fontsize = new ListBox();
absolutePanel.add(fontsize, 244, 134);
fontsize.setSize("35px", "27px");
fontsize.addItem("1");
fontsize.addItem("2");
fontsize.addItem("3");
fontsize.addItem("4");
fontsize.addItem("5");
fontsize.addItem("6");
fontsize.addItem("7");
// tglbtnB = new ToggleButton("B");
bold=new ToolbarButton();
//bold.setToggleGroup("");
bold.setText("");
bold.setTooltip("Bold");
bold.setCls("button");
bold.setToggleGroup("format");
bold.setIconCls("G:/gwt-2.0.4/gwt-2.0.4/logcom/war/images/bold.gif");
tt.addButton(bold);
bold.setSize("34px", "30px");
italic=new ToolbarButton();
italic.setText("");
italic.setTooltip("Italic");
italic.setToggleGroup("format");
italic.setIcon("G:/gwt-2.0.4/gwt-2.0.4/logcom/war/images/italic.gif");
tt.addButton(italic);
underline=new ToolbarButton();
underline.setText("");
underline.setToggleGroup("format");
underline.setIcon("G:/gwt-2.0.4/gwt-2.0.4/logcom/war/images/underline.gif");
tt.addButton(underline);
leftjustification=new ToolbarButton();
leftjustification.setToggleGroup("justification");
leftjustification.setTooltip("left");
leftjustification.setText("");
leftjustification.setIcon("G:/gwt-2.0.4/gwt-2.0.4/logcom/war/images/justifyleft.gif");
tt.addButton(leftjustification);
centerjustification=new ToolbarButton();
centerjustification.setToggleGroup("justification");
centerjustification.setText("");
centerjustification.setIcon("G:/gwt-2.0.4/gwt-2.0.4/logcom/war/images/justifyCenter.gif");
centerjustification.setTooltip("Center");
tt.addButton(centerjustification);
rightjustification=new ToolbarButton();
rightjustification.setToggleGroup("justification");
rightjustification.setText("");
rightjustification.setIcon("G:/gwt-2.0.4/gwt-2.0.4/logcom/war/images/justifyRight.gif");
rightjustification.setTooltip("Right");
tt.addButton(rightjustification);
DateBox dateBox = new DateBox();
dateBox.setFormat(new DefaultFormat(DateTimeFormat.getFullDateFormat()));
absolutePanel.add(dateBox, 177, 549);
dateBox.setSize("98px", "23px");
Label lblEnterDatetime = new Label("Enter Date/Time");
absolutePanel.add(lblEnterDatetime, 56, 549);
TimeField timeField = new TimeField("New time field", "time_field", 100);
absolutePanel.add(timeField, 298, 548);
Label lblTitle = new Label("Title");
absolutePanel.add(lblTitle, 119, 52);
lblTitle.setSize("254px", "18px");
final TextBox txtbxTitle = new TextBox();
txtbxTitle.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
txtbxTitle.setText("");
}
});
txtbxTitle.setText("Title");
absolutePanel.add(txtbxTitle, 257, 46);
txtbxTitle.setSize("166px", "16px");
Label lblAuthor = new Label("Author");
absolutePanel.add(lblAuthor, 124, 82);
lblAuthor.setSize("257px", "18px");
final TextBox txtbxAuthorName = new TextBox();
txtbxAuthorName.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
txtbxAuthorName.setText("");
}
});
txtbxAuthorName.setText("Author name");
absolutePanel.add(txtbxAuthorName, 260, 80);
txtbxAuthorName.setSize("163px", "16px");
Button button_1 = new Button("New button");
button_1.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String ss=richTextArea.getText();
String st=txtbxTitle.getText();
String sa=txtbxAuthorName.getText();
com.google.gwt.user.client.Window.alert(ss);
}
});
button_1.setText("Submit");
absolutePanel.add(button_1, 213, 274);
button_1.setSize("100px", "28px");
bold.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
//richTextArea.setHTML("<b></b>");
formatter.toggleBold();
}
});
italic.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.toggleItalic();
}
});
underline.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.toggleUnderline();
}
});
leftjustification.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.setJustification(RichTextArea.Justification.LEFT);
}
});
centerjustification.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.setJustification(RichTextArea.Justification.CENTER);
}
});
rightjustification.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.setJustification(RichTextArea.Justification.RIGHT);
}
});
fontsize.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
if(fontsize.isItemSelected(0))
formatter.setFontSize(RichTextArea.FontSize.XX_SMALL);
if(fontsize.isItemSelected(1))
formatter.setFontSize(RichTextArea.FontSize.X_SMALL);
if(fontsize.isItemSelected(2))
formatter.setFontSize(RichTextArea.FontSize.SMALL);
if(fontsize.isItemSelected(3))
formatter.setFontSize(RichTextArea.FontSize.MEDIUM);
if(fontsize.isItemSelected(4))
formatter.setFontSize(RichTextArea.FontSize.LARGE);
if(fontsize.isItemSelected(5))
formatter.setFontSize(RichTextArea.FontSize.X_LARGE);
if(fontsize.isItemSelected(6))
formatter.setFontSize(RichTextArea.FontSize.XX_LARGE);
}
});
}
}
This is all about richtexteditor in gwt.You can also add additional functions in it as per your requirement..
Thanks for your attentions...
Vishal Dixit,Sonal Garg
0 Response to "RichTextEditor in GWT,Tree in GWT"
Post a Comment