You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by lk...@apache.org on 2019/11/23 17:48:49 UTC

[netbeans] branch master updated: [NETBEANS-2960] Added Reload Project action for Gradle

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

lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 5a182f7  [NETBEANS-2960] Added Reload Project action for Gradle
5a182f7 is described below

commit 5a182f7f8530bc5ca6fac110647cbffdf7df58d1
Author: Laszlo Kishalmi <la...@gmail.com>
AuthorDate: Fri Nov 15 22:57:39 2019 -0800

    [NETBEANS-2960] Added Reload Project action for Gradle
---
 .../modules/gradle/actions/ReloadAction.java       | 82 ++++++++++++++++++++++
 1 file changed, 82 insertions(+)

diff --git a/groovy/gradle/src/org/netbeans/modules/gradle/actions/ReloadAction.java b/groovy/gradle/src/org/netbeans/modules/gradle/actions/ReloadAction.java
new file mode 100644
index 0000000..6d0f4f1
--- /dev/null
+++ b/groovy/gradle/src/org/netbeans/modules/gradle/actions/ReloadAction.java
@@ -0,0 +1,82 @@
+/*
+ * 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.netbeans.modules.gradle.actions;
+
+import java.awt.event.ActionEvent;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.gradle.NbGradleProjectImpl;
+import org.netbeans.modules.gradle.api.NbGradleProject;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionRegistration;
+import org.openide.util.ContextAwareAction;
+import org.openide.util.Lookup;
+import org.openide.util.NbBundle;
+import static org.netbeans.modules.gradle.actions.Bundle.*;
+import org.netbeans.modules.gradle.api.GradleProjects;
+
+/**
+ *
+ * @author lkishalmi
+ */
+@SuppressWarnings(value = "serial")
+@ActionID(id = "org.netbeans.modules.maven.refresh", category = "Project")
+@ActionRegistration(displayName = "#ACT_Reload_Project", lazy=false)
+@ActionReference(position = 1700, path = "Projects/" + NbGradleProject.GRADLE_PROJECT_TYPE + "/Actions")
+@NbBundle.Messages("ACT_Reload_Project=Reload Project")
+public class ReloadAction  extends AbstractAction implements ContextAwareAction {
+
+    private final Lookup context;
+    public ReloadAction() {
+        this(Lookup.EMPTY);
+    }
+
+    @NbBundle.Messages({"# {0} - count", "ACT_Reload_Projects=Reload {0} Projects"})
+    private ReloadAction(Lookup lkp) {
+        context = lkp;
+        Collection<? extends NbGradleProjectImpl> col = context.lookupAll(NbGradleProjectImpl.class);
+        if (col.size() > 1) {
+            putValue(Action.NAME, ACT_Reload_Projects(col.size()));
+        } else {
+            putValue(Action.NAME, ACT_Reload_Project());
+        }
+    }
+
+    @Override public void actionPerformed(ActionEvent event) {
+        Set<Project> reload = new LinkedHashSet<>();
+        for (NbGradleProjectImpl prj : context.lookupAll(NbGradleProjectImpl.class)) {
+            reload.add(prj);
+            reload.addAll(GradleProjects.openedProjectDependencies(prj).values());
+        }
+        for (Project project : reload) {
+            NbGradleProject.fireGradleProjectReload(project);
+        }
+    }
+
+    @Override public Action createContextAwareInstance(Lookup actionContext) {
+        return new ReloadAction(actionContext);
+    }
+
+
+}


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

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