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

Commit

Permalink
Merge branch 'rhbz803572' of github.com:zanata/zanata into rhbz803572
Browse files Browse the repository at this point in the history
Conflicts:
	server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/TargetContentsPresenter.java
  • Loading branch information
alex-sl-eng committed Mar 23, 2012
2 parents 147a2ec + 4e7e270 commit ea4174d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 19 deletions.
Expand Up @@ -1146,6 +1146,7 @@ public void selectTransUnit(TransUnit transUnit)

eventBus.fireEvent(new TransUnitSelectionEvent(selectedTransUnit));
sourceContentsPresenter.setSelectedSource(display.getSelectedRowNumber());
display.getTargetCellEditor().savePendingChange(true);
display.gotoRow(display.getSelectedRowNumber(), true);
}
}
Expand Down
Expand Up @@ -24,6 +24,8 @@
public interface TargetContentsDisplay extends WidgetDisplay, Iterable<ToggleEditor>
{

ToggleEditor openEditorAndCloseOthers(ToggleEditor currentEditor);

interface Listener
{
void validate(ToggleEditor editor);
Expand Down
Expand Up @@ -58,7 +58,6 @@ public class TargetContentsPresenter implements TargetContentsDisplay.Listener
private List<TargetContentsDisplay> displayList;
private ToggleEditor currentEditor;
private List<ToggleEditor> currentEditors;
private InlineTargetCellEditor inlineTargetCellEditor;

@Inject
public TargetContentsPresenter(Provider<TargetContentsDisplay> displayProvider, final EventBus eventBus, final TableEditorMessages messages, final SourceContentsPresenter sourceContentsPresenter)
Expand Down Expand Up @@ -150,22 +149,24 @@ public void setCurrentEditorText(String text)
public void showEditors(int rowIndex)
{
TargetContentsDisplay previousDisplay = currentDisplay;
previousDisplay.setToView();
if (previousDisplay != null)
{
previousDisplay.setToView();
}
currentDisplay = displayList.get(rowIndex);
currentEditors = currentDisplay.getEditors();

if (currentEditor != null)
{
currentEditor.setViewMode(ToggleEditor.ViewMode.EDIT);
Log.info("show editors at row:" + rowIndex + " current editor:" + currentEditor.getText());
currentEditor = currentDisplay.openEditorAndCloseOthers(currentEditor);
Log.info("show editors at row:" + rowIndex + " current editor:" + currentEditor.getText());
}
}

public TargetContentsDisplay getNextTargetContentsDisplay(int rowIndex, TransUnit transUnit)
{
TargetContentsDisplay result = displayList.get(rowIndex);
result.setTargets(transUnit.getTargets());
currentDisplay = result;
return result;
}

Expand Down Expand Up @@ -194,13 +195,10 @@ public void validate(ToggleEditor editor)
@Override
public void saveAsApproved(ToggleEditor editor)
{
// TODO we should get new value out and save
int editorIndex = currentEditors.indexOf(editor);
if (editorIndex + 1 < currentEditors.size())
{
currentDisplay.setToView();
currentEditor = currentEditors.get(editorIndex + 1);
currentEditor.setViewMode(ToggleEditor.ViewMode.EDIT);
currentEditor = currentDisplay.openEditorAndCloseOthers(currentEditors.get(editorIndex + 1));
}
else
{
Expand All @@ -225,18 +223,16 @@ public void copySource(ToggleEditor editor)
@Override
public void toggleView(ToggleEditor editor)
{
// editor.setViewMode(ToggleEditor.ViewMode.EDIT);
// editor.setViewMode(ToggleEditor.ViewMode.EDIT);
currentEditor = editor;
if (currentEditors.contains(editor))
{
// still in the same trans unit. won't trigger transunit selection or
// edit cell event
Log.info("same transunit just another editor");
currentDisplay.setToView();
currentEditor.setViewMode(ToggleEditor.ViewMode.EDIT);
//still in the same trans unit. won't trigger transunit selection or edit cell event
Log.info("same transunit just another editor:" + editor);
currentEditor = currentDisplay.openEditorAndCloseOthers(editor);
}
// else, it's clicking an editor outside current selection. the table
// selection event will trigger and showEditors will take care of the rest
Log.info("current display:" + currentDisplay);
//else, it's clicking an editor outside current selection. the table selection event will trigger and showEditors will take care of the rest
}

public List<String> getNewTargets()
Expand Down
Expand Up @@ -18,6 +18,7 @@
import java.util.Iterator;
import java.util.List;

import com.google.common.base.Objects;
import org.zanata.webtrans.client.ui.Editor;
import org.zanata.webtrans.client.ui.ToggleEditor;

Expand Down Expand Up @@ -45,6 +46,14 @@ public TargetContentsView()
editors = Lists.newArrayList();
}

@Override
public ToggleEditor openEditorAndCloseOthers(ToggleEditor currentEditor)
{
setToView();
currentEditor.setViewMode(ToggleEditor.ViewMode.EDIT);
return currentEditor;
}

@Override
public void setTargets(List<String> targets)
{
Expand Down Expand Up @@ -105,7 +114,7 @@ public boolean isEditing()
@Override
public List<ToggleEditor> getEditors()
{
return ImmutableList.copyOf(editors);
return editors;
}

@Override
Expand All @@ -125,4 +134,12 @@ public Iterator<ToggleEditor> iterator()
{
return editors.iterator();
}

@Override
public String toString()
{
return Objects.toStringHelper(this).
add("editors", editors).
toString();
}
}
Expand Up @@ -229,9 +229,9 @@ public void setViewMode(ViewMode viewMode)
textArea.setVisible(viewMode == ViewMode.EDIT);
if (viewMode == ViewMode.EDIT)
{
textArea.setFocus(true);
listener.setValidationMessagePanel(this);
fireValidationEvent();
textArea.setFocus(true);
}
buttons.setVisible(viewMode == ViewMode.EDIT);
//sync label and text area
Expand Down Expand Up @@ -354,6 +354,7 @@ public String toString()
{
return Objects.toStringHelper(this).
add("label", label.getText()).
add("isOpen", textArea.isVisible()).
toString();
}
}

0 comments on commit ea4174d

Please sign in to comment.