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

Commit

Permalink
remove syntax highlight editor option and spellcheck option
Browse files Browse the repository at this point in the history
  • Loading branch information
huangp committed Feb 17, 2014
1 parent d99e207 commit 769115f
Show file tree
Hide file tree
Showing 20 changed files with 16 additions and 182 deletions.
Expand Up @@ -28,7 +28,6 @@
import org.zanata.webtrans.client.events.DisplaySouthPanelEvent;
import org.zanata.webtrans.client.events.EditorPageSizeChangeEvent;
import org.zanata.webtrans.client.events.NotificationEvent;
import org.zanata.webtrans.client.events.RefreshPageEvent;
import org.zanata.webtrans.client.events.ReloadUserConfigUIEvent;
import org.zanata.webtrans.client.events.ReloadUserConfigUIHandler;
import org.zanata.webtrans.client.events.UserConfigChangeEvent;
Expand Down Expand Up @@ -160,12 +159,7 @@ public void onEditorButtonsOptionChanged(Boolean editorButtons) {

@Override
public void onSpellCheckOptionChanged(Boolean spellCheckChkValue) {
if (userOptionsService.getConfigHolder().getState()
.isSpellCheckEnabled() != spellCheckChkValue) {
userOptionsService.getConfigHolder().setSpellCheckEnabled(
spellCheckChkValue);
eventBus.fireEvent(UserConfigChangeEvent.EDITOR_CONFIG_CHANGE_EVENT);
}

}

@Override
Expand Down Expand Up @@ -206,16 +200,6 @@ public void onDisplayTransUnitDetailsOptionChanged(
eventBus.fireEvent(UserConfigChangeEvent.EDITOR_CONFIG_CHANGE_EVENT);
}

@Override
public void onUseCodeMirrorOptionChanged(Boolean useCodeMirrorChkValue) {
if (userOptionsService.getConfigHolder().getState()
.isUseCodeMirrorEditor() != useCodeMirrorChkValue) {
userOptionsService.getConfigHolder().setUseCodeMirrorEditor(
useCodeMirrorChkValue);
eventBus.fireEvent(RefreshPageEvent.REDRAW_PAGE_EVENT);
}
}

@Override
protected void onUnbind() {
changeReferenceLangPresenter.unbind();
Expand Down
Expand Up @@ -107,7 +107,6 @@ public class TargetContentsPresenter implements TargetContentsDisplay.Listener,
// cached state
private String findMessage;
private boolean isDisplayButtons;
private boolean spellCheckEnabled;

@Inject
public TargetContentsPresenter(
Expand Down Expand Up @@ -136,9 +135,6 @@ public TargetContentsPresenter(
isDisplayButtons =
userOptionsService.getConfigHolder().getState()
.isDisplayButtons();
spellCheckEnabled =
userOptionsService.getConfigHolder().getState()
.isSpellCheckEnabled();

editorKeyShortcuts.registerKeys(this);
saveAsApprovedConfirmation.setListener(this);
Expand Down Expand Up @@ -421,15 +417,11 @@ public void onUserConfigChanged(UserConfigChangeEvent event) {
boolean displayButtons =
userOptionsService.getConfigHolder().getState()
.isDisplayButtons();
boolean isSpellCheckEnabled =
userOptionsService.getConfigHolder().getState()
.isSpellCheckEnabled();

if (isDisplayButtons != displayButtons
|| spellCheckEnabled != isSpellCheckEnabled) {

if (isDisplayButtons != displayButtons) {
for (TargetContentsDisplay contentsDisplay : displayList) {
contentsDisplay.showButtons(displayButtons);
contentsDisplay.setEnableSpellCheck(isSpellCheckEnabled);
}
}

Expand All @@ -438,7 +430,6 @@ public void onUserConfigChanged(UserConfigChangeEvent event) {
.getConfigHolder().getState()
.isShowSaveApprovedWarning());
isDisplayButtons = displayButtons;
spellCheckEnabled = isSpellCheckEnabled;
}

@Override
Expand Down
Expand Up @@ -66,8 +66,6 @@ public boolean apply(ContentState contentState) {
public static final boolean DEFAULT_FILTER = false;
public static final boolean DEFAULT_DISPLAY_BUTTONS = true;
public static final boolean DEFAULT_ENTER_SAVES_APPROVED = false;
public static final boolean DEFAULT_USE_CODE_MIRROR = false;
public static final boolean DEFAULT_SPELL_CHECK = true;
public static final DiffMode DEFAULT_TM_DISPLAY_MODE = DiffMode.NORMAL;
public static final boolean DEFAULT_SHOW_PANEL = true;
public static final String DEFAULT_SELECTED_REFERENCE = "none";
Expand All @@ -81,7 +79,6 @@ public UserConfigHolder() {
state.documentListPageSize = DEFAULT_DOC_LIST_PAGE_SIZE;
state.navOption = NavOption.FUZZY_UNTRANSLATED;
state.showError = DEFAULT_SHOW_ERROR;
state.useCodeMirrorEditor = DEFAULT_USE_CODE_MIRROR;
state.showSaveApprovedWarning = DEFAULT_SHOW_SAVE_APPROVED_WARNING;
state.transMemoryDisplayMode = DEFAULT_TM_DISPLAY_MODE;

Expand All @@ -92,8 +89,6 @@ public UserConfigHolder() {
state.filterByRejected = DEFAULT_FILTER;
state.filterByHasError = DEFAULT_FILTER;

state.spellCheckEnabled = DEFAULT_SPELL_CHECK;

state.showTMPanel = DEFAULT_SHOW_PANEL;
state.showGlossaryPanel = DEFAULT_SHOW_PANEL;
state.showOptionalTransUnitDetails = DEFAULT_SHOW_PANEL;
Expand Down Expand Up @@ -156,11 +151,6 @@ public void setShowError(boolean showError) {
state.showError = showError;
}

public void setUseCodeMirrorEditor(boolean useCodeMirrorEditor) {
state = new ConfigurationState(state);
state.useCodeMirrorEditor = useCodeMirrorEditor;
}

public void setFilterByUntranslated(boolean filterByUntranslated) {
state = new ConfigurationState(state);
state.filterByUntranslated = filterByUntranslated;
Expand Down Expand Up @@ -196,11 +186,6 @@ public void setShowSaveApprovedWarning(boolean showSaveApprovedWarning) {
state.showSaveApprovedWarning = showSaveApprovedWarning;
}

public void setSpellCheckEnabled(boolean spellCheckEnabled) {
state = new ConfigurationState(state);
state.spellCheckEnabled = spellCheckEnabled;
}

public void setTMDisplayMode(DiffMode diffMode) {
state = new ConfigurationState(state);
state.transMemoryDisplayMode = diffMode;
Expand Down Expand Up @@ -255,7 +240,6 @@ public static class ConfigurationState implements IsSerializable {
private int documentListPageSize;
private NavOption navOption;
private boolean showError;
private boolean useCodeMirrorEditor;

private boolean filterByUntranslated;
private boolean filterByFuzzy;
Expand All @@ -266,7 +250,6 @@ public static class ConfigurationState implements IsSerializable {
private String selectedReferenceForSourceLang;

private boolean showSaveApprovedWarning;
private boolean spellCheckEnabled;
private DiffMode transMemoryDisplayMode;
private ThemesOption displayTheme;

Expand All @@ -287,15 +270,13 @@ private ConfigurationState(ConfigurationState old) {
this.documentListPageSize = old.getDocumentListPageSize();
this.navOption = old.getNavOption();
this.showError = old.isShowError();
this.useCodeMirrorEditor = old.isUseCodeMirrorEditor();
this.filterByUntranslated = old.isFilterByUntranslated();
this.filterByFuzzy = old.isFilterByFuzzy();
this.filterByTranslated = old.isFilterByTranslated();
this.filterByApproved = old.isFilterByApproved();
this.filterByRejected = old.isFilterByRejected();
this.filterByHasError = old.isFilterByHasError();
this.showSaveApprovedWarning = old.isShowSaveApprovedWarning();
this.spellCheckEnabled = old.isSpellCheckEnabled();
this.transMemoryDisplayMode = old.getTransMemoryDisplayMode();
this.displayTheme = old.getDisplayTheme();
this.showTMPanel = old.isShowTMPanel();
Expand Down Expand Up @@ -331,10 +312,6 @@ public boolean isShowError() {
return showError;
}

public boolean isUseCodeMirrorEditor() {
return useCodeMirrorEditor;
}

public boolean isFilterByUntranslated() {
return filterByUntranslated;
}
Expand Down Expand Up @@ -363,10 +340,6 @@ public boolean isShowSaveApprovedWarning() {
return showSaveApprovedWarning;
}

public boolean isSpellCheckEnabled() {
return spellCheckEnabled;
}

public DiffMode getTransMemoryDisplayMode() {
return transMemoryDisplayMode;
}
Expand Down
Expand Up @@ -497,9 +497,6 @@ String undoUnsuccessful(@PluralCount int unsuccessfulCount,
@DefaultMessage("Refresh current page")
String refreshCurrentPage();

@DefaultMessage("Enable spell check in editor (Firefox only)")
String spellCheckTooltip();

@DefaultMessage("Translation Memory (TM) options")
String transMemoryOption();

Expand Down
Expand Up @@ -108,12 +108,6 @@ public HashMap<UserOptions, String> getEditorOptions() {
.toString(configHolder.getState().isEnterSavesApproved()));
configMap.put(UserOptions.EditorPageSize,
Integer.toString(configHolder.getState().getEditorPageSize()));
configMap.put(UserOptions.UseCodeMirrorEditor, Boolean
.toString(configHolder.getState().isUseCodeMirrorEditor()));
configMap
.put(UserOptions.EnableSpellCheck,
Boolean.toString(configHolder.getState()
.isSpellCheckEnabled()));
configMap.put(UserOptions.TransMemoryDisplayMode, configHolder
.getState().getTransMemoryDisplayMode().name());
configMap.put(UserOptions.DisplayTransMemory,
Expand Down Expand Up @@ -175,8 +169,6 @@ public void loadEditorDefaultOptions() {
.setEditorPageSize(UserConfigHolder.DEFAULT_EDITOR_PAGE_SIZE);
configHolder
.setShowSaveApprovedWarning(UserConfigHolder.DEFAULT_SHOW_SAVE_APPROVED_WARNING);
configHolder
.setUseCodeMirrorEditor(UserConfigHolder.DEFAULT_USE_CODE_MIRROR);
configHolder.setTMDisplayMode(UserConfigHolder.DEFAULT_TM_DISPLAY_MODE);
configHolder.setShowTMPanel(UserConfigHolder.DEFAULT_SHOW_PANEL);
configHolder.setShowGlossaryPanel(UserConfigHolder.DEFAULT_SHOW_PANEL);
Expand Down
16 changes: 4 additions & 12 deletions zanata-war/src/main/java/org/zanata/webtrans/client/ui/Editor.java
Expand Up @@ -101,11 +101,11 @@ public void execute() {
listener.onEditorClicked(id, index);
}
};
if (listener.getConfigState().isUseCodeMirrorEditor()) {
textArea = new CodeMirrorEditor(onCodeMirrorFocusCallback);
} else {
// if (listener.getConfigState().isUseCodeMirrorEditor()) {
// textArea = new CodeMirrorEditor(onCodeMirrorFocusCallback);
// } else {
textArea = new EditorTextArea(displayString);
}
// }

initWidget(uiBinder.createAndBindUi(this));
// determine whether to show or hide buttons
Expand All @@ -125,14 +125,6 @@ protected void onEnsureDebugId(String baseID) {
textArea.ensureDebugId(baseID+ "target-" + index);
}

@Override
public void setEnableSpellCheck(Boolean enabled) {
targetWrapper.getElement().setAttribute("contenteditable",
enabled.toString());
targetWrapper.getElement().setAttribute("spellcheck",
enabled.toString());
}

private void fireValidationEvent() {
if (listener.canEditTranslation()) {
listener.validate(this);
Expand Down
Expand Up @@ -69,14 +69,14 @@ interface Styles extends CssResource {
private String source = "";
private final TransUnitId transUnitId;

public SourcePanel(TransUnitId transUnitId, boolean useCodeMirrorEditor) {
public SourcePanel(TransUnitId transUnitId) {
this.transUnitId = transUnitId;
initWidget(uiBinder.createAndBindUi(this));
if (useCodeMirrorEditor) {
sourceContent = new CodeMirrorReadOnlyWidget();
} else {
// if (useCodeMirrorEditor) {
// sourceContent = new CodeMirrorReadOnlyWidget();
// } else {
sourceContent = new HighlightingLabel();
}
// }
sourceContentContainer.setWidget(sourceContent);
sinkEvents(Event.ONCLICK);
}
Expand Down
Expand Up @@ -27,8 +27,6 @@ public interface ToggleEditor extends IsWidget, HasText,

void refresh();

void setEnableSpellCheck(Boolean enabled);

TransUnitId getId();

void switchType();
Expand Down
Expand Up @@ -25,8 +25,6 @@ interface Listener extends

void onEditorButtonsOptionChanged(Boolean editorButtons);

void onUseCodeMirrorOptionChanged(Boolean useCodeMirrorChkValue);

void onShowSaveApprovedWarningChanged(Boolean showSaveApprovedWarning);

void onSpellCheckOptionChanged(Boolean spellCheckChkValue);
Expand Down
Expand Up @@ -63,7 +63,7 @@ public class EditorOptionsView extends Composite implements

@UiField
CheckBox showTMChk, showGlossaryChk, showOptionalTransUnitDetailsChk,
useCodeMirrorChk, showSaveApprovedWarningChk, spellCheckChk,
showSaveApprovedWarningChk,
enterChk, editorButtonsChk;

@UiField
Expand All @@ -83,12 +83,8 @@ public EditorOptionsView(WebTransMessages messages,
NavOption.class, navOptionRenderer);
navOptionGroup.addToContainer(optionsContainer);

useCodeMirrorChk.setTitle(messages.useCodeMirrorEditorTooltip());
showSaveApprovedWarningChk.setTitle(messages
.showSaveApprovedWarningTooltip());
// TODO at the moment browser spell check only works in Firefox. If
// later Chrome supports it then change the tooltip.
spellCheckChk.setTitle(messages.spellCheckTooltip());

diffModeDiff.setText(uiMessages.diffModeAsDiff());
diffModeHighlight.setText(uiMessages.diffModeAsHighlight());
Expand Down Expand Up @@ -149,23 +145,13 @@ public void onEnterSaveOptionChanged(ValueChangeEvent<Boolean> event) {
listener.onEnterSaveOptionChanged(enterChk.getValue());
}

@UiHandler("useCodeMirrorChk")
public void onCodeMirrorOptionChanged(ValueChangeEvent<Boolean> event) {
listener.onUseCodeMirrorOptionChanged(useCodeMirrorChk.getValue());
}

@UiHandler("showSaveApprovedWarningChk")
public void
onShowSaveApprovedWarningChanged(ValueChangeEvent<Boolean> event) {
listener.onShowSaveApprovedWarningChanged(showSaveApprovedWarningChk
.getValue());
}

@UiHandler("spellCheckChk")
public void onSpellCheckChanged(ValueChangeEvent<Boolean> event) {
listener.onSpellCheckOptionChanged(spellCheckChk.getValue());
}

@UiHandler({ "diffModeDiff", "diffModeHighlight" })
public void onDiffModeOptionChange(ValueChangeEvent<Boolean> event) {
if (diffModeDiff.getValue()) {
Expand Down Expand Up @@ -208,9 +194,7 @@ public void setOptionsState(UserConfigHolder.ConfigurationState state) {

navOptionGroup.setDefaultSelected(state.getNavOption());
selectPageSize(state.getEditorPageSize());
useCodeMirrorChk.setValue(state.isUseCodeMirrorEditor());
showSaveApprovedWarningChk.setValue(state.isShowSaveApprovedWarning());
spellCheckChk.setValue(state.isSpellCheckEnabled());

if (state.getTransMemoryDisplayMode() == DiffMode.NORMAL) {
diffModeDiff.setValue(true);
Expand Down
Expand Up @@ -29,22 +29,12 @@
<ui:text from="{messages.enterKeySaves}" />
</g:CheckBox>
</li>
<li>
<g:CheckBox ui:field="useCodeMirrorChk">
<ui:text from="{messages.useSyntaxHighlight}" />
</g:CheckBox>
</li>
<li>
<g:CheckBox ui:field="showSaveApprovedWarningChk"
styleName="txt--invert">
<ui:text from="{messages.showSaveApproveWarning}" />
</g:CheckBox>
</li>
<li>
<g:CheckBox ui:field="spellCheckChk">
<ui:text from="{messages.enabledSpellCheck}" />
</g:CheckBox>
</li>

<li class="l--push-v-half">
<h5 class="txt--invert txt--align-center">
Expand Down
Expand Up @@ -124,11 +124,10 @@ public void setValue(TransUnit value, boolean fireEvents) {
sourcePanelList.clear();

int rowIndex = 0;
boolean useCodeMirrorEditor =
configHolder.getState().isUseCodeMirrorEditor();

for (String source : value.getSources()) {
SourcePanel sourcePanel =
new SourcePanel(transUnit.getId(), useCodeMirrorEditor);
new SourcePanel(transUnit.getId());
sourcePanel.ensureDebugId(value.getRowIndex() + "-source-panel-" + rowIndex);
sourcePanel.setValue(source, value.getSourceComment(),
value.isPlural());
Expand Down
Expand Up @@ -70,8 +70,6 @@ public interface TargetContentsDisplay extends WidgetDisplay, HasTransUnitId,
void updateCachedTargetsAndVersion(List<String> targets, Integer verNum,
ContentState status);

void setEnableSpellCheck(boolean spellCheckEnabled);

void updateCommentIndicator(int commentsCount);

ContentState getCachedState();
Expand Down

0 comments on commit 769115f

Please sign in to comment.