[kune-commits] r900 - in trunk: .
src/main/java/org/ourproject/kune/app/client
src/main/java/org/ourproject/kune/platf/client/services
src/main/java/org/ourproject/kune/platf/client/ui/palette
src/main/java/org/ourproject/kune/workspace/client/editor
vjrj
vjrj at ourproject.org
Thu Oct 2 21:57:56 CEST 2008
Author: vjrj
Date: 2008-10-02 21:57:49 +0200 (Thu, 02 Oct 2008)
New Revision: 900
Added:
trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/WebSafePalette.java
Removed:
trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorSelectListener.java
Modified:
trunk/TODO
trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/WebSafePalettePanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/WebSafePalettePresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/WebSafePaletteView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorToolbar.java
Log:
Incomplete - task 80: Text editor refactorization
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2008-10-01 21:12:10 UTC (rev 899)
+++ trunk/TODO 2008-10-02 19:57:49 UTC (rev 900)
@@ -5,16 +5,6 @@
SHORT-TERM (URGENT):
--------------------------------------------------------------------------------
-<vjrj>
- - Room join fails
- - Revisited ExtPoint system
- - " Desktop
- - LoginPanel issues
- - NGPanel issues
- - use of http://google-web-toolkit-doc-1-5.googlecode.com/svn/javadoc/1.5/com/google/gwt/user/client/rpc/StatusCodeException.html
-
---> vjrj
-<vjrj/>
<vjrj> IconHyperlink.java and IconLabel.java to gwt1.5
<vjrj> chat add new room name validation (do a form with validation)
--> vjrj
@@ -57,8 +47,6 @@
--> vjrj
<danigb> click in new group, reload sn innecessary
--> vjrj
-<vjrj> Test:
-http://gwtforge.com/
<vjrj> for dev, study jetty hot deploy (if scanIntervalSeconds > 0 also reload with client changes ... ). It will be nice to send a signal or something like that. See:
http://jetty.mortbay.org/jetty5/faq/faq_s_200-General_t_HotDeploy.html
See, I think is what we are looking for:
Modified: trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java 2008-10-01 21:12:10 UTC (rev 899)
+++ trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java 2008-10-02 19:57:49 UTC (rev 900)
@@ -23,6 +23,7 @@
import org.ourproject.kune.docs.client.DocumentClientModule;
import org.ourproject.kune.platf.client.services.KuneCoreModule;
import org.ourproject.kune.platf.client.services.KuneModule;
+import org.ourproject.kune.platf.client.services.KunePlatformModule;
import org.ourproject.kune.platf.client.services.KuneWorkspaceModule;
import com.allen_sauer.gwt.log.client.Log;
@@ -51,7 +52,7 @@
}
public void onModuleLoadCont() {
- Suco.install(new KuneCoreModule(), new KuneWorkspaceModule(), new EmiteUIModule(), new DocumentClientModule(),
- new ChatClientModule(), new KuneModule());
+ Suco.install(new KuneCoreModule(), new KunePlatformModule(), new KuneWorkspaceModule(), new EmiteUIModule(),
+ new DocumentClientModule(), new ChatClientModule(), new KuneModule());
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java 2008-10-01 21:12:10 UTC (rev 899)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java 2008-10-02 19:57:49 UTC (rev 900)
@@ -33,9 +33,7 @@
import org.ourproject.kune.platf.client.tool.ToolSelector;
import org.ourproject.kune.platf.client.tool.ToolSelectorPresenter;
import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
-import org.ourproject.kune.platf.client.ui.upload.FileUploader;
-import org.ourproject.kune.platf.client.ui.upload.FileUploaderDialog;
-import org.ourproject.kune.platf.client.ui.upload.FileUploaderPresenter;
+import org.ourproject.kune.platf.client.ui.palette.WebSafePalette;
import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator;
import org.ourproject.kune.workspace.client.ctxnav.ContextNavigatorPanel;
import org.ourproject.kune.workspace.client.ctxnav.ContextNavigatorPresenter;
@@ -287,9 +285,11 @@
ActionToolbarPanel.Position.content, $$(ActionManager.class), $(WorkspaceSkeleton.class));
final ActionToolbar<StateToken> toolbar = new ActionToolbarPresenter<StateToken>(
contentNavigatorToolbar);
+
final TextEditorPresenter presenter = new TextEditorPresenter(true, toolbar,
$(I18nUITranslationService.class));
- final TextEditorPanel panel = new TextEditorPanel(presenter, i18n, $(WorkspaceSkeleton.class));
+ final TextEditorPanel panel = new TextEditorPanel(presenter, $(I18nTranslationService.class),
+ $(WorkspaceSkeleton.class), $(WebSafePalette.class));
presenter.init(panel);
return presenter;
}
@@ -352,16 +352,6 @@
}
});
- register(Singleton.class, new Factory<FileUploader>(FileUploader.class) {
- public FileUploader create() {
- final FileUploaderPresenter presenter = new FileUploaderPresenter($(Session.class),
- $$(ContextNavigator.class));
- final FileUploaderDialog panel = new FileUploaderDialog(presenter, i18n, $(WorkspaceSkeleton.class));
- presenter.init(panel);
- return presenter;
- }
- });
-
register(Singleton.class, new Factory<FileDownloadUtils>(FileDownloadUtils.class) {
public FileDownloadUtils create() {
return new FileDownloadUtils($(Session.class));
Added: trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java 2008-10-01 21:12:10 UTC (rev 899)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java 2008-10-02 19:57:49 UTC (rev 900)
@@ -0,0 +1,43 @@
+package org.ourproject.kune.platf.client.services;
+
+import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.platf.client.ui.palette.WebSafePalette;
+import org.ourproject.kune.platf.client.ui.palette.WebSafePalettePanel;
+import org.ourproject.kune.platf.client.ui.palette.WebSafePalettePresenter;
+import org.ourproject.kune.platf.client.ui.upload.FileUploader;
+import org.ourproject.kune.platf.client.ui.upload.FileUploaderDialog;
+import org.ourproject.kune.platf.client.ui.upload.FileUploaderPresenter;
+import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator;
+import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService;
+import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
+
+import com.calclab.suco.client.ioc.decorator.Singleton;
+import com.calclab.suco.client.ioc.module.AbstractModule;
+import com.calclab.suco.client.ioc.module.Factory;
+
+public class KunePlatformModule extends AbstractModule {
+
+ @Override
+ protected void onLoad() {
+ register(Singleton.class, new Factory<WebSafePalette>(WebSafePalette.class) {
+ public WebSafePalette create() {
+ final WebSafePalettePresenter presenter = new WebSafePalettePresenter();
+ final WebSafePalettePanel panel = new WebSafePalettePanel(presenter);
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(Singleton.class, new Factory<FileUploader>(FileUploader.class) {
+ public FileUploader create() {
+ final FileUploaderPresenter presenter = new FileUploaderPresenter($(Session.class),
+ $$(ContextNavigator.class));
+ final FileUploaderDialog panel = new FileUploaderDialog(presenter, $(I18nUITranslationService.class),
+ $(WorkspaceSkeleton.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ }
+}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorSelectListener.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorSelectListener.java 2008-10-01 21:12:10 UTC (rev 899)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorSelectListener.java 2008-10-02 19:57:49 UTC (rev 900)
@@ -1,25 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2008 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-package org.ourproject.kune.platf.client.ui.palette;
-
-public interface ColorSelectListener {
- void onColorSelected(String color);
-}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/WebSafePalette.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/WebSafePalette.java 2008-10-01 21:12:10 UTC (rev 899)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/WebSafePalette.java 2008-10-02 19:57:49 UTC (rev 900)
@@ -0,0 +1,11 @@
+package org.ourproject.kune.platf.client.ui.palette;
+
+import com.calclab.suco.client.listener.Listener;
+
+public interface WebSafePalette {
+
+ void hide();
+
+ void show(int left, int top, Listener<String> onColorSelected);
+
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/WebSafePalettePanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/WebSafePalettePanel.java 2008-10-01 21:12:10 UTC (rev 899)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/WebSafePalettePanel.java 2008-10-02 19:57:49 UTC (rev 900)
@@ -20,8 +20,8 @@
package org.ourproject.kune.platf.client.ui.palette;
import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Grid;
+import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.SourcesTableEvents;
import com.google.gwt.user.client.ui.TableListener;
@@ -31,42 +31,61 @@
* http://en.wikipedia.org/wiki/Web_colors#Web-safe_colors
*
*/
-public class WebSafePalettePanel extends Composite implements WebSafePaletteView {
+public class WebSafePalettePanel implements WebSafePaletteView {
+ Grid paletteGrid;
private final WebSafePalettePresenter presenter;
+ private PopupPanel popupPalette;
public WebSafePalettePanel(final WebSafePalettePresenter initPresenter) {
- this.presenter = initPresenter;
+ this.presenter = initPresenter;
+ }
- Grid paletteGrid = new Grid(ROWS, COLS);
+ public void hide() {
+ if (popupPalette != null) {
+ popupPalette.hide();
+ }
+ }
- initWidget(paletteGrid);
+ public void show(final int left, final int top) {
+ if (paletteGrid == null) {
+ createPalette();
+ }
+ popupPalette = new PopupPanel(true, true);
+ popupPalette.setVisible(false);
+ popupPalette.show();
+ popupPalette.setPopupPosition(left, top);
+ popupPalette.setWidget(paletteGrid);
+ popupPalette.setVisible(true);
+ }
- paletteGrid.setCellSpacing(1);
- // Put color values in the grid cells
+ private void createPalette() {
+ paletteGrid = new Grid(ROWS, COLS);
- int row;
- int col;
- int n = 0;
- for (int a = 0; a < COLORS.length; a++) {
- for (int b = 0; b < COLORS.length; b++) {
- for (int c = 0; c < COLORS.length; c++) {
- row = n / COLS;
- col = n % COLS;
- String currentColor = "#" + COLORS[c] + COLORS[a] + COLORS[b];
- paletteGrid.setText(row, col, " ");
- DOM.setStyleAttribute(paletteGrid.getCellFormatter().getElement(row, col), "backgroundColor",
- currentColor);
- n++;
- }
- }
- }
- paletteGrid.addStyleName("kune-WebSafePalette");
- paletteGrid.addTableListener(new TableListener() {
- public void onCellClicked(final SourcesTableEvents sender, final int row, final int col) {
- presenter.onColorSelected(row, col);
- }
- });
+ paletteGrid.setCellSpacing(1);
+ // Put color values in the grid cells
+
+ int row;
+ int col;
+ int n = 0;
+ for (int a = 0; a < COLORS.length; a++) {
+ for (int b = 0; b < COLORS.length; b++) {
+ for (int c = 0; c < COLORS.length; c++) {
+ row = n / COLS;
+ col = n % COLS;
+ final String currentColor = "#" + COLORS[c] + COLORS[a] + COLORS[b];
+ paletteGrid.setText(row, col, " ");
+ DOM.setStyleAttribute(paletteGrid.getCellFormatter().getElement(row, col), "backgroundColor",
+ currentColor);
+ n++;
+ }
+ }
+ }
+ paletteGrid.addStyleName("kune-WebSafePalette");
+ paletteGrid.addTableListener(new TableListener() {
+ public void onCellClicked(final SourcesTableEvents sender, final int row, final int col) {
+ presenter.onColorSelected(row, col);
+ }
+ });
}
-
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/WebSafePalettePresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/WebSafePalettePresenter.java 2008-10-01 21:12:10 UTC (rev 899)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/WebSafePalettePresenter.java 2008-10-02 19:57:49 UTC (rev 900)
@@ -20,47 +20,45 @@
package org.ourproject.kune.platf.client.ui.palette;
-import java.util.ArrayList;
-import java.util.Iterator;
+import com.calclab.suco.client.listener.Listener;
-public class WebSafePalettePresenter {
+public class WebSafePalettePresenter implements WebSafePalette {
- private final ArrayList<ColorSelectListener> colorSelectListeners;
+ private Listener<String> onColorSelected;
+ private WebSafePaletteView view;
public WebSafePalettePresenter() {
- colorSelectListeners = new ArrayList<ColorSelectListener>();
}
- public void addColorSelectListener(final ColorSelectListener listener) {
- colorSelectListeners.add(listener);
+ public void hide() {
+ this.view.hide();
}
- protected void fireColorSelectListeners(final String color) {
- for (Iterator<ColorSelectListener> it = colorSelectListeners.iterator(); it.hasNext();) {
- (it.next()).onColorSelected(color);
- }
+ public void init(final WebSafePaletteView view) {
+ this.view = view;
}
- public void onColorSelected(final int row, final int col) {
- String color = getColor(row, col);
- fireColorSelectListeners(color);
+ public void show(final int left, final int top, final Listener<String> onColorSelected) {
+ view.show(left, top);
+ this.onColorSelected = onColorSelected;
}
- private String getColor(final int row, final int col) {
- String color = null;
- int pd = row * WebSafePaletteView.COLS + col;
- int da = pd / 6;
- int ra = pd % 6;
- int aa = da - ra / 6;
- int db = aa / 6;
- int rb = aa % 6;
- int rc = (db - rb / 6) % 6;
- color = "rgb(" + ra * 51 + ", " + rc * 51 + ", " + rb * 51 + ")";
- return color;
+ protected void onColorSelected(final int row, final int col) {
+ final String color = getColor(row, col);
+ onColorSelected.onEvent(color);
}
- public void reset() {
- colorSelectListeners.clear();
+ private String getColor(final int row, final int col) {
+ String color = null;
+ final int pd = row * WebSafePaletteView.COLS + col;
+ final int da = pd / 6;
+ final int ra = pd % 6;
+ final int aa = da - ra / 6;
+ final int db = aa / 6;
+ final int rb = aa % 6;
+ final int rc = (db - rb / 6) % 6;
+ color = "rgb(" + ra * 51 + ", " + rc * 51 + ", " + rb * 51 + ")";
+ return color;
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/WebSafePaletteView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/WebSafePaletteView.java 2008-10-01 21:12:10 UTC (rev 899)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/WebSafePaletteView.java 2008-10-02 19:57:49 UTC (rev 900)
@@ -28,4 +28,8 @@
final String COLORS[] = { "0", "3", "6", "9", "C", "F" };
+ void hide();
+
+ void show(int left, int top);
+
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPanel.java 2008-10-01 21:12:10 UTC (rev 899)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPanel.java 2008-10-02 19:57:49 UTC (rev 900)
@@ -22,6 +22,7 @@
import org.ourproject.kune.platf.client.services.I18nTranslationService;
import org.ourproject.kune.platf.client.ui.DefaultBorderLayout;
+import org.ourproject.kune.platf.client.ui.palette.WebSafePalette;
import org.ourproject.kune.workspace.client.skel.Toolbar;
import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
@@ -45,7 +46,7 @@
private final WorkspaceSkeleton ws;
public TextEditorPanel(final TextEditorPresenter presenter, final I18nTranslationService i18n,
- final WorkspaceSkeleton ws) {
+ final WorkspaceSkeleton ws, final WebSafePalette colorPalette) {
this.presenter = presenter;
this.i18n = i18n;
this.ws = ws;
@@ -58,7 +59,7 @@
final Toolbar editorTopBar = new Toolbar();
editorTopBar.getPanel().setWidth("auto");
- textEditorToolbar = new TextEditorToolbar(gwtRTarea, presenter, i18n);
+ textEditorToolbar = new TextEditorToolbar(gwtRTarea, presenter, colorPalette, i18n);
editorTopBar.add(textEditorToolbar);
editorTopBar.addStyleName("k-toolbar-bottom-line");
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorToolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorToolbar.java 2008-10-01 21:12:10 UTC (rev 899)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorToolbar.java 2008-10-02 19:57:49 UTC (rev 900)
@@ -27,11 +27,10 @@
import org.ourproject.kune.platf.client.ui.imgchooser.ImageChooser;
import org.ourproject.kune.platf.client.ui.imgchooser.ImageChooserCallback;
import org.ourproject.kune.platf.client.ui.imgchooser.ImageData;
-import org.ourproject.kune.platf.client.ui.palette.ColorSelectListener;
-import org.ourproject.kune.platf.client.ui.palette.WebSafePalettePanel;
-import org.ourproject.kune.platf.client.ui.palette.WebSafePalettePresenter;
+import org.ourproject.kune.platf.client.ui.palette.WebSafePalette;
import org.ourproject.kune.workspace.client.site.Site;
+import com.calclab.suco.client.listener.Listener;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
@@ -41,7 +40,6 @@
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.KeyboardListener;
import com.google.gwt.user.client.ui.MenuBar;
-import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.RichTextArea;
import com.google.gwt.user.client.ui.ToggleButton;
@@ -112,21 +110,17 @@
});
showLinkPanel();
} else if (sender == backColor) {
- showPalette(sender, sender.getAbsoluteLeft(), sender.getAbsoluteTop() + 20);
- palettePresenter.addColorSelectListener(new ColorSelectListener() {
- public void onColorSelected(final String color) {
+ colorPalette.show(sender.getAbsoluteLeft(), sender.getAbsoluteTop() + 20, new Listener<String>() {
+ public void onEvent(final String color) {
basic.setBackColor(color);
- popupPalette.hide();
- palettePresenter.reset();
+ colorPalette.hide();
}
});
} else if (sender == fontColor) {
- showPalette(sender, sender.getAbsoluteLeft(), sender.getAbsoluteTop() + 20);
- palettePresenter.addColorSelectListener(new ColorSelectListener() {
- public void onColorSelected(final String color) {
+ colorPalette.show(sender.getAbsoluteLeft(), sender.getAbsoluteTop() + 20, new Listener<String>() {
+ public void onEvent(final String color) {
basic.setForeColor(color);
- popupPalette.hide();
- palettePresenter.reset();
+ colorPalette.hide();
}
});
} else if (sender == removeLink) {
@@ -287,10 +281,8 @@
private PushButton fontColor;
private MenuBar fonts;
private MenuBar fontSizes;
- private WebSafePalettePanel palettePanel;
+ private final WebSafePalette colorPalette;
private final TextEditorPresenter presenter;
- private PopupPanel popupPalette;
- private WebSafePalettePresenter palettePresenter;
private final I18nTranslationService i18n;
/**
@@ -300,8 +292,9 @@
* the rich text area to be controlled
*/
public TextEditorToolbar(final RichTextArea richText, final TextEditorPresenter presenter,
- final I18nTranslationService i18n) {
+ final WebSafePalette colorPalette, final I18nTranslationService i18n) {
this.richText = richText;
+ this.colorPalette = colorPalette;
this.i18n = i18n;
this.basic = richText.getBasicFormatter();
this.extended = richText.getExtendedFormatter();
@@ -394,19 +387,6 @@
}
}
- public void showPalette(final Widget sender, final int left, final int top) {
- if (palettePanel == null) {
- palettePresenter = new WebSafePalettePresenter();
- palettePanel = new WebSafePalettePanel(palettePresenter);
- }
- popupPalette = new PopupPanel(true, true);
- popupPalette.setVisible(false);
- popupPalette.show();
- popupPalette.setPopupPosition(left, top);
- popupPalette.setWidget(palettePanel);
- popupPalette.setVisible(true);
- }
-
private MenuBar createFontSizesMenu() {
final MenuBar menu = new MenuBar();
final MenuBar submenu = new MenuBar(true);
More information about the kune-commits
mailing list