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

Commit

Permalink
Merge branch 'integration/master' of github.com:zanata/zanata into in…
Browse files Browse the repository at this point in the history
…tegration/master
  • Loading branch information
Alex Eng committed Sep 26, 2012
2 parents cb5d8cc + 785b89c commit 825a4d9
Show file tree
Hide file tree
Showing 25 changed files with 543 additions and 139 deletions.
18 changes: 18 additions & 0 deletions functional-test/pom.xml
Expand Up @@ -243,6 +243,24 @@
</executions>
</plugin>

<!--We don't want cobertura here-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<instrumentation>
<excludes>
<exclude>**/*</exclude>
</excludes>
</instrumentation>
<check>
<totalBranchRate>0</totalBranchRate>
<totalLineRate>0</totalLineRate>
<haltOnFailure>false</haltOnFailure>
</check>
</configuration>
</plugin>

<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.11</version>
Expand Down
24 changes: 24 additions & 0 deletions zanata-model/pom.xml
Expand Up @@ -40,6 +40,30 @@
</archive>
</configuration>
</plugin>

<!-- basically we only want to test validators-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<instrumentation>
<excludes>
<exclude>**/test/**/*</exclude>
<exclude>**/hibernate/**/*</exclude>
<exclude>**/util/*</exclude>
<exclude>**/model/po/*</exclude>
<exclude>**/model/security/*</exclude>
<exclude>**/model/type/*</exclude>
<exclude>**/model/*</exclude>
</excludes>
</instrumentation>
<check>
<totalBranchRate>${cobertura.total-branch-rate}</totalBranchRate>
<totalLineRate>${cobertura.total-line-rate}</totalLineRate>
<haltOnFailure>${cobertura.halt.failure}</haltOnFailure>
</check>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
4 changes: 3 additions & 1 deletion zanata-war/pom.xml
Expand Up @@ -235,14 +235,16 @@
<exclude>**/client/auth/**</exclude>
<exclude>**/client/events/**</exclude>
<exclude>**/client/gin/**</exclude>
<exclude>**/client/rpc/**</exclude>
<exclude>**/client/ui/**</exclude>
<exclude>**/client/view/**</exclude>
<exclude>**/*OkapiUtil*</exclude>
<exclude>**/EventWrapperImpl*</exclude>
<exclude>**/*DataProvider*</exclude>
<exclude>**/*SelectionModel*</exclude>
<!--below are some trivial classes(java bean) at the moment-->
<exclude>**/shared/auth/**</exclude>
<exclude>**/shared/model/**</exclude>
<exclude>**/shared/rpc/**</exclude>
<exclude>**/*Exception*</exclude>
</excludes>
</instrumentation>
Expand Down
Expand Up @@ -33,6 +33,7 @@
**/
public class RequestValidationEvent extends GwtEvent<RequestValidationEventHandler>
{
public static final RequestValidationEvent EVENT = new RequestValidationEvent();
/**
* Handler type.
*/
Expand All @@ -48,7 +49,7 @@ public static Type<RequestValidationEventHandler> getType()
return TYPE != null ? TYPE : (TYPE = new Type<RequestValidationEventHandler>());
}

public RequestValidationEvent()
private RequestValidationEvent()
{
}

Expand Down
Expand Up @@ -20,16 +20,20 @@
*/
package org.zanata.webtrans.client.gin;

import java.util.Map;

import net.customware.gwt.presenter.client.DefaultEventBus;
import net.customware.gwt.presenter.client.Display;
import net.customware.gwt.presenter.client.EventBus;
import net.customware.gwt.presenter.client.gin.AbstractPresenterModule;

import org.zanata.webtrans.client.Application;
import org.zanata.webtrans.client.EventProcessor;
import org.zanata.webtrans.client.editor.filter.TransFilterDisplay;
import org.zanata.webtrans.client.editor.filter.TransFilterPresenter;
import org.zanata.webtrans.client.editor.filter.TransFilterView;
import org.zanata.webtrans.client.presenter.TransFilterPresenter;
import org.zanata.webtrans.client.resources.ValidationMessages;
import org.zanata.webtrans.client.view.SideMenuDisplay;
import org.zanata.webtrans.client.view.SourceContentsDisplay;
import org.zanata.webtrans.client.view.SourceContentsView;
import org.zanata.webtrans.client.events.NativeEvent;
import org.zanata.webtrans.client.events.NativeEventImpl;
import org.zanata.webtrans.client.history.History;
Expand Down Expand Up @@ -78,12 +82,11 @@
import org.zanata.webtrans.client.view.KeyShortcutView;
import org.zanata.webtrans.client.view.NotificationView;
import org.zanata.webtrans.client.view.SearchResultsView;
import org.zanata.webtrans.client.view.SideMenuDisplay;
import org.zanata.webtrans.client.view.SideMenuView;
import org.zanata.webtrans.client.view.SourceContentsDisplay;
import org.zanata.webtrans.client.view.SourceContentsView;
import org.zanata.webtrans.client.view.TargetContentsDisplay;
import org.zanata.webtrans.client.view.TargetContentsView;
import org.zanata.webtrans.client.view.TransFilterDisplay;
import org.zanata.webtrans.client.view.TransFilterView;
import org.zanata.webtrans.client.view.TransMemoryDetailsDisplay;
import org.zanata.webtrans.client.view.TransMemoryDetailsView;
import org.zanata.webtrans.client.view.TransMemoryView;
Expand All @@ -98,7 +101,15 @@
import org.zanata.webtrans.client.view.WorkspaceUsersView;
import org.zanata.webtrans.shared.auth.Identity;
import org.zanata.webtrans.shared.model.UserWorkspaceContext;
import org.zanata.webtrans.shared.validation.ValidationObject;
import org.zanata.webtrans.shared.validation.action.HtmlXmlTagValidation;
import org.zanata.webtrans.shared.validation.action.JavaVariablesValidation;
import org.zanata.webtrans.shared.validation.action.NewlineLeadTrailValidation;
import org.zanata.webtrans.shared.validation.action.PrintfVariablesValidation;
import org.zanata.webtrans.shared.validation.action.PrintfXSIExtensionValidation;
import org.zanata.webtrans.shared.validation.action.XmlEntityValidation;

import com.google.common.collect.ImmutableMap;
import com.google.gwt.core.client.Scheduler;
import com.google.inject.Provider;
import com.google.inject.Provides;
Expand Down Expand Up @@ -190,4 +201,34 @@ public Identity get()
}
}

/**
* a map contains all validation objects.
*
* @see org.zanata.webtrans.client.service.ValidationService
* @param valMessages Validation messages
* @return a map contains all validation objects.
*/
@Provides
public Map<String, ValidationObject> allValidationObjects(ValidationMessages valMessages)
{
ImmutableMap.Builder<String, ValidationObject> builder = ImmutableMap.builder();

HtmlXmlTagValidation htmlxmlValidation = new HtmlXmlTagValidation(valMessages);
NewlineLeadTrailValidation newlineLeadTrailValidation = new NewlineLeadTrailValidation(valMessages);
JavaVariablesValidation javaVariablesValidation = new JavaVariablesValidation(valMessages);
XmlEntityValidation xmlEntityValidation = new XmlEntityValidation(valMessages);
PrintfVariablesValidation printfVariablesValidation = new PrintfVariablesValidation(valMessages);
PrintfXSIExtensionValidation positionalPrintfValidation = new PrintfXSIExtensionValidation(valMessages);
printfVariablesValidation.mutuallyExclusive(positionalPrintfValidation);
positionalPrintfValidation.mutuallyExclusive(printfVariablesValidation);

builder.put(htmlxmlValidation.getId(), htmlxmlValidation);
builder.put(newlineLeadTrailValidation.getId(), newlineLeadTrailValidation);
builder.put(printfVariablesValidation.getId(), printfVariablesValidation);
builder.put(positionalPrintfValidation.getId(), positionalPrintfValidation);
builder.put(javaVariablesValidation.getId(), javaVariablesValidation);
builder.put(xmlEntityValidation.getId(), xmlEntityValidation);

return builder.build();
}
}
Expand Up @@ -48,12 +48,14 @@
*/
public class SourceContentsPresenter implements ClickHandler
{
private HasSelectableSource selectedSource;

private final EventBus eventBus;

private Provider<SourceContentsDisplay> displayProvider;
private List<SourceContentsDisplay> displayList = Collections.emptyList();

// states
private TransUnitId currentTransUnitId;
private HasSelectableSource selectedSource;

@Inject
public SourceContentsPresenter(final EventBus eventBus, Provider<SourceContentsDisplay> displayProvider)
Expand All @@ -72,25 +74,8 @@ public void setSelectedSource(TransUnitId id)
Log.debug("source content selected id:" + id);

SourceContentsDisplay sourceContentsView = Iterables.find(displayList, new FindByTransUnitIdPredicate(id));
// after save as fuzzy re-render(will call
// SourceContentsView.setValue(TransUnit) which cause re-creation of
// SourcePanel list), we want to re-select the radio button
List<HasSelectableSource> sourcePanelList = sourceContentsView.getSourcePanelList();
for (HasSelectableSource sourcePanel : sourcePanelList)
{
if (selectedSource != null && selectedSource.getSource().equals(sourcePanel.getSource()))
{
fireClickEventToSelectSource(sourcePanel);
return;
}
}
//else by default it will select the first one
fireClickEventToSelectSource(sourceContentsView.getSourcePanelList().get(0));
}

private static void fireClickEventToSelectSource(HasSelectableSource sourcePanel)
{
ClickEvent.fireNativeEvent(Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false), sourcePanel);
// by default select the first one
sourceContentsView.getSourcePanelList().get(0).clickSelf();
}

public String getSelectedSource()
Expand Down Expand Up @@ -142,7 +127,7 @@ public void onClick(ClickEvent event)

Log.debug("Selected source: " + selectedSource.getSource());
//TODO this is firing every time we click.
eventBus.fireEvent(new RequestValidationEvent());
eventBus.fireEvent(RequestValidationEvent.EVENT);
}
}

Expand Down
Expand Up @@ -18,20 +18,18 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
* site: http://www.fsf.org.
*/
package org.zanata.webtrans.client.editor.filter;

import net.customware.gwt.presenter.client.EventBus;
import net.customware.gwt.presenter.client.widget.WidgetPresenter;
package org.zanata.webtrans.client.presenter;

import org.zanata.webtrans.client.events.FindMessageEvent;
import org.zanata.webtrans.client.events.FindMessageHandler;
import org.zanata.webtrans.client.history.History;
import org.zanata.webtrans.client.history.HistoryToken;

import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import org.zanata.webtrans.client.view.TransFilterDisplay;
import com.google.inject.Inject;

import net.customware.gwt.presenter.client.EventBus;
import net.customware.gwt.presenter.client.widget.WidgetPresenter;

public class TransFilterPresenter extends WidgetPresenter<TransFilterDisplay> implements TransFilterDisplay.Listener, FindMessageHandler
{

Expand Down
Expand Up @@ -20,7 +20,6 @@
*/
package org.zanata.webtrans.client.presenter;

import org.zanata.webtrans.client.editor.filter.TransFilterPresenter;
import org.zanata.webtrans.client.events.PageChangeEvent;
import org.zanata.webtrans.client.events.PageChangeEventHandler;
import org.zanata.webtrans.client.events.PageCountChangeEvent;
Expand Down
Expand Up @@ -58,31 +58,16 @@

public class ValidationService implements RunValidationEventHandler, TransUnitSelectionHandler, DocumentSelectionHandler
{
private final Map<String, ValidationObject> validationMap = new HashMap<String, ValidationObject>();
private final EventBus eventBus;
private final TableEditorMessages messages;
private Map<String, ValidationObject> validationMap;

@Inject
public ValidationService(final EventBus eventBus, final TableEditorMessages messages, final ValidationMessages valMessages)
public ValidationService(final EventBus eventBus, final TableEditorMessages messages, Map<String, ValidationObject> validationMap)
{
this.eventBus = eventBus;
this.messages = messages;

HtmlXmlTagValidation htmlxmlValidation = new HtmlXmlTagValidation(valMessages);
NewlineLeadTrailValidation newlineLeadTrailValidation = new NewlineLeadTrailValidation(valMessages);
JavaVariablesValidation javaVariablesValidation = new JavaVariablesValidation(valMessages);
XmlEntityValidation xmlEntityValidation = new XmlEntityValidation(valMessages);
PrintfVariablesValidation printfVariablesValidation = new PrintfVariablesValidation(valMessages);
PrintfXSIExtensionValidation positionalPrintfValidation = new PrintfXSIExtensionValidation(valMessages);
printfVariablesValidation.mutuallyExclusive(positionalPrintfValidation);
positionalPrintfValidation.mutuallyExclusive(printfVariablesValidation);

validationMap.put(htmlxmlValidation.getId(), htmlxmlValidation);
validationMap.put(newlineLeadTrailValidation.getId(), newlineLeadTrailValidation);
validationMap.put(printfVariablesValidation.getId(), printfVariablesValidation);
validationMap.put(positionalPrintfValidation.getId(), positionalPrintfValidation);
validationMap.put(javaVariablesValidation.getId(), javaVariablesValidation);
validationMap.put(xmlEntityValidation.getId(), xmlEntityValidation);
this.validationMap = validationMap;

eventBus.addHandler(RunValidationEvent.getType(), this);
eventBus.addHandler(TransUnitSelectionEvent.getType(), this);
Expand Down Expand Up @@ -143,7 +128,7 @@ public void updateStatus(String key, boolean isEnabled)
action.setEnabled(isEnabled);

// request re-run validation with new options
eventBus.fireEvent(new RequestValidationEvent());
eventBus.fireEvent(RequestValidationEvent.EVENT);
}

public List<ValidationObject> getValidationList()
Expand Down
Expand Up @@ -9,4 +9,6 @@ public interface HasSelectableSource extends HasClickHandlers
void setSelected(boolean selected);

void refresh();

void clickSelf();
}
Expand Up @@ -23,6 +23,7 @@
import org.zanata.webtrans.client.resources.NavigationMessages;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerRegistration;
Expand Down Expand Up @@ -117,6 +118,12 @@ public void refresh()
sourceContent.refresh();
}

@Override
public void clickSelf()
{
ClickEvent.fireNativeEvent(Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false), this);
}

public void highlightSearch(String searchTerm)
{
sourceContent.highlight(searchTerm);
Expand Down
Expand Up @@ -18,24 +18,12 @@
table-layout: fixed;
}

.selectedRow .CodeMirror-lines {
cursor: default;

}

.nonSelectedRow .CodeMirror-lines {
cursor: default;

}

</ui:style>


<g:HorizontalPanel width="100%" height="100%" styleName="{style.nonSelectedRow}" ui:field="container">
<g:cell horizontalAlignment="ALIGN_LEFT">
<g:HTMLPanel>
<!--<fui:HighlightingLabel ui:field="highlightingLabel" stylePrimaryName="TableEditorContent"/>-->

<fui:CodeMirrorReadOnlyWidget ui:field="sourceContent" />
</g:HTMLPanel>
</g:cell>
Expand Down
@@ -1,6 +1,4 @@
package org.zanata.webtrans.client.editor.filter;

import com.google.gwt.user.client.ui.HasValue;
package org.zanata.webtrans.client.view;

import net.customware.gwt.presenter.client.widget.WidgetDisplay;

Expand Down
Expand Up @@ -18,7 +18,7 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
* site: http://www.fsf.org.
*/
package org.zanata.webtrans.client.editor.filter;
package org.zanata.webtrans.client.view;

import com.google.gwt.i18n.client.LocalizableResource.DefaultLocale;
import com.google.gwt.i18n.client.LocalizableResource.Generate;
Expand Down

0 comments on commit 825a4d9

Please sign in to comment.