You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2018/09/20 10:03:01 UTC

[isis] 01/02: ISIS-1919: fixes action menu tooltips, but ultimately we want

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch v2
in repository https://gitbox.apache.org/repos/asf/isis.git

commit b7afd97f3f07e882b93aae60aa2b97f7a79ade3f
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Sep 20 11:39:46 2018 +0200

    ISIS-1919: fixes action menu tooltips, but ultimately we want
    
    ... tooltips that pop up instantly (without browser specific fixed
    delay)
    also removes deprecated IsisSystem class, that one, that just held 3
    constants
    
    Task-Url: https://issues.apache.org/jira/browse/ISIS-1919
---
 .../isis/core/runtime/system/IsisSystem.java       | 35 ---------------
 .../isis/core/runtime/system/MessageRegistry.java  |  2 +-
 .../isis/core/runtime/system/SystemConstants.java  |  6 ++-
 .../serviceactions/ServiceActionUtil.java          | 31 ++++++--------
 .../actionmenu/serviceactions/Tooltips.java        | 50 ++++++++++++++++++++++
 .../isis/viewer/wicket/ui/panels/PanelUtil.java    | 11 +++--
 6 files changed, 73 insertions(+), 62 deletions(-)

diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/IsisSystem.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/IsisSystem.java
deleted file mode 100644
index 0fa3fad..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/IsisSystem.java
+++ /dev/null
@@ -1,35 +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.runtime.system;
-
-/**
- * @deprecated
- */
-@Deprecated
-public class IsisSystem {
-
-    public static final String MSG_ARE_YOU_SURE = "Are you sure?";
-    public static final String MSG_CONFIRM = "Confirm";
-    public static final String MSG_CANCEL = "Cancel";
-
-    private IsisSystem(){}
-
-
-}
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/MessageRegistry.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/MessageRegistry.java
index 3873b34..d134722 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/MessageRegistry.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/MessageRegistry.java
@@ -27,7 +27,7 @@ public class MessageRegistry {
     public MessageRegistry(){}
 
     public List<String> listMessages() {
-        return Arrays.asList(IsisSystem.MSG_ARE_YOU_SURE, IsisSystem.MSG_CONFIRM, IsisSystem.MSG_CANCEL);
+        return Arrays.asList(SystemConstants.MSG_ARE_YOU_SURE, SystemConstants.MSG_CONFIRM, SystemConstants.MSG_CANCEL);
     }
 
 
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/SystemConstants.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/SystemConstants.java
index d1218eb..ccdf286 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/SystemConstants.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/SystemConstants.java
@@ -28,6 +28,10 @@ import org.apache.isis.core.runtime.authorization.AuthorizationManager;
 import org.apache.isis.core.runtime.authorization.AuthorizationManagerInstaller;
 
 public final class SystemConstants {
+    
+    public static final String MSG_ARE_YOU_SURE = "Are you sure?";
+    public static final String MSG_CONFIRM = "Confirm";
+    public static final String MSG_CANCEL = "Cancel";
 
     /**
      * Key used to lookup {@link DeploymentType} (eg via command line) in
@@ -39,8 +43,6 @@ public final class SystemConstants {
     public static final String DEPLOYMENT_TYPE_KEY = ConfigurationConstants.ROOT + "deploymentType";
 
 
-
-
     /**
      * Key used to lookup {@link AppManifest} (if any) from the {@link IsisConfiguration}.
      */
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/ServiceActionUtil.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/ServiceActionUtil.java
index daa41f3..833aa75 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/ServiceActionUtil.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/ServiceActionUtil.java
@@ -21,14 +21,10 @@ package org.apache.isis.viewer.wicket.ui.components.actionmenu.serviceactions;
 
 import java.util.List;
 
-import java.util.function.Function;
-import org.apache.isis.commons.internal.base._Strings;
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableBiMap;
 import com.google.common.collect.ImmutableMap;
-import org.apache.isis.commons.internal.collections._Lists;
 
-import org.apache.wicket.AttributeModifier;
 import org.apache.wicket.Component;
 import org.apache.wicket.MarkupContainer;
 import org.apache.wicket.markup.html.basic.Label;
@@ -36,7 +32,6 @@ import org.apache.wicket.markup.html.link.AbstractLink;
 import org.apache.wicket.markup.html.list.ListItem;
 import org.apache.wicket.markup.html.list.ListView;
 import org.apache.wicket.markup.html.panel.Fragment;
-import org.apache.wicket.model.Model;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,10 +42,12 @@ import org.apache.isis.applib.layout.menubars.bootstrap3.BS3Menu;
 import org.apache.isis.applib.layout.menubars.bootstrap3.BS3MenuBar;
 import org.apache.isis.applib.services.bookmark.Bookmark;
 import org.apache.isis.applib.services.i18n.TranslationService;
+import org.apache.isis.commons.internal.base._Strings;
+import org.apache.isis.commons.internal.collections._Lists;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.services.ServicesInjector;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.runtime.system.IsisSystem;
+import org.apache.isis.core.runtime.system.SystemConstants;
 import org.apache.isis.core.runtime.system.context.IsisContext;
 import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
 import org.apache.isis.core.runtime.system.session.IsisSessionFactoryBuilder;
@@ -59,7 +56,6 @@ import org.apache.isis.viewer.wicket.model.models.ServiceActionsModel;
 import org.apache.isis.viewer.wicket.ui.components.actionmenu.CssClassFaBehavior;
 import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
 
-import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipBehavior;
 import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig;
 import de.agilecoders.wicket.extensions.markup.html.bootstrap.confirmation.ConfirmationBehavior;
 import de.agilecoders.wicket.extensions.markup.html.bootstrap.confirmation.ConfirmationConfig;
@@ -88,17 +84,14 @@ public final class ServiceActionUtil {
             if (!menuItem.isEnabled()) {
                 listItem.add(new CssClassAppender("disabled"));
                 subMenuItemLink.setEnabled(false);
-                TooltipBehavior tooltipBehavior = new TooltipBehavior(Model.of(menuItem.getDisabledReason()));
-                listItem.add(tooltipBehavior);
+                
+                Tooltips.addTooltip(listItem, subMenuItemLink, menuItem.getDisabledReason());
+                
+                
             } else {
 
                 if(!_Strings.isNullOrEmpty(menuItem.getDescription())) {
-                    //XXX ISIS-1625, tooltips for menu actions
-                    listItem.add(new AttributeModifier("title", Model.of(menuItem.getDescription())));
-
-                    // ISIS-1615, prevent bootstrap from changing the HTML link's 'title' attribute on client-side;
-                    // bootstrap will not touch the 'title' attribute once the HTML link has a 'data-original-title' attribute
-                    subMenuItemLink.add(new AttributeModifier("data-original-title", ""));
+                    Tooltips.addTooltip(listItem, subMenuItemLink, menuItem.getDescription());
                 }
 
                 //XXX ISIS-1626, confirmation dialog for no-parameter menu actions
@@ -193,6 +186,8 @@ public final class ServiceActionUtil {
         final List<CssMenuItem> menuItems = separatorStrategy.applySeparatorStrategy(subMenuItem);
         ListView<CssMenuItem> subMenuItemsView = new ListView<CssMenuItem>("subMenuItems",
                 menuItems) {
+             private static final long serialVersionUID = 1L;
+
             @Override
             protected void populateItem(ListItem<CssMenuItem> listItem) {
                 CssMenuItem subMenuItem = listItem.getModelObject();
@@ -281,9 +276,9 @@ public final class ServiceActionUtil {
         ConfirmationConfig confirmationConfig = new ConfirmationConfig();
 
         final String context = IsisSessionFactoryBuilder.class.getName();
-        final String areYouSure = translationService.translate(context, IsisSystem.MSG_ARE_YOU_SURE);
-        final String confirm = translationService.translate(context, IsisSystem.MSG_CONFIRM);
-        final String cancel = translationService.translate(context, IsisSystem.MSG_CANCEL);
+        final String areYouSure = translationService.translate(context, SystemConstants.MSG_ARE_YOU_SURE);
+        final String confirm = translationService.translate(context, SystemConstants.MSG_CONFIRM);
+        final String cancel = translationService.translate(context, SystemConstants.MSG_CANCEL);
 
         confirmationConfig
         .withTitle(areYouSure)
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/Tooltips.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/Tooltips.java
new file mode 100644
index 0000000..e5b521e
--- /dev/null
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/Tooltips.java
@@ -0,0 +1,50 @@
+/* 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.viewer.wicket.ui.components.actionmenu.serviceactions;
+
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.markup.html.link.AbstractLink;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.model.Model;
+
+class Tooltips {
+
+    public static void addTooltip(ListItem<CssMenuItem> listItem, AbstractLink menuItemLink, String tooltipText) {
+        //TODO seems TooltipBehavior does not work on menu actions
+        //TooltipBehavior tooltipBehavior = new TooltipBehavior(
+        //   Model.of(menuItem.getDisabledReason()), createTooltipConfig() );
+        //listItem.add(tooltipBehavior);
+        //--
+        
+        listItem.add(new AttributeModifier("title", Model.of(tooltipText)));
+//        // XXX ISIS-1615, prevent bootstrap from changing the HTML link's 'title' attribute on client-side;
+//        // bootstrap will not touch the 'title' attribute once the HTML link has a 'data-original-title' attribute
+        menuItemLink.add(new AttributeModifier("data-original-title", ""));
+//        //--
+    }
+
+    
+//    private static TooltipConfig createTooltipConfig() {
+//        return new TooltipConfig()
+//                .withTrigger(OpenTrigger.hover)
+//                .withPlacement(Placement.bottom);
+//        
+//    }
+    
+
+}
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelUtil.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelUtil.java
index bc13735..8668def 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelUtil.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelUtil.java
@@ -18,8 +18,6 @@
  */
 package org.apache.isis.viewer.wicket.ui.panels;
 
-import org.apache.isis.commons.internal.base._Strings;
-
 import org.apache.wicket.Component;
 import org.apache.wicket.ajax.attributes.AjaxCallListener;
 import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
@@ -30,8 +28,9 @@ import org.apache.wicket.request.resource.CssResourceReference;
 
 import org.apache.isis.applib.annotation.SemanticsOf;
 import org.apache.isis.applib.services.i18n.TranslationService;
+import org.apache.isis.commons.internal.base._Strings;
 import org.apache.isis.core.metamodel.services.ServicesInjector;
-import org.apache.isis.core.runtime.system.IsisSystem;
+import org.apache.isis.core.runtime.system.SystemConstants;
 import org.apache.isis.core.runtime.system.session.IsisSessionFactoryBuilder;
 
 import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig;
@@ -105,9 +104,9 @@ public final class PanelUtil {
         ConfirmationConfig confirmationConfig = new ConfirmationConfig();
 
         final String context = IsisSessionFactoryBuilder.class.getName();
-        final String areYouSure = translationService.translate(context, IsisSystem.MSG_ARE_YOU_SURE);
-        final String confirm = translationService.translate(context, IsisSystem.MSG_CONFIRM);
-        final String cancel = translationService.translate(context, IsisSystem.MSG_CANCEL);
+        final String areYouSure = translationService.translate(context, SystemConstants.MSG_ARE_YOU_SURE);
+        final String confirm = translationService.translate(context, SystemConstants.MSG_CONFIRM);
+        final String cancel = translationService.translate(context, SystemConstants.MSG_CANCEL);
 
         confirmationConfig
         .withTitle(areYouSure)