Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minor cleanup

  • Loading branch information...
commit 6a0299c4ab1a0a575f87e43a60ada5bc75a0d063 1 parent ed213ee
@wolfs authored
View
27 src/main/java/hudson/plugins/depgraph_view/AbstractDependencyGraphAction.java
@@ -1,35 +1,26 @@
package hudson.plugins.depgraph_view;
+import com.google.common.collect.ImmutableMap;
import hudson.Launcher;
+import hudson.model.AbstractModelObject;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.DependencyGraph.Dependency;
import hudson.model.Hudson;
import hudson.plugins.depgraph_view.DependencyGraphProperty.DescriptorImpl;
import hudson.util.LogTaskListener;
+import org.kohsuke.stapler.StaplerRequest;
+import org.kohsuke.stapler.StaplerResponse;
+import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.servlet.http.HttpServletResponse;
-
-import org.kohsuke.stapler.StaplerRequest;
-import org.kohsuke.stapler.StaplerResponse;
-
-import com.google.common.collect.ImmutableMap;
-
public abstract class AbstractDependencyGraphAction implements Action {
private final Logger LOGGER = Logger.getLogger(Logger.class.getName());
@@ -131,13 +122,11 @@ public String generateDotText(Set<AbstractProject<?,?>> projects, Set<Dependency
builder.append(projectToNodeString(proj)).append(";\n");
}
- Map<Class<?>, String> depClass2Color = new HashMap<Class<?>, String>();
for (Dependency dep : sortedDeps) {
builder.append(dependencyToEdgeString(dep));
builder.append(";\n");
-
-
}
+
builder.append("color=white;\n}\n");
return builder.append("}").toString();
}
@@ -161,6 +150,8 @@ private String escapeString(String toEscape) {
public abstract String getTitle();
+ public abstract AbstractModelObject getParentObject();
+
public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException {
String path = req.getRestOfPath();
if (path.startsWith("/graph.")) {
View
9 src/main/java/hudson/plugins/depgraph_view/CalculateDeps.java
@@ -7,6 +7,7 @@
import hudson.model.Item;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Logger;
@@ -17,10 +18,6 @@
private final Set<AbstractProject<?,?>> visitedProj = new HashSet<AbstractProject<?,?>>();
private boolean calculated = false;
- public CalculateDeps(AbstractProject<?, ?> proj) {
- visitedProj.add(proj);
- }
-
public CalculateDeps(Collection<? extends AbstractProject<?, ?>> projects) {
visitedProj.addAll(projects);
}
@@ -67,13 +64,13 @@ private void calculateNodesAndDependencies(Set<AbstractProject<?, ?>> fromProjec
if (!calculated) {
calculateNodesAndDependencies();
}
- return visitedProj;
+ return Collections.unmodifiableSet(visitedProj);
}
public Set<Dependency> getDependencies() {
if (!calculated) {
calculateNodesAndDependencies();
}
- return visitedDeps;
+ return Collections.unmodifiableSet(visitedDeps);
}
}
View
35 src/main/java/hudson/plugins/depgraph_view/DependencyGraphProjectAction.java
@@ -1,35 +0,0 @@
-package hudson.plugins.depgraph_view;
-
-import hudson.model.AbstractProject;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.logging.Logger;
-
-import org.kohsuke.stapler.StaplerRequest;
-
-
-
-public final class DependencyGraphProjectAction extends AbstractDependencyGraphAction {
- Logger LOGGER = Logger.getLogger(DependencyGraphProperty.class.getName());
-
- final private AbstractProject<?, ?> project;
-
- public DependencyGraphProjectAction(AbstractProject<?, ?> project) {
- this.project = project;
- }
-
- public AbstractProject<?, ?> getProject() {
- return project;
- }
-
- @Override
- protected Collection<AbstractProject<?, ?>> getProjectsForDepgraph(StaplerRequest req) {
- return Collections.<AbstractProject<?, ?>>singleton(project);
- }
-
- @Override
- public String getTitle() {
- return Messages.AbstractDependencyGraphAction_DependencyGraphOf(project.getDisplayName());
- }
-}
View
27 src/main/java/hudson/plugins/depgraph_view/DependencyGraphProjectActionFactory.java
@@ -1,9 +1,11 @@
package hudson.plugins.depgraph_view;
import hudson.Extension;
+import hudson.model.AbstractModelObject;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.TransientProjectActionFactory;
+import org.kohsuke.stapler.StaplerRequest;
import java.util.Collection;
import java.util.Collections;
@@ -15,8 +17,33 @@
*/
@Extension
public class DependencyGraphProjectActionFactory extends TransientProjectActionFactory {
+
+ public static final class DependencyGraphProjectAction extends AbstractDependencyGraphAction {
+ final private AbstractProject<?, ?> project;
+
+ public DependencyGraphProjectAction(AbstractProject<?, ?> project) {
+ this.project = project;
+ }
+
+ @Override
+ protected Collection<AbstractProject<?, ?>> getProjectsForDepgraph(StaplerRequest req) {
+ return Collections.<AbstractProject<?, ?>>singleton(project);
+ }
+
+ @Override
+ public String getTitle() {
+ return Messages.AbstractDependencyGraphAction_DependencyGraphOf(project.getDisplayName());
+ }
+
+ @Override
+ public AbstractModelObject getParentObject() {
+ return project;
+ }
+ }
+
@Override
public Collection<? extends Action> createFor(AbstractProject target) {
return Collections.singleton(new DependencyGraphProjectAction(target));
}
+
}
View
9 src/main/java/hudson/plugins/depgraph_view/DependencyGraphProperty.java
@@ -2,19 +2,12 @@
import hudson.Extension;
import hudson.Functions;
-import hudson.Launcher;
import hudson.Util;
-import hudson.model.*;
+import hudson.model.Node;
import hudson.slaves.NodeProperty;
import hudson.slaves.NodePropertyDescriptor;
import hudson.util.FormValidation;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-
import net.sf.json.JSONObject;
-
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
View
43 src/main/java/hudson/plugins/depgraph_view/DependencyGraphRootAction.java
@@ -1,43 +0,0 @@
-package hudson.plugins.depgraph_view;
-
-import hudson.Extension;
-import hudson.model.*;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.kohsuke.stapler.StaplerRequest;
-
-
-public class DependencyGraphRootAction extends AbstractDependencyGraphAction
- implements Action {
-
- private View view;
-
- public DependencyGraphRootAction(View view) {
- this.view = view;
- }
-
- @Override
- protected Collection<? extends AbstractProject<?, ?>> getProjectsForDepgraph(StaplerRequest req) {
- Collection<TopLevelItem> items = view.getItems();
- List<AbstractProject<?,?>> projects = new ArrayList<AbstractProject<?,?>>();
- for (TopLevelItem item : items) {
- if (item instanceof AbstractProject<?, ?>) {
- projects.add((AbstractProject<?, ?>) item);
- }
- }
- return projects;
- }
-
- @Override
- public String getTitle() {
- return Messages.AbstractDependencyGraphAction_DependencyGraphOf(view.getDisplayName());
- }
-
- public View getView() {
- return view;
- }
-
-}
View
40 src/main/java/hudson/plugins/depgraph_view/DependencyGraphViewActionFactory.java
@@ -1,10 +1,11 @@
package hudson.plugins.depgraph_view;
import hudson.Extension;
-import hudson.model.Action;
-import hudson.model.TransientViewActionFactory;
-import hudson.model.View;
+import hudson.model.*;
+import org.kohsuke.stapler.StaplerRequest;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -15,8 +16,41 @@
*/
@Extension
public class DependencyGraphViewActionFactory extends TransientViewActionFactory {
+ public static class DependencyGraphRootAction extends AbstractDependencyGraphAction
+ implements Action {
+
+ private View view;
+
+ public DependencyGraphRootAction(View view) {
+ this.view = view;
+ }
+
+ @Override
+ protected Collection<? extends AbstractProject<?, ?>> getProjectsForDepgraph(StaplerRequest req) {
+ Collection<TopLevelItem> items = view.getItems();
+ Collection<AbstractProject<?,?>> projects = new ArrayList<AbstractProject<?,?>>();
+ for (TopLevelItem item : items) {
+ if (item instanceof AbstractProject<?, ?>) {
+ projects.add((AbstractProject<?, ?>) item);
+ }
+ }
+ return projects;
+ }
+
+ @Override
+ public String getTitle() {
+ return Messages.AbstractDependencyGraphAction_DependencyGraphOf(view.getDisplayName());
+ }
+
+ @Override
+ public AbstractModelObject getParentObject() {
+ return view;
+ }
+ }
+
@Override
public List<Action> createFor(View v) {
return Collections.<Action>singletonList(new DependencyGraphRootAction(v));
}
+
}
View
4 src/main/resources/hudson/plugins/depgraph_view/DependencyGraphProjectAction/index.jelly
@@ -1,4 +0,0 @@
-<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:sv="/lib/sectioned_view" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
-<j:set var="parentObject" value="${it.project}" />
-<st:include it="${it}" page="mainPanel.jelly"/>
-</j:jelly>
View
4 src/main/resources/hudson/plugins/depgraph_view/DependencyGraphRootAction/index.jelly
@@ -1,4 +0,0 @@
-<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
-<j:set var="parentObject" value="${it.view}" />
-<st:include it="${it}" page="mainPanel.jelly"/>
-</j:jelly>
Please sign in to comment.
Something went wrong with that request. Please try again.