mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 21:42:27 +00:00
Merged ff1f60905e
Conflicts: changelog.html pom.xml test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java
This commit is contained in:
commit
6a2dad3134
17 files changed
+483
-138
No files matched your search
@@ -0,0 +1,30 @@
|
||||
package hudson;
|
||||
|
||||
import hudson.model.ManagementLink;
|
||||
|
||||
/**
|
||||
* Show "About Jenkins" link.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
@Extension
|
||||
public class AboutJenkins extends ManagementLink {
|
||||
@Override
|
||||
public String getIconFileName() {
|
||||
return "help.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrlName() {
|
||||
return "about";
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return Messages.AboutJenkins_DisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Messages.AboutJenkins_Description();
|
||||
}
|
||||
}
|
||||
@@ -397,6 +397,15 @@ public class PluginWrapper implements Comparable<PluginWrapper> {
|
||||
return manifest.getMainAttributes().getValue("Plugin-Class");
|
||||
}
|
||||
|
||||
public boolean hasLicensesXml() {
|
||||
try {
|
||||
new URL(baseResourceURL,"WEB-INF/licenses.xml").openStream().close();
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes sure that all the dependencies exist, and then accept optional dependencies
|
||||
* as real dependencies.
|
||||
|
||||
@@ -28,14 +28,7 @@ import hudson.security.ACL;
|
||||
import hudson.security.NotSerilizableSecurityContext;
|
||||
import org.acegisecurity.context.SecurityContext;
|
||||
import org.acegisecurity.context.SecurityContextHolder;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
import org.kohsuke.graph_layouter.Layout;
|
||||
import org.kohsuke.graph_layouter.Navigator;
|
||||
import org.kohsuke.graph_layouter.Direction;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -49,17 +42,6 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import java.io.IOException;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Color;
|
||||
import java.awt.Point;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
* Maintains the build dependencies between {@link AbstractProject}s
|
||||
@@ -319,97 +301,97 @@ public final class DependencyGraph implements Comparator<AbstractProject> {
|
||||
return Collections.unmodifiableMap(m);
|
||||
}
|
||||
|
||||
/**
|
||||
* Experimental visualization of project dependencies.
|
||||
*/
|
||||
public void doGraph( StaplerRequest req, StaplerResponse rsp ) throws IOException {
|
||||
// Require admin permission for now (avoid exposing project names with restricted permissions)
|
||||
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
|
||||
try {
|
||||
|
||||
// creates a dummy graphics just so that we can measure font metrics
|
||||
BufferedImage emptyImage = new BufferedImage(1,1, BufferedImage.TYPE_INT_RGB );
|
||||
Graphics2D graphics = emptyImage.createGraphics();
|
||||
graphics.setFont(FONT);
|
||||
final FontMetrics fontMetrics = graphics.getFontMetrics();
|
||||
|
||||
// TODO: timestamp check
|
||||
Layout<AbstractProject> layout = new Layout<AbstractProject>(new Navigator<AbstractProject>() {
|
||||
public Collection<AbstractProject> vertices() {
|
||||
// only include projects that have some dependency
|
||||
List<AbstractProject> r = new ArrayList<AbstractProject>();
|
||||
for (AbstractProject p : Hudson.getInstance().getAllItems(AbstractProject.class)) {
|
||||
if(!getDownstream(p).isEmpty() || !getUpstream(p).isEmpty())
|
||||
r.add(p);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
public Collection<AbstractProject> edge(AbstractProject p) {
|
||||
return getDownstream(p);
|
||||
}
|
||||
|
||||
public Dimension getSize(AbstractProject p) {
|
||||
int w = fontMetrics.stringWidth(p.getDisplayName()) + MARGIN*2;
|
||||
return new Dimension(w, fontMetrics.getHeight() + MARGIN*2);
|
||||
}
|
||||
}, Direction.LEFTRIGHT);
|
||||
|
||||
Rectangle area = layout.calcDrawingArea();
|
||||
area.grow(4,4); // give it a bit of margin
|
||||
BufferedImage image = new BufferedImage(area.width, area.height, BufferedImage.TYPE_INT_RGB );
|
||||
Graphics2D g2 = image.createGraphics();
|
||||
g2.setTransform(AffineTransform.getTranslateInstance(-area.x,-area.y));
|
||||
g2.setPaint(Color.WHITE);
|
||||
g2.fill(area);
|
||||
g2.setFont(FONT);
|
||||
|
||||
g2.setPaint(Color.BLACK);
|
||||
for( AbstractProject p : layout.vertices() ) {
|
||||
final Point sp = center(layout.vertex(p));
|
||||
|
||||
for (AbstractProject q : layout.edges(p)) {
|
||||
Point cur=sp;
|
||||
for( Point pt : layout.edge(p,q) ) {
|
||||
g2.drawLine(cur.x, cur.y, pt.x, pt.y);
|
||||
cur=pt;
|
||||
}
|
||||
|
||||
final Point ep = center(layout.vertex(q));
|
||||
g2.drawLine(cur.x, cur.y, ep.x, ep.y);
|
||||
}
|
||||
}
|
||||
|
||||
int diff = fontMetrics.getAscent()+fontMetrics.getLeading()/2;
|
||||
|
||||
for( AbstractProject p : layout.vertices() ) {
|
||||
Rectangle r = layout.vertex(p);
|
||||
g2.setPaint(Color.WHITE);
|
||||
g2.fillRect(r.x, r.y, r.width, r.height);
|
||||
g2.setPaint(Color.BLACK);
|
||||
g2.drawRect(r.x, r.y, r.width, r.height);
|
||||
g2.drawString(p.getDisplayName(), r.x+MARGIN, r.y+MARGIN+ diff);
|
||||
}
|
||||
|
||||
rsp.setContentType("image/png");
|
||||
ServletOutputStream os = rsp.getOutputStream();
|
||||
ImageIO.write(image, "PNG", os);
|
||||
os.close();
|
||||
} catch(HeadlessException e) {
|
||||
// not available. send out error message
|
||||
rsp.sendRedirect2(req.getContextPath()+"/images/headless.png");
|
||||
}
|
||||
}
|
||||
|
||||
private Point center(Rectangle r) {
|
||||
return new Point(r.x+r.width/2,r.y+r.height/2);
|
||||
}
|
||||
|
||||
private static final Font FONT = new Font("TimesRoman", Font.PLAIN, 10);
|
||||
/**
|
||||
* Margins between the project name and its bounding box.
|
||||
*/
|
||||
private static final int MARGIN = 4;
|
||||
// /**
|
||||
// * Experimental visualization of project dependencies.
|
||||
// */
|
||||
// public void doGraph( StaplerRequest req, StaplerResponse rsp ) throws IOException {
|
||||
// // Require admin permission for now (avoid exposing project names with restricted permissions)
|
||||
// Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
|
||||
// try {
|
||||
//
|
||||
// // creates a dummy graphics just so that we can measure font metrics
|
||||
// BufferedImage emptyImage = new BufferedImage(1,1, BufferedImage.TYPE_INT_RGB );
|
||||
// Graphics2D graphics = emptyImage.createGraphics();
|
||||
// graphics.setFont(FONT);
|
||||
// final FontMetrics fontMetrics = graphics.getFontMetrics();
|
||||
//
|
||||
// // TODO: timestamp check
|
||||
// Layout<AbstractProject> layout = new Layout<AbstractProject>(new Navigator<AbstractProject>() {
|
||||
// public Collection<AbstractProject> vertices() {
|
||||
// // only include projects that have some dependency
|
||||
// List<AbstractProject> r = new ArrayList<AbstractProject>();
|
||||
// for (AbstractProject p : Hudson.getInstance().getAllItems(AbstractProject.class)) {
|
||||
// if(!getDownstream(p).isEmpty() || !getUpstream(p).isEmpty())
|
||||
// r.add(p);
|
||||
// }
|
||||
// return r;
|
||||
// }
|
||||
//
|
||||
// public Collection<AbstractProject> edge(AbstractProject p) {
|
||||
// return getDownstream(p);
|
||||
// }
|
||||
//
|
||||
// public Dimension getSize(AbstractProject p) {
|
||||
// int w = fontMetrics.stringWidth(p.getDisplayName()) + MARGIN*2;
|
||||
// return new Dimension(w, fontMetrics.getHeight() + MARGIN*2);
|
||||
// }
|
||||
// }, Direction.LEFTRIGHT);
|
||||
//
|
||||
// Rectangle area = layout.calcDrawingArea();
|
||||
// area.grow(4,4); // give it a bit of margin
|
||||
// BufferedImage image = new BufferedImage(area.width, area.height, BufferedImage.TYPE_INT_RGB );
|
||||
// Graphics2D g2 = image.createGraphics();
|
||||
// g2.setTransform(AffineTransform.getTranslateInstance(-area.x,-area.y));
|
||||
// g2.setPaint(Color.WHITE);
|
||||
// g2.fill(area);
|
||||
// g2.setFont(FONT);
|
||||
//
|
||||
// g2.setPaint(Color.BLACK);
|
||||
// for( AbstractProject p : layout.vertices() ) {
|
||||
// final Point sp = center(layout.vertex(p));
|
||||
//
|
||||
// for (AbstractProject q : layout.edges(p)) {
|
||||
// Point cur=sp;
|
||||
// for( Point pt : layout.edge(p,q) ) {
|
||||
// g2.drawLine(cur.x, cur.y, pt.x, pt.y);
|
||||
// cur=pt;
|
||||
// }
|
||||
//
|
||||
// final Point ep = center(layout.vertex(q));
|
||||
// g2.drawLine(cur.x, cur.y, ep.x, ep.y);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// int diff = fontMetrics.getAscent()+fontMetrics.getLeading()/2;
|
||||
//
|
||||
// for( AbstractProject p : layout.vertices() ) {
|
||||
// Rectangle r = layout.vertex(p);
|
||||
// g2.setPaint(Color.WHITE);
|
||||
// g2.fillRect(r.x, r.y, r.width, r.height);
|
||||
// g2.setPaint(Color.BLACK);
|
||||
// g2.drawRect(r.x, r.y, r.width, r.height);
|
||||
// g2.drawString(p.getDisplayName(), r.x+MARGIN, r.y+MARGIN+ diff);
|
||||
// }
|
||||
//
|
||||
// rsp.setContentType("image/png");
|
||||
// ServletOutputStream os = rsp.getOutputStream();
|
||||
// ImageIO.write(image, "PNG", os);
|
||||
// os.close();
|
||||
// } catch(HeadlessException e) {
|
||||
// // not available. send out error message
|
||||
// rsp.sendRedirect2(req.getContextPath()+"/images/headless.png");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private Point center(Rectangle r) {
|
||||
// return new Point(r.x+r.width/2,r.y+r.height/2);
|
||||
// }
|
||||
//
|
||||
// private static final Font FONT = new Font("TimesRoman", Font.PLAIN, 10);
|
||||
// /**
|
||||
// * Margins between the project name and its bounding box.
|
||||
// */
|
||||
// private static final int MARGIN = 4;
|
||||
|
||||
|
||||
private static final Comparator<Dependency> NAME_COMPARATOR = new Comparator<Dependency>() {
|
||||
|
||||
Reference in new issue
Block a user