[kune-commits] r1513 - in trunk: script src/main/java/cc/kune/core/client/resources src/main/java/cc/kune/core/client/rpcservices src/main/java/cc/kune/core/server/manager src/main/java/cc/kune/core/server/manager/impl src/main/java/cc/kune/core/server/rpc src/main/java/cc/kune/gspace/client src/main/java/cc/kune/gspace/client/i18n
Vicente J. Ruiz Jurado
vjrj_ at ourproject.org
Wed Sep 7 23:37:24 CEST 2011
Author: vjrj_
Date: 2011-09-07 23:37:23 +0200 (Wed, 07 Sep 2011)
New Revision: 1513
Added:
trunk/script/findMsg.sh
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslationDataProvider.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorTabsCollection.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTraslatorSaver.java
Removed:
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslationProvider.java
trunk/src/main/java/cc/kune/gspace/client/i18n/TranslatorTabsCollection.java
Modified:
trunk/src/main/java/cc/kune/core/client/resources/CoreMessages.java
trunk/src/main/java/cc/kune/core/client/rpcservices/I18nService.java
trunk/src/main/java/cc/kune/core/client/rpcservices/I18nServiceAsync.java
trunk/src/main/java/cc/kune/core/server/manager/I18nTranslationManager.java
trunk/src/main/java/cc/kune/core/server/manager/impl/I18nTranslationManagerDefault.java
trunk/src/main/java/cc/kune/core/server/rpc/I18nRPC.java
trunk/src/main/java/cc/kune/gspace/client/GSpaceGinModule.java
trunk/src/main/java/cc/kune/gspace/client/GSpaceParts.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nToTranslateGridPanel.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPanel.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPresenter.java
Log:
NEW - # 79: I18n refactorization
http://kune.ourproject.org/issues/ticket/79
Added: trunk/script/findMsg.sh
===================================================================
--- trunk/script/findMsg.sh (rev 0)
+++ trunk/script/findMsg.sh 2011-09-07 21:37:23 UTC (rev 1513)
@@ -0,0 +1,3 @@
+#!/bin/bash
+STR=`echo $1 | sed 's/ /\\[\\\"\\\+\\\n \\]\*/g'`
+echo egrep -r -m 1 "\"$STR\"" src/main/java/cc
\ No newline at end of file
Property changes on: trunk/script/findMsg.sh
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/src/main/java/cc/kune/core/client/resources/CoreMessages.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/resources/CoreMessages.java 2011-09-07 13:44:13 UTC (rev 1512)
+++ trunk/src/main/java/cc/kune/core/client/resources/CoreMessages.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -32,8 +32,8 @@
public final static String INCORRECT_NICKNAME_EMAIL_OR_PASSWORD = "The username/password is incorrect";
public final static String MEMBERS_NOT_PUBLIC = "The members of this group are not public";
public final static String NAME_IN_ALREADY_IN_USE = "This name is already in use. Please try with a different name";
+ public final static String NAME_IN_USE = "This name in already in use. Please try with a different name";
public final static String NAME_RESTRICTED = "This user name can not be used. Please try with a different name";
- public final static String NAME_IN_USE = "This name in already in use. Please try with a different name";
public final static String PASSWD_MUST_BE_BETWEEN_6_AND_40 = "The password must be between 6 and 40 characters";
public final static String REGISTER_A_NEW_GROUP_TITLE = "Register a new Group";
public final static String REGISTER_TITLE = "Register";
@@ -41,7 +41,7 @@
public final static String SIGN_IN_TITLE = "Sign in";
public final static String USER_DOESN_T_HAVE_A_HOMEPAGE = "This user does not have a homepage";
public final static String USER_OPTIONS_DIALOG_TITLE = "User options";
- public final static String YOUR_HOMEPAGE = "Your homepage";
+ public final static String YOUR_HOMEPAGE = "Your " + "homepage";
private CoreMessages() {
}
Modified: trunk/src/main/java/cc/kune/core/client/rpcservices/I18nService.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/rpcservices/I18nService.java 2011-09-07 13:44:13 UTC (rev 1512)
+++ trunk/src/main/java/cc/kune/core/client/rpcservices/I18nService.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -41,6 +41,6 @@
String getTranslation(String userHash, String language, String text);
- String setTranslation(String userHash, String id, String translation) throws DefaultException;
+ String setTranslation(String userHash, Long id, String translation) throws DefaultException;
}
Modified: trunk/src/main/java/cc/kune/core/client/rpcservices/I18nServiceAsync.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/rpcservices/I18nServiceAsync.java 2011-09-07 13:44:13 UTC (rev 1512)
+++ trunk/src/main/java/cc/kune/core/client/rpcservices/I18nServiceAsync.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -38,6 +38,6 @@
void getTranslation(String userHash, String language, String text, AsyncCallback<String> callback);
- void setTranslation(String userHash, String id, String translation, AsyncCallback<String> asyncCallback);
+ void setTranslation(String userHash, Long id, String translation, AsyncCallback<String> asyncCallback);
}
Modified: trunk/src/main/java/cc/kune/core/server/manager/I18nTranslationManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/I18nTranslationManager.java 2011-09-07 13:44:13 UTC (rev 1512)
+++ trunk/src/main/java/cc/kune/core/server/manager/I18nTranslationManager.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -46,7 +46,7 @@
SearchResult<I18nTranslation> getUntranslatedLexicon(String language, Integer firstResult,
Integer maxResults);
- String setTranslation(String id, String translation) throws DefaultException;
+ String setTranslation(Long id, String translation) throws DefaultException;
void setTranslation(String language, String text, String translation);
Modified: trunk/src/main/java/cc/kune/core/server/manager/impl/I18nTranslationManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/impl/I18nTranslationManagerDefault.java 2011-09-07 13:44:13 UTC (rev 1512)
+++ trunk/src/main/java/cc/kune/core/server/manager/impl/I18nTranslationManagerDefault.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -162,8 +162,8 @@
}
@Override
- public String setTranslation(final String id, final String translation) throws DefaultException {
- final I18nTranslation trans = super.find(Long.valueOf(id));
+ public String setTranslation(final Long id, final String translation) throws DefaultException {
+ final I18nTranslation trans = super.find(id);
if (trans != null) {
final String escapedTranslation = TextUtils.escapeHtmlLight(translation);
trans.setText(escapedTranslation);
Modified: trunk/src/main/java/cc/kune/core/server/rpc/I18nRPC.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/rpc/I18nRPC.java 2011-09-07 13:44:13 UTC (rev 1512)
+++ trunk/src/main/java/cc/kune/core/server/rpc/I18nRPC.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -139,7 +139,7 @@
@Override
@Authenticated
@Transactional
- public String setTranslation(final String userHash, final String id, final String translation)
+ public String setTranslation(final String userHash, final Long id, final String translation)
throws DefaultException {
return i18nTranslationManager.setTranslation(id, translation);
}
Modified: trunk/src/main/java/cc/kune/gspace/client/GSpaceGinModule.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/GSpaceGinModule.java 2011-09-07 13:44:13 UTC (rev 1512)
+++ trunk/src/main/java/cc/kune/gspace/client/GSpaceGinModule.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -29,7 +29,7 @@
import cc.kune.gspace.client.i18n.I18nTranslatorPresenter;
import cc.kune.gspace.client.i18n.I18nTranslatorPresenter.I18nTranslatorView;
import cc.kune.gspace.client.i18n.SiteOptionsI18nTranslatorAction;
-import cc.kune.gspace.client.i18n.TranslatorTabsCollection;
+import cc.kune.gspace.client.i18n.I18nTranslatorTabsCollection;
import cc.kune.gspace.client.licensewizard.LicenseChangeAction;
import cc.kune.gspace.client.licensewizard.LicenseWizard;
import cc.kune.gspace.client.licensewizard.LicenseWizardPanel;
@@ -153,7 +153,7 @@
s(UserOptionsCollection.class);
s(GroupOptionsCollection.class);
- s(TranslatorTabsCollection.class);
+ s(I18nTranslatorTabsCollection.class);
s(GroupOptGeneral.class, GroupOptGeneralPresenter.class);
s(GroupOptGeneralView.class, GroupOptGeneralPanel.class);
Modified: trunk/src/main/java/cc/kune/gspace/client/GSpaceParts.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/GSpaceParts.java 2011-09-07 13:44:13 UTC (rev 1512)
+++ trunk/src/main/java/cc/kune/gspace/client/GSpaceParts.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -25,7 +25,7 @@
import cc.kune.core.client.state.Session;
import cc.kune.gspace.client.i18n.I18nToTranslateGridPanel;
import cc.kune.gspace.client.i18n.SiteOptionsI18nTranslatorAction;
-import cc.kune.gspace.client.i18n.TranslatorTabsCollection;
+import cc.kune.gspace.client.i18n.I18nTranslatorTabsCollection;
import cc.kune.gspace.client.options.GroupOptions;
import cc.kune.gspace.client.options.GroupOptionsCollection;
import cc.kune.gspace.client.options.UserOptions;
@@ -68,7 +68,7 @@
final Provider<UserOptTools> utc, final Provider<SitebarSearchPresenter> siteSearch,
final Provider<SiteOptionsI18nTranslatorAction> transAction,
final Provider<I18nToTranslateGridPanel> toTrans,
- final Provider<TranslatorTabsCollection> gtranslator) {
+ final Provider<I18nTranslatorTabsCollection> gtranslator) {
session.onAppStart(true, new AppStartHandler() {
@Override
Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.java 2011-09-07 13:44:13 UTC (rev 1512)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -18,13 +18,15 @@
package cc.kune.gspace.client.i18n;
import cc.kune.common.client.utils.SimpleCallback;
+import cc.kune.core.client.i18n.I18nUITranslationService;
import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
import cc.kune.core.shared.dto.I18nTranslationDTO;
-import cc.kune.core.shared.i18n.I18nTranslationService;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.cell.client.ValueUpdater;
import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
@@ -101,7 +103,7 @@
*/
private final CellList<I18nTranslationDTO> cellList;
- private final I18nTranslationProvider data;
+ private final I18nTranslationDataProvider data;
/**
* The pager used to change the range of data.
@@ -122,8 +124,10 @@
I18nTranslatorForm translatorForm;
@Inject
- public I18nCellList(final I18nTranslationProvider data, final I18nTranslationService i18n) {
+ public I18nCellList(final I18nTranslationDataProvider data, final I18nUITranslationService i18n,
+ final I18nTraslatorSaver saver) {
this.data = data;
+
final TranslationCell cell = new TranslationCell();
// Set a key provider that provides a unique key for each contact. If key is
@@ -138,26 +142,31 @@
// Add a selection model so we can select cells.
cellList.setSelectionModel(selectionModel);
+
+ // Create the UiBinder.
+ final Binder uiBinder = GWT.create(Binder.class);
+ initWidget(uiBinder.createAndBindUi(this));
+ translatorForm.init(data, i18n, saver);
cellList.setValueUpdater(new ValueUpdater<I18nTranslationDTO>() {
+
@Override
public void update(final I18nTranslationDTO value) {
- // TODO Auto-generated method stub
+ // save(value);
}
});
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
@Override
public void onSelectionChange(final SelectionChangeEvent event) {
translatorForm.setInfo(selectionModel.getSelectedObject());
- translatorForm.focusToTranslate();
- // cellList.get
- // pagerPanel.ensureVisible((UIObject) event.getSource());
+ Scheduler.get().scheduleEntry(new ScheduledCommand() {
+ @Override
+ public void execute() {
+ translatorForm.focusToTranslate();
+ }
+ });
}
});
- cellList.sinkEvents(com.google.gwt.user.client.Event.KEYEVENTS);
- // Create the UiBinder.
- final Binder uiBinder = GWT.create(Binder.class);
- initWidget(uiBinder.createAndBindUi(this));
- translatorForm.init(data, i18n);
+ // cellList.sinkEvents(com.google.gwt.user.client.Event.KEYEVENTS);
data.addDataDisplay(cellList);
data.setSelectionMode(selectionModel);
data.setLoadCallback(new SimpleCallback() {
@@ -180,4 +189,5 @@
data.setLanguage(language, toTranslate);
translatorForm.setToLanguage(language);
}
+
}
Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nToTranslateGridPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nToTranslateGridPanel.java 2011-09-07 13:44:13 UTC (rev 1512)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nToTranslateGridPanel.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -27,4 +27,5 @@
public void setLanguage(final I18nLanguageSimpleDTO language) {
list.setLanguage(language, true);
}
+
}
Copied: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslationDataProvider.java (from rev 1511, trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslationProvider.java)
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslationDataProvider.java (rev 0)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslationDataProvider.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package cc.kune.gspace.client.i18n;
+
+import java.util.List;
+
+import cc.kune.common.client.utils.SimpleCallback;
+import cc.kune.core.client.rpcservices.AsyncCallbackSimple;
+import cc.kune.core.client.rpcservices.I18nServiceAsync;
+import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
+import cc.kune.core.shared.dto.I18nTranslationDTO;
+
+import com.google.gwt.user.cellview.client.CellList;
+import com.google.gwt.view.client.ListDataProvider;
+import com.google.gwt.view.client.SingleSelectionModel;
+import com.google.inject.Inject;
+
+public class I18nTranslationDataProvider {
+
+ private final ListDataProvider<I18nTranslationDTO> dataProvider = new ListDataProvider<I18nTranslationDTO>();
+ private final I18nServiceAsync i18n;
+ private SimpleCallback loadCallback;
+ private SingleSelectionModel<I18nTranslationDTO> selectionModel;
+ private final Session session;
+
+ @Inject
+ private I18nTranslationDataProvider(final Session session, final I18nServiceAsync i18n) {
+ this.session = session;
+ this.i18n = i18n;
+ }
+
+ public void addDataDisplay(final CellList<I18nTranslationDTO> displayList) {
+ dataProvider.addDataDisplay(displayList);
+ }
+
+ private void avance(final int increment) {
+ final I18nTranslationDTO selected = selectionModel.getSelectedObject();
+ final List<I18nTranslationDTO> list = dataProvider.getList();
+ final int pos = list.indexOf(selected);
+ final int next = pos + increment;
+ if (next >= 0 && next < list.size()) {
+ selectionModel.setSelected(list.get(next), true);
+ }
+ }
+
+ public void refreshDisplays() {
+ dataProvider.refresh();
+ }
+
+ public void selectNext() {
+ avance(1);
+ }
+
+ public void selectPrevious() {
+ avance(-1);
+ }
+
+ public void setLanguage(final I18nLanguageSimpleDTO language, final boolean toTranslate) {
+ dataProvider.getList().clear();
+ dataProvider.refresh();
+ i18n.getTranslatedLexicon(session.getUserHash(), language.getCode(), toTranslate,
+ new AsyncCallbackSimple<List<I18nTranslationDTO>>() {
+ @Override
+ public void onSuccess(final List<I18nTranslationDTO> result) {
+ dataProvider.setList(result);
+ dataProvider.refresh();
+ if (result.size() > 0) {
+ selectionModel.setSelected(result.get(0), true);
+ }
+ loadCallback.onCallback();
+ }
+ });
+ }
+
+ public void setLoadCallback(final SimpleCallback loadCallback) {
+ this.loadCallback = loadCallback;
+ }
+
+ public void setSelectionMode(final SingleSelectionModel<I18nTranslationDTO> selectionModel) {
+ this.selectionModel = selectionModel;
+ }
+
+}
Deleted: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslationProvider.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslationProvider.java 2011-09-07 13:44:13 UTC (rev 1512)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslationProvider.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -1,97 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package cc.kune.gspace.client.i18n;
-
-import java.util.List;
-
-import cc.kune.common.client.utils.SimpleCallback;
-import cc.kune.core.client.rpcservices.AsyncCallbackSimple;
-import cc.kune.core.client.rpcservices.I18nServiceAsync;
-import cc.kune.core.client.state.Session;
-import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
-import cc.kune.core.shared.dto.I18nTranslationDTO;
-
-import com.google.gwt.user.cellview.client.CellList;
-import com.google.gwt.view.client.ListDataProvider;
-import com.google.gwt.view.client.SingleSelectionModel;
-import com.google.inject.Inject;
-
-public class I18nTranslationProvider {
-
- private final ListDataProvider<I18nTranslationDTO> dataProvider = new ListDataProvider<I18nTranslationDTO>();
- private final I18nServiceAsync i18n;
- private SimpleCallback loadCallback;
- private SingleSelectionModel<I18nTranslationDTO> selectionModel;
- private final Session session;
-
- @Inject
- private I18nTranslationProvider(final Session session, final I18nServiceAsync i18n) {
- this.session = session;
- this.i18n = i18n;
- }
-
- public void addDataDisplay(final CellList<I18nTranslationDTO> displayList) {
- dataProvider.addDataDisplay(displayList);
- }
-
- private void avance(final int increment) {
- final I18nTranslationDTO selected = selectionModel.getSelectedObject();
- final List<I18nTranslationDTO> list = dataProvider.getList();
- final int pos = list.indexOf(selected);
- final int next = pos + increment;
- if (next >= 0 && next < list.size()) {
- selectionModel.setSelected(list.get(next), true);
- }
- }
-
- public void refreshDisplays() {
- dataProvider.refresh();
- }
-
- public void selectNext() {
- avance(1);
- }
-
- public void selectPrevious() {
- avance(-1);
- }
-
- public void setLanguage(final I18nLanguageSimpleDTO language, final boolean toTranslate) {
- dataProvider.getList().clear();
- dataProvider.refresh();
- i18n.getTranslatedLexicon(session.getUserHash(), language.getCode(), toTranslate,
- new AsyncCallbackSimple<List<I18nTranslationDTO>>() {
- @Override
- public void onSuccess(final List<I18nTranslationDTO> result) {
- dataProvider.setList(result);
- dataProvider.refresh();
- if (result.size() > 0) {
- selectionModel.setSelected(result.get(0), true);
- }
- loadCallback.onCallback();
- }
- });
- }
-
- public void setLoadCallback(final SimpleCallback loadCallback) {
- this.loadCallback = loadCallback;
- }
-
- public void setSelectionMode(final SingleSelectionModel<I18nTranslationDTO> selectionModel) {
- this.selectionModel = selectionModel;
- }
-
-}
Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java 2011-09-07 13:44:13 UTC (rev 1512)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -46,7 +46,7 @@
private static Binder uiBinder = GWT.create(Binder.class);
@UiField
PushButton copyIcon;
- private I18nTranslationProvider dataProvider;
+ private I18nTranslationDataProvider dataProvider;
private I18nTranslationService i18n;
private I18nTranslationDTO item;
@UiField
@@ -58,14 +58,13 @@
Label noteForTranslators;
@UiField
Label noteForTranslatorsTittle;
+ private I18nTraslatorSaver saver;
@UiField
Label toLanguageTitle;
@UiField
Label toTranslate;
-
@UiField
Label toTranslateTitle;
-
@UiField
TextArea translation;
@@ -108,11 +107,11 @@
void handleKeyPress(final KeyPressEvent event) {
if (event.isAltKeyDown()
&& event.getNativeEvent().getKeyCode() == com.google.gwt.event.dom.client.KeyCodes.KEY_PAGEUP) {
- // cellList.fireEvent(event);
+ saveIfNeeded();
dataProvider.selectPrevious();
} else if (event.isAltKeyDown()
&& event.getNativeEvent().getKeyCode() == com.google.gwt.event.dom.client.KeyCodes.KEY_PAGEDOWN) {
- // cellList.fireEvent(event);
+ saveIfNeeded();
dataProvider.selectNext();
} else if (event.isAltKeyDown() && event.getCharCode() == 'v') {
copyTranslation();
@@ -121,9 +120,11 @@
}
}
- public void init(final I18nTranslationProvider dataProvider, final I18nTranslationService i18n) {
+ public void init(final I18nTranslationDataProvider dataProvider, final I18nTranslationService i18n,
+ final I18nTraslatorSaver saver) {
this.dataProvider = dataProvider;
this.i18n = i18n;
+ this.saver = saver;
Tooltip.to(copyIcon, i18n.t("Copy the text to translate"));
toTranslateTitle.setText(i18n.t("translate this:"));
noteForTranslatorsTittle.setText(i18n.t("Notes:"));
@@ -131,7 +132,16 @@
keyboardRecomendation.setText(i18n.t("Pulse Alt+PageUp or Alt+PageDown to move up/down in the list while translating, and Alt-V to copy the original text. The translations are autosaved"));
}
+ private void saveIfNeeded() {
+ keyboardTimer.cancel();
+ final String newTranslation = translation.getText();
+ if (item != null && !item.getText().equals(newTranslation)) {
+ saver.save(new I18nTranslationDTO(item.getId(), item.getTrKey(), newTranslation));
+ }
+ }
+
public void setInfo(final I18nTranslationDTO item) {
+ saveIfNeeded();
this.item = item;
final String[] splitted = splitNT(item.getTrKey());
toTranslate.setText(splitted[0]);
@@ -160,10 +170,12 @@
}
private void update() {
+ keyboardTimer.cancel();
if (item != null) {
item.setText(translation.getText());
item.setDirty(true);
dataProvider.refreshDisplays();
+ saveIfNeeded();
}
}
Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPanel.java 2011-09-07 13:44:13 UTC (rev 1512)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPanel.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -24,7 +24,7 @@
@Inject
public I18nTranslatorPanel(final I18nTranslationService i18n, final NotifyLevelImages images,
- final TranslatorTabsCollection transGroup, final LanguageSelectorPanel lanSelectorPanel,
+ final I18nTranslatorTabsCollection transGroup, final LanguageSelectorPanel lanSelectorPanel,
final I18nToTranslateGridPanel toTranslateGrid, final I18nTranslatedGridPanel translatedGrid,
final I18nTranslateRecomendPanel transRecommend, final CoreResources res) {
super(TRANSLATOR_PANEL_ID, "", false, false, images, TRANSLATOR_ERROR_ID, i18n.t("Close"), null,
Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPresenter.java 2011-09-07 13:44:13 UTC (rev 1512)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPresenter.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -3,18 +3,14 @@
import cc.kune.common.client.notify.NotifyUser;
import cc.kune.common.client.ui.dialogs.tabbed.AbstractTabbedDialog;
import cc.kune.common.client.ui.dialogs.tabbed.AbstractTabbedDialogPresenter;
-import cc.kune.common.client.ui.dialogs.tabbed.AbstractTabbedDialogPresenter.AbstractTabbedDialogView;
import cc.kune.core.client.i18n.I18nUITranslationService;
-import cc.kune.core.client.rpcservices.I18nServiceAsync;
import cc.kune.core.client.state.Session;
import cc.kune.core.shared.dto.I18nLanguageDTO;
import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
import cc.kune.gspace.client.i18n.I18nTranslatorPresenter.I18nTranslatorView;
import com.google.gwt.event.shared.EventBus;
-import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.inject.Inject;
-import com.google.inject.Provider;
import com.gwtplatform.mvp.client.annotations.ProxyCodeSplit;
import com.gwtplatform.mvp.client.proxy.Proxy;
@@ -26,53 +22,30 @@
public interface I18nTranslatorProxy extends Proxy<I18nTranslatorPresenter> {
}
- public interface I18nTranslatorView extends AbstractTabbedDialogView {
- void hide();
+ public interface I18nTranslatorView extends
+ cc.kune.common.client.ui.dialogs.tabbed.AbstractTabbedDialogPresenter.AbstractTabbedDialogView {
void init();
void setLanguage(I18nLanguageSimpleDTO currentLanguage);
- void show();
-
}
private final I18nUITranslationService i18n;
- private final Provider<I18nServiceAsync> i18nService;
private final Session session;
@Inject
public I18nTranslatorPresenter(final EventBus eventBus, final I18nTranslatorProxy proxy,
- final Session session, final I18nUITranslationService i18n, final I18nTranslatorView view,
- final Provider<I18nServiceAsync> i18nService) {
+ final Session session, final I18nUITranslationService i18n, final I18nTranslatorView view) {
super(eventBus, view, proxy);
this.session = session;
this.i18n = i18n;
- this.i18nService = i18nService;
}
public void doClose() {
getView().hide();
}
- public void doTranslation(final String id, final String trKey, final String translation) {
- NotifyUser.showProgress(i18n.t("Saving"));
- i18nService.get().setTranslation(session.getUserHash(), id, translation,
- new AsyncCallback<String>() {
- @Override
- public void onFailure(final Throwable caught) {
- NotifyUser.hideProgress();
- NotifyUser.error(i18n.t("Server error saving the translation"));
- }
-
- @Override
- public void onSuccess(final String result) {
- NotifyUser.hideProgress();
- i18n.setTranslationAfterSave(trKey, result);
- }
- });
- }
-
@Override
public I18nTranslatorView getView() {
return (I18nTranslatorView) super.getView();
Copied: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorTabsCollection.java (from rev 1511, trunk/src/main/java/cc/kune/gspace/client/i18n/TranslatorTabsCollection.java)
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorTabsCollection.java (rev 0)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorTabsCollection.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -0,0 +1,29 @@
+/*
+ *
+ * Copyright (C) 2007-2011 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 cc.kune.gspace.client.i18n;
+
+import cc.kune.common.client.ProvidersCollection;
+
+import com.google.inject.Singleton;
+
+ at SuppressWarnings("serial")
+ at Singleton
+public class I18nTranslatorTabsCollection extends ProvidersCollection {
+}
Added: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTraslatorSaver.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTraslatorSaver.java (rev 0)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTraslatorSaver.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -0,0 +1,46 @@
+package cc.kune.gspace.client.i18n;
+
+import cc.kune.common.client.notify.NotifyUser;
+import cc.kune.core.client.i18n.I18nUITranslationService;
+import cc.kune.core.client.rpcservices.I18nServiceAsync;
+import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.dto.I18nTranslationDTO;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+
+ at Singleton
+public class I18nTraslatorSaver {
+ private final I18nUITranslationService i18n;
+ private final Provider<I18nServiceAsync> i18nService;
+ private final Session session;
+
+ @Inject
+ public I18nTraslatorSaver(final Session session, final Provider<I18nServiceAsync> i18nService,
+ final I18nUITranslationService i18n) {
+ this.session = session;
+ this.i18nService = i18nService;
+ this.i18n = i18n;
+ }
+
+ public void save(final I18nTranslationDTO item) {
+ NotifyUser.showProgress(i18n.t("Saving"));
+ i18nService.get().setTranslation(session.getUserHash(), item.getId(), item.getText(),
+ new AsyncCallback<String>() {
+ @Override
+ public void onFailure(final Throwable caught) {
+ NotifyUser.hideProgress();
+ NotifyUser.error(i18n.t("Server error saving the translation"));
+ }
+
+ @Override
+ public void onSuccess(final String result) {
+ NotifyUser.hideProgress();
+ i18n.setTranslationAfterSave(item.getTrKey(), result);
+ }
+ });
+ }
+
+}
Deleted: trunk/src/main/java/cc/kune/gspace/client/i18n/TranslatorTabsCollection.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/TranslatorTabsCollection.java 2011-09-07 13:44:13 UTC (rev 1512)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/TranslatorTabsCollection.java 2011-09-07 21:37:23 UTC (rev 1513)
@@ -1,29 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2011 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 cc.kune.gspace.client.i18n;
-
-import cc.kune.common.client.ProvidersCollection;
-
-import com.google.inject.Singleton;
-
- at SuppressWarnings("serial")
- at Singleton
-public class TranslatorTabsCollection extends ProvidersCollection {
-}
More information about the kune-commits
mailing list