Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 154151 Details for
Bug 282483
[Publishing] Allow publish *only* on build events rather than resource change events
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
New Patch, runs auto-publish on project close / delete events
282483b.patch (text/plain), 16.30 KB, created by
Rob Stryker
on 2009-12-09 15:39:20 EST
(
hide
)
Description:
New Patch, runs auto-publish on project close / delete events
Filename:
MIME Type:
Creator:
Rob Stryker
Created:
2009-12-09 15:39:20 EST
Size:
16.30 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.server.core >Index: servercore/org/eclipse/wst/server/core/internal/ResourceManager.java >=================================================================== >RCS file: /cvsroot/webtools/servertools/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ResourceManager.java,v >retrieving revision 1.62 >diff -u -r1.62 ResourceManager.java >--- servercore/org/eclipse/wst/server/core/internal/ResourceManager.java 28 Sep 2009 20:33:33 -0000 1.62 >+++ servercore/org/eclipse/wst/server/core/internal/ResourceManager.java 9 Dec 2009 20:42:03 -0000 >@@ -90,7 +90,7 @@ > * > * @param event a resource change event > */ >- public void resourceChanged(IResourceChangeEvent event) { >+ public void resourceChanged(final IResourceChangeEvent event) { > IResourceDelta delta = event.getDelta(); > if (delta == null) > return; >@@ -98,7 +98,7 @@ > // ignore clean builds > if (event.getBuildKind() == IncrementalProjectBuilder.CLEAN_BUILD) > return; >- >+ > Trace.trace(Trace.RESOURCES, "->- ServerResourceChangeListener responding to resource change: " + event.getType() + " ->-"); > IResourceDelta[] children = delta.getAffectedChildren(); > if (children != null) { >@@ -119,7 +119,7 @@ > > // only respond to project changes > if (resource != null && resource instanceof IProject) { >- publishHandleProjectChange(visitorDelta); >+ publishHandleProjectChange(visitorDelta, event); > return false; > } > return true; >@@ -950,6 +950,17 @@ > * @param delta org.eclipse.core.resources.IResourceDelta > */ > protected void publishHandleProjectChange(IResourceDelta delta) { >+ publishHandleProjectChange(delta, null); >+ } >+ >+ /** >+ * A project has changed. If this is an add or remove, check >+ * to see if it is part of a current server configuration. >+ * >+ * @param delta org.eclipse.core.resources.IResourceDelta >+ * @param buildEvent whether this event was a build event >+ */ >+ protected void publishHandleProjectChange(IResourceDelta delta, IResourceChangeEvent event) { > Trace.trace(Trace.FINEST, "> publishHandleProjectChange " + delta.getResource()); > IProject project = (IProject) delta.getResource(); > >@@ -974,7 +985,7 @@ > for (int i = 0; i < size; i++) { > for (int j = 0; j < size2; j++) { > if (servers2[j].getAdapter(ServerDelegate.class) != null) >- ((Server) servers2[j]).handleModuleProjectChange(modules[i]); >+ ((Server) servers2[j]).handleModuleProjectChange(modules[i], event); > } > } > Trace.trace(Trace.FINEST, "< publishHandleProjectChange"); >Index: servercore/org/eclipse/wst/server/core/internal/Server.java >=================================================================== >RCS file: /cvsroot/webtools/servertools/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java,v >retrieving revision 1.170 >diff -u -r1.170 Server.java >--- servercore/org/eclipse/wst/server/core/internal/Server.java 25 Sep 2009 19:00:59 -0000 1.170 >+++ servercore/org/eclipse/wst/server/core/internal/Server.java 9 Dec 2009 20:42:03 -0000 >@@ -50,7 +50,9 @@ > public static final String FILE_EXTENSION = "server"; > > public static final int AUTO_PUBLISH_DISABLE = 1; >- public static final int AUTO_PUBLISH_ENABLE = 2; >+ public static final int AUTO_PUBLISH_RESOURCE = 2; >+ public static final int AUTO_PUBLISH_BUILD = 3; >+ > > protected static final String PROP_HOSTNAME = "hostname"; > protected static final String SERVER_ID = "server-id"; >@@ -159,10 +161,15 @@ > > public class ResourceChangeJob extends ServerJob { > private IModule module; >- >+ private IResourceChangeEvent event; >+ > public ResourceChangeJob(IModule module) { >+ this(module, null); >+ } >+ public ResourceChangeJob(IModule module, IResourceChangeEvent event) { > super(NLS.bind(Messages.jobUpdateServer, Server.this.getName())); > this.module = module; >+ this.event = event; > > if (module.getProject() == null) > setRule(Server.this); >@@ -214,7 +221,7 @@ > behaviourDelegate.handleResourceChange(); > > if (getServerState() == IServer.STATE_STARTED) >- autoPublish(); >+ autoPublish(event); > > return Status.OK_STATUS; > } >@@ -475,7 +482,7 @@ > } > > public int getAutoPublishSetting() { >- return getAttribute(PROP_AUTO_PUBLISH_SETTING, AUTO_PUBLISH_ENABLE); >+ return getAttribute(PROP_AUTO_PUBLISH_SETTING, AUTO_PUBLISH_RESOURCE); > } > > public int getStartTimeout() { >@@ -743,6 +750,10 @@ > } > > protected void handleModuleProjectChange(IModule module) { >+ handleModuleProjectChange(module, null); >+ } >+ >+ protected void handleModuleProjectChange(IModule module, IResourceChangeEvent buildEvent) { > Trace.trace(Trace.FINEST, "> handleDeployableProjectChange() " + this + " " + module); > > // check for duplicate jobs already waiting and don't create a new one >@@ -758,7 +769,7 @@ > } > } > >- ResourceChangeJob job = new ResourceChangeJob(module); >+ ResourceChangeJob job = new ResourceChangeJob(module, buildEvent); > job.setSystem(true); > job.setPriority(Job.BUILD); > job.schedule(); >@@ -780,11 +791,22 @@ > * thread if automatic publishing is currently enabled. > */ > protected void autoPublish() { >+ autoPublish(null); >+ } >+ >+ protected void autoPublish(IResourceChangeEvent event) { >+ > stopAutoPublish(); >+ boolean buildOccurred = didBuildOccur(event); >+ boolean projectClosedOrDeleted = isProjectCloseOrDeleteEvent(event); > > if (getAutoPublishSetting() == AUTO_PUBLISH_DISABLE) > return; > >+ if( (getAutoPublishSetting() == AUTO_PUBLISH_BUILD) && >+ !buildOccurred && !projectClosedOrDeleted) >+ return; >+ > int time = getAutoPublishTime(); > if (time >= 0) { > autoPublishThread = new AutoPublishThread(); >@@ -794,6 +816,24 @@ > autoPublishThread.start(); > } > } >+ >+ private boolean isProjectCloseOrDeleteEvent(IResourceChangeEvent event) { >+ int kind = event.getType(); >+ if( (kind & IResourceChangeEvent.PRE_CLOSE) > 0 || >+ (kind & IResourceChangeEvent.PRE_DELETE) > 0) >+ return true; >+ return false; >+ } >+ >+ private boolean didBuildOccur(IResourceChangeEvent event) { >+ int kind = event.getBuildKind(); >+ final boolean eventOccurred = >+ (kind == IncrementalProjectBuilder.INCREMENTAL_BUILD) || >+ (kind == IncrementalProjectBuilder.FULL_BUILD) || >+ ((kind == IncrementalProjectBuilder.AUTO_BUILD && >+ ResourcesPlugin.getWorkspace().isAutoBuilding())); >+ return eventOccurred; >+ } > > /** > * Returns the event notification manager. >@@ -2018,9 +2058,9 @@ > configuration = ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(configPath)); > > // for migration from WTP 2.0 -> WTP 3.0 >- int autoPubSetting = getAttribute(PROP_AUTO_PUBLISH_SETTING, AUTO_PUBLISH_ENABLE); >+ int autoPubSetting = getAttribute(PROP_AUTO_PUBLISH_SETTING, AUTO_PUBLISH_RESOURCE); > if (autoPubSetting == 0) >- map.put(PROP_AUTO_PUBLISH_SETTING, AUTO_PUBLISH_ENABLE); >+ map.put(PROP_AUTO_PUBLISH_SETTING, AUTO_PUBLISH_RESOURCE); > } > > protected void setInternal(ServerWorkingCopy wc) { >#P org.eclipse.wst.server.ui >Index: serverui/org/eclipse/wst/server/ui/internal/Messages.java >=================================================================== >RCS file: /cvsroot/webtools/servertools/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java,v >retrieving revision 1.66 >diff -u -r1.66 Messages.java >--- serverui/org/eclipse/wst/server/ui/internal/Messages.java 2 Dec 2009 17:20:30 -0000 1.66 >+++ serverui/org/eclipse/wst/server/ui/internal/Messages.java 9 Dec 2009 20:42:05 -0000 >@@ -286,7 +286,8 @@ > public static String serverEditorOverviewPublishSection; > public static String serverEditorOverviewPublishDescription; > public static String serverEditorOverviewAutoPublishDisable; >- public static String serverEditorOverviewAutoPublishEnabled; >+ public static String serverEditorOverviewAutoPublishEnabledResource; >+ public static String serverEditorOverviewAutoPublishEnabledBuild; > public static String serverEditorOverviewAutoPublishEnabledInterval; > public static String serverEditorOverviewPublishCommand; > public static String serverEditorOverviewTimeoutSection; >Index: serverui/org/eclipse/wst/server/ui/internal/Messages.properties >=================================================================== >RCS file: /cvsroot/webtools/servertools/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties,v >retrieving revision 1.94 >diff -u -r1.94 Messages.properties >--- serverui/org/eclipse/wst/server/ui/internal/Messages.properties 2 Dec 2009 17:20:30 -0000 1.94 >+++ serverui/org/eclipse/wst/server/ui/internal/Messages.properties 9 Dec 2009 20:42:05 -0000 >@@ -447,7 +447,8 @@ > serverEditorOverviewPublishSection=Publishing > serverEditorOverviewPublishDescription=Modify settings for publishing. > serverEditorOverviewAutoPublishDisable=Never publish automatically >-serverEditorOverviewAutoPublishEnabled=Automatically publish when resources change >+serverEditorOverviewAutoPublishEnabledResource=Automatically publish when resources change >+serverEditorOverviewAutoPublishEnabledBuild=Automatically publish after a build event > serverEditorOverviewAutoPublishEnabledInterval=Publishing interval (in seconds): > serverEditorOverviewPublishCommand=modify publish settings > serverEditorOverviewPublishers=Select publishing actions: >Index: serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java >=================================================================== >RCS file: /cvsroot/webtools/servertools/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java,v >retrieving revision 1.63 >diff -u -r1.63 OverviewEditorPart.java >--- serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java 6 Nov 2008 16:34:53 -0000 1.63 >+++ serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java 9 Dec 2009 20:42:05 -0000 >@@ -93,7 +93,8 @@ > protected Combo runtimeCombo; > protected Button browse; > protected Button autoPublishDisable; >- protected Button autoPublishEnable; >+ protected Button autoPublishEnableResource; >+ protected Button autoPublishEnableBuild; > protected Spinner autoPublishTime; > protected Table publishersTable; > protected CheckboxTableViewer publishersViewer; >@@ -205,9 +206,10 @@ > } else if (event.getPropertyName().equals(Server.PROP_AUTO_PUBLISH_SETTING)) { > Integer autoPublishSetting = (Integer)event.getNewValue(); > int setting = autoPublishSetting.intValue(); >- autoPublishEnable.setSelection(setting == Server.AUTO_PUBLISH_ENABLE); >+ autoPublishEnableResource.setSelection(setting == Server.AUTO_PUBLISH_RESOURCE); >+ autoPublishEnableBuild.setSelection(setting == Server.AUTO_PUBLISH_BUILD); > autoPublishDisable.setSelection(setting == Server.AUTO_PUBLISH_DISABLE); >- autoPublishTime.setEnabled(setting == Server.AUTO_PUBLISH_ENABLE); >+ autoPublishTime.setEnabled(setting != Server.AUTO_PUBLISH_DISABLE); > validate(); > } else if (event.getPropertyName().equals(Server.PROP_START_TIMEOUT)) { > Integer time = (Integer)event.getNewValue(); >@@ -619,18 +621,26 @@ > autoPublishDisable.setSelection(publishSetting == Server.AUTO_PUBLISH_DISABLE); > whs.setHelp(autoPublishDisable, ContextIds.EDITOR_AUTOPUBLISH_DISABLE); > >- autoPublishEnable = toolkit.createButton(composite, Messages.serverEditorOverviewAutoPublishEnabled, SWT.RADIO); >- autoPublishEnable.setSelection(publishSetting == Server.AUTO_PUBLISH_ENABLE); >+ autoPublishEnableResource = toolkit.createButton(composite, Messages.serverEditorOverviewAutoPublishEnabledResource, SWT.RADIO); >+ autoPublishEnableResource.setSelection(publishSetting == Server.AUTO_PUBLISH_RESOURCE); > data = new GridData(GridData.FILL_HORIZONTAL); > data.horizontalSpan = 2; >- autoPublishEnable.setLayoutData(data); >- whs.setHelp(autoPublishEnable, ContextIds.EDITOR_AUTOPUBLISH_ENABLE); >+ autoPublishEnableResource.setLayoutData(data); >+ whs.setHelp(autoPublishEnableResource, ContextIds.EDITOR_AUTOPUBLISH_ENABLE); >+ >+ autoPublishEnableBuild = toolkit.createButton(composite, Messages.serverEditorOverviewAutoPublishEnabledBuild, SWT.RADIO); >+ autoPublishEnableBuild .setSelection(publishSetting == Server.AUTO_PUBLISH_RESOURCE); >+ data = new GridData(GridData.FILL_HORIZONTAL); >+ data.horizontalSpan = 2; >+ autoPublishEnableBuild.setLayoutData(data); >+ whs.setHelp(autoPublishEnableBuild, ContextIds.EDITOR_AUTOPUBLISH_ENABLE); >+ > > final Label autoPublishTimeLabel = createLabel(toolkit,composite, Messages.serverEditorOverviewAutoPublishEnabledInterval); > data = new GridData(); > data.horizontalIndent = 20; > autoPublishTimeLabel.setLayoutData(data); >- autoPublishTimeLabel.setEnabled(autoPublishEnable.getSelection()); >+ autoPublishTimeLabel.setEnabled(!autoPublishDisable.getSelection()); > > autoPublishTime = new Spinner(composite, SWT.BORDER); > autoPublishTime.setMinimum(0); >@@ -640,23 +650,36 @@ > data = new GridData(GridData.HORIZONTAL_ALIGN_END); > data.widthHint = 30; > autoPublishTime.setLayoutData(data); >- autoPublishTime.setEnabled(autoPublishEnable.getSelection()); >+ autoPublishTime.setEnabled(!autoPublishDisable.getSelection()); > SWTUtil.setSpinnerTooltip(autoPublishTime); > whs.setHelp(autoPublishTime, ContextIds.EDITOR_AUTOPUBLISH_ENABLE); > >- autoPublishEnable.addSelectionListener(new SelectionAdapter() { >+ autoPublishEnableResource.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { >- if (updating || !autoPublishEnable.getSelection()) >+ if (updating || !autoPublishEnableResource.getSelection()) > return; > updating = true; >- execute(new SetServerAutoPublishDefaultCommand(getServer(), Server.AUTO_PUBLISH_ENABLE)); >+ execute(new SetServerAutoPublishDefaultCommand(getServer(), Server.AUTO_PUBLISH_RESOURCE)); > updating = false; >- autoPublishTimeLabel.setEnabled(autoPublishEnable.getSelection()); >- autoPublishTime.setEnabled(autoPublishEnable.getSelection()); >+ autoPublishTimeLabel.setEnabled(!autoPublishDisable.getSelection()); >+ autoPublishTime.setEnabled(!autoPublishDisable.getSelection()); > validate(); > } > }); >- >+ >+ autoPublishEnableBuild.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ if (updating || !autoPublishEnableBuild.getSelection()) >+ return; >+ updating = true; >+ execute(new SetServerAutoPublishDefaultCommand(getServer(), Server.AUTO_PUBLISH_BUILD)); >+ updating = false; >+ autoPublishTimeLabel.setEnabled(!autoPublishDisable.getSelection()); >+ autoPublishTime.setEnabled(!autoPublishDisable.getSelection()); >+ validate(); >+ } >+ }); >+ > autoPublishDisable.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { > if (updating || !autoPublishDisable.getSelection()) >@@ -664,8 +687,8 @@ > updating = true; > execute(new SetServerAutoPublishDefaultCommand(getServer(), Server.AUTO_PUBLISH_DISABLE)); > updating = false; >- autoPublishTimeLabel.setEnabled(autoPublishEnable.getSelection()); >- autoPublishTime.setEnabled(autoPublishEnable.getSelection()); >+ autoPublishTimeLabel.setEnabled(!autoPublishDisable.getSelection()); >+ autoPublishTime.setEnabled(!autoPublishDisable.getSelection()); > validate(); > } > }); >@@ -952,17 +975,20 @@ > Server svr = (Server) server; > int publishSetting = svr.getAutoPublishSetting(); > autoPublishDisable.setSelection(publishSetting == Server.AUTO_PUBLISH_DISABLE); >- autoPublishEnable.setSelection(publishSetting == Server.AUTO_PUBLISH_ENABLE); >+ autoPublishEnableResource.setSelection(publishSetting == Server.AUTO_PUBLISH_RESOURCE); >+ autoPublishEnableBuild.setSelection(publishSetting == Server.AUTO_PUBLISH_BUILD); > autoPublishTime.setSelection(svr.getAutoPublishTime()); > > if (readOnly) { > autoPublishDisable.setEnabled(false); >- autoPublishEnable.setEnabled(false); >+ autoPublishEnableResource.setEnabled(false); >+ autoPublishEnableBuild.setEnabled(false); > autoPublishTime.setEnabled(false); > } else { > autoPublishDisable.setEnabled(true); >- autoPublishEnable.setEnabled(true); >- autoPublishTime.setEnabled(publishSetting == Server.AUTO_PUBLISH_ENABLE); >+ autoPublishEnableResource.setEnabled(true); >+ autoPublishEnableBuild.setEnabled(true); >+ autoPublishTime.setEnabled(publishSetting != Server.AUTO_PUBLISH_DISABLE); > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
arvera
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 282483
:
140835
|
141038
| 154151 |
156898
|
164050