View | Details | Raw Unified | Return to bug 282483 | Differences between
and this patch

Collapse All | Expand All

(-)servercore/org/eclipse/wst/server/core/internal/ResourceManager.java (-4 / +15 lines)
Lines 90-96 Link Here
90
		 * 
90
		 * 
91
		 * @param event a resource change event
91
		 * @param event a resource change event
92
		 */
92
		 */
93
		public void resourceChanged(IResourceChangeEvent event) {
93
		public void resourceChanged(final IResourceChangeEvent event) {
94
			IResourceDelta delta = event.getDelta();
94
			IResourceDelta delta = event.getDelta();
95
			if (delta == null)
95
			if (delta == null)
96
				return;
96
				return;
Lines 98-104 Link Here
98
			// ignore clean builds
98
			// ignore clean builds
99
			if (event.getBuildKind() == IncrementalProjectBuilder.CLEAN_BUILD)
99
			if (event.getBuildKind() == IncrementalProjectBuilder.CLEAN_BUILD)
100
				return;
100
				return;
101
			
101
								
102
			Trace.trace(Trace.RESOURCES, "->- ServerResourceChangeListener responding to resource change: " + event.getType() + " ->-");
102
			Trace.trace(Trace.RESOURCES, "->- ServerResourceChangeListener responding to resource change: " + event.getType() + " ->-");
103
			IResourceDelta[] children = delta.getAffectedChildren();
103
			IResourceDelta[] children = delta.getAffectedChildren();
104
			if (children != null) {
104
			if (children != null) {
Lines 119-125 Link Here
119
119
120
						// only respond to project changes
120
						// only respond to project changes
121
						if (resource != null && resource instanceof IProject) {
121
						if (resource != null && resource instanceof IProject) {
122
							publishHandleProjectChange(visitorDelta);
122
							publishHandleProjectChange(visitorDelta, event);
123
							return false;
123
							return false;
124
						}
124
						}
125
						return true;
125
						return true;
Lines 950-955 Link Here
950
	 * @param delta org.eclipse.core.resources.IResourceDelta
950
	 * @param delta org.eclipse.core.resources.IResourceDelta
951
	 */
951
	 */
952
	protected void publishHandleProjectChange(IResourceDelta delta) {
952
	protected void publishHandleProjectChange(IResourceDelta delta) {
953
		publishHandleProjectChange(delta, null);
954
	}
955
	
956
	/**
957
	 * A project has changed. If this is an add or remove, check
958
	 * to see if it is part of a current server configuration.
959
	 *
960
	 * @param delta org.eclipse.core.resources.IResourceDelta
961
	 * @param buildEvent whether this event was a build event
962
	 */
963
	protected void publishHandleProjectChange(IResourceDelta delta, IResourceChangeEvent event) {
953
		Trace.trace(Trace.FINEST, "> publishHandleProjectChange " + delta.getResource());
964
		Trace.trace(Trace.FINEST, "> publishHandleProjectChange " + delta.getResource());
954
		IProject project = (IProject) delta.getResource();
965
		IProject project = (IProject) delta.getResource();
955
		
966
		
Lines 974-980 Link Here
974
		for (int i = 0; i < size; i++) {
985
		for (int i = 0; i < size; i++) {
975
			for (int j = 0; j < size2; j++) {
986
			for (int j = 0; j < size2; j++) {
976
				if (servers2[j].getAdapter(ServerDelegate.class) != null)
987
				if (servers2[j].getAdapter(ServerDelegate.class) != null)
977
					((Server) servers2[j]).handleModuleProjectChange(modules[i]);
988
					((Server) servers2[j]).handleModuleProjectChange(modules[i], event);
978
			}
989
			}
979
		}
990
		}
980
		Trace.trace(Trace.FINEST, "< publishHandleProjectChange");
991
		Trace.trace(Trace.FINEST, "< publishHandleProjectChange");
(-)servercore/org/eclipse/wst/server/core/internal/Server.java (-7 / +47 lines)
Lines 50-56 Link Here
50
	public static final String FILE_EXTENSION = "server";
50
	public static final String FILE_EXTENSION = "server";
51
51
52
	public static final int AUTO_PUBLISH_DISABLE = 1;
52
	public static final int AUTO_PUBLISH_DISABLE = 1;
53
	public static final int AUTO_PUBLISH_ENABLE = 2;
53
	public static final int AUTO_PUBLISH_RESOURCE = 2;
54
	public static final int AUTO_PUBLISH_BUILD = 3;
55
	
54
56
55
	protected static final String PROP_HOSTNAME = "hostname";
57
	protected static final String PROP_HOSTNAME = "hostname";
56
	protected static final String SERVER_ID = "server-id";
58
	protected static final String SERVER_ID = "server-id";
Lines 159-168 Link Here
159
161
160
	public class ResourceChangeJob extends ServerJob {
162
	public class ResourceChangeJob extends ServerJob {
161
		private IModule module;
163
		private IModule module;
162
164
		private IResourceChangeEvent event;
165
		
163
		public ResourceChangeJob(IModule module) {
166
		public ResourceChangeJob(IModule module) {
167
			this(module, null);
168
		}
169
		public ResourceChangeJob(IModule module, IResourceChangeEvent event) {
164
			super(NLS.bind(Messages.jobUpdateServer, Server.this.getName()));
170
			super(NLS.bind(Messages.jobUpdateServer, Server.this.getName()));
165
			this.module = module;
171
			this.module = module;
172
			this.event = event;
166
			
173
			
167
			if (module.getProject() == null)
174
			if (module.getProject() == null)
168
				setRule(Server.this);
175
				setRule(Server.this);
Lines 214-220 Link Here
214
				behaviourDelegate.handleResourceChange();
221
				behaviourDelegate.handleResourceChange();
215
			
222
			
216
			if (getServerState() == IServer.STATE_STARTED)
223
			if (getServerState() == IServer.STATE_STARTED)
217
				autoPublish();
224
				autoPublish(event);
218
			
225
			
219
			return Status.OK_STATUS;
226
			return Status.OK_STATUS;
220
		}
227
		}
Lines 475-481 Link Here
475
	}
482
	}
476
483
477
	public int getAutoPublishSetting() {
484
	public int getAutoPublishSetting() {
478
		return getAttribute(PROP_AUTO_PUBLISH_SETTING, AUTO_PUBLISH_ENABLE);
485
		return getAttribute(PROP_AUTO_PUBLISH_SETTING, AUTO_PUBLISH_RESOURCE);
479
	}
486
	}
480
487
481
	public int getStartTimeout() {
488
	public int getStartTimeout() {
Lines 743-748 Link Here
743
 	}
750
 	}
744
751
745
	protected void handleModuleProjectChange(IModule module) {
752
	protected void handleModuleProjectChange(IModule module) {
753
		handleModuleProjectChange(module, null);
754
	}
755
756
	protected void handleModuleProjectChange(IModule module, IResourceChangeEvent buildEvent) {
746
		Trace.trace(Trace.FINEST, "> handleDeployableProjectChange() " + this + " " + module);
757
		Trace.trace(Trace.FINEST, "> handleDeployableProjectChange() " + this + " " + module);
747
		
758
		
748
		// check for duplicate jobs already waiting and don't create a new one
759
		// check for duplicate jobs already waiting and don't create a new one
Lines 758-764 Link Here
758
			}
769
			}
759
		}
770
		}
760
		
771
		
761
		ResourceChangeJob job = new ResourceChangeJob(module);
772
		ResourceChangeJob job = new ResourceChangeJob(module, buildEvent);
762
		job.setSystem(true);
773
		job.setSystem(true);
763
		job.setPriority(Job.BUILD);
774
		job.setPriority(Job.BUILD);
764
		job.schedule();
775
		job.schedule();
Lines 780-790 Link Here
780
	 * thread if automatic publishing is currently enabled.
791
	 * thread if automatic publishing is currently enabled.
781
	 */
792
	 */
782
	protected void autoPublish() {
793
	protected void autoPublish() {
794
		autoPublish(null);
795
	}
796
	
797
	protected void autoPublish(IResourceChangeEvent event) {
798
783
		stopAutoPublish();
799
		stopAutoPublish();
800
		boolean buildOccurred = didBuildOccur(event);
801
		boolean projectClosedOrDeleted = isProjectCloseOrDeleteEvent(event);
784
		
802
		
785
		if (getAutoPublishSetting() == AUTO_PUBLISH_DISABLE)
803
		if (getAutoPublishSetting() == AUTO_PUBLISH_DISABLE)
786
			return;
804
			return;
787
		
805
		
806
		if( (getAutoPublishSetting() == AUTO_PUBLISH_BUILD) && 
807
				!buildOccurred && !projectClosedOrDeleted)
808
			return;
809
		
788
		int time = getAutoPublishTime();
810
		int time = getAutoPublishTime();
789
		if (time >= 0) {
811
		if (time >= 0) {
790
			autoPublishThread = new AutoPublishThread();
812
			autoPublishThread = new AutoPublishThread();
Lines 794-799 Link Here
794
			autoPublishThread.start();
816
			autoPublishThread.start();
795
		}
817
		}
796
	}
818
	}
819
	
820
	private boolean isProjectCloseOrDeleteEvent(IResourceChangeEvent event) {
821
		int kind = event.getType();
822
		if( (kind & IResourceChangeEvent.PRE_CLOSE) > 0 || 
823
				(kind & IResourceChangeEvent.PRE_DELETE) > 0)
824
			return true;
825
		return false;
826
	}
827
	
828
	private boolean didBuildOccur(IResourceChangeEvent event) {
829
		int kind = event.getBuildKind();
830
		final boolean eventOccurred = 
831
			   (kind == IncrementalProjectBuilder.INCREMENTAL_BUILD) || 
832
			   (kind == IncrementalProjectBuilder.FULL_BUILD) || 
833
			   ((kind == IncrementalProjectBuilder.AUTO_BUILD && 
834
					ResourcesPlugin.getWorkspace().isAutoBuilding()));
835
		return eventOccurred;
836
	}
797
837
798
	/**
838
	/**
799
	 * Returns the event notification manager.
839
	 * Returns the event notification manager.
Lines 2018-2026 Link Here
2018
			configuration = ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(configPath));
2058
			configuration = ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(configPath));
2019
2059
2020
		// for migration from WTP 2.0 -> WTP 3.0
2060
		// for migration from WTP 2.0 -> WTP 3.0
2021
		int autoPubSetting = getAttribute(PROP_AUTO_PUBLISH_SETTING, AUTO_PUBLISH_ENABLE);
2061
		int autoPubSetting = getAttribute(PROP_AUTO_PUBLISH_SETTING, AUTO_PUBLISH_RESOURCE);
2022
		if (autoPubSetting == 0)
2062
		if (autoPubSetting == 0)
2023
			map.put(PROP_AUTO_PUBLISH_SETTING, AUTO_PUBLISH_ENABLE);
2063
			map.put(PROP_AUTO_PUBLISH_SETTING, AUTO_PUBLISH_RESOURCE);
2024
	}
2064
	}
2025
2065
2026
	protected void setInternal(ServerWorkingCopy wc) {
2066
	protected void setInternal(ServerWorkingCopy wc) {
(-)serverui/org/eclipse/wst/server/ui/internal/Messages.java (-1 / +2 lines)
Lines 286-292 Link Here
286
	public static String serverEditorOverviewPublishSection;
286
	public static String serverEditorOverviewPublishSection;
287
	public static String serverEditorOverviewPublishDescription;
287
	public static String serverEditorOverviewPublishDescription;
288
	public static String serverEditorOverviewAutoPublishDisable;
288
	public static String serverEditorOverviewAutoPublishDisable;
289
	public static String serverEditorOverviewAutoPublishEnabled;
289
	public static String serverEditorOverviewAutoPublishEnabledResource;
290
	public static String serverEditorOverviewAutoPublishEnabledBuild;
290
	public static String serverEditorOverviewAutoPublishEnabledInterval;
291
	public static String serverEditorOverviewAutoPublishEnabledInterval;
291
	public static String serverEditorOverviewPublishCommand;
292
	public static String serverEditorOverviewPublishCommand;
292
	public static String serverEditorOverviewTimeoutSection;
293
	public static String serverEditorOverviewTimeoutSection;
(-)serverui/org/eclipse/wst/server/ui/internal/Messages.properties (-1 / +2 lines)
Lines 447-453 Link Here
447
serverEditorOverviewPublishSection=Publishing
447
serverEditorOverviewPublishSection=Publishing
448
serverEditorOverviewPublishDescription=Modify settings for publishing.
448
serverEditorOverviewPublishDescription=Modify settings for publishing.
449
serverEditorOverviewAutoPublishDisable=Never publish automatically
449
serverEditorOverviewAutoPublishDisable=Never publish automatically
450
serverEditorOverviewAutoPublishEnabled=Automatically publish when resources change
450
serverEditorOverviewAutoPublishEnabledResource=Automatically publish when resources change
451
serverEditorOverviewAutoPublishEnabledBuild=Automatically publish after a build event
451
serverEditorOverviewAutoPublishEnabledInterval=Publishing interval (in seconds):
452
serverEditorOverviewAutoPublishEnabledInterval=Publishing interval (in seconds):
452
serverEditorOverviewPublishCommand=modify publish settings
453
serverEditorOverviewPublishCommand=modify publish settings
453
serverEditorOverviewPublishers=Select publishing actions:
454
serverEditorOverviewPublishers=Select publishing actions:
(-)serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java (-21 / +47 lines)
Lines 93-99 Link Here
93
	protected Combo runtimeCombo;
93
	protected Combo runtimeCombo;
94
	protected Button browse;
94
	protected Button browse;
95
	protected Button autoPublishDisable;
95
	protected Button autoPublishDisable;
96
	protected Button autoPublishEnable;
96
	protected Button autoPublishEnableResource;
97
	protected Button autoPublishEnableBuild;
97
	protected Spinner autoPublishTime;
98
	protected Spinner autoPublishTime;
98
	protected Table publishersTable;
99
	protected Table publishersTable;
99
	protected CheckboxTableViewer publishersViewer;
100
	protected CheckboxTableViewer publishersViewer;
Lines 205-213 Link Here
205
				} else if (event.getPropertyName().equals(Server.PROP_AUTO_PUBLISH_SETTING)) {
206
				} else if (event.getPropertyName().equals(Server.PROP_AUTO_PUBLISH_SETTING)) {
206
					Integer autoPublishSetting = (Integer)event.getNewValue();
207
					Integer autoPublishSetting = (Integer)event.getNewValue();
207
					int setting = autoPublishSetting.intValue();
208
					int setting = autoPublishSetting.intValue();
208
					autoPublishEnable.setSelection(setting == Server.AUTO_PUBLISH_ENABLE);
209
					autoPublishEnableResource.setSelection(setting == Server.AUTO_PUBLISH_RESOURCE);
210
					autoPublishEnableBuild.setSelection(setting == Server.AUTO_PUBLISH_BUILD);
209
					autoPublishDisable.setSelection(setting == Server.AUTO_PUBLISH_DISABLE);
211
					autoPublishDisable.setSelection(setting == Server.AUTO_PUBLISH_DISABLE);
210
					autoPublishTime.setEnabled(setting == Server.AUTO_PUBLISH_ENABLE);
212
					autoPublishTime.setEnabled(setting != Server.AUTO_PUBLISH_DISABLE);
211
					validate();
213
					validate();
212
				} else if (event.getPropertyName().equals(Server.PROP_START_TIMEOUT)) {
214
				} else if (event.getPropertyName().equals(Server.PROP_START_TIMEOUT)) {
213
					Integer time = (Integer)event.getNewValue();
215
					Integer time = (Integer)event.getNewValue();
Lines 619-636 Link Here
619
			autoPublishDisable.setSelection(publishSetting == Server.AUTO_PUBLISH_DISABLE);
621
			autoPublishDisable.setSelection(publishSetting == Server.AUTO_PUBLISH_DISABLE);
620
			whs.setHelp(autoPublishDisable, ContextIds.EDITOR_AUTOPUBLISH_DISABLE);
622
			whs.setHelp(autoPublishDisable, ContextIds.EDITOR_AUTOPUBLISH_DISABLE);
621
			
623
			
622
			autoPublishEnable = toolkit.createButton(composite, Messages.serverEditorOverviewAutoPublishEnabled, SWT.RADIO);
624
			autoPublishEnableResource = toolkit.createButton(composite, Messages.serverEditorOverviewAutoPublishEnabledResource, SWT.RADIO);
623
			autoPublishEnable.setSelection(publishSetting == Server.AUTO_PUBLISH_ENABLE);
625
			autoPublishEnableResource.setSelection(publishSetting == Server.AUTO_PUBLISH_RESOURCE);
624
			data = new GridData(GridData.FILL_HORIZONTAL);
626
			data = new GridData(GridData.FILL_HORIZONTAL);
625
			data.horizontalSpan = 2;
627
			data.horizontalSpan = 2;
626
			autoPublishEnable.setLayoutData(data);
628
			autoPublishEnableResource.setLayoutData(data);
627
			whs.setHelp(autoPublishEnable, ContextIds.EDITOR_AUTOPUBLISH_ENABLE);
629
			whs.setHelp(autoPublishEnableResource, ContextIds.EDITOR_AUTOPUBLISH_ENABLE);
630
			
631
			autoPublishEnableBuild = toolkit.createButton(composite, Messages.serverEditorOverviewAutoPublishEnabledBuild, SWT.RADIO);
632
			autoPublishEnableBuild .setSelection(publishSetting == Server.AUTO_PUBLISH_RESOURCE);
633
			data = new GridData(GridData.FILL_HORIZONTAL);
634
			data.horizontalSpan = 2;
635
			autoPublishEnableBuild.setLayoutData(data);
636
			whs.setHelp(autoPublishEnableBuild, ContextIds.EDITOR_AUTOPUBLISH_ENABLE);
637
			
628
			
638
			
629
			final Label autoPublishTimeLabel = createLabel(toolkit,composite, Messages.serverEditorOverviewAutoPublishEnabledInterval);
639
			final Label autoPublishTimeLabel = createLabel(toolkit,composite, Messages.serverEditorOverviewAutoPublishEnabledInterval);
630
			data = new GridData();
640
			data = new GridData();
631
			data.horizontalIndent = 20;
641
			data.horizontalIndent = 20;
632
			autoPublishTimeLabel.setLayoutData(data);
642
			autoPublishTimeLabel.setLayoutData(data);
633
			autoPublishTimeLabel.setEnabled(autoPublishEnable.getSelection());
643
			autoPublishTimeLabel.setEnabled(!autoPublishDisable.getSelection());
634
			
644
			
635
			autoPublishTime = new Spinner(composite, SWT.BORDER);
645
			autoPublishTime = new Spinner(composite, SWT.BORDER);
636
			autoPublishTime.setMinimum(0);
646
			autoPublishTime.setMinimum(0);
Lines 640-662 Link Here
640
			data = new GridData(GridData.HORIZONTAL_ALIGN_END);
650
			data = new GridData(GridData.HORIZONTAL_ALIGN_END);
641
			data.widthHint = 30;
651
			data.widthHint = 30;
642
			autoPublishTime.setLayoutData(data);
652
			autoPublishTime.setLayoutData(data);
643
			autoPublishTime.setEnabled(autoPublishEnable.getSelection());
653
			autoPublishTime.setEnabled(!autoPublishDisable.getSelection());
644
			SWTUtil.setSpinnerTooltip(autoPublishTime);
654
			SWTUtil.setSpinnerTooltip(autoPublishTime);
645
			whs.setHelp(autoPublishTime, ContextIds.EDITOR_AUTOPUBLISH_ENABLE);
655
			whs.setHelp(autoPublishTime, ContextIds.EDITOR_AUTOPUBLISH_ENABLE);
646
			
656
			
647
			autoPublishEnable.addSelectionListener(new SelectionAdapter() {
657
			autoPublishEnableResource.addSelectionListener(new SelectionAdapter() {
648
				public void widgetSelected(SelectionEvent e) {
658
				public void widgetSelected(SelectionEvent e) {
649
					if (updating || !autoPublishEnable.getSelection())
659
					if (updating || !autoPublishEnableResource.getSelection())
650
						return;
660
						return;
651
					updating = true;
661
					updating = true;
652
					execute(new SetServerAutoPublishDefaultCommand(getServer(), Server.AUTO_PUBLISH_ENABLE));
662
					execute(new SetServerAutoPublishDefaultCommand(getServer(), Server.AUTO_PUBLISH_RESOURCE));
653
					updating = false;
663
					updating = false;
654
					autoPublishTimeLabel.setEnabled(autoPublishEnable.getSelection());
664
					autoPublishTimeLabel.setEnabled(!autoPublishDisable.getSelection());
655
					autoPublishTime.setEnabled(autoPublishEnable.getSelection());
665
					autoPublishTime.setEnabled(!autoPublishDisable.getSelection());
656
					validate();
666
					validate();
657
				}
667
				}
658
			});
668
			});
659
						
669
670
			autoPublishEnableBuild.addSelectionListener(new SelectionAdapter() {
671
				public void widgetSelected(SelectionEvent e) {
672
					if (updating || !autoPublishEnableBuild.getSelection())
673
						return;
674
					updating = true;
675
					execute(new SetServerAutoPublishDefaultCommand(getServer(), Server.AUTO_PUBLISH_BUILD));
676
					updating = false;
677
					autoPublishTimeLabel.setEnabled(!autoPublishDisable.getSelection());
678
					autoPublishTime.setEnabled(!autoPublishDisable.getSelection());
679
					validate();
680
				}
681
			});
682
660
			autoPublishDisable.addSelectionListener(new SelectionAdapter() {
683
			autoPublishDisable.addSelectionListener(new SelectionAdapter() {
661
				public void widgetSelected(SelectionEvent e) {
684
				public void widgetSelected(SelectionEvent e) {
662
					if (updating || !autoPublishDisable.getSelection())
685
					if (updating || !autoPublishDisable.getSelection())
Lines 664-671 Link Here
664
					updating = true;
687
					updating = true;
665
					execute(new SetServerAutoPublishDefaultCommand(getServer(), Server.AUTO_PUBLISH_DISABLE));
688
					execute(new SetServerAutoPublishDefaultCommand(getServer(), Server.AUTO_PUBLISH_DISABLE));
666
					updating = false;
689
					updating = false;
667
					autoPublishTimeLabel.setEnabled(autoPublishEnable.getSelection());
690
					autoPublishTimeLabel.setEnabled(!autoPublishDisable.getSelection());
668
					autoPublishTime.setEnabled(autoPublishEnable.getSelection());
691
					autoPublishTime.setEnabled(!autoPublishDisable.getSelection());
669
					validate();
692
					validate();
670
				}
693
				}
671
			});
694
			});
Lines 952-968 Link Here
952
			Server svr = (Server) server;
975
			Server svr = (Server) server;
953
			int publishSetting = svr.getAutoPublishSetting();
976
			int publishSetting = svr.getAutoPublishSetting();
954
			autoPublishDisable.setSelection(publishSetting == Server.AUTO_PUBLISH_DISABLE);
977
			autoPublishDisable.setSelection(publishSetting == Server.AUTO_PUBLISH_DISABLE);
955
			autoPublishEnable.setSelection(publishSetting == Server.AUTO_PUBLISH_ENABLE);
978
			autoPublishEnableResource.setSelection(publishSetting == Server.AUTO_PUBLISH_RESOURCE);
979
			autoPublishEnableBuild.setSelection(publishSetting == Server.AUTO_PUBLISH_BUILD);
956
			autoPublishTime.setSelection(svr.getAutoPublishTime());
980
			autoPublishTime.setSelection(svr.getAutoPublishTime());
957
			
981
			
958
			if (readOnly) {
982
			if (readOnly) {
959
				autoPublishDisable.setEnabled(false);
983
				autoPublishDisable.setEnabled(false);
960
				autoPublishEnable.setEnabled(false);
984
				autoPublishEnableResource.setEnabled(false);
985
				autoPublishEnableBuild.setEnabled(false);
961
				autoPublishTime.setEnabled(false);
986
				autoPublishTime.setEnabled(false);
962
			} else {
987
			} else {
963
				autoPublishDisable.setEnabled(true);
988
				autoPublishDisable.setEnabled(true);
964
				autoPublishEnable.setEnabled(true);
989
				autoPublishEnableResource.setEnabled(true);
965
				autoPublishTime.setEnabled(publishSetting == Server.AUTO_PUBLISH_ENABLE);
990
				autoPublishEnableBuild.setEnabled(true);
991
				autoPublishTime.setEnabled(publishSetting != Server.AUTO_PUBLISH_DISABLE);
966
			}
992
			}
967
		}
993
		}
968
		
994
		

Return to bug 282483