Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Plural support - fire validation event for selected trans unit
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Apr 10, 2012
1 parent 9b811c1 commit 6013935
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 31 deletions.
Expand Up @@ -30,8 +30,6 @@ public interface TargetContentsDisplay extends WidgetDisplay

void showButtons(boolean displayButtons);

void openEditors();

void focusEditor(int currentEditorIndex);

interface Listener
Expand Down
Expand Up @@ -122,7 +122,12 @@ public void showEditors(int rowIndex, int editorIndex)
Log.info("enter show editor with editor index:" + editorIndex + " current editor index:" + currentEditorIndex);
currentDisplay = displayList.get(rowIndex);
currentEditors = currentDisplay.getEditors();
currentDisplay.openEditors();

for (ToggleEditor editor : currentDisplay.getEditors())
{
editor.setViewMode(ToggleEditor.ViewMode.EDIT);
validate(editor);
}

if (configHolder.isDisplayButtons())
{
Expand Down Expand Up @@ -180,9 +185,10 @@ public void initWidgets(int pageSize)
@Override
public void validate(ToggleEditor editor)
{
currentEditorIndex = editor.getIndex();
// currentEditorIndex = editor.getIndex();
RunValidationEvent event = new RunValidationEvent(sourceContentsPresenter.getSelectedSource(), editor.getText(), false);
event.addWidget(validationMessagePanel);
event.addWidget(editor);
eventBus.fireEvent(event);
}

Expand Down
Expand Up @@ -88,15 +88,6 @@ public void showButtons(boolean displayButtons)
buttons.setVisible(isEditing() && displayButtons);
}

@Override
public void openEditors()
{
for (ToggleEditor editor : editors)
{
editor.setViewMode(ToggleEditor.ViewMode.EDIT);
}
}

@Override
public void focusEditor(final int currentEditorIndex)
{
Expand Down Expand Up @@ -175,6 +166,7 @@ public void setToView()
{
for (ToggleEditor editor : editors)
{
editor.removeValidationMessagePanel();
editor.setViewMode(ToggleEditor.ViewMode.VIEW);
}
}
Expand Down
Expand Up @@ -7,6 +7,7 @@
import org.zanata.webtrans.client.editor.table.TargetContentsDisplay;
import org.zanata.webtrans.client.resources.NavigationMessages;

import com.allen_sauer.gwt.log.client.Log;
import com.google.common.base.Objects;
import com.google.common.base.Strings;
import com.google.gwt.core.client.GWT;
Expand All @@ -27,7 +28,7 @@
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.Widget;

public class Editor extends Composite implements ToggleEditor, HasUpdateValidationWarning
public class Editor extends Composite implements ToggleEditor
{
private String findMessage;
private TargetContentsDisplay.Listener listener;
Expand Down Expand Up @@ -309,10 +310,16 @@ public void setFocus()
@Override
public void addValidationMessagePanel(IsWidget validationMessagePanel)
{
validationMessagePanelContainer.clear();
removeValidationMessagePanel();
validationMessagePanelContainer.add(validationMessagePanel);
}

@Override
public void removeValidationMessagePanel()
{
validationMessagePanelContainer.clear();
}

@Override
public void insertTextInCursorPosition(String suggestion)
{
Expand Down Expand Up @@ -343,6 +350,13 @@ public void showCopySourceButton(boolean displayButtons)
@Override
public void updateValidationWarning(List<String> errors)
{
// TODO update label css is errors is empty
if (!errors.isEmpty())
{
textArea.addStyleName("HasValidationError");
}
else
{
textArea.removeStyleName("HasValidationError");
}
}
}
Expand Up @@ -18,7 +18,7 @@

.textArea {
width:98%;
margin-left:5px;
margin-left:3px;
}
</ui:style>

Expand Down
Expand Up @@ -3,7 +3,7 @@
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.IsWidget;

public interface ToggleEditor extends IsWidget, HasText
public interface ToggleEditor extends IsWidget, HasText, HasUpdateValidationWarning
{

ViewMode getViewMode();
Expand All @@ -18,6 +18,8 @@ public interface ToggleEditor extends IsWidget, HasText

void addValidationMessagePanel(IsWidget validationMessagePanel);

void removeValidationMessagePanel();

int getIndex();

void showCopySourceButton(boolean displayButtons);
Expand All @@ -35,5 +37,4 @@ static enum ViewMode
}

void setTextAndValidate(String text);

}
Expand Up @@ -53,7 +53,7 @@
<g:Label ui:field="headerLabel" />
</g:cell>
<g:cell horizontalAlignment="ALIGN_RIGHT" width="95px" verticalAlignment="ALIGN_MIDDLE">
<g:Anchor ui:field="runValidationAnchor" styleName="{style.clickable}" />
<g:Anchor ui:field="runValidationAnchor" styleName="{style.clickable}"/>
</g:cell>
<g:cell horizontalAlignment="ALIGN_RIGHT" width="16px" verticalAlignment="ALIGN_MIDDLE">
<g:PushButton ui:field="validateButton" styleName="gwt-Button" title="{messages.runValidation}">
Expand Down
Expand Up @@ -405,11 +405,6 @@ tr.FuzzyStateDecoration td.TableEditorCell-Target .TableEditorContent {
padding-right: 5px;
}

tr.FuzzyStateDecoration td.TableEditorCell-Target table.TableEditorCell-Target-Table {
/* border-left: 3px solid #ffc000; */
/* border-right: 3px solid #ffc000; */
}

tr.FuzzyStateDecoration td.TableEditorCell-Target div.TableEditorCell-Target {
border-left: 3px solid #ffc000;
border-right: 3px solid #ffc000;
Expand All @@ -420,12 +415,6 @@ tr.ApprovedStateDecoration td.TableEditorCell-Target .TableEditorContent {
padding-right: 5px;
}

tr.ApprovedStateDecoration td.TableEditorCell-Target table.TableEditorCell-Target-Table
{
/* border-left: 3px solid #099b09; */
/* border-right: 3px solid #099b09; */
}

tr.ApprovedStateDecoration td.TableEditorCell-Target div.TableEditorCell-Target
{
border-left: 3px solid #099b09;
Expand All @@ -442,6 +431,11 @@ tr.ApprovedStateDecoration td.TableEditorCell-Target div.TableEditorCell-Target
width: 99%;
}

.HasValidationError {
border-left:3px solid red;
border-right:3px solid red;
}

.Severity-Error {
background-color: #ffcccc;
}
Expand Down

0 comments on commit 6013935

Please sign in to comment.