diff --git a/hudson/manifest.mf b/hudson/manifest.mf --- a/hudson/manifest.mf +++ b/hudson/manifest.mf @@ -2,5 +2,5 @@ OpenIDE-Module: org.netbeans.modules.hudson OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/hudson/Bundle.properties OpenIDE-Module-Layer: org/netbeans/modules/hudson/layer.xml -OpenIDE-Module-Specification-Version: 1.26 +OpenIDE-Module-Specification-Version: 1.27 diff --git a/hudson/src/org/netbeans/modules/hudson/api/HudsonInstance.java b/hudson/src/org/netbeans/modules/hudson/api/HudsonInstance.java --- a/hudson/src/org/netbeans/modules/hudson/api/HudsonInstance.java +++ b/hudson/src/org/netbeans/modules/hudson/api/HudsonInstance.java @@ -46,6 +46,7 @@ import java.util.Collection; import java.util.prefs.Preferences; +import javax.swing.Action; import org.openide.awt.ActionReference; /** @@ -146,6 +147,7 @@ new Persistence(true); private boolean isPersistent; private String info; + private Action newJobAction = null; /** * Constructor for persistence settings that use default info message. @@ -158,9 +160,10 @@ /** * Constructor for persistence settings that use custom info message. */ - public Persistence(boolean isPersistent, String info) { + public Persistence(boolean isPersistent, String info, Action newJob) { this.isPersistent = isPersistent; this.info = (info == null ? "" : info); //NOI18N + this.newJobAction = newJob; } /** @@ -181,7 +184,15 @@ * Transient instance with a custom info message. */ public static Persistence tranzient(String info) { - return new Persistence(false, info); + return new Persistence(false, info, null); + } + + /** + * Transient instance with a custom info message and custom "New Build" + * action. + */ + public static Persistence tranzient(String info, Action newJob) { + return new Persistence(false, info, newJob); } /** @@ -216,5 +227,12 @@ public boolean isPersistent() { return isPersistent; } + + /** + * @return Custom "New Build" action, can be null. + */ + public Action getNewJobAction() { + return newJobAction; + } } } diff --git a/hudson/src/org/netbeans/modules/hudson/api/HudsonManager.java b/hudson/src/org/netbeans/modules/hudson/api/HudsonManager.java --- a/hudson/src/org/netbeans/modules/hudson/api/HudsonManager.java +++ b/hudson/src/org/netbeans/modules/hudson/api/HudsonManager.java @@ -89,7 +89,7 @@ HudsonInstanceProperties props = new HudsonInstanceProperties(name, url, Integer.toString(sync)); props.put(INSTANCE_PERSISTED, persistence.isPersistent() ? TRUE : FALSE); HudsonInstanceImpl nue = HudsonInstanceImpl.createHudsonInstance( - props, true, persistence.getInfo(null)); + props, true, persistence); HudsonManagerImpl.getDefault().addInstance(nue); return nue; } diff --git a/hudson/src/org/netbeans/modules/hudson/impl/HudsonInstanceImpl.java b/hudson/src/org/netbeans/modules/hudson/impl/HudsonInstanceImpl.java --- a/hudson/src/org/netbeans/modules/hudson/impl/HudsonInstanceImpl.java +++ b/hudson/src/org/netbeans/modules/hudson/impl/HudsonInstanceImpl.java @@ -96,7 +96,7 @@ private HudsonInstanceProperties properties; private BuilderConnector builderConnector; - private String info; // additional info for transient instances + private Persistence persistence; private HudsonVersion version; private boolean connected; @@ -118,10 +118,10 @@ private final Map> workspaces = new HashMap>(); private final Map> artifacts = new HashMap>(); - private HudsonInstanceImpl(HudsonInstanceProperties properties, boolean interactive, BuilderConnector builderConnector, String info) { + private HudsonInstanceImpl(HudsonInstanceProperties properties, boolean interactive, BuilderConnector builderConnector, Persistence persistence) { this.builderConnector = builderConnector; this.properties = properties; - this.info = info; + this.persistence = persistence; RP = new RequestProcessor(getUrl(), 1, true); final AtomicBoolean firstSynch = new AtomicBoolean(interactive); // #200643 @@ -194,12 +194,12 @@ } public static HudsonInstanceImpl createHudsonInstance(HudsonInstanceProperties properties, boolean interactive) { - return createHudsonInstance(properties, interactive, null); + return createHudsonInstance(properties, interactive, Persistence.persistent()); } - public static HudsonInstanceImpl createHudsonInstance(HudsonInstanceProperties properties, boolean interactive, String info) { + public static HudsonInstanceImpl createHudsonInstance(HudsonInstanceProperties properties, boolean interactive, Persistence persistence) { HudsonConnector connector = new HudsonConnector(properties.get(HudsonInstanceConstants.INSTANCE_URL)); - HudsonInstanceImpl instance = new HudsonInstanceImpl(properties, interactive, connector, info); + HudsonInstanceImpl instance = new HudsonInstanceImpl(properties, interactive, connector, persistence); assert instance.getName() != null; assert instance.getUrl() != null; @@ -564,7 +564,7 @@ this.setViews(viewList, foundPrimaryView); } - public String getInfo() { - return info; + public Persistence getPersistence() { + return persistence; } } diff --git a/hudson/src/org/netbeans/modules/hudson/ui/actions/CreateJob.java b/hudson/src/org/netbeans/modules/hudson/ui/actions/CreateJob.java --- a/hudson/src/org/netbeans/modules/hudson/ui/actions/CreateJob.java +++ b/hudson/src/org/netbeans/modules/hudson/ui/actions/CreateJob.java @@ -54,6 +54,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.Action; import javax.swing.JButton; import org.netbeans.api.project.Project; import org.netbeans.api.project.ui.OpenProjects; @@ -110,6 +111,14 @@ "CreateJob.create=Create" }) @Override public void actionPerformed(ActionEvent e) { + if (instance instanceof HudsonInstanceImpl) { + Action custom = ((HudsonInstanceImpl) instance) + .getPersistence().getNewJobAction(); + if (custom != null) { + custom.actionPerformed(e); + return; + } + } final CreateJobPanel panel = new CreateJobPanel(); final DialogDescriptor dd = new DialogDescriptor(panel, CreateJob_title()); final AtomicReference dialog = new AtomicReference(); diff --git a/hudson/src/org/netbeans/modules/hudson/ui/nodes/HudsonInstanceNode.java b/hudson/src/org/netbeans/modules/hudson/ui/nodes/HudsonInstanceNode.java --- a/hudson/src/org/netbeans/modules/hudson/ui/nodes/HudsonInstanceNode.java +++ b/hudson/src/org/netbeans/modules/hudson/ui/nodes/HudsonInstanceNode.java @@ -140,10 +140,10 @@ }) private String getProjectInfoString() { boolean pers = instance.isPersisted(); - String info = instance.getInfo(); + String info = instance.getPersistence().getInfo( + HudsonInstanceNode_from_open_project()); return (!pers ? " " + // NOI18N - (info == null ? HudsonInstanceNode_from_open_project() : info) - + "" : ""); //NOI18N + info + "" : ""); //NOI18N } public @Override Action[] getActions(boolean context) {