You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ma...@apache.org on 2010/02/17 17:15:29 UTC
svn commit: r911049 - in
/james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor:
Toolbar.java ToolbarConstants.java bundles/ToolbarImages.java
Author: manolo
Date: Wed Feb 17 16:15:29 2010
New Revision: 911049
URL: http://svn.apache.org/viewvc?rev=911049&view=rev
Log:
:
Modified:
james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/Toolbar.java
james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/ToolbarConstants.java
james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/bundles/ToolbarImages.java
Modified: james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/Toolbar.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/Toolbar.java?rev=911049&r1=911048&r2=911049&view=diff
==============================================================================
--- james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/Toolbar.java (original)
+++ james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/Toolbar.java Wed Feb 17 16:15:29 2010
@@ -1,33 +1,23 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one *
- * or more contributor license agreements. See the NOTICE file *
- * distributed with this work for additional information *
- * regarding copyright ownership. The ASF licenses this file *
- * to you under the Apache License, Version 2.0 (the *
- * "License"); you may not use this file except in compliance *
- * with the License. You may obtain a copy of the License at *
- * *
- * http://www.apache.org/licenses/LICENSE-2.0 *
- * *
- * Unless required by applicable law or agreed to in writing, *
- * software distributed under the License is distributed on an *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
- * KIND, either express or implied. See the License for the *
- * specific language governing permissions and limitations *
- * under the License. *
- ****************************************************************/
-/**
- * Much of this code has been taken from the GWT Showcase example
- * which is licensed under Apache License v2.0
+/*
+ * Copyright 2010 Manuel Carrasco Moñino. (manuel_carrasco at users.sourceforge.net)
+ * http://code.google.com/p/gwtchismes
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
*
- * This class is necessary while GWT library doesn't provide any
- * toolbar to be used with its RichTextArea widget.
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
*/
-package org.apache.hupa.widgets.editor;
-
-import org.apache.hupa.widgets.editor.FontPicker.FontPickerType;
-import org.apache.hupa.widgets.editor.bundles.ToolbarImages;
+package com.google.code.p.gwtchismes.client.editor;
+import com.google.code.p.gwtchismes.client.editor.GWTCFontPicker.FontPickerType;
+import com.google.code.p.gwtchismes.client.editor.bundles.ToolbarImages;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
@@ -37,20 +27,19 @@
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
+import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.RichTextArea;
import com.google.gwt.user.client.ui.ToggleButton;
import com.google.gwt.user.client.ui.Widget;
/**
- * Toolbar for use with {@link RichTextArea}. It provides a simple UI for all
- * rich text formatting, dynamically displayed only for the available
- * functionality.
+ * Toolbar for use with {@link RichTextArea}.
*/
@SuppressWarnings("deprecation")
public class Toolbar extends Composite {
@@ -131,9 +120,9 @@
}
- private ValueChangeHandler<ColorPicker> colorHandler = new ValueChangeHandler<ColorPicker>() {
- public void onValueChange(ValueChangeEvent<ColorPicker> event) {
- ColorPicker sender = event.getValue();
+ private ValueChangeHandler<GWTCColorPicker> colorHandler = new ValueChangeHandler<GWTCColorPicker>() {
+ public void onValueChange(ValueChangeEvent<GWTCColorPicker> event) {
+ GWTCColorPicker sender = event.getValue();
if (sender == backColorsPicker) {
basic.setBackColor(sender.getColor());
} else if (sender == foreColorsPicker) {
@@ -142,9 +131,9 @@
sender.hide();
}
};
- private ValueChangeHandler<FontPicker> fontHandler = new ValueChangeHandler<FontPicker>() {
- public void onValueChange(ValueChangeEvent<FontPicker> event) {
- FontPicker sender = event.getValue();
+ private ValueChangeHandler<GWTCFontPicker> fontHandler = new ValueChangeHandler<GWTCFontPicker>() {
+ public void onValueChange(ValueChangeEvent<GWTCFontPicker> event) {
+ GWTCFontPicker sender = event.getValue();
if (sender == fontFamilyPicker) {
basic.setFontName(sender.getFontName());
} else if (sender == fontSizePicker) {
@@ -154,7 +143,6 @@
}
};
- private static final ToolbarImages images = (ToolbarImages) GWT.create(ToolbarImages.class);
private EventHandler handler = new EventHandler();
@@ -183,22 +171,20 @@
private PushButton removeFormat;
private PushButton fontFamily;
- private FontPicker fontFamilyPicker = new FontPicker(FontPickerType.FONT_FAMILY);
+ private GWTCFontPicker fontFamilyPicker = new GWTCFontPicker(FontPickerType.FONT_FAMILY);
private PushButton fontSize;
- private FontPicker fontSizePicker = new FontPicker(FontPickerType.FONT_SIZE);
+ private GWTCFontPicker fontSizePicker = new GWTCFontPicker(FontPickerType.FONT_SIZE);
private PushButton backColors;
private PushButton foreColors;
- private ColorPicker backColorsPicker = new ColorPicker();
- private ColorPicker foreColorsPicker = new ColorPicker();
+ private GWTCColorPicker backColorsPicker = new GWTCColorPicker();
+ private GWTCColorPicker foreColorsPicker = new GWTCColorPicker();
- /**
- * Creates a new toolbar that drives the given rich text area.
- *
- * @param richText
- * the rich text area to be controlled
- */
public Toolbar(RichTextArea richText, ToolbarConstants strings) {
+ this(richText, strings, (ToolbarImages)GWT.create(ToolbarImages.class));
+ }
+
+ public Toolbar(RichTextArea richText, ToolbarConstants strings, ToolbarImages images) {
this.richText = richText;
this.basic = richText.getBasicFormatter();
this.extended = richText.getExtendedFormatter();
@@ -251,15 +237,15 @@
fontSizePicker.addValueChangeHandler(fontHandler);
}
- private PushButton createPushButton(AbstractImagePrototype img, String tip) {
- PushButton pb = new PushButton(img.createImage());
+ private PushButton createPushButton(ImageResource img, String tip) {
+ PushButton pb = new PushButton(new Image(img));
pb.addClickHandler(handler);
pb.setTitle(tip);
return pb;
}
- private ToggleButton createToggleButton(AbstractImagePrototype img, String tip) {
- ToggleButton tb = new ToggleButton(img.createImage());
+ private ToggleButton createToggleButton(ImageResource img, String tip) {
+ ToggleButton tb = new ToggleButton(new Image(img));
tb.addClickHandler(handler);
tb.setTitle(tip);
return tb;
Modified: james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/ToolbarConstants.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/ToolbarConstants.java?rev=911049&r1=911048&r2=911049&view=diff
==============================================================================
--- james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/ToolbarConstants.java (original)
+++ james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/ToolbarConstants.java Wed Feb 17 16:15:29 2010
@@ -1,4 +1,20 @@
-package org.apache.hupa.widgets.editor;
+/*
+ * Copyright 2010 Manuel Carrasco Moñino. (manuel_carrasco at users.sourceforge.net)
+ * http://code.google.com/p/gwtchismes
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.code.p.gwtchismes.client.editor;
import com.google.gwt.i18n.client.Constants;
Modified: james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/bundles/ToolbarImages.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/bundles/ToolbarImages.java?rev=911049&r1=911048&r2=911049&view=diff
==============================================================================
--- james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/bundles/ToolbarImages.java (original)
+++ james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/bundles/ToolbarImages.java Wed Feb 17 16:15:29 2010
@@ -1,59 +1,69 @@
-package org.apache.hupa.widgets.editor.bundles;
+/*
+ * Copyright 2010 Manuel Carrasco Moñino. (manuel_carrasco at users.sourceforge.net)
+ * http://code.google.com/p/gwtchismes
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.ImageBundle;
+package com.google.code.p.gwtchismes.client.editor.bundles;
+import com.google.gwt.resources.client.ClientBundle;
+import com.google.gwt.resources.client.ImageResource;
+ public interface ToolbarImages extends ClientBundle {
- /**
- * This {@link ImageBundle} is used for all the button icons. Using an image
- * bundle allows all of these images to be packed into a single image, which
- * saves a lot of HTTP requests, drastically improving startup time.
- */
- public interface ToolbarImages extends ImageBundle {
+ ImageResource bold();
- AbstractImagePrototype bold();
+ ImageResource createLink();
- AbstractImagePrototype createLink();
+ ImageResource hr();
- AbstractImagePrototype hr();
+ ImageResource indent();
- AbstractImagePrototype indent();
+ ImageResource insertImage();
- AbstractImagePrototype insertImage();
+ ImageResource italic();
- AbstractImagePrototype italic();
+ ImageResource justifyCenter();
- AbstractImagePrototype justifyCenter();
+ ImageResource justifyLeft();
- AbstractImagePrototype justifyLeft();
+ ImageResource justifyRight();
- AbstractImagePrototype justifyRight();
+ ImageResource ol();
- AbstractImagePrototype ol();
+ ImageResource outdent();
- AbstractImagePrototype outdent();
+ ImageResource removeFormat();
- AbstractImagePrototype removeFormat();
+ ImageResource removeLink();
- AbstractImagePrototype removeLink();
+ ImageResource strikeThrough();
- AbstractImagePrototype strikeThrough();
+ ImageResource subscript();
- AbstractImagePrototype subscript();
+ ImageResource superscript();
- AbstractImagePrototype superscript();
+ ImageResource ul();
- AbstractImagePrototype ul();
-
- AbstractImagePrototype underline();
+ ImageResource underline();
- AbstractImagePrototype backColors();
+ ImageResource backColors();
- AbstractImagePrototype foreColors();
+ ImageResource foreColors();
- AbstractImagePrototype fonts();
+ ImageResource fonts();
- AbstractImagePrototype fontSizes();
+ ImageResource fontSizes();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org