ISIS-903: TranslationServicePoMenu now emits event for its action... ... so that this can be suppressed in the UI by a subscriber if required.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/2cf70db5 Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/2cf70db5 Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/2cf70db5 Branch: refs/heads/master Commit: 2cf70db5b790678aef823cda7ed817befb0f515b Parents: b71bee5 Author: Dan Haywood <[email protected]> Authored: Wed Feb 18 10:04:29 2015 +0000 Committer: Dan Haywood <[email protected]> Committed: Wed Feb 18 14:07:53 2015 +0000 ---------------------------------------------------------------------- .../services/i18n/TranslationServicePoMenu.java | 71 --------------- .../i18n/po/TranslationServicePoMenu.java | 94 ++++++++++++++++++++ 2 files changed, 94 insertions(+), 71 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/isis/blob/2cf70db5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/TranslationServicePoMenu.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/TranslationServicePoMenu.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/TranslationServicePoMenu.java deleted file mode 100644 index 239e79b..0000000 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/TranslationServicePoMenu.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.isis.core.metamodel.services.i18n; - -import javax.inject.Inject; -import org.apache.isis.applib.annotation.Action; -import org.apache.isis.applib.annotation.ActionLayout; -import org.apache.isis.applib.annotation.DomainService; -import org.apache.isis.applib.annotation.DomainServiceLayout; -import org.apache.isis.applib.annotation.NatureOfService; -import org.apache.isis.applib.annotation.ParameterLayout; -import org.apache.isis.applib.annotation.RestrictTo; -import org.apache.isis.applib.annotation.SemanticsOf; -import org.apache.isis.applib.value.Clob; -import org.apache.isis.core.metamodel.services.i18n.po.TranslationServicePo; - -@DomainService( - nature = NatureOfService.VIEW_MENU_ONLY -) -@DomainServiceLayout( - menuBar = DomainServiceLayout.MenuBar.SECONDARY, - named = "Prototyping" -) -public class TranslationServicePoMenu { - - private boolean prototype; - - @Action( - semantics = SemanticsOf.SAFE, - restrictTo = RestrictTo.PROTOTYPING - ) - @ActionLayout( - cssClassFa = "fa-download" - ) - public Clob downloadPotFile( - @ParameterLayout(named = ".pot file name") - final String potFileName) { - final String chars = translationService.toPo(); - return new Clob(potFileName, "text/plain", chars); - } - - public String default0DownloadPotFile() { - return "myapp.pot"; - } - public boolean hideDownloadPotFile() { - return translationService == null || translationService.getMode().isRead(); - } - - // ////////////////////////////////////// - - - @Inject - private TranslationServicePo translationService; - -} http://git-wip-us.apache.org/repos/asf/isis/blob/2cf70db5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/TranslationServicePoMenu.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/TranslationServicePoMenu.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/TranslationServicePoMenu.java new file mode 100644 index 0000000..c39f98a --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/TranslationServicePoMenu.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.isis.core.metamodel.services.i18n.po; + +import java.util.List; +import javax.inject.Inject; +import org.apache.isis.applib.Identifier; +import org.apache.isis.applib.IsisApplibModule; +import org.apache.isis.applib.annotation.Action; +import org.apache.isis.applib.annotation.ActionLayout; +import org.apache.isis.applib.annotation.DomainService; +import org.apache.isis.applib.annotation.DomainServiceLayout; +import org.apache.isis.applib.annotation.NatureOfService; +import org.apache.isis.applib.annotation.ParameterLayout; +import org.apache.isis.applib.annotation.RestrictTo; +import org.apache.isis.applib.annotation.SemanticsOf; +import org.apache.isis.applib.value.Clob; + +@DomainService( + nature = NatureOfService.VIEW_MENU_ONLY +) +@DomainServiceLayout( + menuBar = DomainServiceLayout.MenuBar.SECONDARY, + named = "Prototyping" +) +public class TranslationServicePoMenu { + + public static abstract class ActionDomainEvent extends IsisApplibModule.ActionDomainEvent<TranslationServicePoMenu> { + public ActionDomainEvent(final TranslationServicePoMenu source, final Identifier identifier) { + super(source, identifier); + } + + public ActionDomainEvent(final TranslationServicePoMenu source, final Identifier identifier, final Object... arguments) { + super(source, identifier, arguments); + } + + public ActionDomainEvent(final TranslationServicePoMenu source, final Identifier identifier, final List<Object> arguments) { + super(source, identifier, arguments); + } + } + + // ////////////////////////////////////// + + public static class DownloadPotFileDomainEvent extends ActionDomainEvent { + public DownloadPotFileDomainEvent(final TranslationServicePoMenu source, final Identifier identifier, final Object... arguments) { + super(source, identifier, arguments); + } + } + + @Action( + domainEvent = DownloadPotFileDomainEvent.class, + semantics = SemanticsOf.SAFE, + restrictTo = RestrictTo.PROTOTYPING + ) + @ActionLayout( + cssClassFa = "fa-download" + ) + public Clob downloadPotFile( + @ParameterLayout(named = ".pot file name") + final String potFileName) { + final String chars = translationService.toPo(); + return new Clob(potFileName, "text/plain", chars); + } + + public String default0DownloadPotFile() { + return "translations.pot"; + } + public boolean hideDownloadPotFile() { + return translationService.getMode().isRead(); + } + + // ////////////////////////////////////// + + + @Inject + private TranslationServicePo translationService; + +}
