You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2018/02/20 08:39:56 UTC

[GitHub] geertjanw closed pull request #409: NETBEANS-357: corrected the target folder for toolbar link for action

geertjanw closed pull request #409: NETBEANS-357: corrected the target folder for toolbar link for action
URL: https://github.com/apache/incubator-netbeans/pull/409
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/editor.lib2/nbproject/project.xml b/editor.lib2/nbproject/project.xml
index 859f2d267..a05fa92b6 100644
--- a/editor.lib2/nbproject/project.xml
+++ b/editor.lib2/nbproject/project.xml
@@ -170,6 +170,15 @@
                     </test-dependency>
                     <test-dependency>
                         <code-name-base>org.openide.loaders</code-name-base>
+                        <compile-dependency/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.openide.nodes</code-name-base>
+                        <compile-dependency/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.editor</code-name-base>
+                        <compile-dependency/>
                     </test-dependency>
                     <test-dependency>
                         <code-name-base>org.openide.util.ui</code-name-base>
diff --git a/editor.lib2/src/org/netbeans/modules/editor/lib2/EditorActionRegistrationProcessor.java b/editor.lib2/src/org/netbeans/modules/editor/lib2/EditorActionRegistrationProcessor.java
index e56746442..ac999de7f 100644
--- a/editor.lib2/src/org/netbeans/modules/editor/lib2/EditorActionRegistrationProcessor.java
+++ b/editor.lib2/src/org/netbeans/modules/editor/lib2/EditorActionRegistrationProcessor.java
@@ -257,10 +257,11 @@ private void register(Element e, EditorActionRegistration annotation) throws Lay
         int toolBarPosition = annotation.toolBarPosition();
         if (toolBarPosition != Integer.MAX_VALUE) {
             StringBuilder toolBarPresenterFilePath = new StringBuilder(50);
-            toolBarPresenterFilePath.append("Editors/Toolbar/");
+            toolBarPresenterFilePath.append("Editors/");
             if (mimeType.length() > 0) {
                 toolBarPresenterFilePath.append(mimeType).append("/");
             }
+            toolBarPresenterFilePath.append("Toolbars/Default/");
             toolBarPresenterFilePath.append(actionName).append(".shadow");
             LayerBuilder.File toolBarPresenterShadowFile = layer.file(toolBarPresenterFilePath.toString());
             toolBarPresenterShadowFile.stringvalue("originalFile", actionFilePath);
diff --git a/editor.lib2/test/unit/src/org/netbeans/modules/editor/lib2/testactionsregistration/EditorActionRegistrationTest.java b/editor.lib2/test/unit/src/org/netbeans/modules/editor/lib2/testactionsregistration/EditorActionRegistrationTest.java
index fb6e65b72..b4100290d 100644
--- a/editor.lib2/test/unit/src/org/netbeans/modules/editor/lib2/testactionsregistration/EditorActionRegistrationTest.java
+++ b/editor.lib2/test/unit/src/org/netbeans/modules/editor/lib2/testactionsregistration/EditorActionRegistrationTest.java
@@ -21,10 +21,12 @@
 
 import java.awt.event.ActionEvent;
 import java.io.ByteArrayOutputStream;
+import java.util.List;
 import javax.swing.AbstractAction;
 import javax.swing.Action;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.api.editor.EditorActionRegistration;
+import org.netbeans.modules.editor.impl.ToolbarActionsProvider;
 import org.netbeans.modules.editor.lib2.actions.EditorActionUtilities;
 import org.netbeans.modules.editor.lib2.actions.SearchableEditorKit;
 import org.netbeans.spi.editor.AbstractEditorAction;
@@ -32,6 +34,8 @@
 import org.openide.filesystems.FileUtil;
 import org.openide.util.test.AnnotationProcessorTestUtils;
 
+import org.openide.loaders.DataShadow;
+
 /**
  * Test registration of editor actions through an annotation.
  *
@@ -93,6 +97,29 @@ public void testRegistrationNoIconAndKeyBinding() throws Exception {
         assertTrue((Boolean) a.getValue(AbstractEditorAction.NO_ICON_IN_MENU));
         assertTrue((Boolean) a.getValue(AbstractEditorAction.NO_KEY_BINDING));
     }
+    
+    public void testToolbarRegistration() throws Exception {
+        FileObject toolbarDir = FileUtil.getConfigFile("/Editors/text/foo/Toolbars/Default");
+        assertNotNull("text/base toolbar directory is null", toolbarDir);
+        FileObject toolbarLink = toolbarDir.getFileObject(EditorTestActionToolbar.id + ".shadow"); // NOI18N
+        assertNotNull("Action link in toolbar must exist", toolbarLink);
+        FileObject orig = DataShadow.findOriginal(toolbarLink);
+        assertNotNull("Action registration must exist", orig);
+        
+        List items = ToolbarActionsProvider.getToolbarItems("text/foo");
+        assertFalse("At least one registration must be present", items.isEmpty());
+        for (Object o : items) {
+            if (!(o instanceof Action)) {
+                continue;
+            }
+            Action a = (Action)o;
+            String name = (String)a.getValue(Action.NAME);
+            if (EditorTestActionToolbar.id.equals(name)) {
+                return; // OK
+            }
+        }
+        fail("Registered action not found");
+    }
 
     public void testNonPublicClass() throws Exception {
         String nonPublicClassSource =
@@ -201,5 +228,18 @@ public void actionPerformed(ActionEvent evt) {
         }
 
     }
+    
+    @EditorActionRegistration(name = "ToolbarIcon", shortDescription = "", 
+            mimeType="text/foo", toolBarPosition = 1000)
+    public static final class EditorTestActionToolbar extends AbstractAction {
+        static final String id = "ToolbarIcon";
+        public EditorTestActionToolbar() {
+        }
 
+        @Override
+        public void actionPerformed(ActionEvent evt) {
+        }
+
+    }
+    
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists