Log Message
added ConsoleNoteButton
Modified Paths
Added Paths
Diff
Added: trunk/hudson/plugins/vncviewer/src/main/java/org/jenkinsci/plugins/vncviewer/ConsoleNoteButton.java (0 => 41301)
--- trunk/hudson/plugins/vncviewer/src/main/java/org/jenkinsci/plugins/vncviewer/ConsoleNoteButton.java (rev 0)
+++ trunk/hudson/plugins/vncviewer/src/main/java/org/jenkinsci/plugins/vncviewer/ConsoleNoteButton.java 2015-03-27 17:08:49 UTC (rev 41301)
@@ -0,0 +1,53 @@
+package org.jenkinsci.plugins.vncviewer;
+
+import hudson.Extension;
+import hudson.MarkupText;
+import hudson.console.ConsoleAnnotationDescriptor;
+import hudson.console.ConsoleAnnotator;
+import hudson.console.ConsoleNote;
+import hudson.console.HyperlinkNote;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class ConsoleNoteButton extends ConsoleNote {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final String caption;
+ private final String html;
+
+ public ConsoleNoteButton(String caption, String html) {
+ this.caption = caption;
+ this.html = html;
+ }
+
+ @Override
+ public ConsoleAnnotator annotate(Object context, MarkupText text, int charPos) {
+ text.addMarkup(charPos,
+// "<input type=button value='"+caption+"' _onClick_='reveal-expandable-detail'><div class='expandable-detail'>"+html+"</div>");
+ "<a href="" html + "\" target=\"new\"><button>" + caption + "</button></a>");
+ return null;
+ }
+
+ public static String encodeTo(String buttonCaption, String html) {
+ try {
+ return new ConsoleNoteButton(buttonCaption, html).encode();
+ } catch (IOException e) {
+ // impossible, but don't make this a fatal problem
+ LOGGER.log(Level.WARNING, "Failed to serialize "+HyperlinkNote.class,e);
+ return "";
+ }
+ }
+
+ @Extension
+ public static final class DescriptorImpl extends ConsoleAnnotationDescriptor {
+ public String getDisplayName() {
+ return "Button";
+ }
+ }
+
+ private static final Logger LOGGER = Logger.getLogger(ConsoleNoteButton.class.getName());
+}
\ No newline at end of file
Property changes on: trunk/hudson/plugins/vncviewer/src/main/java/org/jenkinsci/plugins/vncviewer/ConsoleNoteButton.java
___________________________________________________________________
Added: svn:mime-type
Modified: trunk/hudson/plugins/vncviewer/src/main/java/org/jenkinsci/plugins/vncviewer/VncViewerBuildWrapper.java (41300 => 41301)
--- trunk/hudson/plugins/vncviewer/src/main/java/org/jenkinsci/plugins/vncviewer/VncViewerBuildWrapper.java 2015-03-27 16:11:50 UTC (rev 41300)
+++ trunk/hudson/plugins/vncviewer/src/main/java/org/jenkinsci/plugins/vncviewer/VncViewerBuildWrapper.java 2015-03-27 17:08:49 UTC (rev 41301)
@@ -28,7 +28,6 @@
import hudson.Launcher.LocalLauncher;
import hudson.Proc;
import hudson.Util;
-import hudson.console.ExpandableDetailsNote;
import hudson.model.BuildListener;
import hudson.model.Item;
import hudson.model.AbstractBuild;
@@ -39,7 +38,6 @@
import hudson.util.FormValidation;
import java.io.BufferedOutputStream;
-import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -82,7 +80,6 @@
int startPortNmb = 8888;
Proc noVncProc = null;
String lp = String.valueOf(startPortNmb);
- final ByteArrayOutputStream loggingStream = new ByteArrayOutputStream();
if (vncServReplaced.isEmpty())
vncServReplaced = DESCRIPTOR.getDefaultVncServ();
@@ -109,7 +106,7 @@
for (int i = 0; i < 1000 ; i++ )
{
lp = String.valueOf(startPortNmb + i);
- noVncProc = localLauncher.launch().stderr(loggingStream).stdout(loggingStream).cmds(webSockifyPath, "--web", webPath,lp,vncServReplaced).start();
+ noVncProc = localLauncher.launch().stderr(listener.getLogger()).stdout(listener.getLogger()).cmds(webSockifyPath, "--web", webPath,lp,vncServReplaced).start();
Thread.sleep(5000);
if (noVncProc.isAlive())
{
@@ -129,23 +126,16 @@
String url = "" + hostAddr + ":" + lp + "/vnc_auto.html?host=" + hostAddr + "&port=" + lp;
String txt = "Start vnc viewer for " + vncServReplaced;
listener.getLogger().print('\n');
- listener.annotate(new VncHyperlinkNote(url,txt.length()));
- listener.getLogger().print(txt);
+ listener.annotate(new ConsoleNoteButton(txt,url));
listener.getLogger().print("\n\n");
final Proc noVncProcFinal = noVncProc;
return new Environment() {
@Override
public boolean tearDown(AbstractBuild build, BuildListener listener)
throws IOException, InterruptedException {
- try {
-
- listener.annotate(new ExpandableDetailsNote("VNC viewer logs",loggingStream.toString()));
- listener.getLogger().print('\n');
- noVncProcFinal.kill();
- loggingStream.close();
- }
- catch (Exception e)
- {}
+ try {noVncProcFinal.getStderr().close();}catch (Exception e){}
+ try {noVncProcFinal.getStdout().close();}catch (Exception e){}
+ try {noVncProcFinal.kill();}catch (Exception e){}
return true;
}
};
@@ -174,7 +164,7 @@
{
return FormValidation.errorWithMarkup("Vnc server can't be empty!" );
}
- return FormValidation.okWithMarkup("<strong><font color=\"blue\">Please, make sure that your vncserer is running on '" + value + "'</font></strong>");
+ return FormValidation.okWithMarkup("<strong><font color=\"blue\">Please, make sure that your vncserver is running on '" + value + "'</font></strong>");
}
@Override
You received this message because you are subscribed to the Google Groups "Jenkins Commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-commits+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.