[kune-commits] r861 - in
trunk/src/main/java/org/ourproject/kune/workspace/client: .
entitylogo signin skel themes title
vjrj
vjrj at ourproject.org
Mon Sep 8 03:13:21 CEST 2008
Author: vjrj
Date: 2008-09-08 03:13:19 +0200 (Mon, 08 Sep 2008)
New Revision: 861
Added:
trunk/src/main/java/org/ourproject/kune/workspace/client/entitylogo/
trunk/src/main/java/org/ourproject/kune/workspace/client/entitylogo/EntityLogo.java
trunk/src/main/java/org/ourproject/kune/workspace/client/entitylogo/EntityLogoPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/entitylogo/EntityLogoPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/entitylogo/EntityLogoView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/signin/
trunk/src/main/java/org/ourproject/kune/workspace/client/signin/RegisterForm.java
trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignIn.java
trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInForm.java
trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/skel/
trunk/src/main/java/org/ourproject/kune/workspace/client/skel/AbstractBar.java
trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Entity.java
trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntitySummary.java
trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntityWorkspace.java
trunk/src/main/java/org/ourproject/kune/workspace/client/skel/SiteBar.java
trunk/src/main/java/org/ourproject/kune/workspace/client/skel/TitleBar.java
trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Toolbar.java
trunk/src/main/java/org/ourproject/kune/workspace/client/skel/WorkspaceSkeleton.java
trunk/src/main/java/org/ourproject/kune/workspace/client/themes/
trunk/src/main/java/org/ourproject/kune/workspace/client/themes/WsTheme.java
trunk/src/main/java/org/ourproject/kune/workspace/client/themes/WsThemePanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/themes/WsThemePresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/themes/WsThemeView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/title/
trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntitySubTitlePanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntitySubTitlePresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntitySubTitleView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitleView.java
Log:
Refactorization
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/entitylogo/EntityLogo.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/entitylogo/EntityLogo.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/entitylogo/EntityLogo.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,6 @@
+package org.ourproject.kune.workspace.client.entitylogo;
+
+
+public interface EntityLogo {
+
+}
\ No newline at end of file
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/entitylogo/EntityLogoPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/entitylogo/EntityLogoPanel.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/entitylogo/EntityLogoPanel.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,123 @@
+/*
+ *
+ * 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.workspace.client.entitylogo;
+
+import org.ourproject.kune.platf.client.services.I18nTranslationService;
+import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
+import org.ourproject.kune.workspace.client.themes.WsTheme;
+
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Hyperlink;
+import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.SimplePanel;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+public class EntityLogoPanel extends SimplePanel implements EntityLogoView {
+ class EntityTextLogo extends VerticalPanel {
+
+ private static final int GROUP_NAME_LIMIT_SIZE = 90;
+ private static final String LOGO_SMALL_FONT_SIZE = "108%";
+ private static final String LOGO_DEFAULT_FONT_SIZE = "167%";
+ private final Label defTextLogoLabel;
+ private final Hyperlink defTextPutYourLogoHL;
+ private final HorizontalPanel putYourLogoHP;
+
+ public EntityTextLogo() {
+ // Initialize
+ super();
+ defTextLogoLabel = new Label();
+ final HTML expandCell = new HTML("<b></b>");
+ putYourLogoHP = new HorizontalPanel();
+ defTextPutYourLogoHL = new Hyperlink();
+
+ // Layout
+ add(defTextLogoLabel);
+ add(putYourLogoHP);
+ putYourLogoHP.add(expandCell);
+ putYourLogoHP.add(defTextPutYourLogoHL);
+
+ // Set properties
+ // TODO: Put your logo here functionality
+ defTextPutYourLogoHL.setText(i18n.t("Put Your Logo Here"));
+ expandCell.setWidth("100%");
+ putYourLogoHP.setCellWidth(expandCell, "100%");
+ // TODO: link to configure the logo
+ setStylePrimaryName("k-entitytextlogo");
+ setDefaultText("");
+ }
+
+ public void setDefaultText(final String text) {
+ if (text.length() > GROUP_NAME_LIMIT_SIZE) {
+ DOM.setStyleAttribute(defTextLogoLabel.getElement(), "fontSize", LOGO_SMALL_FONT_SIZE);
+ } else {
+ DOM.setStyleAttribute(defTextLogoLabel.getElement(), "fontSize", LOGO_DEFAULT_FONT_SIZE);
+ }
+ defTextLogoLabel.setText(text);
+
+ }
+
+ public void setPutYourLogoVisible(final boolean visible) {
+ putYourLogoHP.setVisible(visible);
+ }
+
+ }
+
+ private EntityTextLogo entityTextLogo;
+ private final I18nTranslationService i18n;
+
+ public EntityLogoPanel(final I18nTranslationService i18n, final WorkspaceSkeleton ws) {
+ this.i18n = i18n;
+ ws.addToEntityMainHeader(this);
+ }
+
+ public void setLogo(final Image image) {
+ clear();
+ add(image);
+ }
+
+ public void setLogo(final String groupName) {
+ clear();
+ add(getEntityTextLogo());
+ entityTextLogo.setDefaultText(groupName);
+ }
+
+ public void setPutYourLogoVisible(final boolean visible) {
+ getEntityTextLogo().setPutYourLogoVisible(visible);
+ }
+
+ public void setTheme(final WsTheme oldTheme, final WsTheme newTheme) {
+ if (oldTheme != null) {
+ getEntityTextLogo().removeStyleDependentName(oldTheme.toString());
+ }
+ getEntityTextLogo().addStyleDependentName(newTheme.toString());
+ }
+
+ private EntityTextLogo getEntityTextLogo() {
+ if (entityTextLogo == null) {
+ this.entityTextLogo = new EntityTextLogo();
+ }
+ return entityTextLogo;
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/entitylogo/EntityLogoPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/entitylogo/EntityLogoPresenter.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/entitylogo/EntityLogoPresenter.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,37 @@
+package org.ourproject.kune.workspace.client.entitylogo;
+
+import org.ourproject.kune.platf.client.dto.GroupDTO;
+import org.ourproject.kune.platf.client.dto.StateDTO;
+import org.ourproject.kune.platf.client.state.StateManager;
+import org.ourproject.kune.workspace.client.themes.WsTheme;
+import org.ourproject.kune.workspace.client.themes.WsThemePresenter;
+
+import com.calclab.suco.client.signal.Slot;
+import com.calclab.suco.client.signal.Slot2;
+
+public class EntityLogoPresenter implements EntityLogo {
+ private EntityLogoView view;
+
+ public EntityLogoPresenter(final StateManager stateManager, final WsThemePresenter theme) {
+ stateManager.onStateChanged(new Slot<StateDTO>() {
+ public void onEvent(final StateDTO state) {
+ final GroupDTO group = state.getGroup();
+ final boolean isAdmin = state.getGroupRights().isAdministrable();
+
+ view.setLogo(group.getLongName());
+ view.setPutYourLogoVisible(isAdmin);
+ }
+ });
+ theme.onThemeChanged(new Slot2<WsTheme, WsTheme>() {
+ public void onEvent(final WsTheme oldTheme, final WsTheme newTheme) {
+ view.setTheme(oldTheme, newTheme);
+ }
+ });
+ }
+
+ public void init(final EntityLogoView view) {
+ this.view = view;
+
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/entitylogo/EntityLogoView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/entitylogo/EntityLogoView.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/entitylogo/EntityLogoView.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,17 @@
+package org.ourproject.kune.workspace.client.entitylogo;
+
+import org.ourproject.kune.workspace.client.themes.WsTheme;
+
+import com.google.gwt.user.client.ui.Image;
+
+public interface EntityLogoView {
+
+ // FIXME: Don' use Image
+ public abstract void setLogo(final Image image);
+
+ public abstract void setLogo(final String groupName);
+
+ public abstract void setPutYourLogoVisible(final boolean visible);
+
+ public abstract void setTheme(final WsTheme oldTheme, WsTheme newTheme);
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/signin/RegisterForm.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/signin/RegisterForm.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/signin/RegisterForm.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,206 @@
+package org.ourproject.kune.workspace.client.signin;
+
+import org.ourproject.kune.platf.client.ui.dialogs.DefaultForm;
+import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService;
+
+import com.gwtext.client.data.SimpleStore;
+import com.gwtext.client.data.Store;
+import com.gwtext.client.widgets.form.ComboBox;
+import com.gwtext.client.widgets.form.TextField;
+import com.gwtext.client.widgets.form.VType;
+import com.gwtext.client.widgets.form.ValidationException;
+import com.gwtext.client.widgets.form.Validator;
+
+public class RegisterForm extends DefaultForm {
+
+ private static final String MUST_BE_BETWEEN_3_AND_15 = "Must be between 3 and 15 lowercase characters. Can only contain characters, numbers, and dashes";
+
+ private static final String NICK_FIELD = "nick";
+ private static final String EMAIL_FIELD = "email";
+ private static final String LONGNAME_FIELD = "long_name";
+ private static final String PASSWORD_FIELD = "password";
+ private static final String PASSWORD_FIELD_DUP = "passwordDup";
+ private static final String LANG_FIELD = "lang";
+ private static final String COUNTRY_FIELD = "country";
+ private static final String TIMEZONE_FIELD = "timezone";
+
+ private final TextField shortNameRegField;
+ private final TextField longNameRegField;
+ private final TextField passwdRegField;
+ private final TextField passwdRegFieldDup;
+ private final TextField emailRegField;
+ private final ComboBox languageCombo;
+ private final ComboBox countryCombo;
+ private final ComboBox timezoneCombo;
+
+ public RegisterForm(final SignInPresenter presenter, final I18nUITranslationService i18n) {
+ super.addStyleName("kune-Margin-Large-l");
+
+ shortNameRegField = new TextField();
+ shortNameRegField.setFieldLabel(i18n.t("Nickname"));
+ shortNameRegField.setName(NICK_FIELD);
+ shortNameRegField.setWidth(DEF_FIELD_WIDTH);
+ shortNameRegField.setAllowBlank(false);
+ shortNameRegField.setMinLength(3);
+ shortNameRegField.setMaxLength(15);
+ shortNameRegField.setRegex("^[a-z0-9_\\-]+$");
+ shortNameRegField.setMinLengthText(i18n.t(MUST_BE_BETWEEN_3_AND_15));
+ shortNameRegField.setMaxLengthText(i18n.t(MUST_BE_BETWEEN_3_AND_15));
+ shortNameRegField.setRegexText(i18n.t(MUST_BE_BETWEEN_3_AND_15));
+ shortNameRegField.setValidationEvent(false);
+ add(shortNameRegField);
+
+ longNameRegField = new TextField();
+ longNameRegField.setFieldLabel(i18n.t("Full Name"));
+ longNameRegField.setName(LONGNAME_FIELD);
+ longNameRegField.setWidth(DEF_FIELD_WIDTH);
+ longNameRegField.setAllowBlank(false);
+ longNameRegField.setMinLength(3);
+ longNameRegField.setMaxLength(50);
+ longNameRegField.setValidationEvent(false);
+ add(longNameRegField);
+
+ passwdRegField = new TextField();
+ passwdRegField.setFieldLabel(i18n.t("Password"));
+ passwdRegField.setName(PASSWORD_FIELD);
+ passwdRegField.setPassword(true);
+ passwdRegField.setAllowBlank(false);
+ passwdRegField.setMaxLength(40);
+ passwdRegField.setWidth(DEF_FIELD_WIDTH);
+ passwdRegField.setValidationEvent(false);
+ add(passwdRegField);
+
+ passwdRegFieldDup = new TextField();
+ passwdRegFieldDup.setFieldLabel(i18n.t("Retype password"));
+ passwdRegFieldDup.setName(PASSWORD_FIELD_DUP);
+ passwdRegFieldDup.setPassword(true);
+ passwdRegFieldDup.setAllowBlank(false);
+ passwdRegFieldDup.setMinLength(6);
+ passwdRegFieldDup.setMaxLength(40);
+ passwdRegFieldDup.setWidth(DEF_FIELD_WIDTH);
+ passwdRegFieldDup.setInvalidText(i18n.t("Passwords do not match"));
+ passwdRegFieldDup.setValidator(new Validator() {
+ public boolean validate(final String value) throws ValidationException {
+ return passwdRegField.getValueAsString().equals(passwdRegFieldDup.getValueAsString());
+ }
+ });
+ passwdRegFieldDup.setValidationEvent(false);
+ add(passwdRegFieldDup);
+
+ emailRegField = new TextField();
+ emailRegField.setFieldLabel(i18n.t("Email"));
+ emailRegField.setName(EMAIL_FIELD);
+ emailRegField.setVtype(VType.EMAIL);
+ emailRegField.setWidth(DEF_FIELD_WIDTH);
+ emailRegField.setAllowBlank(false);
+ emailRegField.setValidationEvent(false);
+
+ add(emailRegField);
+
+ final Store langStore = new SimpleStore(new String[] { "abbr", "language" }, presenter.getLanguages());
+ langStore.load();
+
+ languageCombo = new ComboBox();
+ languageCombo.setName(LANG_FIELD);
+ languageCombo.setMinChars(1);
+ languageCombo.setFieldLabel(i18n.t("Language"));
+ languageCombo.setStore(langStore);
+ languageCombo.setDisplayField("language");
+ languageCombo.setMode(ComboBox.LOCAL);
+ languageCombo.setTriggerAction(ComboBox.ALL);
+ languageCombo.setEmptyText(i18n.t("Enter language"));
+ languageCombo.setLoadingText(i18n.t("Searching..."));
+ languageCombo.setTypeAhead(true);
+ languageCombo.setTypeAheadDelay(1000);
+ languageCombo.setSelectOnFocus(false);
+ languageCombo.setWidth(186);
+ languageCombo.setAllowBlank(false);
+ languageCombo.setValueField("abbr");
+ languageCombo.setValue(presenter.getCurrentLanguage().getCode());
+ languageCombo.setPageSize(7);
+ languageCombo.setForceSelection(true);
+ languageCombo.setValidationEvent(false);
+ add(languageCombo);
+
+ final Store countryStore = new SimpleStore(new String[] { "abbr", "country" }, presenter.getCountries());
+ countryStore.load();
+
+ countryCombo = new ComboBox();
+ countryCombo.setName(COUNTRY_FIELD);
+ countryCombo.setMinChars(1);
+ countryCombo.setFieldLabel(i18n.t("Country"));
+ countryCombo.setStore(countryStore);
+ countryCombo.setDisplayField("country");
+ countryCombo.setMode(ComboBox.LOCAL);
+ countryCombo.setTriggerAction(ComboBox.ALL);
+ countryCombo.setEmptyText(i18n.t("Enter your country"));
+ countryCombo.setLoadingText(i18n.t("Searching..."));
+ countryCombo.setTypeAhead(true);
+ countryCombo.setTypeAheadDelay(1000);
+ countryCombo.setSelectOnFocus(false);
+ countryCombo.setWidth(186);
+ countryCombo.setAllowBlank(false);
+ countryCombo.setValueField("abbr");
+ countryCombo.setPageSize(7);
+ countryCombo.setForceSelection(true);
+ countryCombo.setValidationEvent(false);
+ add(countryCombo);
+
+ final Store timezoneStore = new SimpleStore(new String[] { "id" }, presenter.getTimezones());
+ timezoneStore.load();
+
+ timezoneCombo = new ComboBox();
+ timezoneCombo.setName(TIMEZONE_FIELD);
+ timezoneCombo.setMinChars(1);
+ timezoneCombo.setFieldLabel(i18n.t("Timezone"));
+ timezoneCombo.setStore(timezoneStore);
+ timezoneCombo.setDisplayField("id");
+ timezoneCombo.setMode(ComboBox.LOCAL);
+ timezoneCombo.setTriggerAction(ComboBox.ALL);
+ timezoneCombo.setEmptyText(i18n.t("Enter your timezone"));
+ timezoneCombo.setLoadingText(i18n.t("Searching..."));
+ timezoneCombo.setTypeAhead(true);
+ timezoneCombo.setTypeAheadDelay(1000);
+ timezoneCombo.setSelectOnFocus(false);
+ timezoneCombo.setWidth(186);
+ timezoneCombo.setAllowBlank(false);
+ timezoneCombo.setValueField("id");
+ timezoneCombo.setPageSize(7);
+ timezoneCombo.setForceSelection(true);
+ timezoneCombo.setValidationEvent(false);
+ add(timezoneCombo);
+ }
+
+ public String getCountry() {
+ return countryCombo.getValueAsString();
+ }
+
+ public String getEmail() {
+ return emailRegField.getValueAsString();
+ }
+
+ public String getLanguage() {
+ return languageCombo.getValueAsString();
+ }
+
+ public String getLongName() {
+ return longNameRegField.getValueAsString();
+ }
+
+ public String getRegisterPassword() {
+ return passwdRegField.getValueAsString();
+ }
+
+ public String getRegisterPasswordDup() {
+ return passwdRegFieldDup.getValueAsString();
+ }
+
+ public String getShortName() {
+ return shortNameRegField.getValueAsString();
+ }
+
+ public String getTimezone() {
+ return timezoneCombo.getValueAsString();
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignIn.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignIn.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignIn.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,28 @@
+/*
+ *
+ * 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.workspace.client.signin;
+
+import org.ourproject.kune.platf.client.dto.StateToken;
+
+public interface SignIn {
+
+ void doSignIn(StateToken previousStateToken);
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInForm.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInForm.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInForm.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,48 @@
+package org.ourproject.kune.workspace.client.signin;
+
+import org.ourproject.kune.platf.client.services.I18nTranslationService;
+import org.ourproject.kune.platf.client.ui.dialogs.DefaultForm;
+
+import com.gwtext.client.widgets.form.TextField;
+
+public class SignInForm extends DefaultForm {
+ private static final String NICKOREMAIL_FIELD = "nickOrEmail";
+ private static final String PASSWORD_FIELD = "password";
+
+ private final TextField loginNickOrEmailField;
+ private final TextField loginPassField;
+
+ public SignInForm(final I18nTranslationService i18n) {
+ super.addStyleName("kune-Margin-Large-trbl");
+
+ loginNickOrEmailField = new TextField();
+ loginNickOrEmailField.setFieldLabel(i18n.t("Nickname or email"));
+ loginNickOrEmailField.setName(NICKOREMAIL_FIELD);
+ loginNickOrEmailField.setWidth(DEF_FIELD_WIDTH);
+ loginNickOrEmailField.setAllowBlank(false);
+ loginNickOrEmailField.setValidationEvent(false);
+ super.add(loginNickOrEmailField);
+
+ loginPassField = new TextField();
+ loginPassField.setFieldLabel(i18n.t("Password"));
+ loginPassField.setName(PASSWORD_FIELD);
+ loginPassField.setWidth(DEF_FIELD_WIDTH);
+ loginPassField.setPassword(true);
+ loginPassField.setAllowBlank(false);
+ loginPassField.setValidationEvent(false);
+ super.add(loginPassField);
+ }
+
+ public void focusLogin() {
+ loginNickOrEmailField.focus();
+ }
+
+ public String getLoginPassword() {
+ return loginPassField.getValueAsString();
+ }
+
+ public String getNickOrEmail() {
+ return loginNickOrEmailField.getValueAsString();
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInPanel.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInPanel.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,357 @@
+/*
+ *
+ * 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.workspace.client.signin;
+
+import java.util.Date;
+
+import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.platf.client.ui.dialogs.BasicDialog;
+import org.ourproject.kune.platf.client.ui.dialogs.InfoDialog;
+import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService;
+import org.ourproject.kune.workspace.client.newgroup.SiteErrorType;
+import org.ourproject.kune.workspace.client.site.Site;
+import org.ourproject.kune.workspace.client.site.msg.SimpleMessagePanel;
+import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.Cookies;
+import com.google.gwt.user.client.DeferredCommand;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.Widget;
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.core.RegionPosition;
+import com.gwtext.client.widgets.Button;
+import com.gwtext.client.widgets.Component;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.TabPanel;
+import com.gwtext.client.widgets.event.ButtonListenerAdapter;
+import com.gwtext.client.widgets.event.PanelListenerAdapter;
+import com.gwtext.client.widgets.event.WindowListenerAdapter;
+import com.gwtext.client.widgets.form.Field;
+import com.gwtext.client.widgets.layout.BorderLayout;
+import com.gwtext.client.widgets.layout.BorderLayoutData;
+import com.gwtext.client.widgets.layout.FitLayout;
+
+public class SignInPanel implements SignInView {
+ private class MessagePanel extends Panel {
+ private final SimpleMessagePanel messagesPanel;
+
+ public MessagePanel() {
+ setPaddings(10);
+ setBorder(false);
+ setHeight(60);
+ messagesPanel = new SimpleMessagePanel();
+ messagesPanel.setMessage("", SiteErrorType.info, SiteErrorType.error);
+ add(messagesPanel);
+ }
+
+ public void hide() {
+ messagesPanel.hide();
+ super.hide();
+ }
+
+ public void setMessage(final String message, final SiteErrorType lastMessageType, final SiteErrorType type) {
+ messagesPanel.setMessage(message, lastMessageType, type);
+ }
+
+ public void show() {
+ messagesPanel.show();
+ super.show();
+ }
+ }
+
+ private BasicDialog dialog;
+ private final SignInPresenter presenter;
+ private SignInForm signInForm;
+ private RegisterForm registerForm;
+ private MessagePanel messagesSignInPanel;
+ private InfoDialog welcomeDialog;
+ private TabPanel centerPanel;
+ private MessagePanel messagesRegisterPanel;
+ private final I18nUITranslationService i18n;
+
+ public SignInPanel(final SignInPresenter presenter, final I18nUITranslationService i18n, final WorkspaceSkeleton ws) {
+ this.i18n = i18n;
+ Field.setMsgTarget("side");
+ this.presenter = presenter;
+ createPanel();
+ }
+
+ public void center() {
+ dialog.center();
+ }
+
+ public String getCountry() {
+ return registerForm.getCountry();
+ }
+
+ public String getEmail() {
+ return registerForm.getEmail();
+ }
+
+ public String getLanguage() {
+ return registerForm.getLanguage();
+ }
+
+ public String getLoginPassword() {
+ return signInForm.getLoginPassword();
+ }
+
+ public String getLongName() {
+ return registerForm.getLongName();
+ }
+
+ public String getNickOrEmail() {
+ return signInForm.getNickOrEmail();
+ }
+
+ public String getRegisterPassword() {
+ return registerForm.getRegisterPassword();
+ }
+
+ public String getRegisterPasswordDup() {
+ return registerForm.getRegisterPasswordDup();
+ }
+
+ public String getShortName() {
+ return registerForm.getShortName();
+ }
+
+ public String getTimezone() {
+ return registerForm.getTimezone();
+ }
+
+ public void hide() {
+ dialog.hide();
+ }
+
+ public void hideMessages() {
+ messagesSignInPanel.hide();
+ if (messagesRegisterPanel != null) {
+ messagesRegisterPanel.hide();
+ }
+ renderDialogIfNeeded();
+ }
+
+ public boolean isRegisterFormValid() {
+ return registerForm.isValid();
+ }
+
+ public boolean isSignInFormValid() {
+ return signInForm.isValid();
+ }
+
+ public void mask(final String message) {
+ dialog.getEl().mask(message, "x-mask-loading");
+ }
+
+ public void maskProcessing() {
+ mask(i18n.t("Processing"));
+ }
+
+ public void reset() {
+ DeferredCommand.addCommand(new Command() {
+ public void execute() {
+ signInForm.reset();
+ if (registerForm != null) {
+ registerForm.reset();
+ }
+ }
+ });
+ }
+
+ public void setCookie(final String userHash) {
+ // http://code.google.com/p/google-web-toolkit-incubator/wiki/LoginSecurityFAQ
+ final long duration = Session.SESSION_DURATION;
+ final Date expires = new Date(System.currentTimeMillis() + duration);
+ Cookies.setCookie(Site.USERHASH, userHash, expires, null, "/", false);
+ GWT.log("Received hash: " + userHash, null);
+ }
+
+ public void setRegisterMessage(final String message, final SiteErrorType type) {
+ messagesRegisterPanel.setMessage(message, type, type);
+ messagesRegisterPanel.show();
+ renderDialogIfNeeded();
+ }
+
+ public void setSignInMessage(final String message, final SiteErrorType type) {
+ messagesSignInPanel.setMessage(message, type, type);
+ messagesSignInPanel.show();
+ renderDialogIfNeeded();
+ }
+
+ public void show() {
+ centerPanel.activate(0);
+ dialog.setVisible(true);
+ dialog.show();
+ Site.hideProgress();
+ dialog.focus();
+ signInForm.focusLogin();
+ }
+
+ public void showWelcolmeDialog() {
+ if (welcomeDialog == null) {
+ welcomeDialog = new InfoDialog(i18n.t("Welcome"), i18n.t("Thanks for registering"), i18n
+ .t("Now you can participate more actively in this site with other people and groups. "
+ + "You can also use your personal space to publish contents. "
+ + "Your email is not verified, please follow the instructions you will receive by email."),
+ i18n.t("Ok"), true, true, 400, 270);
+ }
+ welcomeDialog.show();
+ }
+
+ public void unMask() {
+ dialog.getEl().unmask();
+ }
+
+ private void confPanel(final Panel panel) {
+ // panel.setLayout(new FormLayout());
+ // panel.setAutoWidth(true);
+ // anel.setAutoHeight(true);
+ }
+
+ private Panel createNoAccountRegister() {
+ final Panel noAccRegisterPanel = new Panel();
+ noAccRegisterPanel.setBorder(false);
+ noAccRegisterPanel.setMargins(0, 90, 0, 0);
+ final Label dontHaveAccountLabel = new Label(i18n.t("Don't have an account?"));
+ final Label registerLabel = new Label(i18n.t("Create one."));
+ registerLabel.addClickListener(new ClickListener() {
+ public void onClick(final Widget arg0) {
+ centerPanel.activate(1);
+ }
+ });
+ registerLabel.addStyleName("kune-Margin-Medium-l");
+ registerLabel.addStyleName("kune-link");
+ noAccRegisterPanel.add(dontHaveAccountLabel);
+ noAccRegisterPanel.add(registerLabel);
+ return noAccRegisterPanel;
+ }
+
+ private void createPanel() {
+ dialog = new BasicDialog(i18n.t("Sign in"), true, false, 370, 400);
+ dialog.setLayout(new FitLayout());
+ final Panel dialogPanel = new Panel();
+ dialogPanel.setLayout(new BorderLayout());
+ // dialog.setAutoHeight(false);
+ // dialog.setAutoWidth(false);
+ // dialog.setAutoHeight(true);
+ // dialog.setAutoWidth(true);
+ dialogPanel.setHeight("100%");
+ dialogPanel.setWidth("auto");
+ // dialog.setCollapsible(false);
+
+ centerPanel = new TabPanel();
+ centerPanel.setActiveTab(0);
+ // centerPanel.setAutoWidth(true);
+ // centerPanel.setAutoHeight(true);
+ centerPanel.setClosable(false);
+
+ final Panel signInPanel = new Panel(i18n.t("Sign in"));
+ confPanel(signInPanel);
+ signInForm = new SignInForm(i18n);
+ signInPanel.add(signInForm.getForm());
+ signInPanel.add(createNoAccountRegister());
+ messagesSignInPanel = new MessagePanel();
+ signInPanel.add(messagesSignInPanel);
+
+ final Panel registerPanel = new Panel(i18n.t("Register"));
+ confPanel(registerPanel);
+
+ centerPanel.add(signInPanel);
+ centerPanel.add(registerPanel);
+ dialogPanel.add(centerPanel, new BorderLayoutData(RegionPosition.CENTER));
+ dialog.add(dialogPanel);
+
+ final Button signInBtn = new Button(i18n.t("Sign in"));
+ signInBtn.addListener(new ButtonListenerAdapter() {
+ public void onClick(final Button button, final EventObject e) {
+ signInForm.validate();
+ if (signInForm.isValid()) {
+ presenter.onFormSignIn();
+ }
+ }
+ });
+ dialog.addButton(signInBtn);
+
+ final Button registerBtn = new Button(i18n.t("Register"));
+ registerBtn.addListener(new ButtonListenerAdapter() {
+ public void onClick(final Button button, final EventObject e) {
+ registerForm.validate();
+ if (registerForm.isValid()) {
+ presenter.onFormRegister();
+ }
+ }
+ });
+ dialog.addButton(registerBtn);
+ registerBtn.hide();
+
+ final Button cancel = new Button();
+ dialog.addButton(cancel);
+ cancel.setText(i18n.tWithNT("Cancel", "used in button"));
+ cancel.addListener(new ButtonListenerAdapter() {
+ public void onClick(final Button button, final EventObject e) {
+ presenter.onCancel();
+ }
+ });
+
+ signInPanel.addListener(new PanelListenerAdapter() {
+ public void onActivate(final Panel panel) {
+ dialog.setTitle(i18n.t("Sign in"));
+ registerBtn.hide();
+ signInBtn.show();
+ }
+ });
+
+ registerPanel.addListener(new PanelListenerAdapter() {
+ public void onActivate(final Panel panel) {
+ if (registerForm == null) {
+ maskProcessing();
+ registerForm = new RegisterForm(presenter, i18n);
+ registerPanel.add(registerForm.getForm());
+ messagesRegisterPanel = new MessagePanel();
+ registerPanel.add(messagesRegisterPanel);
+ messagesRegisterPanel.hide();
+ renderDialogIfNeeded();
+ unMask();
+ }
+ dialog.setTitle(i18n.t("Register"));
+ signInBtn.hide();
+ registerBtn.show();
+ }
+ });
+
+ dialog.addListener(new WindowListenerAdapter() {
+ public void onHide(final Component component) {
+ presenter.onClose();
+ }
+ });
+ hideMessages();
+ renderDialogIfNeeded();
+ }
+
+ private void renderDialogIfNeeded() {
+ if (dialog.isRendered()) {
+ dialog.doLayout();
+ }
+ }
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInPresenter.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInPresenter.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,208 @@
+/*
+ *
+ * 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.workspace.client.signin;
+
+import org.ourproject.kune.platf.client.dto.I18nCountryDTO;
+import org.ourproject.kune.platf.client.dto.I18nLanguageDTO;
+import org.ourproject.kune.platf.client.dto.StateToken;
+import org.ourproject.kune.platf.client.dto.TimeZoneDTO;
+import org.ourproject.kune.platf.client.dto.UserDTO;
+import org.ourproject.kune.platf.client.dto.UserInfoDTO;
+import org.ourproject.kune.platf.client.errors.EmailAddressInUseException;
+import org.ourproject.kune.platf.client.errors.GroupNameInUseException;
+import org.ourproject.kune.platf.client.errors.UserAuthException;
+import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.platf.client.state.StateManager;
+import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService;
+import org.ourproject.kune.workspace.client.newgroup.SiteErrorType;
+import org.ourproject.kune.workspace.client.site.Site;
+import org.ourproject.kune.workspace.client.site.rpc.UserServiceAsync;
+
+import com.calclab.emite.client.im.roster.RosterManager.SubscriptionMode;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+public class SignInPresenter implements SignIn {
+
+ SignInView view;
+ private final Session session;
+ private final I18nUITranslationService i18n;
+ private final UserServiceAsync userService;
+ private final StateManager stateManager;
+ private StateToken previousStateToken;
+
+ public SignInPresenter(final Session session, final StateManager stateManager, final I18nUITranslationService i18n,
+ final UserServiceAsync userService) {
+ this.session = session;
+ this.stateManager = stateManager;
+ this.userService = userService;
+ this.i18n = i18n;
+ }
+
+ public void doSignIn(final StateToken previousStateToken) {
+ this.previousStateToken = previousStateToken;
+ if (!session.isLogged()) {
+ Site.showProgressProcessing();
+ view.show();
+ view.center();
+ Site.hideProgress();
+ } else {
+ stateManager.gotoToken(previousStateToken);
+ }
+ }
+
+ public Object[][] getCountries() {
+ return session.getCountriesArray();
+ }
+
+ public I18nLanguageDTO getCurrentLanguage() {
+ return session.getCurrentLanguage();
+ }
+
+ public Object[][] getLanguages() {
+ return session.getLanguagesArray();
+ }
+
+ public Object[][] getTimezones() {
+ return session.getTimezones();
+ }
+
+ public void init(final SignInView loginview) {
+ this.view = loginview;
+ }
+
+ public void onCancel() {
+ resetMessages();
+ reset();
+ view.hide();
+ stateManager.gotoToken(previousStateToken);
+ }
+
+ public void onClose() {
+ reset();
+ view.hideMessages();
+ if (!session.isLogged()) {
+ stateManager.gotoToken(previousStateToken);
+ }
+ }
+
+ public void onFormRegister() {
+ if (view.isRegisterFormValid()) {
+ view.maskProcessing();
+
+ final I18nLanguageDTO language = new I18nLanguageDTO();
+ language.setCode(view.getLanguage());
+
+ final I18nCountryDTO country = new I18nCountryDTO();
+ country.setCode(view.getCountry());
+
+ final TimeZoneDTO timezone = new TimeZoneDTO();
+ timezone.setId(view.getTimezone());
+
+ final UserDTO user = new UserDTO(view.getLongName(), view.getShortName(), view.getRegisterPassword(), view
+ .getEmail(), language, country, timezone, null, true, SubscriptionMode.manual, "blue");
+ final AsyncCallback<UserInfoDTO> callback = new AsyncCallback<UserInfoDTO>() {
+ public void onFailure(final Throwable caught) {
+ view.unMask();
+ try {
+ throw caught;
+ } catch (final EmailAddressInUseException e) {
+ view.setRegisterMessage(i18n.t("This email in in use by other person, try with another."),
+ SiteErrorType.error);
+ } catch (final GroupNameInUseException e) {
+ view.setRegisterMessage(i18n.t("This name in already in use, try with a different name."),
+ SiteErrorType.error);
+ } catch (final Throwable e) {
+ view.setRegisterMessage(i18n.t("Error during registration."), SiteErrorType.error);
+ GWT.log("Other kind of exception in user registration" + e.getMessage() + ", "
+ + e.getLocalizedMessage(), null);
+ e.printStackTrace();
+ throw new RuntimeException();
+ }
+ }
+
+ public void onSuccess(final UserInfoDTO userInfoDTO) {
+ stateManager.gotoToken(userInfoDTO.getHomePage());
+ onSignIn(userInfoDTO);
+ view.hide();
+ view.unMask();
+ view.showWelcolmeDialog();
+ }
+ };
+ userService.createUser(user, callback);
+ }
+ }
+
+ protected void onFormSignIn() {
+ if (view.isSignInFormValid()) {
+ view.maskProcessing();
+
+ final String nickOrEmail = view.getNickOrEmail();
+ final String passwd = view.getLoginPassword();
+
+ final UserDTO user = new UserDTO();
+ user.setShortName(nickOrEmail);
+ user.setPassword(passwd);
+
+ final AsyncCallback<UserInfoDTO> callback = new AsyncCallback<UserInfoDTO>() {
+ public void onFailure(final Throwable caught) {
+ view.unMask();
+ Site.hideProgress();
+ try {
+ throw caught;
+ } catch (final UserAuthException e) {
+ view.setSignInMessage(i18n.t("Incorrect nickname/email or password"), SiteErrorType.error);
+ } catch (final Throwable e) {
+ view.setSignInMessage("Error in login", SiteErrorType.error);
+ GWT.log("Other kind of exception in LoginFormPresenter/doLogin", null);
+ throw new RuntimeException();
+ }
+ }
+
+ public void onSuccess(final UserInfoDTO userInfoDTO) {
+ onSignIn(userInfoDTO);
+ stateManager.gotoToken(previousStateToken);
+ view.hide();
+ view.unMask();
+ }
+ };
+ userService.login(user.getShortName(), user.getPassword(), callback);
+ }
+ }
+
+ private void onSignIn(final UserInfoDTO userInfoDTO) {
+ final String userHash = userInfoDTO.getUserHash();
+ view.setCookie(userHash);
+ session.setUserHash(userHash);
+ session.setCurrentUserInfo(userInfoDTO);
+ final I18nLanguageDTO language = userInfoDTO.getLanguage();
+ i18n.changeCurrentLanguage(language.getCode());
+ session.setCurrentLanguage(language);
+ }
+
+ private void reset() {
+ view.reset();
+ }
+
+ private void resetMessages() {
+ view.hideMessages();
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInView.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInView.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,73 @@
+/*
+ *
+ * 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.workspace.client.signin;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.workspace.client.newgroup.SiteErrorType;
+
+public interface SignInView extends View {
+
+ public void center();
+
+ public String getCountry();
+
+ public String getEmail();
+
+ public String getLanguage();
+
+ public String getLoginPassword();
+
+ public String getLongName();
+
+ public String getNickOrEmail();
+
+ public String getRegisterPassword();
+
+ public String getRegisterPasswordDup();
+
+ public String getShortName();
+
+ public String getTimezone();
+
+ public void hide();
+
+ public void hideMessages();
+
+ public boolean isRegisterFormValid();
+
+ public boolean isSignInFormValid();
+
+ public void maskProcessing();
+
+ public void reset();
+
+ public void show();
+
+ public void showWelcolmeDialog();
+
+ public void unMask();
+
+ void setCookie(String userHash);
+
+ void setRegisterMessage(String message, SiteErrorType type);
+
+ void setSignInMessage(String message, SiteErrorType type);
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/AbstractBar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/AbstractBar.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/AbstractBar.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,45 @@
+package org.ourproject.kune.workspace.client.skel;
+
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+public class AbstractBar extends Composite {
+ private final HorizontalPanel childPanel;
+ private final HorizontalPanel mainPanel;
+
+ public AbstractBar() {
+ mainPanel = new HorizontalPanel();
+ childPanel = new HorizontalPanel();
+ mainPanel.add(childPanel);
+ initWidget(mainPanel);
+ mainPanel.setWidth("100%");
+ }
+
+ public void add(final Widget widget) {
+ childPanel.add(widget);
+ childPanel.setCellVerticalAlignment(widget, VerticalPanel.ALIGN_MIDDLE);
+ }
+
+ public void addFill() {
+ final Label emptyLabel = new Label("");
+ this.add(emptyLabel);
+ childPanel.setCellWidth(emptyLabel, "100%");
+ }
+
+ public void addSeparator() {
+ final Label emptyLabel = new Label("");
+ emptyLabel.setStyleName("ytb-sep");
+ emptyLabel.addStyleName("k-toolbar-sep");
+ this.add(emptyLabel);
+ }
+
+ public void addSpacer() {
+ final Label emptyLabel = new Label("");
+ emptyLabel.setStyleName("ytb-spacer");
+ this.add(emptyLabel);
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Entity.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Entity.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Entity.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,47 @@
+package org.ourproject.kune.workspace.client.skel;
+
+import org.ourproject.kune.platf.client.ui.DefaultBorderLayout;
+import org.ourproject.kune.workspace.client.themes.WsTheme;
+
+import com.google.gwt.user.client.ui.Widget;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.layout.FitLayout;
+
+public class Entity extends DefaultBorderLayout {
+
+ private final EntityWorkspace entityWorkspace;
+ private final EntitySummary entitySummary;
+ private final Panel entityMainHeader;
+
+ public Entity() {
+ entityMainHeader = new Panel();
+ entityMainHeader.setBorder(false);
+ entityMainHeader.setLayout(new FitLayout());
+ entitySummary = new EntitySummary();
+ entityWorkspace = new EntityWorkspace();
+ add(entityMainHeader, DefaultBorderLayout.Position.NORTH, 65);
+ add(entityWorkspace.getPanel(), DefaultBorderLayout.Position.CENTER);
+ add(entitySummary.getPanel(), DefaultBorderLayout.Position.EAST, true, 150);
+ }
+
+ public void addToEntityMainHeader(final Widget widget) {
+ entityMainHeader.add(widget);
+ doLayoutIfNeeded();
+ }
+
+ public EntitySummary getEntitySummary() {
+ return entitySummary;
+ }
+
+ public EntityWorkspace getEntityWorkspace() {
+ return entityWorkspace;
+ }
+
+ public void setTheme(final WsTheme oldTheme, final WsTheme newTheme) {
+ if (oldTheme != null) {
+ super.removeStyle("k-entity-" + oldTheme);
+ }
+ super.addStyle("k-entity-" + newTheme);
+ entityWorkspace.setTheme(oldTheme, newTheme);
+ }
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntitySummary.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntitySummary.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntitySummary.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,66 @@
+package org.ourproject.kune.workspace.client.skel;
+
+import org.ourproject.kune.platf.client.ui.DefaultBorderLayout;
+
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.Toolbar;
+import com.gwtext.client.widgets.event.ContainerListener;
+import com.gwtext.client.widgets.layout.FitLayout;
+
+public class EntitySummary {
+ private final Panel entityTools;
+ private final Panel entitySummary;
+ private final DefaultBorderLayout mainPanel;
+ private final Toolbar trayBar;
+ private final VerticalPanel vpTools;
+
+ public EntitySummary() {
+ mainPanel = new DefaultBorderLayout();
+ entityTools = new Panel();
+ entityTools.setLayout(new FitLayout());
+ entityTools.setAutoHeight(true);
+ vpTools = new VerticalPanel();
+ entityTools.add(vpTools);
+ entitySummary = new Panel();
+ entityTools.setBorder(false);
+ entitySummary.setBorder(false);
+ entityTools.setAutoScroll(false);
+ entitySummary.setAutoScroll(true);
+ entitySummary.setCls("k-entity-summary");
+ trayBar = mainPanel.createBottomBar(entitySummary, "k-site-traybar");
+ mainPanel.add(entityTools, DefaultBorderLayout.Position.NORTH);
+ mainPanel.add(entitySummary, DefaultBorderLayout.Position.CENTER);
+ trayBar.addFill();
+ }
+
+ public void addInSummary(final Widget widget) {
+ entitySummary.add(widget);
+ entitySummary.syncSize();
+ mainPanel.doLayoutIfNeeded();
+ }
+
+ public void addInTools(final Widget widget) {
+ vpTools.add(widget);
+ // entityTools.render(widget.getElement());
+ if (entityTools.isRendered()) {
+ entityTools.syncSize();
+ entityTools.doLayout(false);
+ mainPanel.doLayoutIfNeeded();
+ }
+ }
+
+ public void addListener(final ContainerListener listener) {
+ entitySummary.addListener(listener);
+ }
+
+ public Panel getPanel() {
+ return mainPanel.getPanel();
+ }
+
+ public Toolbar getSiteTraybar() {
+ return trayBar;
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntityWorkspace.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntityWorkspace.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntityWorkspace.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,138 @@
+package org.ourproject.kune.workspace.client.skel;
+
+import org.ourproject.kune.platf.client.ui.DefaultBorderLayout;
+import org.ourproject.kune.platf.client.ui.RoundedPanel;
+import org.ourproject.kune.workspace.client.themes.WsTheme;
+
+import com.google.gwt.user.client.ui.Widget;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.layout.AnchorLayout;
+import com.gwtext.client.widgets.layout.AnchorLayoutData;
+
+public class EntityWorkspace extends DefaultBorderLayout {
+ private final Panel content;
+ private final Panel context;
+ private final TitleBar title;
+ private final TitleBar subTitle;
+ private final TitleBar bottom;
+ private final Toolbar contentTopBar;
+ private final Toolbar contentBottomBar;
+ private final Toolbar contextTopBar;
+ private final Toolbar contextBottomBar;
+ private final RoundedPanel roundedTitle;
+ private final RoundedPanel roundedBottom;
+ private final DefaultBorderLayout contextWrap;
+
+ public EntityWorkspace() {
+ final Panel titles = new Panel();
+ titles.setBorder(false);
+ titles.setLayout(new AnchorLayout());
+ final Panel bottomPanel = new Panel();
+ bottomPanel.setBorder(false);
+ bottomPanel.setLayout(new AnchorLayout());
+
+ title = new TitleBar();
+ title.setHeight("" + (DEF_TOOLBAR_HEIGHT - 2));
+ title.setStylePrimaryName("k-entity-title");
+ subTitle = new TitleBar();
+ subTitle.setStylePrimaryName("k-entity-subtitle");
+ bottom = new TitleBar();
+ bottom.setHeight("" + (DEF_TOOLBAR_HEIGHT - 2));
+ bottom.setStylePrimaryName("k-entity-bottom");
+
+ roundedTitle = new RoundedPanel(title, RoundedPanel.TOPLEFT, 2);
+ roundedBottom = new RoundedPanel(bottom, RoundedPanel.BOTTOMLEFT, 2);
+
+ titles.add(roundedTitle, new AnchorLayoutData("100% -" + DEF_TOOLBAR_HEIGHT));
+ titles.add(subTitle, new AnchorLayoutData("100% -" + DEF_TOOLBAR_HEIGHT));
+ bottomPanel.add(roundedBottom, new AnchorLayoutData("100% -" + DEF_TOOLBAR_HEIGHT));
+
+ final DefaultBorderLayout contentWrap = new DefaultBorderLayout();
+ contextWrap = new DefaultBorderLayout();
+ contentWrap.setBorder(true);
+ contextWrap.setBorder(true);
+ content = new Panel();
+ context = new Panel();
+ content.setBorder(false);
+ context.setBorder(false);
+ context.setCollapsible(true);
+ content.setPaddings(7);
+ content.setAutoScroll(true);
+ context.setAutoScroll(true);
+
+ contentTopBar = new Toolbar();
+ contentBottomBar = new Toolbar();
+ contextTopBar = new Toolbar();
+ contextBottomBar = new Toolbar();
+ contentTopBar.addStyleName("k-toolbar-bottom-line");
+ contentBottomBar.addStyleName("k-toolbar-top-line");
+ contextTopBar.addStyleName("k-toolbar-bottom-line");
+ contextBottomBar.addStyleName("k-toolbar-top-line");
+ contentWrap.add(contentTopBar.getPanel(), Position.NORTH, false, DEF_TOOLBAR_HEIGHT);
+ contextWrap.add(contextTopBar.getPanel(), Position.NORTH, false, DEF_TOOLBAR_HEIGHT);
+ contentWrap.add(content, Position.CENTER);
+ contextWrap.add(context, Position.CENTER);
+ contentWrap.add(contentBottomBar.getPanel(), Position.SOUTH, false, DEF_TOOLBAR_HEIGHT);
+ contextWrap.add(contextBottomBar.getPanel(), Position.SOUTH, false, DEF_TOOLBAR_HEIGHT);
+
+ add(titles, DefaultBorderLayout.Position.NORTH, DEF_TOOLBAR_HEIGHT * 2);
+ add(contentWrap.getPanel(), DefaultBorderLayout.Position.CENTER);
+ add(contextWrap.getPanel(), DefaultBorderLayout.Position.EAST, true, 175);
+ add(bottomPanel, DefaultBorderLayout.Position.SOUTH, DEF_TOOLBAR_HEIGHT + 2);
+ }
+
+ public TitleBar getBottomTitle() {
+ return bottom;
+ }
+
+ public Toolbar getContentBottomBar() {
+ return contentBottomBar;
+ }
+
+ public Toolbar getContentTopBar() {
+ return contentTopBar;
+ }
+
+ public Toolbar getContextBottomBar() {
+ return contextBottomBar;
+ }
+
+ public Toolbar getContextTopBar() {
+ return contextTopBar;
+ }
+
+ public TitleBar getSubTitle() {
+ return subTitle;
+ }
+
+ public TitleBar getTitle() {
+ return title;
+ }
+
+ public void setContent(final Widget widget) {
+ setPanel(content, widget);
+ }
+
+ public void setContext(final Widget widget) {
+ setPanel(context, widget);
+ }
+
+ public void setTheme(final WsTheme oldTheme, final WsTheme newTheme) {
+ final String themeS = newTheme.toString();
+ if (oldTheme != null) {
+ final String previousThemeS = oldTheme.toString();
+ title.removeStyleDependentName(previousThemeS);
+ subTitle.removeStyleDependentName(previousThemeS);
+ bottom.removeStyleDependentName(previousThemeS);
+ super.removeStyle("k-entityworkspace-" + previousThemeS);
+ context.removeStyleName("k-entity-context-" + previousThemeS);
+ }
+ super.addStyle("k-entityworkspace-" + newTheme);
+ roundedTitle.setCornerStyleName("k-entity-title-rd-" + newTheme);
+ roundedBottom.setCornerStyleName("k-entity-bottom-rd-" + newTheme);
+ title.addStyleDependentName(themeS);
+ subTitle.addStyleDependentName(themeS);
+ bottom.addStyleDependentName(themeS);
+ context.addStyleName("k-entity-context-" + newTheme);
+ }
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/SiteBar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/SiteBar.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/SiteBar.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,33 @@
+package org.ourproject.kune.workspace.client.skel;
+
+import com.google.gwt.user.client.ui.Widget;
+import com.gwtext.client.widgets.Panel;
+
+public class SiteBar extends Panel {
+
+ private final TitleBar titleBar;
+
+ public SiteBar() {
+ super.setBorder(false);
+ titleBar = new TitleBar();
+ titleBar.setStyleName("k-sitebar");
+ super.add(titleBar);
+ }
+
+ public void add(final Widget widget) {
+ titleBar.add(widget);
+ }
+
+ public Widget addFill() {
+ return titleBar.addFill();
+ }
+
+ public Widget addSeparator() {
+ return titleBar.addSeparator();
+ }
+
+ public Widget addSpacer() {
+ return titleBar.addSpacer();
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/TitleBar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/TitleBar.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/TitleBar.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,48 @@
+package org.ourproject.kune.workspace.client.skel;
+
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+public class TitleBar extends Composite {
+
+ private final HorizontalPanel childPanel;
+ private final HorizontalPanel mainPanel;
+
+ public TitleBar() {
+ mainPanel = new HorizontalPanel();
+ childPanel = new HorizontalPanel();
+ mainPanel.add(childPanel);
+ initWidget(mainPanel);
+ mainPanel.setWidth("100%");
+ }
+
+ public void add(final Widget widget) {
+ childPanel.add(widget);
+ childPanel.setCellVerticalAlignment(widget, VerticalPanel.ALIGN_MIDDLE);
+ }
+
+ public Widget addFill() {
+ final Label emptyLabel = new Label("");
+ this.add(emptyLabel);
+ childPanel.setCellWidth(emptyLabel, "100%");
+ return emptyLabel;
+ }
+
+ public Widget addSeparator() {
+ final Label emptyLabel = new Label("");
+ emptyLabel.setStyleName("ytb-sep");
+ emptyLabel.addStyleName("k-toolbar-sep");
+ this.add(emptyLabel);
+ return emptyLabel;
+ }
+
+ public Widget addSpacer() {
+ final Label emptyLabel = new Label("");
+ emptyLabel.setStyleName("ytb-spacer");
+ this.add(emptyLabel);
+ return emptyLabel;
+ }
+}
\ No newline at end of file
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Toolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Toolbar.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Toolbar.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,78 @@
+package org.ourproject.kune.workspace.client.skel;
+
+import org.ourproject.kune.platf.client.ui.DefaultBorderLayout;
+
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.Widget;
+import com.gwtext.client.widgets.Panel;
+
+public class Toolbar {
+ private final Panel container;
+ private final HorizontalPanel childPanel;
+
+ public Toolbar() {
+ container = new Panel();
+ container.setBorder(false);
+ container.setBodyBorder(false);
+ container.setHeight(DefaultBorderLayout.DEF_TOOLBAR_HEIGHT);
+ container.setWidth("100%");
+ container.setHeader(false);
+ container.setBaseCls("x-toolbar");
+ container.addClass("x-panel");
+ childPanel = new HorizontalPanel();
+ container.add(childPanel);
+ }
+
+ public void add(final Widget widget) {
+ childPanel.add(widget);
+ doLayoutIfNeeded();
+ }
+
+ public Widget addFill() {
+ final Label emptyLabel = new Label("");
+ this.add(emptyLabel);
+ childPanel.setCellWidth(emptyLabel, "100%");
+ return emptyLabel;
+ }
+
+ public Widget addSeparator() {
+ final Label emptyLabel = new Label("");
+ emptyLabel.setStyleName("ytb-sep");
+ emptyLabel.addStyleName("k-toolbar-sep");
+ this.add(emptyLabel);
+ return emptyLabel;
+ }
+
+ public Widget addSpacer() {
+ final Label emptyLabel = new Label("");
+ emptyLabel.setStyleName("ytb-spacer");
+ this.add(emptyLabel);
+ return emptyLabel;
+ }
+
+ public void addStyleName(final String cls) {
+ container.addClass(cls);
+ }
+
+ public void doLayoutIfNeeded() {
+ if (container.isRendered()) {
+ container.doLayout(false);
+ }
+ }
+
+ public Panel getPanel() {
+ return container;
+ }
+
+ public void remove(final Widget widget) {
+ childPanel.remove(widget);
+ doLayoutIfNeeded();
+ }
+
+ public void removeAll() {
+ childPanel.clear();
+ doLayoutIfNeeded();
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/WorkspaceSkeleton.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/WorkspaceSkeleton.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/WorkspaceSkeleton.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,108 @@
+package org.ourproject.kune.workspace.client.skel;
+
+import org.ourproject.kune.platf.client.ui.DefaultBorderLayout;
+import org.ourproject.kune.workspace.client.themes.WsTheme;
+
+import com.calclab.suco.client.signal.Slot0;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.DeferredCommand;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.Widget;
+import com.gwtext.client.core.ExtElement;
+import com.gwtext.client.widgets.MessageBox;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.Toolbar;
+import com.gwtext.client.widgets.Viewport;
+import com.gwtext.client.widgets.layout.FitLayout;
+
+public class WorkspaceSkeleton {
+ private final Entity entity;
+ private final SiteBar sitebar;
+ private final DefaultBorderLayout mainPanel;
+ private final Panel container;
+ private final ExtElement extRootBody;
+
+ public WorkspaceSkeleton() {
+ extRootBody = new ExtElement(RootPanel.getBodyElement());
+ container = new Panel();
+ container.setLayout(new FitLayout());
+ container.setBorder(false);
+ container.setPaddings(5);
+ mainPanel = new DefaultBorderLayout();
+ sitebar = new SiteBar();
+ entity = new Entity();
+ mainPanel.add(sitebar, DefaultBorderLayout.Position.NORTH, DefaultBorderLayout.DEF_TOOLBAR_HEIGHT);
+ mainPanel.add(entity.getPanel(), DefaultBorderLayout.Position.CENTER);
+ container.add(mainPanel.getPanel());
+ new Viewport(container);
+ }
+
+ public void addToEntityMainHeader(final Widget widget) {
+ entity.addToEntityMainHeader(widget);
+ }
+
+ public void askConfirmation(final String title, final String message, final Slot0 onConfirmed, final Slot0 onCancel) {
+ MessageBox.confirm(title, message, new MessageBox.ConfirmCallback() {
+ public void execute(final String btnID) {
+ if (btnID.equals("yes")) {
+ DeferredCommand.addCommand(new Command() {
+ public void execute() {
+ onConfirmed.onEvent();
+ }
+ });
+ } else {
+ onCancel.onEvent();
+ }
+ }
+ });
+ }
+
+ public EntitySummary getEntitySummary() {
+ return entity.getEntitySummary();
+ }
+
+ public EntityWorkspace getEntityWorkspace() {
+ return entity.getEntityWorkspace();
+ }
+
+ public SiteBar getSiteBar() {
+ return sitebar;
+ }
+
+ public Toolbar getSiteTraybar() {
+ return entity.getEntitySummary().getSiteTraybar();
+ }
+
+ public void mask() {
+ extRootBody.mask();
+ }
+
+ public void mask(final String message) {
+ extRootBody.mask(message, "x-mask-loading");
+ }
+
+ public void promptMessage(final String title, final String message, final Slot0 onEnter) {
+ MessageBox.prompt(title, message, new MessageBox.PromptCallback() {
+ public void execute(final String btnID, final String text) {
+ // FIXME: use btnID
+ onEnter.onEvent();
+ }
+ });
+ }
+
+ public void setTheme(final WsTheme oldTheme, final WsTheme newTheme) {
+ entity.setTheme(oldTheme, newTheme);
+ }
+
+ public void showAlertMessage(final String title, final String message) {
+ MessageBox.alert(title, message, new MessageBox.AlertCallback() {
+ public void execute() {
+ }
+ });
+ }
+
+ public void unMask() {
+ extRootBody.unmask();
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/themes/WsTheme.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/themes/WsTheme.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/themes/WsTheme.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,48 @@
+package org.ourproject.kune.workspace.client.themes;
+
+public class WsTheme {
+ private final String name;
+
+ public WsTheme(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final WsTheme other = (WsTheme) obj;
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ return true;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (name == null ? 0 : name.hashCode());
+ return result;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/themes/WsThemePanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/themes/WsThemePanel.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/themes/WsThemePanel.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,59 @@
+package org.ourproject.kune.workspace.client.themes;
+
+import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService;
+import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
+
+import com.calclab.suco.client.signal.Slot2;
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.widgets.ToolbarButton;
+import com.gwtext.client.widgets.menu.BaseItem;
+import com.gwtext.client.widgets.menu.Menu;
+import com.gwtext.client.widgets.menu.MenuItem;
+import com.gwtext.client.widgets.menu.event.BaseItemListenerAdapter;
+
+public class WsThemePanel extends ToolbarButton implements WsThemeView {
+
+ private final Menu menu;
+ private final WsThemePresenter presenter;
+ private final I18nUITranslationService i18n;
+
+ public WsThemePanel(final WorkspaceSkeleton ws, final WsThemePresenter presenter,
+ final I18nUITranslationService i18n) {
+ this.presenter = presenter;
+ this.i18n = i18n;
+ menu = new Menu();
+
+ menu.setDefaultAlign("br-tr");
+ super.setMenu(menu);
+ super.setIcon("images/colors.gif");
+ super.setTooltip(i18n.t("Select Workspace theme for this group"));
+ ws.getSiteTraybar().addButton(this);
+ presenter.onThemeChanged(new Slot2<WsTheme, WsTheme>() {
+ public void onEvent(final WsTheme oldTheme, final WsTheme newTheme) {
+ ws.setTheme(oldTheme, newTheme);
+ }
+ });
+ }
+
+ public void setThemes(final String[] themes) {
+ for (int i = 0; i < themes.length; i++) {
+ final WsTheme theme = new WsTheme(themes[i]);
+ final MenuItem item = new MenuItem();
+ final String name = theme.getName();
+ item.setIconCls("k-wstheme-icon-" + name);
+ item.setText(i18n.t(name));
+ menu.addItem(item);
+ item.addListener(new BaseItemListenerAdapter() {
+ @Override
+ public void onClick(final BaseItem item, final EventObject e) {
+ presenter.onChangeGroupWsTheme(theme);
+ }
+ });
+ }
+ }
+
+ public void setVisible(final boolean visible) {
+ super.setVisible(visible);
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/themes/WsThemePresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/themes/WsThemePresenter.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/themes/WsThemePresenter.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,78 @@
+package org.ourproject.kune.workspace.client.themes;
+
+import org.ourproject.kune.platf.client.dto.InitDataDTO;
+import org.ourproject.kune.platf.client.dto.StateDTO;
+import org.ourproject.kune.platf.client.rpc.AsyncCallbackSimple;
+import org.ourproject.kune.platf.client.rpc.GroupServiceAsync;
+import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.platf.client.state.StateManager;
+import org.ourproject.kune.workspace.client.site.Site;
+
+import com.calclab.suco.client.provider.Provider;
+import com.calclab.suco.client.signal.Signal2;
+import com.calclab.suco.client.signal.Slot;
+import com.calclab.suco.client.signal.Slot2;
+
+public class WsThemePresenter {
+
+ private WsThemeView view;
+ private WsTheme previousTheme;
+ private final Signal2<WsTheme, WsTheme> onThemeChanged;
+ private final Provider<GroupServiceAsync> groupServiceProvider;
+ private final Session session;
+
+ public WsThemePresenter(final Session session, final Provider<GroupServiceAsync> groupServiceProvider,
+ final StateManager stateManager) {
+ this.session = session;
+ this.groupServiceProvider = groupServiceProvider;
+ this.onThemeChanged = new Signal2<WsTheme, WsTheme>("onThemeChanged");
+ session.onInitDataReceived(new Slot<InitDataDTO>() {
+ public void onEvent(final InitDataDTO initData) {
+ view.setThemes(initData.getWsThemes());
+ setTheme(new WsTheme(initData.getWsThemes()[0]));
+ }
+ });
+ stateManager.onStateChanged(new Slot<StateDTO>() {
+ public void onEvent(final StateDTO state) {
+ setState(state);
+ }
+ });
+ }
+
+ public void init(final WsThemeView view) {
+ this.view = view;
+ }
+
+ public void onThemeChanged(final Slot2<WsTheme, WsTheme> slot) {
+ onThemeChanged.add(slot);
+ }
+
+ protected void onChangeGroupWsTheme(final WsTheme newTheme) {
+ Site.showProgressProcessing();
+ groupServiceProvider.get().changeGroupWsTheme(session.getUserHash(),
+ session.getCurrentState().getGroup().getShortName(), newTheme.getName(),
+ new AsyncCallbackSimple<Object>() {
+ public void onSuccess(final Object result) {
+ setTheme(newTheme);
+ Site.hideProgress();
+ }
+ });
+ }
+
+ private void setState(final StateDTO state) {
+ setTheme(new WsTheme(state.getGroup().getWorkspaceTheme()));
+ if (state.getGroupRights().isAdministrable()) {
+ view.setVisible(true);
+ } else {
+ view.setVisible(false);
+ }
+ }
+
+ private void setTheme(final WsTheme newTheme) {
+ if (previousTheme == null || !previousTheme.equals(newTheme)) {
+ onThemeChanged.fire(previousTheme, newTheme);
+ }
+ previousTheme = newTheme;
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/themes/WsThemeView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/themes/WsThemeView.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/themes/WsThemeView.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,9 @@
+package org.ourproject.kune.workspace.client.themes;
+
+public interface WsThemeView {
+
+ void setThemes(String[] themes);
+
+ void setVisible(boolean visible);
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntitySubTitlePanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntitySubTitlePanel.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntitySubTitlePanel.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,68 @@
+/*
+ *
+ * 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.workspace.client.title;
+
+import org.ourproject.kune.platf.client.services.I18nTranslationService;
+import org.ourproject.kune.workspace.client.skel.TitleBar;
+import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
+
+import com.google.gwt.user.client.ui.Label;
+
+public class EntitySubTitlePanel implements EntitySubTitleView {
+ private final Label subTitleLeftLabel;
+ private final Label subTitleRightLabel;
+
+ public EntitySubTitlePanel(final EntitySubTitlePresenter presenter, final I18nTranslationService i18n,
+ final WorkspaceSkeleton ws) {
+ subTitleLeftLabel = new Label();
+ subTitleRightLabel = new Label();
+
+ final TitleBar wsSubTitle = ws.getEntityWorkspace().getSubTitle();
+ wsSubTitle.add(subTitleLeftLabel);
+ wsSubTitle.addFill();
+ wsSubTitle.add(subTitleRightLabel);
+
+ subTitleRightLabel.setText(i18n.t("Language:"));
+
+ subTitleLeftLabel.addStyleName("kune-Margin-Large-l");
+ subTitleLeftLabel.addStyleName("kune-ft15px");
+ subTitleRightLabel.addStyleName("kune-Margin-Large-r");
+ subTitleRightLabel.addStyleName("kune-ft12px");
+ }
+
+ public void setContentSubTitleLeft(final String subTitle) {
+ subTitleLeftLabel.setText(subTitle);
+ }
+
+ public void setContentSubTitleLeftVisible(final boolean visible) {
+ subTitleLeftLabel.setVisible(visible);
+ }
+
+ public void setContentSubTitleRight(final String subTitle) {
+ subTitleRightLabel.setText(subTitle);
+
+ }
+
+ public void setContentSubTitleRightVisible(final boolean visible) {
+ subTitleRightLabel.setVisible(visible);
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntitySubTitlePresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntitySubTitlePresenter.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntitySubTitlePresenter.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,73 @@
+/*
+ *
+ * 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.workspace.client.title;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.dto.StateDTO;
+import org.ourproject.kune.platf.client.services.I18nTranslationService;
+import org.ourproject.kune.platf.client.state.StateManager;
+
+import com.calclab.suco.client.signal.Slot;
+
+public class EntitySubTitlePresenter {
+
+ private EntitySubTitleView view;
+ private final I18nTranslationService i18n;
+
+ public EntitySubTitlePresenter(final I18nTranslationService i18n, final StateManager stateManager) {
+ this.i18n = i18n;
+ stateManager.onStateChanged(new Slot<StateDTO>() {
+ public void onEvent(final StateDTO state) {
+ setState(state);
+ }
+ });
+ }
+
+ public View getView() {
+ return view;
+ }
+
+ public void init(final EntitySubTitleView view) {
+ this.view = view;
+ }
+
+ public void setContentLanguage(final String langName) {
+ view.setContentSubTitleRight(i18n.t("Language: [%s]", langName));
+ }
+
+ private void setState(final StateDTO state) {
+ if (state.hasDocument()) {
+ view.setContentSubTitleLeft(i18n.tWithNT("by: [%s]", "used in a list of authors", state.getAuthors().get(0)
+ .getName()));
+ view.setContentSubTitleLeftVisible(true);
+ } else {
+ view.setContentSubTitleLeftVisible(false);
+ }
+ if (state.getLanguage() != null) {
+ final String langName = state.getLanguage().getEnglishName();
+ setContentLanguage(langName);
+ view.setContentSubTitleRightVisible(true);
+ } else {
+ view.setContentSubTitleRightVisible(false);
+ }
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntitySubTitleView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntitySubTitleView.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntitySubTitleView.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,34 @@
+/*
+ *
+ * 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.workspace.client.title;
+
+import org.ourproject.kune.platf.client.View;
+
+public interface EntitySubTitleView extends View {
+
+ void setContentSubTitleLeft(String subTitle);
+
+ void setContentSubTitleRight(String subTitle);
+
+ void setContentSubTitleLeftVisible(boolean visible);
+
+ void setContentSubTitleRightVisible(boolean visible);
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePanel.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePanel.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,72 @@
+/*
+ *
+ * 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.workspace.client.title;
+
+import org.ourproject.kune.platf.client.ui.EditableClickListener;
+import org.ourproject.kune.platf.client.ui.EditableIconLabel;
+import org.ourproject.kune.workspace.client.skel.TitleBar;
+import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
+
+import com.google.gwt.user.client.ui.Label;
+
+public class EntityTitlePanel implements EntityTitleView {
+ private final EditableIconLabel titleLabel;
+ private final Label dateLabel;
+
+ public EntityTitlePanel(final WorkspaceSkeleton ws, final EntityTitlePresenter presenter) {
+ titleLabel = new EditableIconLabel(new EditableClickListener() {
+ public void onEdited(final String text) {
+ presenter.onTitleRename(text);
+ }
+ });
+ dateLabel = new Label();
+
+ final TitleBar wsTitle = ws.getEntityWorkspace().getTitle();
+ wsTitle.add(titleLabel);
+ wsTitle.addFill();
+ wsTitle.add(dateLabel);
+ titleLabel.addStyleName("kune-Margin-Large-l");
+ titleLabel.addStyleName("kune-ft17px");
+ dateLabel.addStyleName("kune-Margin-Large-r");
+ dateLabel.addStyleName("kune-ft12px");
+ }
+
+ public void restoreOldTitle() {
+ titleLabel.restoreOldText();
+ }
+
+ public void setContentDate(final String date) {
+ dateLabel.setText(date);
+ }
+
+ public void setContentTitle(final String title) {
+ titleLabel.setText(title);
+ }
+
+ public void setContentTitleEditable(final boolean editable) {
+ titleLabel.setEditable(editable);
+ }
+
+ public void setDateVisible(final boolean visible) {
+ dateLabel.setVisible(visible);
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePresenter.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePresenter.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,121 @@
+/*
+ *
+ * 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.workspace.client.title;
+
+import java.util.Date;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.dto.StateDTO;
+import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
+import org.ourproject.kune.platf.client.services.I18nTranslationService;
+import org.ourproject.kune.platf.client.services.KuneErrorHandler;
+import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.platf.client.state.StateManager;
+import org.ourproject.kune.workspace.client.site.Site;
+
+import com.calclab.suco.client.provider.Provider;
+import com.calclab.suco.client.signal.Slot;
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+public class EntityTitlePresenter {
+
+ private EntityTitleView view;
+ private final I18nTranslationService i18n;
+ private final KuneErrorHandler errorHandler;
+ private final StateManager stateManager;
+ private final Provider<ContentServiceAsync> contentServiceProvider;
+ private final Session session;
+
+ public EntityTitlePresenter(final I18nTranslationService i18n, final KuneErrorHandler errorHandler,
+ final StateManager stateManager, final Session session,
+ final Provider<ContentServiceAsync> contentServiceProvider) {
+ this.i18n = i18n;
+ this.errorHandler = errorHandler;
+ this.stateManager = stateManager;
+ this.session = session;
+ this.contentServiceProvider = contentServiceProvider;
+ stateManager.onStateChanged(new Slot<StateDTO>() {
+ public void onEvent(final StateDTO state) {
+ setState(state);
+ }
+ });
+ }
+
+ public View getView() {
+ return view;
+ }
+
+ public void init(final EntityTitleView view) {
+ this.view = view;
+ }
+
+ public void onTitleRename(final String newName) {
+ Site.showProgressSaving();
+ final StateDTO currentState = session.getCurrentState();
+ contentServiceProvider.get().rename(session.getUserHash(), currentState.getGroup().getShortName(),
+ currentState.getStateToken().getEncoded(), newName, new AsyncCallback<String>() {
+ public void onFailure(final Throwable caught) {
+ view.restoreOldTitle();
+ errorHandler.process(caught);
+ }
+
+ public void onSuccess(final String result) {
+ Site.hideProgress();
+ view.setContentTitle(result);
+ stateManager.reloadContextAndTitles();
+ }
+ });
+ Site.hideProgress();
+ }
+
+ public void setContentDate(final Date publishedOn) {
+ final DateTimeFormat fmt = DateTimeFormat.getFormat("MM/dd/yyyy, Z");
+ view.setContentDate(i18n.t("Published on: [%s]", fmt.format(publishedOn)));
+ }
+
+ private void setContentDateVisible(final boolean visible) {
+ view.setDateVisible(visible);
+ }
+
+ private void setContentTitle(final String title, final boolean editable) {
+ view.setContentTitle(title);
+ view.setContentTitleEditable(editable);
+ }
+
+ private void setState(final StateDTO state) {
+ if (state.hasDocument()) {
+ setContentTitle(state.getTitle(), state.getContentRights().isEditable());
+ setContentDateVisible(true);
+ setContentDate(state.getPublishedOn());
+ } else {
+ if (state.getFolder().getParentFolderId() == null) {
+ // We translate root folder names (documents, chat room,
+ // etcetera)
+ setContentTitle(i18n.t(state.getTitle()), false);
+ } else {
+ setContentTitle(state.getTitle(), state.getContentRights().isEditable());
+ }
+ setContentDateVisible(false);
+ }
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitleView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitleView.java 2008-09-08 01:05:36 UTC (rev 860)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitleView.java 2008-09-08 01:13:19 UTC (rev 861)
@@ -0,0 +1,37 @@
+/*
+ *
+ * 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.workspace.client.title;
+
+import org.ourproject.kune.platf.client.View;
+
+public interface EntityTitleView extends View {
+
+ void restoreOldTitle();
+
+ void setContentDate(String date);
+
+ void setContentTitle(String title);
+
+ void setContentTitleEditable(boolean editable);
+
+ void setDateVisible(boolean visible);
+
+}
More information about the kune-commits
mailing list