Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 206811 | Differences between
and this patch

Collapse All | Expand All

(-)build.properties (-2 / +2 lines)
Lines 20-24 Link Here
20
jars.compile.order = .
20
jars.compile.order = .
21
source.. = src/
21
source.. = src/
22
output.. = bin/
22
output.. = bin/
23
javacSource = 1.4
23
javacSource = 1.5
24
javacTarget = 1.4
24
javacTarget = 1.5
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)src/org/eclipse/emf/workspace/examples/extlibrary/presentation/EXTLibraryEditor.java (-19 / +54 lines)
Lines 1-5 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
3
 * </copyright>
13
 * </copyright>
4
 *
14
 *
5
 * $Id: EXTLibraryEditor.java,v 1.6 2007/10/03 20:17:42 cdamus Exp $
15
 * $Id: EXTLibraryEditor.java,v 1.6 2007/10/03 20:17:42 cdamus Exp $
Lines 214-220 Link Here
214
	 * <!-- end-user-doc -->
224
	 * <!-- end-user-doc -->
215
	 * @generated
225
	 * @generated
216
	 */
226
	 */
217
	protected Collection selectionChangedListeners = new ArrayList();
227
	protected Collection<ISelectionChangedListener> selectionChangedListeners =
228
		new ArrayList<ISelectionChangedListener>();
218
229
219
	/**
230
	/**
220
	 * This keeps track of the selection of the editor as a whole.
231
	 * This keeps track of the selection of the editor as a whole.
Lines 251-262 Link Here
251
				}
262
				}
252
			}
263
			}
253
			public void partBroughtToTop(IWorkbenchPart p) {
264
			public void partBroughtToTop(IWorkbenchPart p) {
265
				// nothing to do
254
			}
266
			}
255
			public void partClosed(IWorkbenchPart p) {
267
			public void partClosed(IWorkbenchPart p) {
268
				// nothing to do
256
			}
269
			}
257
			public void partDeactivated(IWorkbenchPart p) {
270
			public void partDeactivated(IWorkbenchPart p) {
271
				// nothing to do
258
			}
272
			}
259
			public void partOpened(IWorkbenchPart p) {
273
			public void partOpened(IWorkbenchPart p) {
274
				// nothing to do
260
			}
275
			}
261
		};
276
		};
262
277
Lines 264-295 Link Here
264
	 * Resources that have been removed since last activation.
279
	 * Resources that have been removed since last activation.
265
	 * @generated
280
	 * @generated
266
	 */
281
	 */
267
	Collection removedResources = new ArrayList();
282
	Collection<Resource> removedResources = new ArrayList<Resource>();
268
283
269
	/**
284
	/**
270
	 * Resources that have been changed since last activation.
285
	 * Resources that have been changed since last activation.
271
	 * @generated
286
	 * @generated
272
	 */
287
	 */
273
	Collection changedResources = new ArrayList();
288
	Collection<Resource> changedResources = new ArrayList<Resource>();
274
289
275
	/**
290
	/**
276
	 * Resources that have been moved since last activation.
291
	 * Resources that have been moved since last activation.
277
	 * Maps {@link Resource resource} to {@link URI new URI}
292
	 * Maps {@link Resource resource} to {@link URI new URI}
278
	 */
293
	 */
279
	Map movedResources = new HashMap();
294
	Map<Resource, URI> movedResources = new HashMap<Resource, URI>();
280
295
281
	/**
296
	/**
282
	 * Resources that have been saved.
297
	 * Resources that have been saved.
283
	 * @generated
298
	 * @generated
284
	 */
299
	 */
285
	Collection savedResources = new ArrayList();
300
	Collection<Resource> savedResources = new ArrayList<Resource>();
286
	
301
	
287
	private boolean dirty;
302
	private boolean dirty;
288
303
289
	private IOperationHistoryListener historyListener = new IOperationHistoryListener() {
304
	private final IOperationHistoryListener historyListener = new IOperationHistoryListener() {
290
		public void historyNotification(final OperationHistoryEvent event) {
305
		public void historyNotification(final OperationHistoryEvent event) {
291
			if (event.getEventType() == OperationHistoryEvent.DONE) {
306
			if (event.getEventType() == OperationHistoryEvent.DONE) {
292
				Set affectedResources = ResourceUndoContext.getAffectedResources(
307
				Set<Resource> affectedResources = ResourceUndoContext.getAffectedResources(
293
						event.getOperation());
308
						event.getOperation());
294
				
309
				
295
				if (affectedResources.contains(getResource())) {
310
				if (affectedResources.contains(getResource())) {
Lines 362-368 Link Here
362
					getOperationHistory().dispose(undoContext, true, true, true);
377
					getOperationHistory().dispose(undoContext, true, true, true);
363
					
378
					
364
					// change saved resource's URI and remove from map
379
					// change saved resource's URI and remove from map
365
					res.setURI((URI) movedResources.remove(res));
380
					res.setURI(movedResources.remove(res));
366
						
381
						
367
					// must change my editor input
382
					// must change my editor input
368
					IEditorInput newInput = new FileEditorInput(
383
					IEditorInput newInput = new FileEditorInput(
Lines 467-473 Link Here
467
	protected void handleMovedResource() {
482
	protected void handleMovedResource() {
468
		if (!isDirty() || handleDirtyConflict()) {
483
		if (!isDirty() || handleDirtyConflict()) {
469
			Resource res = getResource();
484
			Resource res = getResource();
470
			URI newURI = (URI) movedResources.get(res);
485
			URI newURI = movedResources.get(res);
471
			
486
			
472
			if (newURI != null) {
487
			if (newURI != null) {
473
				if (res.isLoaded()) {
488
				if (res.isLoaded()) {
Lines 504-510 Link Here
504
519
505
		// Create an adapter factory that yields item providers.
520
		// Create an adapter factory that yields item providers.
506
		//
521
		//
507
		List factories = new ArrayList();
522
		List<AdapterFactory> factories = new ArrayList<AdapterFactory>();
508
		factories.add(new ResourceItemProviderAdapterFactory());
523
		factories.add(new ResourceItemProviderAdapterFactory());
509
		factories.add(new EXTLibraryItemProviderAdapterFactory());
524
		factories.add(new EXTLibraryItemProviderAdapterFactory());
510
		factories.add(new ReflectiveItemProviderAdapterFactory());
525
		factories.add(new ReflectiveItemProviderAdapterFactory());
Lines 527-532 Link Here
527
	 * 
542
	 * 
528
	 * @generated
543
	 * @generated
529
	 */
544
	 */
545
	@Override
530
	protected void firePropertyChange(int action) {
546
	protected void firePropertyChange(int action) {
531
		super.firePropertyChange(action);
547
		super.firePropertyChange(action);
532
	}
548
	}
Lines 537-544 Link Here
537
	 * 
553
	 * 
538
	 * @generated
554
	 * @generated
539
	 */
555
	 */
540
	public void setSelectionToViewer(Collection collection) {
556
	public void setSelectionToViewer(Collection<?> collection) {
541
		final Collection theSelection = collection;
557
		final Collection<?> theSelection = collection;
542
		// Make sure it's okay.
558
		// Make sure it's okay.
543
		//
559
		//
544
		if (theSelection != null && !theSelection.isEmpty()) {
560
		if (theSelection != null && !theSelection.isEmpty()) {
Lines 582-602 Link Here
582
			super((TransactionalEditingDomain) getEditingDomain(), adapterFactory);
598
			super((TransactionalEditingDomain) getEditingDomain(), adapterFactory);
583
		}
599
		}
584
600
601
		@Override
585
		public Object [] getElements(Object object) {
602
		public Object [] getElements(Object object) {
586
			Object parent = super.getParent(object);
603
			Object parent = super.getParent(object);
587
			return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
604
			return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
588
		}
605
		}
589
606
607
		@Override
590
		public Object [] getChildren(Object object) {
608
		public Object [] getChildren(Object object) {
591
			Object parent = super.getParent(object);
609
			Object parent = super.getParent(object);
592
			return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
610
			return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
593
		}
611
		}
594
612
613
		@Override
595
		public boolean hasChildren(Object object) {
614
		public boolean hasChildren(Object object) {
596
			Object parent = super.getParent(object);
615
			Object parent = super.getParent(object);
597
			return parent != null;
616
			return parent != null;
598
		}
617
		}
599
618
619
		@Override
600
		public Object getParent(Object object) {
620
		public Object getParent(Object object) {
601
			return null;
621
			return null;
602
		}
622
		}
Lines 718-723 Link Here
718
	 * <!-- end-user-doc -->
738
	 * <!-- end-user-doc -->
719
	 * @generated
739
	 * @generated
720
	 */
740
	 */
741
	@Override
721
	public void createPartControl(Composite parent) {
742
	public void createPartControl(Composite parent) {
722
		// Creates the model from the editor input
743
		// Creates the model from the editor input
723
		//
744
		//
Lines 743-748 Link Here
743
	 * <!-- begin-user-doc -->
764
	 * <!-- begin-user-doc -->
744
	 * <!-- end-user-doc -->
765
	 * <!-- end-user-doc -->
745
	 */
766
	 */
767
	@Override
768
	@SuppressWarnings("unchecked")
746
	public Object getAdapter(Class key) {
769
	public Object getAdapter(Class key) {
747
		if (key.equals(IContentOutlinePage.class)) {
770
		if (key.equals(IContentOutlinePage.class)) {
748
			return getContentOutlinePage();
771
			return getContentOutlinePage();
Lines 772-777 Link Here
772
			// The content outline is just a tree.
795
			// The content outline is just a tree.
773
			//
796
			//
774
			class MyContentOutlinePage extends ContentOutlinePage {
797
			class MyContentOutlinePage extends ContentOutlinePage {
798
				@Override
775
				public void createControl(Composite parent) {
799
				public void createControl(Composite parent) {
776
					super.createControl(parent);
800
					super.createControl(parent);
777
					contentOutlineViewer = getTreeViewer();
801
					contentOutlineViewer = getTreeViewer();
Lines 796-812 Link Here
796
					if (!editingDomain.getResourceSet().getResources().isEmpty()) {
820
					if (!editingDomain.getResourceSet().getResources().isEmpty()) {
797
					  // Select the root object in the view.
821
					  // Select the root object in the view.
798
					  //
822
					  //
799
					  ArrayList selection = new ArrayList();
823
					  ArrayList<Object> selection = new ArrayList<Object>();
800
					  selection.add(getResource());
824
					  selection.add(getResource());
801
					  contentOutlineViewer.setSelection(new StructuredSelection(selection), true);
825
					  contentOutlineViewer.setSelection(new StructuredSelection(selection), true);
802
					}
826
					}
803
				}
827
				}
804
828
829
				@Override
805
				public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) {
830
				public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) {
806
					super.makeContributions(menuManager, toolBarManager, statusLineManager);
831
					super.makeContributions(menuManager, toolBarManager, statusLineManager);
807
					contentOutlineStatusLineManager = statusLineManager;
832
					contentOutlineStatusLineManager = statusLineManager;
808
				}
833
				}
809
834
835
				@Override
810
				public void setActionBars(IActionBars actionBars) {
836
				public void setActionBars(IActionBars actionBars) {
811
					super.setActionBars(actionBars);
837
					super.setActionBars(actionBars);
812
					getActionBarContributor().shareGlobalActions(this, actionBars);
838
					getActionBarContributor().shareGlobalActions(this, actionBars);
Lines 839-849 Link Here
839
		if (propertySheetPage == null) {
865
		if (propertySheetPage == null) {
840
			propertySheetPage =
866
			propertySheetPage =
841
				new ExtendedPropertySheetPage(editingDomain) {
867
				new ExtendedPropertySheetPage(editingDomain) {
842
					public void setSelectionToViewer(List selection) {
868
					@Override
869
					public void setSelectionToViewer(List<?> selection) {
843
						EXTLibraryEditor.this.setSelectionToViewer(selection);
870
						EXTLibraryEditor.this.setSelectionToViewer(selection);
844
						EXTLibraryEditor.this.setFocus();
871
						EXTLibraryEditor.this.setFocus();
845
					}
872
					}
846
873
874
					@Override
847
					public void setActionBars(IActionBars actionBars) {
875
					public void setActionBars(IActionBars actionBars) {
848
						super.setActionBars(actionBars);
876
						super.setActionBars(actionBars);
849
						getActionBarContributor().shareGlobalActions(this, actionBars);
877
						getActionBarContributor().shareGlobalActions(this, actionBars);
Lines 862-874 Link Here
862
	 */
890
	 */
863
	public void handleContentOutlineSelection(ISelection selection) {
891
	public void handleContentOutlineSelection(ISelection selection) {
864
		if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
892
		if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
865
			Iterator selectedElements = ((IStructuredSelection)selection).iterator();
893
			Iterator<?> selectedElements = ((IStructuredSelection)selection).iterator();
866
			if (selectedElements.hasNext()) {
894
			if (selectedElements.hasNext()) {
867
				// Get the first selected element.
895
				// Get the first selected element.
868
				//
896
				//
869
				Object selectedElement = selectedElements.next();
897
				Object selectedElement = selectedElements.next();
870
898
871
				ArrayList selectionList = new ArrayList();
899
				ArrayList<Object> selectionList = new ArrayList<Object>();
872
				selectionList.add(selectedElement);
900
				selectionList.add(selectedElement);
873
				while (selectedElements.hasNext()) {
901
				while (selectedElements.hasNext()) {
874
					selectionList.add(selectedElements.next());
902
					selectionList.add(selectedElements.next());
Lines 886-891 Link Here
886
	 * <!-- begin-user-doc -->
914
	 * <!-- begin-user-doc -->
887
	 * <!-- end-user-doc -->
915
	 * <!-- end-user-doc -->
888
	 */
916
	 */
917
	@Override
889
	public boolean isDirty() {
918
	public boolean isDirty() {
890
		return dirty;
919
		return dirty;
891
	}
920
	}
Lines 895-900 Link Here
895
	 * <!-- begin-user-doc -->
924
	 * <!-- begin-user-doc -->
896
	 * <!-- end-user-doc -->
925
	 * <!-- end-user-doc -->
897
	 */
926
	 */
927
	@Override
898
	public void doSave(IProgressMonitor progressMonitor) {
928
	public void doSave(IProgressMonitor progressMonitor) {
899
		// Do the work within an operation because this is a long running activity
929
		// Do the work within an operation because this is a long running activity
900
		// that modifies the workbench.  Moreover, we must do this in a read-only
930
		// that modifies the workbench.  Moreover, we must do this in a read-only
Lines 904-909 Link Here
904
			new WorkspaceModifyOperation() {
934
			new WorkspaceModifyOperation() {
905
				// This is the method that gets invoked when the operation runs.
935
				// This is the method that gets invoked when the operation runs.
906
				//
936
				//
937
				@Override
907
				public void execute(IProgressMonitor monitor) {
938
				public void execute(IProgressMonitor monitor) {
908
					try {
939
					try {
909
						((TransactionalEditingDomain) getEditingDomain()).runExclusive(new Runnable() {
940
						((TransactionalEditingDomain) getEditingDomain()).runExclusive(new Runnable() {
Lines 949-954 Link Here
949
	 * <!-- end-user-doc -->
980
	 * <!-- end-user-doc -->
950
	 * @generated
981
	 * @generated
951
	 */
982
	 */
983
	@Override
952
	public boolean isSaveAsAllowed() {
984
	public boolean isSaveAsAllowed() {
953
		return true;
985
		return true;
954
	}
986
	}
Lines 959-964 Link Here
959
	 * <!-- end-user-doc -->
991
	 * <!-- end-user-doc -->
960
	 * @generated
992
	 * @generated
961
	 */
993
	 */
994
	@Override
962
	public void doSaveAs() {
995
	public void doSaveAs() {
963
		SaveAsDialog saveAsDialog= new SaveAsDialog(getSite().getShell());
996
		SaveAsDialog saveAsDialog= new SaveAsDialog(getSite().getShell());
964
		saveAsDialog.open();
997
		saveAsDialog.open();
Lines 1038-1043 Link Here
1038
	 * <!-- begin-user-doc -->
1071
	 * <!-- begin-user-doc -->
1039
	 * <!-- end-user-doc -->
1072
	 * <!-- end-user-doc -->
1040
	 */
1073
	 */
1074
	@Override
1041
	public void init(IEditorSite site, IEditorInput editorInput) {
1075
	public void init(IEditorSite site, IEditorInput editorInput) {
1042
		setSite(site);
1076
		setSite(site);
1043
		setInputWithNotify(editorInput);
1077
		setInputWithNotify(editorInput);
Lines 1054-1059 Link Here
1054
	 * <!-- begin-user-doc -->
1088
	 * <!-- begin-user-doc -->
1055
	 * <!-- end-user-doc -->
1089
	 * <!-- end-user-doc -->
1056
	 */
1090
	 */
1091
	@Override
1057
	public void setFocus() {
1092
	public void setFocus() {
1058
		selectionViewer.getControl().setFocus();
1093
		selectionViewer.getControl().setFocus();
1059
	}
1094
	}
Lines 1098-1105 Link Here
1098
	public void setSelection(ISelection selection) {
1133
	public void setSelection(ISelection selection) {
1099
		editorSelection = selection;
1134
		editorSelection = selection;
1100
1135
1101
		for (Iterator listeners = selectionChangedListeners.iterator(); listeners.hasNext(); ) {
1136
		for (ISelectionChangedListener listener : selectionChangedListeners) {
1102
			ISelectionChangedListener listener = (ISelectionChangedListener)listeners.next();
1103
			listener.selectionChanged(new SelectionChangedEvent(this, selection));
1137
			listener.selectionChanged(new SelectionChangedEvent(this, selection));
1104
		}
1138
		}
1105
		setStatusLineManager(selection);
1139
		setStatusLineManager(selection);
Lines 1116-1122 Link Here
1116
	
1150
	
1117
		if (statusLineManager != null) {
1151
		if (statusLineManager != null) {
1118
			if (selection instanceof IStructuredSelection) {
1152
			if (selection instanceof IStructuredSelection) {
1119
				Collection collection = ((IStructuredSelection)selection).toList();
1153
				Collection<?> collection = ((IStructuredSelection)selection).toList();
1120
				switch (collection.size()) {
1154
				switch (collection.size()) {
1121
					case 0: {
1155
					case 0: {
1122
						statusLineManager.setMessage(getString("_UI_NoObjectSelected")); //$NON-NLS-1$
1156
						statusLineManager.setMessage(getString("_UI_NoObjectSelected")); //$NON-NLS-1$
Lines 1204-1209 Link Here
1204
	 * <!-- begin-user-doc -->
1238
	 * <!-- begin-user-doc -->
1205
	 * <!-- end-user-doc -->
1239
	 * <!-- end-user-doc -->
1206
	 */
1240
	 */
1241
	@Override
1207
	public void dispose() {
1242
	public void dispose() {
1208
		workspaceSynchronizer.dispose();
1243
		workspaceSynchronizer.dispose();
1209
		getOperationHistory().removeOperationHistoryListener(historyListener);
1244
		getOperationHistory().removeOperationHistoryListener(historyListener);
(-)src/org/eclipse/emf/workspace/examples/extlibrary/presentation/EXTLibraryEditorPlugin.java (-2 / +11 lines)
Lines 1-5 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
3
 * </copyright>
13
 * </copyright>
4
 *
14
 *
5
 * $Id: EXTLibraryEditorPlugin.java,v 1.1 2006/01/30 16:30:09 cdamus Exp $
15
 * $Id: EXTLibraryEditorPlugin.java,v 1.1 2006/01/30 16:30:09 cdamus Exp $
Lines 7-15 Link Here
7
package org.eclipse.emf.workspace.examples.extlibrary.presentation;
17
package org.eclipse.emf.workspace.examples.extlibrary.presentation;
8
18
9
import org.eclipse.emf.common.EMFPlugin;
19
import org.eclipse.emf.common.EMFPlugin;
10
11
import org.eclipse.emf.common.ui.EclipseUIPlugin;
20
import org.eclipse.emf.common.ui.EclipseUIPlugin;
12
13
import org.eclipse.emf.common.util.ResourceLocator;
21
import org.eclipse.emf.common.util.ResourceLocator;
14
22
15
/**
23
/**
Lines 54-59 Link Here
54
	 * @return the singleton instance.
62
	 * @return the singleton instance.
55
	 * @generated
63
	 * @generated
56
	 */
64
	 */
65
	@Override
57
	public ResourceLocator getPluginResourceLocator() {
66
	public ResourceLocator getPluginResourceLocator() {
58
		return plugin;
67
		return plugin;
59
	}
68
	}
(-)src/org/eclipse/emf/workspace/examples/extlibrary/presentation/ResourceLoadedListener.java (-1 / +2 lines)
Lines 46-52 Link Here
46
public class ResourceLoadedListener extends DemultiplexingListener {
46
public class ResourceLoadedListener extends DemultiplexingListener {
47
	private static ResourceLoadedListener instance;
47
	private static ResourceLoadedListener instance;
48
	
48
	
49
	private final Set ignoredResources = new java.util.HashSet();
49
	private final Set<Resource> ignoredResources = new java.util.HashSet<Resource>();
50
	
50
	
51
	/**
51
	/**
52
	 * Initializes me with my filter.
52
	 * Initializes me with my filter.
Lines 87-92 Link Here
87
		ignoredResources.remove(res);
87
		ignoredResources.remove(res);
88
	}
88
	}
89
89
90
	@Override
90
	protected void handleNotification(TransactionalEditingDomain domain, Notification notification) {
91
	protected void handleNotification(TransactionalEditingDomain domain, Notification notification) {
91
		if (ignoredResources.contains(notification.getNotifier())) {
92
		if (ignoredResources.contains(notification.getNotifier())) {
92
			// skip any resource that we are supposed to ignore
93
			// skip any resource that we are supposed to ignore
(-)src/org/eclipse/emf/workspace/examples/extlibrary/presentation/EXTLibraryActionBarContributor.java (-17 / +41 lines)
Lines 1-5 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
3
 * </copyright>
13
 * </copyright>
4
 *
14
 *
5
 * $Id: EXTLibraryActionBarContributor.java,v 1.2 2006/02/22 15:17:44 cmcgee Exp $
15
 * $Id: EXTLibraryActionBarContributor.java,v 1.2 2006/02/22 15:17:44 cmcgee Exp $
Lines 8-14 Link Here
8
18
9
import java.util.ArrayList;
19
import java.util.ArrayList;
10
import java.util.Collection;
20
import java.util.Collection;
11
import java.util.Iterator;
12
21
13
import org.eclipse.emf.common.ui.viewer.IViewerProvider;
22
import org.eclipse.emf.common.ui.viewer.IViewerProvider;
14
import org.eclipse.emf.edit.domain.EditingDomain;
23
import org.eclipse.emf.edit.domain.EditingDomain;
Lines 84-89 Link Here
84
	protected IAction showPropertiesViewAction =
93
	protected IAction showPropertiesViewAction =
85
		new Action(EXTLibraryEditorPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) //$NON-NLS-1$
94
		new Action(EXTLibraryEditorPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) //$NON-NLS-1$
86
		{
95
		{
96
			@Override
87
			public void run() {
97
			public void run() {
88
				try {
98
				try {
89
					getPage().showView("org.eclipse.ui.views.PropertySheet"); //$NON-NLS-1$
99
					getPage().showView("org.eclipse.ui.views.PropertySheet"); //$NON-NLS-1$
Lines 104-113 Link Here
104
	protected IAction refreshViewerAction =
114
	protected IAction refreshViewerAction =
105
		new Action(EXTLibraryEditorPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) //$NON-NLS-1$
115
		new Action(EXTLibraryEditorPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) //$NON-NLS-1$
106
		{
116
		{
117
			@Override
107
			public boolean isEnabled() {
118
			public boolean isEnabled() {
108
				return activeEditorPart instanceof IViewerProvider;
119
				return activeEditorPart instanceof IViewerProvider;
109
			}
120
			}
110
121
122
			@Override
111
			public void run() {
123
			public void run() {
112
				if (activeEditorPart instanceof IViewerProvider) {
124
				if (activeEditorPart instanceof IViewerProvider) {
113
					Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer();
125
					Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer();
Lines 127-133 Link Here
127
	 * <!-- end-user-doc -->
139
	 * <!-- end-user-doc -->
128
	 * @generated
140
	 * @generated
129
	 */
141
	 */
130
	protected Collection createChildActions;
142
	protected Collection<IAction> createChildActions;
131
143
132
	/**
144
	/**
133
	 * This is the menu manager into which menu contribution items should be added for CreateChild actions.
145
	 * This is the menu manager into which menu contribution items should be added for CreateChild actions.
Lines 144-150 Link Here
144
	 * <!-- end-user-doc -->
156
	 * <!-- end-user-doc -->
145
	 * @generated
157
	 * @generated
146
	 */
158
	 */
147
	protected Collection createSiblingActions;
159
	protected Collection<IAction> createSiblingActions;
148
160
149
	/**
161
	/**
150
	 * This is the menu manager into which menu contribution items should be added for CreateSibling actions.
162
	 * This is the menu manager into which menu contribution items should be added for CreateSibling actions.
Lines 165-170 Link Here
165
		validateAction = new ValidateAction();
177
		validateAction = new ValidateAction();
166
	}
178
	}
167
179
180
	@Override
168
	public void init(IActionBars actionBars) {
181
	public void init(IActionBars actionBars) {
169
		super.init(actionBars);
182
		super.init(actionBars);
170
183
Lines 186-191 Link Here
186
	 * <!-- end-user-doc -->
199
	 * <!-- end-user-doc -->
187
	 * @generated
200
	 * @generated
188
	 */
201
	 */
202
	@Override
189
	public void contributeToToolBar(IToolBarManager toolBarManager) {
203
	public void contributeToToolBar(IToolBarManager toolBarManager) {
190
		toolBarManager.add(new Separator("extlibrary-settings")); //$NON-NLS-1$
204
		toolBarManager.add(new Separator("extlibrary-settings")); //$NON-NLS-1$
191
		toolBarManager.add(new Separator("extlibrary-additions")); //$NON-NLS-1$
205
		toolBarManager.add(new Separator("extlibrary-additions")); //$NON-NLS-1$
Lines 197-202 Link Here
197
	 * <!-- begin-user-doc -->
211
	 * <!-- begin-user-doc -->
198
	 * <!-- end-user-doc -->
212
	 * <!-- end-user-doc -->
199
	 */
213
	 */
214
	@Override
200
	public void contributeToMenu(IMenuManager menuManager) {
215
	public void contributeToMenu(IMenuManager menuManager) {
201
		super.contributeToMenu(menuManager);
216
		super.contributeToMenu(menuManager);
202
217
Lines 235-240 Link Here
235
	 * <!-- end-user-doc -->
250
	 * <!-- end-user-doc -->
236
	 * @generated
251
	 * @generated
237
	 */
252
	 */
253
	@Override
238
	public void setActiveEditor(IEditorPart part) {
254
	public void setActiveEditor(IEditorPart part) {
239
		super.setActiveEditor(part);
255
		super.setActiveEditor(part);
240
		activeEditorPart = part;
256
		activeEditorPart = part;
Lines 259-270 Link Here
259
		}
275
		}
260
	}
276
	}
261
	
277
	
278
	@Override
262
	public void activate() {
279
	public void activate() {
263
		longRunningReadAction.setActiveWorkbenchPart(activeEditor);
280
		longRunningReadAction.setActiveWorkbenchPart(activeEditor);
264
		
281
		
265
		super.activate();
282
		super.activate();
266
	}
283
	}
267
	
284
	
285
	@Override
268
	public void deactivate() {
286
	public void deactivate() {
269
		longRunningReadAction.setActiveWorkbenchPart(null);
287
		longRunningReadAction.setActiveWorkbenchPart(null);
270
		
288
		
Lines 291-298 Link Here
291
309
292
		// Query the new selection for appropriate new child/sibling descriptors
310
		// Query the new selection for appropriate new child/sibling descriptors
293
		//
311
		//
294
		Collection newChildDescriptors = null;
312
		Collection<?> newChildDescriptors = null;
295
		Collection newSiblingDescriptors = null;
313
		Collection<?> newSiblingDescriptors = null;
296
314
297
		ISelection selection = event.getSelection();
315
		ISelection selection = event.getSelection();
298
		if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) {
316
		if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) {
Lines 326-336 Link Here
326
	 * <!-- end-user-doc -->
344
	 * <!-- end-user-doc -->
327
	 * @generated
345
	 * @generated
328
	 */
346
	 */
329
	protected Collection generateCreateChildActions(Collection descriptors, ISelection selection) {
347
	protected Collection<IAction> generateCreateChildActions(Collection<?> descriptors, ISelection selection) {
330
		Collection actions = new ArrayList();
348
		Collection<IAction> actions = new ArrayList<IAction>();
331
		if (descriptors != null) {
349
		if (descriptors != null) {
332
			for (Iterator i = descriptors.iterator(); i.hasNext(); ) {
350
			for (Object next : descriptors) {
333
				actions.add(new CreateChildAction(activeEditorPart, selection, i.next()));
351
				actions.add(new CreateChildAction(activeEditorPart, selection, next));
334
			}
352
			}
335
		}
353
		}
336
		return actions;
354
		return actions;
Lines 343-353 Link Here
343
	 * <!-- end-user-doc -->
361
	 * <!-- end-user-doc -->
344
	 * @generated
362
	 * @generated
345
	 */
363
	 */
346
	protected Collection generateCreateSiblingActions(Collection descriptors, ISelection selection) {
364
	protected Collection<IAction> generateCreateSiblingActions(Collection<?> descriptors, ISelection selection) {
347
		Collection actions = new ArrayList();
365
		Collection<IAction> actions = new ArrayList<IAction>();
348
		if (descriptors != null) {
366
		if (descriptors != null) {
349
			for (Iterator i = descriptors.iterator(); i.hasNext(); ) {
367
			for (Object next : descriptors) {
350
				actions.add(new CreateSiblingAction(activeEditorPart, selection, i.next()));
368
				actions.add(new CreateSiblingAction(activeEditorPart, selection, next));
351
			}
369
			}
352
		}
370
		}
353
		return actions;
371
		return actions;
Lines 362-371 Link Here
362
	 * <!-- end-user-doc -->
380
	 * <!-- end-user-doc -->
363
	 * @generated
381
	 * @generated
364
	 */
382
	 */
365
	protected void populateManager(IContributionManager manager, Collection actions, String contributionID) {
383
	protected void populateManager(IContributionManager manager,
384
			Collection<? extends IAction> actions, String contributionID) {
385
		
366
		if (actions != null) {
386
		if (actions != null) {
367
			for (Iterator i = actions.iterator(); i.hasNext(); ) {
387
			for (IAction action : actions) {
368
				IAction action = (IAction)i.next();
369
				if (contributionID != null) {
388
				if (contributionID != null) {
370
					manager.insertBefore(contributionID, action);
389
					manager.insertBefore(contributionID, action);
371
				}
390
				}
Lines 383-389 Link Here
383
	 * <!-- end-user-doc -->
402
	 * <!-- end-user-doc -->
384
	 * @generated
403
	 * @generated
385
	 */
404
	 */
386
	protected void depopulateManager(IContributionManager manager, Collection actions) {
405
	protected void depopulateManager(IContributionManager manager,
406
			Collection<? extends IAction> actions) {
407
		
387
		if (actions != null) {
408
		if (actions != null) {
388
			IContributionItem[] items = manager.getItems();
409
			IContributionItem[] items = manager.getItems();
389
			for (int i = 0; i < items.length; i++) {
410
			for (int i = 0; i < items.length; i++) {
Lines 412-417 Link Here
412
	 * <!-- end-user-doc -->
433
	 * <!-- end-user-doc -->
413
	 * @generated
434
	 * @generated
414
	 */
435
	 */
436
	@Override
415
	public void menuAboutToShow(IMenuManager menuManager) {
437
	public void menuAboutToShow(IMenuManager menuManager) {
416
		super.menuAboutToShow(menuManager);
438
		super.menuAboutToShow(menuManager);
417
		MenuManager submenuManager = null;
439
		MenuManager submenuManager = null;
Lines 430-435 Link Here
430
	 * <!-- begin-user-doc -->
452
	 * <!-- begin-user-doc -->
431
	 * <!-- end-user-doc -->
453
	 * <!-- end-user-doc -->
432
	 */
454
	 */
455
	@Override
433
	protected void addGlobalActions(IMenuManager menuManager) {
456
	protected void addGlobalActions(IMenuManager menuManager) {
434
		menuManager.insertAfter("additions-end", new Separator("ui-actions")); //$NON-NLS-1$ //$NON-NLS-2$
457
		menuManager.insertAfter("additions-end", new Separator("ui-actions")); //$NON-NLS-1$ //$NON-NLS-2$
435
		menuManager.insertAfter("ui-actions", showPropertiesViewAction); //$NON-NLS-1$
458
		menuManager.insertAfter("ui-actions", showPropertiesViewAction); //$NON-NLS-1$
Lines 450-455 Link Here
450
	 * <!-- end-user-doc -->
473
	 * <!-- end-user-doc -->
451
	 * @generated
474
	 * @generated
452
	 */
475
	 */
476
	@Override
453
	protected boolean removeAllReferencesOnDelete() {
477
	protected boolean removeAllReferencesOnDelete() {
454
		return true;
478
		return true;
455
	}
479
	}
(-)src/org/eclipse/emf/workspace/examples/extlibrary/domain/EXTLibraryEditingDomainFactory.java (-4 / +6 lines)
Lines 20-25 Link Here
20
import java.util.Map;
20
import java.util.Map;
21
21
22
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.IStatus;
23
import org.eclipse.emf.ecore.resource.Resource;
23
import org.eclipse.emf.ecore.resource.ResourceSet;
24
import org.eclipse.emf.ecore.resource.ResourceSet;
24
import org.eclipse.emf.transaction.Transaction;
25
import org.eclipse.emf.transaction.Transaction;
25
import org.eclipse.emf.transaction.TransactionalCommandStack;
26
import org.eclipse.emf.transaction.TransactionalCommandStack;
Lines 50-64 Link Here
50
		((TransactionalCommandStack) result.getCommandStack()).setExceptionHandler(
51
		((TransactionalCommandStack) result.getCommandStack()).setExceptionHandler(
51
				new CommandStackExceptionHandler());
52
				new CommandStackExceptionHandler());
52
		
53
		
53
		DefaultOptions defaults = (DefaultOptions) TransactionUtil.getAdapter(
54
		DefaultOptions defaults = TransactionUtil.getAdapter(
54
            result, DefaultOptions.class);
55
            result, DefaultOptions.class);
55
		if (defaults != null) {
56
		if (defaults != null) {
56
            Map options = new java.util.HashMap();
57
            Map<Object, Object> options = new java.util.HashMap<Object, Object>();
57
58
58
            options.put(Transaction.OPTION_VALIDATE_EDIT,
59
            options.put(Transaction.OPTION_VALIDATE_EDIT,
59
                new WorkspaceValidateEditSupport() {
60
                new WorkspaceValidateEditSupport() {
60
                    protected IStatus doValidateEdit(Transaction transaction,
61
                    @Override
61
                            Collection resources, Object context) {
62
					protected IStatus doValidateEdit(Transaction transaction,
63
                            Collection<? extends Resource> resources, Object context) {
62
                        if ((context == null) && (Display.getCurrent() != null)) {
64
                        if ((context == null) && (Display.getCurrent() != null)) {
63
                            // get the active shell for the context
65
                            // get the active shell for the context
64
                            // when validating on the UI thread
66
                            // when validating on the UI thread
(-)src/org/eclipse/emf/workspace/examples/extlibrary/actions/LongRunningReadAction.java (-2 / +5 lines)
Lines 23-28 Link Here
23
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
23
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
24
import org.eclipse.emf.transaction.RunnableWithResult;
24
import org.eclipse.emf.transaction.RunnableWithResult;
25
import org.eclipse.emf.transaction.TransactionalEditingDomain;
25
import org.eclipse.emf.transaction.TransactionalEditingDomain;
26
import org.eclipse.emf.transaction.util.TransactionUtil;
26
import org.eclipse.emf.workspace.examples.extlibrary.console.ConsoleUtil;
27
import org.eclipse.emf.workspace.examples.extlibrary.console.ConsoleUtil;
27
import org.eclipse.emf.workspace.examples.extlibrary.internal.l10n.Messages;
28
import org.eclipse.emf.workspace.examples.extlibrary.internal.l10n.Messages;
28
import org.eclipse.jface.action.Action;
29
import org.eclipse.jface.action.Action;
Lines 50-55 Link Here
50
		super(Messages.readJob_title);
51
		super(Messages.readJob_title);
51
	}
52
	}
52
53
54
	@Override
53
	public void run() {
55
	public void run() {
54
		if (domain != null) {
56
		if (domain != null) {
55
			ConsoleUtil.showConsole(CONSOLE);
57
			ConsoleUtil.showConsole(CONSOLE);
Lines 92-101 Link Here
92
			setPriority(Job.LONG);
94
			setPriority(Job.LONG);
93
		}
95
		}
94
		
96
		
97
		@Override
95
		protected IStatus run(final IProgressMonitor monitor) {
98
		protected IStatus run(final IProgressMonitor monitor) {
96
			try {
99
			try {
97
				return (IStatus) domain.runExclusive(
100
				return TransactionUtil.runExclusive(domain,
98
					new RunnableWithResult.Impl() {
101
					new RunnableWithResult.Impl<IStatus>() {
99
						public void run() {
102
						public void run() {
100
							setResult(longRunningRead(monitor));
103
							setResult(longRunningRead(monitor));
101
						}});
104
						}});
(-)src/org/eclipse/emf/workspace/examples/extlibrary/console/ConsoleUtil.java (-5 / +8 lines)
Lines 42-51 Link Here
42
public class ConsoleUtil {
42
public class ConsoleUtil {
43
	
43
	
44
	/** cache for console name to actual console object mapping*/
44
	/** cache for console name to actual console object mapping*/
45
	private static Map nameToConsole = new HashMap();
45
	private static Map<String, MessageConsole> nameToConsole =
46
		new HashMap<String, MessageConsole>();
46
	
47
	
47
	/** cache for 'console name' to 'stream for that console' mapping */
48
	/** cache for 'console name' to 'stream for that console' mapping */
48
	private static Map nameToStream = new HashMap();
49
	private static Map<String, MessageConsoleStream> nameToStream =
50
		new HashMap<String, MessageConsoleStream>();
49
51
50
	/**
52
	/**
51
	 * Registers the console with the Eclipse Console Manager.
53
	 * Registers the console with the Eclipse Console Manager.
Lines 64-70 Link Here
64
			nameToConsole.put(name, console );
66
			nameToConsole.put(name, console );
65
		}
67
		}
66
		
68
		
67
		return (MessageConsole) nameToConsole.get( name);
69
		return nameToConsole.get( name);
68
	}
70
	}
69
	
71
	
70
	
72
	
Lines 75-81 Link Here
75
	 */
77
	 */
76
	public synchronized static void unregisterConsole(String name){		
78
	public synchronized static void unregisterConsole(String name){		
77
		if(nameToConsole.containsKey( name)){		
79
		if(nameToConsole.containsKey( name)){		
78
			ConsolePlugin.getDefault().getConsoleManager().removeConsoles( new IConsole[]{(IConsole)nameToConsole.get(name)});
80
			ConsolePlugin.getDefault().getConsoleManager().removeConsoles(
81
				new IConsole[]{nameToConsole.get(name)});
79
			nameToConsole.remove( name);
82
			nameToConsole.remove( name);
80
		}		
83
		}		
81
	}
84
	}
Lines 97-103 Link Here
97
			
100
			
98
		}
101
		}
99
		
102
		
100
		return (MessageConsoleStream) nameToStream.get(name);
103
		return nameToStream.get(name);
101
		
104
		
102
	}
105
	}
103
106
(-)META-INF/MANIFEST.MF (-7 / +7 lines)
Lines 13-25 Link Here
13
 org.eclipse.emf.workspace.examples.extlibrary.presentation
13
 org.eclipse.emf.workspace.examples.extlibrary.presentation
14
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
14
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
15
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)";visibility:=reexport,
15
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)";visibility:=reexport,
16
 org.eclipse.emf.examples.library.edit;bundle-version="[2.2.0,3.0.0)";visibility:=reexport,
16
 org.eclipse.emf.examples.library.edit;bundle-version="[2.3.0,3.0.0)";visibility:=reexport,
17
 org.eclipse.emf.ecore.xmi;bundle-version="[2.2.0,3.0.0)";visibility:=reexport,
17
 org.eclipse.emf.ecore.xmi;bundle-version="[2.3.0,3.0.0)";visibility:=reexport,
18
 org.eclipse.emf.edit.ui;bundle-version="[2.2.0,3.0.0)";visibility:=reexport,
18
 org.eclipse.emf.edit.ui;bundle-version="[2.3.0,3.0.0)";visibility:=reexport,
19
 org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)";visibility:=reexport,
19
 org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)";visibility:=reexport,
20
 org.eclipse.emf.workspace;bundle-version="[1.0.0,2.0.0)",
20
 org.eclipse.emf.workspace;bundle-version="[1.2.0,2.0.0)",
21
 org.eclipse.emf.transaction.ui;bundle-version="[1.0.0,2.0.0)",
21
 org.eclipse.emf.transaction.ui;bundle-version="[1.2.0,2.0.0)",
22
 org.eclipse.emf.workspace.ui;bundle-version="[1.0.0,2.0.0)",
22
 org.eclipse.emf.workspace.ui;bundle-version="[1.2.0,2.0.0)",
23
 org.eclipse.ui.console;bundle-version="[3.1.100,4.0.0)"
23
 org.eclipse.ui.console;bundle-version="[3.1.100,4.0.0)"
24
Eclipse-LazyStart: true
24
Eclipse-LazyStart: true
25
Bundle-RequiredExecutionEnvironment: J2SE-1.4
25
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:53:52 EST 2006
1
#Sun Nov 11 17:20:41 EST 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-)src/org/eclipse/emf/transaction/impl/TransactionalCommandStackImpl.java (-5 / +14 lines)
Lines 54-60 Link Here
54
     * 
54
     * 
55
     *  @since 1.1
55
     *  @since 1.1
56
     */
56
     */
57
	protected void doExecute(Command command, Map options) throws InterruptedException, RollbackException {
57
	@Override
58
	protected void doExecute(Command command, Map<?, ?> options) throws InterruptedException, RollbackException {
58
		InternalTransaction tx = createTransaction(command, options);
59
		InternalTransaction tx = createTransaction(command, options);
59
		
60
		
60
		try {
61
		try {
Lines 98-110 Link Here
98
     * 
99
     * 
99
     * @since 1.1
100
     * @since 1.1
100
     */
101
     */
101
    protected void handleRollback(Command command, RollbackException rbe) {
102
    @Override
103
	protected void handleRollback(Command command, RollbackException rbe) {
102
        if ((command != null) && (top >= 0) && (commandList.get(top) == command)) {
104
        if ((command != null) && (top >= 0) && (commandList.get(top) == command)) {
103
            // pop the failed command
105
            // pop the failed command
104
            commandList.remove(top--);
106
            commandList.remove(top--);
105
107
106
            if (top >= 0) {
108
            if (top >= 0) {
107
                mostRecentCommand = (Command) commandList.get(top);
109
                mostRecentCommand = commandList.get(top);
108
            } else {
110
            } else {
109
                mostRecentCommand = null;
111
                mostRecentCommand = null;
110
            }
112
            }
Lines 118-123 Link Here
118
     * an undo transaction (a read/write transaction with the
120
     * an undo transaction (a read/write transaction with the
119
     * {@link #getUndoRedoOptions() undo/redo options}).
121
     * {@link #getUndoRedoOptions() undo/redo options}).
120
     */
122
     */
123
	@Override
121
	public void undo() {
124
	public void undo() {
122
		if (canUndo()) {
125
		if (canUndo()) {
123
			try {
126
			try {
Lines 138-143 Link Here
138
	 * Extends the inherited implementation to consider the redoability of
141
	 * Extends the inherited implementation to consider the redoability of
139
	 * {@link ConditionalRedoCommand}s.
142
	 * {@link ConditionalRedoCommand}s.
140
	 */
143
	 */
144
	@Override
141
	public boolean canRedo() {
145
	public boolean canRedo() {
142
		boolean result = super.canRedo();
146
		boolean result = super.canRedo();
143
		
147
		
Lines 158-163 Link Here
158
	 * of a redo transaction (a read/write transaction with the
162
	 * of a redo transaction (a read/write transaction with the
159
	 * {@link #getUndoRedoOptions() undo/redo options}).
163
	 * {@link #getUndoRedoOptions() undo/redo options}).
160
	 */
164
	 */
165
	@Override
161
	public void redo() {
166
	public void redo() {
162
		if (canRedo()) {
167
		if (canRedo()) {
163
			try {
168
			try {
Lines 175-181 Link Here
175
	}
180
	}
176
181
177
	// Documentation copied from the inherited specification
182
	// Documentation copied from the inherited specification
178
	public EMFCommandTransaction createTransaction(Command command, Map options) throws InterruptedException {
183
	public EMFCommandTransaction createTransaction(Command command, Map<?, ?> options)
184
			throws InterruptedException {
185
		
179
		EMFCommandTransaction result;
186
		EMFCommandTransaction result;
180
		
187
		
181
		if (command instanceof TriggerCommand) {
188
		if (command instanceof TriggerCommand) {
Lines 191-197 Link Here
191
	}
198
	}
192
199
193
	// Documentation copied from the inherited specification
200
	// Documentation copied from the inherited specification
194
	public void executeTriggers(Command command, List triggers, Map options) throws InterruptedException, RollbackException {
201
	public void executeTriggers(Command command, List<Command> triggers,
202
			Map<?, ?> options) throws InterruptedException, RollbackException {
203
		
195
		if (!triggers.isEmpty()) {
204
		if (!triggers.isEmpty()) {
196
			TriggerCommand trigger = (command == null)
205
			TriggerCommand trigger = (command == null)
197
				? new TriggerCommand(triggers)
206
				? new TriggerCommand(triggers)
(-)src/org/eclipse/emf/transaction/impl/FilterManager.java (-12 / +13 lines)
Lines 18-24 Link Here
18
18
19
import java.util.ArrayList;
19
import java.util.ArrayList;
20
import java.util.Collections;
20
import java.util.Collections;
21
import java.util.Iterator;
22
import java.util.List;
21
import java.util.List;
23
22
24
import org.eclipse.emf.common.notify.Notification;
23
import org.eclipse.emf.common.notify.Notification;
Lines 70-77 Link Here
70
	 * 
69
	 * 
71
	 * @see #selectUnbatched(List, NotificationFilter)
70
	 * @see #selectUnbatched(List, NotificationFilter)
72
	 */
71
	 */
73
	public List select(List notifications, NotificationFilter filter, ArrayList cache) {
72
	public List<Notification> select(List<Notification> notifications,
74
		List result;
73
			NotificationFilter filter, ArrayList<Notification> cache) {
74
		List<Notification> result;
75
		
75
		
76
		if (filter == NotificationFilter.ANY) {
76
		if (filter == NotificationFilter.ANY) {
77
			result = notifications;
77
			result = notifications;
Lines 84-92 Link Here
84
				filter = NotificationFilter.NOT_TOUCH;
84
				filter = NotificationFilter.NOT_TOUCH;
85
			}
85
			}
86
			
86
			
87
			for (Iterator iter = notifications.iterator(); iter.hasNext();) {
87
			for (Notification next : notifications) {
88
				Notification next = (Notification) iter.next();
89
				
90
				if (filter.matches(next)) {
88
				if (filter.matches(next)) {
91
					result.add(next);
89
					result.add(next);
92
				}
90
				}
Lines 111-118 Link Here
111
	 * 
109
	 * 
112
	 * @see #selectUnbatched(List, NotificationFilter)
110
	 * @see #selectUnbatched(List, NotificationFilter)
113
	 */
111
	 */
114
	public List select(List notifications, NotificationFilter filter) {
112
	public List<Notification> select(List<Notification> notifications,
115
		return select(notifications, filter, new ArrayList());
113
			NotificationFilter filter) {
114
		return select(notifications, filter, new ArrayList<Notification>());
116
	}
115
	}
117
	
116
	
118
	/**
117
	/**
Lines 132-149 Link Here
132
	 * 
131
	 * 
133
	 * @see #select(List, NotificationFilter)
132
	 * @see #select(List, NotificationFilter)
134
	 */
133
	 */
135
	public List selectUnbatched(List notification, NotificationFilter filter) {
134
	public List<Notification> selectUnbatched(List<Notification> notification,
136
		List result;
135
			NotificationFilter filter) {
136
		
137
		List<Notification> result;
137
		
138
		
138
		if (filter == null) {
139
		if (filter == null) {
139
			// the default filter
140
			// the default filter
140
			filter = NotificationFilter.NOT_TOUCH;
141
			filter = NotificationFilter.NOT_TOUCH;
141
		}
142
		}
142
143
143
		if (filter.matches((Notification) notification.get(0))) {
144
		if (filter.matches(notification.get(0))) {
144
			result = notification;
145
			result = notification;
145
		} else {
146
		} else {
146
			result = Collections.EMPTY_LIST;
147
			result = Collections.emptyList();
147
		}
148
		}
148
		
149
		
149
		return result;
150
		return result;
(-)src/org/eclipse/emf/transaction/impl/PrivilegedRunnable.java (-5 / +8 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 26-35 Link Here
26
/**
26
/**
27
 * Implementation of the privileged runnable, which allows a thread to lend
27
 * Implementation of the privileged runnable, which allows a thread to lend
28
 * its transaction to another cooperating thread for synchronous execution.
28
 * its transaction to another cooperating thread for synchronous execution.
29
 *
29
 * 
30
 * @param <T> the result type of the runnable
31
 * 
30
 * @author Christian W. Damus (cdamus)
32
 * @author Christian W. Damus (cdamus)
31
 */
33
 */
32
public final class PrivilegedRunnable extends RunnableWithResult.Impl {
34
public final class PrivilegedRunnable<T> extends RunnableWithResult.Impl<T> {
33
	private final InternalTransaction transaction;
35
	private final InternalTransaction transaction;
34
	private final Runnable delegate;
36
	private final Runnable delegate;
35
	private final Thread owner;
37
	private final Thread owner;
Lines 70-77 Link Here
70
	 * Runs my delegate in the context of the transaction that I share.
72
	 * Runs my delegate in the context of the transaction that I share.
71
	 */
73
	 */
72
	public void run() {
74
	public void run() {
73
		final RunnableWithResult rwr = (delegate instanceof RunnableWithResult)?
75
		@SuppressWarnings("unchecked")
74
			(RunnableWithResult) delegate : null;
76
		final RunnableWithResult<T> rwr = (delegate instanceof RunnableWithResult)?
77
			(RunnableWithResult<T>) delegate : null;
75
		
78
		
76
		boolean needPrivilege = transaction.getOwner() != Thread.currentThread();
79
		boolean needPrivilege = transaction.getOwner() != Thread.currentThread();
77
		if (needPrivilege) {
80
		if (needPrivilege) {
(-)src/org/eclipse/emf/transaction/impl/AbstractTransactionalCommandStack.java (-11 / +13 lines)
Lines 95-101 Link Here
95
     * transaction (if any) and passing the exception along to
95
     * transaction (if any) and passing the exception along to
96
     * the registered exception handler (if any).
96
     * the registered exception handler (if any).
97
     */
97
     */
98
    protected void handleError(Exception exception) {
98
    @Override
99
	protected void handleError(Exception exception) {
99
    	InternalTransaction active = getDomain().getActiveTransaction();
100
    	InternalTransaction active = getDomain().getActiveTransaction();
100
    	
101
    	
101
    	if ((active != null) && active.isActive()) {
102
    	if ((active != null) && active.isActive()) {
Lines 156-162 Link Here
156
     * command is rolled back.  Note that <code>doExecute()</code> is only
157
     * command is rolled back.  Note that <code>doExecute()</code> is only
157
     * called if the command is {@linkplain Command#canExecute() executable}.
158
     * called if the command is {@linkplain Command#canExecute() executable}.
158
     */
159
     */
159
    public void execute(Command command, Map options)
160
    public void execute(Command command, Map<?, ?> options)
160
            throws InterruptedException, RollbackException {
161
            throws InterruptedException, RollbackException {
161
        
162
        
162
        if ((command != null) && command.canExecute()) {
163
        if ((command != null) && command.canExecute()) {
Lines 184-190 Link Here
184
     *     waiting to start the transaction
185
     *     waiting to start the transaction
185
     * @throws RollbackException if the execution of the command is rolled back
186
     * @throws RollbackException if the execution of the command is rolled back
186
     */
187
     */
187
    protected abstract void doExecute(Command command, Map options)
188
    protected abstract void doExecute(Command command, Map<?, ?> options)
188
            throws InterruptedException, RollbackException;
189
            throws InterruptedException, RollbackException;
189
190
190
    /**
191
    /**
Lines 212-218 Link Here
212
     * checked exception thrown by that method is handled by
213
     * checked exception thrown by that method is handled by
213
     * {@link #handleError(Exception)} but is not propagated.
214
     * {@link #handleError(Exception)} but is not propagated.
214
     */
215
     */
215
    public void execute(Command command) {
216
    @Override
217
	public void execute(Command command) {
216
    	try {
218
    	try {
217
    		execute(command, null);
219
    		execute(command, null);
218
    	} catch (InterruptedException e) {
220
    	} catch (InterruptedException e) {
Lines 244-250 Link Here
244
     * 
246
     * 
245
     * @return my editing domain's transaction options for undo/redo
247
     * @return my editing domain's transaction options for undo/redo
246
     */
248
     */
247
    protected Map getUndoRedoOptions() {
249
    protected Map<Object, Object> getUndoRedoOptions() {
248
    	return domain.getUndoRedoOptions();
250
    	return domain.getUndoRedoOptions();
249
    }
251
    }
250
    
252
    
Lines 255-270 Link Here
255
     * @param options a client-supplied options map
257
     * @param options a client-supplied options map
256
     * @return a derived map of options suitable for trigger transactions
258
     * @return a derived map of options suitable for trigger transactions
257
     */
259
     */
258
    public static final Map makeTriggerTransactionOptions(Map options) {
260
    public static final Map<Object, Object> makeTriggerTransactionOptions(Map<?, ?> options) {
259
        Map result;
261
        Map<Object, Object> result;
260
        
262
        
261
        if ((options == null) || options.isEmpty()) {
263
        if ((options == null) || options.isEmpty()) {
262
            result = Collections.singletonMap(
264
            result = Collections.<Object, Object>singletonMap(
263
                TransactionImpl.OPTION_IS_TRIGGER_TRANSACTION, Boolean.TRUE); 
265
                TransactionImpl.OPTION_IS_TRIGGER_TRANSACTION, true); 
264
        } else {
266
        } else {
265
            result = new java.util.HashMap(options);
267
            result = new java.util.HashMap<Object, Object>(options);
266
            result.put(
268
            result.put(
267
                TransactionImpl.OPTION_IS_TRIGGER_TRANSACTION, Boolean.TRUE);
269
                TransactionImpl.OPTION_IS_TRIGGER_TRANSACTION, true);
268
        }
270
        }
269
        
271
        
270
        return result;
272
        return result;
(-)src/org/eclipse/emf/transaction/impl/TransactionValidator.java (-9 / +10 lines)
Lines 21-26 Link Here
21
21
22
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.IStatus;
23
import org.eclipse.core.runtime.Status;
23
import org.eclipse.core.runtime.Status;
24
import org.eclipse.emf.common.notify.Notification;
24
import org.eclipse.emf.transaction.RollbackException;
25
import org.eclipse.emf.transaction.RollbackException;
25
import org.eclipse.emf.transaction.Transaction;
26
import org.eclipse.emf.transaction.Transaction;
26
27
Lines 57-74 Link Here
57
		}
58
		}
58
59
59
		// Documentation copied from the inherited specification
60
		// Documentation copied from the inherited specification
60
		public List getNotificationsForValidation(Transaction tx) {
61
		public List<Notification> getNotificationsForValidation(Transaction tx) {
61
			return Collections.EMPTY_LIST;
62
			return Collections.emptyList();
62
		}
63
		}
63
64
64
		// Documentation copied from the inherited specification
65
		// Documentation copied from the inherited specification
65
		public List getNotificationsForPrecommit(Transaction tx) {
66
		public List<Notification> getNotificationsForPrecommit(Transaction tx) {
66
			return Collections.EMPTY_LIST;
67
			return Collections.emptyList();
67
		}
68
		}
68
69
69
		// Documentation copied from the inherited specification
70
		// Documentation copied from the inherited specification
70
		public List getNotificationsForPostcommit(Transaction tx) {
71
		public List<Notification> getNotificationsForPostcommit(Transaction tx) {
71
			return Collections.EMPTY_LIST;
72
			return Collections.emptyList();
72
		}
73
		}
73
74
74
		// Documentation copied from the inherited specification
75
		// Documentation copied from the inherited specification
Lines 124-130 Link Here
124
	 * @return the transaction's notifications, or <code>null</code> if the
125
	 * @return the transaction's notifications, or <code>null</code> if the
125
	 *     transaction has not started yet
126
	 *     transaction has not started yet
126
	 */
127
	 */
127
	List getNotificationsForValidation(Transaction tx);
128
	List<Notification> getNotificationsForValidation(Transaction tx);
128
	
129
	
129
	/**
130
	/**
130
	 * Obtains the notifications that I need to broadcast in a pre-commit
131
	 * Obtains the notifications that I need to broadcast in a pre-commit
Lines 136-142 Link Here
136
	 * @return those of the transaction's notifications that are eligible to
137
	 * @return those of the transaction's notifications that are eligible to
137
	 *     be broadcast, or <code>null</code> if the transaction has not started
138
	 *     be broadcast, or <code>null</code> if the transaction has not started
138
	 */
139
	 */
139
	List getNotificationsForPrecommit(Transaction tx);
140
	List<Notification> getNotificationsForPrecommit(Transaction tx);
140
	
141
	
141
	/**
142
	/**
142
	 * Obtains the notifications that I need to broadcast in a post-commit
143
	 * Obtains the notifications that I need to broadcast in a post-commit
Lines 148-154 Link Here
148
	 * @return those of the transaction's notifications that are eligible to
149
	 * @return those of the transaction's notifications that are eligible to
149
	 *     be broadcast, or <code>null</code> if the transaction has not started
150
	 *     be broadcast, or <code>null</code> if the transaction has not started
150
	 */
151
	 */
151
	List getNotificationsForPostcommit(Transaction tx);
152
	List<Notification> getNotificationsForPostcommit(Transaction tx);
152
	
153
	
153
	/**
154
	/**
154
	 * Disposes me by clearing my state and cleaning up any resources that I
155
	 * Disposes me by clearing my state and cleaning up any resources that I
(-)src/org/eclipse/emf/transaction/impl/TransactionalEditingDomainImpl.java (-138 / +164 lines)
Lines 32-37 Link Here
32
import org.eclipse.emf.common.notify.AdapterFactory;
32
import org.eclipse.emf.common.notify.AdapterFactory;
33
import org.eclipse.emf.common.notify.Notification;
33
import org.eclipse.emf.common.notify.Notification;
34
import org.eclipse.emf.common.notify.impl.AdapterImpl;
34
import org.eclipse.emf.common.notify.impl.AdapterImpl;
35
import org.eclipse.emf.ecore.resource.Resource;
35
import org.eclipse.emf.ecore.resource.ResourceSet;
36
import org.eclipse.emf.ecore.resource.ResourceSet;
36
import org.eclipse.emf.ecore.util.EcoreUtil;
37
import org.eclipse.emf.ecore.util.EcoreUtil;
37
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
38
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
Lines 52-57 Link Here
52
import org.eclipse.emf.transaction.internal.l10n.Messages;
53
import org.eclipse.emf.transaction.internal.l10n.Messages;
53
import org.eclipse.emf.transaction.util.Adaptable;
54
import org.eclipse.emf.transaction.util.Adaptable;
54
import org.eclipse.emf.transaction.util.Lock;
55
import org.eclipse.emf.transaction.util.Lock;
56
import org.eclipse.emf.transaction.util.TransactionUtil;
55
import org.eclipse.osgi.util.NLS;
57
import org.eclipse.osgi.util.NLS;
56
58
57
/**
59
/**
Lines 80-103 Link Here
80
	
82
	
81
	private TransactionValidator.Factory validatorFactory = null;
83
	private TransactionValidator.Factory validatorFactory = null;
82
	
84
	
83
	private final Map defaultTransactionOptions = new java.util.HashMap();
85
	private final Map<Object, Object> defaultTransactionOptions =
84
	private final Map defaultTransactionOptionsRO = Collections
86
		new java.util.HashMap<Object, Object>();
87
	private final Map<Object, Object> defaultTransactionOptionsRO = Collections
85
        .unmodifiableMap(defaultTransactionOptions);
88
        .unmodifiableMap(defaultTransactionOptions);
86
	
89
	
87
	private Lock transactionLock = new Lock();
90
	private final Lock transactionLock = new Lock();
88
	private Lock writeLock = new Lock();
91
	private final Lock writeLock = new Lock();
89
	
92
	
90
	private final List precommitListeners = new java.util.ArrayList();
93
	private final List<ResourceSetListener> precommitListeners =
91
	private final List aggregatePrecommitListeners = new java.util.ArrayList();
94
		new java.util.ArrayList<ResourceSetListener>();
92
	private final List postcommitListeners = new java.util.ArrayList();
95
	private final List<ResourceSetListener> aggregatePrecommitListeners =
96
		new java.util.ArrayList<ResourceSetListener>();
97
	private final List<ResourceSetListener> postcommitListeners =
98
		new java.util.ArrayList<ResourceSetListener>();
93
	
99
	
94
	// reusable notification list and event for unbatched change events
100
	// reusable notification list and event for unbatched change events
95
	private final List unbatchedNotifications = new java.util.ArrayList(1);
101
	private final List<Notification> unbatchedNotifications =
102
		new java.util.ArrayList<Notification>(1);
96
	private final ResourceSetChangeEvent unbatchedChangeEvent =
103
	private final ResourceSetChangeEvent unbatchedChangeEvent =
97
		new ResourceSetChangeEvent(this, null, unbatchedNotifications);
104
		new ResourceSetChangeEvent(this, null, unbatchedNotifications);
98
	
105
	
99
	// this is editable by clients for backwards compatibility with 1.1
106
	// this is editable by clients for backwards compatibility with 1.1
100
	private Map undoRedoOptions = new java.util.HashMap(
107
	private final Map<Object, Object> undoRedoOptions = new java.util.HashMap<Object, Object>(
101
	    TransactionImpl.DEFAULT_UNDO_REDO_OPTIONS);
108
	    TransactionImpl.DEFAULT_UNDO_REDO_OPTIONS);
102
	
109
	
103
	/**
110
	/**
Lines 157-163 Link Here
157
        
164
        
158
        // create a map for read-only-resource support.  Use a weak map
165
        // create a map for read-only-resource support.  Use a weak map
159
        //    to avoid retaining resources in this map
166
        //    to avoid retaining resources in this map
160
        resourceToReadOnlyMap = new java.util.WeakHashMap();
167
        resourceToReadOnlyMap = new java.util.WeakHashMap<Resource, Boolean>();
161
	}
168
	}
162
	
169
	
163
	/**
170
	/**
Lines 275-282 Link Here
275
			tx = startTransaction(true, null);
282
			tx = startTransaction(true, null);
276
		}
283
		}
277
		
284
		
278
		final RunnableWithResult rwr = (read instanceof RunnableWithResult)?
285
		final RunnableWithResult<?> rwr = (read instanceof RunnableWithResult)?
279
			(RunnableWithResult) read : null;
286
			(RunnableWithResult<?>) read : null;
280
		
287
		
281
		try {
288
		try {
282
			read.run();
289
			read.run();
Lines 369-375 Link Here
369
	}
376
	}
370
377
371
	// Documentation copied from the inherited specification
378
	// Documentation copied from the inherited specification
372
	public InternalTransaction startTransaction(boolean readOnly, Map options) throws InterruptedException {
379
	public InternalTransaction startTransaction(boolean readOnly, Map<?, ?> options)
380
			throws InterruptedException {
381
		
373
		InternalTransaction result;
382
		InternalTransaction result;
374
		
383
		
375
		result = new TransactionImpl(this, readOnly, options);
384
		result = new TransactionImpl(this, readOnly, options);
Lines 412-418 Link Here
412
	 */
421
	 */
413
	protected final ResourceSetListener[] getPrecommitListeners() {
422
	protected final ResourceSetListener[] getPrecommitListeners() {
414
		synchronized (precommitListeners) {
423
		synchronized (precommitListeners) {
415
			return (ResourceSetListener[]) precommitListeners.toArray(
424
			return precommitListeners.toArray(
416
				new ResourceSetListener[precommitListeners.size()]);
425
				new ResourceSetListener[precommitListeners.size()]);
417
		}
426
		}
418
	}
427
	}
Lines 426-432 Link Here
426
	 */
435
	 */
427
	protected final ResourceSetListener[] getAggregatePrecommitListeners() {
436
	protected final ResourceSetListener[] getAggregatePrecommitListeners() {
428
		synchronized (aggregatePrecommitListeners) {
437
		synchronized (aggregatePrecommitListeners) {
429
			return (ResourceSetListener[]) aggregatePrecommitListeners.toArray(
438
			return aggregatePrecommitListeners.toArray(
430
				new ResourceSetListener[aggregatePrecommitListeners.size()]);
439
				new ResourceSetListener[aggregatePrecommitListeners.size()]);
431
		}
440
		}
432
	}
441
	}
Lines 439-445 Link Here
439
	 */
448
	 */
440
	protected final ResourceSetListener[] getPostcommitListeners() {
449
	protected final ResourceSetListener[] getPostcommitListeners() {
441
		synchronized (postcommitListeners) {
450
		synchronized (postcommitListeners) {
442
			return (ResourceSetListener[]) postcommitListeners.toArray(
451
			return postcommitListeners.toArray(
443
				new ResourceSetListener[postcommitListeners.size()]);
452
				new ResourceSetListener[postcommitListeners.size()]);
444
		}
453
		}
445
	}
454
	}
Lines 561-580 Link Here
561
	
570
	
562
	// Documentation copied from the inherited specification
571
	// Documentation copied from the inherited specification
563
	public void precommit(final InternalTransaction tx) throws RollbackException {
572
	public void precommit(final InternalTransaction tx) throws RollbackException {
564
		class PrecommitRunnable implements Runnable {
573
		class PrecommitRunnable extends RunnableWithResult.Impl<List<Command>> {
565
			private final List notifications;
574
			private final List<Notification> notifications;
566
			private final ResourceSetListener[] listeners;
575
			private final ResourceSetListener[] listeners;
567
			private final List triggers = new java.util.ArrayList();
568
			private RollbackException rollback;
576
			private RollbackException rollback;
569
			
577
			
570
			PrecommitRunnable(ResourceSetListener[] listeners, List notifications) {
578
			PrecommitRunnable(ResourceSetListener[] listeners,
579
					List<Notification> notifications) {
580
				
571
				this.listeners = listeners;
581
				this.listeners = listeners;
572
				this.notifications = notifications;
582
				this.notifications = notifications;
573
			}
583
			}
574
			
584
			
575
			void runExclusive() throws InterruptedException {
585
			List<Command> runExclusive() throws InterruptedException {
576
				if ((listeners.length > 0) && !notifications.isEmpty()) {
586
				if ((listeners.length > 0) && !notifications.isEmpty()) {
577
					TransactionalEditingDomainImpl.this.runExclusive(this);
587
					return TransactionUtil.runExclusive(
588
						TransactionalEditingDomainImpl.this, this);
589
				} else {
590
					return Collections.emptyList();
578
				}
591
				}
579
			}
592
			}
580
			
593
			
Lines 582-602 Link Here
582
				return rollback;
595
				return rollback;
583
			}
596
			}
584
			
597
			
585
			List getTriggers() {
586
				return triggers;
587
			}
588
			
589
			public void run() {
598
			public void run() {
590
				ArrayList cache = new ArrayList(notifications.size());
599
				List<Command> triggers = new java.util.ArrayList<Command>();
591
				for (int i = 0; i < listeners.length; i++) {
600
				setResult(triggers);
601
				
602
				ArrayList<Notification> cache = new ArrayList<Notification>(
603
						notifications.size());
604
				
605
				for (ResourceSetListener element : listeners) {
592
					try {
606
					try {
593
						List filtered = FilterManager.getInstance().select(
607
						List<Notification> filtered = FilterManager.getInstance().select(
594
								notifications,
608
								notifications,
595
								listeners[i].getFilter(),
609
								element.getFilter(),
596
								cache);
610
								cache);
597
						
611
						
598
						if (!filtered.isEmpty()) {
612
						if (!filtered.isEmpty()) {
599
							Command cmd = listeners[i].transactionAboutToCommit(
613
							Command cmd = element.transactionAboutToCommit(
600
									new ResourceSetChangeEvent(
614
									new ResourceSetChangeEvent(
601
											TransactionalEditingDomainImpl.this,
615
											TransactionalEditingDomainImpl.this,
602
											tx,
616
											tx,
Lines 640-646 Link Here
640
		//    are no more notifications to send to them
654
		//    are no more notifications to send to them
641
		while (runnable != null) {
655
		while (runnable != null) {
642
			try {
656
			try {
643
				runnable.runExclusive();
657
				List<Command> triggers = runnable.runExclusive();
644
				
658
				
645
				if (runnable.getRollback() != null) {
659
				if (runnable.getRollback() != null) {
646
					Tracing.throwing(TransactionalEditingDomainImpl.class,
660
					Tracing.throwing(TransactionalEditingDomainImpl.class,
Lines 655-664 Link Here
655
					command = null;
669
					command = null;
656
				}
670
				}
657
				
671
				
658
				getTransactionalCommandStack().executeTriggers(
672
				if (!triggers.isEmpty()) {
659
					command, runnable.getTriggers(), tx.getOptions());
673
					getTransactionalCommandStack().executeTriggers(
674
						command, triggers, tx.getOptions());
675
				}
660
				
676
				
661
				List notifications = validator.getNotificationsForPrecommit(tx);
677
				List<Notification> notifications = validator.getNotificationsForPrecommit(
678
					tx);
662
				
679
				
663
				if ((notifications == null) || notifications.isEmpty()) {
680
				if ((notifications == null) || notifications.isEmpty()) {
664
					runnable = null;
681
					runnable = null;
Lines 697-707 Link Here
697
			Tracing.trace(">>> Postcommitting " + getDebugID(tx) + " at " + Tracing.now()); //$NON-NLS-1$ //$NON-NLS-2$
714
			Tracing.trace(">>> Postcommitting " + getDebugID(tx) + " at " + Tracing.now()); //$NON-NLS-1$ //$NON-NLS-2$
698
		}
715
		}
699
		
716
		
700
		final List notifications = validator.getNotificationsForPostcommit(tx);
717
		final List<Notification> notifications = validator.getNotificationsForPostcommit(
718
			tx);
701
		if ((notifications == null) || notifications.isEmpty()) {
719
		if ((notifications == null) || notifications.isEmpty()) {
702
			return;
720
			return;
703
		}
721
		}
704
		final ArrayList cache = new ArrayList(notifications.size());
722
		final ArrayList<Notification> cache = new ArrayList<Notification>(
723
				notifications.size());
705
		
724
		
706
		// dispose the validator now because starting the read-only transaction
725
		// dispose the validator now because starting the read-only transaction
707
		//    below will replace it with a new validator
726
		//    below will replace it with a new validator
Lines 712-726 Link Here
712
		try {
731
		try {
713
			runExclusive(new Runnable() {
732
			runExclusive(new Runnable() {
714
				public void run() {
733
				public void run() {
715
					for (int i = 0; i < listeners.length; i++) {
734
					for (ResourceSetListener element : listeners) {
716
						try {
735
						try {
717
							List filtered = FilterManager.getInstance().select(
736
							List<Notification> filtered = FilterManager.getInstance().select(
718
									notifications,
737
									notifications,
719
									listeners[i].getFilter(),
738
									element.getFilter(),
720
									cache);
739
									cache);
721
							
740
							
722
							if (!filtered.isEmpty()) {
741
							if (!filtered.isEmpty()) {
723
								listeners[i].resourceSetChanged(
742
								element.resourceSetChanged(
724
										new ResourceSetChangeEvent(
743
										new ResourceSetChangeEvent(
725
												TransactionalEditingDomainImpl.this,
744
												TransactionalEditingDomainImpl.this,
726
												tx,
745
												tx,
Lines 759-772 Link Here
759
		try {
778
		try {
760
			runExclusive(new Runnable() {
779
			runExclusive(new Runnable() {
761
				public void run() {
780
				public void run() {
762
					for (int i = 0; i < listeners.length; i++) {
781
					for (ResourceSetListener element : listeners) {
763
						try {
782
						try {
764
							List filtered = FilterManager.getInstance().selectUnbatched(
783
							List<Notification> filtered = FilterManager.getInstance().selectUnbatched(
765
									unbatchedNotifications,
784
									unbatchedNotifications,
766
									listeners[i].getFilter());
785
									element.getFilter());
767
							
786
							
768
							if (!filtered.isEmpty()) {
787
							if (!filtered.isEmpty()) {
769
								listeners[i].resourceSetChanged(unbatchedChangeEvent);
788
								element.resourceSetChanged(unbatchedChangeEvent);
770
							}
789
							}
771
						} catch (Exception e) {
790
						} catch (Exception e) {
772
							Tracing.catching(TransactionalEditingDomainImpl.class, "broadcastUnbatched", e); //$NON-NLS-1$
791
							Tracing.catching(TransactionalEditingDomainImpl.class, "broadcastUnbatched", e); //$NON-NLS-1$
Lines 796-802 Link Here
796
	}
815
	}
797
	
816
	
798
	// Documentation copied from the inherited specification
817
	// Documentation copied from the inherited specification
799
	public final RunnableWithResult createPrivilegedRunnable(Runnable runnable) {
818
	public final RunnableWithResult<Object> createPrivilegedRunnable(Runnable runnable) {
800
		InternalTransaction tx = getActiveTransaction();
819
		InternalTransaction tx = getActiveTransaction();
801
		
820
		
802
		if ((tx == null) || (tx.getOwner() != Thread.currentThread())) {
821
		if ((tx == null) || (tx.getOwner() != Thread.currentThread())) {
Lines 804-814 Link Here
804
					"active transaction not owned by caller"); //$NON-NLS-1$
823
					"active transaction not owned by caller"); //$NON-NLS-1$
805
		}
824
		}
806
		
825
		
807
		return new PrivilegedRunnable(tx, runnable);
826
		return new PrivilegedRunnable<Object>(tx, runnable);
808
	}
827
	}
809
	
828
	
810
	// Documentation copied from the inherited specification
829
	// Documentation copied from the inherited specification
811
	public void startPrivileged(PrivilegedRunnable runnable) {
830
	public void startPrivileged(PrivilegedRunnable<?> runnable) {
812
		if (runnable.getTransaction().getEditingDomain() != this) {
831
		if (runnable.getTransaction().getEditingDomain() != this) {
813
			throw new IllegalArgumentException(
832
			throw new IllegalArgumentException(
814
					"runnable has no privileges on this editing domain"); //$NON-NLS-1$
833
					"runnable has no privileges on this editing domain"); //$NON-NLS-1$
Lines 822-828 Link Here
822
		}
841
		}
823
		
842
		
824
	// Documentation copied from the inherited specification
843
	// Documentation copied from the inherited specification
825
	public void endPrivileged(PrivilegedRunnable runnable) {
844
	public void endPrivileged(PrivilegedRunnable<?> runnable) {
826
		if (runnable.getTransaction().getEditingDomain() != this) {
845
		if (runnable.getTransaction().getEditingDomain() != this) {
827
			throw new IllegalArgumentException(
846
			throw new IllegalArgumentException(
828
					"runnable has no privileges on this editing domain"); //$NON-NLS-1$
847
					"runnable has no privileges on this editing domain"); //$NON-NLS-1$
Lines 853-858 Link Here
853
		// disconnect the resource set from the editing domain
872
		// disconnect the resource set from the editing domain
854
		((FactoryImpl) Factory.INSTANCE).unmapResourceSet(this);
873
		((FactoryImpl) Factory.INSTANCE).unmapResourceSet(this);
855
	}
874
	}
875
876
	public Map<Object, Object> getUndoRedoOptions() {
877
		return undoRedoOptions;
878
	}
879
	
880
	@SuppressWarnings("unchecked")
881
	public <T> T getAdapter(Class<? extends T> adapterType) {
882
	    T result;
883
	    
884
	    if (adapterType == DefaultOptions.class) {
885
	        result = (T) this;
886
	    } else {
887
	        result = null;
888
	    }
889
	    
890
	    return result;
891
	}
892
	
893
	public Map<Object, Object> getDefaultTransactionOptions() {
894
	    return defaultTransactionOptionsRO;  // return the read-only view
895
	}
896
	
897
	public void setDefaultTransactionOptions(Map<?, ?> options) {
898
	    defaultTransactionOptions.clear();
899
	    defaultTransactionOptions.putAll(options);
900
	}
901
	
902
	/**
903
	 * Sets the factory to use when creating validators for transaction
904
	 * validation.
905
	 * 
906
	 * @since 1.1
907
	 * 
908
	 * @param validatorFactory the factory to set
909
	 */
910
	public void setValidatorFactory(TransactionValidator.Factory validatorFactory) {
911
		this.validatorFactory = validatorFactory;
912
	}
913
	
914
	/**
915
	 * Obtains the factory that this transactional editing domain uses
916
	 * to create validators for transaction validation.
917
	 * <p>
918
	 * If the validator factory has yet to be initialized, it is initialized
919
	 * using the default validator factory.
920
	 * </p>
921
	 * 
922
	 * @since 1.1
923
	 * 
924
	 * @return the requested validator factory
925
	 */
926
	public TransactionValidator.Factory getValidatorFactory() {
927
		if (this.validatorFactory == null) {
928
			return TransactionValidator.Factory.INSTANCE;
929
		}
930
        
931
		return this.validatorFactory;
932
	}
933
934
	/**
935
	 * Default implementation of the validator factory
936
	 * 
937
	 * @since 1.1
938
	 * 
939
	 * @author David Cummings (dcummin)
940
	 */
941
	public static class ValidatorFactoryImpl implements TransactionValidator.Factory {
942
		/**
943
	     * {@inheritDoc}
944
	     */
945
		public TransactionValidator createReadOnlyValidator() {
946
			return new ReadOnlyValidatorImpl();
947
		}
948
949
		/**
950
	     * {@inheritDoc}
951
	     */
952
		public TransactionValidator createReadWriteValidator() {
953
			return new ReadWriteValidatorImpl();
954
		}
955
	}
856
	
956
	
857
	/**
957
	/**
858
	 * Default implementation of a transaction editing domain factory.  This
958
	 * Default implementation of a transaction editing domain factory.  This
Lines 926-933 Link Here
926
		 * @param domain the editing domain to remove from the resource set mapping
1026
		 * @param domain the editing domain to remove from the resource set mapping
927
		 */
1027
		 */
928
		public synchronized void unmapResourceSet(TransactionalEditingDomain domain) {
1028
		public synchronized void unmapResourceSet(TransactionalEditingDomain domain) {
929
			for (Iterator iter = domain.getResourceSet().eAdapters().iterator(); iter.hasNext();) {
1029
			for (Iterator<Adapter> iter = domain.getResourceSet().eAdapters().iterator();
930
				Adapter next = (Adapter) iter.next();
1030
					iter.hasNext();) {
1031
				
1032
				Adapter next = iter.next();
931
				
1033
				
932
				if (next.isAdapterForType(ResourceSetDomainLink.class)) {
1034
				if (next.isAdapterForType(ResourceSetDomainLink.class)) {
933
					iter.remove();
1035
					iter.remove();
Lines 944-962 Link Here
944
		 *
1046
		 *
945
		 * @author Christian W. Damus (cdamus)
1047
		 * @author Christian W. Damus (cdamus)
946
		 */
1048
		 */
947
		private static class ResourceSetDomainLink extends AdapterImpl implements IEditingDomainProvider {
1049
		private static class ResourceSetDomainLink extends AdapterImpl
948
			private final Reference domain;
1050
				implements IEditingDomainProvider {
1051
			
1052
			private final Reference<TransactionalEditingDomain> domain;
949
			
1053
			
950
			ResourceSetDomainLink(TransactionalEditingDomain domain) {
1054
			ResourceSetDomainLink(TransactionalEditingDomain domain) {
951
				this.domain = new WeakReference(domain);
1055
				this.domain = new WeakReference<TransactionalEditingDomain>(domain);
952
			}
1056
			}
953
			
1057
			
1058
			@Override
954
			public boolean isAdapterForType(Object type) {
1059
			public boolean isAdapterForType(Object type) {
955
				return type == ResourceSetDomainLink.class;
1060
				return type == ResourceSetDomainLink.class;
956
			}
1061
			}
957
			
1062
			
958
			final TransactionalEditingDomain getDomain() {
1063
			final TransactionalEditingDomain getDomain() {
959
				TransactionalEditingDomain result = (TransactionalEditingDomain) domain.get();
1064
				TransactionalEditingDomain result = domain.get();
960
				
1065
				
961
				if (result == null) {
1066
				if (result == null) {
962
					// no longer need the adapter
1067
					// no longer need the adapter
Lines 981-991 Link Here
981
	 * @author Christian W. Damus (cdamus)
1086
	 * @author Christian W. Damus (cdamus)
982
	 */
1087
	 */
983
	public final static class RegistryImpl implements TransactionalEditingDomain.Registry {
1088
	public final static class RegistryImpl implements TransactionalEditingDomain.Registry {
984
		private final Map domains = new java.util.HashMap();
1089
		private final Map<String, TransactionalEditingDomain> domains =
1090
			new java.util.HashMap<String, TransactionalEditingDomain>();
985
		
1091
		
986
		// Documentation copied from the inherited specification
1092
		// Documentation copied from the inherited specification
987
		public synchronized TransactionalEditingDomain getEditingDomain(String id) {
1093
		public synchronized TransactionalEditingDomain getEditingDomain(String id) {
988
			TransactionalEditingDomain result = (TransactionalEditingDomain) domains.get(id);
1094
			TransactionalEditingDomain result = domains.get(id);
989
			
1095
			
990
			if (result == null) {
1096
			if (result == null) {
991
				result = EditingDomainManager.getInstance().createEditingDomain(id);
1097
				result = EditingDomainManager.getInstance().createEditingDomain(id);
Lines 1034-1040 Link Here
1034
				throw exc;
1140
				throw exc;
1035
			}
1141
			}
1036
			
1142
			
1037
			TransactionalEditingDomain result = (TransactionalEditingDomain) domains.remove(id);
1143
			TransactionalEditingDomain result = domains.remove(id);
1038
			
1144
			
1039
			if (result != null) {
1145
			if (result != null) {
1040
				EditingDomainManager.getInstance().deconfigureListeners(id, result);
1146
				EditingDomainManager.getInstance().deconfigureListeners(id, result);
Lines 1044-1127 Link Here
1044
		}
1150
		}
1045
		
1151
		
1046
	}
1152
	}
1047
1048
	public Map getUndoRedoOptions() {
1049
		return undoRedoOptions;
1050
	}
1051
	
1052
	public Object getAdapter(Class adapterType) {
1053
	    Object result;
1054
	    
1055
	    if (adapterType == DefaultOptions.class) {
1056
	        result = this;
1057
	    } else {
1058
	        result = null;
1059
	    }
1060
	    
1061
	    return result;
1062
	}
1063
	
1064
	public Map getDefaultTransactionOptions() {
1065
	    return defaultTransactionOptionsRO;  // return the read-only view
1066
	}
1067
	
1068
	public void setDefaultTransactionOptions(Map options) {
1069
	    defaultTransactionOptions.clear();
1070
	    defaultTransactionOptions.putAll(options);
1071
	}
1072
	
1073
	/**
1074
	 * Sets the factory to use when creating validators for transaction
1075
	 * validation.
1076
	 * 
1077
	 * @since 1.1
1078
	 * 
1079
	 * @param validatorFactory the factory to set
1080
	 */
1081
	public void setValidatorFactory(TransactionValidator.Factory validatorFactory) {
1082
		this.validatorFactory = validatorFactory;
1083
	}
1084
	
1085
	/**
1086
	 * Obtains the factory that this transactional editing domain uses
1087
	 * to create validators for transaction validation.
1088
	 * <p>
1089
	 * If the validator factory has yet to be initialized, it is initialized
1090
	 * using the default validator factory.
1091
	 * </p>
1092
	 * 
1093
	 * @since 1.1
1094
	 * 
1095
	 * @return the requested validator factory
1096
	 */
1097
	public TransactionValidator.Factory getValidatorFactory() {
1098
		if (this.validatorFactory == null) {
1099
			return TransactionValidator.Factory.INSTANCE;
1100
		}
1101
        
1102
		return this.validatorFactory;
1103
	}
1104
1105
	/**
1106
	 * Default implementation of the validator factory
1107
	 * 
1108
	 * @since 1.1
1109
	 * 
1110
	 * @author David Cummings (dcummin)
1111
	 */
1112
	public static class ValidatorFactoryImpl implements TransactionValidator.Factory {
1113
		/**
1114
	     * {@inheritDoc}
1115
	     */
1116
		public TransactionValidator createReadOnlyValidator() {
1117
			return new ReadOnlyValidatorImpl();
1118
		}
1119
1120
		/**
1121
	     * {@inheritDoc}
1122
	     */
1123
		public TransactionValidator createReadWriteValidator() {
1124
			return new ReadWriteValidatorImpl();
1125
		}
1126
	}
1127
}
1153
}
(-)src/org/eclipse/emf/transaction/impl/InternalTransaction.java (-3 / +3 lines)
Lines 99-105 Link Here
99
	 * 
99
	 * 
100
	 * @see #add(Notification)
100
	 * @see #add(Notification)
101
	 */
101
	 */
102
	List getNotifications();
102
	List<Notification> getNotifications();
103
	
103
	
104
	/**
104
	/**
105
	 * Pauses me while a child transaction is active, so that I do not collect
105
	 * Pauses me while a child transaction is active, so that I do not collect
Lines 157-163 Link Here
157
	 *  
157
	 *  
158
	 * @param runnable the runnable whose thread is to borrow me
158
	 * @param runnable the runnable whose thread is to borrow me
159
	 */
159
	 */
160
	void startPrivileged(PrivilegedRunnable runnable);
160
	void startPrivileged(PrivilegedRunnable<?> runnable);
161
	
161
	
162
	/**
162
	/**
163
	 * Returns me to my previous owner, upon completion of the specified
163
	 * Returns me to my previous owner, upon completion of the specified
Lines 165-169 Link Here
165
	 * 
165
	 * 
166
	 * @param runnable the runnable whose thread had borrowed me
166
	 * @param runnable the runnable whose thread had borrowed me
167
	 */
167
	 */
168
	void endPrivileged(PrivilegedRunnable runnable);
168
	void endPrivileged(PrivilegedRunnable<?> runnable);
169
}
169
}
(-)src/org/eclipse/emf/transaction/impl/TransactionImpl.java (-29 / +33 lines)
Lines 17-23 Link Here
17
package org.eclipse.emf.transaction.impl;
17
package org.eclipse.emf.transaction.impl;
18
18
19
import java.util.Collections;
19
import java.util.Collections;
20
import java.util.Iterator;
21
import java.util.List;
20
import java.util.List;
22
import java.util.Map;
21
import java.util.Map;
23
22
Lines 86-98 Link Here
86
	 * As of the 1.2 release, this map is immutable.
85
	 * As of the 1.2 release, this map is immutable.
87
	 * </p>
86
	 * </p>
88
	 */
87
	 */
89
	public static final Map DEFAULT_UNDO_REDO_OPTIONS;
88
	public static final Map<Object, Object> DEFAULT_UNDO_REDO_OPTIONS;
90
	static {
89
	static {
91
		Map map = new java.util.HashMap();
90
		Map<Object, Object> map = new java.util.HashMap<Object, Object>();
92
		map.put(Transaction.OPTION_NO_TRIGGERS, Boolean.TRUE);
91
		map.put(Transaction.OPTION_NO_TRIGGERS, true);
93
		map.put(Transaction.OPTION_NO_UNDO, Boolean.TRUE);
92
		map.put(Transaction.OPTION_NO_UNDO, true);
94
		map.put(Transaction.OPTION_NO_VALIDATION, Boolean.TRUE);
93
		map.put(Transaction.OPTION_NO_VALIDATION, true);
95
		map.put(Transaction.OPTION_IS_UNDO_REDO_TRANSACTION, Boolean.TRUE);
94
		map.put(Transaction.OPTION_IS_UNDO_REDO_TRANSACTION, true);
96
		DEFAULT_UNDO_REDO_OPTIONS = Collections.unmodifiableMap(map);
95
		DEFAULT_UNDO_REDO_OPTIONS = Collections.unmodifiableMap(map);
97
	}
96
	}
98
	
97
	
Lines 103-110 Link Here
103
	private final TransactionalEditingDomain domain;
102
	private final TransactionalEditingDomain domain;
104
	private Thread owner;
103
	private Thread owner;
105
	private final boolean readOnly;
104
	private final boolean readOnly;
106
	private final Map options;
105
	private final Map<Object, Object> options;
107
	private final Map mutableOptions;
106
	private final Map<Object, Object> mutableOptions;
108
	
107
	
109
	private InternalTransaction parent;
108
	private InternalTransaction parent;
110
	private InternalTransaction root;
109
	private InternalTransaction root;
Lines 112-118 Link Here
112
	private boolean active;
111
	private boolean active;
113
	private boolean closing; // prevents re-entrant commit/rollback
112
	private boolean closing; // prevents re-entrant commit/rollback
114
	private boolean rollingBack;
113
	private boolean rollingBack;
115
	protected List notifications;
114
	protected List<Notification> notifications;
116
	protected final CompositeChangeDescription change;
115
	protected final CompositeChangeDescription change;
117
	
116
	
118
	private boolean aborted;
117
	private boolean aborted;
Lines 140-151 Link Here
140
	 *     if I am read/write
139
	 *     if I am read/write
141
	 * @param options my options, or <code>null</code> for defaults
140
	 * @param options my options, or <code>null</code> for defaults
142
	 */
141
	 */
143
	public TransactionImpl(TransactionalEditingDomain domain, boolean readOnly, Map options) {
142
	public TransactionImpl(TransactionalEditingDomain domain, boolean readOnly,
143
			Map<?, ?> options) {
144
		this.domain = domain;
144
		this.domain = domain;
145
		this.readOnly = readOnly;
145
		this.readOnly = readOnly;
146
		this.owner = Thread.currentThread();
146
		this.owner = Thread.currentThread();
147
		
147
		
148
		this.mutableOptions = new java.util.HashMap();
148
		this.mutableOptions = new java.util.HashMap<Object, Object>();
149
		this.options = Collections.unmodifiableMap(mutableOptions);
149
		this.options = Collections.unmodifiableMap(mutableOptions);
150
		
150
		
151
		if (options != null) {
151
		if (options != null) {
Lines 159-165 Link Here
159
		change = new CompositeChangeDescription();
159
		change = new CompositeChangeDescription();
160
		
160
		
161
		if (collectsNotifications(this)) {
161
		if (collectsNotifications(this)) {
162
			notifications = new org.eclipse.emf.common.util.BasicEList.FastCompare();
162
			notifications = new org.eclipse.emf.common.util.BasicEList.FastCompare<Notification>();
163
		} else {
163
		} else {
164
			// no need to collect any notifications if we won't use them
164
			// no need to collect any notifications if we won't use them
165
			notifications = null;
165
			notifications = null;
Lines 265-271 Link Here
265
	}
265
	}
266
266
267
	// Documentation copied from the inherited specification
267
	// Documentation copied from the inherited specification
268
	public final Map getOptions() {
268
	public final Map<Object, Object> getOptions() {
269
		return options;
269
		return options;
270
	}
270
	}
271
271
Lines 628-635 Link Here
628
				//  my changes except for certain special cases where we must
628
				//  my changes except for certain special cases where we must
629
				//  prevent the passing of our changes.
629
				//  prevent the passing of our changes.
630
				
630
				
631
				if (getOptions().get(BLOCK_CHANGE_PROPAGATION) == Boolean.TRUE
631
				if (hasOption(this, BLOCK_CHANGE_PROPAGATION)
632
						&& parent.getOptions().get(ALLOW_CHANGE_PROPAGATION_BLOCKING) == Boolean.TRUE) {
632
						&& hasOption(parent, ALLOW_CHANGE_PROPAGATION_BLOCKING)) {
633
					parent.resume(null);
633
					parent.resume(null);
634
				} else {
634
				} else {
635
					parent.resume(change);
635
					parent.resume(change);
Lines 653-660 Link Here
653
	}
653
	}
654
	
654
	
655
	// Documentation copied from the inherited specification
655
	// Documentation copied from the inherited specification
656
	public List getNotifications() {
656
	public List<Notification> getNotifications() {
657
		return (notifications == null)? Collections.EMPTY_LIST : notifications;
657
		return (notifications == null)? Collections.<Notification>emptyList()
658
			: notifications;
658
	}
659
	}
659
	
660
	
660
	/**
661
	/**
Lines 679-685 Link Here
679
	// Documentation copied from the inherited specification
680
	// Documentation copied from the inherited specification
680
	public void addTriggers(TriggerCommand triggers) {
681
	public void addTriggers(TriggerCommand triggers) {
681
		// extract out only the triggered commands (exclude the triggering command)
682
		// extract out only the triggered commands (exclude the triggering command)
682
		List triggerCommands = triggers.getTriggers();
683
		List<Command> triggerCommands = triggers.getTriggers();
683
		Command triggerCommand;
684
		Command triggerCommand;
684
		
685
		
685
		if (triggerCommands.isEmpty()) {
686
		if (triggerCommands.isEmpty()) {
Lines 689-695 Link Here
689
		// bug 165026:  Must copy the list, because it may be read-only like
690
		// bug 165026:  Must copy the list, because it may be read-only like
690
		//    GMF's NOOP_TRIGGER command
691
		//    GMF's NOOP_TRIGGER command
691
		triggerCommand = new ConditionalRedoCommand.Compound(
692
		triggerCommand = new ConditionalRedoCommand.Compound(
692
				new java.util.ArrayList(triggerCommands));
693
				new java.util.ArrayList<Command>(triggerCommands));
693
		
694
		
694
		if (this.triggers == null) {
695
		if (this.triggers == null) {
695
			this.triggers = triggerCommand;
696
			this.triggers = triggerCommand;
Lines 703-709 Link Here
703
	}
704
	}
704
	
705
	
705
	// Documentation copied from the inherited specification
706
	// Documentation copied from the inherited specification
706
	public void startPrivileged(PrivilegedRunnable runnable) {
707
	public void startPrivileged(PrivilegedRunnable<?> runnable) {
707
		if (runnable.getTransaction() != this) {
708
		if (runnable.getTransaction() != this) {
708
			throw new IllegalArgumentException(
709
			throw new IllegalArgumentException(
709
					"runnable has no privileges on this transaction"); //$NON-NLS-1$
710
					"runnable has no privileges on this transaction"); //$NON-NLS-1$
Lines 723-729 Link Here
723
	}
724
	}
724
725
725
	// Documentation copied from the inherited specification
726
	// Documentation copied from the inherited specification
726
	public void endPrivileged(PrivilegedRunnable runnable) {
727
	public void endPrivileged(PrivilegedRunnable<?> runnable) {
727
		if (runnable.getTransaction() != this) {
728
		if (runnable.getTransaction() != this) {
728
			throw new IllegalArgumentException(
729
			throw new IllegalArgumentException(
729
					"runnable has no privileges on this transaction"); //$NON-NLS-1$
730
					"runnable has no privileges on this transaction"); //$NON-NLS-1$
Lines 746-757 Link Here
746
        
747
        
747
	    // if we have no parent transaction, then we are a root and we "inherit"
748
	    // if we have no parent transaction, then we are a root and we "inherit"
748
	    // the editing domain's default transaction options
749
	    // the editing domain's default transaction options
749
        Map parentOptions = (parent == null) ? getDefaultOptions(getEditingDomain())
750
        Map<Object, Object> parentOptions = (parent == null) ?
750
            : parent.getOptions();
751
        	getDefaultOptions(getEditingDomain()) : parent.getOptions();
751
        
752
        
752
        if (parentOptions != null) {
753
        if (parentOptions != null) {
753
            for (Iterator iter = parentOptions.entrySet().iterator(); iter.hasNext();) {
754
            for (Map.Entry<Object, Object> next : parentOptions.entrySet()) {
754
                Map.Entry next = (Map.Entry) iter.next();
755
                Object option = next.getKey();
755
                Object option = next.getKey();
756
                
756
                
757
                if (ALLOW_CHANGE_PROPAGATION_BLOCKING.equals(option)) {
757
                if (ALLOW_CHANGE_PROPAGATION_BLOCKING.equals(option)) {
Lines 770-775 Link Here
770
        }
770
        }
771
	}
771
	}
772
	
772
	
773
	@Override
773
	public String toString() {
774
	public String toString() {
774
		return "Transaction[active=" + isActive() //$NON-NLS-1$
775
		return "Transaction[active=" + isActive() //$NON-NLS-1$
775
			+ ", read-only=" + isReadOnly() //$NON-NLS-1$
776
			+ ", read-only=" + isReadOnly() //$NON-NLS-1$
Lines 889-898 Link Here
889
	 * 
890
	 * 
890
	 * @since 1.2
891
	 * @since 1.2
891
	 */
892
	 */
892
	protected static Map getDefaultOptions(TransactionalEditingDomain domain) {
893
	protected static Map<Object, Object> getDefaultOptions(
893
        TransactionalEditingDomain.DefaultOptions defaults = (TransactionalEditingDomain.DefaultOptions) TransactionUtil
894
			TransactionalEditingDomain domain) {
895
		
896
        TransactionalEditingDomain.DefaultOptions defaults = TransactionUtil
894
            .getAdapter(domain, TransactionalEditingDomain.DefaultOptions.class);
897
            .getAdapter(domain, TransactionalEditingDomain.DefaultOptions.class);
895
        
898
        
896
        return (defaults == null)? Collections.EMPTY_MAP : defaults.getDefaultTransactionOptions();
899
        return (defaults == null)? Collections.<Object, Object>emptyMap()
900
        	: defaults.getDefaultTransactionOptions();
897
    }
901
    }
898
}
902
}
(-)src/org/eclipse/emf/transaction/impl/InternalTransactionalEditingDomain.java (-4 / +5 lines)
Lines 54-60 Link Here
54
	 *     
54
	 *     
55
	 * @see #activate(InternalTransaction)
55
	 * @see #activate(InternalTransaction)
56
	 */
56
	 */
57
	InternalTransaction startTransaction(boolean readOnly, Map options) throws InterruptedException;
57
	InternalTransaction startTransaction(boolean readOnly, Map<?, ?> options)
58
	throws InterruptedException;
58
	
59
	
59
	/**
60
	/**
60
	 * Obtains the transaction that currently has access to me, and whose
61
	 * Obtains the transaction that currently has access to me, and whose
Lines 185-191 Link Here
185
	 *  
186
	 *  
186
	 * @return A map with undo/redo options.
187
	 * @return A map with undo/redo options.
187
	 */
188
	 */
188
	Map getUndoRedoOptions();
189
	Map<Object, Object> getUndoRedoOptions();
189
	
190
	
190
	/**
191
	/**
191
	 * Transfers ownership of this editing domain to the specified
192
	 * Transfers ownership of this editing domain to the specified
Lines 193-199 Link Here
193
	 *  
194
	 *  
194
	 * @param runnable the runnable whose thread is to borrow me
195
	 * @param runnable the runnable whose thread is to borrow me
195
	 */
196
	 */
196
	void startPrivileged(PrivilegedRunnable runnable);
197
	void startPrivileged(PrivilegedRunnable<?> runnable);
197
	
198
	
198
	/**
199
	/**
199
	 * Returns me to my previous owner, upon completion of the specified
200
	 * Returns me to my previous owner, upon completion of the specified
Lines 201-205 Link Here
201
	 * 
202
	 * 
202
	 * @param runnable the runnable whose thread had borrowed me
203
	 * @param runnable the runnable whose thread had borrowed me
203
	 */
204
	 */
204
	void endPrivileged(PrivilegedRunnable runnable);
205
	void endPrivileged(PrivilegedRunnable<?> runnable);
205
}
206
}
(-)src/org/eclipse/emf/transaction/impl/InternalTransactionalCommandStack.java (-2 / +4 lines)
Lines 65-71 Link Here
65
	 *     
65
	 *     
66
	 * @see #getDomain()
66
	 * @see #getDomain()
67
	 */
67
	 */
68
	EMFCommandTransaction createTransaction(Command command, Map options) throws InterruptedException;
68
	EMFCommandTransaction createTransaction(Command command, Map<?, ?> options)
69
	throws InterruptedException;
69
	
70
	
70
	/**
71
	/**
71
	 * Executes the specified list of trigger commands.  All of the commands are
72
	 * Executes the specified list of trigger commands.  All of the commands are
Lines 86-92 Link Here
86
	 * @see ResourceSetListener#transactionAboutToCommit(org.eclipse.emf.transaction.ResourceSetChangeEvent)
87
	 * @see ResourceSetListener#transactionAboutToCommit(org.eclipse.emf.transaction.ResourceSetChangeEvent)
87
	 * @see #createTransaction(Command, Map)
88
	 * @see #createTransaction(Command, Map)
88
	 */
89
	 */
89
	void executeTriggers(Command command, List triggers, Map options) throws InterruptedException, RollbackException;
90
	void executeTriggers(Command command, List<Command> triggers,
91
			Map<?, ?> options) throws InterruptedException, RollbackException;
90
	
92
	
91
	/**
93
	/**
92
	 * Disposes of my state and any additional resources that I may be
94
	 * Disposes of my state and any additional resources that I may be
(-)src/org/eclipse/emf/transaction/impl/TriggerCommandTransaction.java (-2 / +5 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 39-45 Link Here
39
	 * @param domain the editing domain in which I am active
39
	 * @param domain the editing domain in which I am active
40
	 * @param options my options
40
	 * @param options my options
41
	 */
41
	 */
42
	public TriggerCommandTransaction(TriggerCommand command, InternalTransactionalEditingDomain domain, Map options) {
42
	public TriggerCommandTransaction(TriggerCommand command,
43
			InternalTransactionalEditingDomain domain, Map<?, ?> options) {
43
		super(command, domain, options);
44
		super(command, domain, options);
44
	}
45
	}
45
46
Lines 47-52 Link Here
47
	 * Extends the inherited implementation by first clearing my change
48
	 * Extends the inherited implementation by first clearing my change
48
	 * description, so that I will not propagate these changes upwards.
49
	 * description, so that I will not propagate these changes upwards.
49
	 */
50
	 */
51
	@Override
50
	protected synchronized void close() {
52
	protected synchronized void close() {
51
		change.clear();
53
		change.clear();
52
		
54
		
Lines 57-62 Link Here
57
	 * Overrides the inherited implementation to simply propagate triggers to
59
	 * Overrides the inherited implementation to simply propagate triggers to
58
	 * my parent, because it's the transaction that the outside world can see.
60
	 * my parent, because it's the transaction that the outside world can see.
59
	 */
61
	 */
62
	@Override
60
	public void addTriggers(TriggerCommand triggers) {
63
	public void addTriggers(TriggerCommand triggers) {
61
		((InternalTransaction) getParent()).addTriggers(triggers);
64
		((InternalTransaction) getParent()).addTriggers(triggers);
62
	}
65
	}
(-)src/org/eclipse/emf/transaction/impl/EMFCommandTransaction.java (-1 / +2 lines)
Lines 40-46 Link Here
40
	 * @param domain the editing domain in which I am active
40
	 * @param domain the editing domain in which I am active
41
	 * @param options my options
41
	 * @param options my options
42
	 */
42
	 */
43
	public EMFCommandTransaction(Command command, InternalTransactionalEditingDomain domain, Map options) {
43
	public EMFCommandTransaction(Command command, InternalTransactionalEditingDomain domain,
44
			Map<?, ?> options) {
44
		super(domain, false, options);
45
		super(domain, false, options);
45
		
46
		
46
		this.command = command;
47
		this.command = command;
(-)src/org/eclipse/emf/transaction/impl/TransactionChangeRecorder.java (-11 / +20 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005, 2006 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 108-113 Link Here
108
	 * 
108
	 * 
109
	 * @throws IllegalStateException if I have been {@link #dispose() disposed}
109
	 * @throws IllegalStateException if I have been {@link #dispose() disposed}
110
	 */
110
	 */
111
	@Override
111
	public ChangeDescription endRecording() {
112
	public ChangeDescription endRecording() {
112
		if (disposed) {
113
		if (disposed) {
113
			throw new IllegalStateException("cannot end a disposed recorder"); //$NON-NLS-1$
114
			throw new IllegalStateException("cannot end a disposed recorder"); //$NON-NLS-1$
Lines 135-152 Link Here
135
	 *       outside of the scope of the editing domain and its resource set</li>
136
	 *       outside of the scope of the editing domain and its resource set</li>
136
	 * </ul>
137
	 * </ul>
137
	 */
138
	 */
139
	@Override
138
	public void setTarget(Notifier target) {
140
	public void setTarget(Notifier target) {
139
		if (!disposed) {
141
		if (!disposed) {
140
			Iterator contents = target instanceof EObject ? isResolveProxies() ? ((EObject) target).eContents().iterator()
142
			Iterator<? extends Notifier> contents = (target instanceof EObject) ? isResolveProxies() ? ((EObject) target)
141
					: ((InternalEList) ((EObject) target).eContents()).basicIterator()
143
				.eContents().iterator()
142
					: target instanceof ResourceSet ? ((ResourceSet) target)
144
				: ((InternalEList<EObject>) ((EObject) target).eContents())
143
							.getResources().iterator()
145
					.basicIterator()
144
							: target instanceof Resource ? ((Resource) target)
146
				: target instanceof ResourceSet ? ((ResourceSet) target)
145
									.getContents().iterator() : null;
147
					.getResources().iterator()
146
	
148
					: target instanceof Resource ? ((Resource) target)
149
						.getContents().iterator()
150
						: null;
151
147
			if (contents != null) {
152
			if (contents != null) {
148
				while (contents.hasNext()) {
153
				while (contents.hasNext()) {
149
					Notifier notifier = (Notifier) contents.next();
154
					Notifier notifier = contents.next();
150
					addAdapter(notifier);
155
					addAdapter(notifier);
151
				}
156
				}
152
			}
157
			}
Lines 160-165 Link Here
160
	 * currently recording) and passing it along to the domain's current
165
	 * currently recording) and passing it along to the domain's current
161
	 * transaction (if any).
166
	 * transaction (if any).
162
	 */
167
	 */
168
	@Override
163
	public void notifyChanged(Notification notification) {
169
	public void notifyChanged(Notification notification) {
164
		if (disposed) {
170
		if (disposed) {
165
			// I am disposed, so I should no longer be responding to or even
171
			// I am disposed, so I should no longer be responding to or even
Lines 385-390 Link Here
385
	 * 
391
	 * 
386
	 * @since 1.1
392
	 * @since 1.1
387
	 */
393
	 */
394
	@Override
388
	public void dispose() {
395
	public void dispose() {
389
		if (!disposed) {
396
		if (!disposed) {
390
			super.dispose();
397
			super.dispose();
Lines 395-402 Link Here
395
			if (rset != null) {
402
			if (rset != null) {
396
				removeAdapter(rset);
403
				removeAdapter(rset);
397
				
404
				
398
				for (Iterator iter = EcoreUtil.getAllProperContents(rset, false); iter.hasNext();) {
405
				for (Iterator<Notifier> iter = EcoreUtil.getAllProperContents(rset, false);
399
					removeAdapter((Notifier) iter.next());
406
						iter.hasNext();) {
407
					
408
					removeAdapter(iter.next());
400
				}
409
				}
401
			}
410
			}
402
			
411
			
(-)src/org/eclipse/emf/transaction/impl/EditingDomainManager.java (-30 / +28 lines)
Lines 16-24 Link Here
16
 */
16
 */
17
package org.eclipse.emf.transaction.impl;
17
package org.eclipse.emf.transaction.impl;
18
18
19
import java.lang.ref.Reference;
19
import java.lang.ref.WeakReference;
20
import java.lang.ref.WeakReference;
20
import java.util.Collection;
21
import java.util.Collection;
21
import java.util.Iterator;
22
import java.util.Map;
22
import java.util.Map;
23
23
24
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.CoreException;
Lines 55-62 Link Here
55
55
56
	private static final EditingDomainManager INSTANCE = new EditingDomainManager();
56
	private static final EditingDomainManager INSTANCE = new EditingDomainManager();
57
	
57
	
58
	private Collection universalListeners;
58
	private Collection<IConfigurationElement> universalListeners;
59
	private final Map listeners = new java.util.HashMap();
59
	private final Map<String, Reference<ResourceSetListener>> listeners =
60
		new java.util.HashMap<String, Reference<ResourceSetListener>>();
60
	
61
	
61
	/**
62
	/**
62
	 * Not instantiable by clients.
63
	 * Not instantiable by clients.
Lines 152-163 Link Here
152
	 * @param domain the editing domain to which to add the listeners
153
	 * @param domain the editing domain to which to add the listeners
153
	 */
154
	 */
154
	public void configureListeners(String id, TransactionalEditingDomain domain) {
155
	public void configureListeners(String id, TransactionalEditingDomain domain) {
155
		Collection configs = getListenerConfigs(id);
156
		Collection<IConfigurationElement> configs = getListenerConfigs(id);
156
		
157
		
157
		for (Iterator iter = configs.iterator(); iter.hasNext();) {
158
		for (IConfigurationElement next : configs) {
158
			ResourceSetListener listener = getListener(
159
			ResourceSetListener listener = getListener(next, true);
159
					(IConfigurationElement) iter.next(),
160
					true);
161
			
160
			
162
			if (listener != null) {
161
			if (listener != null) {
163
				domain.addResourceSetListener(listener);
162
				domain.addResourceSetListener(listener);
Lines 174-185 Link Here
174
	 * @param domain the editing domain from which to remove the listeners
173
	 * @param domain the editing domain from which to remove the listeners
175
	 */
174
	 */
176
	public void deconfigureListeners(String id, TransactionalEditingDomain domain) {
175
	public void deconfigureListeners(String id, TransactionalEditingDomain domain) {
177
		Collection configs = getListenerConfigs(id);
176
		Collection<IConfigurationElement> configs = getListenerConfigs(id);
178
		
177
		
179
		for (Iterator iter = configs.iterator(); iter.hasNext();) {
178
		for (IConfigurationElement next : configs) {
180
			ResourceSetListener listener = getListener(
179
			ResourceSetListener listener = getListener(next, false);
181
					(IConfigurationElement) iter.next(),
182
					false);
183
			
180
			
184
			if (listener != null) {
181
			if (listener != null) {
185
				domain.removeResourceSetListener(listener);
182
				domain.removeResourceSetListener(listener);
Lines 219-238 Link Here
219
	 * @param id the domain ID to retrieve
216
	 * @param id the domain ID to retrieve
220
	 * @return the configuration elements for listeners registered to this ID
217
	 * @return the configuration elements for listeners registered to this ID
221
	 */
218
	 */
222
	private Collection getListenerConfigs(String id) {
219
	private Collection<IConfigurationElement> getListenerConfigs(String id) {
223
		Collection result = new java.util.ArrayList();
220
		Collection<IConfigurationElement> result =
221
			new java.util.ArrayList<IConfigurationElement>();
224
		
222
		
225
		IConfigurationElement[] configs = Platform.getExtensionRegistry().getConfigurationElementsFor(
223
		IConfigurationElement[] configs = Platform.getExtensionRegistry().getConfigurationElementsFor(
226
				EMFTransactionPlugin.getPluginId(),
224
				EMFTransactionPlugin.getPluginId(),
227
				EXT_POINT_LISTENERS);
225
				EXT_POINT_LISTENERS);
228
		
226
		
229
		for (int i = 0; i < configs.length; i++) {
227
		for (IConfigurationElement element : configs) {
230
			if (E_LISTENER.equals(configs[i].getName())) {
228
			if (E_LISTENER.equals(element.getName())) {
231
				IConfigurationElement[] domains = configs[i].getChildren(E_DOMAIN);
229
				IConfigurationElement[] domains = element.getChildren(E_DOMAIN);
232
				
230
				
233
				for (int j = 0; j < domains.length; j++) {
231
				for (IConfigurationElement element2 : domains) {
234
					if (id.equals(domains[j].getAttribute(A_ID))) {
232
					if (id.equals(element2.getAttribute(A_ID))) {
235
						result.add(configs[i]);
233
						result.add(element);
236
						break;
234
						break;
237
					}
235
					}
238
				}
236
				}
Lines 250-269 Link Here
250
	 * 
248
	 * 
251
	 * @return the configuration elements for universal listeners
249
	 * @return the configuration elements for universal listeners
252
	 */
250
	 */
253
	private Collection getUniversalListenerConfigs() {
251
	private Collection<IConfigurationElement> getUniversalListenerConfigs() {
254
		if (universalListeners == null) {
252
		if (universalListeners == null) {
255
			universalListeners = new java.util.ArrayList();
253
			universalListeners = new java.util.ArrayList<IConfigurationElement>();
256
			
254
			
257
			IConfigurationElement[] configs = Platform.getExtensionRegistry().getConfigurationElementsFor(
255
			IConfigurationElement[] configs = Platform.getExtensionRegistry().getConfigurationElementsFor(
258
					EMFTransactionPlugin.getPluginId(),
256
					EMFTransactionPlugin.getPluginId(),
259
					EXT_POINT_LISTENERS);
257
					EXT_POINT_LISTENERS);
260
			
258
			
261
			for (int i = 0; i < configs.length; i++) {
259
			for (IConfigurationElement element : configs) {
262
				if (E_LISTENER.equals(configs[i].getName())) {
260
				if (E_LISTENER.equals(element.getName())) {
263
					IConfigurationElement[] domains = configs[i].getChildren(E_DOMAIN);
261
					IConfigurationElement[] domains = element.getChildren(E_DOMAIN);
264
					
262
					
265
					if (domains.length == 0) {
263
					if (domains.length == 0) {
266
						universalListeners.add(configs[i]);
264
						universalListeners.add(element);
267
					}
265
					}
268
				}
266
				}
269
			}
267
			}
Lines 286-294 Link Here
286
	private ResourceSetListener getListener(IConfigurationElement config, boolean create) {
284
	private ResourceSetListener getListener(IConfigurationElement config, boolean create) {
287
		ResourceSetListener result = null;
285
		ResourceSetListener result = null;
288
		
286
		
289
		WeakReference ref = (WeakReference) listeners.get(config.getAttribute(A_CLASS));
287
		Reference<ResourceSetListener> ref = listeners.get(config.getAttribute(A_CLASS));
290
		if (ref != null) {
288
		if (ref != null) {
291
			result = (ResourceSetListener) ref.get();
289
			result = ref.get();
292
		}
290
		}
293
		
291
		
294
		if ((result == null) && create) {
292
		if ((result == null) && create) {
Lines 298-304 Link Here
298
				
296
				
299
				if (listener instanceof ResourceSetListener) {
297
				if (listener instanceof ResourceSetListener) {
300
					result = (ResourceSetListener) listener;
298
					result = (ResourceSetListener) listener;
301
					ref = new WeakReference(result);
299
					ref = new WeakReference<ResourceSetListener>(result);
302
					listeners.put(result.getClass().getName(), ref);
300
					listeners.put(result.getClass().getName(), ref);
303
				} else {
301
				} else {
304
					EMFTransactionPlugin.getPlugin().log(
302
					EMFTransactionPlugin.getPlugin().log(
(-)src/org/eclipse/emf/transaction/impl/ReadWriteValidatorImpl.java (-35 / +31 lines)
Lines 74-80 Link Here
74
	private NotificationTree transactionToPrecommit = null;
74
	private NotificationTree transactionToPrecommit = null;
75
	
75
	
76
	// maps the active transaction and its ancestors to notification tree nodes
76
	// maps the active transaction and its ancestors to notification tree nodes
77
	private final Map txToNode = new java.util.HashMap();
77
	private final Map<InternalTransaction, NotificationTree> txToNode =
78
		new java.util.HashMap<InternalTransaction, NotificationTree>();
78
	
79
	
79
	/**
80
	/**
80
	 * Initializes me.
81
	 * Initializes me.
Lines 143-150 Link Here
143
	}
144
	}
144
	
145
	
145
	// Documentation copied from the inherited method specification
146
	// Documentation copied from the inherited method specification
146
	public synchronized List getNotificationsForValidation(Transaction tx) {
147
	public synchronized List<Notification> getNotificationsForValidation(Transaction tx) {
147
		List result = null;
148
		List<Notification> result = null;
148
		
149
		
149
		if (tree != null) {
150
		if (tree != null) {
150
			NotificationTree nested = findTree(tx);
151
			NotificationTree nested = findTree(tx);
Lines 158-165 Link Here
158
	}
159
	}
159
	
160
	
160
	// Documentation copied from the inherited method specification
161
	// Documentation copied from the inherited method specification
161
	public synchronized List getNotificationsForPrecommit(Transaction tx) {
162
	public synchronized List<Notification> getNotificationsForPrecommit(Transaction tx) {
162
		List result = null;
163
		List<Notification> result = null;
163
		
164
		
164
		if ((transactionToPrecommit != null)
165
		if ((transactionToPrecommit != null)
165
				&& (transactionToPrecommit == findTree(tx))) {
166
				&& (transactionToPrecommit == findTree(tx))) {
Lines 175-182 Link Here
175
	}
176
	}
176
	
177
	
177
	// Documentation copied from the inherited method specification
178
	// Documentation copied from the inherited method specification
178
	public synchronized List getNotificationsForPostcommit(Transaction tx) {
179
	public synchronized List<Notification> getNotificationsForPostcommit(Transaction tx) {
179
		List result = null;
180
		List<Notification> result = null;
180
		
181
		
181
		if (tree != null) {
182
		if (tree != null) {
182
			NotificationTree nested = findTree(tx);
183
			NotificationTree nested = findTree(tx);
Lines 203-209 Link Here
203
		NotificationTree result = null;
204
		NotificationTree result = null;
204
		
205
		
205
		if (tree != null) {
206
		if (tree != null) {
206
			result = (NotificationTree) txToNode.get(tx);
207
			result = txToNode.get(tx);
207
		}
208
		}
208
		
209
		
209
		return result;
210
		return result;
Lines 215-221 Link Here
215
		IStatus result;
216
		IStatus result;
216
		
217
		
217
		try {
218
		try {
218
			IValidator validator = createValidator();
219
			IValidator<Notification> validator = createValidator();
219
			
220
			
220
			result = validator.validate(getNotificationsForValidation(tx));
221
			result = validator.validate(getNotificationsForValidation(tx));
221
		} catch (Exception e) {
222
		} catch (Exception e) {
Lines 238-244 Link Here
238
     *
239
     *
239
	 * @return the validator
240
	 * @return the validator
240
	 */
241
	 */
241
	protected IValidator createValidator() {
242
	protected IValidator<Notification> createValidator() {
242
		return ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
243
		return ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
243
	}
244
	}
244
	
245
	
Lines 297-309 Link Here
297
	 * @author Christian W. Damus (cdamus)
298
	 * @author Christian W. Damus (cdamus)
298
	 */
299
	 */
299
	private static class NotificationTree {
300
	private static class NotificationTree {
300
		private final List children = new org.eclipse.emf.common.util.BasicEList.FastCompare();
301
		private final List<NotificationTree> children =
302
			new org.eclipse.emf.common.util.BasicEList.FastCompare<NotificationTree>();
301
		
303
		
302
		// number of notifications in parent before start of child transaction
304
		// number of notifications in parent before start of child transaction
303
		private int parentNotificationCount;
305
		private int parentNotificationCount;
304
		
306
		
305
		private InternalTransaction transaction;
307
		private InternalTransaction transaction;
306
		private List notifications;  // stores the notifications
308
		private List<Notification> notifications;  // stores the notifications
307
		
309
		
308
		private final byte notificationMask;
310
		private final byte notificationMask;
309
		
311
		
Lines 355-361 Link Here
355
		 * 
357
		 * 
356
		 * @return my children
358
		 * @return my children
357
		 */
359
		 */
358
		List getChildren() {
360
		List<NotificationTree> getChildren() {
359
			return children;
361
			return children;
360
		}
362
		}
361
		
363
		
Lines 372-385 Link Here
372
		 * @see ReadWriteValidatorImpl#PRECOMMIT
374
		 * @see ReadWriteValidatorImpl#PRECOMMIT
373
		 * @see ReadWriteValidatorImpl#POSTCOMMIT
375
		 * @see ReadWriteValidatorImpl#POSTCOMMIT
374
		 */
376
		 */
375
		List collectNotifications(byte purpose) {
377
		List<Notification> collectNotifications(byte purpose) {
376
			List result;
378
			List<Notification> result;
377
			
379
			
378
			if ((notificationMask & purpose) == purpose) {
380
			if ((notificationMask & purpose) == purpose) {
379
				result = new java.util.ArrayList();
381
				result = new java.util.ArrayList<Notification>();
380
				collectNotifications(result, purpose);
382
				collectNotifications(result, purpose);
381
			} else {
383
			} else {
382
				result = Collections.EMPTY_LIST;
384
				result = Collections.emptyList();
383
			}
385
			}
384
			
386
			
385
			return result;
387
			return result;
Lines 394-407 Link Here
394
		 * 
396
		 * 
395
		 * @see #collectNotifications()
397
		 * @see #collectNotifications()
396
		 */
398
		 */
397
		private void collectNotifications(List notifications, byte purpose) {
399
		private void collectNotifications(List<? super Notification> notifications, byte purpose) {
398
			if ((notificationMask & purpose) == purpose) {
400
			if ((notificationMask & purpose) == purpose) {
399
				int lastIndex = 0;
401
				int lastIndex = 0;
400
				List parentNotifications = getNotifications();
402
				List<Notification> parentNotifications = getNotifications();
401
				
403
				
402
				for (Iterator iter = children.iterator(); iter.hasNext();) {
404
				for (NotificationTree next : children) {
403
					NotificationTree next = (NotificationTree) iter.next();
404
					
405
					// append the parent transaction's notifications from the
405
					// append the parent transaction's notifications from the
406
					//    last position to this child's position
406
					//    last position to this child's position
407
					notifications.addAll(parentNotifications.subList(
407
					notifications.addAll(parentNotifications.subList(
Lines 427-443 Link Here
427
		 * change, etc.).
427
		 * change, etc.).
428
		 */
428
		 */
429
		void setRolledBack() {
429
		void setRolledBack() {
430
			Iterator children = getChildren().iterator();
430
			Iterator<NotificationTree> children = getChildren().iterator();
431
			boolean inPlace = transaction == null;
431
			boolean inPlace = transaction == null;
432
			
432
			
433
            ListIterator iter;
433
            ListIterator<Notification> iter;
434
			if (inPlace) {
434
			if (inPlace) {
435
			    // already committed?  Some ancestor transaction is rolling back
435
			    // already committed?  Some ancestor transaction is rolling back
436
			    iter = notifications.listIterator();
436
			    iter = notifications.listIterator();
437
			} else {
437
			} else {
438
			    // transaction has the notifications
438
			    // transaction has the notifications
439
			    iter = transaction.getNotifications().listIterator();
439
			    iter = transaction.getNotifications().listIterator();
440
	            notifications = new org.eclipse.emf.common.util.BasicEList.FastCompare();
440
	            notifications = new org.eclipse.emf.common.util.BasicEList.FastCompare<Notification>();
441
			}
441
			}
442
			
442
			
443
			// filter out all undoable notifications, leaving only those that
443
			// filter out all undoable notifications, leaving only those that
Lines 446-459 Link Here
446
			//    where in the notification ordering the child transactions fit
446
			//    where in the notification ordering the child transactions fit
447
			//    so that we retain correct linear ordering overall
447
			//    so that we retain correct linear ordering overall
448
			for (int i = 0; children.hasNext();) {
448
			for (int i = 0; children.hasNext();) {
449
				NotificationTree child = (NotificationTree) children.next();
449
				NotificationTree child = children.next();
450
				int parentNotificationCount = child.parentNotificationCount;
450
				int parentNotificationCount = child.parentNotificationCount;
451
				
451
				
452
				if (inPlace) {
452
				if (inPlace) {
453
	                for (; (i < parentNotificationCount) && iter.hasNext(); i++) {
453
	                for (; (i < parentNotificationCount) && iter.hasNext(); i++) {
454
	                    Notification next = (Notification) iter.next();
454
					    if (isUndoableObjectChange(iter.next())) {
455
	                    
456
					    if (isUndoableObjectChange(next)) {
457
					        iter.remove();
455
					        iter.remove();
458
					    }
456
					    }
459
	                }
457
	                }
Lines 464-470 Link Here
464
	                child.parentNotificationCount = iter.nextIndex();
462
	                child.parentNotificationCount = iter.nextIndex();
465
				} else {
463
				} else {
466
                    for (; (i < parentNotificationCount) && iter.hasNext(); i++) {
464
                    for (; (i < parentNotificationCount) && iter.hasNext(); i++) {
467
                        Notification next = (Notification) iter.next();
465
                        Notification next = iter.next();
468
                        
466
                        
469
    					if (!isUndoableObjectChange(next)) {
467
    					if (!isUndoableObjectChange(next)) {
470
    						notifications.add(next);
468
    						notifications.add(next);
Lines 484-498 Link Here
484
			// filter the remaining notifications
482
			// filter the remaining notifications
485
			if (inPlace) {
483
			if (inPlace) {
486
    			while (iter.hasNext()) {
484
    			while (iter.hasNext()) {
487
    				Notification next = (Notification) iter.next();
485
    				if (isUndoableObjectChange(iter.next())) {
488
    				
489
    				if (isUndoableObjectChange(next)) {
490
    					iter.remove();
486
    					iter.remove();
491
    				}
487
    				}
492
    			}
488
    			}
493
			} else {
489
			} else {
494
                while (iter.hasNext()) {
490
                while (iter.hasNext()) {
495
                    Notification next = (Notification) iter.next();
491
                    Notification next = iter.next();
496
                    
492
                    
497
                    if (!isUndoableObjectChange(next)) {
493
                    if (!isUndoableObjectChange(next)) {
498
                        notifications.add(next);
494
                        notifications.add(next);
Lines 522-528 Link Here
522
		 * 
518
		 * 
523
		 * @return my notifications
519
		 * @return my notifications
524
		 */
520
		 */
525
		List getNotifications() {
521
		List<Notification> getNotifications() {
526
			return (notifications != null)? notifications :
522
			return (notifications != null)? notifications :
527
				transaction.getNotifications();
523
				transaction.getNotifications();
528
		}
524
		}
(-)src/org/eclipse/emf/transaction/impl/ResourceSetManager.java (-13 / +16 lines)
Lines 17-23 Link Here
17
package org.eclipse.emf.transaction.impl;
17
package org.eclipse.emf.transaction.impl;
18
18
19
import java.util.Collection;
19
import java.util.Collection;
20
import java.util.Iterator;
21
import java.util.Map;
20
import java.util.Map;
22
21
23
import org.eclipse.emf.common.notify.Notification;
22
import org.eclipse.emf.common.notify.Notification;
Lines 43-51 Link Here
43
public final class ResourceSetManager {
42
public final class ResourceSetManager {
44
	private static final ResourceSetManager INSTANCE = new ResourceSetManager();
43
	private static final ResourceSetManager INSTANCE = new ResourceSetManager();
45
	
44
	
46
	private final Map loadingResources = new java.util.WeakHashMap();
45
	private final Map<Resource, Boolean> loadingResources = new java.util.WeakHashMap<Resource, Boolean>();
47
	private final Map loadedResources = new java.util.WeakHashMap();
46
	private final Map<Resource, Boolean> loadedResources = new java.util.WeakHashMap<Resource, Boolean>();
48
	private final Map unloadingResources = new java.util.WeakHashMap();
47
	private final Map<Resource, Boolean> unloadingResources = new java.util.WeakHashMap<Resource, Boolean>();
49
	
48
	
50
	/**
49
	/**
51
	 * Not instantiable by clients.
50
	 * Not instantiable by clients.
Lines 72-79 Link Here
72
	 * @param rset a resource set
71
	 * @param rset a resource set
73
	 */
72
	 */
74
	public synchronized void observe(ResourceSet rset) {
73
	public synchronized void observe(ResourceSet rset) {
75
		for (Iterator iter = rset.getResources().iterator(); iter.hasNext();) {
74
		for (Resource next : rset.getResources()) {
76
			observe((Resource) iter.next());
75
			observe(next);
77
		}
76
		}
78
	}
77
	}
79
	
78
	
Lines 112-120 Link Here
112
				break;
111
				break;
113
			case Notification.ADD_MANY:
112
			case Notification.ADD_MANY:
114
				if (newValue != null) {
113
				if (newValue != null) {
115
					for (Iterator iter = ((Collection) newValue).iterator(); iter.hasNext();) {
114
					@SuppressWarnings("unchecked")
115
					Collection<Resource> resources = (Collection<Resource>) newValue;
116
					for (Resource next : resources) {
116
						// observe the new resource
117
						// observe the new resource
117
						observe((Resource) iter.next());
118
						observe(next);
118
					}
119
					}
119
				}
120
				}
120
				break;
121
				break;
Lines 127-136 Link Here
127
				break;
128
				break;
128
			case Notification.REMOVE_MANY:
129
			case Notification.REMOVE_MANY:
129
				if (oldValue != null) {
130
				if (oldValue != null) {
130
					for (Iterator iter = ((Collection) oldValue).iterator(); iter.hasNext();) {
131
					@SuppressWarnings("unchecked")
132
					Collection<Resource> resources = (Collection<Resource>) oldValue;
133
					for (Resource next : resources) {
131
						// the old resource is effectively unloaded as far as we are
134
						// the old resource is effectively unloaded as far as we are
132
						//    concerned because it is no longer in this resource set
135
						//    concerned because it is no longer in this resource set
133
						setUnloaded((Resource) iter.next());
136
						setUnloaded(next);
134
					}
137
					}
135
				}
138
				}
136
				break;
139
				break;
Lines 229-235 Link Here
229
	 * @param res a loaded resource
232
	 * @param res a loaded resource
230
	 */
233
	 */
231
	private void setLoaded(Resource res) {
234
	private void setLoaded(Resource res) {
232
		loadedResources.put(res, Boolean.TRUE);
235
		loadedResources.put(res, true);
233
		loadingResources.remove(res);
236
		loadingResources.remove(res);
234
		unloadingResources.remove(res);
237
		unloadingResources.remove(res);
235
	}
238
	}
Lines 240-246 Link Here
240
	 * @param res a loading resource
243
	 * @param res a loading resource
241
	 */
244
	 */
242
	private void setLoading(Resource res) {
245
	private void setLoading(Resource res) {
243
		loadingResources.put(res, Boolean.TRUE);
246
		loadingResources.put(res, true);
244
		loadedResources.remove(res);
247
		loadedResources.remove(res);
245
		unloadingResources.remove(res);
248
		unloadingResources.remove(res);
246
	}
249
	}
Lines 251-257 Link Here
251
	 * @param res an unloading resource
254
	 * @param res an unloading resource
252
	 */
255
	 */
253
	private void setUnloading(Resource res) {
256
	private void setUnloading(Resource res) {
254
		unloadingResources.put(res, Boolean.TRUE);
257
		unloadingResources.put(res, true);
255
		loadedResources.remove(res);
258
		loadedResources.remove(res);
256
		loadingResources.remove(res);
259
		loadingResources.remove(res);
257
	}
260
	}
(-)src/org/eclipse/emf/transaction/RunnableWithResult.java (-6 / +8 lines)
Lines 30-40 Link Here
30
 * or failure of the transaction.
30
 * or failure of the transaction.
31
 * </p>
31
 * </p>
32
 * 
32
 * 
33
 * @param <T> the result type of the runnable
34
 * 
33
 * @author Christian W. Damus (cdamus)
35
 * @author Christian W. Damus (cdamus)
34
 * 
36
 * 
35
 * @see TransactionalEditingDomain#runExclusive(Runnable)
37
 * @see TransactionalEditingDomain#runExclusive(Runnable)
36
 */
38
 */
37
public interface RunnableWithResult
39
public interface RunnableWithResult<T>
38
	extends Runnable {
40
	extends Runnable {
39
41
40
	/**
42
	/**
Lines 42-48 Link Here
42
	 * 
44
	 * 
43
	 * @return my result, or <code>null</code> if none
45
	 * @return my result, or <code>null</code> if none
44
	 */
46
	 */
45
	Object getResult();
47
	T getResult();
46
	
48
	
47
	/**
49
	/**
48
	 * Sets the commit status after completion of the {@link Runnable#run()} method.
50
	 * Sets the commit status after completion of the {@link Runnable#run()} method.
Lines 69-76 Link Here
69
	 *
71
	 *
70
	 * @author Christian W. Damus (cdamus)
72
	 * @author Christian W. Damus (cdamus)
71
	 */
73
	 */
72
	static abstract class Impl implements RunnableWithResult {
74
	static abstract class Impl<T> implements RunnableWithResult<T> {
73
		private Object result;
75
		private T result;
74
		private IStatus status;
76
		private IStatus status;
75
		
77
		
76
		/**
78
		/**
Lines 78-84 Link Here
78
		 * 
80
		 * 
79
		 * @param result my result
81
		 * @param result my result
80
		 */
82
		 */
81
		protected final void setResult(Object result) {
83
		protected final void setResult(T result) {
82
			this.result = result;
84
			this.result = result;
83
		}
85
		}
84
		
86
		
Lines 88-94 Link Here
88
		}
90
		}
89
		
91
		
90
		// Documentation copied from interface
92
		// Documentation copied from interface
91
		public final Object getResult() {
93
		public final T getResult() {
92
			return result;
94
			return result;
93
		}
95
		}
94
		
96
		
(-)src/org/eclipse/emf/transaction/NotificationFilter.java (-3 / +18 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005, 2006 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 49-54 Link Here
49
public abstract class NotificationFilter {
49
public abstract class NotificationFilter {
50
	/** As its name implies, this filter matches any notification. */
50
	/** As its name implies, this filter matches any notification. */
51
	public static final NotificationFilter ANY = new NotificationFilter() {
51
	public static final NotificationFilter ANY = new NotificationFilter() {
52
		@Override
52
		public boolean matches(Notification notification) {
53
		public boolean matches(Notification notification) {
53
			return true;
54
			return true;
54
		}};
55
		}};
Lines 59-64 Link Here
59
	 * @see Notification#isTouch()
60
	 * @see Notification#isTouch()
60
	 */
61
	 */
61
	public static final NotificationFilter NOT_TOUCH = new NotificationFilter() {
62
	public static final NotificationFilter NOT_TOUCH = new NotificationFilter() {
63
		@Override
62
		public boolean matches(Notification notification) {
64
		public boolean matches(Notification notification) {
63
			return !notification.isTouch();
65
			return !notification.isTouch();
64
		}};
66
		}};
Lines 83-88 Link Here
83
	 * A filter matching "resource loaded" events.
85
	 * A filter matching "resource loaded" events.
84
	 */
86
	 */
85
	public static final NotificationFilter RESOURCE_LOADED = new NotificationFilter() {
87
	public static final NotificationFilter RESOURCE_LOADED = new NotificationFilter() {
88
		@Override
86
		public boolean matches(Notification notification) {
89
		public boolean matches(Notification notification) {
87
			return (notification.getNotifier() instanceof Resource)
90
			return (notification.getNotifier() instanceof Resource)
88
					&& (notification.getFeatureID(Resource.class)
91
					&& (notification.getFeatureID(Resource.class)
Lines 95-100 Link Here
95
	 * A filter matching "resource unloaded" events.
98
	 * A filter matching "resource unloaded" events.
96
	 */
99
	 */
97
	public static final NotificationFilter RESOURCE_UNLOADED = new NotificationFilter() {
100
	public static final NotificationFilter RESOURCE_UNLOADED = new NotificationFilter() {
101
		@Override
98
		public boolean matches(Notification notification) {
102
		public boolean matches(Notification notification) {
99
			return (notification.getNotifier() instanceof Resource)
103
			return (notification.getNotifier() instanceof Resource)
100
					&& (notification.getFeatureID(Resource.class)
104
					&& (notification.getFeatureID(Resource.class)
Lines 137-142 Link Here
137
	 */
141
	 */
138
	public static NotificationFilter createNotifierFilter(final Object notifier) {
142
	public static NotificationFilter createNotifierFilter(final Object notifier) {
139
		return new NotificationFilter() {
143
		return new NotificationFilter() {
144
			@Override
140
			public boolean matches(Notification notification) {
145
			public boolean matches(Notification notification) {
141
				return notification.getNotifier() == notifier;
146
				return notification.getNotifier() == notifier;
142
			}};
147
			}};
Lines 152-157 Link Here
152
	 */
157
	 */
153
	public static NotificationFilter createEventTypeFilter(final int eventType) {
158
	public static NotificationFilter createEventTypeFilter(final int eventType) {
154
		return new NotificationFilter() {
159
		return new NotificationFilter() {
160
			@Override
155
			public boolean matches(Notification notification) {
161
			public boolean matches(Notification notification) {
156
				return notification.getEventType() == eventType;
162
				return notification.getEventType() == eventType;
157
			}};
163
			}};
Lines 166-171 Link Here
166
	 */
172
	 */
167
	public static NotificationFilter createFeatureFilter(final EStructuralFeature feature) {
173
	public static NotificationFilter createFeatureFilter(final EStructuralFeature feature) {
168
		return new NotificationFilter() {
174
		return new NotificationFilter() {
175
			@Override
169
			public boolean matches(Notification notification) {
176
			public boolean matches(Notification notification) {
170
				return notification.getFeature() == feature;
177
				return notification.getFeature() == feature;
171
			}};
178
			}};
Lines 180-187 Link Here
180
	 * 
187
	 * 
181
	 * @return the filter
188
	 * @return the filter
182
	 */
189
	 */
183
	public static NotificationFilter createFeatureFilter(final Class ownerType, final int featureId) {
190
	public static NotificationFilter createFeatureFilter(
191
			final Class<?> ownerType, final int featureId) {
184
		return new NotificationFilter() {
192
		return new NotificationFilter() {
193
			@Override
185
			public boolean matches(Notification notification) {
194
			public boolean matches(Notification notification) {
186
				return ownerType.isInstance(notification.getNotifier())
195
				return ownerType.isInstance(notification.getNotifier())
187
						&& (notification.getFeatureID(ownerType) == featureId);
196
						&& (notification.getFeatureID(ownerType) == featureId);
Lines 202-207 Link Here
202
	 */
211
	 */
203
	public static NotificationFilter createFeatureFilter(final EClassifier ownerType, final int featureId) {
212
	public static NotificationFilter createFeatureFilter(final EClassifier ownerType, final int featureId) {
204
		return new NotificationFilter() {
213
		return new NotificationFilter() {
214
			@Override
205
			public boolean matches(Notification notification) {
215
			public boolean matches(Notification notification) {
206
				return ownerType.isInstance(notification.getNotifier())
216
				return ownerType.isInstance(notification.getNotifier())
207
						&& (notification.getFeatureID(ownerType.getInstanceClass()) == featureId);
217
						&& (notification.getFeatureID(ownerType.getInstanceClass()) == featureId);
Lines 217-224 Link Here
217
	 * 
227
	 * 
218
	 * @return the filter
228
	 * @return the filter
219
	 */
229
	 */
220
	public static NotificationFilter createNotifierTypeFilter(final Class type) {
230
	public static NotificationFilter createNotifierTypeFilter(final Class<?> type) {
221
		return new NotificationFilter() {
231
		return new NotificationFilter() {
232
			@Override
222
			public boolean matches(Notification notification) {
233
			public boolean matches(Notification notification) {
223
				return type.isInstance(notification.getNotifier());
234
				return type.isInstance(notification.getNotifier());
224
			}};
235
			}};
Lines 235-240 Link Here
235
	 */
246
	 */
236
	public static NotificationFilter createNotifierTypeFilter(final EClassifier type) {
247
	public static NotificationFilter createNotifierTypeFilter(final EClassifier type) {
237
		return new NotificationFilter() {
248
		return new NotificationFilter() {
249
			@Override
238
			public boolean matches(Notification notification) {
250
			public boolean matches(Notification notification) {
239
				return type.isInstance(notification.getNotifier());
251
				return type.isInstance(notification.getNotifier());
240
			}};
252
			}};
Lines 251-256 Link Here
251
	 */
263
	 */
252
	public final NotificationFilter and(final NotificationFilter other) {
264
	public final NotificationFilter and(final NotificationFilter other) {
253
		return new NotificationFilter() {
265
		return new NotificationFilter() {
266
			@Override
254
			public boolean matches(Notification notification) {
267
			public boolean matches(Notification notification) {
255
				return NotificationFilter.this.matches(notification)
268
				return NotificationFilter.this.matches(notification)
256
						&& other.matches(notification);
269
						&& other.matches(notification);
Lines 268-273 Link Here
268
	 */
281
	 */
269
	public final NotificationFilter or(final NotificationFilter other) {
282
	public final NotificationFilter or(final NotificationFilter other) {
270
		return new NotificationFilter() {
283
		return new NotificationFilter() {
284
			@Override
271
			public boolean matches(Notification notification) {
285
			public boolean matches(Notification notification) {
272
				return NotificationFilter.this.matches(notification)
286
				return NotificationFilter.this.matches(notification)
273
						|| other.matches(notification);
287
						|| other.matches(notification);
Lines 281-286 Link Here
281
	 */
295
	 */
282
	public final NotificationFilter negated() {
296
	public final NotificationFilter negated() {
283
		return new NotificationFilter() {
297
		return new NotificationFilter() {
298
			@Override
284
			public boolean matches(Notification notification) {
299
			public boolean matches(Notification notification) {
285
				return !NotificationFilter.this.matches(notification);
300
				return !NotificationFilter.this.matches(notification);
286
			}};
301
			}};
(-)src/org/eclipse/emf/transaction/TriggerListener.java (-5 / +3 lines)
Lines 16-23 Link Here
16
 */
16
 */
17
package org.eclipse.emf.transaction;
17
package org.eclipse.emf.transaction;
18
18
19
import java.util.Iterator;
20
21
import org.eclipse.emf.common.command.Command;
19
import org.eclipse.emf.common.command.Command;
22
import org.eclipse.emf.common.notify.Notification;
20
import org.eclipse.emf.common.notify.Notification;
23
import org.eclipse.emf.transaction.util.ConditionalRedoCommand;
21
import org.eclipse.emf.transaction.util.ConditionalRedoCommand;
Lines 55-66 Link Here
55
	 * @return a composite of the commands returned by the subclass
53
	 * @return a composite of the commands returned by the subclass
56
	 *     implementation of the {@link #trigger} method
54
	 *     implementation of the {@link #trigger} method
57
	 */
55
	 */
56
	@Override
58
	public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {
57
	public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {
59
		Command result = null;
58
		Command result = null;
60
		
59
		
61
		for (Iterator iter = event.getNotifications().iterator(); iter.hasNext();) {
60
		for (Notification next : event.getNotifications()) {
62
			Notification next = (Notification) iter.next();
63
			
64
			Command trigger = trigger(event.getEditingDomain(), next);
61
			Command trigger = trigger(event.getEditingDomain(), next);
65
			if (trigger != null) {
62
			if (trigger != null) {
66
				if (result == null) {
63
				if (result == null) {
Lines 96-101 Link Here
96
	/**
93
	/**
97
	 * I want only ppre-commit events, not post-commit events.
94
	 * I want only ppre-commit events, not post-commit events.
98
	 */
95
	 */
96
	@Override
99
	public boolean isPrecommitOnly() {
97
	public boolean isPrecommitOnly() {
100
		return true;
98
		return true;
101
	}
99
	}
(-)src/org/eclipse/emf/transaction/TransactionalCommandStack.java (-1 / +1 lines)
Lines 51-57 Link Here
51
	 * @throws RollbackException if the changes performed by the command are
51
	 * @throws RollbackException if the changes performed by the command are
52
	 *    rolled back by validation of the transaction
52
	 *    rolled back by validation of the transaction
53
	 */
53
	 */
54
	void execute(Command command, Map options) throws InterruptedException, RollbackException;
54
	void execute(Command command, Map<?, ?> options) throws InterruptedException, RollbackException;
55
55
56
	/**
56
	/**
57
	 * Sets an exception handler.  This object will be notified when exceptions
57
	 * Sets an exception handler.  This object will be notified when exceptions
(-)src/org/eclipse/emf/transaction/RecordingCommand.java (-1 / +6 lines)
Lines 93-98 Link Here
93
	 * Subclasses should override this if they have more preparation to do.
93
	 * Subclasses should override this if they have more preparation to do.
94
	 * By default, the result is just <code>true</code>.
94
	 * By default, the result is just <code>true</code>.
95
	 */
95
	 */
96
	@Override
96
	protected boolean prepare() {
97
	protected boolean prepare() {
97
		return true;
98
		return true;
98
	}
99
	}
Lines 151-156 Link Here
151
	 * I can be undone if I successfully recorded the changes that I executed.
152
	 * I can be undone if I successfully recorded the changes that I executed.
152
	 * Subclasses would not normally need to override this method.
153
	 * Subclasses would not normally need to override this method.
153
	 */
154
	 */
155
	@Override
154
	public boolean canUndo() {
156
	public boolean canUndo() {
155
		return canApplyChange();
157
		return canApplyChange();
156
	}
158
	}
Lines 175-180 Link Here
175
	 * Undoes the changes that I recorded.
177
	 * Undoes the changes that I recorded.
176
	 * Subclasses would not normally need to override this method.
178
	 * Subclasses would not normally need to override this method.
177
	 */
179
	 */
180
	@Override
178
	public final void undo() {
181
	public final void undo() {
179
		if (change != null) {
182
		if (change != null) {
180
			change.applyAndReverse();
183
			change.applyAndReverse();
Lines 199-204 Link Here
199
	protected abstract void doExecute();
202
	protected abstract void doExecute();
200
	
203
	
201
	// Documentation copied from the inherited specification
204
	// Documentation copied from the inherited specification
205
	@Override
202
	public Command chain(Command command) {
206
	public Command chain(Command command) {
203
	    return new ConditionalRedoCommand.Compound().chain(this).chain(command);
207
	    return new ConditionalRedoCommand.Compound().chain(this).chain(command);
204
	}
208
	}
Lines 245-251 Link Here
245
     * Extends the inherited implementation by disposing my change description,
249
     * Extends the inherited implementation by disposing my change description,
246
     * if any.
250
     * if any.
247
     */
251
     */
248
    public void dispose() {
252
    @Override
253
	public void dispose() {
249
        super.dispose();
254
        super.dispose();
250
        
255
        
251
        if (change != null) {
256
        if (change != null) {
(-)src/org/eclipse/emf/transaction/ReadFilter.java (+1 lines)
Lines 45-50 Link Here
45
	}
45
	}
46
	
46
	
47
	// Documentation inherited from the method specification
47
	// Documentation inherited from the method specification
48
	@Override
48
	public boolean matches(Notification notification) {
49
	public boolean matches(Notification notification) {
49
		switch (notification.getEventType()) {
50
		switch (notification.getEventType()) {
50
		case Notification.RESOLVE:
51
		case Notification.RESOLVE:
(-)src/org/eclipse/emf/transaction/DemultiplexingListener.java (-5 / +3 lines)
Lines 16-23 Link Here
16
 */
16
 */
17
package org.eclipse.emf.transaction;
17
package org.eclipse.emf.transaction;
18
18
19
import java.util.Iterator;
20
21
import org.eclipse.emf.common.notify.Notification;
19
import org.eclipse.emf.common.notify.Notification;
22
20
23
/**
21
/**
Lines 50-59 Link Here
50
	 * 
48
	 * 
51
	 * @see #handleNotification(TransactionalEditingDomain, Notification)
49
	 * @see #handleNotification(TransactionalEditingDomain, Notification)
52
	 */
50
	 */
51
	@Override
53
	public void resourceSetChanged(ResourceSetChangeEvent event) {
52
	public void resourceSetChanged(ResourceSetChangeEvent event) {
54
		for (Iterator iter = event.getNotifications().iterator(); iter.hasNext();) {
53
		for (Notification next : event.getNotifications()) {
55
			Notification next = (Notification) iter.next();
56
			
57
			handleNotification(event.getEditingDomain(), next);
54
			handleNotification(event.getEditingDomain(), next);
58
		}
55
		}
59
	}
56
	}
Lines 71-76 Link Here
71
	/**
68
	/**
72
	 * I want only post-commit events, not pre-commit events.
69
	 * I want only post-commit events, not pre-commit events.
73
	 */
70
	 */
71
	@Override
74
	public boolean isPostcommitOnly() {
72
	public boolean isPostcommitOnly() {
75
		return true;
73
		return true;
76
	}
74
	}
(-)src/org/eclipse/emf/transaction/Transaction.java (-4 / +4 lines)
Lines 23-31 Link Here
23
23
24
24
25
/**
25
/**
26
 * Specification of a transaction in a {@link TransactionalEditingDomain}.  All reading and
26
 * Specification of a transaction in a {@link TransactionalEditingDomain}.  All
27
 * writing of data in a <code>TransactionalEditingDomain</code> is performed in the context
27
 * reading and writing of data in a <code>TransactionalEditingDomain</code> is
28
 * of a transaction.
28
 * performed in the context of a transaction.
29
 * <p>
29
 * <p>
30
 * This interface is not intended to be implemented by clients.  It is used
30
 * This interface is not intended to be implemented by clients.  It is used
31
 * internally and by frameworks extending this API.  It is mostly of use to
31
 * internally and by frameworks extending this API.  It is mostly of use to
Lines 191-197 Link Here
191
	 * 
191
	 * 
192
	 * @return an unmodifiable view of my options
192
	 * @return an unmodifiable view of my options
193
	 */
193
	 */
194
	Map getOptions();
194
	Map<Object, Object> getOptions();
195
195
196
	/**
196
	/**
197
	 * Queries whether I am active.  I am active after I have started and
197
	 * Queries whether I am active.  I am active after I have started and
(-)src/org/eclipse/emf/transaction/TransactionalEditingDomain.java (-5 / +22 lines)
Lines 24-29 Link Here
24
import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
24
import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
25
import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl;
25
import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl;
26
import org.eclipse.emf.transaction.util.Adaptable;
26
import org.eclipse.emf.transaction.util.Adaptable;
27
import org.eclipse.emf.transaction.util.TransactionUtil;
27
28
28
/**
29
/**
29
 * An extension of the {@link EditingDomain} API that applies transactional
30
 * An extension of the {@link EditingDomain} API that applies transactional
Lines 149-154 Link Here
149
	 * safe to call this method on the Eclipse UI thread because special
150
	 * safe to call this method on the Eclipse UI thread because special
150
	 * precaution is taken to ensure that liveness is maintained (using
151
	 * precaution is taken to ensure that liveness is maintained (using
151
	 * mechanisms built into the Job Manager).
152
	 * mechanisms built into the Job Manager).
153
	 * </p><p>
154
	 * <b>Note</b>: Since the 1.2 release, the
155
	 * {@link TransactionUtil#runExclusive(TransactionalEditingDomain, RunnableWithResult)}
156
	 * utility provides type-safe execution of runnables returning results and
157
	 * should be preferred over this API.
152
	 * </p>
158
	 * </p>
153
	 * 
159
	 * 
154
	 * @param read a read-only operation to execute
160
	 * @param read a read-only operation to execute
Lines 159-165 Link Here
159
	 *    
165
	 *    
160
	 * @throws InterruptedException if the current thread is interrupted while
166
	 * @throws InterruptedException if the current thread is interrupted while
161
	 *    waiting for access to the resource set
167
	 *    waiting for access to the resource set
162
	 *    
168
	 * 
169
	 * @see TransactionUtil#runExclusive(RunnableWithResult)
163
	 * @see Transaction#commit()
170
	 * @see Transaction#commit()
164
	 */
171
	 */
165
	Object runExclusive(Runnable read) throws InterruptedException;
172
	Object runExclusive(Runnable read) throws InterruptedException;
Lines 221-228 Link Here
221
	 * active transaction remains active.  Any attempt to execute the runnable
228
	 * active transaction remains active.  Any attempt to execute the runnable
222
	 * after this transaction has committed or while a nested transaction is
229
	 * after this transaction has committed or while a nested transaction is
223
	 * active will result in an {@link IllegalStateException}.
230
	 * active will result in an {@link IllegalStateException}.
231
	 * </p><p>
232
	 * <b>Note</b>: Since the 1.2 release, the
233
	 * {@link TransactionUtil#createPrivilegedRunnable(TransactionalEditingDomain, RunnableWithResult)}
234
	 * utility provides type-safe privileged access for runnables returning
235
	 * results and should be preferred over this API.
224
	 * </p>
236
	 * </p>
225
	 * 
237
	 * 
238
	 * @param <T> the result type of the {@link RunnableWithResult} if such
239
	 *    is the <tt>read</tt> argument
240
	 * 
226
	 * @param runnable a runnable to execute in the context of the active
241
	 * @param runnable a runnable to execute in the context of the active
227
	 *     transaction, on any thread
242
	 *     transaction, on any thread
228
	 *     
243
	 *     
Lines 235-242 Link Here
235
	 *     prevents "theft" of transactions by malicious code.  Note also
250
	 *     prevents "theft" of transactions by malicious code.  Note also
236
	 *     that this implies an exception if there is no active transaction at
251
	 *     that this implies an exception if there is no active transaction at
237
	 *     the time of this call
252
	 *     the time of this call
253
	 *     
254
	 * @see TransactionUtil#createPrivilegedRunnable(TransactionalEditingDomain, RunnableWithResult)
238
	 */
255
	 */
239
	RunnableWithResult createPrivilegedRunnable(Runnable runnable);
256
	RunnableWithResult<Object> createPrivilegedRunnable(Runnable runnable);
240
	
257
	
241
	/**
258
	/**
242
	 * Disposes of this editing domain and any resources that it has allocated.
259
	 * Disposes of this editing domain and any resources that it has allocated.
Lines 392-400 Link Here
392
	     * Obtains a read-only view of the editing domain's default transaction
409
	     * Obtains a read-only view of the editing domain's default transaction
393
	     * options.
410
	     * options.
394
	     * 
411
	     * 
395
	     * @return my read-only transaction options
412
	     * @return my read-only map of transaction options
396
	     */
413
	     */
397
	    Map getDefaultTransactionOptions();
414
	    Map<Object, Object> getDefaultTransactionOptions();
398
	    
415
	    
399
	    /**
416
	    /**
400
	     * Sets the default transaction options.  It is probably best to do this
417
	     * Sets the default transaction options.  It is probably best to do this
Lines 404-409 Link Here
404
	     * 
421
	     * 
405
	     * @param options the new options.  The options are copied from the map
422
	     * @param options the new options.  The options are copied from the map
406
	     */
423
	     */
407
	    void setDefaultTransactionOptions(Map options);
424
	    void setDefaultTransactionOptions(Map<?, ?> options);
408
	}
425
	}
409
}
426
}
(-)src/org/eclipse/emf/transaction/ResourceSetChangeEvent.java (-4 / +5 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005, 2006 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 43-49 Link Here
43
	private static final long serialVersionUID = -6265603064286194469L;
43
	private static final long serialVersionUID = -6265603064286194469L;
44
	
44
	
45
	private final Transaction transaction;
45
	private final Transaction transaction;
46
	private final List notifications;
46
	private final List<Notification> notifications;
47
	
47
	
48
	/**
48
	/**
49
	 * Initializes me with my source editing domain.
49
	 * Initializes me with my source editing domain.
Lines 62-68 Link Here
62
	 * @param notifications a list of events (as {@link Notification}s), in the
62
	 * @param notifications a list of events (as {@link Notification}s), in the
63
	 *     order in which they occurred
63
	 *     order in which they occurred
64
	 */
64
	 */
65
	public ResourceSetChangeEvent(TransactionalEditingDomain source, Transaction transaction, List notifications) {
65
	public ResourceSetChangeEvent(TransactionalEditingDomain source,
66
			Transaction transaction, List<Notification> notifications) {
66
		super(source);
67
		super(source);
67
		
68
		
68
		this.transaction = transaction;
69
		this.transaction = transaction;
Lines 105-111 Link Here
105
	 * 
106
	 * 
106
	 * @see Notification
107
	 * @see Notification
107
	 */
108
	 */
108
	public List getNotifications() {
109
	public List<Notification> getNotifications() {
109
		return notifications;
110
		return notifications;
110
	}
111
	}
111
}
112
}
(-)src/org/eclipse/emf/transaction/ResourceContentTypeFilter.java (+3 lines)
Lines 61-66 Link Here
61
	}
61
	}
62
	
62
	
63
	// Documentation inherited from the method specification
63
	// Documentation inherited from the method specification
64
	@Override
64
	public boolean matches(Notification notification) {
65
	public boolean matches(Notification notification) {
65
		boolean result = false;
66
		boolean result = false;
66
		IContentType[] actualTypes = getContentTypes(notification);
67
		IContentType[] actualTypes = getContentTypes(notification);
Lines 122-131 Link Here
122
				return contentTypes;
123
				return contentTypes;
123
			}
124
			}
124
			
125
			
126
			@Override
125
			public boolean isAdapterForType(Object type) {
127
			public boolean isAdapterForType(Object type) {
126
				return type == Cache.class;
128
				return type == Cache.class;
127
			}
129
			}
128
			
130
			
131
			@Override
129
			public void notifyChanged(Notification msg) {
132
			public void notifyChanged(Notification msg) {
130
				if (!msg.isTouch()) {
133
				if (!msg.isTouch()) {
131
					// clear the cache
134
					// clear the cache
(-)src/org/eclipse/emf/transaction/util/ConditionalRedoCommand.java (-11 / +9 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 16-22 Link Here
16
 */
16
 */
17
package org.eclipse.emf.transaction.util;
17
package org.eclipse.emf.transaction.util;
18
18
19
import java.util.Iterator;
20
import java.util.List;
19
import java.util.List;
21
20
22
import org.eclipse.emf.common.command.Command;
21
import org.eclipse.emf.common.command.Command;
Lines 58-73 Link Here
58
			super();
57
			super();
59
		}
58
		}
60
59
61
		public Compound(int resultIndex, List commandList) {
60
		public Compound(int resultIndex, List<Command> commandList) {
62
			super(resultIndex, commandList);
61
			super(resultIndex, commandList);
63
		}
62
		}
64
63
65
		public Compound(int resultIndex, String label, List commandList) {
64
		public Compound(int resultIndex, String label, List<Command> commandList) {
66
			super(resultIndex, label, commandList);
65
			super(resultIndex, label, commandList);
67
		}
66
		}
68
67
69
		public Compound(int resultIndex, String label, String description,
68
		public Compound(int resultIndex, String label, String description,
70
				List commandList) {
69
				List<Command> commandList) {
71
			super(resultIndex, label, description, commandList);
70
			super(resultIndex, label, description, commandList);
72
		}
71
		}
73
72
Lines 83-97 Link Here
83
			super(resultIndex);
82
			super(resultIndex);
84
		}
83
		}
85
84
86
		public Compound(List commandList) {
85
		public Compound(List<Command> commandList) {
87
			super(commandList);
86
			super(commandList);
88
		}
87
		}
89
88
90
		public Compound(String label, List commandList) {
89
		public Compound(String label, List<Command> commandList) {
91
			super(label, commandList);
90
			super(label, commandList);
92
		}
91
		}
93
92
94
		public Compound(String label, String description, List commandList) {
93
		public Compound(String label, String description, List<Command> commandList) {
95
			super(label, description, commandList);
94
			super(label, description, commandList);
96
		}
95
		}
97
96
Lines 111-119 Link Here
111
		 *     <code>true</code>, otherwise
110
		 *     <code>true</code>, otherwise
112
		 */
111
		 */
113
		public boolean canRedo() {
112
		public boolean canRedo() {
114
			for (Iterator iter = commandList.iterator(); iter.hasNext();) {
113
			for (Object next : commandList) {
115
				Object next = iter.next();
116
117
				if ((next instanceof ConditionalRedoCommand)
114
				if ((next instanceof ConditionalRedoCommand)
118
						&& !((ConditionalRedoCommand) next).canRedo()) {
115
						&& !((ConditionalRedoCommand) next).canRedo()) {
119
					return false;
116
					return false;
Lines 126-131 Link Here
126
		/**
123
		/**
127
		 * I am self-chaining.
124
		 * I am self-chaining.
128
		 */
125
		 */
126
		@Override
129
		public Command chain(Command c) {
127
		public Command chain(Command c) {
130
			append(c);
128
			append(c);
131
			return this;
129
			return this;
(-)src/org/eclipse/emf/transaction/util/TriggerCommand.java (-9 / +12 lines)
Lines 36-42 Link Here
36
 */
36
 */
37
public class TriggerCommand extends ConditionalRedoCommand.Compound {
37
public class TriggerCommand extends ConditionalRedoCommand.Compound {
38
	private final Command triggeringCommand;
38
	private final Command triggeringCommand;
39
	private final List triggers;
39
	private final List<Command> triggers;
40
	
40
	
41
	/**
41
	/**
42
	 * Initializes me with a list of commands triggered not by the execution of
42
	 * Initializes me with a list of commands triggered not by the execution of
Lines 47-53 Link Here
47
	 * 
47
	 * 
48
	 * @param triggers the trigger commands that I encapsulate
48
	 * @param triggers the trigger commands that I encapsulate
49
	 */
49
	 */
50
	public TriggerCommand(List triggers) {
50
	public TriggerCommand(List<Command> triggers) {
51
		super(0, "Triggers", "Triggered Changes", triggers); //$NON-NLS-1$ //$NON-NLS-2$
51
		super(0, "Triggers", "Triggered Changes", triggers); //$NON-NLS-1$ //$NON-NLS-2$
52
		
52
		
53
		this.triggeringCommand = null;
53
		this.triggeringCommand = null;
Lines 62-68 Link Here
62
	 * @param triggeringCommand the command that triggered further commands
62
	 * @param triggeringCommand the command that triggered further commands
63
	 * @param triggers the trigger commands that I encapsulate
63
	 * @param triggers the trigger commands that I encapsulate
64
	 */
64
	 */
65
	public TriggerCommand(Command triggeringCommand, List triggers) {
65
	public TriggerCommand(Command triggeringCommand, List<Command> triggers) {
66
		super(0, triggeringCommand.getLabel(), triggeringCommand.getDescription(), triggers);
66
		super(0, triggeringCommand.getLabel(), triggeringCommand.getDescription(), triggers);
67
		
67
		
68
		this.triggeringCommand = triggeringCommand;
68
		this.triggeringCommand = triggeringCommand;
Lines 85-95 Link Here
85
	 * 
85
	 * 
86
	 * @return my triggers, as a list of {@link Command}s.  Will not be empty
86
	 * @return my triggers, as a list of {@link Command}s.  Will not be empty
87
	 */
87
	 */
88
	public final List getTriggers() {
88
	public final List<Command> getTriggers() {
89
		return triggers;
89
		return triggers;
90
	}
90
	}
91
	
91
	
92
	// Documentation copied from the inherited specification
92
	// Documentation copied from the inherited specification
93
	@Override
93
	protected boolean prepare() {
94
	protected boolean prepare() {
94
		// we will check canExecute() as we go
95
		// we will check canExecute() as we go
95
		return !triggers.isEmpty();
96
		return !triggers.isEmpty();
Lines 99-109 Link Here
99
	 * Executes all of my trigger commands, then prepends the original triggering
100
	 * Executes all of my trigger commands, then prepends the original triggering
100
	 * command (if any) so that it will be undone/redone with the others.
101
	 * command (if any) so that it will be undone/redone with the others.
101
	 */
102
	 */
103
	@Override
102
	public void execute() {
104
	public void execute() {
103
		// execute just the triggers
105
		// execute just the triggers
104
	    for (ListIterator iter = commandList.listIterator(); iter.hasNext();) {
106
	    for (ListIterator<Command> iter = commandList.listIterator(); iter.hasNext();) {
105
			try {
107
			try {
106
				Command command = (Command) iter.next();
108
				Command command = iter.next();
107
				
109
				
108
				if (command.canExecute()) {
110
				if (command.canExecute()) {
109
					command.execute();
111
					command.execute();
Lines 123-129 Link Here
123
					// Iterate back over the executed commands to undo them.
125
					// Iterate back over the executed commands to undo them.
124
					//
126
					//
125
					while (iter.hasPrevious()) {
127
					while (iter.hasPrevious()) {
126
						Command command = (Command) iter.previous();
128
						Command command = iter.previous();
127
						if (command.canUndo()) {
129
						if (command.canUndo()) {
128
							command.undo();
130
							command.undo();
129
						} else {
131
						} else {
Lines 147-153 Link Here
147
			// then replace the command-list with a new list that includes
149
			// then replace the command-list with a new list that includes
148
			// the
150
			// the
149
			// originally executed command (for undo/redo)
151
			// originally executed command (for undo/redo)
150
			commandList = new java.util.ArrayList(triggers.size() + 1);
152
			commandList = new java.util.ArrayList<Command>(triggers.size() + 1);
151
			commandList.add(triggeringCommand);
153
			commandList.add(triggeringCommand);
152
			commandList.addAll(triggers);
154
			commandList.addAll(triggers);
153
		}
155
		}
Lines 157-163 Link Here
157
     * Extends the inherited implementation by disposing my triggering command,
159
     * Extends the inherited implementation by disposing my triggering command,
158
     * also (if any).
160
     * also (if any).
159
     */
161
     */
160
    public void dispose() {
162
    @Override
163
	public void dispose() {
161
        super.dispose();
164
        super.dispose();
162
        
165
        
163
        if (triggeringCommand != null) {
166
        if (triggeringCommand != null) {
(-)src/org/eclipse/emf/transaction/util/CommandChangeDescription.java (+2 lines)
Lines 83-88 Link Here
83
	 * I apply my change by undoing the encapsulated operation.  After it is
83
	 * I apply my change by undoing the encapsulated operation.  After it is
84
	 * undone, I dispose myself.
84
	 * undone, I dispose myself.
85
	 */
85
	 */
86
	@Override
86
	public void apply() {
87
	public void apply() {
87
		try {
88
		try {
88
			command.undo();
89
			command.undo();
Lines 95-100 Link Here
95
	 * I apply-and-reverse by alternately undoing and redoing the encapsulated
96
	 * I apply-and-reverse by alternately undoing and redoing the encapsulated
96
	 * operation.
97
	 * operation.
97
	 */
98
	 */
99
	@Override
98
	public void applyAndReverse() {
100
	public void applyAndReverse() {
99
		if (isRedone) {
101
		if (isRedone) {
100
			command.undo();
102
			command.undo();
(-)src/org/eclipse/emf/transaction/util/Queue.java (-360 / +362 lines)
Lines 1-360 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005, 2006 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
9
 *
10
 * Contributors:
10
 * Contributors:
11
 *   IBM - Initial API and implementation
11
 *   IBM - Initial API and implementation
12
 *
12
 *
13
 * </copyright>
13
 * </copyright>
14
 *
14
 *
15
 * $Id: Queue.java,v 1.2 2006/01/13 21:50:43 cdamus Exp $
15
 * $Id: Queue.java,v 1.2 2006/01/13 21:50:43 cdamus Exp $
16
 */
16
 */
17
package org.eclipse.emf.transaction.util;
17
package org.eclipse.emf.transaction.util;
18
18
19
import org.eclipse.emf.transaction.internal.Tracing;
19
import org.eclipse.emf.transaction.internal.Tracing;
20
20
21
21
22
/**
22
/**
23
 * Simplistic implementation of a FIFO wait queue for fair notification of
23
 * Simplistic implementation of a FIFO wait queue for fair notification of
24
 * threads that are waiting for a lock.
24
 * threads that are waiting for a lock.
25
 *
25
 *
26
 * @author Christian W. Damus (cdamus)
26
 * @author Christian W. Damus (cdamus)
27
 */
27
 */
28
final class Queue {
28
final class Queue {
29
	private Wait head;
29
	private Wait head;
30
	private Wait tail;
30
	private Wait tail;
31
	private int size;
31
	private int size;
32
	private int exclusiveCount;  // number of threads waiting for exclusive access
32
	private int exclusiveCount;  // number of threads waiting for exclusive access
33
	
33
	
34
	/**
34
	/**
35
	 * Initializes me.
35
	 * Initializes me.
36
	 */
36
	 */
37
	public Queue() {
37
	public Queue() {
38
		super();
38
		super();
39
	}
39
	}
40
	
40
	
41
	/**
41
	/**
42
	 * Queries whether the queue is empty of threads.
42
	 * Queries whether the queue is empty of threads.
43
	 * 
43
	 * 
44
	 * @return <code>true</code> if I have no threads; <code>false</code>, otherwise
44
	 * @return <code>true</code> if I have no threads; <code>false</code>, otherwise
45
	 */
45
	 */
46
	public synchronized boolean isEmpty() {
46
	public synchronized boolean isEmpty() {
47
		return size == 0;
47
		return size == 0;
48
	}
48
	}
49
	
49
	
50
	/**
50
	/**
51
	 * Queries the number of waiting threads.
51
	 * Queries the number of waiting threads.
52
	 * 
52
	 * 
53
	 * @return my size
53
	 * @return my size
54
	 */
54
	 */
55
	public synchronized int size() {
55
	public synchronized int size() {
56
		return size;
56
		return size;
57
	}
57
	}
58
	
58
	
59
	/**
59
	/**
60
	 * Queries the number of threads waiting for exclusive access.
60
	 * Queries the number of threads waiting for exclusive access.
61
	 * 
61
	 * 
62
	 * @return my count of exclusive threads
62
	 * @return my count of exclusive threads
63
	 */
63
	 */
64
	public synchronized int exclusiveCount() {
64
	public synchronized int exclusiveCount() {
65
		return exclusiveCount;
65
		return exclusiveCount;
66
	}
66
	}
67
	
67
	
68
	/**
68
	/**
69
	 * Adds the current thread to the queue, blocking until either:
69
	 * Adds the current thread to the queue, blocking until either:
70
	 * <ul>
70
	 * <ul>
71
	 *    <li>the thread is awakened again by being dequeued</li>
71
	 *    <li>the thread is awakened again by being dequeued</li>
72
	 *    <li>the thread times out (if a time-out is specified)</li>
72
	 *    <li>the thread times out (if a time-out is specified)</li>
73
	 *    <li>the thread is interrupted while it is waiting</li>
73
	 *    <li>the thread is interrupted while it is waiting</li>
74
	 * </ul>
74
	 * </ul>
75
	 * 
75
	 * 
76
	 * @param timeout the time-out interval, in millis, or <code>0L</code>
76
	 * @param timeout the time-out interval, in millis, or <code>0L</code>
77
	 *     if no time-out is desired (i.e., wait as long as necessary)
77
	 *     if no time-out is desired (i.e., wait as long as necessary)
78
	 * @param exclusive <code>true</code> if the current thread needs exclusive
78
	 * @param exclusive <code>true</code> if the current thread needs exclusive
79
	 *     access (i.e., no other threads may currently be
79
	 *     access (i.e., no other threads may currently be
80
	 *     {@link #yield() yielding}); <code>false</code>, otherwise
80
	 *     {@link #yield() yielding}); <code>false</code>, otherwise
81
	 *     
81
	 *     
82
	 * @return the new wait node
82
	 * @return the new wait node
83
	 *    
83
	 *    
84
	 * @throws InterruptedException if the thread was interrupted while
84
	 * @throws InterruptedException if the thread was interrupted while
85
	 *    waiting for notification.  If it is interrupted after it has been
85
	 *    waiting for notification.  If it is interrupted after it has been
86
	 *    notified but before it awakes, no exception is thrown
86
	 *    notified but before it awakes, no exception is thrown
87
	 */
87
	 */
88
	public synchronized Wait put(long timeout, boolean exclusive) throws InterruptedException {
88
	public synchronized Wait put(long timeout, boolean exclusive) throws InterruptedException {
89
		final Thread current = Thread.currentThread();
89
		final Thread current = Thread.currentThread();
90
		Wait result;
90
		Wait result;
91
		
91
		
92
		// first, see whether we can find an existing node that timed out, but
92
		// first, see whether we can find an existing node that timed out, but
93
		//    that we have not yet dequeued.  If found, just re-use it to
93
		//    that we have not yet dequeued.  If found, just re-use it to
94
		//    to preserve seniority.  This allows threads to loop with short
94
		//    to preserve seniority.  This allows threads to loop with short
95
		//    time-outs for the sake of liveness (e.g., to check for cancellation
95
		//    time-outs for the sake of liveness (e.g., to check for cancellation
96
		//    of progress monitors)
96
		//    of progress monitors)
97
		result = findNode(current);
97
		result = findNode(current);
98
		
98
		
99
		if (result == null) {
99
		if (result == null) {
100
			// must enqueue a new node
100
			// must enqueue a new node
101
			result = new Wait(current);
101
			result = new Wait(current);
102
		
102
		
103
			if (tail == null) {
103
			if (tail == null) {
104
				tail = result;
104
				tail = result;
105
				head = tail;
105
				head = tail;
106
			} else {
106
			} else {
107
				tail.next = result;
107
				tail.next = result;
108
				tail = result;
108
				tail = result;
109
			}			
109
			}			
110
			
110
			
111
			size++;
111
			size++;
112
			
112
			
113
			if (exclusive) {
113
			if (exclusive) {
114
				exclusiveCount++;
114
				exclusiveCount++;
115
			}
115
			}
116
		} else {
116
		} else {
117
			// must keep the count of exclusive waits in sync
117
			// must keep the count of exclusive waits in sync
118
			if (exclusive != result.isExclusive()) {
118
			if (exclusive != result.isExclusive()) {
119
				exclusiveCount += exclusive? 1 : -1;
119
				exclusiveCount += exclusive? 1 : -1;
120
			}
120
			}
121
		}
121
		}
122
		
122
		
123
		result.initialize(exclusive);
123
		result.initialize(exclusive);
124
		
124
		
125
		return result;
125
		return result;
126
	}
126
	}
127
	
127
	
128
	/**
128
	/**
129
	 * Dequeues the next eligible (not timed-out or interrupted)
129
	 * Dequeues the next eligible (not timed-out or interrupted)
130
	 * thread.  If any threads are currently yielding, then we look for the
130
	 * thread.  If any threads are currently yielding, then we look for the
131
	 * the next eligible non-exclusive thread.
131
	 * the next eligible non-exclusive thread.
132
	 * 
132
	 * 
133
	 * @param allowExclusive whether to allow dequeueing of threads waiting
133
	 * @param allowExclusive whether to allow dequeueing of threads waiting
134
	 *     for exclusive access
134
	 *     for exclusive access
135
	 * 
135
	 * 
136
	 * @return the next eligible thread, or <code>null</code> if
136
	 * @return the next eligible thread, or <code>null</code> if
137
	 *     no threads were waiting or they all timed out
137
	 *     no threads were waiting or they all timed out
138
	 */
138
	 */
139
	public synchronized Wait take(boolean allowExclusive) {
139
	public synchronized Wait take(boolean allowExclusive) {
140
		Wait result = null;
140
		Wait result = null;
141
		
141
		
142
		Wait prev = null;
142
		Wait prev = null;
143
		for (Wait node = head; (result == null) && (node != null); node = node.next) {
143
		for (Wait node = head; (result == null) && (node != null); node = node.next) {
144
			if (allowExclusive || !node.isExclusive()) {
144
			if (allowExclusive || !node.isExclusive()) {
145
				// this is a candidate.  Remove it from the list
145
				// this is a candidate.  Remove it from the list
146
				if (prev != null) {
146
				if (prev != null) {
147
					prev.next = node.next;
147
					prev.next = node.next;
148
				} else {
148
				} else {
149
					head = node.next;
149
					head = node.next;
150
				}
150
				}
151
				
151
				
152
				if (head == null) {
152
				if (head == null) {
153
					tail = null;
153
					tail = null;
154
				} else if (node == tail) {
154
				} else if (node == tail) {
155
					tail = prev;
155
					tail = prev;
156
				}
156
				}
157
				
157
				
158
				// help the garbage collector
158
				// help the garbage collector
159
				node.next = null;
159
				node.next = null;
160
				
160
				
161
				size--;
161
				size--;
162
				
162
				
163
				if (node.isExclusive()) {
163
				if (node.isExclusive()) {
164
					exclusiveCount--;
164
					exclusiveCount--;
165
				}
165
				}
166
				
166
				
167
				result = node;
167
				result = node;
168
			} else {
168
			} else {
169
				prev = node;
169
				prev = node;
170
			}
170
			}
171
		}
171
		}
172
		
172
		
173
		return result;
173
		return result;
174
	}
174
	}
175
	
175
	
176
	/**
176
	/**
177
	 * Finds an existing node for the specified <code>thread</code>, to be
177
	 * Finds an existing node for the specified <code>thread</code>, to be
178
	 * re-used for another wait following a time-out.  This ensures the
178
	 * re-used for another wait following a time-out.  This ensures the
179
	 * preservation of ordering for threads that time-out periodically but
179
	 * preservation of ordering for threads that time-out periodically but
180
	 * with the intention of waiting again each time.
180
	 * with the intention of waiting again each time.
181
	 * 
181
	 * 
182
	 * @param thread a thread to look for in the queue
182
	 * @param thread a thread to look for in the queue
183
	 * 
183
	 * 
184
	 * @return the thread's node, or <code>null</code> if it is not found
184
	 * @return the thread's node, or <code>null</code> if it is not found
185
	 */
185
	 */
186
	private Wait findNode(Thread thread) {
186
	private Wait findNode(Thread thread) {
187
		Wait result = null;
187
		Wait result = null;
188
		
188
		
189
		for (Wait next = head; next != null; next = next.next) {
189
		for (Wait next = head; next != null; next = next.next) {
190
			if (next.thread == thread) {
190
			if (next.thread == thread) {
191
				result = next;
191
				result = next;
192
				break;
192
				break;
193
			}
193
			}
194
		}
194
		}
195
		
195
		
196
		return result;
196
		return result;
197
	}
197
	}
198
	
198
	
199
	public String toString() {
199
	@Override
200
		StringBuffer result = new StringBuffer();
200
	public String toString() {
201
		boolean first = true;
201
		StringBuffer result = new StringBuffer();
202
		
202
		boolean first = true;
203
		result.append("Queue["); //$NON-NLS-1$
203
		
204
		for (Wait next = head; head != null; next = next.next) {
204
		result.append("Queue["); //$NON-NLS-1$
205
			if (first) {
205
		for (Wait next = head; head != null; next = next.next) {
206
				first = false;
206
			if (first) {
207
			} else {
207
				first = false;
208
				result.append(", "); //$NON-NLS-1$
208
			} else {
209
			}
209
				result.append(", "); //$NON-NLS-1$
210
			
210
			}
211
			result.append(next);
211
			
212
		}
212
			result.append(next);
213
		
213
		}
214
		result.append(']');
214
		
215
		
215
		result.append(']');
216
		return result.toString();
216
		
217
	}
217
		return result.toString();
218
	
218
	}
219
	/**
219
	
220
	 * Implementation of a linked node in the wait queue. 
220
	/**
221
	 *
221
	 * Implementation of a linked node in the wait queue. 
222
	 * @author Christian W. Damus (cdamus)
222
	 *
223
	 */
223
	 * @author Christian W. Damus (cdamus)
224
	static class Wait {
224
	 */
225
		Wait next;
225
	static class Wait {
226
		private final Thread thread;
226
		Wait next;
227
		private boolean exclusive;
227
		private final Thread thread;
228
		private boolean notified;
228
		private boolean exclusive;
229
		private boolean timedOut;
229
		private boolean notified;
230
		
230
		private boolean timedOut;
231
		/**
231
		
232
		 * Initializes me with the thread that is waiting on me.
232
		/**
233
		 * 
233
		 * Initializes me with the thread that is waiting on me.
234
		 * @param thread my thread
234
		 * 
235
		 */
235
		 * @param thread my thread
236
		Wait(Thread thread) {
236
		 */
237
			this.thread = thread;
237
		Wait(Thread thread) {
238
		}
238
			this.thread = thread;
239
		
239
		}
240
		/**
240
		
241
		 * Queries whether my thread was successfully notified.
241
		/**
242
		 * 
242
		 * Queries whether my thread was successfully notified.
243
		 * @return whether my thread was notified
243
		 * 
244
		 */
244
		 * @return whether my thread was notified
245
		boolean wasNotified() {
245
		 */
246
			return notified && !timedOut;
246
		boolean wasNotified() {
247
		}
247
			return notified && !timedOut;
248
		
248
		}
249
		/**
249
		
250
		 * Queries whether I require exclusive scheduling.
250
		/**
251
		 * 
251
		 * Queries whether I require exclusive scheduling.
252
		 * @return whether I am exclusive
252
		 * 
253
		 */
253
		 * @return whether I am exclusive
254
		boolean isExclusive() {
254
		 */
255
			return exclusive;
255
		boolean isExclusive() {
256
		}
256
			return exclusive;
257
		
257
		}
258
		/**
258
		
259
		 * Initializes my state.
259
		/**
260
		 * 
260
		 * Initializes my state.
261
		 * @param excl <code>true</code> if I should not be dequeue while
261
		 * 
262
		 *    there are any yielders; <code>false</code>, otherwise
262
		 * @param excl <code>true</code> if I should not be dequeue while
263
		 */
263
		 *    there are any yielders; <code>false</code>, otherwise
264
		void initialize(boolean excl) {
264
		 */
265
			this.exclusive = excl;
265
		void initialize(boolean excl) {
266
			timedOut = false;
266
			this.exclusive = excl;
267
			notified = false;
267
			timedOut = false;
268
		}
268
			notified = false;
269
		
269
		}
270
		/**
270
		
271
		 * Retrieves that thread that is/was waiting on me.
271
		/**
272
		 * 
272
		 * Retrieves that thread that is/was waiting on me.
273
		 * @return my thread
273
		 * 
274
		 */
274
		 * @return my thread
275
		Thread getThread() {
275
		 */
276
			return thread;
276
		Thread getThread() {
277
		}
277
			return thread;
278
		
278
		}
279
		/**
279
		
280
		 * Attempts to wake my thread.  Wake-up can be attempted once only
280
		/**
281
		 * upon dequeueing the thread.  It will succeed only if the thread
281
		 * Attempts to wake my thread.  Wake-up can be attempted once only
282
		 * did not already time-out or interrupt.
282
		 * upon dequeueing the thread.  It will succeed only if the thread
283
		 * 
283
		 * did not already time-out or interrupt.
284
		 * @return <code>true</code> if my thread was awakened;
284
		 * 
285
		 *    <code>false</code> if it had already been awakened or timed out,
285
		 * @return <code>true</code> if my thread was awakened;
286
		 *    or if it had been interrupted
286
		 *    <code>false</code> if it had already been awakened or timed out,
287
		 */
287
		 *    or if it had been interrupted
288
		synchronized boolean wakeUp() {
288
		 */
289
			boolean result = false;
289
		synchronized boolean wakeUp() {
290
			
290
			boolean result = false;
291
			if (!(notified || timedOut)) {
291
			
292
				notified = true;
292
			if (!(notified || timedOut)) {
293
				result = true;
293
				notified = true;
294
				notify();  // wake me up!
294
				result = true;
295
			}
295
				notify();  // wake me up!
296
			
296
			}
297
			return result;
297
			
298
		}
298
			return result;
299
		
299
		}
300
		/**
300
		
301
		 * Waits for the specified time-out.
301
		/**
302
		 * 
302
		 * Waits for the specified time-out.
303
		 * @param timeout the time-out, in millis, or <code>0L</code> to wait
303
		 * 
304
		 *    indefinitely
304
		 * @param timeout the time-out, in millis, or <code>0L</code> to wait
305
		 *    
305
		 *    indefinitely
306
		 * @throws InterruptedException if the waiting thread was interrupted
306
		 *    
307
		 */
307
		 * @throws InterruptedException if the waiting thread was interrupted
308
		synchronized void waitFor(long timeout) throws InterruptedException {
308
		 */
309
			// first, check whether perhaps another thread has already awakened
309
		synchronized void waitFor(long timeout) throws InterruptedException {
310
			//   me *after* I was put on the queue but *before* calling this
310
			// first, check whether perhaps another thread has already awakened
311
			//   method (as there is an unsynchronized gap in the
311
			//   me *after* I was put on the queue but *before* calling this
312
			//   Lock.acquire() method)
312
			//   method (as there is an unsynchronized gap in the
313
			if (notified) {
313
			//   Lock.acquire() method)
314
				return;
314
			if (notified) {
315
			}
315
				return;
316
			
316
			}
317
			long waitTime = timeout;
317
			
318
			long start = System.currentTimeMillis();
318
			long waitTime = timeout;
319
			
319
			long start = System.currentTimeMillis();
320
			try {
320
			
321
				for (;;) {
321
			try {
322
					wait(waitTime);
322
				for (;;) {
323
					
323
					wait(waitTime);
324
					if (notified) {
324
					
325
						break;
325
					if (notified) {
326
					}
326
						break;
327
					
327
					}
328
					if (timeout > 0L) {
328
					
329
						waitTime = timeout - (System.currentTimeMillis() - start);
329
					if (timeout > 0L) {
330
						
330
						waitTime = timeout - (System.currentTimeMillis() - start);
331
						if (waitTime <= 0L) {
331
						
332
							// giving up waiting
332
						if (waitTime <= 0L) {
333
							timedOut = true;
333
							// giving up waiting
334
							break;
334
							timedOut = true;
335
						}
335
							break;
336
					}
336
						}
337
				}
337
					}
338
			} catch (InterruptedException e) {
338
				}
339
				Tracing.catching(Wait.class, "waitFor", e); //$NON-NLS-1$
339
			} catch (InterruptedException e) {
340
				if (!notified) {
340
				Tracing.catching(Wait.class, "waitFor", e); //$NON-NLS-1$
341
					// thread was interrupted while it was waiting.
341
				if (!notified) {
342
					//   Pretend like we timed out (just in case), but
342
					// thread was interrupted while it was waiting.
343
					//   propagate the exception
343
					//   Pretend like we timed out (just in case), but
344
					timedOut = true;
344
					//   propagate the exception
345
					Tracing.throwing(Wait.class, "waitFor", e); //$NON-NLS-1$
345
					timedOut = true;
346
					throw e;
346
					Tracing.throwing(Wait.class, "waitFor", e); //$NON-NLS-1$
347
				} else {
347
					throw e;
348
					// the thread was interrupted after notification, but
348
				} else {
349
					//    before it woke up from the wait().  Must propagate
349
					// the thread was interrupted after notification, but
350
					//    the interrupt status but not fail this operation
350
					//    before it woke up from the wait().  Must propagate
351
					Thread.currentThread().interrupt();
351
					//    the interrupt status but not fail this operation
352
				}
352
					Thread.currentThread().interrupt();
353
			}
353
				}
354
		}
354
			}
355
		
355
		}
356
		public String toString() {
356
		
357
			return thread.getName() + "[" + notified + ", " + timedOut + ']'; //$NON-NLS-1$ //$NON-NLS-2$
357
		@Override
358
		}
358
		public String toString() {
359
	}
359
			return thread.getName() + "[" + notified + ", " + timedOut + ']'; //$NON-NLS-1$ //$NON-NLS-2$
360
}
360
		}
361
	}
362
}
(-)src/org/eclipse/emf/transaction/util/Lock.java (-10 / +13 lines)
Lines 21-27 Link Here
21
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.IStatus;
23
import org.eclipse.core.runtime.OperationCanceledException;
23
import org.eclipse.core.runtime.OperationCanceledException;
24
import org.eclipse.core.runtime.Platform;
25
import org.eclipse.core.runtime.Status;
24
import org.eclipse.core.runtime.Status;
26
import org.eclipse.core.runtime.jobs.IJobManager;
25
import org.eclipse.core.runtime.jobs.IJobManager;
27
import org.eclipse.core.runtime.jobs.ILock;
26
import org.eclipse.core.runtime.jobs.ILock;
Lines 72-78 Link Here
72
 * @author Christian W. Damus (cdamus)
71
 * @author Christian W. Damus (cdamus)
73
 */
72
 */
74
public class Lock {
73
public class Lock {
75
	private static final IJobManager jobmgr = Platform.getJobManager();
74
	private static final IJobManager jobmgr = Job.getJobManager();
76
	
75
	
77
	private static long nextId = 0;
76
	private static long nextId = 0;
78
	
77
	
Lines 99-114 Link Here
99
	
98
	
100
	// threads currently yielding read access
99
	// threads currently yielding read access
101
	// must use identity map because threads can override equals()
100
	// must use identity map because threads can override equals()
102
	private final Map yielders = new java.util.IdentityHashMap();
101
	private final Map<Thread, Lock> yielders =
102
		new java.util.IdentityHashMap<Thread, Lock>();
103
	
103
	
104
	// every thread has its own ILock that it acquires while it owns the
104
	// every thread has its own ILock that it acquires while it owns the
105
	//    transaction lock, to ensure that the thread is registered as a
105
	//    transaction lock, to ensure that the thread is registered as a
106
	//    "lock owner" in the lock table.  This ensures that Display.syncExec()
106
	//    "lock owner" in the lock table.  This ensures that Display.syncExec()
107
	//    calls from these threads will use the work queue to communicate
107
	//    calls from these threads will use the work queue to communicate
108
	//    runnables to a waiting UI thread
108
	//    runnables to a waiting UI thread
109
	private ThreadLocal threadLock = new ThreadLocal() {
109
	private final ThreadLocal<ILock> threadLock = new ThreadLocal<ILock>() {
110
		protected Object initialValue() {
110
		@Override
111
			return Platform.getJobManager().newLock();
111
		protected ILock initialValue() {
112
			return Job.getJobManager().newLock();
112
		}};
113
		}};
113
		
114
		
114
	/**
115
	/**
Lines 693-699 Link Here
693
			} else if (current == owner) {
694
			} else if (current == owner) {
694
				// current thread no longer needs the dummy lock
695
				// current thread no longer needs the dummy lock
695
				getThreadLock().release();
696
				getThreadLock().release();
696
			} // else non-owner is transfering.  Shouldn't happen
697
			} // else non-owner is transferring.  Shouldn't happen
697
			
698
			
698
		owner = thread;
699
		owner = thread;
699
	}
700
	}
Lines 705-713 Link Here
705
	 * @return the current thread's thread lock
706
	 * @return the current thread's thread lock
706
	 */
707
	 */
707
	private ILock getThreadLock() {
708
	private ILock getThreadLock() {
708
		return (ILock) threadLock.get();
709
		return threadLock.get();
709
	}
710
	}
710
	
711
	
712
	@Override
711
	public String toString() {
713
	public String toString() {
712
		Thread lastKnownOwner = owner;
714
		Thread lastKnownOwner = owner;
713
		
715
		
Lines 729-735 Link Here
729
        private final Thread thread;
731
        private final Thread thread;
730
        private final boolean exclusive;
732
        private final boolean exclusive;
731
733
732
        private ILock ilock = jobmgr.newLock();
734
        private final ILock ilock = jobmgr.newLock();
733
        private IStatus acquireStatus;
735
        private IStatus acquireStatus;
734
        
736
        
735
        private boolean aborted;
737
        private boolean aborted;
Lines 747-753 Link Here
747
        /**
749
        /**
748
         * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
750
         * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
749
         */
751
         */
750
        protected IStatus run(IProgressMonitor monitor) {
752
        @Override
753
		protected IStatus run(IProgressMonitor monitor) {
751
            try {
754
            try {
752
                ilock.acquire();
755
                ilock.acquire();
753
                
756
                
(-)src/org/eclipse/emf/transaction/util/Adaptable.java (-1 / +3 lines)
Lines 35-43 Link Here
35
    /**
35
    /**
36
     * Obtains an instance of the specified adapter type.
36
     * Obtains an instance of the specified adapter type.
37
     * 
37
     * 
38
     * @param <T> the interface for which to get an adapter
39
     * 
38
     * @param adapterType the required interface
40
     * @param adapterType the required interface
39
     * @return an instance of the required interface that adapts me, or
41
     * @return an instance of the required interface that adapts me, or
40
     *    <code>null</code> if I do not supply this interface
42
     *    <code>null</code> if I do not supply this interface
41
     */
43
     */
42
    Object getAdapter(Class adapterType);
44
    <T> T getAdapter(Class<? extends T> adapterType);
43
}
45
}
(-)src/org/eclipse/emf/transaction/util/CompositeChangeDescription.java (-26 / +43 lines)
Lines 25-31 Link Here
25
import org.eclipse.emf.common.util.BasicEMap;
25
import org.eclipse.emf.common.util.BasicEMap;
26
import org.eclipse.emf.common.util.EList;
26
import org.eclipse.emf.common.util.EList;
27
import org.eclipse.emf.common.util.EMap;
27
import org.eclipse.emf.common.util.EMap;
28
import org.eclipse.emf.ecore.EObject;
28
import org.eclipse.emf.ecore.change.ChangeDescription;
29
import org.eclipse.emf.ecore.change.ChangeDescription;
30
import org.eclipse.emf.ecore.change.FeatureChange;
31
import org.eclipse.emf.ecore.change.ResourceChange;
29
import org.eclipse.emf.ecore.change.impl.ChangeDescriptionImpl;
32
import org.eclipse.emf.ecore.change.impl.ChangeDescriptionImpl;
30
import org.eclipse.emf.transaction.TransactionChangeDescription;
33
import org.eclipse.emf.transaction.TransactionChangeDescription;
31
34
Lines 43-49 Link Here
43
	extends ChangeDescriptionImpl
46
	extends ChangeDescriptionImpl
44
	implements TransactionChangeDescription {
47
	implements TransactionChangeDescription {
45
48
46
	private final List changes = new java.util.ArrayList();
49
	private final List<ChangeDescription> changes =
50
		new java.util.ArrayList<ChangeDescription>();
47
	
51
	
48
	/**
52
	/**
49
	 * Queries whether I have no composed change descriptions.
53
	 * Queries whether I have no composed change descriptions.
Lines 66-73 Link Here
66
     * Disposes my children, recursively.
70
     * Disposes my children, recursively.
67
     */
71
     */
68
    void dispose() {
72
    void dispose() {
69
        for (Iterator iter = changes.iterator(); iter.hasNext();) {
73
        for (ChangeDescription next : changes) {
70
            TransactionUtil.dispose((ChangeDescription) iter.next());
74
            TransactionUtil.dispose(next);
71
        }
75
        }
72
    }
76
    }
73
	
77
	
Lines 77-83 Link Here
77
	public boolean canApply() {
81
	public boolean canApply() {
78
		boolean result = true;
82
		boolean result = true;
79
		
83
		
80
		for (Iterator iter = changes.iterator(); result && iter.hasNext();) {
84
		for (Iterator<ChangeDescription> iter = changes.iterator();
85
				result && iter.hasNext();) {
86
			
81
			Object next = iter.next();
87
			Object next = iter.next();
82
			
88
			
83
			if (next instanceof TransactionChangeDescription) {
89
			if (next instanceof TransactionChangeDescription) {
Lines 89-108 Link Here
89
	}
95
	}
90
	
96
	
91
	// Documentation copied from the inherited method
97
	// Documentation copied from the inherited method
98
	@Override
92
	public void apply() {
99
	public void apply() {
93
		// must apply changes in the reverse order that they were added
100
		// must apply changes in the reverse order that they were added
94
		for (ListIterator iter = changes.listIterator(changes.size()); iter.hasPrevious();) {
101
		for (ListIterator<ChangeDescription> iter = changes.listIterator(changes.size());
95
			((ChangeDescription) iter.previous()).apply();
102
				iter.hasPrevious();) {
103
			
104
			iter.previous().apply();
96
		}
105
		}
97
		
106
		
98
		changes.clear();
107
		changes.clear();
99
	}
108
	}
100
109
101
	// Documentation copied from the inherited method
110
	// Documentation copied from the inherited method
111
	@Override
102
	public void applyAndReverse() {
112
	public void applyAndReverse() {
103
		// must apply changes in the reverse order that they were added
113
		// must apply changes in the reverse order that they were added
104
		for (ListIterator iter = changes.listIterator(changes.size()); iter.hasPrevious();) {
114
		for (ListIterator<ChangeDescription> iter = changes.listIterator(changes.size());
105
			((ChangeDescription) iter.previous()).applyAndReverse();
115
				iter.hasPrevious();) {
116
			
117
			iter.previous().applyAndReverse();
106
		}
118
		}
107
		
119
		
108
		// invert the order of the changes for next apply-and-reverse
120
		// invert the order of the changes for next apply-and-reverse
Lines 120-127 Link Here
120
			if (change instanceof CompositeChangeDescription) {
132
			if (change instanceof CompositeChangeDescription) {
121
				CompositeChangeDescription other = ((CompositeChangeDescription) change);
133
				CompositeChangeDescription other = ((CompositeChangeDescription) change);
122
				
134
				
123
				for (Iterator iter = other.changes.iterator(); iter.hasNext();) {
135
				for (ChangeDescription next : other.changes) {
124
					add((ChangeDescription) iter.next());
136
					add(next);
125
				}
137
				}
126
			} else {
138
			} else {
127
				changes.add(change);
139
				changes.add(change);
Lines 177-188 Link Here
177
	 * My object changes are the concatenation of the changes in my composed
189
	 * My object changes are the concatenation of the changes in my composed
178
	 * descriptions.
190
	 * descriptions.
179
	 */
191
	 */
180
	public EMap getObjectChanges() {
192
	@Override
193
	public EMap<EObject, EList<FeatureChange>> getObjectChanges() {
181
		if (objectChanges == null) {
194
		if (objectChanges == null) {
182
			objectChanges = new BasicEMap();
195
			objectChanges = new BasicEMap<EObject, EList<FeatureChange>>();
183
			
196
			
184
			for (Iterator iter = changes.iterator(); iter.hasNext();) {
197
			for (ChangeDescription next : changes) {
185
				objectChanges.addAll(((ChangeDescription) iter.next()).getObjectChanges());
198
				objectChanges.addAll(next.getObjectChanges());
186
			}
199
			}
187
		}
200
		}
188
		
201
		
Lines 193-204 Link Here
193
	 * My objects to attach are the concatenation of the changes in my composed
206
	 * My objects to attach are the concatenation of the changes in my composed
194
	 * descriptions.
207
	 * descriptions.
195
	 */
208
	 */
196
	public EList getObjectsToDetach() {
209
	@Override
210
	public EList<EObject> getObjectsToDetach() {
197
		if (objectsToDetach == null) {
211
		if (objectsToDetach == null) {
198
			objectsToDetach = new BasicEList();
212
			objectsToDetach = new BasicEList<EObject>();
199
			
213
			
200
			for (Iterator iter = changes.iterator(); iter.hasNext();) {
214
			for (ChangeDescription next : changes) {
201
				objectsToDetach.addAll(((ChangeDescription) iter.next()).getObjectsToDetach());
215
				objectsToDetach.addAll(next.getObjectsToDetach());
202
			}
216
			}
203
		}
217
		}
204
		
218
		
Lines 209-220 Link Here
209
	 * My objects to detach are the concatenation of the changes in my composed
223
	 * My objects to detach are the concatenation of the changes in my composed
210
	 * descriptions.
224
	 * descriptions.
211
	 */
225
	 */
212
	public EList getObjectsToAttach() {
226
	@Override
227
	public EList<EObject> getObjectsToAttach() {
213
		if (objectsToAttach == null) {
228
		if (objectsToAttach == null) {
214
			objectsToAttach = new BasicEList();
229
			objectsToAttach = new BasicEList<EObject>();
215
			
230
			
216
			for (Iterator iter = changes.iterator(); iter.hasNext();) {
231
			for (ChangeDescription next : changes) {
217
				objectsToAttach.addAll(((ChangeDescription) iter.next()).getObjectsToAttach());
232
				objectsToAttach.addAll(next.getObjectsToAttach());
218
			}
233
			}
219
		}
234
		}
220
		
235
		
Lines 225-242 Link Here
225
	 * My resource changes are the concatenation of the changes in my composed
240
	 * My resource changes are the concatenation of the changes in my composed
226
	 * descriptions.
241
	 * descriptions.
227
	 */
242
	 */
228
	public EList getResourceChanges() {
243
	@Override
244
	public EList<ResourceChange> getResourceChanges() {
229
		if (resourceChanges == null) {
245
		if (resourceChanges == null) {
230
			resourceChanges = new BasicEList();
246
			resourceChanges = new BasicEList<ResourceChange>();
231
			
247
			
232
			for (Iterator iter = changes.iterator(); iter.hasNext();) {
248
			for (ChangeDescription next : changes) {
233
				resourceChanges.addAll(((ChangeDescription) iter.next()).getResourceChanges());
249
				resourceChanges.addAll(next.getResourceChanges());
234
			}
250
			}
235
		}
251
		}
236
		
252
		
237
		return resourceChanges;
253
		return resourceChanges;
238
	}
254
	}
239
	
255
	
256
	@Override
240
	public String toString() {
257
	public String toString() {
241
		StringBuffer result = new StringBuffer("CompositeChangeDescription["); //$NON-NLS-1$
258
		StringBuffer result = new StringBuffer("CompositeChangeDescription["); //$NON-NLS-1$
242
		result.append(getObjectChanges().size()).append(", "); //$NON-NLS-1$
259
		result.append(getObjectChanges().size()).append(", "); //$NON-NLS-1$
(-)src/org/eclipse/emf/transaction/util/TransactionUtil.java (-13 / +73 lines)
Lines 28-33 Link Here
28
import org.eclipse.emf.ecore.util.EcoreUtil;
28
import org.eclipse.emf.ecore.util.EcoreUtil;
29
import org.eclipse.emf.edit.domain.EditingDomain;
29
import org.eclipse.emf.edit.domain.EditingDomain;
30
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
30
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
31
import org.eclipse.emf.transaction.RunnableWithResult;
31
import org.eclipse.emf.transaction.Transaction;
32
import org.eclipse.emf.transaction.Transaction;
32
import org.eclipse.emf.transaction.TransactionalEditingDomain;
33
import org.eclipse.emf.transaction.TransactionalEditingDomain;
33
import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
34
import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
Lines 205-211 Link Here
205
	 * @param notifier the notifier to disconnect
206
	 * @param notifier the notifier to disconnect
206
	 */
207
	 */
207
	private static void disconnectFromEditingDomain0(Notifier notifier) {
208
	private static void disconnectFromEditingDomain0(Notifier notifier) {
208
		Set recorders = getExistingChangeRecorders(notifier);
209
		Set<TransactionChangeRecorder> recorders = getExistingChangeRecorders(notifier);
209
		
210
		
210
		if (!recorders.isEmpty()) {
211
		if (!recorders.isEmpty()) {
211
			// this resource is managed by a transactional editing domain
212
			// this resource is managed by a transactional editing domain
Lines 216-222 Link Here
216
				throw new IllegalArgumentException("resource is still in the domain's resource set"); //$NON-NLS-1$
217
				throw new IllegalArgumentException("resource is still in the domain's resource set"); //$NON-NLS-1$
217
			}
218
			}
218
			
219
			
219
			Iterator iter = EcoreUtil.getAllProperContents(Collections.singleton(
220
			Iterator<?> iter = EcoreUtil.getAllProperContents(Collections.singleton(
220
					notifier), false);
221
					notifier), false);
221
			while (iter.hasNext()) {
222
			while (iter.hasNext()) {
222
				((Notifier) iter.next()).eAdapters().removeAll(recorders);
223
				((Notifier) iter.next()).eAdapters().removeAll(recorders);
Lines 231-247 Link Here
231
	 * @return the currently attached change recorders, which may be an empty
232
	 * @return the currently attached change recorders, which may be an empty
232
	 *    set if none
233
	 *    set if none
233
	 */
234
	 */
234
	private static Set getExistingChangeRecorders(Notifier notifier) {
235
	private static Set<TransactionChangeRecorder> getExistingChangeRecorders(
235
		Set result = null;
236
			Notifier notifier) {
237
		
238
		Set<TransactionChangeRecorder> result = null;
236
		
239
		
237
		Object[] adapters = notifier.eAdapters().toArray();
240
		Object[] adapters = notifier.eAdapters().toArray();
238
		for (int i = 0; i < adapters.length; i++) {
241
		for (Object element : adapters) {
239
			if (adapters[i] instanceof TransactionChangeRecorder) {
242
			if (element instanceof TransactionChangeRecorder) {
240
				TransactionChangeRecorder next = (TransactionChangeRecorder) adapters[i];
243
				TransactionChangeRecorder next = (TransactionChangeRecorder) element;
241
				
244
				
242
				if (next.getEditingDomain() != null) {
245
				if (next.getEditingDomain() != null) {
243
					if (result == null) {
246
					if (result == null) {
244
						result = new java.util.HashSet();
247
						result = new java.util.HashSet<TransactionChangeRecorder>();
245
					}
248
					}
246
					
249
					
247
					result.add(next);
250
					result.add(next);
Lines 249-255 Link Here
249
			}
252
			}
250
		}
253
		}
251
		
254
		
252
		return (result == null)? Collections.EMPTY_SET : result;
255
		return (result == null)? Collections.<TransactionChangeRecorder>emptySet()
256
			: result;
253
	}
257
	}
254
    
258
    
255
    /**
259
    /**
Lines 266-273 Link Here
266
        } else if (change instanceof CommandChangeDescription) {
270
        } else if (change instanceof CommandChangeDescription) {
267
            ((CommandChangeDescription) change).dispose();
271
            ((CommandChangeDescription) change).dispose();
268
        } else {
272
        } else {
269
            for (Iterator iter = change.eAllContents(); iter.hasNext();) {
273
            for (Iterator<EObject> iter = change.eAllContents(); iter.hasNext();) {
270
                ((EObject) iter.next()).eAdapters().clear();
274
                iter.next().eAdapters().clear();
271
            }
275
            }
272
        }
276
        }
273
    }
277
    }
Lines 275-288 Link Here
275
    /**
279
    /**
276
     * Obtains an instance of the specified adapter type for an editing domain.
280
     * Obtains an instance of the specified adapter type for an editing domain.
277
     * 
281
     * 
282
     * @param <T> the adapter interface that is required
283
     * 
278
     * @param domain an editing domain to adapt
284
     * @param domain an editing domain to adapt
279
     * @param adapterType the required interface
285
     * @param adapterType the required interface
280
     * 
286
     * 
281
     * @return an instance of the required interface that adapts the
287
     * @return an instance of the required interface that adapts the
282
     *    <tt>domain</tt>, or <code>null</code> if it does not supply this interface
288
     *    <tt>domain</tt>, or <code>null</code> if it does not supply this interface
289
     * 
290
     * @since 1.2
283
     */
291
     */
284
    public static Object getAdapter(TransactionalEditingDomain domain, Class adapterType) {
292
    public static <T> T getAdapter(TransactionalEditingDomain domain,
285
        Object result;
293
    		Class<? extends T> adapterType) {
294
        T result;
286
        
295
        
287
        if (domain instanceof Adaptable) {
296
        if (domain instanceof Adaptable) {
288
            result = ((Adaptable) domain).getAdapter(adapterType);
297
            result = ((Adaptable) domain).getAdapter(adapterType);
Lines 292-295 Link Here
292
        
301
        
293
        return result;
302
        return result;
294
    }
303
    }
304
    
305
    /**
306
     * Utility method for executing exclusive runnables that
307
     * {@linkplain RunnableWithResult return values}.  The advantage of this
308
     * method over {@link TransactionalEditingDomain#runExclusive(Runnable)} is
309
     * that it provides compile-time type safety.
310
     * 
311
     * @param <T> the result type of the runnable
312
     * 
313
     * @param domain the editing domain in which to run
314
     * @param runnable the runnable to execute
315
     * 
316
     * @return the result of the runnable
317
     * 
318
     * @throws InterruptedException if the current thread is interrupted while
319
	 *    waiting for access to the resource set
320
     * 
321
     * @since 1.2
322
     */
323
    @SuppressWarnings("unchecked")
324
	public static <T> T runExclusive(TransactionalEditingDomain domain,
325
    		RunnableWithResult<? extends T> runnable) throws InterruptedException {
326
    	
327
    	return (T) domain.runExclusive(runnable);
328
    }
329
    
330
    /**
331
     * Utility method for providing privileged access to runnables that
332
     * {@linkplain RunnableWithResult return values}.  The advantage of this
333
     * method over {@link TransactionalEditingDomain#createPrivilegedRunnable(Runnable)} is
334
     * that it provides compile-time type safety.
335
     * 
336
     * @param <T> the result type of the runnable
337
     * 
338
     * @param domain the editing domain in which to grant privileged access
339
     * @param runnable the runnable to execute
340
     * 
341
     * @return the result of the runnable
342
     * 
343
     * @throws InterruptedException if the current thread is interrupted while
344
	 *    waiting for access to the resource set
345
     * 
346
     * @since 1.2
347
     */
348
    @SuppressWarnings("unchecked")
349
	public static <T> RunnableWithResult<T> createPrivilegedRunnable(
350
			TransactionalEditingDomain domain,
351
    		RunnableWithResult<? extends T> runnable) throws InterruptedException {
352
    	
353
    	return (RunnableWithResult<T>) domain.createPrivilegedRunnable(runnable);
354
    }
295
}
355
}
(-)src/org/eclipse/emf/transaction/util/ValidateEditSupport.java (-9 / +9 lines)
Lines 114-120 Link Here
114
     * @since 1.2
114
     * @since 1.2
115
     */
115
     */
116
    class Default implements ValidateEditSupport {
116
    class Default implements ValidateEditSupport {
117
        private final Set resourcesToValidate = new java.util.HashSet();
117
        private final Set<Resource> resourcesToValidate = new java.util.HashSet<Resource>();
118
        
118
        
119
        /**
119
        /**
120
         * Initializes me.
120
         * Initializes me.
Lines 130-136 Link Here
130
         * 
130
         * 
131
         * @return the resources to validate-edit
131
         * @return the resources to validate-edit
132
         */
132
         */
133
        protected final Set getResourcesToValidate() {
133
        protected final Set<Resource> getResourcesToValidate() {
134
            return resourcesToValidate;
134
            return resourcesToValidate;
135
        }
135
        }
136
        
136
        
Lines 157-171 Link Here
157
         * @return the result of the validate-edit attempt
157
         * @return the result of the validate-edit attempt
158
         */
158
         */
159
        protected IStatus doValidateEdit(Transaction transaction,
159
        protected IStatus doValidateEdit(Transaction transaction,
160
                Collection resources, Object context) {
160
                Collection<? extends Resource> resources, Object context) {
161
            IStatus result = Status.OK_STATUS;
161
            IStatus result = Status.OK_STATUS;
162
162
163
            EditingDomain domain = transaction.getEditingDomain();
163
            EditingDomain domain = transaction.getEditingDomain();
164
164
165
            for (Iterator iter = resources.iterator(); result.isOK()
165
            for (Iterator<? extends Resource> iter = resources.iterator(); result.isOK()
166
                    && iter.hasNext();) {
166
                    && iter.hasNext();) {
167
                
167
                
168
                Resource next = (Resource) iter.next();
168
                Resource next = iter.next();
169
169
170
                if (domain.isReadOnly(next)) {
170
                if (domain.isReadOnly(next)) {
171
                    result = new Status(IStatus.ERROR, EMFTransactionPlugin
171
                    result = new Status(IStatus.ERROR, EMFTransactionPlugin
Lines 187-198 Link Here
187
            if (!resourcesToValidate.isEmpty()) {
187
            if (!resourcesToValidate.isEmpty()) {
188
                // protect against concurrent modifications: setting modified
188
                // protect against concurrent modifications: setting modified
189
                //   state to false will trigger removal from the collection
189
                //   state to false will trigger removal from the collection
190
                Resource[] resources = (Resource[]) resourcesToValidate
190
                Resource[] resources = resourcesToValidate.toArray(
191
                    .toArray(new Resource[resourcesToValidate.size()]);
191
                	new Resource[resourcesToValidate.size()]);
192
                
192
                
193
                for (int i = 0; i < resources.length; i++) {
193
                for (Resource element : resources) {
194
                    // note that this is exempt from the transaction protocol
194
                    // note that this is exempt from the transaction protocol
195
                    resources[i].setModified(false);
195
                    element.setModified(false);
196
                    
196
                    
197
                    // setting modified to false should have removed them 
197
                    // setting modified to false should have removed them 
198
                    // already, but just in case ...
198
                    // already, but just in case ...
(-)src/org/eclipse/emf/transaction/internal/EMFTransactionPlugin.java (+3 lines)
Lines 39-44 Link Here
39
	}
39
	}
40
40
41
	// implements the inherited method
41
	// implements the inherited method
42
	@Override
42
	public ResourceLocator getPluginResourceLocator() {
43
	public ResourceLocator getPluginResourceLocator() {
43
		return plugin;
44
		return plugin;
44
	}
45
	}
Lines 81-86 Link Here
81
		/**
82
		/**
82
		 * This method is called upon plug-in activation
83
		 * This method is called upon plug-in activation
83
		 */
84
		 */
85
		@Override
84
		public void start(BundleContext context) throws Exception {
86
		public void start(BundleContext context) throws Exception {
85
			super.start(context);
87
			super.start(context);
86
		}
88
		}
Lines 88-93 Link Here
88
		/**
90
		/**
89
		 * This method is called when the plug-in is stopped
91
		 * This method is called when the plug-in is stopped
90
		 */
92
		 */
93
		@Override
91
		public void stop(BundleContext context) throws Exception {
94
		public void stop(BundleContext context) throws Exception {
92
			super.stop(context);
95
			super.stop(context);
93
			EMFTransactionPlugin.plugin = null;
96
			EMFTransactionPlugin.plugin = null;
(-)src/org/eclipse/emf/transaction/internal/Tracing.java (-60 / +12 lines)
Lines 109-115 Link Here
109
	/**
109
	/**
110
	 * The cached debug options (for optimization).
110
	 * The cached debug options (for optimization).
111
	 */
111
	 */
112
	private static final Map cachedOptions = new HashMap();
112
	private static final Map<String, Boolean> cachedOptions =
113
		new HashMap<String, Boolean>();
113
114
114
	/**
115
	/**
115
	 * Retrieves a Boolean value indicating whether tracing is enabled.
116
	 * Retrieves a Boolean value indicating whether tracing is enabled.
Lines 137-149 Link Here
137
			Boolean value = null;
138
			Boolean value = null;
138
			
139
			
139
			synchronized (cachedOptions) {
140
			synchronized (cachedOptions) {
140
				value = (Boolean) cachedOptions.get(option);
141
				value = cachedOptions.get(option);
141
	
142
	
142
				if (null == value) {
143
				if (null == value) {
143
					value =
144
					value =
144
						new Boolean(
145
						Boolean.TRUE.toString().equalsIgnoreCase(
145
							Boolean.TRUE.toString().equalsIgnoreCase(
146
								org.eclipse.core.runtime.Platform.getDebugOption(option));
146
								org.eclipse.core.runtime.Platform.getDebugOption(option)));
147
	
147
	
148
					cachedOptions.put(option, value);
148
					cachedOptions.put(option, value);
149
				}
149
				}
Lines 254-260 Link Here
254
	 */
254
	 */
255
	public static void changing(
255
	public static void changing(
256
        String option,
256
        String option,
257
        Class clazz,
257
        Class<?> clazz,
258
        String methodName,
258
        String methodName,
259
        String valueDescription,
259
        String valueDescription,
260
        Object oldValue,
260
        Object oldValue,
Lines 291-297 Link Here
291
	 * 
291
	 * 
292
	 */
292
	 */
293
	public static void catching(
293
	public static void catching(
294
		Class clazz,
294
		Class<?> clazz,
295
		String methodName,
295
		String methodName,
296
		Throwable throwable) {
296
		Throwable throwable) {
297
297
Lines 322-328 Link Here
322
	 * 
322
	 * 
323
	 */
323
	 */
324
	public static void throwing(
324
	public static void throwing(
325
		Class clazz,
325
		Class<?> clazz,
326
		String methodName,
326
		String methodName,
327
		Throwable throwable) {
327
		Throwable throwable) {
328
328
Lines 343-396 Link Here
343
	}
343
	}
344
344
345
	/**
345
	/**
346
	 * Traces the entering into the specified method of the specified class.
347
	 * 
348
	 * @param clazz The class whose method is being entered.
349
	 * @param methodName The name of method that is being entered.
350
	 * 
351
	 */
352
	public static void entering(
353
		Class clazz,
354
		String methodName) {
355
356
		if (shouldTrace(EMFTransactionDebugOptions.METHODS_ENTERING)) {
357
358
			trace(
359
				PREFIX_ENTERING
360
					+ clazz.getName()
361
					+ SEPARATOR_METHOD
362
					+ methodName);
363
		}
364
	}
365
366
	/**
367
	 * Traces the entering into the specified method of the specified class,
368
	 * with the specified parameter.
369
	 * 
370
	 * @param clazz The class whose method is being entered.
371
	 * @param methodName The name of method that is being entered.
372
	 * @param parameter The parameter to the method being entered.
373
	 * 
374
	 */
375
	public static void entering(
376
		Class clazz,
377
		String methodName,
378
		Object parameter) {
379
380
		if (shouldTrace(EMFTransactionDebugOptions.METHODS_ENTERING)) {
381
382
			trace(
383
				PREFIX_ENTERING
384
					+ clazz.getName()
385
					+ SEPARATOR_METHOD
386
					+ methodName
387
					+ PARENTHESIS_OPEN
388
					+ getArgumentString(parameter)
389
					+ PARENTHESIS_CLOSE);
390
		}
391
	}
392
393
	/**
394
	 * Traces the entering into the specified method of the specified class,
346
	 * Traces the entering into the specified method of the specified class,
395
	 * with the specified parameters.
347
	 * with the specified parameters.
396
	 * 
348
	 * 
Lines 400-408 Link Here
400
	 * 
352
	 * 
401
	 */
353
	 */
402
	public static void entering(
354
	public static void entering(
403
		Class clazz,
355
		Class<?> clazz,
404
		String methodName,
356
		String methodName,
405
		Object[] parameters) {
357
		Object... parameters) {
406
358
407
		if (shouldTrace(EMFTransactionDebugOptions.METHODS_ENTERING)) {
359
		if (shouldTrace(EMFTransactionDebugOptions.METHODS_ENTERING)) {
408
360
Lines 425-431 Link Here
425
	 * 
377
	 * 
426
	 */
378
	 */
427
	public static void exiting(
379
	public static void exiting(
428
		Class clazz,
380
		Class<?> clazz,
429
		String methodName) {
381
		String methodName) {
430
382
431
		if (shouldTrace(EMFTransactionDebugOptions.METHODS_EXITING)) {
383
		if (shouldTrace(EMFTransactionDebugOptions.METHODS_EXITING)) {
Lines 448-454 Link Here
448
	 * 
400
	 * 
449
	 */
401
	 */
450
	public static void exiting(
402
	public static void exiting(
451
		Class clazz,
403
		Class<?> clazz,
452
		String methodName,
404
		String methodName,
453
		Object returnValue) {
405
		Object returnValue) {
454
406
(-)META-INF/MANIFEST.MF (-4 / +4 lines)
Lines 7-19 Link Here
7
Bundle-Vendor: %Plugin.providerName
7
Bundle-Vendor: %Plugin.providerName
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
9
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)";visibility:=reexport,
9
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)";visibility:=reexport,
10
 org.eclipse.emf.edit;bundle-version="[2.2.0,3.0.0)";visibility:=reexport,
10
 org.eclipse.emf.edit;bundle-version="[2.3.0,3.0.0)";visibility:=reexport,
11
 org.eclipse.emf.ecore.change;bundle-version="[2.2.0,3.0.0)";visibility:=reexport,
11
 org.eclipse.emf.ecore.change;bundle-version="[2.3.0,3.0.0)";visibility:=reexport,
12
 org.eclipse.emf.validation;bundle-version="[1.0.0,2.0.0)";visibility:=reexport
12
 org.eclipse.emf.validation;bundle-version="[1.2.0,2.0.0)";visibility:=reexport
13
Eclipse-LazyStart: true
13
Eclipse-LazyStart: true
14
Export-Package: org.eclipse.emf.transaction,
14
Export-Package: org.eclipse.emf.transaction,
15
 org.eclipse.emf.transaction.impl,
15
 org.eclipse.emf.transaction.impl,
16
 org.eclipse.emf.transaction.internal;x-friends:="org.eclipse.emf.transaction.tests",
16
 org.eclipse.emf.transaction.internal;x-friends:="org.eclipse.emf.transaction.tests",
17
 org.eclipse.emf.transaction.internal.l10n;x-friends:="org.eclipse.emf.transaction.tests",
17
 org.eclipse.emf.transaction.internal.l10n;x-friends:="org.eclipse.emf.transaction.tests",
18
 org.eclipse.emf.transaction.util
18
 org.eclipse.emf.transaction.util
19
Bundle-RequiredExecutionEnvironment: J2SE-1.4
19
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)build.properties (-2 / +2 lines)
Lines 24-28 Link Here
24
               plugin.properties,\
24
               plugin.properties,\
25
               .options
25
               .options
26
src.includes = about.html
26
src.includes = about.html
27
javacSource = 1.4
27
javacSource = 1.5
28
javacTarget = 1.4
28
javacTarget = 1.5
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:57:53 EST 2006
1
#Sun Nov 11 09:25:14 EST 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-).classpath (-1 / +1 lines)
Lines 1-6 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="output" path="bin"/>
5
	<classpathentry kind="output" path="bin"/>
6
</classpath>
6
</classpath>
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 7-10 Link Here
7
Bundle-Localization: plugin
7
Bundle-Localization: plugin
8
Require-Bundle: org.eclipse.help;bundle-version="[3.2.0,4.0.0)"
8
Require-Bundle: org.eclipse.help;bundle-version="[3.2.0,4.0.0)"
9
Eclipse-LazyStart: true
9
Eclipse-LazyStart: true
10
Bundle-RequiredExecutionEnvironment: J2SE-1.4
10
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:52:13 EST 2006
1
#Sun Nov 11 17:03:45 EST 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 6-9 Link Here
6
Bundle-Vendor: %Plugin.providerName
6
Bundle-Vendor: %Plugin.providerName
7
Bundle-Localization: plugin
7
Bundle-Localization: plugin
8
Eclipse-LazyStart: true
8
Eclipse-LazyStart: true
9
Bundle-RequiredExecutionEnvironment: J2SE-1.4
9
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)build.properties (-2 / +2 lines)
Lines 20-24 Link Here
20
               META-INF/,\
20
               META-INF/,\
21
               modeling32.png
21
               modeling32.png
22
src.includes = about.html
22
src.includes = about.html
23
javacSource = 1.4
23
javacSource = 1.5
24
javacTarget = 1.4
24
javacTarget = 1.5
(-)src/org/eclipse/emf/workspace/ui/actions/UndoActionWrapper.java (-4 / +18 lines)
Lines 22-28 Link Here
22
import org.eclipse.swt.widgets.Event;
22
import org.eclipse.swt.widgets.Event;
23
import org.eclipse.ui.IWorkbenchPart;
23
import org.eclipse.ui.IWorkbenchPart;
24
import org.eclipse.ui.IWorkbenchPartSite;
24
import org.eclipse.ui.IWorkbenchPartSite;
25
import org.eclipse.ui.operations.OperationHistoryActionHandler;
26
import org.eclipse.ui.operations.UndoActionHandler;
25
import org.eclipse.ui.operations.UndoActionHandler;
27
26
28
/**
27
/**
Lines 32-51 Link Here
32
 * @author Christian W. Damus (cdamus)
31
 * @author Christian W. Damus (cdamus)
33
 */
32
 */
34
public class UndoActionWrapper extends UndoAction {
33
public class UndoActionWrapper extends UndoAction {
35
	private final ActionWrapperHelper delegate;
34
	private final ActionWrapperHelper<UndoActionHandler> delegate;
36
	
35
	
37
	/**
36
	/**
38
	 * Initializes me.
37
	 * Initializes me.
39
	 */
38
	 */
40
	public UndoActionWrapper() {
39
	public UndoActionWrapper() {
41
		delegate = new ActionWrapperHelper(new ActionWrapperHelper.OwnerAccess() {
40
		delegate = new ActionWrapperHelper<UndoActionHandler>(
41
				new ActionWrapperHelper.OwnerAccess<UndoActionHandler>() {
42
		
42
		
43
			public void firePropertyChange(String property, Object oldValue,
43
			public void firePropertyChange(String property, Object oldValue,
44
					Object newValue) {
44
					Object newValue) {
45
				firePropertyChange0(property, oldValue, newValue);
45
				firePropertyChange0(property, oldValue, newValue);
46
			}
46
			}
47
		
47
		
48
			public OperationHistoryActionHandler createDelegate(
48
			public UndoActionHandler createDelegate(
49
					IWorkbenchPartSite site, IUndoContext context) {
49
					IWorkbenchPartSite site, IUndoContext context) {
50
				return new UndoActionHandler(site, context);
50
				return new UndoActionHandler(site, context);
51
			}});
51
			}});
Lines 60-65 Link Here
60
	 * Extends the superclass implementation to update the operation history
60
	 * Extends the superclass implementation to update the operation history
61
	 * undo action handler to which I delegate.
61
	 * undo action handler to which I delegate.
62
	 */
62
	 */
63
	@Override
63
	public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart) {
64
	public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart) {
64
		super.setActiveWorkbenchPart(workbenchPart);
65
		super.setActiveWorkbenchPart(workbenchPart);
65
		delegate.setActiveWorkbenchPart(workbenchPart);
66
		delegate.setActiveWorkbenchPart(workbenchPart);
Lines 68-73 Link Here
68
	/**
69
	/**
69
	 * Delegates to the operation framework action handler.
70
	 * Delegates to the operation framework action handler.
70
	 */
71
	 */
72
	@Override
71
	public void update() {
73
	public void update() {
72
		if (delegate != null) {
74
		if (delegate != null) {
73
			delegate.update();
75
			delegate.update();
Lines 77-82 Link Here
77
	/**
79
	/**
78
	 * Delegates to the operation framework action handler.
80
	 * Delegates to the operation framework action handler.
79
	 */
81
	 */
82
	@Override
80
	public String getDescription() {
83
	public String getDescription() {
81
		if (delegate != null) {
84
		if (delegate != null) {
82
			return delegate.getDescription();
85
			return delegate.getDescription();
Lines 88-93 Link Here
88
	/**
91
	/**
89
	 * Delegates to the operation framework action handler.
92
	 * Delegates to the operation framework action handler.
90
	 */
93
	 */
94
	@Override
91
	public String getText() {
95
	public String getText() {
92
		if (delegate != null) {
96
		if (delegate != null) {
93
			return delegate.getText();
97
			return delegate.getText();
Lines 99-104 Link Here
99
	/**
103
	/**
100
	 * Delegates to the operation framework action handler.
104
	 * Delegates to the operation framework action handler.
101
	 */
105
	 */
106
	@Override
102
	public String getToolTipText() {
107
	public String getToolTipText() {
103
		if (delegate != null) {
108
		if (delegate != null) {
104
			return delegate.getToolTipText();
109
			return delegate.getToolTipText();
Lines 110-115 Link Here
110
	/**
115
	/**
111
	 * Delegates to the operation framework action handler.
116
	 * Delegates to the operation framework action handler.
112
	 */
117
	 */
118
	@Override
113
	public boolean isEnabled() {
119
	public boolean isEnabled() {
114
		if (delegate != null) {
120
		if (delegate != null) {
115
			return delegate.isEnabled();
121
			return delegate.isEnabled();
Lines 121-126 Link Here
121
	/**
127
	/**
122
	 * Delegates to the operation framework action handler.
128
	 * Delegates to the operation framework action handler.
123
	 */
129
	 */
130
	@Override
124
	public boolean isHandled() {
131
	public boolean isHandled() {
125
		if (delegate != null) {
132
		if (delegate != null) {
126
			return delegate.isHandled();
133
			return delegate.isHandled();
Lines 132-137 Link Here
132
	/**
139
	/**
133
	 * Delegates to the operation framework action handler.
140
	 * Delegates to the operation framework action handler.
134
	 */
141
	 */
142
	@Override
135
	public void run() {
143
	public void run() {
136
		if (delegate != null) {
144
		if (delegate != null) {
137
			delegate.run();
145
			delegate.run();
Lines 141-146 Link Here
141
	/**
149
	/**
142
	 * Delegates to the operation framework action handler.
150
	 * Delegates to the operation framework action handler.
143
	 */
151
	 */
152
	@Override
144
	public void runWithEvent(Event event) {
153
	public void runWithEvent(Event event) {
145
		if (delegate != null) {
154
		if (delegate != null) {
146
			delegate.runWithEvent(event);
155
			delegate.runWithEvent(event);
Lines 150-155 Link Here
150
	/**
159
	/**
151
	 * Delegates to the operation framework action handler.
160
	 * Delegates to the operation framework action handler.
152
	 */
161
	 */
162
	@Override
153
	public void setChecked(boolean checked) {
163
	public void setChecked(boolean checked) {
154
		if (delegate != null) {
164
		if (delegate != null) {
155
			delegate.setChecked(checked);
165
			delegate.setChecked(checked);
Lines 159-164 Link Here
159
	/**
169
	/**
160
	 * Delegates to the operation framework action handler.
170
	 * Delegates to the operation framework action handler.
161
	 */
171
	 */
172
	@Override
162
	public void setDescription(String text) {
173
	public void setDescription(String text) {
163
		if (delegate != null) {
174
		if (delegate != null) {
164
			delegate.setDescription(text);
175
			delegate.setDescription(text);
Lines 168-173 Link Here
168
	/**
179
	/**
169
	 * Delegates to the operation framework action handler.
180
	 * Delegates to the operation framework action handler.
170
	 */
181
	 */
182
	@Override
171
	public void setEnabled(boolean enabled) {
183
	public void setEnabled(boolean enabled) {
172
		if (delegate != null) {
184
		if (delegate != null) {
173
			delegate.setEnabled(enabled);
185
			delegate.setEnabled(enabled);
Lines 177-182 Link Here
177
	/**
189
	/**
178
	 * Delegates to the operation framework action handler.
190
	 * Delegates to the operation framework action handler.
179
	 */
191
	 */
192
	@Override
180
	public void setText(String text) {
193
	public void setText(String text) {
181
		if (delegate != null) {
194
		if (delegate != null) {
182
			delegate.setText(text);
195
			delegate.setText(text);
Lines 186-191 Link Here
186
	/**
199
	/**
187
	 * Delegates to the operation framework action handler.
200
	 * Delegates to the operation framework action handler.
188
	 */
201
	 */
202
	@Override
189
	public void setToolTipText(String toolTipText) {
203
	public void setToolTipText(String toolTipText) {
190
		if (delegate != null) {
204
		if (delegate != null) {
191
			delegate.setToolTipText(toolTipText);
205
			delegate.setToolTipText(toolTipText);
(-)src/org/eclipse/emf/workspace/ui/actions/RedoActionWrapper.java (-4 / +18 lines)
Lines 22-28 Link Here
22
import org.eclipse.swt.widgets.Event;
22
import org.eclipse.swt.widgets.Event;
23
import org.eclipse.ui.IWorkbenchPart;
23
import org.eclipse.ui.IWorkbenchPart;
24
import org.eclipse.ui.IWorkbenchPartSite;
24
import org.eclipse.ui.IWorkbenchPartSite;
25
import org.eclipse.ui.operations.OperationHistoryActionHandler;
26
import org.eclipse.ui.operations.RedoActionHandler;
25
import org.eclipse.ui.operations.RedoActionHandler;
27
26
28
/**
27
/**
Lines 32-51 Link Here
32
 * @author Christian W. Damus (cdamus)
31
 * @author Christian W. Damus (cdamus)
33
 */
32
 */
34
public class RedoActionWrapper extends RedoAction {
33
public class RedoActionWrapper extends RedoAction {
35
	private final ActionWrapperHelper delegate;
34
	private final ActionWrapperHelper<RedoActionHandler> delegate;
36
	
35
	
37
	/**
36
	/**
38
	 * Initializes me.
37
	 * Initializes me.
39
	 */
38
	 */
40
	public RedoActionWrapper() {
39
	public RedoActionWrapper() {
41
		delegate = new ActionWrapperHelper(new ActionWrapperHelper.OwnerAccess() {
40
		delegate = new ActionWrapperHelper<RedoActionHandler>(
41
			new ActionWrapperHelper.OwnerAccess<RedoActionHandler>() {
42
			
42
			
43
			public void firePropertyChange(String property, Object oldValue,
43
			public void firePropertyChange(String property, Object oldValue,
44
					Object newValue) {
44
					Object newValue) {
45
				firePropertyChange0(property, oldValue, newValue);
45
				firePropertyChange0(property, oldValue, newValue);
46
			}
46
			}
47
		
47
		
48
			public OperationHistoryActionHandler createDelegate(
48
			public RedoActionHandler createDelegate(
49
					IWorkbenchPartSite site, IUndoContext context) {
49
					IWorkbenchPartSite site, IUndoContext context) {
50
				return new RedoActionHandler(site, context);
50
				return new RedoActionHandler(site, context);
51
			}});
51
			}});
Lines 60-65 Link Here
60
	 * Extends the superclass implementation to update the operation history
60
	 * Extends the superclass implementation to update the operation history
61
	 * redo action handler to which I delegate.
61
	 * redo action handler to which I delegate.
62
	 */
62
	 */
63
	@Override
63
	public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart) {
64
	public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart) {
64
		super.setActiveWorkbenchPart(workbenchPart);
65
		super.setActiveWorkbenchPart(workbenchPart);
65
		delegate.setActiveWorkbenchPart(workbenchPart);
66
		delegate.setActiveWorkbenchPart(workbenchPart);
Lines 68-73 Link Here
68
	/**
69
	/**
69
	 * Delegates to the operation framework action handler.
70
	 * Delegates to the operation framework action handler.
70
	 */
71
	 */
72
	@Override
71
	public void update() {
73
	public void update() {
72
		if (delegate != null) {
74
		if (delegate != null) {
73
			delegate.update();
75
			delegate.update();
Lines 77-82 Link Here
77
	/**
79
	/**
78
	 * Delegates to the operation framework action handler.
80
	 * Delegates to the operation framework action handler.
79
	 */
81
	 */
82
	@Override
80
	public String getDescription() {
83
	public String getDescription() {
81
		if (delegate != null) {
84
		if (delegate != null) {
82
			return delegate.getDescription();
85
			return delegate.getDescription();
Lines 88-93 Link Here
88
	/**
91
	/**
89
	 * Delegates to the operation framework action handler.
92
	 * Delegates to the operation framework action handler.
90
	 */
93
	 */
94
	@Override
91
	public String getText() {
95
	public String getText() {
92
		if (delegate != null) {
96
		if (delegate != null) {
93
			return delegate.getText();
97
			return delegate.getText();
Lines 99-104 Link Here
99
	/**
103
	/**
100
	 * Delegates to the operation framework action handler.
104
	 * Delegates to the operation framework action handler.
101
	 */
105
	 */
106
	@Override
102
	public String getToolTipText() {
107
	public String getToolTipText() {
103
		if (delegate != null) {
108
		if (delegate != null) {
104
			return delegate.getToolTipText();
109
			return delegate.getToolTipText();
Lines 110-115 Link Here
110
	/**
115
	/**
111
	 * Delegates to the operation framework action handler.
116
	 * Delegates to the operation framework action handler.
112
	 */
117
	 */
118
	@Override
113
	public boolean isEnabled() {
119
	public boolean isEnabled() {
114
		if (delegate != null) {
120
		if (delegate != null) {
115
			return delegate.isEnabled();
121
			return delegate.isEnabled();
Lines 121-126 Link Here
121
	/**
127
	/**
122
	 * Delegates to the operation framework action handler.
128
	 * Delegates to the operation framework action handler.
123
	 */
129
	 */
130
	@Override
124
	public boolean isHandled() {
131
	public boolean isHandled() {
125
		if (delegate != null) {
132
		if (delegate != null) {
126
			return delegate.isHandled();
133
			return delegate.isHandled();
Lines 132-137 Link Here
132
	/**
139
	/**
133
	 * Delegates to the operation framework action handler.
140
	 * Delegates to the operation framework action handler.
134
	 */
141
	 */
142
	@Override
135
	public void run() {
143
	public void run() {
136
		if (delegate != null) {
144
		if (delegate != null) {
137
			delegate.run();
145
			delegate.run();
Lines 141-146 Link Here
141
	/**
149
	/**
142
	 * Delegates to the operation framework action handler.
150
	 * Delegates to the operation framework action handler.
143
	 */
151
	 */
152
	@Override
144
	public void runWithEvent(Event event) {
153
	public void runWithEvent(Event event) {
145
		if (delegate != null) {
154
		if (delegate != null) {
146
			delegate.runWithEvent(event);
155
			delegate.runWithEvent(event);
Lines 150-155 Link Here
150
	/**
159
	/**
151
	 * Delegates to the operation framework action handler.
160
	 * Delegates to the operation framework action handler.
152
	 */
161
	 */
162
	@Override
153
	public void setChecked(boolean checked) {
163
	public void setChecked(boolean checked) {
154
		if (delegate != null) {
164
		if (delegate != null) {
155
			delegate.setChecked(checked);
165
			delegate.setChecked(checked);
Lines 159-164 Link Here
159
	/**
169
	/**
160
	 * Delegates to the operation framework action handler.
170
	 * Delegates to the operation framework action handler.
161
	 */
171
	 */
172
	@Override
162
	public void setDescription(String text) {
173
	public void setDescription(String text) {
163
		if (delegate != null) {
174
		if (delegate != null) {
164
			delegate.setDescription(text);
175
			delegate.setDescription(text);
Lines 168-173 Link Here
168
	/**
179
	/**
169
	 * Delegates to the operation framework action handler.
180
	 * Delegates to the operation framework action handler.
170
	 */
181
	 */
182
	@Override
171
	public void setEnabled(boolean enabled) {
183
	public void setEnabled(boolean enabled) {
172
		if (delegate != null) {
184
		if (delegate != null) {
173
			delegate.setEnabled(enabled);
185
			delegate.setEnabled(enabled);
Lines 177-182 Link Here
177
	/**
189
	/**
178
	 * Delegates to the operation framework action handler.
190
	 * Delegates to the operation framework action handler.
179
	 */
191
	 */
192
	@Override
180
	public void setText(String text) {
193
	public void setText(String text) {
181
		if (delegate != null) {
194
		if (delegate != null) {
182
			delegate.setText(text);
195
			delegate.setText(text);
Lines 186-191 Link Here
186
	/**
199
	/**
187
	 * Delegates to the operation framework action handler.
200
	 * Delegates to the operation framework action handler.
188
	 */
201
	 */
202
	@Override
189
	public void setToolTipText(String toolTipText) {
203
	public void setToolTipText(String toolTipText) {
190
		if (delegate != null) {
204
		if (delegate != null) {
191
			delegate.setToolTipText(toolTipText);
205
			delegate.setToolTipText(toolTipText);
(-)src/org/eclipse/emf/workspace/ui/actions/ActionWrapperHelper.java (-15 / +27 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 34-48 Link Here
34
 * that they cannot inherit because they must separately extend the EMF
34
 * that they cannot inherit because they must separately extend the EMF
35
 * action classes.  i.e., this is an instance of the "prefer composition over
35
 * action classes.  i.e., this is an instance of the "prefer composition over
36
 * inheritance" idiom.
36
 * inheritance" idiom.
37
 *
37
 * 
38
 * @param <T> the operation-history action handler type that I support
39
 * 
38
 * @author Christian W. Damus (cdamus)
40
 * @author Christian W. Damus (cdamus)
39
 */
41
 */
40
class ActionWrapperHelper extends Action {
42
class ActionWrapperHelper<T extends OperationHistoryActionHandler> extends Action {
41
	private final OwnerAccess ownerAccess;
43
	private final OwnerAccess<T> ownerAccess;
42
	
44
	
43
	private OperationHistoryActionHandler delegate;
45
	private T delegate;
44
	
46
	
45
	private Map siteToActionHandler = new java.util.HashMap();
47
	private final Map<IWorkbenchPartSite, T> siteToActionHandler =
48
		new java.util.HashMap<IWorkbenchPartSite, T>();
46
	private IPartListener partListener;
49
	private IPartListener partListener;
47
	
50
	
48
	private final IPropertyChangeListener listener = new IPropertyChangeListener() {
51
	private final IPropertyChangeListener listener = new IPropertyChangeListener() {
Lines 52-58 Link Here
52
					event.getProperty(), event.getOldValue(), event.getNewValue());
55
					event.getProperty(), event.getOldValue(), event.getNewValue());
53
		}};
56
		}};
54
57
55
	ActionWrapperHelper(OwnerAccess ownerAccess) {
58
	ActionWrapperHelper(OwnerAccess<T> ownerAccess) {
56
		this.ownerAccess = ownerAccess;
59
		this.ownerAccess = ownerAccess;
57
	}
60
	}
58
		
61
		
Lines 84-92 Link Here
84
		}
87
		}
85
	}
88
	}
86
	
89
	
87
	private OperationHistoryActionHandler getActionHandler(IWorkbenchPartSite site, IUndoContext context) {
90
	private T getActionHandler(IWorkbenchPartSite site, IUndoContext context) {
88
		OperationHistoryActionHandler result =
91
		T result = siteToActionHandler.get(site);
89
			(OperationHistoryActionHandler) siteToActionHandler.get(site);
90
		
92
		
91
		if (result == null) {
93
		if (result == null) {
92
			result = ownerAccess.createDelegate(site, context);
94
			result = ownerAccess.createDelegate(site, context);
Lines 108-116 Link Here
108
			partListener = new IPartListener() {
110
			partListener = new IPartListener() {
109
			
111
			
110
				public void partClosed(IWorkbenchPart part) {
112
				public void partClosed(IWorkbenchPart part) {
111
					OperationHistoryActionHandler handler =
113
					T handler = siteToActionHandler.get(part.getSite());
112
						(OperationHistoryActionHandler) siteToActionHandler.get(
113
								part.getSite());
114
					
114
					
115
					if (handler != null) {
115
					if (handler != null) {
116
						siteToActionHandler.remove(part.getSite());
116
						siteToActionHandler.remove(part.getSite());
Lines 152-157 Link Here
152
	/**
152
	/**
153
	 * Delegates to the operation framework action handler.
153
	 * Delegates to the operation framework action handler.
154
	 */
154
	 */
155
	@Override
155
	public String getDescription() {
156
	public String getDescription() {
156
		if (delegate != null) {
157
		if (delegate != null) {
157
			return delegate.getDescription();
158
			return delegate.getDescription();
Lines 163-168 Link Here
163
	/**
164
	/**
164
	 * Delegates to the operation framework action handler.
165
	 * Delegates to the operation framework action handler.
165
	 */
166
	 */
167
	@Override
166
	public String getText() {
168
	public String getText() {
167
		if (delegate != null) {
169
		if (delegate != null) {
168
			return delegate.getText();
170
			return delegate.getText();
Lines 174-179 Link Here
174
	/**
176
	/**
175
	 * Delegates to the operation framework action handler.
177
	 * Delegates to the operation framework action handler.
176
	 */
178
	 */
179
	@Override
177
	public String getToolTipText() {
180
	public String getToolTipText() {
178
		if (delegate != null) {
181
		if (delegate != null) {
179
			return delegate.getToolTipText();
182
			return delegate.getToolTipText();
Lines 185-190 Link Here
185
	/**
188
	/**
186
	 * Delegates to the operation framework action handler.
189
	 * Delegates to the operation framework action handler.
187
	 */
190
	 */
191
	@Override
188
	public boolean isEnabled() {
192
	public boolean isEnabled() {
189
		if (delegate != null) {
193
		if (delegate != null) {
190
			return delegate.isEnabled();
194
			return delegate.isEnabled();
Lines 196-201 Link Here
196
	/**
200
	/**
197
	 * Delegates to the operation framework action handler.
201
	 * Delegates to the operation framework action handler.
198
	 */
202
	 */
203
	@Override
199
	public boolean isHandled() {
204
	public boolean isHandled() {
200
		if (delegate != null) {
205
		if (delegate != null) {
201
			return delegate.isHandled();
206
			return delegate.isHandled();
Lines 207-212 Link Here
207
	/**
212
	/**
208
	 * Delegates to the operation framework action handler.
213
	 * Delegates to the operation framework action handler.
209
	 */
214
	 */
215
	@Override
210
	public void run() {
216
	public void run() {
211
		if (delegate != null) {
217
		if (delegate != null) {
212
			delegate.run();
218
			delegate.run();
Lines 216-221 Link Here
216
	/**
222
	/**
217
	 * Delegates to the operation framework action handler.
223
	 * Delegates to the operation framework action handler.
218
	 */
224
	 */
225
	@Override
219
	public void runWithEvent(Event event) {
226
	public void runWithEvent(Event event) {
220
		if (delegate != null) {
227
		if (delegate != null) {
221
			delegate.runWithEvent(event);
228
			delegate.runWithEvent(event);
Lines 225-230 Link Here
225
	/**
232
	/**
226
	 * Delegates to the operation framework action handler.
233
	 * Delegates to the operation framework action handler.
227
	 */
234
	 */
235
	@Override
228
	public void setChecked(boolean checked) {
236
	public void setChecked(boolean checked) {
229
		if (delegate != null) {
237
		if (delegate != null) {
230
			delegate.setChecked(checked);
238
			delegate.setChecked(checked);
Lines 234-239 Link Here
234
	/**
242
	/**
235
	 * Delegates to the operation framework action handler.
243
	 * Delegates to the operation framework action handler.
236
	 */
244
	 */
245
	@Override
237
	public void setDescription(String text) {
246
	public void setDescription(String text) {
238
		if (delegate != null) {
247
		if (delegate != null) {
239
			delegate.setDescription(text);
248
			delegate.setDescription(text);
Lines 243-248 Link Here
243
	/**
252
	/**
244
	 * Delegates to the operation framework action handler.
253
	 * Delegates to the operation framework action handler.
245
	 */
254
	 */
255
	@Override
246
	public void setEnabled(boolean enabled) {
256
	public void setEnabled(boolean enabled) {
247
		if (delegate != null) {
257
		if (delegate != null) {
248
			delegate.setEnabled(enabled);
258
			delegate.setEnabled(enabled);
Lines 252-257 Link Here
252
	/**
262
	/**
253
	 * Delegates to the operation framework action handler.
263
	 * Delegates to the operation framework action handler.
254
	 */
264
	 */
265
	@Override
255
	public void setText(String text) {
266
	public void setText(String text) {
256
		if (delegate != null) {
267
		if (delegate != null) {
257
			delegate.setText(text);
268
			delegate.setText(text);
Lines 261-266 Link Here
261
	/**
272
	/**
262
	 * Delegates to the operation framework action handler.
273
	 * Delegates to the operation framework action handler.
263
	 */
274
	 */
275
	@Override
264
	public void setToolTipText(String toolTipText) {
276
	public void setToolTipText(String toolTipText) {
265
		if (delegate != null) {
277
		if (delegate != null) {
266
			delegate.setToolTipText(toolTipText);
278
			delegate.setToolTipText(toolTipText);
Lines 273-279 Link Here
273
	 *
285
	 *
274
	 * @author Christian W. Damus (cdamus)
286
	 * @author Christian W. Damus (cdamus)
275
	 */
287
	 */
276
	static interface OwnerAccess {
288
	static interface OwnerAccess<T extends Action> {
277
		/**
289
		/**
278
		 * Fires a property change event on behalf of the owner action wrapper.
290
		 * Fires a property change event on behalf of the owner action wrapper.
279
		 * 
291
		 * 
Lines 292-297 Link Here
292
		 * 
304
		 * 
293
		 * @return the new action handler
305
		 * @return the new action handler
294
		 */
306
		 */
295
		OperationHistoryActionHandler createDelegate(IWorkbenchPartSite site, IUndoContext context);
307
		T createDelegate(IWorkbenchPartSite site, IUndoContext context);
296
	}
308
	}
297
}
309
}
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)build.properties (-2 / +2 lines)
Lines 17-21 Link Here
17
               plugin.properties,\
17
               plugin.properties,\
18
               about.html
18
               about.html
19
src.includes = about.html
19
src.includes = about.html
20
javacSource = 1.4
20
javacSource = 1.5
21
javacTarget = 1.4
21
javacTarget = 1.5
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:55:15 EST 2006
1
#Sun Nov 11 17:04:57 EST 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-)META-INF/MANIFEST.MF (-4 / +4 lines)
Lines 2-14 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Plugin.name
3
Bundle-Name: %Plugin.name
4
Bundle-SymbolicName: org.eclipse.emf.workspace.ui
4
Bundle-SymbolicName: org.eclipse.emf.workspace.ui
5
Bundle-Version: 1.0.100.qualifier
5
Bundle-Version: 1.2.0.qualifier
6
Bundle-Localization: plugin
6
Bundle-Localization: plugin
7
Require-Bundle: org.eclipse.emf.workspace;bundle-version="[1.0.0,2.0.0)",
7
Require-Bundle: org.eclipse.emf.workspace;bundle-version="[1.2.0,2.0.0)",
8
 org.eclipse.emf.edit.ui;bundle-version="[2.2.0,3.0.0)"
8
 org.eclipse.emf.edit.ui;bundle-version="[2.3.0,3.0.0)"
9
Eclipse-LazyStart: true
9
Eclipse-LazyStart: true
10
Bundle-Activator: org.eclipse.emf.workspace.ui.internal.EMFWorkbenchUIPlugin$Implementation
10
Bundle-Activator: org.eclipse.emf.workspace.ui.internal.EMFWorkbenchUIPlugin$Implementation
11
Bundle-Vendor: %Plugin.providerName
11
Bundle-Vendor: %Plugin.providerName
12
Export-Package: org.eclipse.emf.workspace.ui.actions,
12
Export-Package: org.eclipse.emf.workspace.ui.actions,
13
 org.eclipse.emf.workspace.ui.internal;x-internal:=true
13
 org.eclipse.emf.workspace.ui.internal;x-internal:=true
14
Bundle-RequiredExecutionEnvironment: J2SE-1.4
14
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-).classpath (-1 / +1 lines)
Lines 1-6 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="output" path="bin"/>
5
	<classpathentry kind="output" path="bin"/>
6
</classpath>
6
</classpath>
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:55:59 EST 2006
1
#Sun Nov 11 13:12:56 EST 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 7-10 Link Here
7
Bundle-Localization: plugin
7
Bundle-Localization: plugin
8
Require-Bundle: org.eclipse.help;bundle-version="[3.2.0,4.0.0)"
8
Require-Bundle: org.eclipse.help;bundle-version="[3.2.0,4.0.0)"
9
Eclipse-LazyStart: true
9
Eclipse-LazyStart: true
10
Bundle-RequiredExecutionEnvironment: J2SE-1.4
10
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)src/org/eclipse/emf/workspace/util/MovedSynchRequest.java (+1 lines)
Lines 41-46 Link Here
41
		this.newURI = newURI;
41
		this.newURI = newURI;
42
	}
42
	}
43
	
43
	
44
	@Override
44
	protected void doPerform() {
45
	protected void doPerform() {
45
		if (!synch.getDelegate().handleResourceMoved(resource, newURI)) {
46
		if (!synch.getDelegate().handleResourceMoved(resource, newURI)) {
46
			// note that if our delegate is the default, it
47
			// note that if our delegate is the default, it
(-)src/org/eclipse/emf/workspace/util/ChangedSynchRequest.java (+1 lines)
Lines 35-40 Link Here
35
		super(synch, resource);
35
		super(synch, resource);
36
	}
36
	}
37
	
37
	
38
	@Override
38
	protected void doPerform() {
39
	protected void doPerform() {
39
		if (!synch.getDelegate().handleResourceChanged(resource)) {
40
		if (!synch.getDelegate().handleResourceChanged(resource)) {
40
			// note that if our delegate is the default, it
41
			// note that if our delegate is the default, it
(-)src/org/eclipse/emf/workspace/util/OperationChangeDescription.java (-5 / +7 lines)
Lines 48-54 Link Here
48
		implements TransactionChangeDescription {
48
		implements TransactionChangeDescription {
49
	private boolean isRedone = true;
49
	private boolean isRedone = true;
50
	private IUndoableOperation operation;
50
	private IUndoableOperation operation;
51
	private Reference info;
51
	private Reference<IAdaptable> info;
52
52
53
	/**
53
	/**
54
	 * Initializes me with the undoable operation that I encapsulate and the
54
	 * Initializes me with the undoable operation that I encapsulate and the
Lines 60-66 Link Here
60
	public OperationChangeDescription(IUndoableOperation operation, IAdaptable info) {
60
	public OperationChangeDescription(IUndoableOperation operation, IAdaptable info) {
61
		this.operation = operation;
61
		this.operation = operation;
62
		
62
		
63
		this.info = new WeakReference(info);
63
		this.info = new WeakReference<IAdaptable>(info);
64
	}
64
	}
65
	
65
	
66
	/**
66
	/**
Lines 82-90 Link Here
82
	 * I apply my change by undoing the encapsulated operation.  After it is
82
	 * I apply my change by undoing the encapsulated operation.  After it is
83
	 * undone, I dispose myself.
83
	 * undone, I dispose myself.
84
	 */
84
	 */
85
	@Override
85
	public void apply() {
86
	public void apply() {
86
		try {
87
		try {
87
			operation.undo(new NullProgressMonitor(), (IAdaptable) info.get());
88
			operation.undo(new NullProgressMonitor(), info.get());
88
		} catch (ExecutionException e) {
89
		} catch (ExecutionException e) {
89
			EMFWorkspacePlugin.INSTANCE.log(new Status(
90
			EMFWorkspacePlugin.INSTANCE.log(new Status(
90
				IStatus.ERROR,
91
				IStatus.ERROR,
Lines 101-113 Link Here
101
	 * I apply-and-reverse by alternately undoing and redoing the encapsulated
102
	 * I apply-and-reverse by alternately undoing and redoing the encapsulated
102
	 * operation.
103
	 * operation.
103
	 */
104
	 */
105
	@Override
104
	public void applyAndReverse() {
106
	public void applyAndReverse() {
105
		try {
107
		try {
106
			if (isRedone) {
108
			if (isRedone) {
107
				operation.undo(new NullProgressMonitor(), (IAdaptable) info.get());
109
				operation.undo(new NullProgressMonitor(), info.get());
108
				isRedone = false;
110
				isRedone = false;
109
			} else {
111
			} else {
110
				operation.redo(new NullProgressMonitor(), (IAdaptable) info.get());
112
				operation.redo(new NullProgressMonitor(), info.get());
111
				isRedone = true;
113
				isRedone = true;
112
			}
114
			}
113
		} catch (ExecutionException e) {
115
		} catch (ExecutionException e) {
(-)src/org/eclipse/emf/workspace/util/DeletedSynchRequest.java (+1 lines)
Lines 35-40 Link Here
35
		super(synch, resource);
35
		super(synch, resource);
36
	}
36
	}
37
	
37
	
38
	@Override
38
	protected void doPerform() {
39
	protected void doPerform() {
39
		if (!synch.getDelegate().handleResourceDeleted(resource)) {
40
		if (!synch.getDelegate().handleResourceDeleted(resource)) {
40
			// note that if our delegate is the default, it
41
			// note that if our delegate is the default, it
(-)src/org/eclipse/emf/workspace/util/WorkspaceSynchronizer.java (-15 / +18 lines)
Lines 19-25 Link Here
19
19
20
import java.io.IOException;
20
import java.io.IOException;
21
import java.util.Collection;
21
import java.util.Collection;
22
import java.util.Iterator;
23
import java.util.List;
22
import java.util.List;
24
23
25
import org.eclipse.core.resources.IFile;
24
import org.eclipse.core.resources.IFile;
Lines 78-84 Link Here
78
	private Delegate delegate;
77
	private Delegate delegate;
79
	
78
	
80
	// we employ a copy-on-write strategy on this collection for thread safety
79
	// we employ a copy-on-write strategy on this collection for thread safety
81
	private static Collection synchronizers = new java.util.ArrayList();
80
	private static Collection<WorkspaceSynchronizer> synchronizers =
81
		new java.util.ArrayList<WorkspaceSynchronizer>();
82
	
82
	
83
	// we use a single listener to serve all synchronizers.
83
	// we use a single listener to serve all synchronizers.
84
	private static IResourceChangeListener workspaceListener =
84
	private static IResourceChangeListener workspaceListener =
Lines 163-169 Link Here
163
	 * @param delta the resource change
163
	 * @param delta the resource change
164
	 * @param synchRequests accumulates synch requests for the deltas
164
	 * @param synchRequests accumulates synch requests for the deltas
165
	 */
165
	 */
166
	void processDelta(IResourceDelta delta, List synchRequests) {
166
	void processDelta(IResourceDelta delta, List<SynchRequest> synchRequests) {
167
	    String fullPath = delta.getFullPath().toString();
167
	    String fullPath = delta.getFullPath().toString();
168
	    URI uri = URI.createPlatformResourceURI(fullPath, false);
168
	    URI uri = URI.createPlatformResourceURI(fullPath, false);
169
	    ResourceSet rset = getEditingDomain().getResourceSet();
169
	    ResourceSet rset = getEditingDomain().getResourceSet();
Lines 274-280 Link Here
274
	static void startListening(WorkspaceSynchronizer synchronizer) {
274
	static void startListening(WorkspaceSynchronizer synchronizer) {
275
		// copy-on-write for thread safety
275
		// copy-on-write for thread safety
276
		synchronized (synchronizers) {
276
		synchronized (synchronizers) {
277
			Collection newList = new java.util.ArrayList(synchronizers.size() + 1);
277
			Collection<WorkspaceSynchronizer> newList =
278
				new java.util.ArrayList<WorkspaceSynchronizer>(synchronizers.size() + 1);
278
			newList.addAll(synchronizers);
279
			newList.addAll(synchronizers);
279
			newList.add(synchronizer);
280
			newList.add(synchronizer);
280
			synchronizers = newList;
281
			synchronizers = newList;
Lines 294-300 Link Here
294
	static void stopListening(WorkspaceSynchronizer synchronizer) {
295
	static void stopListening(WorkspaceSynchronizer synchronizer) {
295
		// copy-on-write for thread safety
296
		// copy-on-write for thread safety
296
		synchronized (synchronizers) {
297
		synchronized (synchronizers) {
297
			Collection newList = new java.util.ArrayList(synchronizers);
298
			Collection<WorkspaceSynchronizer> newList =
299
				new java.util.ArrayList<WorkspaceSynchronizer>(synchronizers);
298
			newList.remove(synchronizer);
300
			newList.remove(synchronizer);
299
			synchronizers = newList;
301
			synchronizers = newList;
300
			
302
			
Lines 311-317 Link Here
311
	 * 
313
	 * 
312
	 * @return the currently active synchronizers
314
	 * @return the currently active synchronizers
313
	 */
315
	 */
314
	static Collection getSynchronizers() {
316
	static Collection<WorkspaceSynchronizer> getSynchronizers() {
315
		// does not need synchronization because we copy on write
317
		// does not need synchronization because we copy on write
316
		return synchronizers;
318
		return synchronizers;
317
	}
319
	}
Lines 388-394 Link Here
388
			IResourceDelta delta = event.getDelta();
390
			IResourceDelta delta = event.getDelta();
389
			
391
			
390
			try {
392
			try {
391
				final List synchRequests = new java.util.ArrayList();
393
				final List<SynchRequest> synchRequests =
394
					new java.util.ArrayList<SynchRequest>();
392
				
395
				
393
				delta.accept(new IResourceDeltaVisitor() {
396
				delta.accept(new IResourceDeltaVisitor() {
394
					public boolean visit(IResourceDelta delta) {
397
					public boolean visit(IResourceDelta delta) {
Lines 422-431 Link Here
422
		 * @param delta the delta to process
425
		 * @param delta the delta to process
423
		 * @param synchRequests accumulates synch requests for the deltas
426
		 * @param synchRequests accumulates synch requests for the deltas
424
		 */
427
		 */
425
		private void processDelta(IResourceDelta delta, List synchRequests) {
428
		private void processDelta(IResourceDelta delta, List<SynchRequest> synchRequests) {
426
			for (Iterator iter = getSynchronizers().iterator(); iter.hasNext();) {
429
			for (WorkspaceSynchronizer next : getSynchronizers()) {
427
				((WorkspaceSynchronizer) iter.next()).processDelta(
430
				next.processDelta(delta, synchRequests);
428
						delta, synchRequests);
429
			}
431
			}
430
		}
432
		}
431
	}
433
	}
Lines 472-478 Link Here
472
	 * @author Christian W. Damus (cdamus)
474
	 * @author Christian W. Damus (cdamus)
473
	 */
475
	 */
474
	private static class ResourceSynchJob extends WorkspaceJob {
476
	private static class ResourceSynchJob extends WorkspaceJob {
475
		private final List synchRequests;
477
		private final List<SynchRequest> synchRequests;
476
		
478
		
477
		/**
479
		/**
478
		 * Initializes me with the list of resources changes that I am to
480
		 * Initializes me with the list of resources changes that I am to
Lines 480-486 Link Here
480
		 * 
482
		 * 
481
		 * @param synchRequests the resource synchronization requests
483
		 * @param synchRequests the resource synchronization requests
482
		 */
484
		 */
483
		ResourceSynchJob(List synchRequests) {
485
		ResourceSynchJob(List<SynchRequest> synchRequests) {
484
			super(Messages.synchJobName);
486
			super(Messages.synchJobName);
485
			
487
			
486
			this.synchRequests = synchRequests;
488
			this.synchRequests = synchRequests;
Lines 491-500 Link Here
491
		/**
493
		/**
492
		 * Processes my queued resource synchronization requests.
494
		 * Processes my queued resource synchronization requests.
493
		 */
495
		 */
496
		@Override
494
		public IStatus runInWorkspace(IProgressMonitor monitor) {
497
		public IStatus runInWorkspace(IProgressMonitor monitor) {
495
			try {
498
			try {
496
				for (Iterator iter = synchRequests.iterator(); iter.hasNext();) {
499
				for (SynchRequest next : synchRequests) {
497
					((SynchRequest) iter.next()).perform();
500
					next.perform();
498
				}
501
				}
499
			} catch (InterruptedException e) {
502
			} catch (InterruptedException e) {
500
				Tracing.catching(ResourceSynchJob.class, "run", e); //$NON-NLS-1$
503
				Tracing.catching(ResourceSynchJob.class, "run", e); //$NON-NLS-1$
(-)src/org/eclipse/emf/workspace/util/WorkspaceValidateEditSupport.java (-9 / +8 lines)
Lines 18-31 Link Here
18
package org.eclipse.emf.workspace.util;
18
package org.eclipse.emf.workspace.util;
19
19
20
import java.util.Collection;
20
import java.util.Collection;
21
import java.util.Iterator;
22
import java.util.List;
21
import java.util.List;
23
22
24
import org.eclipse.core.resources.IFile;
23
import org.eclipse.core.resources.IFile;
25
import org.eclipse.core.resources.IWorkspace;
24
import org.eclipse.core.resources.IWorkspace;
26
import org.eclipse.core.resources.ResourcesPlugin;
25
import org.eclipse.core.resources.ResourcesPlugin;
27
import org.eclipse.core.runtime.IStatus;
26
import org.eclipse.core.runtime.IStatus;
28
import org.eclipse.emf.common.util.BasicEList;
29
import org.eclipse.emf.ecore.resource.Resource;
27
import org.eclipse.emf.ecore.resource.Resource;
30
import org.eclipse.emf.transaction.Transaction;
28
import org.eclipse.emf.transaction.Transaction;
31
import org.eclipse.emf.transaction.TransactionalEditingDomain;
29
import org.eclipse.emf.transaction.TransactionalEditingDomain;
Lines 52-75 Link Here
52
public class WorkspaceValidateEditSupport
50
public class WorkspaceValidateEditSupport
53
    extends ValidateEditSupport.Default {
51
    extends ValidateEditSupport.Default {
54
52
55
    protected IStatus doValidateEdit(Transaction transaction,
53
    @Override
56
            Collection resources, Object context) {
54
	protected IStatus doValidateEdit(Transaction transaction,
55
            Collection<? extends Resource> resources, Object context) {
57
        
56
        
58
        IFile[] files = getFiles(resources);
57
        IFile[] files = getFiles(resources);
59
        
58
        
60
        return ResourcesPlugin.getWorkspace().validateEdit(files, context);
59
        return ResourcesPlugin.getWorkspace().validateEdit(files, context);
61
    }
60
    }
62
    
61
    
63
    protected IFile[] getFiles(Collection resources) {
62
    protected IFile[] getFiles(Collection<? extends Resource> resources) {
64
        List result = new BasicEList();
63
        List<IFile> result = new java.util.ArrayList<IFile>();
65
        for (Iterator iter = resources.iterator(); iter.hasNext();) {
64
        for (Resource next : resources) {
66
            IFile file = WorkspaceSynchronizer.getFile((Resource) iter.next());
65
            IFile file = WorkspaceSynchronizer.getFile(next);
67
            
66
            
68
            if (file != null) {
67
            if (file != null) {
69
                result.add(file);
68
                result.add(file);
70
            }
69
            }
71
        }
70
        }
72
        
71
        
73
        return (IFile[]) result.toArray(new IFile[result.size()]);
72
        return result.toArray(new IFile[result.size()]);
74
    }
73
    }
75
}
74
}
(-)src/org/eclipse/emf/workspace/internal/Tracing.java (-60 / +12 lines)
Lines 109-115 Link Here
109
	/**
109
	/**
110
	 * The cached debug options (for optimization).
110
	 * The cached debug options (for optimization).
111
	 */
111
	 */
112
	private static final Map cachedOptions = new HashMap();
112
	private static final Map<String, Boolean> cachedOptions =
113
		new HashMap<String, Boolean>();
113
114
114
	/**
115
	/**
115
	 * Retrieves a Boolean value indicating whether tracing is enabled.
116
	 * Retrieves a Boolean value indicating whether tracing is enabled.
Lines 137-149 Link Here
137
			Boolean value = null;
138
			Boolean value = null;
138
			
139
			
139
			synchronized (cachedOptions) {
140
			synchronized (cachedOptions) {
140
				value = (Boolean) cachedOptions.get(option);
141
				value = cachedOptions.get(option);
141
	
142
	
142
				if (null == value) {
143
				if (null == value) {
143
					value =
144
					value =
144
						new Boolean(
145
						Boolean.TRUE.toString().equalsIgnoreCase(
145
							Boolean.TRUE.toString().equalsIgnoreCase(
146
								org.eclipse.core.runtime.Platform.getDebugOption(option));
146
								org.eclipse.core.runtime.Platform.getDebugOption(option)));
147
	
147
	
148
					cachedOptions.put(option, value);
148
					cachedOptions.put(option, value);
149
				}
149
				}
Lines 254-260 Link Here
254
	 */
254
	 */
255
	public static void changing(
255
	public static void changing(
256
        String option,
256
        String option,
257
        Class clazz,
257
        Class<?> clazz,
258
        String methodName,
258
        String methodName,
259
        String valueDescription,
259
        String valueDescription,
260
        Object oldValue,
260
        Object oldValue,
Lines 291-297 Link Here
291
	 * 
291
	 * 
292
	 */
292
	 */
293
	public static void catching(
293
	public static void catching(
294
		Class clazz,
294
		Class<?> clazz,
295
		String methodName,
295
		String methodName,
296
		Throwable throwable) {
296
		Throwable throwable) {
297
297
Lines 322-328 Link Here
322
	 * 
322
	 * 
323
	 */
323
	 */
324
	public static void throwing(
324
	public static void throwing(
325
		Class clazz,
325
		Class<?> clazz,
326
		String methodName,
326
		String methodName,
327
		Throwable throwable) {
327
		Throwable throwable) {
328
328
Lines 343-396 Link Here
343
	}
343
	}
344
344
345
	/**
345
	/**
346
	 * Traces the entering into the specified method of the specified class.
347
	 * 
348
	 * @param clazz The class whose method is being entered.
349
	 * @param methodName The name of method that is being entered.
350
	 * 
351
	 */
352
	public static void entering(
353
		Class clazz,
354
		String methodName) {
355
356
		if (shouldTrace(EMFWorkspaceDebugOptions.METHODS_ENTERING)) {
357
358
			trace(
359
				PREFIX_ENTERING
360
					+ clazz.getName()
361
					+ SEPARATOR_METHOD
362
					+ methodName);
363
		}
364
	}
365
366
	/**
367
	 * Traces the entering into the specified method of the specified class,
368
	 * with the specified parameter.
369
	 * 
370
	 * @param clazz The class whose method is being entered.
371
	 * @param methodName The name of method that is being entered.
372
	 * @param parameter The parameter to the method being entered.
373
	 * 
374
	 */
375
	public static void entering(
376
		Class clazz,
377
		String methodName,
378
		Object parameter) {
379
380
		if (shouldTrace(EMFWorkspaceDebugOptions.METHODS_ENTERING)) {
381
382
			trace(
383
				PREFIX_ENTERING
384
					+ clazz.getName()
385
					+ SEPARATOR_METHOD
386
					+ methodName
387
					+ PARENTHESIS_OPEN
388
					+ getArgumentString(parameter)
389
					+ PARENTHESIS_CLOSE);
390
		}
391
	}
392
393
	/**
394
	 * Traces the entering into the specified method of the specified class,
346
	 * Traces the entering into the specified method of the specified class,
395
	 * with the specified parameters.
347
	 * with the specified parameters.
396
	 * 
348
	 * 
Lines 400-408 Link Here
400
	 * 
352
	 * 
401
	 */
353
	 */
402
	public static void entering(
354
	public static void entering(
403
		Class clazz,
355
		Class<?> clazz,
404
		String methodName,
356
		String methodName,
405
		Object[] parameters) {
357
		Object... parameters) {
406
358
407
		if (shouldTrace(EMFWorkspaceDebugOptions.METHODS_ENTERING)) {
359
		if (shouldTrace(EMFWorkspaceDebugOptions.METHODS_ENTERING)) {
408
360
Lines 425-431 Link Here
425
	 * 
377
	 * 
426
	 */
378
	 */
427
	public static void exiting(
379
	public static void exiting(
428
		Class clazz,
380
		Class<?> clazz,
429
		String methodName) {
381
		String methodName) {
430
382
431
		if (shouldTrace(EMFWorkspaceDebugOptions.METHODS_EXITING)) {
383
		if (shouldTrace(EMFWorkspaceDebugOptions.METHODS_EXITING)) {
Lines 448-454 Link Here
448
	 * 
400
	 * 
449
	 */
401
	 */
450
	public static void exiting(
402
	public static void exiting(
451
		Class clazz,
403
		Class<?> clazz,
452
		String methodName,
404
		String methodName,
453
		Object returnValue) {
405
		Object returnValue) {
454
406
(-)src/org/eclipse/emf/workspace/internal/EMFWorkspacePlugin.java (+3 lines)
Lines 42-47 Link Here
42
	}
42
	}
43
43
44
	// implements the inherited method
44
	// implements the inherited method
45
	@Override
45
	public ResourceLocator getPluginResourceLocator() {
46
	public ResourceLocator getPluginResourceLocator() {
46
		return plugin;
47
		return plugin;
47
	}
48
	}
Lines 84-89 Link Here
84
		/**
85
		/**
85
		 * This method is called upon plug-in activation
86
		 * This method is called upon plug-in activation
86
		 */
87
		 */
88
		@Override
87
		public void start(BundleContext context) throws Exception {
89
		public void start(BundleContext context) throws Exception {
88
			super.start(context);
90
			super.start(context);
89
		}
91
		}
Lines 91-96 Link Here
91
		/**
93
		/**
92
		 * This method is called when the plug-in is stopped
94
		 * This method is called when the plug-in is stopped
93
		 */
95
		 */
96
		@Override
94
		public void stop(BundleContext context) throws Exception {
97
		public void stop(BundleContext context) throws Exception {
95
			super.stop(context);
98
			super.stop(context);
96
			EMFWorkspacePlugin.plugin = null;
99
			EMFWorkspacePlugin.plugin = null;
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:52:31 EST 2006
1
#Sun Nov 11 14:27:35 EST 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-)src/org/eclipse/emf/workspace/ResourceUndoContext.java (-15 / +18 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005, 2006 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 82-87 Link Here
82
	 * I am equal to other <code>ResourceUndoContexts</code> on the same
82
	 * I am equal to other <code>ResourceUndoContexts</code> on the same
83
	 * resource as mine.
83
	 * resource as mine.
84
	 */
84
	 */
85
	@Override
85
	public boolean equals(Object o) {
86
	public boolean equals(Object o) {
86
		boolean result = false;
87
		boolean result = false;
87
		
88
		
Lines 93-98 Link Here
93
	}
94
	}
94
95
95
	// Redefines the inherited method
96
	// Redefines the inherited method
97
	@Override
96
	public int hashCode() {
98
	public int hashCode() {
97
		return resource == null ? 0 : resource.hashCode();
99
		return resource == null ? 0 : resource.hashCode();
98
	}
100
	}
Lines 125-144 Link Here
125
	 * @return the resources affected by the specified notifications.
127
	 * @return the resources affected by the specified notifications.
126
	 *     The resulting set should be treated as unmodifiable
128
	 *     The resulting set should be treated as unmodifiable
127
	 */
129
	 */
128
	public static Set getAffectedResources(List notifications) {
130
	public static Set<Resource> getAffectedResources(
129
		Set result;
131
			List<? extends Notification> notifications) {
132
		
133
		Set<Resource> result;
130
		
134
		
131
		if (notifications.isEmpty()) {
135
		if (notifications.isEmpty()) {
132
			result = Collections.EMPTY_SET;
136
			result = Collections.emptySet();
133
		} else {
137
		} else {
134
			result = new java.util.HashSet();
138
			result = new java.util.HashSet<Resource>();
135
			
139
			
136
			for (Iterator iter = notifications.iterator(); iter.hasNext();) {
140
			for (Notification next : notifications) {
137
				Notification next = (Notification) iter.next();
138
				Object notifier = next.getNotifier();
141
				Object notifier = next.getNotifier();
139
				
142
				
140
				if (notifier instanceof Resource) {
143
				if (notifier instanceof Resource) {
141
					result.add(notifier);
144
					result.add((Resource) notifier);
142
				} else if (notifier instanceof EObject) {
145
				} else if (notifier instanceof EObject) {
143
					EObject eobj = (EObject) notifier;
146
					EObject eobj = (EObject) notifier;
144
                    Resource resource = eobj.eResource();
147
                    Resource resource = eobj.eResource();
Lines 170-183 Link Here
170
	 * @return the {@link Resource}s that it affects, or an empty set if none.
173
	 * @return the {@link Resource}s that it affects, or an empty set if none.
171
	 *     The resulting set should be treated as unmodifiable
174
	 *     The resulting set should be treated as unmodifiable
172
	 */
175
	 */
173
	public static Set getAffectedResources(IUndoableOperation operation) {
176
	public static Set<Resource> getAffectedResources(IUndoableOperation operation) {
174
		Set result;
177
		Set<Resource> result;
175
		IUndoContext[] contexts = operation.getContexts();
178
		IUndoContext[] contexts = operation.getContexts();
176
		
179
		
177
		if (contexts.length == 0) {
180
		if (contexts.length == 0) {
178
			result = Collections.EMPTY_SET;
181
			result = Collections.emptySet();
179
		} else {
182
		} else {
180
			result = new java.util.HashSet();
183
			result = new java.util.HashSet<Resource>();
181
			
184
			
182
			for (int i = 0; i < contexts.length; i++) {
185
			for (int i = 0; i < contexts.length; i++) {
183
				if (contexts[i] instanceof ResourceUndoContext) {
186
				if (contexts[i] instanceof ResourceUndoContext) {
Lines 197-203 Link Here
197
	 * @param notification a potential cross-resource reference change notification
200
	 * @param notification a potential cross-resource reference change notification
198
	 */
201
	 */
199
	private static void handleCrossResourceReference(
202
	private static void handleCrossResourceReference(
200
			Set resources,
203
			Set<Resource> resources,
201
			Notification notification) {
204
			Notification notification) {
202
		
205
		
203
		Object oldValue = notification.getOldValue();
206
		Object oldValue = notification.getOldValue();
Lines 230-236 Link Here
230
            }
233
            }
231
			break;
234
			break;
232
		case Notification.ADD_MANY:
235
		case Notification.ADD_MANY:
233
			for (Iterator iter = ((Collection) newValue).iterator(); iter.hasNext();) {
236
			for (Iterator<?> iter = ((Collection<?>) newValue).iterator(); iter.hasNext();) {
234
                resource = ((EObject) iter.next()).eResource();
237
                resource = ((EObject) iter.next()).eResource();
235
                
238
                
236
                if (resource != null) {
239
                if (resource != null) {
Lines 246-252 Link Here
246
            }
249
            }
247
			break;
250
			break;
248
		case Notification.REMOVE_MANY:
251
		case Notification.REMOVE_MANY:
249
			for (Iterator iter = ((Collection) oldValue).iterator(); iter.hasNext();) {
252
			for (Iterator<?> iter = ((Collection<?>) oldValue).iterator(); iter.hasNext();) {
250
                resource = ((EObject) iter.next()).eResource();
253
                resource = ((EObject) iter.next()).eResource();
251
                
254
                
252
                if (resource != null) {
255
                if (resource != null) {
(-)src/org/eclipse/emf/workspace/EMFCommandOperation.java (-10 / +19 lines)
Lines 17-23 Link Here
17
package org.eclipse.emf.workspace;
17
package org.eclipse.emf.workspace;
18
18
19
import java.util.Collection;
19
import java.util.Collection;
20
import java.util.Iterator;
21
import java.util.List;
20
import java.util.List;
22
import java.util.Map;
21
import java.util.Map;
23
22
Lines 83-89 Link Here
83
	 * @param command my command
82
	 * @param command my command
84
	 * @param options transaction options, or <code>null</code> for the defaults
83
	 * @param options transaction options, or <code>null</code> for the defaults
85
	 */
84
	 */
86
	public EMFCommandOperation(TransactionalEditingDomain domain, Command command, Map options) {
85
	public EMFCommandOperation(TransactionalEditingDomain domain, Command command,
86
			Map<?, ?> options) {
87
		
87
		super(domain, command.getLabel(), options);
88
		super(domain, command.getLabel(), options);
88
		
89
		
89
		this.command = command;
90
		this.command = command;
Lines 103-108 Link Here
103
	/**
104
	/**
104
	 * I can execute if my command can execute.
105
	 * I can execute if my command can execute.
105
	 */
106
	 */
107
	@Override
106
	public boolean canExecute() {
108
	public boolean canExecute() {
107
		return super.canExecute() && command.canExecute();
109
		return super.canExecute() && command.canExecute();
108
	}
110
	}
Lines 110-115 Link Here
110
	/**
112
	/**
111
	 * Executes me by executing my command.
113
	 * Executes me by executing my command.
112
	 */
114
	 */
115
	@Override
113
	protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
116
	protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
114
		throws ExecutionException {
117
		throws ExecutionException {
115
		
118
		
Lines 118-123 Link Here
118
		return Status.OK_STATUS;
121
		return Status.OK_STATUS;
119
	}
122
	}
120
	
123
	
124
	@Override
121
	protected void didCommit(Transaction transaction) {
125
	protected void didCommit(Transaction transaction) {
122
		super.didCommit(transaction);
126
		super.didCommit(transaction);
123
		
127
		
Lines 131-136 Link Here
131
	/**
135
	/**
132
	 * I can undo if my command or (if any) trigger command can undo.
136
	 * I can undo if my command or (if any) trigger command can undo.
133
	 */
137
	 */
138
	@Override
134
	public boolean canUndo() {
139
	public boolean canUndo() {
135
		return super.canUndo() &&
140
		return super.canUndo() &&
136
			(command.canUndo() && ((triggerCommand == null) || triggerCommand.canUndo()));
141
			(command.canUndo() && ((triggerCommand == null) || triggerCommand.canUndo()));
Lines 139-144 Link Here
139
	/**
144
	/**
140
	 * Undoes me by undoing my trigger command (if any) and my command.
145
	 * Undoes me by undoing my trigger command (if any) and my command.
141
	 */
146
	 */
147
	@Override
142
	protected IStatus doUndo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
148
	protected IStatus doUndo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
143
		if (triggerCommand != null) {
149
		if (triggerCommand != null) {
144
			triggerCommand.undo();
150
			triggerCommand.undo();
Lines 153-158 Link Here
153
	 * I can redo if either my wrapped command is a {@link ConditionalRedoCommand}
159
	 * I can redo if either my wrapped command is a {@link ConditionalRedoCommand}
154
	 * that can undo, or it is not a conditionally redoable command.
160
	 * that can undo, or it is not a conditionally redoable command.
155
	 */
161
	 */
162
	@Override
156
	public boolean canRedo() {
163
	public boolean canRedo() {
157
		return super.canRedo() &&
164
		return super.canRedo() &&
158
			(canRedo(command) && ((triggerCommand == null) || canRedo(triggerCommand)));
165
			(canRedo(command) && ((triggerCommand == null) || canRedo(triggerCommand)));
Lines 166-171 Link Here
166
	/**
173
	/**
167
	 * Redoes me by redoing my command and my trigger command (if any).
174
	 * Redoes me by redoing my command and my trigger command (if any).
168
	 */
175
	 */
176
	@Override
169
	protected IStatus doRedo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
177
	protected IStatus doRedo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
170
		command.redo();
178
		command.redo();
171
		
179
		
Lines 180-186 Link Here
180
     * Extends the inherited implementation to additionally dispose my command
188
     * Extends the inherited implementation to additionally dispose my command
181
     * and my trigger command (if any).
189
     * and my trigger command (if any).
182
     */
190
     */
183
    public void dispose() {
191
    @Override
192
	public void dispose() {
184
        super.dispose();
193
        super.dispose();
185
        
194
        
186
        if (command != null) {
195
        if (command != null) {
Lines 197-203 Link Here
197
	 * 
206
	 * 
198
	 * @see EMFOperationTransaction
207
	 * @see EMFOperationTransaction
199
	 */
208
	 */
200
	Transaction createTransaction(Map options) throws InterruptedException {
209
	@Override
210
	Transaction createTransaction(Map<?, ?> options) throws InterruptedException {
201
		InternalTransactionalCommandStack stack =
211
		InternalTransactionalCommandStack stack =
202
			(InternalTransactionalCommandStack) getEditingDomain().getCommandStack();
212
			(InternalTransactionalCommandStack) getEditingDomain().getCommandStack();
203
		
213
		
Lines 227-235 Link Here
227
		
237
		
228
		if (cmd instanceof CompoundCommand) {
238
		if (cmd instanceof CompoundCommand) {
229
			CompoundCommand compound = (CompoundCommand) cmd;
239
			CompoundCommand compound = (CompoundCommand) cmd;
230
			List nested = compound.getCommandList();
240
			List<Command> nested = compound.getCommandList();
231
			if (!nested.isEmpty()) {
241
			if (!nested.isEmpty()) {
232
				improveLabel((Command) nested.get(0));
242
				improveLabel(nested.get(0));
233
				return;
243
				return;
234
			}
244
			}
235
		} else if (cmd instanceof SetCommand) {
245
		} else if (cmd instanceof SetCommand) {
Lines 265-275 Link Here
265
						owner, IItemPropertySource.class);
275
						owner, IItemPropertySource.class);
266
			
276
			
267
			if (source != null) {
277
			if (source != null) {
268
				Collection descriptors = source.getPropertyDescriptors(owner);
278
				Collection<IItemPropertyDescriptor> descriptors =
279
					source.getPropertyDescriptors(owner);
269
				
280
				
270
				for (Iterator iter = descriptors.iterator(); iter.hasNext();) {
281
				for (IItemPropertyDescriptor next : descriptors) {
271
					IItemPropertyDescriptor next = (IItemPropertyDescriptor) iter.next();
272
					
273
					if (next.getFeature(owner) == feature) {
282
					if (next.getFeature(owner) == feature) {
274
						setLabel(NLS.bind(pattern, next.getDisplayName(owner)));
283
						setLabel(NLS.bind(pattern, next.getDisplayName(owner)));
275
						break;
284
						break;
(-)src/org/eclipse/emf/workspace/CompositeEMFOperation.java (-45 / +67 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005, 2006 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 92-98 Link Here
92
 */
92
 */
93
public class CompositeEMFOperation extends AbstractEMFOperation {
93
public class CompositeEMFOperation extends AbstractEMFOperation {
94
94
95
	private final List children;
95
	private final List<IUndoableOperation> children;
96
	private boolean transactionNestingEnabled = true;
96
	private boolean transactionNestingEnabled = true;
97
	
97
	
98
	/**
98
	/**
Lines 114-120 Link Here
114
	 * @param options for the transaction in which I execute myself, or
114
	 * @param options for the transaction in which I execute myself, or
115
	 *     <code>null</code> for the default options
115
	 *     <code>null</code> for the default options
116
	 */
116
	 */
117
	public CompositeEMFOperation(TransactionalEditingDomain domain, String label, Map options) {
117
	public CompositeEMFOperation(TransactionalEditingDomain domain, String label,
118
			Map<?, ?> options) {
118
		this(domain, label, null, options);
119
		this(domain, label, null, options);
119
	}
120
	}
120
	
121
	
Lines 125-131 Link Here
125
	 * @param label my user-readable label
126
	 * @param label my user-readable label
126
	 * @param children a list of operations to compose
127
	 * @param children a list of operations to compose
127
	 */
128
	 */
128
	public CompositeEMFOperation(TransactionalEditingDomain domain, String label, List children) {
129
	public CompositeEMFOperation(TransactionalEditingDomain domain, String label,
130
			List<? extends IUndoableOperation> children) {
129
		this(domain, label, children, null);
131
		this(domain, label, children, null);
130
	}
132
	}
131
	
133
	
Lines 139-151 Link Here
139
	 * @param options for the transaction in which I execute myself, or
141
	 * @param options for the transaction in which I execute myself, or
140
	 *     <code>null</code> for the default options
142
	 *     <code>null</code> for the default options
141
	 */
143
	 */
142
	public CompositeEMFOperation(TransactionalEditingDomain domain, String label, List children, Map options) {
144
	public CompositeEMFOperation(TransactionalEditingDomain domain, String label,
145
			List<? extends IUndoableOperation> children, Map<?, ?> options) {
143
		super(domain, label, options);
146
		super(domain, label, options);
144
		
147
		
145
		if (children != null) {
148
		if (children != null) {
146
			this.children = new java.util.ArrayList(children);
149
			this.children = new java.util.ArrayList<IUndoableOperation>(children);
147
		} else {
150
		} else {
148
			this.children = new java.util.ArrayList();
151
			this.children = new java.util.ArrayList<IUndoableOperation>();
149
		}
152
		}
150
	}
153
	}
151
	
154
	
Lines 155-164 Link Here
155
	 * so that they may be correctly rolled back (in sequence) in the event
158
	 * so that they may be correctly rolled back (in sequence) in the event
156
	 * of rollback, undo, or redo.
159
	 * of rollback, undo, or redo.
157
	 */
160
	 */
161
	@Override
158
	protected final IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
162
	protected final IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
159
			throws ExecutionException {
163
			throws ExecutionException {
160
		
164
		
161
		final List result = new java.util.ArrayList(size());
165
		final List<IStatus> result = new java.util.ArrayList<IStatus>(size());
162
		
166
		
163
		if (monitor == null) {
167
		if (monitor == null) {
164
			monitor = new NullProgressMonitor();
168
			monitor = new NullProgressMonitor();
Lines 167-173 Link Here
167
		monitor.beginTask(getLabel(), size());
171
		monitor.beginTask(getLabel(), size());
168
		
172
		
169
		try {
173
		try {
170
			for (ListIterator iter = listIterator(); iter.hasNext();) {
174
			for (ListIterator<IUndoableOperation> iter = listIterator(); iter.hasNext();) {
171
				if (monitor.isCanceled()) {
175
				if (monitor.isCanceled()) {
172
					// abort the current transaction so that it will rollback
176
					// abort the current transaction so that it will rollback
173
					//   any changes already committed by child transactions
177
					//   any changes already committed by child transactions
Lines 181-187 Link Here
181
				}
185
				}
182
				
186
				
183
				Transaction childTransaction = null;
187
				Transaction childTransaction = null;
184
				IUndoableOperation next = (IUndoableOperation) iter.next();
188
				IUndoableOperation next = iter.next();
185
				IStatus status = null;
189
				IStatus status = null;
186
				
190
				
187
				if (!(next instanceof AbstractEMFOperation)) {
191
				if (!(next instanceof AbstractEMFOperation)) {
Lines 262-268 Link Here
262
	private Transaction createNonEMFTransaction(
266
	private Transaction createNonEMFTransaction(
263
			IUndoableOperation operation,
267
			IUndoableOperation operation,
264
			IAdaptable info,
268
			IAdaptable info,
265
			Map options)
269
			Map<?, ?> options)
266
			throws InterruptedException {
270
			throws InterruptedException {
267
		
271
		
268
		InternalTransaction result = new NonEMFTransaction(
272
		InternalTransaction result = new NonEMFTransaction(
Lines 273-278 Link Here
273
		return result;
277
		return result;
274
	}
278
	}
275
	
279
	
280
	@Override
276
	protected void didCommit(Transaction transaction) {
281
	protected void didCommit(Transaction transaction) {
277
		super.didCommit(transaction);
282
		super.didCommit(transaction);
278
		
283
		
Lines 280-300 Link Here
280
		if (triggers != null) {
285
		if (triggers != null) {
281
			// append a child operation for the triggers
286
			// append a child operation for the triggers
282
			getChildren().add(new AbstractOperation("") { //$NON-NLS-1$
287
			getChildren().add(new AbstractOperation("") { //$NON-NLS-1$
288
				@Override
283
				public boolean canUndo() {
289
				public boolean canUndo() {
284
					return triggers.canUndo();
290
					return triggers.canUndo();
285
				}
291
				}
286
292
293
				@Override
287
				public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
294
				public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
288
					// this method will never be called
295
					// this method will never be called
289
					triggers.execute();
296
					triggers.execute();
290
					return Status.OK_STATUS;
297
					return Status.OK_STATUS;
291
				}
298
				}
292
299
300
				@Override
293
				public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
301
				public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
294
					triggers.redo();
302
					triggers.redo();
295
					return Status.OK_STATUS;
303
					return Status.OK_STATUS;
296
				}
304
				}
297
305
306
				@Override
298
				public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
307
				public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
299
					triggers.undo();
308
					triggers.undo();
300
					return Status.OK_STATUS;
309
					return Status.OK_STATUS;
Lines 306-317 Link Here
306
	/**
315
	/**
307
	 * I can execute if all of my children can execute.
316
	 * I can execute if all of my children can execute.
308
	 */
317
	 */
318
	@Override
309
	public boolean canExecute() {
319
	public boolean canExecute() {
310
		boolean result = super.canExecute();
320
		boolean result = super.canExecute();
311
		
321
		
312
		if (result) {
322
		if (result) {
313
			for (Iterator iter = iterator(); result && iter.hasNext();) {
323
			for (Iterator<IUndoableOperation> iter = iterator(); result && iter.hasNext();) {
314
				result = ((IUndoableOperation) iter.next()).canExecute();
324
				result = iter.next().canExecute();
315
			}
325
			}
316
		}
326
		}
317
		
327
		
Lines 322-333 Link Here
322
	 * I can undo if my transaction successfully completed with changes recorded
332
	 * I can undo if my transaction successfully completed with changes recorded
323
	 * and my children can all be undone.
333
	 * and my children can all be undone.
324
	 */
334
	 */
335
	@Override
325
	public boolean canUndo() {
336
	public boolean canUndo() {
326
		boolean result = (getChange() != null);
337
		boolean result = (getChange() != null);
327
		
338
		
328
		if (result && isTransactionNestingEnabled()) {
339
		if (result && isTransactionNestingEnabled()) {
329
			for (Iterator iter = iterator(); result && iter.hasNext();) {
340
			for (Iterator<IUndoableOperation> iter = iterator(); result && iter.hasNext();) {
330
				result = ((IUndoableOperation) iter.next()).canUndo();
341
				result = iter.next().canUndo();
331
			}
342
			}
332
		}
343
		}
333
		
344
		
Lines 337-342 Link Here
337
	/**
348
	/**
338
	 * I undo by asking my children to undo, in reverse order.
349
	 * I undo by asking my children to undo, in reverse order.
339
	 */
350
	 */
351
	@Override
340
	protected final IStatus doUndo(IProgressMonitor monitor, IAdaptable info)
352
	protected final IStatus doUndo(IProgressMonitor monitor, IAdaptable info)
341
			throws ExecutionException {
353
			throws ExecutionException {
342
		
354
		
Lines 347-353 Link Here
347
			return super.doUndo(monitor, info);
359
			return super.doUndo(monitor, info);
348
		}
360
		}
349
		
361
		
350
		final List result = new java.util.ArrayList(size());
362
		final List<IStatus> result = new java.util.ArrayList<IStatus>(size());
351
		
363
		
352
		if (monitor == null) {
364
		if (monitor == null) {
353
			monitor = new NullProgressMonitor();
365
			monitor = new NullProgressMonitor();
Lines 356-363 Link Here
356
		ExecutionException caughtException = null;
368
		ExecutionException caughtException = null;
357
		monitor.beginTask(getLabel(), size());
369
		monitor.beginTask(getLabel(), size());
358
		
370
		
359
		for (ListIterator iter = listIterator(size()); iter.hasPrevious();) {
371
		for (ListIterator<IUndoableOperation> iter = listIterator(size());
360
			IUndoableOperation prev = (IUndoableOperation) iter.previous();
372
				iter.hasPrevious();) {
373
			
374
			IUndoableOperation prev = iter.previous();
361
			IStatus status = null;
375
			IStatus status = null;
362
			
376
			
363
			try {
377
			try {
Lines 392-398 Link Here
392
				
406
				
393
				while (iter.hasNext()) {
407
				while (iter.hasNext()) {
394
					// unwind the child operations
408
					// unwind the child operations
395
					IUndoableOperation next = (IUndoableOperation) iter.next();
409
					IUndoableOperation next = iter.next();
396
					if (!next.canRedo()) {
410
					if (!next.canRedo()) {
397
						// oops!  Can't continue unwinding.  Oh, well
411
						// oops!  Can't continue unwinding.  Oh, well
398
						EMFWorkspacePlugin.INSTANCE.log(new Status(
412
						EMFWorkspacePlugin.INSTANCE.log(new Status(
Lines 435-446 Link Here
435
	 * I can redo if my transaction successfully completed with changes recorded
449
	 * I can redo if my transaction successfully completed with changes recorded
436
	 * and my children can all be redone.
450
	 * and my children can all be redone.
437
	 */
451
	 */
452
	@Override
438
	public boolean canRedo() {
453
	public boolean canRedo() {
439
		boolean result = (getChange() != null);
454
		boolean result = (getChange() != null);
440
		
455
		
441
		if (result && isTransactionNestingEnabled()) {
456
		if (result && isTransactionNestingEnabled()) {
442
			for (Iterator iter = iterator(); result && iter.hasNext();) {
457
			for (Iterator<IUndoableOperation> iter = iterator(); result && iter.hasNext();) {
443
				result = ((IUndoableOperation) iter.next()).canRedo();
458
				result = iter.next().canRedo();
444
			}
459
			}
445
		}
460
		}
446
		
461
		
Lines 450-455 Link Here
450
	/**
465
	/**
451
	 * I undo by asking my children to redo, in forward order.
466
	 * I undo by asking my children to redo, in forward order.
452
	 */
467
	 */
468
	@Override
453
	protected final IStatus doRedo(IProgressMonitor monitor, IAdaptable info)
469
	protected final IStatus doRedo(IProgressMonitor monitor, IAdaptable info)
454
			throws ExecutionException {
470
			throws ExecutionException {
455
		
471
		
Lines 460-466 Link Here
460
			return super.doRedo(monitor, info);
476
			return super.doRedo(monitor, info);
461
		}
477
		}
462
		
478
		
463
		final List result = new java.util.ArrayList(size());
479
		final List<IStatus> result = new java.util.ArrayList<IStatus>(size());
464
		
480
		
465
		if (monitor == null) {
481
		if (monitor == null) {
466
			monitor = new NullProgressMonitor();
482
			monitor = new NullProgressMonitor();
Lines 469-476 Link Here
469
		ExecutionException caughtException = null;
485
		ExecutionException caughtException = null;
470
		monitor.beginTask(getLabel(), size());
486
		monitor.beginTask(getLabel(), size());
471
		
487
		
472
		for (ListIterator iter = listIterator(); iter.hasNext();) {
488
		for (ListIterator<IUndoableOperation> iter = listIterator(); iter.hasNext();) {
473
			IUndoableOperation next = (IUndoableOperation) iter.next();
489
			IUndoableOperation next = iter.next();
474
			IStatus status = null;
490
			IStatus status = null;
475
			
491
			
476
			try {
492
			try {
Lines 505-511 Link Here
505
				
521
				
506
				while (iter.hasPrevious()) {
522
				while (iter.hasPrevious()) {
507
					// unwind the child operations
523
					// unwind the child operations
508
					IUndoableOperation prev = (IUndoableOperation) iter.previous();
524
					IUndoableOperation prev = iter.previous();
509
					if (!prev.canUndo()) {
525
					if (!prev.canUndo()) {
510
						// oops!  Can't continue unwinding.  Oh, well
526
						// oops!  Can't continue unwinding.  Oh, well
511
						EMFWorkspacePlugin.INSTANCE.log(new Status(
527
						EMFWorkspacePlugin.INSTANCE.log(new Status(
Lines 545-555 Link Here
545
	/**
561
	/**
546
	 * Removes all of my children and disposes them.
562
	 * Removes all of my children and disposes them.
547
	 */
563
	 */
564
	@Override
548
	public void dispose() {
565
	public void dispose() {
549
		super.dispose();
566
		super.dispose();
550
		
567
		
551
		for (ListIterator iter = listIterator(size()); iter.hasPrevious();) {
568
		for (ListIterator<IUndoableOperation> iter = listIterator(size());
552
			((IUndoableOperation) iter.previous()).dispose();
569
				iter.hasPrevious();) {
570
			
571
			iter.previous().dispose();
553
			iter.remove();
572
			iter.remove();
554
		}
573
		}
555
	}
574
	}
Lines 569-575 Link Here
569
	 * @see #iterator()
588
	 * @see #iterator()
570
	 * @see #listIterator(int)
589
	 * @see #listIterator(int)
571
	 */
590
	 */
572
	protected List getChildren() {
591
	protected List<IUndoableOperation> getChildren() {
573
		return children;
592
		return children;
574
	}
593
	}
575
	
594
	
Lines 665-672 Link Here
665
	private boolean anyChildHasContext(IUndoContext ctx) {
684
	private boolean anyChildHasContext(IUndoContext ctx) {
666
		boolean result = false;
685
		boolean result = false;
667
		
686
		
668
		for (Iterator iter = iterator(); !result && iter.hasNext();) {
687
		for (Iterator<IUndoableOperation> iter = iterator(); !result && iter.hasNext();) {
669
			result = ((IUndoableOperation) iter.next()).hasContext(ctx);
688
			result = iter.next().hasContext(ctx);
670
		}
689
		}
671
		
690
		
672
		return result;
691
		return result;
Lines 677-682 Link Here
677
	 * {@link #setTransactionNestingDisabled(boolean) transaction nesting}
696
	 * {@link #setTransactionNestingDisabled(boolean) transaction nesting}
678
	 * state accordingly.
697
	 * state accordingly.
679
	 */
698
	 */
699
	@Override
680
	void setReuseParentTransaction(boolean reuseParentTransaction) {
700
	void setReuseParentTransaction(boolean reuseParentTransaction) {
681
		super.setReuseParentTransaction(reuseParentTransaction);
701
		super.setReuseParentTransaction(reuseParentTransaction);
682
		
702
		
Lines 744-750 Link Here
744
	 * 
764
	 * 
745
	 * @return an iterator of my children
765
	 * @return an iterator of my children
746
	 */
766
	 */
747
	public Iterator iterator() {
767
	public Iterator<IUndoableOperation> iterator() {
748
		return new ChildIterator();
768
		return new ChildIterator();
749
	}
769
	}
750
	
770
	
Lines 762-768 Link Here
762
	 * 
782
	 * 
763
	 * @return an iterator of my children
783
	 * @return an iterator of my children
764
	 */
784
	 */
765
	public ListIterator listIterator() {
785
	public ListIterator<IUndoableOperation> listIterator() {
766
		return new ChildListIterator(0);
786
		return new ChildListIterator(0);
767
	}
787
	}
768
	
788
	
Lines 783-789 Link Here
783
	 * 
803
	 * 
784
	 * @return an iterator of my children
804
	 * @return an iterator of my children
785
	 */
805
	 */
786
	public ListIterator listIterator(int index) {
806
	public ListIterator<IUndoableOperation> listIterator(int index) {
787
		return new ChildListIterator(index);
807
		return new ChildListIterator(index);
788
	}
808
	}
789
	
809
	
Lines 793-801 Link Here
793
	 *
813
	 *
794
	 * @author Christian W. Damus (cdamus)
814
	 * @author Christian W. Damus (cdamus)
795
	 */
815
	 */
796
	private class ChildIterator implements Iterator {
816
	private class ChildIterator implements Iterator<IUndoableOperation> {
797
		protected Object last;
817
		protected IUndoableOperation last;
798
		protected final ListIterator iter;
818
		protected final ListIterator<IUndoableOperation> iter;
799
	
819
	
800
		ChildIterator() {
820
		ChildIterator() {
801
			this(0);
821
			this(0);
Lines 809-819 Link Here
809
			assertNotExecuted();
829
			assertNotExecuted();
810
			
830
			
811
			iter.remove();
831
			iter.remove();
812
			didRemove((IUndoableOperation) last);
832
			didRemove(last);
813
			last = null;
833
			last = null;
814
		}
834
		}
815
	
835
	
816
		public Object next() {
836
		public IUndoableOperation next() {
817
			last = iter.next();
837
			last = iter.next();
818
			return last;
838
			return last;
819
		}
839
		}
Lines 829-856 Link Here
829
	 *
849
	 *
830
	 * @author Christian W. Damus (cdamus)
850
	 * @author Christian W. Damus (cdamus)
831
	 */
851
	 */
832
	private class ChildListIterator extends ChildIterator implements ListIterator {
852
	private class ChildListIterator extends ChildIterator
853
			implements ListIterator<IUndoableOperation> {
854
		
833
		ChildListIterator(int index) {
855
		ChildListIterator(int index) {
834
			super(index);
856
			super(index);
835
		}
857
		}
836
		
858
		
837
		public void add(Object o) {
859
		public void add(IUndoableOperation o) {
838
			assertNotExecuted();
860
			assertNotExecuted();
839
			
861
			
840
			if (!getChildren().contains(o)) {
862
			if (!getChildren().contains(o)) {
841
				iter.add(o);
863
				iter.add(o);
842
				didAdd((IUndoableOperation) o);
864
				didAdd(o);
843
			}
865
			}
844
		}
866
		}
845
	
867
	
846
		public void set(Object o) {
868
		public void set(IUndoableOperation o) {
847
			assertNotExecuted();
869
			assertNotExecuted();
848
			
870
			
849
			if (!getChildren().contains(o)) {
871
			if (!getChildren().contains(o)) {
850
				didRemove((IUndoableOperation) last);
872
				didRemove(last);
851
				iter.set(o);
873
				iter.set(o);
852
				last = o;
874
				last = o;
853
				didAdd((IUndoableOperation) o);
875
				didAdd(o);
854
			}
876
			}
855
		}
877
		}
856
	
878
	
Lines 862-868 Link Here
862
			return iter.nextIndex();
884
			return iter.nextIndex();
863
		}
885
		}
864
	
886
	
865
		public Object previous() {
887
		public IUndoableOperation previous() {
866
			last = iter.previous();
888
			last = iter.previous();
867
			return last;
889
			return last;
868
		}
890
		}
(-)src/org/eclipse/emf/workspace/AbstractEMFOperation.java (-20 / +26 lines)
Lines 17-23 Link Here
17
package org.eclipse.emf.workspace;
17
package org.eclipse.emf.workspace;
18
18
19
import java.util.Collections;
19
import java.util.Collections;
20
import java.util.Iterator;
21
import java.util.List;
20
import java.util.List;
22
import java.util.Map;
21
import java.util.Map;
23
22
Lines 70-76 Link Here
70
 */
69
 */
71
public abstract class AbstractEMFOperation extends AbstractOperation {
70
public abstract class AbstractEMFOperation extends AbstractOperation {
72
	private final InternalTransactionalEditingDomain domain;
71
	private final InternalTransactionalEditingDomain domain;
73
	private final Map txOptions;
72
	private final Map<Object, Object> txOptions;
74
	
73
	
75
	private Transaction transaction;
74
	private Transaction transaction;
76
	private TransactionChangeDescription change;
75
	private TransactionChangeDescription change;
Lines 97-114 Link Here
97
	 * @param options for the transaction in which I execute myself, or
96
	 * @param options for the transaction in which I execute myself, or
98
	 *     <code>null</code> for the default options
97
	 *     <code>null</code> for the default options
99
	 */
98
	 */
100
	public AbstractEMFOperation(TransactionalEditingDomain domain, String label, Map options) {
99
	public AbstractEMFOperation(TransactionalEditingDomain domain, String label,
100
			Map<?, ?> options) {
101
		
101
		super(label);
102
		super(label);
102
		
103
		
103
		this.domain = (InternalTransactionalEditingDomain) domain;
104
		this.domain = (InternalTransactionalEditingDomain) domain;
104
		if (options == null) {
105
		if (options == null) {
105
			this.txOptions = Collections.singletonMap(TransactionImpl.BLOCK_CHANGE_PROPAGATION, Boolean.TRUE);
106
			this.txOptions = Collections.<Object, Object>singletonMap(
107
				TransactionImpl.BLOCK_CHANGE_PROPAGATION, Boolean.TRUE);
106
		} else {
108
		} else {
107
			// make a defensive copy to
109
			// make a defensive copy to
108
			//  - avoid modifying client's data
110
			//  - avoid modifying client's data
109
			//  - guard against client modifying my map
111
			//  - guard against client modifying my map
110
			//  - avoid exceptions on immutable maps
112
			//  - avoid exceptions on immutable maps
111
			this.txOptions = new java.util.HashMap(options);
113
			this.txOptions = new java.util.HashMap<Object, Object>(options);
112
			this.txOptions.put(TransactionImpl.BLOCK_CHANGE_PROPAGATION, Boolean.TRUE);
114
			this.txOptions.put(TransactionImpl.BLOCK_CHANGE_PROPAGATION, Boolean.TRUE);
113
		}
115
		}
114
	}
116
	}
Lines 120-125 Link Here
120
	 * 
122
	 * 
121
	 * @see #doExecute(IProgressMonitor, IAdaptable)
123
	 * @see #doExecute(IProgressMonitor, IAdaptable)
122
	 */
124
	 */
125
	@Override
123
	public final IStatus execute(IProgressMonitor monitor, IAdaptable info)
126
	public final IStatus execute(IProgressMonitor monitor, IAdaptable info)
124
		throws ExecutionException {
127
		throws ExecutionException {
125
		
128
		
Lines 128-141 Link Here
128
        }
131
        }
129
        
132
        
130
		transaction = null;
133
		transaction = null;
131
		final List result = new java.util.ArrayList(2);
134
		final List<IStatus> result = new java.util.ArrayList<IStatus>(2);
132
		
135
		
133
		try {
136
		try {
134
            // add to the transaction a reference to myself for the
137
            // add to the transaction a reference to myself for the
135
            //   command stack's benefit, unless I would be inheriting
138
            //   command stack's benefit, unless I would be inheriting
136
            //   a reference to a nesting operation
139
            //   a reference to a nesting operation
137
            Map options = new java.util.HashMap(getOptions());
140
            Map<Object, Object> options = new java.util.HashMap<Object, Object>(getOptions());
138
            Map inherited = inheritedOptions();
141
            Map<Object, Object> inherited = inheritedOptions();
139
            if (inherited.containsKey(EMFWorkspacePlugin.OPTION_OWNING_OPERATION)) {
142
            if (inherited.containsKey(EMFWorkspacePlugin.OPTION_OWNING_OPERATION)) {
140
                options.put(EMFWorkspacePlugin.OPTION_OWNING_OPERATION,
143
                options.put(EMFWorkspacePlugin.OPTION_OWNING_OPERATION,
141
                    inherited.get(EMFWorkspacePlugin.OPTION_OWNING_OPERATION));
144
                    inherited.get(EMFWorkspacePlugin.OPTION_OWNING_OPERATION));
Lines 195-201 Link Here
195
	 * @return <code>false</code> if either there is an active transaction and it
198
	 * @return <code>false</code> if either there is an active transaction and it
196
	 *     has the same options as specified; <code>true</code>, otherwise
199
	 *     has the same options as specified; <code>true</code>, otherwise
197
	 */
200
	 */
198
	private boolean optionsDiffer(Map options) {
201
	private boolean optionsDiffer(Map<?, ?> options) {
199
		boolean result = true;
202
		boolean result = true;
200
		
203
		
201
		Transaction active =
204
		Transaction active =
Lines 214-221 Link Here
214
     * @return options currently in effect that would be inherited by a new
217
     * @return options currently in effect that would be inherited by a new
215
     *     transaction that I might create
218
     *     transaction that I might create
216
     */
219
     */
217
    private Map inheritedOptions() {
220
    private Map<Object, Object> inheritedOptions() {
218
        Map result = Collections.EMPTY_MAP;
221
        Map<Object, Object> result = Collections.emptyMap();
219
        
222
        
220
        Transaction active =
223
        Transaction active =
221
            ((InternalTransactionalEditingDomain) getEditingDomain()).getActiveTransaction();
224
            ((InternalTransactionalEditingDomain) getEditingDomain()).getActiveTransaction();
Lines 237-253 Link Here
237
	 * 
240
	 * 
238
	 * @return the multi-status
241
	 * @return the multi-status
239
	 */
242
	 */
240
	protected IStatus aggregateStatuses(List statuses) {
243
	protected IStatus aggregateStatuses(List<? extends IStatus> statuses) {
241
		final IStatus result;
244
		final IStatus result;
242
		
245
		
243
		if (statuses.isEmpty()) {
246
		if (statuses.isEmpty()) {
244
			result = Status.OK_STATUS;
247
			result = Status.OK_STATUS;
245
		} else if (statuses.size() == 1) {
248
		} else if (statuses.size() == 1) {
246
			result = ((IStatus) statuses.get(0));
249
			result = statuses.get(0);
247
		} else {
250
		} else {
248
			// find the most severe status, to use its plug-in, code, and message
251
			// find the most severe status, to use its plug-in, code, and message
249
			IStatus[] children = (IStatus[]) statuses.toArray(
252
			IStatus[] children = statuses.toArray(new IStatus[statuses.size()]);
250
					new IStatus[statuses.size()]);
251
			
253
			
252
			IStatus worst = children[0];
254
			IStatus worst = children[0];
253
			for (int i = 1; i < children.length; i++) {
255
			for (int i = 1; i < children.length; i++) {
Lines 297-305 Link Here
297
	
299
	
298
	private void gatherUndoContextsFromTrigger(Command trigger) {
300
	private void gatherUndoContextsFromTrigger(Command trigger) {
299
		if (trigger instanceof CompoundCommand) {
301
		if (trigger instanceof CompoundCommand) {
300
			for (Iterator i = ((CompoundCommand) trigger).getCommandList()
302
			for (Command next : ((CompoundCommand) trigger).getCommandList()) {
301
				.iterator(); i.hasNext();) {
303
				gatherUndoContextsFromTrigger(next);
302
				gatherUndoContextsFromTrigger((Command)i.next());
303
			}
304
			}
304
		} else if (trigger instanceof EMFOperationCommand) {
305
		} else if (trigger instanceof EMFOperationCommand) {
305
			IUndoContext[] undoContextsToAdd = ((EMFOperationCommand)trigger).getOperation().getContexts();
306
			IUndoContext[] undoContextsToAdd = ((EMFOperationCommand)trigger).getOperation().getContexts();
Lines 316-321 Link Here
316
	 * successfully executed.  Subclasses would not usually need to override
317
	 * successfully executed.  Subclasses would not usually need to override
317
	 * this method.
318
	 * this method.
318
	 */
319
	 */
320
	@Override
319
	public boolean canUndo() {
321
	public boolean canUndo() {
320
		return (getChange() == null) || getChange().canApply();
322
		return (getChange() == null) || getChange().canApply();
321
	}
323
	}
Lines 323-328 Link Here
323
	/**
325
	/**
324
	 * Undoes me by inverting my recorded changes in a transaction.
326
	 * Undoes me by inverting my recorded changes in a transaction.
325
	 */
327
	 */
328
	@Override
326
	public final IStatus undo(IProgressMonitor monitor, IAdaptable info)
329
	public final IStatus undo(IProgressMonitor monitor, IAdaptable info)
327
		throws ExecutionException {
330
		throws ExecutionException {
328
		
331
		
Lines 384-389 Link Here
384
	 * successfully executed.  Subclasses would not usually need to override
387
	 * successfully executed.  Subclasses would not usually need to override
385
	 * this method.
388
	 * this method.
386
	 */
389
	 */
390
	@Override
387
	public boolean canRedo() {
391
	public boolean canRedo() {
388
		return (getChange() == null) || getChange().canApply();
392
		return (getChange() == null) || getChange().canApply();
389
	}
393
	}
Lines 391-396 Link Here
391
	/**
395
	/**
392
	 * Redoes me by replaying my recorded changes in a transaction.
396
	 * Redoes me by replaying my recorded changes in a transaction.
393
	 */
397
	 */
398
	@Override
394
	public final IStatus redo(IProgressMonitor monitor, IAdaptable info)
399
	public final IStatus redo(IProgressMonitor monitor, IAdaptable info)
395
		throws ExecutionException {
400
		throws ExecutionException {
396
		
401
		
Lines 461-467 Link Here
461
	 * 
466
	 * 
462
	 * @return my options, or an empty map if none
467
	 * @return my options, or an empty map if none
463
	 */
468
	 */
464
	public final Map getOptions() {
469
	public final Map<Object, Object> getOptions() {
465
		return txOptions;
470
		return txOptions;
466
	}
471
	}
467
	
472
	
Lines 476-482 Link Here
476
	 * @throws InterruptedException if the current thread was interrupted while
481
	 * @throws InterruptedException if the current thread was interrupted while
477
	 *     waiting for the transaction to start
482
	 *     waiting for the transaction to start
478
	 */
483
	 */
479
	Transaction createTransaction(Map options) throws InterruptedException {
484
	Transaction createTransaction(Map<?, ?> options) throws InterruptedException {
480
		return domain.startTransaction(false, options);
485
		return domain.startTransaction(false, options);
481
	}
486
	}
482
	
487
	
Lines 591-596 Link Here
591
	/**
596
	/**
592
	 * Forgets my transaction and its change description.
597
	 * Forgets my transaction and its change description.
593
	 */
598
	 */
599
	@Override
594
	public void dispose() {
600
	public void dispose() {
595
		super.dispose();
601
		super.dispose();
596
		
602
		
(-)src/org/eclipse/emf/workspace/WorkspaceEditingDomainFactory.java (+2 lines)
Lines 51-56 Link Here
51
	 * 
51
	 * 
52
	 * @return the new editing domain
52
	 * @return the new editing domain
53
	 */
53
	 */
54
	@Override
54
	public TransactionalEditingDomain createEditingDomain() {
55
	public TransactionalEditingDomain createEditingDomain() {
55
		return createEditingDomain(OperationHistoryFactory.getOperationHistory());
56
		return createEditingDomain(OperationHistoryFactory.getOperationHistory());
56
	}
57
	}
Lines 63-68 Link Here
63
	 * 
64
	 * 
64
	 * @return the new editing domain
65
	 * @return the new editing domain
65
	 */
66
	 */
67
	@Override
66
	public TransactionalEditingDomain createEditingDomain(ResourceSet rset) {
68
	public TransactionalEditingDomain createEditingDomain(ResourceSet rset) {
67
		return createEditingDomain(
69
		return createEditingDomain(
68
				rset,
70
				rset,
(-)src/org/eclipse/emf/workspace/EMFOperationCommand.java (-8 / +9 lines)
Lines 20-25 Link Here
20
import java.lang.ref.WeakReference;
20
import java.lang.ref.WeakReference;
21
import java.util.Arrays;
21
import java.util.Arrays;
22
import java.util.Collection;
22
import java.util.Collection;
23
import java.util.Collections;
23
import java.util.Map;
24
import java.util.Map;
24
25
25
import org.eclipse.core.commands.ExecutionException;
26
import org.eclipse.core.commands.ExecutionException;
Lines 62-68 Link Here
62
public class EMFOperationCommand implements ConditionalRedoCommand {
63
public class EMFOperationCommand implements ConditionalRedoCommand {
63
	private final TransactionalEditingDomain domain;
64
	private final TransactionalEditingDomain domain;
64
	private IUndoableOperation operation;
65
	private IUndoableOperation operation;
65
	private Reference adaptable;
66
	private Reference<IAdaptable> adaptable;
66
	
67
	
67
	/**
68
	/**
68
	 * Initializes me with the undoable operation that I wrap.
69
	 * Initializes me with the undoable operation that I wrap.
Lines 102-108 Link Here
102
		this.operation = operation;
103
		this.operation = operation;
103
		
104
		
104
		if (adaptable != null) {
105
		if (adaptable != null) {
105
			this.adaptable = new WeakReference(adaptable);
106
			this.adaptable = new WeakReference<IAdaptable>(adaptable);
106
		}
107
		}
107
	}
108
	}
108
	
109
	
Lines 188-194 Link Here
188
	private Transaction createNonEMFTransaction(
189
	private Transaction createNonEMFTransaction(
189
			IUndoableOperation operation,
190
			IUndoableOperation operation,
190
			IAdaptable info,
191
			IAdaptable info,
191
			Map options)
192
			Map<?, ?> options)
192
			throws InterruptedException {
193
			throws InterruptedException {
193
		
194
		
194
		InternalTransaction result = new NonEMFTransaction(
195
		InternalTransaction result = new NonEMFTransaction(
Lines 268-283 Link Here
268
	}
269
	}
269
270
270
	// Documentation copied from the inherited specification
271
	// Documentation copied from the inherited specification
271
	public Collection getResult() {
272
	public Collection<?> getResult() {
272
		return null;
273
		return Collections.EMPTY_LIST;
273
	}
274
	}
274
275
275
	/**
276
	/**
276
	 * Obtains the affected objects from my wrapped operation, if it is an
277
	 * Obtains the affected objects from my wrapped operation, if it is an
277
	 * {@link IAdvancedUndoableOperation}. 
278
	 * {@link IAdvancedUndoableOperation}. 
278
	 */
279
	 */
279
	public Collection getAffectedObjects() {
280
	public Collection<?> getAffectedObjects() {
280
		Collection result = null;
281
		Collection<Object> result = null;
281
		
282
		
282
		if (operation instanceof IAdvancedUndoableOperation) {
283
		if (operation instanceof IAdvancedUndoableOperation) {
283
			Object[] affected = ((IAdvancedUndoableOperation) operation).getAffectedObjects();
284
			Object[] affected = ((IAdvancedUndoableOperation) operation).getAffectedObjects();
Lines 339-345 Link Here
339
		IAdaptable result = null;
340
		IAdaptable result = null;
340
		
341
		
341
		if (adaptable != null) {
342
		if (adaptable != null) {
342
			result = (IAdaptable) adaptable.get();
343
			result = adaptable.get();
343
		}
344
		}
344
		
345
		
345
		return result;
346
		return result;
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)build.properties (-2 / +2 lines)
Lines 22-26 Link Here
22
               modeling32.png,\
22
               modeling32.png,\
23
               plugin.properties
23
               plugin.properties
24
src.includes = about.html
24
src.includes = about.html
25
javacSource = 1.4
25
javacSource = 1.5
26
javacTarget = 1.4
26
javacTarget = 1.5
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 16-19 Link Here
16
 org.eclipse.emf.workspace.internal;x-friends:="org.eclipse.emf.workspace.tests",
16
 org.eclipse.emf.workspace.internal;x-friends:="org.eclipse.emf.workspace.tests",
17
 org.eclipse.emf.workspace.internal.l10n;x-friends:="org.eclipse.emf.workspace.tests",
17
 org.eclipse.emf.workspace.internal.l10n;x-friends:="org.eclipse.emf.workspace.tests",
18
 org.eclipse.emf.workspace.util
18
 org.eclipse.emf.workspace.util
19
Bundle-RequiredExecutionEnvironment: J2SE-1.4
19
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)src/org/eclipse/emf/workspace/impl/NonEMFTransaction.java (-5 / +6 lines)
Lines 64-70 Link Here
64
	public NonEMFTransaction(TransactionalEditingDomain domain,
64
	public NonEMFTransaction(TransactionalEditingDomain domain,
65
			IUndoableOperation operation,
65
			IUndoableOperation operation,
66
			IAdaptable info,
66
			IAdaptable info,
67
			Map options) {
67
			Map<?, ?> options) {
68
		super(domain, false, customizeOptions(options));
68
		super(domain, false, customizeOptions(options));
69
		
69
		
70
		this.operation = operation;
70
		this.operation = operation;
Lines 80-86 Link Here
80
	 * @return A new map of options that should be passed to the superclass to
80
	 * @return A new map of options that should be passed to the superclass to
81
	 *  become our official set of options.
81
	 *  become our official set of options.
82
	 */
82
	 */
83
	private static Map customizeOptions(Map options) {
83
	private static Map<?, ?> customizeOptions(Map<?, ?> options) {
84
		// Copy the options and add the special non-change description propagation
84
		// Copy the options and add the special non-change description propagation
85
		//  option. We do this because if by any chance that the child operation
85
		//  option. We do this because if by any chance that the child operation
86
		//  invokes some AbstractEMFOperation again then it will be handling the
86
		//  invokes some AbstractEMFOperation again then it will be handling the
Lines 88-102 Link Here
88
		//  transactions by default will propagate all of the change descriptions upward.
88
		//  transactions by default will propagate all of the change descriptions upward.
89
		//  This can cause situations where the same change description object is applied
89
		//  This can cause situations where the same change description object is applied
90
		//  and reversed twice.
90
		//  and reversed twice.
91
		options = new HashMap(options);
91
		Map<Object, Object> result = new HashMap<Object, Object>(options);
92
		options.put(TransactionImpl.ALLOW_CHANGE_PROPAGATION_BLOCKING, Boolean.TRUE);
92
		result.put(TransactionImpl.ALLOW_CHANGE_PROPAGATION_BLOCKING, true);
93
		
93
		
94
		return options;
94
		return result;
95
	}
95
	}
96
96
97
	/**
97
	/**
98
	 * Appends my non-EMF change and commits.
98
	 * Appends my non-EMF change and commits.
99
	 */
99
	 */
100
	@Override
100
	public void commit() throws RollbackException {
101
	public void commit() throws RollbackException {
101
		change.add(new OperationChangeDescription(operation, info));
102
		change.add(new OperationChangeDescription(operation, info));
102
		
103
		
(-)src/org/eclipse/emf/workspace/impl/WorkspaceCommandStackImpl.java (-21 / +34 lines)
Lines 17-23 Link Here
17
package org.eclipse.emf.workspace.impl;
17
package org.eclipse.emf.workspace.impl;
18
18
19
import java.util.Collection;
19
import java.util.Collection;
20
import java.util.Iterator;
21
import java.util.List;
20
import java.util.List;
22
import java.util.Map;
21
import java.util.Map;
23
import java.util.Set;
22
import java.util.Set;
Lines 95-100 Link Here
95
     * Extends the superclass implementation to add/remove listeners on the
94
     * Extends the superclass implementation to add/remove listeners on the
96
     * editing domain.
95
     * editing domain.
97
	 */
96
	 */
97
	@Override
98
	public void setEditingDomain(InternalTransactionalEditingDomain domain) {
98
	public void setEditingDomain(InternalTransactionalEditingDomain domain) {
99
        InternalTransactionalEditingDomain oldDomain = getDomain();
99
        InternalTransactionalEditingDomain oldDomain = getDomain();
100
        
100
        
Lines 133-139 Link Here
133
     * 
133
     * 
134
     *  @since 1.1
134
     *  @since 1.1
135
	 */
135
	 */
136
	protected void doExecute(Command command, Map options)
136
	@Override
137
	protected void doExecute(Command command, Map<?, ?> options)
137
			throws InterruptedException, RollbackException {
138
			throws InterruptedException, RollbackException {
138
		EMFCommandOperation oper = new EMFCommandOperation(getDomain(), command, options);
139
		EMFCommandOperation oper = new EMFCommandOperation(getDomain(), command, options);
139
		
140
		
Lines 177-182 Link Here
177
	/**
178
	/**
178
	 * Queries whether we can undo my default undo context in my operation history.
179
	 * Queries whether we can undo my default undo context in my operation history.
179
	 */
180
	 */
181
	@Override
180
	public boolean canUndo() {
182
	public boolean canUndo() {
181
		return getOperationHistory().canUndo(getDefaultUndoContext());
183
		return getOperationHistory().canUndo(getDefaultUndoContext());
182
	}
184
	}
Lines 184-189 Link Here
184
	/**
186
	/**
185
	 * Undoes my default undo context in my operation history.
187
	 * Undoes my default undo context in my operation history.
186
	 */
188
	 */
189
	@Override
187
	public void undo() {
190
	public void undo() {
188
		try {
191
		try {
189
			getOperationHistory().undo(
192
			getOperationHistory().undo(
Lines 205-210 Link Here
205
	/**
208
	/**
206
	 * Queries whether we can redo my default undo context in my operation history.
209
	 * Queries whether we can redo my default undo context in my operation history.
207
	 */
210
	 */
211
	@Override
208
	public boolean canRedo() {
212
	public boolean canRedo() {
209
		return getOperationHistory().canRedo(getDefaultUndoContext());
213
		return getOperationHistory().canRedo(getDefaultUndoContext());
210
	}
214
	}
Lines 212-217 Link Here
212
	/**
216
	/**
213
	 * Redoes my default undo context in my operation history.
217
	 * Redoes my default undo context in my operation history.
214
	 */
218
	 */
219
	@Override
215
	public void redo() {
220
	public void redo() {
216
		try {
221
		try {
217
			getOperationHistory().redo(
222
			getOperationHistory().redo(
Lines 233-238 Link Here
233
	/**
238
	/**
234
	 * Disposes my default undo context in my operation history.
239
	 * Disposes my default undo context in my operation history.
235
	 */
240
	 */
241
	@Override
236
	public void flush() {
242
	public void flush() {
237
		getOperationHistory().dispose(
243
		getOperationHistory().dispose(
238
				getDefaultUndoContext(),
244
				getDefaultUndoContext(),
Lines 250-255 Link Here
250
	 * Gets the command from the most recently executed, done, or redone
256
	 * Gets the command from the most recently executed, done, or redone
251
	 * operation.
257
	 * operation.
252
	 */
258
	 */
259
	@Override
253
	public Command getMostRecentCommand() {
260
	public Command getMostRecentCommand() {
254
		Command result = null;
261
		Command result = null;
255
		
262
		
Lines 263-268 Link Here
263
	/**
270
	/**
264
	 * Gets the command from the top of the undo history, if any.
271
	 * Gets the command from the top of the undo history, if any.
265
	 */
272
	 */
273
	@Override
266
	public Command getUndoCommand() {
274
	public Command getUndoCommand() {
267
		Command result = null;
275
		Command result = null;
268
		
276
		
Lines 279-284 Link Here
279
	/**
287
	/**
280
	 * Gets the command from the top of the redo history, if any.
288
	 * Gets the command from the top of the redo history, if any.
281
	 */
289
	 */
290
	@Override
282
	public Command getRedoCommand() {
291
	public Command getRedoCommand() {
283
		Command result = null;
292
		Command result = null;
284
		
293
		
Lines 293-299 Link Here
293
	}
302
	}
294
	
303
	
295
	// Documentation copied from the method specification
304
	// Documentation copied from the method specification
296
	public EMFCommandTransaction createTransaction(Command command, Map options) throws InterruptedException {
305
	public EMFCommandTransaction createTransaction(Command command,
306
			Map<?, ?> options) throws InterruptedException {
307
		
297
		EMFCommandTransaction result;
308
		EMFCommandTransaction result;
298
		
309
		
299
		if (command instanceof TriggerCommand) {
310
		if (command instanceof TriggerCommand) {
Lines 309-315 Link Here
309
	}
320
	}
310
321
311
	// Documentation copied from the method specification
322
	// Documentation copied from the method specification
312
	public void executeTriggers(Command command, List triggers, Map options) throws InterruptedException, RollbackException {
323
	public void executeTriggers(Command command, List<Command> triggers,
324
			Map<?, ?> options) throws InterruptedException, RollbackException {
325
		
313
		if (!triggers.isEmpty()) {
326
		if (!triggers.isEmpty()) {
314
			TriggerCommand trigger = (command == null)
327
			TriggerCommand trigger = (command == null)
315
				? new TriggerCommand(triggers)
328
				? new TriggerCommand(triggers)
Lines 390-395 Link Here
390
			}
403
			}
391
		}
404
		}
392
		
405
		
406
		@Override
393
		public void resourceSetChanged(ResourceSetChangeEvent event) {
407
		public void resourceSetChanged(ResourceSetChangeEvent event) {
394
            IUndoableOperation operation = null;
408
            IUndoableOperation operation = null;
395
            
409
            
Lines 399-418 Link Here
399
                    EMFWorkspacePlugin.OPTION_OWNING_OPERATION);
413
                    EMFWorkspacePlugin.OPTION_OWNING_OPERATION);
400
            }
414
            }
401
            
415
            
402
            Set affectedResources = ResourceUndoContext.getAffectedResources(
416
            Set<Resource> affectedResources = ResourceUndoContext.getAffectedResources(
403
                event.getNotifications());
417
                event.getNotifications());
404
            
418
            
405
			Set unloaded = getUnloadedResources(event.getNotifications());
419
			Set<Resource> unloaded = getUnloadedResources(event.getNotifications());
406
			if (unloaded != null) {
420
			if (unloaded != null) {
407
				// don't add these resources to the operation
421
				// don't add these resources to the operation
408
				affectedResources.removeAll(unloaded);
422
				affectedResources.removeAll(unloaded);
409
				
423
				
410
                // dispose their undo contexts
424
                // dispose their undo contexts
411
				for (Iterator iter = unloaded.iterator(); iter.hasNext();) {
425
				for (Resource next : unloaded) {
412
					getOperationHistory().dispose(
426
					getOperationHistory().dispose(
413
							new ResourceUndoContext(
427
							new ResourceUndoContext(getDomain(), next),
414
									getDomain(),
415
									(Resource) iter.next()),
416
							true, true, true);
428
							true, true, true);
417
				}
429
				}
418
			}
430
			}
Lines 420-429 Link Here
420
            if ((operation != null) && !affectedResources.isEmpty()) {
432
            if ((operation != null) && !affectedResources.isEmpty()) {
421
                // add any resource undo contexts to this operation that are
433
                // add any resource undo contexts to this operation that are
422
                //   not already applied
434
                //   not already applied
423
                for (Iterator iter = affectedResources.iterator(); iter.hasNext();) {
435
                for (Resource next : affectedResources) {
424
                    ResourceUndoContext ctx = new ResourceUndoContext(
436
                    ResourceUndoContext ctx = new ResourceUndoContext(
425
                        getDomain(),
437
                        getDomain(), next);
426
                        (Resource) iter.next());
427
                    
438
                    
428
                    if (!operation.hasContext(ctx)) {
439
                    if (!operation.hasContext(ctx)) {
429
                        operation.addContext(ctx);
440
                        operation.addContext(ctx);
Lines 439-479 Link Here
439
		 * @return a set of resources that the notifications indicate have been
450
		 * @return a set of resources that the notifications indicate have been
440
		 *     unloaded, or <code>null</code> if none
451
		 *     unloaded, or <code>null</code> if none
441
		 */
452
		 */
442
		private Set getUnloadedResources(Collection notifications) {
453
		private Set<Resource> getUnloadedResources(Collection<Notification> notifications) {
443
			Set result = null;
454
			Set<Resource> result = null;
444
			
455
			
445
			for (Iterator iter = notifications.iterator(); iter.hasNext();) {
456
			for (Notification next : notifications) {
446
				Notification next = (Notification) iter.next();
447
				
448
				if (NotificationFilter.RESOURCE_UNLOADED.matches(next)) {
457
				if (NotificationFilter.RESOURCE_UNLOADED.matches(next)) {
449
					if (result == null) {
458
					if (result == null) {
450
						result = new java.util.HashSet();
459
						result = new java.util.HashSet<Resource>();
451
					}
460
					}
452
					
461
					
453
					result.add(next.getNotifier());
462
					result.add((Resource) next.getNotifier());
454
				}
463
				}
455
			}
464
			}
456
			
465
			
457
			return result;
466
			return result;
458
		}
467
		}
459
		
468
		
469
		@Override
460
		public boolean isPostcommitOnly() {
470
		public boolean isPostcommitOnly() {
461
			// only interested in post-commit "resourceSetChanged" event
471
			// only interested in post-commit "resourceSetChanged" event
462
			return true;
472
			return true;
463
		}
473
		}
464
	}
474
	}
465
	
475
	
476
	@Override
466
	public boolean isSaveNeeded() {
477
	public boolean isSaveNeeded() {
467
		// We override the execute method and never call the super implementation
478
		// We override the execute method and never call the super implementation
468
		//  so we have to implement the isSaveNeeded method ourselves.
479
		//  so we have to implement the isSaveNeeded method ourselves.
469
		IUndoableOperation nextUndoableOperation = history.getUndoOperation(getDefaultUndoContext());
480
		IUndoableOperation nextUndoableOperation = history.getUndoOperation(getDefaultUndoContext());
470
		
481
		
471
		if (nextUndoableOperation == null)
482
		if (nextUndoableOperation == null) {
472
			return false;
483
			return false;
484
		}
473
		
485
		
474
		return savedContext != null ? !nextUndoableOperation.hasContext(getSavedContext()) : true;
486
		return savedContext != null ? !nextUndoableOperation.hasContext(getSavedContext()) : true;
475
	}
487
	}
476
	
488
	
489
	@Override
477
	public void saveIsDone() {
490
	public void saveIsDone() {
478
		// We override the execute method and never call the super implementation
491
		// We override the execute method and never call the super implementation
479
		//  so we have to implement the saveIsDone method ourselves.
492
		//  so we have to implement the saveIsDone method ourselves.
(-)src/org/eclipse/emf/workspace/impl/EMFOperationTransaction.java (-1 / +2 lines)
Lines 41-47 Link Here
41
	 * @param domain my editing domain
41
	 * @param domain my editing domain
42
	 * @param options my options
42
	 * @param options my options
43
	 */
43
	 */
44
	public EMFOperationTransaction(Command command, InternalTransactionalEditingDomain domain, Map options) {
44
	public EMFOperationTransaction(Command command,
45
			InternalTransactionalEditingDomain domain, Map<?, ?> options) {
45
		super(command, domain, options);
46
		super(command, domain, options);
46
	}
47
	}
47
48
(-)build.properties (-2 / +2 lines)
Lines 17-21 Link Here
17
               plugin.properties,\
17
               plugin.properties,\
18
               about.html
18
               about.html
19
src.includes = about.html
19
src.includes = about.html
20
javacSource = 1.4
20
javacSource = 1.5
21
javacTarget = 1.4
21
javacTarget = 1.5
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)META-INF/MANIFEST.MF (-4 / +4 lines)
Lines 2-16 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Plugin.name
3
Bundle-Name: %Plugin.name
4
Bundle-SymbolicName: org.eclipse.emf.transaction.ui
4
Bundle-SymbolicName: org.eclipse.emf.transaction.ui
5
Bundle-Version: 1.0.100.qualifier
5
Bundle-Version: 1.2.0.qualifier
6
Bundle-Vendor: %Plugin.providerName
6
Bundle-Vendor: %Plugin.providerName
7
Bundle-Localization: plugin
7
Bundle-Localization: plugin
8
Require-Bundle: org.eclipse.emf.edit.ui;bundle-version="[2.2.0,3.0.0)",
8
Require-Bundle: org.eclipse.emf.edit.ui;bundle-version="[2.3.0,3.0.0)",
9
 org.eclipse.emf.transaction;bundle-version="[1.0.0,2.0.0)"
9
 org.eclipse.emf.transaction;bundle-version="[1.2.0,2.0.0)"
10
Eclipse-LazyStart: true
10
Eclipse-LazyStart: true
11
Bundle-Activator: org.eclipse.emf.transaction.ui.internal.EMFTransactionUIPlugin$Implementation
11
Bundle-Activator: org.eclipse.emf.transaction.ui.internal.EMFTransactionUIPlugin$Implementation
12
Export-Package: org.eclipse.emf.transaction.ui.internal;x-internal:=true,
12
Export-Package: org.eclipse.emf.transaction.ui.internal;x-internal:=true,
13
 org.eclipse.emf.transaction.ui.internal.l10n;x-internal:=true,
13
 org.eclipse.emf.transaction.ui.internal.l10n;x-internal:=true,
14
 org.eclipse.emf.transaction.ui.provider,
14
 org.eclipse.emf.transaction.ui.provider,
15
 org.eclipse.emf.transaction.ui.view
15
 org.eclipse.emf.transaction.ui.view
16
Bundle-RequiredExecutionEnvironment: J2SE-1.4
16
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)src/org/eclipse/emf/transaction/ui/provider/TransactionalAdapterFactoryContentProvider.java (-13 / +20 lines)
Lines 27-32 Link Here
27
import org.eclipse.emf.transaction.ui.internal.EMFTransactionUIStatusCodes;
27
import org.eclipse.emf.transaction.ui.internal.EMFTransactionUIStatusCodes;
28
import org.eclipse.emf.transaction.ui.internal.Tracing;
28
import org.eclipse.emf.transaction.ui.internal.Tracing;
29
import org.eclipse.emf.transaction.ui.internal.l10n.Messages;
29
import org.eclipse.emf.transaction.ui.internal.l10n.Messages;
30
import org.eclipse.emf.transaction.util.TransactionUtil;
30
import org.eclipse.jface.viewers.Viewer;
31
import org.eclipse.jface.viewers.Viewer;
31
import org.eclipse.ui.views.properties.IPropertySource;
32
import org.eclipse.ui.views.properties.IPropertySource;
32
33
Lines 61-73 Link Here
61
	 * Runs the specified runnable in the editing domain, with interrupt
62
	 * Runs the specified runnable in the editing domain, with interrupt
62
	 * handling.
63
	 * handling.
63
	 * 
64
	 * 
65
	 * @param <T> the result type of the runnable
66
	 * 
64
	 * @param run the runnable to run
67
	 * @param run the runnable to run
65
	 * 
68
	 * 
66
	 * @return its result, or <code>null</code> on interrupt
69
	 * @return its result, or <code>null</code> on interrupt
67
	 */
70
	 */
68
	protected Object run(RunnableWithResult run) {
71
	protected <T> T run(RunnableWithResult<? extends T> run) {
69
		try {
72
		try {
70
			return domain.runExclusive(run);
73
			return TransactionUtil.runExclusive(domain, run);
71
		} catch (InterruptedException e) {
74
		} catch (InterruptedException e) {
72
			Tracing.catching(TransactionalAdapterFactoryContentProvider.class, "run", e); //$NON-NLS-1$
75
			Tracing.catching(TransactionalAdapterFactoryContentProvider.class, "run", e); //$NON-NLS-1$
73
			
76
			
Lines 89-96 Link Here
89
	 * Extends the inherited implementation by running in a read-only transaction.
92
	 * Extends the inherited implementation by running in a read-only transaction.
90
	 * The returned property source also uses transactions to access properties.
93
	 * The returned property source also uses transactions to access properties.
91
	 */
94
	 */
95
	@Override
92
	protected IPropertySource createPropertySource(final Object object, final IItemPropertySource itemPropertySource) {
96
	protected IPropertySource createPropertySource(final Object object, final IItemPropertySource itemPropertySource) {
93
		return wrap((IPropertySource) run(new RunnableWithResult.Impl() {
97
		return wrap(run(new RunnableWithResult.Impl<IPropertySource>() {
94
			public void run() {
98
			public void run() {
95
				setResult(TransactionalAdapterFactoryContentProvider.super.createPropertySource(object, itemPropertySource));
99
				setResult(TransactionalAdapterFactoryContentProvider.super.createPropertySource(object, itemPropertySource));
96
			}}));
100
			}}));
Lines 99-106 Link Here
99
	/**
103
	/**
100
	 * Extends the inherited implementation by running in a read-only transaction.
104
	 * Extends the inherited implementation by running in a read-only transaction.
101
	 */
105
	 */
106
	@Override
102
	public Object[] getChildren(final Object object) {
107
	public Object[] getChildren(final Object object) {
103
		return (Object[]) run(new RunnableWithResult.Impl() {
108
		return run(new RunnableWithResult.Impl<Object[]>() {
104
			public void run() {
109
			public void run() {
105
				setResult(TransactionalAdapterFactoryContentProvider.super.getChildren(object));
110
				setResult(TransactionalAdapterFactoryContentProvider.super.getChildren(object));
106
			}});
111
			}});
Lines 109-116 Link Here
109
	/**
114
	/**
110
	 * Extends the inherited implementation by running in a read-only transaction.
115
	 * Extends the inherited implementation by running in a read-only transaction.
111
	 */
116
	 */
117
	@Override
112
	public Object[] getElements(final Object object) {
118
	public Object[] getElements(final Object object) {
113
		return (Object[]) run(new RunnableWithResult.Impl() {
119
		return run(new RunnableWithResult.Impl<Object[]>() {
114
			public void run() {
120
			public void run() {
115
				setResult(TransactionalAdapterFactoryContentProvider.super.getElements(object));
121
				setResult(TransactionalAdapterFactoryContentProvider.super.getElements(object));
116
			}});
122
			}});
Lines 119-126 Link Here
119
	/**
125
	/**
120
	 * Extends the inherited implementation by running in a read-only transaction.
126
	 * Extends the inherited implementation by running in a read-only transaction.
121
	 */
127
	 */
128
	@Override
122
	public Object getParent(final Object object) {
129
	public Object getParent(final Object object) {
123
		return run(new RunnableWithResult.Impl() {
130
		return run(new RunnableWithResult.Impl<Object>() {
124
			public void run() {
131
			public void run() {
125
				setResult(TransactionalAdapterFactoryContentProvider.super.getParent(object));
132
				setResult(TransactionalAdapterFactoryContentProvider.super.getParent(object));
126
			}});
133
			}});
Lines 130-137 Link Here
130
	 * Extends the inherited implementation by running in a read-only transaction.
137
	 * Extends the inherited implementation by running in a read-only transaction.
131
	 * The returned property source also uses transactions to access properties.
138
	 * The returned property source also uses transactions to access properties.
132
	 */
139
	 */
140
	@Override
133
	public IPropertySource getPropertySource(final Object object) {
141
	public IPropertySource getPropertySource(final Object object) {
134
		return wrap((IPropertySource) run(new RunnableWithResult.Impl() {
142
		return wrap(run(new RunnableWithResult.Impl<IPropertySource>() {
135
			public void run() {
143
			public void run() {
136
				setResult(TransactionalAdapterFactoryContentProvider.super.getPropertySource(object));
144
				setResult(TransactionalAdapterFactoryContentProvider.super.getPropertySource(object));
137
			}}));
145
			}}));
Lines 140-160 Link Here
140
	/**
148
	/**
141
	 * Extends the inherited implementation by running in a read-only transaction.
149
	 * Extends the inherited implementation by running in a read-only transaction.
142
	 */
150
	 */
151
	@Override
143
	public boolean hasChildren(final Object object) {
152
	public boolean hasChildren(final Object object) {
144
		Boolean result = (Boolean) run(new RunnableWithResult.Impl() {
153
		return run(new RunnableWithResult.Impl<Boolean>() {
145
			public void run() {
154
			public void run() {
146
				setResult(TransactionalAdapterFactoryContentProvider.super.hasChildren(object)
155
				setResult(TransactionalAdapterFactoryContentProvider.super.hasChildren(object));
147
						? Boolean.TRUE : Boolean.FALSE);
148
			}});
156
			}});
149
		
150
		return (result == null) ? false : result.booleanValue();
151
	}
157
	}
152
158
153
	/**
159
	/**
154
	 * Extends the inherited implementation by running in a read-only transaction.
160
	 * Extends the inherited implementation by running in a read-only transaction.
155
	 */
161
	 */
162
	@Override
156
	public void inputChanged(final Viewer vwr, final Object oldInput, final Object newInput) { 
163
	public void inputChanged(final Viewer vwr, final Object oldInput, final Object newInput) { 
157
		run(new RunnableWithResult.Impl() {
164
		run(new RunnableWithResult.Impl<Object>() {
158
			public void run() {
165
			public void run() {
159
				TransactionalAdapterFactoryContentProvider.super.inputChanged(vwr, oldInput, newInput);
166
				TransactionalAdapterFactoryContentProvider.super.inputChanged(vwr, oldInput, newInput);
160
			}});
167
			}});
(-)src/org/eclipse/emf/transaction/ui/provider/TransactionalPropertySource.java (-168 / +168 lines)
Lines 1-168 Link Here
1
/**
1
/**
2
 * <copyright> 
2
 * <copyright> 
3
 *
3
 *
4
 * Copyright (c) 2005, 2006 IBM Corporation and others.
4
 * Copyright (c) 2005, 2006 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 * 
9
 * 
10
 * Contributors: 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
11
 *   IBM - Initial API and implementation
12
 *
12
 *
13
 * </copyright>
13
 * </copyright>
14
 *
14
 *
15
 * $Id: TransactionalPropertySource.java,v 1.1 2006/01/30 19:47:45 cdamus Exp $
15
 * $Id: TransactionalPropertySource.java,v 1.1 2006/01/30 19:47:45 cdamus Exp $
16
 */
16
 */
17
package org.eclipse.emf.transaction.ui.provider;
17
package org.eclipse.emf.transaction.ui.provider;
18
18
19
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.Status;
20
import org.eclipse.core.runtime.Status;
21
import org.eclipse.emf.transaction.RunnableWithResult;
21
import org.eclipse.emf.transaction.RunnableWithResult;
22
import org.eclipse.emf.transaction.TransactionalEditingDomain;
22
import org.eclipse.emf.transaction.Transaction;
23
import org.eclipse.emf.transaction.Transaction;
23
import org.eclipse.emf.transaction.TransactionalEditingDomain;
24
import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
24
import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
25
import org.eclipse.emf.transaction.ui.internal.EMFTransactionUIPlugin;
25
import org.eclipse.emf.transaction.ui.internal.EMFTransactionUIPlugin;
26
import org.eclipse.emf.transaction.ui.internal.EMFTransactionUIStatusCodes;
26
import org.eclipse.emf.transaction.ui.internal.EMFTransactionUIStatusCodes;
27
import org.eclipse.emf.transaction.ui.internal.Tracing;
27
import org.eclipse.emf.transaction.ui.internal.Tracing;
28
import org.eclipse.emf.transaction.ui.internal.l10n.Messages;
28
import org.eclipse.emf.transaction.ui.internal.l10n.Messages;
29
import org.eclipse.ui.views.properties.IPropertyDescriptor;
29
import org.eclipse.emf.transaction.util.TransactionUtil;
30
import org.eclipse.ui.views.properties.IPropertySource;
30
import org.eclipse.ui.views.properties.IPropertyDescriptor;
31
import org.eclipse.ui.views.properties.IPropertySource2;
31
import org.eclipse.ui.views.properties.IPropertySource;
32
32
import org.eclipse.ui.views.properties.IPropertySource2;
33
33
34
/**
34
35
 * A property source wrapper that calls its delegate in transactions of the
35
/**
36
 * appropriate kind.  Note that transactions are not actually required for
36
 * A property source wrapper that calls its delegate in transactions of the
37
 * methods that do not access model objects.
37
 * appropriate kind.  Note that transactions are not actually required for
38
 * 
38
 * methods that do not access model objects.
39
 * @author Christian W. Damus (cdamus)
39
 * 
40
 */
40
 * @author Christian W. Damus (cdamus)
41
public class TransactionalPropertySource
41
 */
42
	implements IPropertySource2 {
42
public class TransactionalPropertySource
43
43
	implements IPropertySource2 {
44
	private final TransactionalEditingDomain domain;
44
45
	
45
	private final TransactionalEditingDomain domain;
46
	private final IPropertySource propertySource;
46
	
47
	private final IPropertySource2 propertySource2;
47
	private final IPropertySource propertySource;
48
	
48
	private final IPropertySource2 propertySource2;
49
	/**
49
	
50
	 * Initializes me with the editing domain in which I create transactions,
50
	/**
51
	 * and the property source that I delegate to.
51
	 * Initializes me with the editing domain in which I create transactions,
52
	 * 
52
	 * and the property source that I delegate to.
53
	 * @param domain my editing domain
53
	 * 
54
	 * @param propertySource my delegate
54
	 * @param domain my editing domain
55
	 */
55
	 * @param propertySource my delegate
56
	public TransactionalPropertySource(TransactionalEditingDomain domain, IPropertySource propertySource) {
56
	 */
57
		this.domain = domain;
57
	public TransactionalPropertySource(TransactionalEditingDomain domain, IPropertySource propertySource) {
58
		
58
		this.domain = domain;
59
		this.propertySource = propertySource;
59
		
60
		this.propertySource2 = (propertySource instanceof IPropertySource2)
60
		this.propertySource = propertySource;
61
			? (IPropertySource2) propertySource
61
		this.propertySource2 = (propertySource instanceof IPropertySource2)
62
			: null;
62
			? (IPropertySource2) propertySource
63
	}
63
			: null;
64
64
	}
65
	/**
65
66
	 * Runs the specified runnable in the editing domain, with interrupt
66
	/**
67
	 * handling.
67
	 * Runs the specified runnable in the editing domain, with interrupt
68
	 * 
68
	 * handling.
69
	 * @param run the runnable to run
69
	 * 
70
	 * 
70
	 * @param <T> the result type of the runnable
71
	 * @return its result, or <code>null</code> on interrupt
71
	 * 
72
	 */
72
	 * @param run the runnable to run
73
	protected Object run(RunnableWithResult run) {
73
	 * 
74
		try {
74
	 * @return its result, or <code>null</code> on interrupt
75
			return domain.runExclusive(run);
75
	 */
76
		} catch (InterruptedException e) {
76
	protected <T> T run(RunnableWithResult<? extends T> run) {
77
			Tracing.catching(TransactionalPropertySource.class, "run", e); //$NON-NLS-1$
77
		try {
78
			
78
			return TransactionUtil.runExclusive(domain, run);
79
			// propagate interrupt status because we are not throwing
79
		} catch (InterruptedException e) {
80
			Thread.currentThread().interrupt();
80
			Tracing.catching(TransactionalPropertySource.class, "run", e); //$NON-NLS-1$
81
			
81
			
82
			EMFTransactionUIPlugin.INSTANCE.log(new Status(
82
			// propagate interrupt status because we are not throwing
83
				IStatus.ERROR,
83
			Thread.currentThread().interrupt();
84
				EMFTransactionUIPlugin.getPluginId(),
84
			
85
				EMFTransactionUIStatusCodes.PROPERTY_SHEET_INTERRUPTED,
85
			EMFTransactionUIPlugin.INSTANCE.log(new Status(
86
				Messages.propertyInterrupt,
86
				IStatus.ERROR,
87
				e));
87
				EMFTransactionUIPlugin.getPluginId(),
88
			
88
				EMFTransactionUIStatusCodes.PROPERTY_SHEET_INTERRUPTED,
89
			return null;
89
				Messages.propertyInterrupt,
90
		}
90
				e));
91
	}
91
			
92
92
			return null;
93
	/**
93
		}
94
	 * Delegates the my wrapped property source in the appropriate transaction.
94
	}
95
	 */
95
96
	public boolean isPropertyResettable(Object id) {
96
	/**
97
		return (propertySource2 == null)? false
97
	 * Delegates the my wrapped property source in the appropriate transaction.
98
				: propertySource2.isPropertyResettable(id);
98
	 */
99
	}
99
	public boolean isPropertyResettable(Object id) {
100
100
		return (propertySource2 == null)? false
101
	/**
101
				: propertySource2.isPropertyResettable(id);
102
	 * Delegates the my wrapped property source in the appropriate transaction.
102
	}
103
	 */
103
104
	public boolean isPropertySet(final Object id) {
104
	/**
105
		Boolean result = (Boolean) run(new RunnableWithResult.Impl() {
105
	 * Delegates the my wrapped property source in the appropriate transaction.
106
			public void run() {
106
	 */
107
				setResult(propertySource.isPropertySet(id)
107
	public boolean isPropertySet(final Object id) {
108
						? Boolean.TRUE : Boolean.FALSE);
108
		return run(new RunnableWithResult.Impl<Boolean>() {
109
			}});
109
			public void run() {
110
		
110
				setResult(propertySource.isPropertySet(id));
111
		return (result == null) ? false : result.booleanValue();
111
			}});
112
	}
112
	}
113
113
114
	/**
114
	/**
115
	 * Delegates the my wrapped property source in the appropriate transaction.
115
	 * Delegates the my wrapped property source in the appropriate transaction.
116
	 */
116
	 */
117
	public Object getEditableValue() {
117
	public Object getEditableValue() {
118
		return run(new RunnableWithResult.Impl() {
118
		return run(new RunnableWithResult.Impl<Object>() {
119
			public void run() {
119
			public void run() {
120
				setResult(propertySource.getEditableValue());
120
				setResult(propertySource.getEditableValue());
121
			}});
121
			}});
122
	}
122
	}
123
123
124
	/**
124
	/**
125
	 * Delegates the my wrapped property source in the appropriate transaction.
125
	 * Delegates the my wrapped property source in the appropriate transaction.
126
	 */
126
	 */
127
	public IPropertyDescriptor[] getPropertyDescriptors() {
127
	public IPropertyDescriptor[] getPropertyDescriptors() {
128
		return propertySource.getPropertyDescriptors();
128
		return propertySource.getPropertyDescriptors();
129
	}
129
	}
130
130
131
	/**
131
	/**
132
	 * Delegates the my wrapped property source in the appropriate transaction.
132
	 * Delegates the my wrapped property source in the appropriate transaction.
133
	 */
133
	 */
134
	public Object getPropertyValue(final Object id) {
134
	public Object getPropertyValue(final Object id) {
135
		return run(new RunnableWithResult.Impl() {
135
		return run(new RunnableWithResult.Impl<Object>() {
136
			public void run() {
136
			public void run() {
137
				setResult(propertySource.getPropertyValue(id));
137
				setResult(propertySource.getPropertyValue(id));
138
			}});
138
			}});
139
	}
139
	}
140
140
141
	/**
141
	/**
142
	 * Delegates the my wrapped property source in the appropriate transaction.
142
	 * Delegates the my wrapped property source in the appropriate transaction.
143
	 */
143
	 */
144
	public void resetPropertyValue(final Object id) {
144
	public void resetPropertyValue(final Object id) {
145
		if (propertySource2 != null) {
145
		if (propertySource2 != null) {
146
			// are we in a read-only context?  if so, balk because we cannot upgrade
146
			// are we in a read-only context?  if so, balk because we cannot upgrade
147
			//    read transaction to write when executing a command
147
			//    read transaction to write when executing a command
148
			Transaction tx = ((InternalTransactionalEditingDomain) domain).getActiveTransaction();
148
			Transaction tx = ((InternalTransactionalEditingDomain) domain).getActiveTransaction();
149
			if ((tx == null) || !tx.isReadOnly()) {
149
			if ((tx == null) || !tx.isReadOnly()) {
150
				propertySource2.resetPropertyValue(id);
150
				propertySource2.resetPropertyValue(id);
151
			}
151
			}
152
		}
152
		}
153
	}
153
	}
154
154
155
	/**
155
	/**
156
	 * Delegates directly to the wrapper property source, because it will use
156
	 * Delegates directly to the wrapper property source, because it will use
157
	 * a command to perform the modification (which implicitly creates a
157
	 * a command to perform the modification (which implicitly creates a
158
	 * read/write transaction).
158
	 * read/write transaction).
159
	 */
159
	 */
160
	public void setPropertyValue(final Object id, final Object value) {
160
	public void setPropertyValue(final Object id, final Object value) {
161
		// are we in a read-only context?  if so, balk because we cannot upgrade
161
		// are we in a read-only context?  if so, balk because we cannot upgrade
162
		//    read transaction to write when executing a command
162
		//    read transaction to write when executing a command
163
		Transaction tx = ((InternalTransactionalEditingDomain) domain).getActiveTransaction();
163
		Transaction tx = ((InternalTransactionalEditingDomain) domain).getActiveTransaction();
164
		if ((tx == null) || !tx.isReadOnly()) {
164
		if ((tx == null) || !tx.isReadOnly()) {
165
			propertySource.setPropertyValue(id, value);
165
			propertySource.setPropertyValue(id, value);
166
		}
166
		}
167
	}
167
	}
168
}
168
}
(-)src/org/eclipse/emf/transaction/ui/provider/TransactionalAdapterFactoryLabelProvider.java (-13 / +20 lines)
Lines 25-30 Link Here
25
import org.eclipse.emf.transaction.ui.internal.EMFTransactionUIStatusCodes;
25
import org.eclipse.emf.transaction.ui.internal.EMFTransactionUIStatusCodes;
26
import org.eclipse.emf.transaction.ui.internal.Tracing;
26
import org.eclipse.emf.transaction.ui.internal.Tracing;
27
import org.eclipse.emf.transaction.ui.internal.l10n.Messages;
27
import org.eclipse.emf.transaction.ui.internal.l10n.Messages;
28
import org.eclipse.emf.transaction.util.TransactionUtil;
28
import org.eclipse.swt.graphics.Image;
29
import org.eclipse.swt.graphics.Image;
29
30
30
31
Lines 55-67 Link Here
55
	 * Runs the specified runnable in the editing domain, with interrupt
56
	 * Runs the specified runnable in the editing domain, with interrupt
56
	 * handling.
57
	 * handling.
57
	 * 
58
	 * 
59
	 * @param <T> the result type of the runnable
60
	 * 
58
	 * @param run the runnable to run
61
	 * @param run the runnable to run
59
	 * 
62
	 * 
60
	 * @return its result, or <code>null</code> on interrupt
63
	 * @return its result, or <code>null</code> on interrupt
61
	 */
64
	 */
62
	protected Object run(RunnableWithResult run) {
65
	protected <T> T run(RunnableWithResult<? extends T> run) {
63
		try {
66
		try {
64
			return domain.runExclusive(run);
67
			return TransactionUtil.runExclusive(domain, run);
65
		} catch (InterruptedException e) {
68
		} catch (InterruptedException e) {
66
			Tracing.catching(TransactionalAdapterFactoryLabelProvider.class, "run", e); //$NON-NLS-1$
69
			Tracing.catching(TransactionalAdapterFactoryLabelProvider.class, "run", e); //$NON-NLS-1$
67
			
70
			
Lines 82-89 Link Here
82
	/**
85
	/**
83
	 * Extends the inherited implementation by running in a read-only transaction.
86
	 * Extends the inherited implementation by running in a read-only transaction.
84
	 */
87
	 */
88
	@Override
85
	public Image getColumnImage(final Object object, final int columnIndex) {
89
	public Image getColumnImage(final Object object, final int columnIndex) {
86
		return (Image) run(new RunnableWithResult.Impl() {
90
		return run(new RunnableWithResult.Impl<Image>() {
87
			public void run() {
91
			public void run() {
88
				setResult(TransactionalAdapterFactoryLabelProvider.super.getColumnImage(object, columnIndex));
92
				setResult(TransactionalAdapterFactoryLabelProvider.super.getColumnImage(object, columnIndex));
89
			}});
93
			}});
Lines 92-99 Link Here
92
	/**
96
	/**
93
	 * Extends the inherited implementation by running in a read-only transaction.
97
	 * Extends the inherited implementation by running in a read-only transaction.
94
	 */
98
	 */
99
	@Override
95
	public String getColumnText(final Object object, final int columnIndex) {
100
	public String getColumnText(final Object object, final int columnIndex) {
96
		return (String) run(new RunnableWithResult.Impl() {
101
		return run(new RunnableWithResult.Impl<String>() {
97
			public void run() {
102
			public void run() {
98
				setResult(TransactionalAdapterFactoryLabelProvider.super.getColumnText(object, columnIndex));
103
				setResult(TransactionalAdapterFactoryLabelProvider.super.getColumnText(object, columnIndex));
99
			}});
104
			}});
Lines 102-109 Link Here
102
	/**
107
	/**
103
	 * Extends the inherited implementation by running in a read-only transaction.
108
	 * Extends the inherited implementation by running in a read-only transaction.
104
	 */
109
	 */
110
	@Override
105
	protected Image getDefaultImage(final Object object) {
111
	protected Image getDefaultImage(final Object object) {
106
		return (Image) run(new RunnableWithResult.Impl() {
112
		return run(new RunnableWithResult.Impl<Image>() {
107
			public void run() {
113
			public void run() {
108
				setResult(TransactionalAdapterFactoryLabelProvider.super.getDefaultImage(object));
114
				setResult(TransactionalAdapterFactoryLabelProvider.super.getDefaultImage(object));
109
			}});
115
			}});
Lines 112-119 Link Here
112
	/**
118
	/**
113
	 * Extends the inherited implementation by running in a read-only transaction.
119
	 * Extends the inherited implementation by running in a read-only transaction.
114
	 */
120
	 */
121
	@Override
115
	public Image getImage(final Object object) {
122
	public Image getImage(final Object object) {
116
		return (Image) run(new RunnableWithResult.Impl() {
123
		return run(new RunnableWithResult.Impl<Image>() {
117
			public void run() {
124
			public void run() {
118
				setResult(TransactionalAdapterFactoryLabelProvider.super.getImage(object));
125
				setResult(TransactionalAdapterFactoryLabelProvider.super.getImage(object));
119
			}});
126
			}});
Lines 122-129 Link Here
122
	/**
129
	/**
123
	 * Extends the inherited implementation by running in a read-only transaction.
130
	 * Extends the inherited implementation by running in a read-only transaction.
124
	 */
131
	 */
132
	@Override
125
	protected Image getImageFromObject(final Object object) {
133
	protected Image getImageFromObject(final Object object) {
126
		return (Image) run(new RunnableWithResult.Impl() {
134
		return run(new RunnableWithResult.Impl<Image>() {
127
			public void run() {
135
			public void run() {
128
				setResult(TransactionalAdapterFactoryLabelProvider.super.getImageFromObject(object));
136
				setResult(TransactionalAdapterFactoryLabelProvider.super.getImageFromObject(object));
129
			}});
137
			}});
Lines 132-139 Link Here
132
	/**
140
	/**
133
	 * Extends the inherited implementation by running in a read-only transaction.
141
	 * Extends the inherited implementation by running in a read-only transaction.
134
	 */
142
	 */
143
	@Override
135
	public String getText(final Object object) {
144
	public String getText(final Object object) {
136
		return (String) run(new RunnableWithResult.Impl() {
145
		return run(new RunnableWithResult.Impl<String>() {
137
			public void run() {
146
			public void run() {
138
				setResult(TransactionalAdapterFactoryLabelProvider.super.getText(object));
147
				setResult(TransactionalAdapterFactoryLabelProvider.super.getText(object));
139
			}});
148
			}});
Lines 142-154 Link Here
142
	/**
151
	/**
143
	 * Extends the inherited implementation by running in a read-only transaction.
152
	 * Extends the inherited implementation by running in a read-only transaction.
144
	 */
153
	 */
154
	@Override
145
	public boolean isLabelProperty(final Object object, final String id) {
155
	public boolean isLabelProperty(final Object object, final String id) {
146
		Boolean result = (Boolean) run(new RunnableWithResult.Impl() {
156
		return run(new RunnableWithResult.Impl<Boolean>() {
147
			public void run() {
157
			public void run() {
148
				setResult(TransactionalAdapterFactoryLabelProvider.super.isLabelProperty(object, id)
158
				setResult(TransactionalAdapterFactoryLabelProvider.super.isLabelProperty(object, id));
149
						? Boolean.TRUE : Boolean.FALSE);
150
			}});
159
			}});
151
		
152
		return (result == null) ? false : result.booleanValue();
153
	}
160
	}
154
}
161
}
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:59:13 EST 2006
1
#Sun Nov 11 14:10:16 EST 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-)src/org/eclipse/emf/transaction/ui/internal/Tracing.java (-60 / +12 lines)
Lines 109-115 Link Here
109
	/**
109
	/**
110
	 * The cached debug options (for optimization).
110
	 * The cached debug options (for optimization).
111
	 */
111
	 */
112
	private static final Map cachedOptions = new HashMap();
112
	private static final Map<String, Boolean> cachedOptions =
113
		new HashMap<String, Boolean>();
113
114
114
	/**
115
	/**
115
	 * Retrieves a Boolean value indicating whether tracing is enabled.
116
	 * Retrieves a Boolean value indicating whether tracing is enabled.
Lines 137-149 Link Here
137
			Boolean value = null;
138
			Boolean value = null;
138
			
139
			
139
			synchronized (cachedOptions) {
140
			synchronized (cachedOptions) {
140
				value = (Boolean) cachedOptions.get(option);
141
				value = cachedOptions.get(option);
141
	
142
	
142
				if (null == value) {
143
				if (null == value) {
143
					value =
144
					value =
144
						new Boolean(
145
						Boolean.TRUE.toString().equalsIgnoreCase(
145
							Boolean.TRUE.toString().equalsIgnoreCase(
146
								org.eclipse.core.runtime.Platform.getDebugOption(option));
146
								org.eclipse.core.runtime.Platform.getDebugOption(option)));
147
	
147
	
148
					cachedOptions.put(option, value);
148
					cachedOptions.put(option, value);
149
				}
149
				}
Lines 254-260 Link Here
254
	 */
254
	 */
255
	public static void changing(
255
	public static void changing(
256
        String option,
256
        String option,
257
        Class clazz,
257
        Class<?> clazz,
258
        String methodName,
258
        String methodName,
259
        String valueDescription,
259
        String valueDescription,
260
        Object oldValue,
260
        Object oldValue,
Lines 291-297 Link Here
291
	 * 
291
	 * 
292
	 */
292
	 */
293
	public static void catching(
293
	public static void catching(
294
		Class clazz,
294
		Class<?> clazz,
295
		String methodName,
295
		String methodName,
296
		Throwable throwable) {
296
		Throwable throwable) {
297
297
Lines 322-328 Link Here
322
	 * 
322
	 * 
323
	 */
323
	 */
324
	public static void throwing(
324
	public static void throwing(
325
		Class clazz,
325
		Class<?> clazz,
326
		String methodName,
326
		String methodName,
327
		Throwable throwable) {
327
		Throwable throwable) {
328
328
Lines 343-396 Link Here
343
	}
343
	}
344
344
345
	/**
345
	/**
346
	 * Traces the entering into the specified method of the specified class.
347
	 * 
348
	 * @param clazz The class whose method is being entered.
349
	 * @param methodName The name of method that is being entered.
350
	 * 
351
	 */
352
	public static void entering(
353
		Class clazz,
354
		String methodName) {
355
356
		if (shouldTrace(EMFTransactionUIDebugOptions.METHODS_ENTERING)) {
357
358
			trace(
359
				PREFIX_ENTERING
360
					+ clazz.getName()
361
					+ SEPARATOR_METHOD
362
					+ methodName);
363
		}
364
	}
365
366
	/**
367
	 * Traces the entering into the specified method of the specified class,
368
	 * with the specified parameter.
369
	 * 
370
	 * @param clazz The class whose method is being entered.
371
	 * @param methodName The name of method that is being entered.
372
	 * @param parameter The parameter to the method being entered.
373
	 * 
374
	 */
375
	public static void entering(
376
		Class clazz,
377
		String methodName,
378
		Object parameter) {
379
380
		if (shouldTrace(EMFTransactionUIDebugOptions.METHODS_ENTERING)) {
381
382
			trace(
383
				PREFIX_ENTERING
384
					+ clazz.getName()
385
					+ SEPARATOR_METHOD
386
					+ methodName
387
					+ PARENTHESIS_OPEN
388
					+ getArgumentString(parameter)
389
					+ PARENTHESIS_CLOSE);
390
		}
391
	}
392
393
	/**
394
	 * Traces the entering into the specified method of the specified class,
346
	 * Traces the entering into the specified method of the specified class,
395
	 * with the specified parameters.
347
	 * with the specified parameters.
396
	 * 
348
	 * 
Lines 400-408 Link Here
400
	 * 
352
	 * 
401
	 */
353
	 */
402
	public static void entering(
354
	public static void entering(
403
		Class clazz,
355
		Class<?> clazz,
404
		String methodName,
356
		String methodName,
405
		Object[] parameters) {
357
		Object... parameters) {
406
358
407
		if (shouldTrace(EMFTransactionUIDebugOptions.METHODS_ENTERING)) {
359
		if (shouldTrace(EMFTransactionUIDebugOptions.METHODS_ENTERING)) {
408
360
Lines 425-431 Link Here
425
	 * 
377
	 * 
426
	 */
378
	 */
427
	public static void exiting(
379
	public static void exiting(
428
		Class clazz,
380
		Class<?> clazz,
429
		String methodName) {
381
		String methodName) {
430
382
431
		if (shouldTrace(EMFTransactionUIDebugOptions.METHODS_EXITING)) {
383
		if (shouldTrace(EMFTransactionUIDebugOptions.METHODS_EXITING)) {
Lines 448-454 Link Here
448
	 * 
400
	 * 
449
	 */
401
	 */
450
	public static void exiting(
402
	public static void exiting(
451
		Class clazz,
403
		Class<?> clazz,
452
		String methodName,
404
		String methodName,
453
		Object returnValue) {
405
		Object returnValue) {
454
406
(-)src/org/eclipse/emf/transaction/examples/internal/wizard/AbstractExampleWizard.java (-12 / +14 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 24-35 Link Here
24
import java.lang.reflect.InvocationTargetException;
24
import java.lang.reflect.InvocationTargetException;
25
import java.net.URL;
25
import java.net.URL;
26
import java.util.Collection;
26
import java.util.Collection;
27
import java.util.Iterator;
28
import java.util.zip.ZipEntry;
27
import java.util.zip.ZipEntry;
29
import java.util.zip.ZipInputStream;
28
import java.util.zip.ZipInputStream;
30
29
31
import org.eclipse.core.resources.IFile;
32
import org.eclipse.core.resources.IProject;
30
import org.eclipse.core.resources.IProject;
31
import org.eclipse.core.resources.IResource;
33
import org.eclipse.core.resources.ResourcesPlugin;
32
import org.eclipse.core.resources.ResourcesPlugin;
34
import org.eclipse.core.runtime.CoreException;
33
import org.eclipse.core.runtime.CoreException;
35
import org.eclipse.core.runtime.FileLocator;
34
import org.eclipse.core.runtime.FileLocator;
Lines 76-84 Link Here
76
	 *  when unzipped into the workspace.
75
	 *  when unzipped into the workspace.
77
	 */
76
	 */
78
	public static class ProjectDescriptor {
77
	public static class ProjectDescriptor {
79
		private String bundleName;
78
		private final String bundleName;
80
		private String zipLocation;
79
		private final String zipLocation;
81
		private String projectName;
80
		private final String projectName;
82
		
81
		
83
		/**
82
		/**
84
		 * Construct a descriptor that points to a zip file located
83
		 * Construct a descriptor that points to a zip file located
Lines 114-121 Link Here
114
		}
113
		}
115
	}
114
	}
116
115
116
	@Override
117
	public boolean performFinish() {
117
	public boolean performFinish() {
118
		final Collection projectDescriptors = getProjectDescriptors();
118
		final Collection<ProjectDescriptor> projectDescriptors = getProjectDescriptors();
119
		
119
		
120
		try {
120
		try {
121
			getContainer().run(true, false, new IRunnableWithProgress() {
121
			getContainer().run(true, false, new IRunnableWithProgress() {
Lines 123-135 Link Here
123
					throws InvocationTargetException, InterruptedException {
123
					throws InvocationTargetException, InterruptedException {
124
					
124
					
125
					WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
125
					WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
126
						@Override
126
						protected void execute(IProgressMonitor m)
127
						protected void execute(IProgressMonitor m)
127
						
128
						
128
							throws CoreException, InvocationTargetException, InterruptedException {
129
							throws CoreException, InvocationTargetException, InterruptedException {
129
							m.beginTask("Unzipping Projects", projectDescriptors.size());
130
							m.beginTask("Unzipping Projects", projectDescriptors.size());
130
							
131
							
131
							for (Iterator i = projectDescriptors.iterator(); i.hasNext();) {
132
							for (ProjectDescriptor next : projectDescriptors) {
132
								unzipProject((ProjectDescriptor)i.next(), m);
133
								unzipProject(next, m);
133
								m.worked(1);
134
								m.worked(1);
134
							}
135
							}
135
						}
136
						}
Lines 157-163 Link Here
157
	 * @return The collection of project descriptors that should be
158
	 * @return The collection of project descriptors that should be
158
	 *  unzipped into the workspace.
159
	 *  unzipped into the workspace.
159
	 */
160
	 */
160
	protected abstract Collection getProjectDescriptors();
161
	protected abstract Collection<ProjectDescriptor> getProjectDescriptors();
161
	
162
	
162
	private void unzipProject(ProjectDescriptor descriptor, IProgressMonitor monitor) {
163
	private void unzipProject(ProjectDescriptor descriptor, IProgressMonitor monitor) {
163
		String bundleName = descriptor.getBundleName();
164
		String bundleName = descriptor.getBundleName();
Lines 230-237 Link Here
230
							byte[] buffer = new byte[102400];
231
							byte[] buffer = new byte[102400];
231
							while (true) {
232
							while (true) {
232
								int len = zipFileStream.read(buffer);
233
								int len = zipFileStream.read(buffer);
233
								if (zipFileStream.available() == 0)
234
								if (zipFileStream.available() == 0) {
234
									break;
235
									break;
236
								}
235
								os.write(buffer, 0, len);
237
								os.write(buffer, 0, len);
236
							}
238
							}
237
						} finally {
239
						} finally {
Lines 247-253 Link Here
247
			}
249
			}
248
			
250
			
249
			project.open(monitor);
251
			project.open(monitor);
250
			project.refreshLocal(IFile.DEPTH_INFINITE, monitor);
252
			project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
251
			
253
			
252
			// Close and re-open the project to force eclipse to re-evaluate
254
			// Close and re-open the project to force eclipse to re-evaluate
253
			//  any natures that this project has.
255
			//  any natures that this project has.
(-)src/org/eclipse/emf/transaction/examples/internal/wizard/WorkspaceExampleWizard.java (-3 / +5 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 30-39 Link Here
30
public class WorkspaceExampleWizard
30
public class WorkspaceExampleWizard
31
	extends AbstractExampleWizard {
31
	extends AbstractExampleWizard {
32
	
32
	
33
	protected Collection getProjectDescriptors() {
33
	@Override
34
	protected Collection<ProjectDescriptor> getProjectDescriptors() {
34
		// We need the workspace example to be unzipped along with the
35
		// We need the workspace example to be unzipped along with the
35
		// EMF library example model, edit and editor examples
36
		// EMF library example model, edit and editor examples
36
		List projects = new ArrayList(4);
37
		List<ProjectDescriptor> projects = new ArrayList<ProjectDescriptor>(4);
37
		projects.add(new ProjectDescriptor("org.eclipse.emf.transaction.examples", "zips/library.zip", "org.eclipse.emf.examples.library"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
38
		projects.add(new ProjectDescriptor("org.eclipse.emf.transaction.examples", "zips/library.zip", "org.eclipse.emf.examples.library"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
38
		projects.add(new ProjectDescriptor("org.eclipse.emf.transaction.examples", "zips/libraryEdit.zip", "org.eclipse.emf.examples.library.edit")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
39
		projects.add(new ProjectDescriptor("org.eclipse.emf.transaction.examples", "zips/libraryEdit.zip", "org.eclipse.emf.examples.library.edit")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
39
		projects.add(new ProjectDescriptor("org.eclipse.emf.transaction.examples", "zips/libraryEditor.zip", "org.eclipse.emf.examples.library.editor"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
40
		projects.add(new ProjectDescriptor("org.eclipse.emf.transaction.examples", "zips/libraryEditor.zip", "org.eclipse.emf.examples.library.editor"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
Lines 42-47 Link Here
42
		return projects;
43
		return projects;
43
	}
44
	}
44
	
45
	
46
	@Override
45
	protected void log(Exception e) {
47
	protected void log(Exception e) {
46
		if (e instanceof CoreException) {
48
		if (e instanceof CoreException) {
47
			TransactionExamplesPlugin.getDefault().getLog().log(((CoreException)e).getStatus());
49
			TransactionExamplesPlugin.getDefault().getLog().log(((CoreException)e).getStatus());
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 13-16 Link Here
13
Bundle-Activator: org.eclipse.emf.transaction.examples.internal.TransactionExamplesPlugin
13
Bundle-Activator: org.eclipse.emf.transaction.examples.internal.TransactionExamplesPlugin
14
Export-Package: org.eclipse.emf.transaction.examples.internal;x-internal:=true,
14
Export-Package: org.eclipse.emf.transaction.examples.internal;x-internal:=true,
15
 org.eclipse.emf.transaction.examples.internal.wizard;x-internal:=true
15
 org.eclipse.emf.transaction.examples.internal.wizard;x-internal:=true
16
Bundle-RequiredExecutionEnvironment: J2SE-1.4
16
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)build.properties (-2 / +2 lines)
Lines 25-29 Link Here
25
src.includes = about.html
25
src.includes = about.html
26
source.. = src/
26
source.. = src/
27
output.. = bin/
27
output.. = bin/
28
javacSource = 1.4
28
javacSource = 1.5
29
javacTarget = 1.4
29
javacTarget = 1.5
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:58:18 EST 2006
1
#Sun Nov 11 13:14:50 EST 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-)src/org/eclipse/emf/workspace/tests/WorkbenchCommandStackTest.java (-18 / +44 lines)
Lines 232-255 Link Here
232
		final IUndoContext undoContext = new UndoContext();
232
		final IUndoContext undoContext = new UndoContext();
233
		
233
		
234
		domain.addResourceSetListener(new ResourceSetListenerImpl() {
234
		domain.addResourceSetListener(new ResourceSetListenerImpl() {
235
			@Override
235
			public boolean isPrecommitOnly() {
236
			public boolean isPrecommitOnly() {
236
				return true;
237
				return true;
237
			}
238
			}
238
			
239
			
240
			@Override
239
			public Command transactionAboutToCommit(ResourceSetChangeEvent event)
241
			public Command transactionAboutToCommit(ResourceSetChangeEvent event)
240
				throws RollbackException {
242
				throws RollbackException {
241
				
243
				
242
				IUndoableOperation op = new AbstractOperation("") { //$NON-NLS-1$
244
				IUndoableOperation op = new AbstractOperation("") { //$NON-NLS-1$
245
					@Override
243
					public IStatus execute(IProgressMonitor monitor, IAdaptable info)
246
					public IStatus execute(IProgressMonitor monitor, IAdaptable info)
244
						throws ExecutionException {
247
						throws ExecutionException {
245
						return Status.OK_STATUS;
248
						return Status.OK_STATUS;
246
					}
249
					}
247
	
250
	
251
					@Override
248
					public IStatus redo(IProgressMonitor monitor, IAdaptable info)
252
					public IStatus redo(IProgressMonitor monitor, IAdaptable info)
249
						throws ExecutionException {
253
						throws ExecutionException {
250
						return Status.OK_STATUS;
254
						return Status.OK_STATUS;
251
					}
255
					}
252
	
256
	
257
					@Override
253
					public IStatus undo(IProgressMonitor monitor, IAdaptable info)
258
					public IStatus undo(IProgressMonitor monitor, IAdaptable info)
254
						throws ExecutionException {
259
						throws ExecutionException {
255
						return Status.OK_STATUS;
260
						return Status.OK_STATUS;
Lines 266-271 Link Here
266
		IUndoContext resCtx = new ResourceUndoContext(domain, r);
271
		IUndoContext resCtx = new ResourceUndoContext(domain, r);
267
        
272
        
268
		AbstractEMFOperation op = new AbstractEMFOperation(domain, "") { //$NON-NLS-1$
273
		AbstractEMFOperation op = new AbstractEMFOperation(domain, "") { //$NON-NLS-1$
274
			@Override
269
			protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
275
			protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
270
				throws ExecutionException {
276
				throws ExecutionException {
271
				
277
				
Lines 286-292 Link Here
286
		}
292
		}
287
		
293
		
288
		assertNotNull(op.getContexts());
294
		assertNotNull(op.getContexts());
289
        List opContexts = Arrays.asList(op.getContexts());
295
        List<IUndoContext> opContexts = Arrays.asList(op.getContexts());
290
		assertTrue(opContexts.contains(resCtx));
296
		assertTrue(opContexts.contains(resCtx));
291
        assertTrue(opContexts.contains(undoContext));
297
        assertTrue(opContexts.contains(undoContext));
292
		
298
		
Lines 315-320 Link Here
315
		
321
		
316
		Command op = new RecordingCommand(domain) {
322
		Command op = new RecordingCommand(domain) {
317
323
324
			@Override
318
			protected void doExecute() {
325
			protected void doExecute() {
319
				r.getContents().add(EXTLibraryFactory.eINSTANCE.createLibrary());
326
				r.getContents().add(EXTLibraryFactory.eINSTANCE.createLibrary());
320
				
327
				
Lines 362-370 Link Here
362
        final RuntimeException error = new RuntimeException();
369
        final RuntimeException error = new RuntimeException();
363
        
370
        
364
        ResourceSetListener testListener = new TriggerListener() {
371
        ResourceSetListener testListener = new TriggerListener() {
365
        	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
372
        	@Override
373
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
366
        		return new RecordingCommand(domain, "Error") { //$NON-NLS-1$
374
        		return new RecordingCommand(domain, "Error") { //$NON-NLS-1$
367
        			protected void doExecute() {
375
        			@Override
376
					protected void doExecute() {
368
        				throw error;
377
        				throw error;
369
        			}};
378
        			}};
370
        	}};
379
        	}};
Lines 376-382 Link Here
376
            domain.addResourceSetListener(testListener);
385
            domain.addResourceSetListener(testListener);
377
            
386
            
378
            domain.getCommandStack().execute(new RecordingCommand(domain) {
387
            domain.getCommandStack().execute(new RecordingCommand(domain) {
379
                protected void doExecute() {
388
                @Override
389
				protected void doExecute() {
380
                    root.getWriters().clear();
390
                    root.getWriters().clear();
381
                    root.getStock().clear();
391
                    root.getStock().clear();
382
                    root.getBranches().clear();
392
                    root.getBranches().clear();
Lines 404-412 Link Here
404
        final RuntimeException error = new OperationCanceledException();
414
        final RuntimeException error = new OperationCanceledException();
405
        
415
        
406
        ResourceSetListener testListener = new TriggerListener() {
416
        ResourceSetListener testListener = new TriggerListener() {
407
        	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
417
        	@Override
418
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
408
        		return new RecordingCommand(domain, "Error") { //$NON-NLS-1$
419
        		return new RecordingCommand(domain, "Error") { //$NON-NLS-1$
409
        			protected void doExecute() {
420
        			@Override
421
					protected void doExecute() {
410
        				throw error;
422
        				throw error;
411
        			}};
423
        			}};
412
        	}};
424
        	}};
Lines 418-424 Link Here
418
            domain.addResourceSetListener(testListener);
430
            domain.addResourceSetListener(testListener);
419
            
431
            
420
            domain.getCommandStack().execute(new RecordingCommand(domain) {
432
            domain.getCommandStack().execute(new RecordingCommand(domain) {
421
                protected void doExecute() {
433
                @Override
434
				protected void doExecute() {
422
                    root.getWriters().clear();
435
                    root.getWriters().clear();
423
                    root.getStock().clear();
436
                    root.getStock().clear();
424
                    root.getBranches().clear();
437
                    root.getBranches().clear();
Lines 446-454 Link Here
446
        final RuntimeException error = new RuntimeException();
459
        final RuntimeException error = new RuntimeException();
447
        
460
        
448
        ResourceSetListener testListener = new TriggerListener() {
461
        ResourceSetListener testListener = new TriggerListener() {
449
        	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
462
        	@Override
463
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
450
        		return new RecordingCommand(domain, "Error") { //$NON-NLS-1$
464
        		return new RecordingCommand(domain, "Error") { //$NON-NLS-1$
451
        			protected void doExecute() {
465
        			@Override
466
					protected void doExecute() {
452
        				throw error;
467
        				throw error;
453
        			}};
468
        			}};
454
        	}};
469
        	}};
Lines 458-464 Link Here
458
            
473
            
459
            try {
474
            try {
460
	            IStatus status = new AbstractEMFOperation(domain, "test") { //$NON-NLS-1$
475
	            IStatus status = new AbstractEMFOperation(domain, "test") { //$NON-NLS-1$
461
	                protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) {
476
	                @Override
477
					protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) {
462
	                    root.getWriters().clear();
478
	                    root.getWriters().clear();
463
	                    root.getStock().clear();
479
	                    root.getStock().clear();
464
	                    root.getBranches().clear();
480
	                    root.getBranches().clear();
Lines 489-497 Link Here
489
        final RuntimeException error = new OperationCanceledException();
505
        final RuntimeException error = new OperationCanceledException();
490
        
506
        
491
        ResourceSetListener testListener = new TriggerListener() {
507
        ResourceSetListener testListener = new TriggerListener() {
492
        	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
508
        	@Override
509
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
493
        		return new RecordingCommand(domain, "Error") { //$NON-NLS-1$
510
        		return new RecordingCommand(domain, "Error") { //$NON-NLS-1$
494
        			protected void doExecute() {
511
        			@Override
512
					protected void doExecute() {
495
        				throw error;
513
        				throw error;
496
        			}};
514
        			}};
497
        	}};
515
        	}};
Lines 501-507 Link Here
501
            
519
            
502
            try {
520
            try {
503
	            IStatus status = new AbstractEMFOperation(domain, "test") { //$NON-NLS-1$
521
	            IStatus status = new AbstractEMFOperation(domain, "test") { //$NON-NLS-1$
504
	                protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) {
522
	                @Override
523
					protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) {
505
	                    root.getWriters().clear();
524
	                    root.getWriters().clear();
506
	                    root.getStock().clear();
525
	                    root.getStock().clear();
507
	                    root.getBranches().clear();
526
	                    root.getBranches().clear();
Lines 531-543 Link Here
531
    public void test_recordingCommandsAsTriggers_bug157103() {
550
    public void test_recordingCommandsAsTriggers_bug157103() {
532
        // one trigger sets default library names
551
        // one trigger sets default library names
533
        domain.addResourceSetListener(new LibraryDefaultNameTrigger() {
552
        domain.addResourceSetListener(new LibraryDefaultNameTrigger() {
534
            protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
553
            @Override
554
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
535
                Command result = null;
555
                Command result = null;
536
                
556
                
537
                final Library newLibrary = (Library) notification.getNewValue();
557
                final Library newLibrary = (Library) notification.getNewValue();
538
                if ((newLibrary.getName() == null) || (newLibrary.getName().length() == 0)) {
558
                if ((newLibrary.getName() == null) || (newLibrary.getName().length() == 0)) {
539
                    result = new RecordingCommand(domain) {
559
                    result = new RecordingCommand(domain) {
540
                        protected void doExecute() {
560
                        @Override
561
						protected void doExecute() {
541
                            newLibrary.setName("New Library"); //$NON-NLS-1$
562
                            newLibrary.setName("New Library"); //$NON-NLS-1$
542
                        }};
563
                        }};
543
                }
564
                }
Lines 549-555 Link Here
549
        
570
        
550
        IUndoContext ctx = new UndoContext();
571
        IUndoContext ctx = new UndoContext();
551
        IUndoableOperation operation = new AbstractEMFOperation(domain, "Test") { //$NON-NLS-1$
572
        IUndoableOperation operation = new AbstractEMFOperation(domain, "Test") { //$NON-NLS-1$
552
            protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) {
573
            @Override
574
			protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) {
553
                newLibrary[0] = EXTLibraryFactory.eINSTANCE.createLibrary();
575
                newLibrary[0] = EXTLibraryFactory.eINSTANCE.createLibrary();
554
                root.getBranches().add(newLibrary[0]);
576
                root.getBranches().add(newLibrary[0]);
555
                
577
                
Lines 679-692 Link Here
679
        SelfOpeningEMFCompositeOperation operation = new SelfOpeningEMFCompositeOperation(
701
        SelfOpeningEMFCompositeOperation operation = new SelfOpeningEMFCompositeOperation(
680
            domain) {
702
            domain) {
681
703
682
            protected IStatus doExecute(IOperationHistory history,
704
            @Override
705
			protected IStatus doExecute(IOperationHistory history,
683
                    IProgressMonitor monitor, IAdaptable info)
706
                    IProgressMonitor monitor, IAdaptable info)
684
                throws ExecutionException {
707
                throws ExecutionException {
685
708
686
                return history.execute(
709
                return history.execute(
687
                    new AbstractEMFOperation(domain, "Test") { //$NON-NLS-1$
710
                    new AbstractEMFOperation(domain, "Test") { //$NON-NLS-1$
688
711
689
                        protected IStatus doExecute(IProgressMonitor monitor,
712
                        @Override
713
						protected IStatus doExecute(IProgressMonitor monitor,
690
                                IAdaptable info) {
714
                                IAdaptable info) {
691
                            root.getBranches().add(
715
                            root.getBranches().add(
692
                                EXTLibraryFactory.eINSTANCE.createLibrary());
716
                                EXTLibraryFactory.eINSTANCE.createLibrary());
Lines 711-722 Link Here
711
	// Fixture methods
735
	// Fixture methods
712
	//
736
	//
713
	
737
	
738
	@Override
714
	protected void doSetUp() throws Exception {
739
	protected void doSetUp() throws Exception {
715
		super.doSetUp();
740
		super.doSetUp();
716
		
741
		
717
		defaultContext = ((IWorkspaceCommandStack) getCommandStack()).getDefaultUndoContext();
742
		defaultContext = ((IWorkspaceCommandStack) getCommandStack()).getDefaultUndoContext();
718
	}
743
	}
719
	
744
	
745
	@Override
720
	protected void doTearDown() throws Exception {
746
	protected void doTearDown() throws Exception {
721
		defaultContext = null;
747
		defaultContext = null;
722
		
748
		
(-)src/org/eclipse/emf/workspace/tests/AbstractTest.java (-33 / +40 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005, 2006 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 44-54 Link Here
44
import org.eclipse.emf.examples.extlibrary.Person;
44
import org.eclipse.emf.examples.extlibrary.Person;
45
import org.eclipse.emf.examples.extlibrary.Writer;
45
import org.eclipse.emf.examples.extlibrary.Writer;
46
import org.eclipse.emf.examples.extlibrary.util.EXTLibrarySwitch;
46
import org.eclipse.emf.examples.extlibrary.util.EXTLibrarySwitch;
47
import org.eclipse.emf.transaction.Transaction;
47
import org.eclipse.emf.transaction.TransactionalCommandStack;
48
import org.eclipse.emf.transaction.TransactionalCommandStack;
48
import org.eclipse.emf.transaction.TransactionalEditingDomain;
49
import org.eclipse.emf.transaction.TransactionalEditingDomain;
49
import org.eclipse.emf.transaction.Transaction;
50
import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
51
import org.eclipse.emf.transaction.impl.InternalTransaction;
50
import org.eclipse.emf.transaction.impl.InternalTransaction;
51
import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
52
import org.eclipse.emf.validation.model.IConstraintStatus;
52
import org.eclipse.emf.validation.model.IConstraintStatus;
53
import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;
53
import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;
54
import org.osgi.framework.Bundle;
54
import org.osgi.framework.Bundle;
Lines 80-86 Link Here
80
80
81
	protected static final String TEST_RESOURCE_NAME = "test_model.extlibrary"; //$NON-NLS-1$
81
	protected static final String TEST_RESOURCE_NAME = "test_model.extlibrary"; //$NON-NLS-1$
82
	
82
	
83
	private final List transactionStack = new java.util.ArrayList();
83
	private final List<InternalTransaction> transactionStack =
84
		new java.util.ArrayList<InternalTransaction>();
84
	
85
	
85
	public AbstractTest() {
86
	public AbstractTest() {
86
		super();
87
		super();
Lines 94-99 Link Here
94
	// Test configuration methods
95
	// Test configuration methods
95
	//
96
	//
96
	
97
	
98
	@Override
97
	protected final void setUp()
99
	protected final void setUp()
98
		throws Exception {
100
		throws Exception {
99
		
101
		
Lines 141-146 Link Here
141
				history);
143
				history);
142
	}
144
	}
143
145
146
	@Override
144
	protected final void tearDown()
147
	protected final void tearDown()
145
		throws Exception {
148
		throws Exception {
146
		
149
		
Lines 208-214 Link Here
208
			file.create(input, true, null);
211
			file.create(input, true, null);
209
			
212
			
210
			result = domain.createResource(
213
			result = domain.createResource(
211
				URI.createPlatformResourceURI(file.getFullPath().toString()).toString());
214
				URI.createPlatformResourceURI(file.getFullPath().toString(), true).toString());
212
		} catch (Exception e) {
215
		} catch (Exception e) {
213
			e.printStackTrace();
216
			e.printStackTrace();
214
			fail("Exception creating test resource: " + e.getLocalizedMessage()); //$NON-NLS-1$
217
			fail("Exception creating test resource: " + e.getLocalizedMessage()); //$NON-NLS-1$
Lines 341-348 Link Here
341
			String name = names[i];
344
			String name = names[i];
342
			result = null;
345
			result = null;
343
			
346
			
344
			for (Iterator iter = getContents(current).iterator(); iter.hasNext();) {
347
			for (Iterator<EObject> iter = getContents(current).iterator(); iter.hasNext();) {
345
				EObject child = (EObject) iter.next();
348
				EObject child = iter.next();
346
				
349
				
347
				if (name.equals(getName(child))) {
350
				if (name.equals(getName(child))) {
348
					result = child;
351
					result = child;
Lines 363-369 Link Here
363
	 * @return its name
366
	 * @return its name
364
	 */
367
	 */
365
	private String getName(EObject object) {
368
	private String getName(EObject object) {
366
		return (String) GetName.INSTANCE.doSwitch(object);
369
		return GetName.INSTANCE.doSwitch(object);
367
	}
370
	}
368
	
371
	
369
	/**
372
	/**
Lines 372-384 Link Here
372
	 * @param object an object, which may be a resource or an element
375
	 * @param object an object, which may be a resource or an element
373
	 * @return its immediate contents (children)
376
	 * @return its immediate contents (children)
374
	 */
377
	 */
375
	private List getContents(Object object) {
378
	private List<EObject> getContents(Object object) {
376
		if (object instanceof EObject) {
379
		if (object instanceof EObject) {
377
			return ((EObject) object).eContents();
380
			return ((EObject) object).eContents();
378
		} else if (object instanceof Resource) {
381
		} else if (object instanceof Resource) {
379
			return ((Resource) object).getContents();
382
			return ((Resource) object).getContents();
380
		} else {
383
		} else {
381
			return Collections.EMPTY_LIST;
384
			return Collections.emptyList();
382
		}
385
		}
383
	}
386
	}
384
	
387
	
Lines 397-403 Link Here
397
	 *
400
	 *
398
	 * @author Christian W. Damus (cdamus)
401
	 * @author Christian W. Damus (cdamus)
399
	 */
402
	 */
400
	private static final class GetName extends EXTLibrarySwitch {
403
	private static final class GetName extends EXTLibrarySwitch<String> {
401
		static final GetName INSTANCE = new GetName();
404
		static final GetName INSTANCE = new GetName();
402
		
405
		
403
		private GetName() {
406
		private GetName() {
Lines 408-430 Link Here
408
			return object.getTitle();
411
			return object.getTitle();
409
		}
412
		}
410
413
411
		public Object caseBook(Book object) {
414
		@Override
415
		public String caseBook(Book object) {
412
			return object.getTitle();
416
			return object.getTitle();
413
		}
417
		}
414
418
415
		public Object caseLibrary(Library object) {
419
		@Override
420
		public String caseLibrary(Library object) {
416
			return object.getName();
421
			return object.getName();
417
		}
422
		}
418
423
419
		public Object casePeriodical(Periodical object) {
424
		@Override
425
		public String casePeriodical(Periodical object) {
420
			return object.getTitle();
426
			return object.getTitle();
421
		}
427
		}
422
		
428
		
423
		public Object caseWriter(Writer object) {
429
		@Override
430
		public String caseWriter(Writer object) {
424
			return object.getName();
431
			return object.getName();
425
		}
432
		}
426
433
427
		public Object casePerson(Person object) {
434
		@Override
435
		public String casePerson(Person object) {
428
			if (object.getFirstName() == null) {
436
			if (object.getFirstName() == null) {
429
				if (object.getLastName() == null) {
437
				if (object.getLastName() == null) {
430
					return ""; //$NON-NLS-1$
438
					return ""; //$NON-NLS-1$
Lines 443-449 Link Here
443
			}
451
			}
444
		}
452
		}
445
453
446
		public Object defaultCase(EObject object) {
454
		@Override
455
		public String defaultCase(EObject object) {
447
			return ""; //$NON-NLS-1$
456
			return ""; //$NON-NLS-1$
448
		}
457
		}
449
	}
458
	}
Lines 483-489 Link Here
483
	 * 
492
	 * 
484
	 * @param options the options
493
	 * @param options the options
485
	 */
494
	 */
486
	protected void startWriting(Map options) {
495
	protected void startWriting(Map<?, ?> options) {
487
		try {
496
		try {
488
			transactionStack.add(
497
			transactionStack.add(
489
					((InternalTransactionalEditingDomain) domain).startTransaction(false, options));
498
					((InternalTransactionalEditingDomain) domain).startTransaction(false, options));
Lines 518-524 Link Here
518
	 * 
527
	 * 
519
	 * @param options the options
528
	 * @param options the options
520
	 */
529
	 */
521
	protected void startReading(Map options) {
530
	protected void startReading(Map<?, ?> options) {
522
		try {
531
		try {
523
			transactionStack.add(
532
			transactionStack.add(
524
					((InternalTransactionalEditingDomain) domain).startTransaction(true, options));
533
					((InternalTransactionalEditingDomain) domain).startTransaction(true, options));
Lines 567-574 Link Here
567
	 * 
576
	 * 
568
	 * @return the map
577
	 * @return the map
569
	 */
578
	 */
570
	protected Map makeOptions(String option) {
579
	protected Map<?, ?> makeOptions(String option) {
571
		return makeOptions(option, Boolean.TRUE);
580
		return makeOptions(option, true);
572
	}
581
	}
573
	
582
	
574
	/**
583
	/**
Lines 579-585 Link Here
579
	 * 
588
	 * 
580
	 * @return the map
589
	 * @return the map
581
	 */
590
	 */
582
	protected Map makeOptions(String option, Object value) {
591
	protected Map<?, ?> makeOptions(String option, Object value) {
583
		if (value == null) {
592
		if (value == null) {
584
			return Collections.EMPTY_MAP;
593
			return Collections.EMPTY_MAP;
585
		}
594
		}
Lines 590-610 Link Here
590
	/**
599
	/**
591
	 * Makes a map from multiple options, as key-value pairs.
600
	 * Makes a map from multiple options, as key-value pairs.
592
	 * 
601
	 * 
593
	 * @param options a pairwise list of keys and values
602
	 * @param option an option
603
	 * @param value the <tt>option</tt> value
604
	 * @param options a pairwise list of additional options and values
594
	 * 
605
	 * 
595
	 * @return the map
606
	 * @return the map
596
	 */
607
	 */
597
	protected Map makeOptions(Object[] options) {
608
	protected Map<?, ?> makeOptions(Object option, Object value, Object... options) {
598
		Map result;
609
		Map<Object, Object> result = new java.util.HashMap<Object, Object>();
599
		
610
		
600
		if (options == null) {
611
		result.put(option, value);
601
			result = Collections.EMPTY_MAP;
612
		
602
		} else {
613
		for (int i = 0; i < options.length - 1; i += 2) {
603
			result = new java.util.HashMap();
614
			result.put(options[i], options[i + 1]);
604
			
605
			for (int i = 0; i < options.length - 1; i += 2) {
606
				result.put(options[i], options[i + 1]);
607
			}
608
		}
615
		}
609
		
616
		
610
		return result;
617
		return result;
(-)src/org/eclipse/emf/workspace/tests/UndoContextTest.java (-4 / +6 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005, 2006 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 71-76 Link Here
71
		IUndoContext ctx = new TestUndoContext();
71
		IUndoContext ctx = new TestUndoContext();
72
		
72
		
73
		IUndoableOperation oper = new TestOperation(domain) {
73
		IUndoableOperation oper = new TestOperation(domain) {
74
			@Override
74
			protected void doExecute() {
75
			protected void doExecute() {
75
				book.setTitle(newTitle);
76
				book.setTitle(newTitle);
76
				newAuthor.getBooks().add(book);
77
				newAuthor.getBooks().add(book);
Lines 83-89 Link Here
83
			fail(e);
84
			fail(e);
84
		}
85
		}
85
		
86
		
86
		Set affected = ResourceUndoContext.getAffectedResources(oper);
87
		Set<Resource> affected = ResourceUndoContext.getAffectedResources(oper);
87
		
88
		
88
		assertNotNull(affected);
89
		assertNotNull(affected);
89
		assertEquals(Collections.singleton(testResource), affected);
90
		assertEquals(Collections.singleton(testResource), affected);
Lines 115-120 Link Here
115
		IUndoContext ctx = new TestUndoContext();
116
		IUndoContext ctx = new TestUndoContext();
116
		
117
		
117
		IUndoableOperation oper = new TestOperation(domain) {
118
		IUndoableOperation oper = new TestOperation(domain) {
119
			@Override
118
			protected void doExecute() {
120
			protected void doExecute() {
119
				book.setTitle(newTitle);
121
				book.setTitle(newTitle);
120
				newAuthor.getBooks().add(book);
122
				newAuthor.getBooks().add(book);
Lines 127-137 Link Here
127
			fail(e);
129
			fail(e);
128
		}
130
		}
129
		
131
		
130
		Set affected = ResourceUndoContext.getAffectedResources(oper);
132
		Set<Resource> affected = ResourceUndoContext.getAffectedResources(oper);
131
		
133
		
132
		assertNotNull(affected);
134
		assertNotNull(affected);
133
		
135
		
134
		Set expected = new java.util.HashSet();
136
		Set<Resource> expected = new java.util.HashSet<Resource>();
135
		expected.add(testResource);
137
		expected.add(testResource);
136
		expected.add(res2);
138
		expected.add(res2);
137
		
139
		
(-)src/org/eclipse/emf/workspace/tests/CompositeEMFOperationTest.java (-16 / +49 lines)
Lines 36-41 Link Here
36
import org.eclipse.core.runtime.IStatus;
36
import org.eclipse.core.runtime.IStatus;
37
import org.eclipse.core.runtime.NullProgressMonitor;
37
import org.eclipse.core.runtime.NullProgressMonitor;
38
import org.eclipse.core.runtime.Status;
38
import org.eclipse.core.runtime.Status;
39
import org.eclipse.emf.ecore.change.ChangeDescription;
39
import org.eclipse.emf.examples.extlibrary.Book;
40
import org.eclipse.emf.examples.extlibrary.Book;
40
import org.eclipse.emf.examples.extlibrary.EXTLibraryFactory;
41
import org.eclipse.emf.examples.extlibrary.EXTLibraryFactory;
41
import org.eclipse.emf.examples.extlibrary.Library;
42
import org.eclipse.emf.examples.extlibrary.Library;
Lines 151-157 Link Here
151
		child2.addContext(ctx1);
152
		child2.addContext(ctx1);
152
		child3.addContext(ctx3);
153
		child3.addContext(ctx3);
153
		
154
		
154
		ListIterator iter = composite.listIterator();
155
		ListIterator<IUndoableOperation> iter = composite.listIterator();
155
		
156
		
156
		// no contexts, yet
157
		// no contexts, yet
157
		assertEquals(
158
		assertEquals(
Lines 310-315 Link Here
310
		CompositeEMFOperation composite = new CompositeEMFOperation(domain, "Composite"); //$NON-NLS-1$
311
		CompositeEMFOperation composite = new CompositeEMFOperation(domain, "Composite"); //$NON-NLS-1$
311
		
312
		
312
		composite.add(new TestOperation(domain) {
313
		composite.add(new TestOperation(domain) {
314
			@Override
313
			protected void doExecute() {
315
			protected void doExecute() {
314
				book.setTitle(newTitle);
316
				book.setTitle(newTitle);
315
			}});
317
			}});
Lines 317-322 Link Here
317
		composite.add(new ChangeExternalData(externalData, book));
319
		composite.add(new ChangeExternalData(externalData, book));
318
		
320
		
319
		composite.add(new TestOperation(domain) {
321
		composite.add(new TestOperation(domain) {
322
			@Override
320
			protected void doExecute() {
323
			protected void doExecute() {
321
				newAuthor.getBooks().add(book);
324
				newAuthor.getBooks().add(book);
322
			}});
325
			}});
Lines 402-407 Link Here
402
		CompositeEMFOperation composite = new CompositeEMFOperation(domain, "Composite"); //$NON-NLS-1$
405
		CompositeEMFOperation composite = new CompositeEMFOperation(domain, "Composite"); //$NON-NLS-1$
403
		
406
		
404
		composite.add(new TestOperation(domain) {
407
		composite.add(new TestOperation(domain) {
408
			@Override
405
			protected void doExecute() {
409
			protected void doExecute() {
406
				book.setTitle(newTitle);
410
				book.setTitle(newTitle);
407
			}});
411
			}});
Lines 415-420 Link Here
415
		
419
		
416
		// EMF change in the nested non-transactional composite
420
		// EMF change in the nested non-transactional composite
417
		composite2.add(new TestOperation(domain) {
421
		composite2.add(new TestOperation(domain) {
422
			@Override
418
			protected void doExecute() {
423
			protected void doExecute() {
419
				newAuthor.getBooks().add(book);
424
				newAuthor.getBooks().add(book);
420
			}});
425
			}});
Lines 502-507 Link Here
502
		CompositeEMFOperation composite = new CompositeEMFOperation(domain, "Composite"); //$NON-NLS-1$
507
		CompositeEMFOperation composite = new CompositeEMFOperation(domain, "Composite"); //$NON-NLS-1$
503
		
508
		
504
		composite.add(new TestOperation(domain) {
509
		composite.add(new TestOperation(domain) {
510
			@Override
505
			protected void doExecute() {
511
			protected void doExecute() {
506
				newAuthor.getBooks().add(book);
512
				newAuthor.getBooks().add(book);
507
			}});
513
			}});
Lines 515-520 Link Here
515
		
521
		
516
		// EMF change in the nested non-transactional composite
522
		// EMF change in the nested non-transactional composite
517
		composite2.add(new TestOperation(domain) {
523
		composite2.add(new TestOperation(domain) {
524
			@Override
518
			protected void doExecute() {
525
			protected void doExecute() {
519
				book.setTitle(null);  // will not pass validation
526
				book.setTitle(null);  // will not pass validation
520
			}});
527
			}});
Lines 568-573 Link Here
568
		CompositeEMFOperation composite = new CompositeEMFOperation(domain, "Composite"); //$NON-NLS-1$
575
		CompositeEMFOperation composite = new CompositeEMFOperation(domain, "Composite"); //$NON-NLS-1$
569
		
576
		
570
		composite.add(new TestOperation(domain) {
577
		composite.add(new TestOperation(domain) {
578
			@Override
571
			protected void doExecute() {
579
			protected void doExecute() {
572
				// add a new library.  Our triggers will set a default name and book
580
				// add a new library.  Our triggers will set a default name and book
573
				newLibrary[0] = EXTLibraryFactory.eINSTANCE.createLibrary();
581
				newLibrary[0] = EXTLibraryFactory.eINSTANCE.createLibrary();
Lines 592-598 Link Here
592
		
600
		
593
		assertEquals("New Library", newLibrary[0].getName()); //$NON-NLS-1$
601
		assertEquals("New Library", newLibrary[0].getName()); //$NON-NLS-1$
594
		assertEquals(1, newLibrary[0].getBooks().size());
602
		assertEquals(1, newLibrary[0].getBooks().size());
595
		assertEquals("New Book", ((Book) newLibrary[0].getBooks().get(0)).getTitle()); //$NON-NLS-1$
603
		assertEquals("New Book", newLibrary[0].getBooks().get(0).getTitle()); //$NON-NLS-1$
596
		assertEquals("New Book", externalData[0]); //$NON-NLS-1$
604
		assertEquals("New Book", externalData[0]); //$NON-NLS-1$
597
		
605
		
598
		commit();
606
		commit();
Lines 627-633 Link Here
627
		assertTrue(root.getBranches().contains(newLibrary[0]));
635
		assertTrue(root.getBranches().contains(newLibrary[0]));
628
		assertEquals("New Library", newLibrary[0].getName()); //$NON-NLS-1$
636
		assertEquals("New Library", newLibrary[0].getName()); //$NON-NLS-1$
629
		assertEquals(1, newLibrary[0].getBooks().size());
637
		assertEquals(1, newLibrary[0].getBooks().size());
630
		assertEquals("New Book", ((Book) newLibrary[0].getBooks().get(0)).getTitle()); //$NON-NLS-1$
638
		assertEquals("New Book", newLibrary[0].getBooks().get(0).getTitle()); //$NON-NLS-1$
631
		assertEquals("New Book", externalData[0]); //$NON-NLS-1$
639
		assertEquals("New Book", externalData[0]); //$NON-NLS-1$
632
		
640
		
633
		commit();
641
		commit();
Lines 654-659 Link Here
654
		CompositeEMFOperation composite = new CompositeEMFOperation(domain, "Composite"); //$NON-NLS-1$
662
		CompositeEMFOperation composite = new CompositeEMFOperation(domain, "Composite"); //$NON-NLS-1$
655
		
663
		
656
		composite.add(new TestOperation(domain) {
664
		composite.add(new TestOperation(domain) {
665
			@Override
657
			protected void doExecute() {
666
			protected void doExecute() {
658
				// add a new library.  Our triggers will set a default name and book
667
				// add a new library.  Our triggers will set a default name and book
659
				newLibrary[0] = EXTLibraryFactory.eINSTANCE.createLibrary();
668
				newLibrary[0] = EXTLibraryFactory.eINSTANCE.createLibrary();
Lines 674-680 Link Here
674
		
683
		
675
		assertEquals("New Library", newLibrary[0].getName()); //$NON-NLS-1$
684
		assertEquals("New Library", newLibrary[0].getName()); //$NON-NLS-1$
676
		assertEquals(1, newLibrary[0].getBooks().size());
685
		assertEquals(1, newLibrary[0].getBooks().size());
677
		assertEquals("New Book", ((Book) newLibrary[0].getBooks().get(0)).getTitle()); //$NON-NLS-1$
686
		assertEquals("New Book", newLibrary[0].getBooks().get(0).getTitle()); //$NON-NLS-1$
678
		
687
		
679
		commit();
688
		commit();
680
689
Lines 707-713 Link Here
707
		assertTrue(root.getBranches().contains(newLibrary[0]));
716
		assertTrue(root.getBranches().contains(newLibrary[0]));
708
		assertEquals("New Library", newLibrary[0].getName()); //$NON-NLS-1$
717
		assertEquals("New Library", newLibrary[0].getName()); //$NON-NLS-1$
709
		assertEquals(1, newLibrary[0].getBooks().size());
718
		assertEquals(1, newLibrary[0].getBooks().size());
710
		assertEquals("New Book", ((Book) newLibrary[0].getBooks().get(0)).getTitle()); //$NON-NLS-1$
719
		assertEquals("New Book", newLibrary[0].getBooks().get(0).getTitle()); //$NON-NLS-1$
711
		
720
		
712
		commit();
721
		commit();
713
	}
722
	}
Lines 738-743 Link Here
738
		CompositeEMFOperation composite = new CompositeEMFOperation(domain, "Composite"); //$NON-NLS-1$
747
		CompositeEMFOperation composite = new CompositeEMFOperation(domain, "Composite"); //$NON-NLS-1$
739
		
748
		
740
		composite.add(new TestOperation(domain) {
749
		composite.add(new TestOperation(domain) {
750
			@Override
741
			protected void doExecute() {
751
			protected void doExecute() {
742
				book.setTitle(newTitle);
752
				book.setTitle(newTitle);
743
			}});
753
			}});
Lines 745-750 Link Here
745
		composite.add(new ChangeExternalData(externalData, book));
755
		composite.add(new ChangeExternalData(externalData, book));
746
		
756
		
747
		composite.add(new TestOperation(domain) {
757
		composite.add(new TestOperation(domain) {
758
			@Override
748
			protected void doExecute() {
759
			protected void doExecute() {
749
				newAuthor.getBooks().add(book);
760
				newAuthor.getBooks().add(book);
750
			}});
761
			}});
Lines 1278-1283 Link Here
1278
		composite.setTransactionNestingEnabled(false);
1289
		composite.setTransactionNestingEnabled(false);
1279
		
1290
		
1280
		composite.add(new TestOperation(domain) {
1291
		composite.add(new TestOperation(domain) {
1292
			@Override
1281
			protected void doExecute() {
1293
			protected void doExecute() {
1282
				// add a new library
1294
				// add a new library
1283
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
1295
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
Lines 1285-1295 Link Here
1285
1297
1286
		CompositeEMFOperation nestedComposite = new CompositeEMFOperation(domain, "Nested"); //$NON-NLS-1$
1298
		CompositeEMFOperation nestedComposite = new CompositeEMFOperation(domain, "Nested"); //$NON-NLS-1$
1287
		nestedComposite.add(new TestOperation(domain) {
1299
		nestedComposite.add(new TestOperation(domain) {
1300
			@Override
1288
			protected void doExecute() {
1301
			protected void doExecute() {
1289
				// add a new library
1302
				// add a new library
1290
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
1303
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
1291
			}});
1304
			}});
1292
		nestedComposite.add(new TestOperation(domain) {
1305
		nestedComposite.add(new TestOperation(domain) {
1306
			@Override
1293
			protected void doExecute() {
1307
			protected void doExecute() {
1294
				// add a new library
1308
				// add a new library
1295
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
1309
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
Lines 1308-1314 Link Here
1308
		assertNotNull(transaction);
1322
		assertNotNull(transaction);
1309
		
1323
		
1310
		// only one transaction (contributing one change description to the composite)
1324
		// only one transaction (contributing one change description to the composite)
1311
		Collection changes = getChanges(transaction);
1325
		Collection<ChangeDescription> changes = getChanges(transaction);
1312
		assertEquals(1, changes.size());
1326
		assertEquals(1, changes.size());
1313
		
1327
		
1314
		capture.clear();
1328
		capture.clear();
Lines 1392-1397 Link Here
1392
		composite.setTransactionNestingEnabled(false);
1406
		composite.setTransactionNestingEnabled(false);
1393
		
1407
		
1394
		composite.add(new TestOperation(domain) {
1408
		composite.add(new TestOperation(domain) {
1409
			@Override
1395
			protected void doExecute() {
1410
			protected void doExecute() {
1396
				// add a new library
1411
				// add a new library
1397
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
1412
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
Lines 1400-1410 Link Here
1400
		CompositeEMFOperation nestedComposite = new CompositeEMFOperation(domain, "Nested"); //$NON-NLS-1$
1415
		CompositeEMFOperation nestedComposite = new CompositeEMFOperation(domain, "Nested"); //$NON-NLS-1$
1401
		nestedComposite.add(new ChangeExternalData(externalData, book));  // non-EMF change
1416
		nestedComposite.add(new ChangeExternalData(externalData, book));  // non-EMF change
1402
		nestedComposite.add(new TestOperation(domain) {
1417
		nestedComposite.add(new TestOperation(domain) {
1418
			@Override
1403
			protected void doExecute() {
1419
			protected void doExecute() {
1404
				// add a new library
1420
				// add a new library
1405
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
1421
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
1406
			}});
1422
			}});
1407
		nestedComposite.add(new TestOperation(domain) {
1423
		nestedComposite.add(new TestOperation(domain) {
1424
			@Override
1408
			protected void doExecute() {
1425
			protected void doExecute() {
1409
				// add a new library
1426
				// add a new library
1410
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
1427
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
Lines 1427-1433 Link Here
1427
		//    before the non-EMF changes, one change for the non-EMF changes,
1444
		//    before the non-EMF changes, one change for the non-EMF changes,
1428
		//    and one change for everything after.  We would have 4 changes
1445
		//    and one change for everything after.  We would have 4 changes
1429
		//    without the no-nesting hint
1446
		//    without the no-nesting hint
1430
		Collection changes = getChanges(transaction);
1447
		Collection<ChangeDescription> changes = getChanges(transaction);
1431
		assertEquals(3, changes.size());
1448
		assertEquals(3, changes.size());
1432
		
1449
		
1433
		capture.clear();
1450
		capture.clear();
Lines 1507-1512 Link Here
1507
		composite.setTransactionNestingEnabled(false);
1524
		composite.setTransactionNestingEnabled(false);
1508
		
1525
		
1509
		composite.add(new TestOperation(domain) {
1526
		composite.add(new TestOperation(domain) {
1527
			@Override
1510
			protected void doExecute() {
1528
			protected void doExecute() {
1511
				// add a new library
1529
				// add a new library
1512
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
1530
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
Lines 1516-1531 Link Here
1516
		nestedComposite.add(new TestOperation(domain,
1534
		nestedComposite.add(new TestOperation(domain,
1517
				// this transaction has different options
1535
				// this transaction has different options
1518
				Collections.singletonMap(Transaction.OPTION_NO_NOTIFICATIONS, Boolean.TRUE)) {
1536
				Collections.singletonMap(Transaction.OPTION_NO_NOTIFICATIONS, Boolean.TRUE)) {
1537
			@Override
1519
			protected void doExecute() {
1538
			protected void doExecute() {
1520
				// add a new library
1539
				// add a new library
1521
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
1540
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
1522
			}});
1541
			}});
1523
		nestedComposite.add(new TestOperation(domain) {
1542
		nestedComposite.add(new TestOperation(domain) {
1543
			@Override
1524
			protected void doExecute() {
1544
			protected void doExecute() {
1525
				// add a new library
1545
				// add a new library
1526
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
1546
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
1527
			}});
1547
			}});
1528
		nestedComposite.add(new TestOperation(domain) {
1548
		nestedComposite.add(new TestOperation(domain) {
1549
			@Override
1529
			protected void doExecute() {
1550
			protected void doExecute() {
1530
				// add a new library
1551
				// add a new library
1531
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
1552
				root.getBranches().add(EXTLibraryFactory.eINSTANCE.createLibrary());
Lines 1548-1554 Link Here
1548
		//    before the different options, one change for the different options,
1569
		//    before the different options, one change for the different options,
1549
		//    and one change for everything after.  We would have 4 changes
1570
		//    and one change for everything after.  We would have 4 changes
1550
		//    without the no-nesting hint
1571
		//    without the no-nesting hint
1551
		Collection changes = getChanges(transaction);
1572
		Collection<ChangeDescription> changes = getChanges(transaction);
1552
		assertEquals(3, changes.size());
1573
		assertEquals(3, changes.size());
1553
		
1574
		
1554
		capture.clear();
1575
		capture.clear();
Lines 1610-1623 Link Here
1610
	 * Does a reflective hack to get the private <tt>changes</tt> field of a
1631
	 * Does a reflective hack to get the private <tt>changes</tt> field of a
1611
	 * composite change description.
1632
	 * composite change description.
1612
	 */
1633
	 */
1613
	private Collection getChanges(Transaction tx) {
1634
	@SuppressWarnings("unchecked")
1614
		Collection result = null;
1635
	private Collection<ChangeDescription> getChanges(Transaction tx) {
1636
		Collection<ChangeDescription> result = null;
1615
		CompositeChangeDescription composite = (CompositeChangeDescription) tx.getChangeDescription();
1637
		CompositeChangeDescription composite = (CompositeChangeDescription) tx.getChangeDescription();
1616
		
1638
		
1617
		try {
1639
		try {
1618
			Field changes = composite.getClass().getDeclaredField("changes"); //$NON-NLS-1$
1640
			Field changes = composite.getClass().getDeclaredField("changes"); //$NON-NLS-1$
1619
			changes.setAccessible(true);
1641
			changes.setAccessible(true);
1620
			result = (Collection) changes.get(composite);
1642
			result = (Collection<ChangeDescription>) changes.get(composite);
1621
		} catch (Exception e) {
1643
		} catch (Exception e) {
1622
			fail("Could not access private changes field of CompositeChangeDescription: " + e.getLocalizedMessage()); //$NON-NLS-1$
1644
			fail("Could not access private changes field of CompositeChangeDescription: " + e.getLocalizedMessage()); //$NON-NLS-1$
1623
		}
1645
		}
Lines 1644-1656 Link Here
1644
			this.library = library;
1666
			this.library = library;
1645
		}
1667
		}
1646
		
1668
		
1669
		@Override
1647
		public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
1670
		public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
1648
			oldData = externalData[0];
1671
			oldData = externalData[0];
1649
			
1672
			
1650
			// can safely read in the enclosing composite's write transaction
1673
			// can safely read in the enclosing composite's write transaction
1651
			if (book == null) {
1674
			if (book == null) {
1652
				// get the book from the new library, then
1675
				// get the book from the new library, then
1653
				book = (Book) library[0].getBooks().get(0);
1676
				book = library[0].getBooks().get(0);
1654
			}
1677
			}
1655
			
1678
			
1656
			externalData[0] = book.getTitle();
1679
			externalData[0] = book.getTitle();
Lines 1658-1668 Link Here
1658
			return Status.OK_STATUS;
1681
			return Status.OK_STATUS;
1659
		}
1682
		}
1660
		
1683
		
1684
		@Override
1661
		public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
1685
		public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
1662
			externalData[0] = oldData;
1686
			externalData[0] = oldData;
1663
			return Status.OK_STATUS;
1687
			return Status.OK_STATUS;
1664
		}
1688
		}
1665
		
1689
		
1690
		@Override
1666
		public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
1691
		public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
1667
			externalData[0] = book.getTitle();
1692
			externalData[0] = book.getTitle();
1668
			return Status.OK_STATUS;
1693
			return Status.OK_STATUS;
Lines 1670-1679 Link Here
1670
	}
1695
	}
1671
	
1696
	
1672
	private static class FailCancelOperation extends AbstractOperation {
1697
	private static class FailCancelOperation extends AbstractOperation {
1673
		private IStatus executeStatus;
1698
		private final IStatus executeStatus;
1674
		private IStatus undoStatus;
1699
		private final IStatus undoStatus;
1675
		private IStatus redoStatus;
1700
		private final IStatus redoStatus;
1676
		private boolean cancelMonitor;
1701
		private final boolean cancelMonitor;
1677
		
1702
		
1678
		FailCancelOperation(IStatus exec, IStatus undo, IStatus redo, boolean cancel) {
1703
		FailCancelOperation(IStatus exec, IStatus undo, IStatus redo, boolean cancel) {
1679
			super("Fail/Cancel Operation"); //$NON-NLS-1$
1704
			super("Fail/Cancel Operation"); //$NON-NLS-1$
Lines 1683-1688 Link Here
1683
			this.cancelMonitor = cancel;
1708
			this.cancelMonitor = cancel;
1684
		}
1709
		}
1685
		
1710
		
1711
		@Override
1686
		public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
1712
		public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
1687
			if ((executeStatus.getSeverity() == IStatus.CANCEL) && cancelMonitor) {
1713
			if ((executeStatus.getSeverity() == IStatus.CANCEL) && cancelMonitor) {
1688
				monitor.setCanceled(true);
1714
				monitor.setCanceled(true);
Lines 1692-1697 Link Here
1692
			return executeStatus;
1718
			return executeStatus;
1693
		}
1719
		}
1694
		
1720
		
1721
		@Override
1695
		public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
1722
		public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
1696
			if ((undoStatus.getSeverity() == IStatus.CANCEL) && cancelMonitor) {
1723
			if ((undoStatus.getSeverity() == IStatus.CANCEL) && cancelMonitor) {
1697
				monitor.setCanceled(true);
1724
				monitor.setCanceled(true);
Lines 1701-1706 Link Here
1701
			return undoStatus;
1728
			return undoStatus;
1702
		}
1729
		}
1703
		
1730
		
1731
		@Override
1704
		public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
1732
		public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
1705
			if ((redoStatus.getSeverity() == IStatus.CANCEL) && cancelMonitor) {
1733
			if ((redoStatus.getSeverity() == IStatus.CANCEL) && cancelMonitor) {
1706
				monitor.setCanceled(true);
1734
				monitor.setCanceled(true);
Lines 1726-1743 Link Here
1726
			wasRedone = false;
1754
			wasRedone = false;
1727
		}
1755
		}
1728
		
1756
		
1757
		@Override
1729
		public IStatus execute(IProgressMonitor monitor, IAdaptable info)
1758
		public IStatus execute(IProgressMonitor monitor, IAdaptable info)
1730
			throws ExecutionException {
1759
			throws ExecutionException {
1731
			wasExecuted = true;
1760
			wasExecuted = true;
1732
			return Status.OK_STATUS;
1761
			return Status.OK_STATUS;
1733
		}
1762
		}
1734
		
1763
		
1764
		@Override
1735
		public IStatus undo(IProgressMonitor monitor, IAdaptable info)
1765
		public IStatus undo(IProgressMonitor monitor, IAdaptable info)
1736
			throws ExecutionException {
1766
			throws ExecutionException {
1737
			wasUndone = true;
1767
			wasUndone = true;
1738
			return Status.OK_STATUS;
1768
			return Status.OK_STATUS;
1739
		}
1769
		}
1740
		
1770
		
1771
		@Override
1741
		public IStatus redo(IProgressMonitor monitor, IAdaptable info)
1772
		public IStatus redo(IProgressMonitor monitor, IAdaptable info)
1742
			throws ExecutionException {
1773
			throws ExecutionException {
1743
			wasRedone = true;
1774
			wasRedone = true;
Lines 1748-1757 Link Here
1748
	private static class TransactionCapture extends ResourceSetListenerImpl {
1779
	private static class TransactionCapture extends ResourceSetListenerImpl {
1749
		private Transaction transaction;
1780
		private Transaction transaction;
1750
		
1781
		
1782
		@Override
1751
		public boolean isPostcommitOnly() {
1783
		public boolean isPostcommitOnly() {
1752
			return true;
1784
			return true;
1753
		}
1785
		}
1754
		
1786
		
1787
		@Override
1755
		public void resourceSetChanged(ResourceSetChangeEvent event) {
1788
		public void resourceSetChanged(ResourceSetChangeEvent event) {
1756
			if (transaction == null) {
1789
			if (transaction == null) {
1757
				transaction = event.getTransaction();
1790
				transaction = event.getTransaction();
(-)src/org/eclipse/emf/workspace/tests/BasicWorkbenchTest.java (-9 / +4 lines)
Lines 17-23 Link Here
17
package org.eclipse.emf.workspace.tests;
17
package org.eclipse.emf.workspace.tests;
18
18
19
import java.util.Collections;
19
import java.util.Collections;
20
import java.util.Iterator;
21
import java.util.List;
20
import java.util.List;
22
21
23
import junit.framework.Test;
22
import junit.framework.Test;
Lines 33-41 Link Here
33
import org.eclipse.emf.examples.extlibrary.Book;
32
import org.eclipse.emf.examples.extlibrary.Book;
34
import org.eclipse.emf.examples.extlibrary.EXTLibraryFactory;
33
import org.eclipse.emf.examples.extlibrary.EXTLibraryFactory;
35
import org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
34
import org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
35
import org.eclipse.emf.transaction.Transaction;
36
import org.eclipse.emf.transaction.TransactionalCommandStack;
36
import org.eclipse.emf.transaction.TransactionalCommandStack;
37
import org.eclipse.emf.transaction.TransactionalEditingDomain;
37
import org.eclipse.emf.transaction.TransactionalEditingDomain;
38
import org.eclipse.emf.transaction.Transaction;
39
import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
38
import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
40
import org.eclipse.emf.workspace.tests.fixtures.TestListener;
39
import org.eclipse.emf.workspace.tests.fixtures.TestListener;
41
40
Lines 301-307 Link Here
301
		
300
		
302
		// check that we got the expected events
301
		// check that we got the expected events
303
		assertNotNull(listener.postcommit);
302
		assertNotNull(listener.postcommit);
304
		List notifications = listener.postcommit.getNotifications();
303
		List<Notification> notifications = listener.postcommit.getNotifications();
305
		assertFalse(notifications.isEmpty());
304
		assertFalse(notifications.isEmpty());
306
		
305
		
307
		// look for an event indicating resource was loaded and one indicating
306
		// look for an event indicating resource was loaded and one indicating
Lines 309-317 Link Here
309
		Notification rootAdded = null;
308
		Notification rootAdded = null;
310
		Notification resLoaded = null;
309
		Notification resLoaded = null;
311
		
310
		
312
		for (Iterator iter = notifications.iterator(); iter.hasNext();) {
311
		for (Notification next : notifications) {
313
			Notification next = (Notification) iter.next();
314
			
315
			if (next.getNotifier() == res) {
312
			if (next.getNotifier() == res) {
316
				if (next.getFeatureID(null) == Resource.RESOURCE__IS_LOADED) {
313
				if (next.getFeatureID(null) == Resource.RESOURCE__IS_LOADED) {
317
					if (next.getNewBooleanValue()) {
314
					if (next.getNewBooleanValue()) {
Lines 347-355 Link Here
347
		Notification rootRemoved = null;
344
		Notification rootRemoved = null;
348
		Notification resUnloaded = null;
345
		Notification resUnloaded = null;
349
		
346
		
350
		for (Iterator iter = notifications.iterator(); iter.hasNext();) {
347
		for (Notification next : notifications) {
351
			Notification next = (Notification) iter.next();
352
			
353
			if (next.getNotifier() == res) {
348
			if (next.getNotifier() == res) {
354
				if (next.getFeatureID(null) == Resource.RESOURCE__IS_LOADED) {
349
				if (next.getFeatureID(null) == Resource.RESOURCE__IS_LOADED) {
355
					if (!next.getNewBooleanValue()) {
350
					if (!next.getNewBooleanValue()) {
(-)src/org/eclipse/emf/workspace/tests/AllTests.java (-3 / +8 lines)
Lines 23-29 Link Here
23
import junit.framework.TestSuite;
23
import junit.framework.TestSuite;
24
import junit.textui.TestRunner;
24
import junit.textui.TestRunner;
25
25
26
import org.eclipse.core.runtime.IPlatformRunnable;
26
import org.eclipse.equinox.app.IApplication;
27
import org.eclipse.equinox.app.IApplicationContext;
27
28
28
/**
29
/**
29
 * Master JUnit test suite for the <em>EMF Workbench API</em>.
30
 * Master JUnit test suite for the <em>EMF Workbench API</em>.
Lines 32-38 Link Here
32
 */
33
 */
33
public class AllTests
34
public class AllTests
34
	extends TestCase
35
	extends TestCase
35
	implements IPlatformRunnable {
36
	implements IApplication {
36
37
37
	public AllTests() {
38
	public AllTests() {
38
		super(""); //$NON-NLS-1$
39
		super(""); //$NON-NLS-1$
Lines 54-64 Link Here
54
		return suite;
55
		return suite;
55
	}
56
	}
56
57
57
	public Object run(Object args)
58
	public Object start(IApplicationContext context)
58
		throws Exception {
59
		throws Exception {
59
60
60
		TestRunner.run(suite());
61
		TestRunner.run(suite());
61
		return Arrays
62
		return Arrays
62
			.asList(new String[] {"Please see raw test suite output for details."}); //$NON-NLS-1$
63
			.asList(new String[] {"Please see raw test suite output for details."}); //$NON-NLS-1$
63
	}
64
	}
65
	
66
	public void stop() {
67
		// nothing to do
68
	}
64
}
69
}
(-)src/org/eclipse/emf/workspace/tests/MemoryLeakTest.java (-24 / +40 lines)
Lines 32-40 Link Here
32
import org.eclipse.core.runtime.Status;
32
import org.eclipse.core.runtime.Status;
33
import org.eclipse.emf.common.command.Command;
33
import org.eclipse.emf.common.command.Command;
34
import org.eclipse.emf.common.notify.Notification;
34
import org.eclipse.emf.common.notify.Notification;
35
import org.eclipse.emf.common.util.BasicEList;
36
import org.eclipse.emf.ecore.EObject;
35
import org.eclipse.emf.ecore.EObject;
37
import org.eclipse.emf.ecore.EReference;
36
import org.eclipse.emf.ecore.EReference;
37
import org.eclipse.emf.ecore.change.ChangeDescription;
38
import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
38
import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
39
import org.eclipse.emf.ecore.util.EcoreUtil;
39
import org.eclipse.emf.ecore.util.EcoreUtil;
40
import org.eclipse.emf.edit.command.CommandParameter;
40
import org.eclipse.emf.edit.command.CommandParameter;
Lines 95-104 Link Here
95
        assertTrue(level1.eAdapters().contains(xrefAdapter));
95
        assertTrue(level1.eAdapters().contains(xrefAdapter));
96
        
96
        
97
        Command cmd = new RemoveCommand(domain, root, EXTLibraryPackage.Literals.LIBRARY__BRANCHES, level1) {
97
        Command cmd = new RemoveCommand(domain, root, EXTLibraryPackage.Literals.LIBRARY__BRANCHES, level1) {
98
            public void doDispose() {
98
            @Override
99
			public void doDispose() {
99
                if (feature instanceof EReference && ((EReference) feature).isContainment()) {
100
                if (feature instanceof EReference && ((EReference) feature).isContainment()) {
100
                    for (Iterator iter = collection.iterator(); iter.hasNext();) {
101
                    for (Object o : collection) {
101
                        EObject next = (EObject) iter.next();
102
                        EObject next = (EObject) o;
102
                        
103
                        
103
                        // clear adapters on the removed object if it is still removed
104
                        // clear adapters on the removed object if it is still removed
104
                        if (next.eContainer() != owner) {
105
                        if (next.eContainer() != owner) {
Lines 158-164 Link Here
158
        assertTrue(level1.eAdapters().contains(xrefAdapter));
159
        assertTrue(level1.eAdapters().contains(xrefAdapter));
159
        
160
        
160
        Command cmd = new RecordingCommand(domain, "Remove Branch") { //$NON-NLS-1$
161
        Command cmd = new RecordingCommand(domain, "Remove Branch") { //$NON-NLS-1$
161
            protected void doExecute() {
162
            @Override
163
			protected void doExecute() {
162
                root.getBranches().remove(level1);        
164
                root.getBranches().remove(level1);        
163
            }};
165
            }};
164
        
166
        
Lines 213-222 Link Here
213
        assertTrue(level1.eAdapters().contains(xrefAdapter));
215
        assertTrue(level1.eAdapters().contains(xrefAdapter));
214
        
216
        
215
        final Command trigger = new RemoveCommand(domain, root, EXTLibraryPackage.Literals.LIBRARY__BRANCHES, level1) {
217
        final Command trigger = new RemoveCommand(domain, root, EXTLibraryPackage.Literals.LIBRARY__BRANCHES, level1) {
216
            public void doDispose() {
218
            @Override
219
			public void doDispose() {
217
                if (feature instanceof EReference && ((EReference) feature).isContainment()) {
220
                if (feature instanceof EReference && ((EReference) feature).isContainment()) {
218
                    for (Iterator iter = collection.iterator(); iter.hasNext();) {
221
                    for (Object o : collection) {
219
                        EObject next = (EObject) iter.next();
222
                        EObject next = (EObject) o;
220
                        
223
                        
221
                        // clear adapters on the removed object if it is still removed
224
                        // clear adapters on the removed object if it is still removed
222
                        if (next.eContainer() != owner) {
225
                        if (next.eContainer() != owner) {
Lines 229-235 Link Here
229
            }};
232
            }};
230
        
233
        
231
        domain.addResourceSetListener(new TriggerListener() {
234
        domain.addResourceSetListener(new TriggerListener() {
232
            protected Command trigger(TransactionalEditingDomain domain,
235
            @Override
236
			protected Command trigger(TransactionalEditingDomain domain,
233
                    Notification notification) {
237
                    Notification notification) {
234
                // trigger on the name change only
238
                // trigger on the name change only
235
                if (notification.getFeature() == EXTLibraryPackage.Literals.LIBRARY__NAME) {
239
                if (notification.getFeature() == EXTLibraryPackage.Literals.LIBRARY__NAME) {
Lines 291-302 Link Here
291
        assertTrue(level1.eAdapters().contains(xrefAdapter));
295
        assertTrue(level1.eAdapters().contains(xrefAdapter));
292
        
296
        
293
        final Command trigger = new RecordingCommand(domain, "Remove Branch") { //$NON-NLS-1$
297
        final Command trigger = new RecordingCommand(domain, "Remove Branch") { //$NON-NLS-1$
294
            protected void doExecute() {
298
            @Override
299
			protected void doExecute() {
295
                root.getBranches().remove(level1);        
300
                root.getBranches().remove(level1);        
296
            }};
301
            }};
297
        
302
        
298
        domain.addResourceSetListener(new TriggerListener() {
303
        domain.addResourceSetListener(new TriggerListener() {
299
            protected Command trigger(TransactionalEditingDomain domain,
304
            @Override
305
			protected Command trigger(TransactionalEditingDomain domain,
300
                    Notification notification) {
306
                    Notification notification) {
301
                // trigger on the name change only
307
                // trigger on the name change only
302
                if (notification.getFeature() == EXTLibraryPackage.Literals.LIBRARY__NAME) {
308
                if (notification.getFeature() == EXTLibraryPackage.Literals.LIBRARY__NAME) {
Lines 353-359 Link Here
353
        assertTrue(level1.eAdapters().contains(xrefAdapter));
359
        assertTrue(level1.eAdapters().contains(xrefAdapter));
354
        
360
        
355
        IUndoableOperation oper = new AbstractEMFOperation(domain, "Remove Branch") { //$NON-NLS-1$
361
        IUndoableOperation oper = new AbstractEMFOperation(domain, "Remove Branch") { //$NON-NLS-1$
356
            protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
362
            @Override
363
			protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
357
                throws ExecutionException {
364
                throws ExecutionException {
358
                
365
                
359
                root.getBranches().remove(level1);
366
                root.getBranches().remove(level1);
Lines 422-433 Link Here
422
        assertTrue(level1.eAdapters().contains(xrefAdapter));
429
        assertTrue(level1.eAdapters().contains(xrefAdapter));
423
        
430
        
424
        final Command trigger = new RecordingCommand(domain, "Remove Branch") { //$NON-NLS-1$
431
        final Command trigger = new RecordingCommand(domain, "Remove Branch") { //$NON-NLS-1$
425
            protected void doExecute() {
432
            @Override
433
			protected void doExecute() {
426
                root.getBranches().remove(level1);        
434
                root.getBranches().remove(level1);        
427
            }};
435
            }};
428
        
436
        
429
        domain.addResourceSetListener(new TriggerListener() {
437
        domain.addResourceSetListener(new TriggerListener() {
430
            protected Command trigger(TransactionalEditingDomain domain,
438
            @Override
439
			protected Command trigger(TransactionalEditingDomain domain,
431
                    Notification notification) {
440
                    Notification notification) {
432
                // trigger on the name change only
441
                // trigger on the name change only
433
                if (notification.getFeature() == EXTLibraryPackage.Literals.LIBRARY__NAME) {
442
                if (notification.getFeature() == EXTLibraryPackage.Literals.LIBRARY__NAME) {
Lines 438-444 Link Here
438
            }});
447
            }});
439
        
448
        
440
        IUndoableOperation oper = new AbstractEMFOperation(domain, "Rename Library") { //$NON-NLS-1$
449
        IUndoableOperation oper = new AbstractEMFOperation(domain, "Rename Library") { //$NON-NLS-1$
441
            protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
450
            @Override
451
			protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
442
                throws ExecutionException {
452
                throws ExecutionException {
443
                
453
                
444
                root.setName("newname"); //$NON-NLS-1$
454
                root.setName("newname"); //$NON-NLS-1$
Lines 507-513 Link Here
507
        assertTrue(level1.eAdapters().contains(xrefAdapter));
517
        assertTrue(level1.eAdapters().contains(xrefAdapter));
508
        
518
        
509
        IUndoableOperation triggerOper = new AbstractEMFOperation(domain, "Remove Branch") { //$NON-NLS-1$
519
        IUndoableOperation triggerOper = new AbstractEMFOperation(domain, "Remove Branch") { //$NON-NLS-1$
510
            protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
520
            @Override
521
			protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
511
                throws ExecutionException {
522
                throws ExecutionException {
512
                
523
                
513
                root.getBranches().remove(level1);  
524
                root.getBranches().remove(level1);  
Lines 517-523 Link Here
517
        final Command trigger = new EMFOperationCommand(domain, triggerOper);
528
        final Command trigger = new EMFOperationCommand(domain, triggerOper);
518
        
529
        
519
        domain.addResourceSetListener(new TriggerListener() {
530
        domain.addResourceSetListener(new TriggerListener() {
520
            protected Command trigger(TransactionalEditingDomain domain,
531
            @Override
532
			protected Command trigger(TransactionalEditingDomain domain,
521
                    Notification notification) {
533
                    Notification notification) {
522
                // trigger on the name change only
534
                // trigger on the name change only
523
                if (notification.getFeature() == EXTLibraryPackage.Literals.LIBRARY__NAME) {
535
                if (notification.getFeature() == EXTLibraryPackage.Literals.LIBRARY__NAME) {
Lines 528-534 Link Here
528
            }});
540
            }});
529
        
541
        
530
        IUndoableOperation oper = new AbstractEMFOperation(domain, "Rename Library") { //$NON-NLS-1$
542
        IUndoableOperation oper = new AbstractEMFOperation(domain, "Rename Library") { //$NON-NLS-1$
531
            protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
543
            @Override
544
			protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
532
                throws ExecutionException {
545
                throws ExecutionException {
533
                
546
                
534
                root.setName("newname"); //$NON-NLS-1$
547
                root.setName("newname"); //$NON-NLS-1$
Lines 579-597 Link Here
579
    //
592
    //
580
    
593
    
581
    private static class TransactionSniffer extends ResourceSetListenerImpl {
594
    private static class TransactionSniffer extends ResourceSetListenerImpl {
582
        private TransactionalEditingDomain domain;
595
        private final TransactionalEditingDomain domain;
583
        private List changes = new BasicEList.FastCompare();
596
        private final List<ChangeDescription> changes =
597
        	new java.util.ArrayList<ChangeDescription>();
584
        
598
        
585
        TransactionSniffer(TransactionalEditingDomain domain) {
599
        TransactionSniffer(TransactionalEditingDomain domain) {
586
            this.domain = domain;
600
            this.domain = domain;
587
            domain.addResourceSetListener(this);
601
            domain.addResourceSetListener(this);
588
        }
602
        }
589
        
603
        
590
        public boolean isPostcommitOnly() {
604
        @Override
605
		public boolean isPostcommitOnly() {
591
            return true;
606
            return true;
592
        }
607
        }
593
        
608
        
594
        public void resourceSetChanged(ResourceSetChangeEvent event) {
609
        @Override
610
		public void resourceSetChanged(ResourceSetChangeEvent event) {
595
            Transaction tx = event.getTransaction();
611
            Transaction tx = event.getTransaction();
596
            
612
            
597
            if ((tx != null) && (tx.getChangeDescription()) != null) {
613
            if ((tx != null) && (tx.getChangeDescription()) != null) {
Lines 603-610 Link Here
603
            // stop listening, now
619
            // stop listening, now
604
            domain.removeResourceSetListener(this);
620
            domain.removeResourceSetListener(this);
605
            
621
            
606
            for (Iterator iter = EcoreUtil.getAllContents(changes); iter.hasNext();) {
622
            for (Iterator<EObject> iter = EcoreUtil.getAllContents(changes); iter.hasNext();) {
607
                EObject next = (EObject) iter.next();
623
                EObject next = iter.next();
608
                assertEquals("Adapters not cleared.", 0, next.eAdapters().size()); //$NON-NLS-1$
624
                assertEquals("Adapters not cleared.", 0, next.eAdapters().size()); //$NON-NLS-1$
609
            }
625
            }
610
        }
626
        }
(-)src/org/eclipse/emf/workspace/tests/AbstractEMFOperationTest.java (-12 / +28 lines)
Lines 90-95 Link Here
90
		IUndoContext ctx = new TestUndoContext();
90
		IUndoContext ctx = new TestUndoContext();
91
		
91
		
92
		IUndoableOperation oper = new TestOperation(domain) {
92
		IUndoableOperation oper = new TestOperation(domain) {
93
			@Override
93
			protected void doExecute() {
94
			protected void doExecute() {
94
				book.setTitle(newTitle);
95
				book.setTitle(newTitle);
95
				newAuthor.getBooks().add(book);
96
				newAuthor.getBooks().add(book);
Lines 155-160 Link Here
155
		// one trigger sets the external data
156
		// one trigger sets the external data
156
		domain.addResourceSetListener(new TriggerListener() {
157
		domain.addResourceSetListener(new TriggerListener() {
157
		
158
		
159
			@Override
158
			protected Command trigger(TransactionalEditingDomain domain,
160
			protected Command trigger(TransactionalEditingDomain domain,
159
					Notification notification) {
161
					Notification notification) {
160
				if (notification.getFeature() == EXTLibraryPackage.Literals.LIBRARY__NAME) {
162
				if (notification.getFeature() == EXTLibraryPackage.Literals.LIBRARY__NAME) {
Lines 169-174 Link Here
169
		IUndoContext ctx = new TestUndoContext();
171
		IUndoContext ctx = new TestUndoContext();
170
		
172
		
171
		IUndoableOperation oper = new TestOperation(domain) {
173
		IUndoableOperation oper = new TestOperation(domain) {
174
			@Override
172
			protected void doExecute() {
175
			protected void doExecute() {
173
				// add a new library.  Our triggers will set a default name and book
176
				// add a new library.  Our triggers will set a default name and book
174
				newLibrary[0] = EXTLibraryFactory.eINSTANCE.createLibrary();
177
				newLibrary[0] = EXTLibraryFactory.eINSTANCE.createLibrary();
Lines 242-247 Link Here
242
		IUndoContext ctx = new TestUndoContext();
245
		IUndoContext ctx = new TestUndoContext();
243
		
246
		
244
		IUndoableOperation oper = new TestOperation(domain) {
247
		IUndoableOperation oper = new TestOperation(domain) {
248
			@Override
245
			protected void doExecute() {
249
			protected void doExecute() {
246
				// add a new library.  Our triggers will set a default name and book
250
				// add a new library.  Our triggers will set a default name and book
247
				newLibrary[0] = EXTLibraryFactory.eINSTANCE.createLibrary();
251
				newLibrary[0] = EXTLibraryFactory.eINSTANCE.createLibrary();
Lines 262-268 Link Here
262
		
266
		
263
		assertEquals("New Library", newLibrary[0].getName()); //$NON-NLS-1$
267
		assertEquals("New Library", newLibrary[0].getName()); //$NON-NLS-1$
264
		assertEquals(1, newLibrary[0].getBooks().size());
268
		assertEquals(1, newLibrary[0].getBooks().size());
265
		assertEquals("New Book", ((Book) newLibrary[0].getBooks().get(0)).getTitle()); //$NON-NLS-1$
269
		assertEquals("New Book", newLibrary[0].getBooks().get(0).getTitle()); //$NON-NLS-1$
266
		
270
		
267
		commit();
271
		commit();
268
272
Lines 293-299 Link Here
293
		assertTrue(root.getBranches().contains(newLibrary[0]));
297
		assertTrue(root.getBranches().contains(newLibrary[0]));
294
		assertEquals("New Library", newLibrary[0].getName()); //$NON-NLS-1$
298
		assertEquals("New Library", newLibrary[0].getName()); //$NON-NLS-1$
295
		assertEquals(1, newLibrary[0].getBooks().size());
299
		assertEquals(1, newLibrary[0].getBooks().size());
296
		assertEquals("New Book", ((Book) newLibrary[0].getBooks().get(0)).getTitle()); //$NON-NLS-1$
300
		assertEquals("New Book", newLibrary[0].getBooks().get(0).getTitle()); //$NON-NLS-1$
297
		
301
		
298
		commit();
302
		commit();
299
	}
303
	}
Lines 314-319 Link Here
314
		IUndoContext ctx = new TestUndoContext();
318
		IUndoContext ctx = new TestUndoContext();
315
		
319
		
316
		IUndoableOperation oper = new TestOperation(domain) {
320
		IUndoableOperation oper = new TestOperation(domain) {
321
			@Override
317
			protected void doExecute() {
322
			protected void doExecute() {
318
				// add a new library.  Our triggers will set a default name and book
323
				// add a new library.  Our triggers will set a default name and book
319
				newLibrary[0] = EXTLibraryFactory.eINSTANCE.createLibrary();
324
				newLibrary[0] = EXTLibraryFactory.eINSTANCE.createLibrary();
Lines 334-340 Link Here
334
		
339
		
335
		// the book is created by the first trigger
340
		// the book is created by the first trigger
336
		assertEquals(1, newLibrary[0].getBooks().size());
341
		assertEquals(1, newLibrary[0].getBooks().size());
337
		Book book = (Book) newLibrary[0].getBooks().get(0);
342
		Book book = newLibrary[0].getBooks().get(0);
338
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
343
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
339
		
344
		
340
		// the publication date is created by the cascaded trigger
345
		// the publication date is created by the cascaded trigger
Lines 368-374 Link Here
368
		// verify that the changes were redone
373
		// verify that the changes were redone
369
		assertTrue(root.getBranches().contains(newLibrary[0]));
374
		assertTrue(root.getBranches().contains(newLibrary[0]));
370
		assertEquals(1, newLibrary[0].getBooks().size());
375
		assertEquals(1, newLibrary[0].getBooks().size());
371
		book = (Book) newLibrary[0].getBooks().get(0);
376
		book = newLibrary[0].getBooks().get(0);
372
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
377
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
373
		assertNotNull(book.getPublicationDate());
378
		assertNotNull(book.getPublicationDate());
374
		
379
		
Lines 395-400 Link Here
395
		IUndoContext ctx = new TestUndoContext();
400
		IUndoContext ctx = new TestUndoContext();
396
		
401
		
397
		IUndoableOperation oper = new TestOperation(domain) {
402
		IUndoableOperation oper = new TestOperation(domain) {
403
			@Override
398
			protected void doExecute() {
404
			protected void doExecute() {
399
				book.setTitle(newTitle);
405
				book.setTitle(newTitle);
400
				newAuthor.getBooks().add(book);
406
				newAuthor.getBooks().add(book);
Lines 449-459 Link Here
449
		
455
		
450
		IUndoableOperation oper = new TestOperation(
456
		IUndoableOperation oper = new TestOperation(
451
				domain,
457
				domain,
452
				makeOptions(new Object[] {
458
				makeOptions(
453
					Transaction.OPTION_NO_NOTIFICATIONS, Boolean.TRUE,
459
					Transaction.OPTION_NO_NOTIFICATIONS, true,
454
					Transaction.OPTION_NO_TRIGGERS, Boolean.TRUE,
460
					Transaction.OPTION_NO_TRIGGERS, true,
455
					Transaction.OPTION_NO_VALIDATION, Boolean.TRUE,
461
					Transaction.OPTION_NO_VALIDATION, true)) {
456
				})) {
462
			
463
			@Override
457
			protected void doExecute() {
464
			protected void doExecute() {
458
				book.setTitle(newTitle);
465
				book.setTitle(newTitle);
459
				newAuthor.getBooks().add(book);
466
				newAuthor.getBooks().add(book);
Lines 498-506 Link Here
498
	public void test_rollbackNestingTransactionOnException_135673() {
505
	public void test_rollbackNestingTransactionOnException_135673() {
499
		CompositeEMFOperation outer = new CompositeEMFOperation(domain, ""); //$NON-NLS-1$
506
		CompositeEMFOperation outer = new CompositeEMFOperation(domain, ""); //$NON-NLS-1$
500
		AbstractEMFOperation inner = new AbstractEMFOperation(domain, "") { //$NON-NLS-1$
507
		AbstractEMFOperation inner = new AbstractEMFOperation(domain, "") { //$NON-NLS-1$
508
			@Override
501
			public boolean canExecute() {
509
			public boolean canExecute() {
502
				return true;
510
				return true;
503
			}
511
			}
512
			@Override
504
			protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
513
			protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
505
					throws ExecutionException {
514
					throws ExecutionException {
506
				// start some nested transactions
515
				// start some nested transactions
Lines 533-542 Link Here
533
		assertNotNull(book);
542
		assertNotNull(book);
534
		
543
		
535
		final AbstractEMFOperation emfOperation = new AbstractEMFOperation(domain, "") { //$NON-NLS-1$
544
		final AbstractEMFOperation emfOperation = new AbstractEMFOperation(domain, "") { //$NON-NLS-1$
545
			@Override
536
			public boolean canExecute() {
546
			public boolean canExecute() {
537
				return true;
547
				return true;
538
			}
548
			}
539
			
549
			
550
			@Override
540
			protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
551
			protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
541
				throws ExecutionException {
552
				throws ExecutionException {
542
				
553
				
Lines 602-611 Link Here
602
		};
613
		};
603
		
614
		
604
		AbstractEMFOperation root = new AbstractEMFOperation(domain, "") { //$NON-NLS-1$
615
		AbstractEMFOperation root = new AbstractEMFOperation(domain, "") { //$NON-NLS-1$
616
			@Override
605
			public boolean canExecute() {
617
			public boolean canExecute() {
606
				return true;
618
				return true;
607
			}
619
			}
608
			
620
			
621
			@Override
609
			protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
622
			protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
610
				throws ExecutionException {
623
				throws ExecutionException {
611
				
624
				
Lines 661-667 Link Here
661
    public void test_nullProgressMonitors_bug150033() {
674
    public void test_nullProgressMonitors_bug150033() {
662
        IUndoableOperation operation = new AbstractEMFOperation(domain, "Test") { //$NON-NLS-1$
675
        IUndoableOperation operation = new AbstractEMFOperation(domain, "Test") { //$NON-NLS-1$
663
        
676
        
664
            protected IStatus doUndo(IProgressMonitor monitor, IAdaptable info)
677
            @Override
678
			protected IStatus doUndo(IProgressMonitor monitor, IAdaptable info)
665
                throws ExecutionException {
679
                throws ExecutionException {
666
                
680
                
667
                monitor.isCanceled();
681
                monitor.isCanceled();
Lines 669-675 Link Here
669
                return super.doUndo(monitor, info);
683
                return super.doUndo(monitor, info);
670
            }
684
            }
671
        
685
        
672
            protected IStatus doRedo(IProgressMonitor monitor, IAdaptable info)
686
            @Override
687
			protected IStatus doRedo(IProgressMonitor monitor, IAdaptable info)
673
                throws ExecutionException {
688
                throws ExecutionException {
674
                
689
                
675
                monitor.isCanceled();
690
                monitor.isCanceled();
Lines 677-683 Link Here
677
                return super.doRedo(monitor, info);
692
                return super.doRedo(monitor, info);
678
            }
693
            }
679
        
694
        
680
            protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
695
            @Override
696
			protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
681
                throws ExecutionException {
697
                throws ExecutionException {
682
                
698
                
683
                monitor.isCanceled();
699
                monitor.isCanceled();
(-)src/org/eclipse/emf/workspace/tests/EMFOperationCommandTest.java (+8 lines)
Lines 161-166 Link Here
161
		
161
		
162
		domain.addResourceSetListener(new TriggerListener() {
162
		domain.addResourceSetListener(new TriggerListener() {
163
		
163
		
164
			@Override
164
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
165
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
165
				Command result = null;
166
				Command result = null;
166
				
167
				
Lines 252-257 Link Here
252
		
253
		
253
		domain.addResourceSetListener(new TriggerListener() {
254
		domain.addResourceSetListener(new TriggerListener() {
254
		
255
		
256
			@Override
255
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
257
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
256
				Command result = null;
258
				Command result = null;
257
				
259
				
Lines 315-326 Link Here
315
		
317
		
316
		Command cmd = new RecordingCommand(domain, "Testing") { //$NON-NLS-1$
318
		Command cmd = new RecordingCommand(domain, "Testing") { //$NON-NLS-1$
317
		
319
		
320
			@Override
318
			protected void doExecute() {
321
			protected void doExecute() {
319
				book.setTitle(newTitle);
322
				book.setTitle(newTitle);
320
			}};
323
			}};
321
		
324
		
322
		domain.addResourceSetListener(new TriggerListener() {
325
		domain.addResourceSetListener(new TriggerListener() {
323
		
326
		
327
			@Override
324
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
328
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
325
				Command result = null;
329
				Command result = null;
326
				
330
				
Lines 391-400 Link Here
391
	 */
395
	 */
392
	public void test_nonredoableOperation_138287() {
396
	public void test_nonredoableOperation_138287() {
393
		IUndoableOperation operation = new TestOperation(domain) {
397
		IUndoableOperation operation = new TestOperation(domain) {
398
			@Override
394
			protected void doExecute() {
399
			protected void doExecute() {
395
				// nothing to do
400
				// nothing to do
396
			}
401
			}
397
			
402
			
403
			@Override
398
			public boolean canRedo() {
404
			public boolean canRedo() {
399
				return false;
405
				return false;
400
			}};
406
			}};
Lines 412-417 Link Here
412
	// Test fixtures
418
	// Test fixtures
413
	//
419
	//
414
	
420
	
421
	@Override
415
	protected void doSetUp()
422
	protected void doSetUp()
416
		throws Exception {
423
		throws Exception {
417
		
424
		
Lines 421-426 Link Here
421
		validationEnabled = true;
428
		validationEnabled = true;
422
	}
429
	}
423
	
430
	
431
	@Override
424
	protected void doTearDown()
432
	protected void doTearDown()
425
		throws Exception {
433
		throws Exception {
426
		
434
		
(-)src/org/eclipse/emf/workspace/tests/EMFCommandOperationTest.java (-6 / +11 lines)
Lines 167-173 Link Here
167
		
167
		
168
		assertEquals("New Library", newLibrary.getName()); //$NON-NLS-1$
168
		assertEquals("New Library", newLibrary.getName()); //$NON-NLS-1$
169
		assertEquals(1, newLibrary.getBooks().size());
169
		assertEquals(1, newLibrary.getBooks().size());
170
		assertEquals("New Book", ((Book) newLibrary.getBooks().get(0)).getTitle()); //$NON-NLS-1$
170
		assertEquals("New Book", newLibrary.getBooks().get(0).getTitle()); //$NON-NLS-1$
171
		
171
		
172
		commit();
172
		commit();
173
173
Lines 198-204 Link Here
198
		assertTrue(root.getBranches().contains(newLibrary));
198
		assertTrue(root.getBranches().contains(newLibrary));
199
		assertEquals("New Library", newLibrary.getName()); //$NON-NLS-1$
199
		assertEquals("New Library", newLibrary.getName()); //$NON-NLS-1$
200
		assertEquals(1, newLibrary.getBooks().size());
200
		assertEquals(1, newLibrary.getBooks().size());
201
		assertEquals("New Book", ((Book) newLibrary.getBooks().get(0)).getTitle()); //$NON-NLS-1$
201
		assertEquals("New Book", newLibrary.getBooks().get(0).getTitle()); //$NON-NLS-1$
202
		
202
		
203
		commit();
203
		commit();
204
	}
204
	}
Lines 237-243 Link Here
237
		
237
		
238
		// the book is created by the first trigger
238
		// the book is created by the first trigger
239
		assertEquals(1, newLibrary.getBooks().size());
239
		assertEquals(1, newLibrary.getBooks().size());
240
		Book book = (Book) newLibrary.getBooks().get(0);
240
		Book book = newLibrary.getBooks().get(0);
241
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
241
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
242
		
242
		
243
		// the publication date is created by the cascaded trigger
243
		// the publication date is created by the cascaded trigger
Lines 271-277 Link Here
271
		// verify that the changes were redone
271
		// verify that the changes were redone
272
		assertTrue(root.getBranches().contains(newLibrary));
272
		assertTrue(root.getBranches().contains(newLibrary));
273
		assertEquals(1, newLibrary.getBooks().size());
273
		assertEquals(1, newLibrary.getBooks().size());
274
		book = (Book) newLibrary.getBooks().get(0);
274
		book = newLibrary.getBooks().get(0);
275
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
275
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
276
		assertNotNull(book.getPublicationDate());
276
		assertNotNull(book.getPublicationDate());
277
		
277
		
Lines 298-303 Link Here
298
		IUndoContext ctx = new TestUndoContext();
298
		IUndoContext ctx = new TestUndoContext();
299
		
299
		
300
		Command cmd = new RecordingCommand(domain) {
300
		Command cmd = new RecordingCommand(domain) {
301
			@Override
301
			protected void doExecute() {
302
			protected void doExecute() {
302
				book.setTitle(newTitle);
303
				book.setTitle(newTitle);
303
				newAuthor.getBooks().add(book);
304
				newAuthor.getBooks().add(book);
Lines 368-373 Link Here
368
		
369
		
369
		// add a new library.  Our triggers will set a default name and book
370
		// add a new library.  Our triggers will set a default name and book
370
		Command cmd = new RecordingCommand(domain) {
371
		Command cmd = new RecordingCommand(domain) {
372
			@Override
371
			protected void doExecute() {
373
			protected void doExecute() {
372
				root.getBranches().add(newLibrary);
374
				root.getBranches().add(newLibrary);
373
			}};
375
			}};
Lines 385-391 Link Here
385
		
387
		
386
		assertEquals("New Library", newLibrary.getName()); //$NON-NLS-1$
388
		assertEquals("New Library", newLibrary.getName()); //$NON-NLS-1$
387
		assertEquals(1, newLibrary.getBooks().size());
389
		assertEquals(1, newLibrary.getBooks().size());
388
		assertEquals("New Book", ((Book) newLibrary.getBooks().get(0)).getTitle()); //$NON-NLS-1$
390
		assertEquals("New Book", newLibrary.getBooks().get(0).getTitle()); //$NON-NLS-1$
389
		
391
		
390
		commit();
392
		commit();
391
393
Lines 416-422 Link Here
416
		assertTrue(root.getBranches().contains(newLibrary));
418
		assertTrue(root.getBranches().contains(newLibrary));
417
		assertEquals("New Library", newLibrary.getName()); //$NON-NLS-1$
419
		assertEquals("New Library", newLibrary.getName()); //$NON-NLS-1$
418
		assertEquals(1, newLibrary.getBooks().size());
420
		assertEquals(1, newLibrary.getBooks().size());
419
		assertEquals("New Book", ((Book) newLibrary.getBooks().get(0)).getTitle()); //$NON-NLS-1$
421
		assertEquals("New Book", newLibrary.getBooks().get(0).getTitle()); //$NON-NLS-1$
420
		
422
		
421
		commit();
423
		commit();
422
	}
424
	}
Lines 489-494 Link Here
489
				// nothing to do
491
				// nothing to do
490
			}
492
			}
491
		
493
		
494
			@Override
492
			public boolean canRedo() {
495
			public boolean canRedo() {
493
				return false;
496
				return false;
494
			}};
497
			}};
Lines 509-520 Link Here
509
	public void test_nonredoableTriggerCommand_138287() {
512
	public void test_nonredoableTriggerCommand_138287() {
510
		// add a trigger command that is not redoable
513
		// add a trigger command that is not redoable
511
		domain.addResourceSetListener(new TriggerListener() {
514
		domain.addResourceSetListener(new TriggerListener() {
515
			@Override
512
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
516
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
513
				return new TestCommand.Redoable() {
517
				return new TestCommand.Redoable() {
514
					public void execute() {
518
					public void execute() {
515
						// nothing to do
519
						// nothing to do
516
					}
520
					}
517
				
521
				
522
					@Override
518
					public boolean canRedo() {
523
					public boolean canRedo() {
519
						return false;
524
						return false;
520
					}};
525
					}};
(-)src/org/eclipse/emf/workspace/tests/TestsPlugin.java (+2 lines)
Lines 27-38 Link Here
27
public class TestsPlugin extends Plugin {
27
public class TestsPlugin extends Plugin {
28
	public static TestsPlugin instance;
28
	public static TestsPlugin instance;
29
	
29
	
30
	@Override
30
	public void start(BundleContext context) throws Exception {
31
	public void start(BundleContext context) throws Exception {
31
		super.start(context);
32
		super.start(context);
32
		
33
		
33
		instance = this;
34
		instance = this;
34
	}
35
	}
35
	
36
	
37
	@Override
36
	public void stop(BundleContext context) throws Exception {
38
	public void stop(BundleContext context) throws Exception {
37
		instance = null;
39
		instance = null;
38
		
40
		
(-)META-INF/MANIFEST.MF (-2 / +2 lines)
Lines 8-18 Link Here
8
Require-Bundle: org.junit;bundle-version="[3.8.1,4.0.0)",
8
Require-Bundle: org.junit;bundle-version="[3.8.1,4.0.0)",
9
 org.eclipse.emf.workspace;bundle-version="1.2.0",
9
 org.eclipse.emf.workspace;bundle-version="1.2.0",
10
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
10
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
11
 org.eclipse.emf.examples.library;bundle-version="[2.2.0,3.0.0)"
11
 org.eclipse.emf.examples.library;bundle-version="[2.3.0,3.0.0)"
12
Export-Package: org.eclipse.emf.workspace.tests,
12
Export-Package: org.eclipse.emf.workspace.tests,
13
 org.eclipse.emf.workspace.tests.constraints,
13
 org.eclipse.emf.workspace.tests.constraints,
14
 org.eclipse.emf.workspace.tests.fixtures,
14
 org.eclipse.emf.workspace.tests.fixtures,
15
 org.eclipse.emf.workspace.util.tests
15
 org.eclipse.emf.workspace.util.tests
16
Eclipse-LazyStart: true
16
Eclipse-LazyStart: true
17
Bundle-Activator: org.eclipse.emf.workspace.tests.TestsPlugin
17
Bundle-Activator: org.eclipse.emf.workspace.tests.TestsPlugin
18
Bundle-RequiredExecutionEnvironment: J2SE-1.4
18
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)src/org/eclipse/emf/workspace/tests/fixtures/TestCommand.java (+2 lines)
Lines 29-38 Link Here
29
public abstract class TestCommand
29
public abstract class TestCommand
30
	extends AbstractCommand {
30
	extends AbstractCommand {
31
31
32
	@Override
32
	protected boolean prepare() {
33
	protected boolean prepare() {
33
		return true;
34
		return true;
34
	}
35
	}
35
	
36
	
37
	@Override
36
	public void undo() {
38
	public void undo() {
37
		// do nothing
39
		// do nothing
38
	}
40
	}
(-)src/org/eclipse/emf/workspace/tests/fixtures/TestListener.java (+2 lines)
Lines 43-48 Link Here
43
		super(filter);
43
		super(filter);
44
	}
44
	}
45
	
45
	
46
	@Override
46
	public Command transactionAboutToCommit(ResourceSetChangeEvent event)
47
	public Command transactionAboutToCommit(ResourceSetChangeEvent event)
47
		throws RollbackException {
48
		throws RollbackException {
48
		
49
		
Lines 51-56 Link Here
51
		return null;
52
		return null;
52
	}
53
	}
53
	
54
	
55
	@Override
54
	public void resourceSetChanged(ResourceSetChangeEvent event) {
56
	public void resourceSetChanged(ResourceSetChangeEvent event) {
55
		postcommit = event;
57
		postcommit = event;
56
	}
58
	}
(-)src/org/eclipse/emf/workspace/tests/fixtures/LibraryDefaultNameTrigger.java (+2 lines)
Lines 45-50 Link Here
45
		this.isAggregate = isAggregate;
45
		this.isAggregate = isAggregate;
46
	}
46
	}
47
	
47
	
48
	@Override
48
	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
49
	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
49
		Command result = null;
50
		Command result = null;
50
		
51
		
Lines 60-65 Link Here
60
		return result;
61
		return result;
61
	}
62
	}
62
	
63
	
64
	@Override
63
	public boolean isAggregatePrecommitListener() {
65
	public boolean isAggregatePrecommitListener() {
64
		return isAggregate;
66
		return isAggregate;
65
	}
67
	}
(-)src/org/eclipse/emf/workspace/tests/fixtures/NonEMFCompositeOperation.java (-14 / +11 lines)
Lines 16-22 Link Here
16
 */
16
 */
17
package org.eclipse.emf.workspace.tests.fixtures;
17
package org.eclipse.emf.workspace.tests.fixtures;
18
18
19
import java.util.Iterator;
20
import java.util.List;
19
import java.util.List;
21
import java.util.ListIterator;
20
import java.util.ListIterator;
22
21
Lines 40-62 Link Here
40
		extends AbstractOperation
39
		extends AbstractOperation
41
		implements ICompositeOperation {
40
		implements ICompositeOperation {
42
	
41
	
43
	private List children = new java.util.ArrayList();
42
	private final List<IUndoableOperation> children = new java.util.ArrayList<IUndoableOperation>();
44
	
43
	
45
	public NonEMFCompositeOperation() {
44
	public NonEMFCompositeOperation() {
46
		super("Non-EMF Composite"); //$NON-NLS-1$
45
		super("Non-EMF Composite"); //$NON-NLS-1$
47
	}
46
	}
48
	
47
	
49
	// Documentation copied from the inherited specification
48
	// Documentation copied from the inherited specification
49
	@Override
50
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
50
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
51
			throws ExecutionException {
51
			throws ExecutionException {
52
		
52
		
53
		monitor.beginTask(getLabel(), children.size());
53
		monitor.beginTask(getLabel(), children.size());
54
		
54
		
55
		try {
55
		try {
56
			for (Iterator iter = children.iterator(); iter.hasNext();) {
56
			for (IUndoableOperation next : children) {
57
				((IUndoableOperation) iter.next()).execute(
57
				next.execute(new SubProgressMonitor(monitor, 1), info);
58
						new SubProgressMonitor(monitor, 1),
59
						info);
60
			}
58
			}
61
		} finally {
59
		} finally {
62
			monitor.done();
60
			monitor.done();
Lines 66-81 Link Here
66
	}
64
	}
67
65
68
	// Documentation copied from the inherited specification
66
	// Documentation copied from the inherited specification
67
	@Override
69
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
68
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
70
			throws ExecutionException {
69
			throws ExecutionException {
71
		
70
		
72
		monitor.beginTask(getLabel(), children.size());
71
		monitor.beginTask(getLabel(), children.size());
73
		
72
		
74
		try {
73
		try {
75
			for (Iterator iter = children.iterator(); iter.hasNext();) {
74
			for (IUndoableOperation next : children) {
76
				((IUndoableOperation) iter.next()).redo(
75
				next.redo(new SubProgressMonitor(monitor, 1), info);
77
						new SubProgressMonitor(monitor, 1),
78
						info);
79
			}
76
			}
80
		} finally {
77
		} finally {
81
			monitor.done();
78
			monitor.done();
Lines 85-100 Link Here
85
	}
82
	}
86
83
87
	// Documentation copied from the inherited specification
84
	// Documentation copied from the inherited specification
85
	@Override
88
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
86
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
89
			throws ExecutionException {
87
			throws ExecutionException {
90
		
88
		
91
		monitor.beginTask(getLabel(), children.size());
89
		monitor.beginTask(getLabel(), children.size());
92
		
90
		
93
		try {
91
		try {
94
			for (ListIterator iter = children.listIterator(children.size()); iter.hasPrevious();) {
92
			for (ListIterator<IUndoableOperation> iter = children.listIterator(children.size());
95
				((IUndoableOperation) iter.previous()).undo(
93
					iter.hasPrevious();) {
96
						new SubProgressMonitor(monitor, 1),
94
				iter.previous().undo(new SubProgressMonitor(monitor, 1), info);
97
						info);
98
			}
95
			}
99
		} finally {
96
		} finally {
100
			monitor.done();
97
			monitor.done();
(-)src/org/eclipse/emf/workspace/tests/fixtures/NullCommand.java (+2 lines)
Lines 25-30 Link Here
25
 */
25
 */
26
public class NullCommand extends AbstractCommand {
26
public class NullCommand extends AbstractCommand {
27
27
28
	@Override
28
	protected boolean prepare() {
29
	protected boolean prepare() {
29
		return true;
30
		return true;
30
	}
31
	}
Lines 35-40 Link Here
35
	}
36
	}
36
	
37
	
37
	/** Does nothing. */
38
	/** Does nothing. */
39
	@Override
38
	public void undo() {
40
	public void undo() {
39
		// nothing to do
41
		// nothing to do
40
	}
42
	}
(-)src/org/eclipse/emf/workspace/tests/fixtures/SelfOpeningEMFCompositeOperation.java (-10 / +10 lines)
Lines 16-22 Link Here
16
 */
16
 */
17
package org.eclipse.emf.workspace.tests.fixtures;
17
package org.eclipse.emf.workspace.tests.fixtures;
18
18
19
import java.util.Iterator;
20
import java.util.List;
19
import java.util.List;
21
import java.util.Set;
20
import java.util.Set;
22
21
Lines 44-56 Link Here
44
    extends AbstractEMFOperation
43
    extends AbstractEMFOperation
45
    implements ICompositeOperation {
44
    implements ICompositeOperation {
46
45
47
    private List children = new java.util.ArrayList();
46
    private final List<IUndoableOperation> children = new java.util.ArrayList<IUndoableOperation>();
48
47
49
    public SelfOpeningEMFCompositeOperation(TransactionalEditingDomain domain) {
48
    public SelfOpeningEMFCompositeOperation(TransactionalEditingDomain domain) {
50
        super(domain, "EMF Composite"); //$NON-NLS-1$
49
        super(domain, "EMF Composite"); //$NON-NLS-1$
51
    }
50
    }
52
51
53
    protected final IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
52
    @Override
53
	protected final IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
54
        throws ExecutionException {
54
        throws ExecutionException {
55
55
56
        IStatus result;
56
        IStatus result;
Lines 110-116 Link Here
110
     * 
110
     * 
111
     * @return my children
111
     * @return my children
112
     */
112
     */
113
    public List getChildren() {
113
    public List<IUndoableOperation> getChildren() {
114
        return children;
114
        return children;
115
    }
115
    }
116
116
Lines 120-131 Link Here
120
            removeContext(current[i]);
120
            removeContext(current[i]);
121
        }
121
        }
122
        
122
        
123
        Set newContexts = new java.util.HashSet();
123
        Set<IUndoContext> newContexts = new java.util.HashSet<IUndoContext>();
124
        for (Iterator iter = children.iterator(); iter.hasNext();) {
124
        for (IUndoableOperation child : children) {
125
            IUndoContext[] next = ((IUndoableOperation) iter.next()).getContexts();
125
            IUndoContext[] next = child.getContexts();
126
            for (int i = 0; i < next.length; i++) {
126
            for (IUndoContext ctx : next) {
127
                if (!newContexts.add(next[i])) {
127
                if (!newContexts.add(ctx)) {
128
                    addContext(next[i]);
128
                    addContext(ctx);
129
                }
129
                }
130
            }
130
            }
131
        }
131
        }
(-)src/org/eclipse/emf/workspace/tests/fixtures/ItemDefaultPublicationDateTrigger.java (+1 lines)
Lines 38-43 Link Here
38
									Notification.ADD)));
38
									Notification.ADD)));
39
	}
39
	}
40
	
40
	
41
	@Override
41
	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
42
	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
42
		Command result = null;
43
		Command result = null;
43
		
44
		
(-)src/org/eclipse/emf/workspace/tests/fixtures/LibraryDefaultBookTrigger.java (+2 lines)
Lines 48-53 Link Here
48
		this.isAggregate = isAggregate;
48
		this.isAggregate = isAggregate;
49
	}
49
	}
50
	
50
	
51
	@Override
51
	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
52
	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
52
		Command result = null;
53
		Command result = null;
53
		
54
		
Lines 64-69 Link Here
64
		return result;
65
		return result;
65
	}
66
	}
66
	
67
	
68
	@Override
67
	public boolean isAggregatePrecommitListener() {
69
	public boolean isAggregatePrecommitListener() {
68
		return isAggregate;
70
		return isAggregate;
69
	}
71
	}
(-)src/org/eclipse/emf/workspace/tests/fixtures/NullOperation.java (+6 lines)
Lines 53-83 Link Here
53
		this.isRedoable = isRedoable;
53
		this.isRedoable = isRedoable;
54
	}
54
	}
55
	
55
	
56
	@Override
56
	public boolean canExecute() {
57
	public boolean canExecute() {
57
		return isExecutable;
58
		return isExecutable;
58
	}
59
	}
59
	
60
	
61
	@Override
60
	public boolean canUndo() {
62
	public boolean canUndo() {
61
		return isUndoable;
63
		return isUndoable;
62
	}
64
	}
63
	
65
	
66
	@Override
64
	public boolean canRedo() {
67
	public boolean canRedo() {
65
		return isRedoable;
68
		return isRedoable;
66
	}
69
	}
67
	
70
	
68
	// Documentation copied from the inherited specification
71
	// Documentation copied from the inherited specification
72
	@Override
69
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
73
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
70
			throws ExecutionException {
74
			throws ExecutionException {
71
		return Status.OK_STATUS;
75
		return Status.OK_STATUS;
72
	}
76
	}
73
77
74
	// Documentation copied from the inherited specification
78
	// Documentation copied from the inherited specification
79
	@Override
75
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
80
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
76
			throws ExecutionException {
81
			throws ExecutionException {
77
		return Status.OK_STATUS;
82
		return Status.OK_STATUS;
78
	}
83
	}
79
84
80
	// Documentation copied from the inherited specification
85
	// Documentation copied from the inherited specification
86
	@Override
81
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
87
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
82
			throws ExecutionException {
88
			throws ExecutionException {
83
		return Status.OK_STATUS;
89
		return Status.OK_STATUS;
(-)src/org/eclipse/emf/workspace/tests/fixtures/ExternalDataOperation.java (+3 lines)
Lines 40-45 Link Here
40
		this.newValue = newValue;
40
		this.newValue = newValue;
41
	}
41
	}
42
	
42
	
43
	@Override
43
	public IStatus execute(IProgressMonitor monitor, IAdaptable info) {
44
	public IStatus execute(IProgressMonitor monitor, IAdaptable info) {
44
		// change the external (non-EMF) data
45
		// change the external (non-EMF) data
45
		oldValue = externalData[0];
46
		oldValue = externalData[0];
Lines 48-59 Link Here
48
		return Status.OK_STATUS;
49
		return Status.OK_STATUS;
49
	}
50
	}
50
	
51
	
52
	@Override
51
	public IStatus undo(IProgressMonitor monitor, IAdaptable info) {
53
	public IStatus undo(IProgressMonitor monitor, IAdaptable info) {
52
		externalData[0] = oldValue;
54
		externalData[0] = oldValue;
53
		
55
		
54
		return Status.OK_STATUS;
56
		return Status.OK_STATUS;
55
	}
57
	}
56
	
58
	
59
	@Override
57
	public IStatus redo(IProgressMonitor monitor, IAdaptable info) {
60
	public IStatus redo(IProgressMonitor monitor, IAdaptable info) {
58
		externalData[0] = newValue;
61
		externalData[0] = newValue;
59
		
62
		
(-)src/org/eclipse/emf/workspace/tests/fixtures/ExternalDataCommand.java (+2 lines)
Lines 36-41 Link Here
36
		this.newValue = newValue;
36
		this.newValue = newValue;
37
	}
37
	}
38
	
38
	
39
	@Override
39
	protected boolean prepare() {
40
	protected boolean prepare() {
40
		return true;
41
		return true;
41
	}
42
	}
Lines 46-51 Link Here
46
		externalData[0] = newValue;
47
		externalData[0] = newValue;
47
	}
48
	}
48
	
49
	
50
	@Override
49
	public void undo() {
51
	public void undo() {
50
		externalData[0] = oldValue;
52
		externalData[0] = oldValue;
51
	}
53
	}
(-)src/org/eclipse/emf/workspace/tests/fixtures/LogCapture.java (-6 / +6 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 18-24 Link Here
18
18
19
import java.util.List;
19
import java.util.List;
20
20
21
import junit.framework.TestCase;
21
import junit.framework.Assert;
22
22
23
import org.eclipse.core.runtime.ILogListener;
23
import org.eclipse.core.runtime.ILogListener;
24
import org.eclipse.core.runtime.IStatus;
24
import org.eclipse.core.runtime.IStatus;
Lines 46-52 Link Here
46
		}};
46
		}};
47
	private final TransactionalCommandStack stack;
47
	private final TransactionalCommandStack stack;
48
	
48
	
49
	private final List logs = new java.util.ArrayList();
49
	private final List<IStatus> logs = new java.util.ArrayList<IStatus>();
50
	private IStatus lastLog;
50
	private IStatus lastLog;
51
	
51
	
52
	/**
52
	/**
Lines 123-129 Link Here
123
	 * 
123
	 * 
124
	 * @return a list (possibly empty) of {@link IStatus}es
124
	 * @return a list (possibly empty) of {@link IStatus}es
125
	 */
125
	 */
126
	public List getLogs() {
126
	public List<IStatus> getLogs() {
127
		return logs;
127
		return logs;
128
	}
128
	}
129
	
129
	
Lines 134-142 Link Here
134
	 */
134
	 */
135
	public void assertLogged(Throwable throwable) {
135
	public void assertLogged(Throwable throwable) {
136
        IStatus log = getLastLog();
136
        IStatus log = getLastLog();
137
        TestCase.assertNotNull(log);
137
        Assert.assertNotNull(log);
138
        log = findStatus(log, throwable);
138
        log = findStatus(log, throwable);
139
        TestCase.assertNotNull(log);
139
        Assert.assertNotNull(log);
140
	}
140
	}
141
	
141
	
142
	private void record(IStatus log) {
142
	private void record(IStatus log) {
(-)src/org/eclipse/emf/workspace/tests/fixtures/TestOperation.java (-2 / +3 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005, 2006 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 38-47 Link Here
38
		super(domain, "Testing"); //$NON-NLS-1$
38
		super(domain, "Testing"); //$NON-NLS-1$
39
	}
39
	}
40
40
41
	public TestOperation(TransactionalEditingDomain domain, Map options) {
41
	public TestOperation(TransactionalEditingDomain domain, Map<?, ?> options) {
42
		super(domain, "Testing", options); //$NON-NLS-1$
42
		super(domain, "Testing", options); //$NON-NLS-1$
43
	}
43
	}
44
44
45
	@Override
45
	protected final IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
46
	protected final IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
46
		doExecute();
47
		doExecute();
47
		
48
		
(-)build.properties (-2 / +2 lines)
Lines 20-24 Link Here
20
               test_models/,\
20
               test_models/,\
21
               about.html
21
               about.html
22
src.includes = about.html
22
src.includes = about.html
23
javacSource = 1.4
23
javacSource = 1.5
24
javacTarget = 1.4
24
javacTarget = 1.5
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)src/org/eclipse/emf/workspace/tests/constraints/BookTitleConstraint.java (-1 / +2 lines)
Lines 30-35 Link Here
30
public class BookTitleConstraint
30
public class BookTitleConstraint
31
	extends AbstractModelConstraint {
31
	extends AbstractModelConstraint {
32
32
33
	@Override
33
	public IStatus validate(IValidationContext ctx) {
34
	public IStatus validate(IValidationContext ctx) {
34
		EMFEventType eType = ctx.getEventType();
35
		EMFEventType eType = ctx.getEventType();
35
		
36
		
Lines 38-44 Link Here
38
			
39
			
39
			if (newValue == null
40
			if (newValue == null
40
				|| ((String)newValue).length() == 0) {
41
				|| ((String)newValue).length() == 0) {
41
				return ctx.createFailureStatus(null);
42
				return ctx.createFailureStatus();
42
			}
43
			}
43
		}
44
		}
44
		
45
		
(-)src/org/eclipse/emf/workspace/util/tests/ValidateEditTest.java (-2 / +4 lines)
Lines 45-51 Link Here
45
    
45
    
46
    private Book book;
46
    private Book book;
47
    
47
    
48
    private Command cmd = new TestCommand() {
48
    private final Command cmd = new TestCommand() {
49
        public void execute() {
49
        public void execute() {
50
            try {
50
            try {
51
                book.setTitle(newTitle);
51
                book.setTitle(newTitle);
Lines 102-107 Link Here
102
	// Fixture methods
102
	// Fixture methods
103
	//
103
	//
104
	
104
	
105
	@Override
105
	protected void doSetUp()
106
	protected void doSetUp()
106
		throws Exception {
107
		throws Exception {
107
		
108
		
Lines 118-123 Link Here
118
        assertNotNull(book);
119
        assertNotNull(book);
119
	}
120
	}
120
	
121
	
122
	@Override
121
	protected void doTearDown()
123
	protected void doTearDown()
122
		throws Exception {
124
		throws Exception {
123
		
125
		
Lines 138-144 Link Here
138
	}
140
	}
139
	
141
	
140
	void setValidateEdit() {
142
	void setValidateEdit() {
141
        TransactionalEditingDomain.DefaultOptions defaults = (TransactionalEditingDomain.DefaultOptions) TransactionUtil
143
        TransactionalEditingDomain.DefaultOptions defaults = TransactionUtil
142
            .getAdapter(domain, TransactionalEditingDomain.DefaultOptions.class);
144
            .getAdapter(domain, TransactionalEditingDomain.DefaultOptions.class);
143
        
145
        
144
        defaults.setDefaultTransactionOptions(Collections.singletonMap(
146
        defaults.setDefaultTransactionOptions(Collections.singletonMap(
(-)src/org/eclipse/emf/workspace/util/tests/WorkspaceSynchronizerTest.java (-3 / +8 lines)
Lines 188-193 Link Here
188
				"moveDestination.extlibrary"); //$NON-NLS-1$
188
				"moveDestination.extlibrary"); //$NON-NLS-1$
189
		
189
		
190
		Job job = new WorkspaceJob("Modify Workspace") { //$NON-NLS-1$
190
		Job job = new WorkspaceJob("Modify Workspace") { //$NON-NLS-1$
191
			@Override
191
			public IStatus runInWorkspace(IProgressMonitor monitor)
192
			public IStatus runInWorkspace(IProgressMonitor monitor)
192
					throws CoreException {
193
					throws CoreException {
193
				// make two copies
194
				// make two copies
Lines 223-228 Link Here
223
			// make the workspace changes in a single job so that all deltas
224
			// make the workspace changes in a single job so that all deltas
224
			//    are fired in one batch
225
			//    are fired in one batch
225
			job = new WorkspaceJob("Modify Workspace") { //$NON-NLS-1$
226
			job = new WorkspaceJob("Modify Workspace") { //$NON-NLS-1$
227
				@Override
226
				public IStatus runInWorkspace(IProgressMonitor monitor)
228
				public IStatus runInWorkspace(IProgressMonitor monitor)
227
						throws CoreException {
229
						throws CoreException {
228
					// delete one file
230
					// delete one file
Lines 531-536 Link Here
531
	// Fixture methods
533
	// Fixture methods
532
	//
534
	//
533
	
535
	
536
	@Override
534
	protected void doSetUp()
537
	protected void doSetUp()
535
		throws Exception {
538
		throws Exception {
536
		
539
		
Lines 540-545 Link Here
540
		synch = new WorkspaceSynchronizer(domain, delegate);
543
		synch = new WorkspaceSynchronizer(domain, delegate);
541
	}
544
	}
542
	
545
	
546
	@Override
543
	protected void doTearDown()
547
	protected void doTearDown()
544
		throws Exception {
548
		throws Exception {
545
		
549
		
Lines 563-568 Link Here
563
				setSystem(true);
567
				setSystem(true);
564
			}
568
			}
565
			
569
			
570
			@Override
566
			protected IStatus run(IProgressMonitor monitor) {
571
			protected IStatus run(IProgressMonitor monitor) {
567
				synchronized (lock) {
572
				synchronized (lock) {
568
					lock.notify();
573
					lock.notify();
Lines 589-597 Link Here
589
	 * @author Christian W. Damus (cdamus)
594
	 * @author Christian W. Damus (cdamus)
590
	 */
595
	 */
591
	static class TestDelegate implements WorkspaceSynchronizer.Delegate {
596
	static class TestDelegate implements WorkspaceSynchronizer.Delegate {
592
		final List deletedResources = new java.util.ArrayList();
597
		final List<Resource> deletedResources = new java.util.ArrayList<Resource>();
593
		final Map movedResources = new java.util.LinkedHashMap();
598
		final Map<Resource, URI> movedResources = new java.util.LinkedHashMap<Resource, URI>();
594
		final List changedResources = new java.util.ArrayList();
599
		final List<Resource> changedResources = new java.util.ArrayList<Resource>();
595
		
600
		
596
		boolean defaultBehaviour = false;
601
		boolean defaultBehaviour = false;
597
		
602
		
(-)src/org/eclipse/emf/workspace/util/tests/OperationChangeDescriptionTest.java (+2 lines)
Lines 103-108 Link Here
103
	// Fixture methods
103
	// Fixture methods
104
	//
104
	//
105
	
105
	
106
	@Override
106
	protected void setUp()
107
	protected void setUp()
107
		throws Exception {
108
		throws Exception {
108
		
109
		
Lines 116-121 Link Here
116
		assertEquals(newValue, externalData[0]);
117
		assertEquals(newValue, externalData[0]);
117
	}
118
	}
118
	
119
	
120
	@Override
119
	protected void tearDown()
121
	protected void tearDown()
120
		throws Exception {
122
		throws Exception {
121
		
123
		
(-)src/org/eclipse/emf/workspace/util/tests/AllTests.java (-3 / +8 lines)
Lines 23-29 Link Here
23
import junit.framework.TestSuite;
23
import junit.framework.TestSuite;
24
import junit.textui.TestRunner;
24
import junit.textui.TestRunner;
25
25
26
import org.eclipse.core.runtime.IPlatformRunnable;
26
import org.eclipse.equinox.app.IApplication;
27
import org.eclipse.equinox.app.IApplicationContext;
27
28
28
/**
29
/**
29
 * JUnit suite for the <code>org.eclipse.emf.workspace.util</code> package.
30
 * JUnit suite for the <code>org.eclipse.emf.workspace.util</code> package.
Lines 32-38 Link Here
32
 */
33
 */
33
public class AllTests
34
public class AllTests
34
	extends TestCase
35
	extends TestCase
35
	implements IPlatformRunnable {
36
	implements IApplication {
36
37
37
	public AllTests() {
38
	public AllTests() {
38
		super(""); //$NON-NLS-1$
39
		super(""); //$NON-NLS-1$
Lines 48-58 Link Here
48
		return suite;
49
		return suite;
49
	}
50
	}
50
51
51
	public Object run(Object args)
52
	public Object start(IApplicationContext context)
52
		throws Exception {
53
		throws Exception {
53
54
54
		TestRunner.run(suite());
55
		TestRunner.run(suite());
55
		return Arrays
56
		return Arrays
56
			.asList(new String[] {"Please see raw test suite output for details."}); //$NON-NLS-1$
57
			.asList(new String[] {"Please see raw test suite output for details."}); //$NON-NLS-1$
57
	}
58
	}
59
	
60
	public void stop() {
61
		// nothing to do
62
	}
58
}
63
}
(-)src/org/eclipse/emf/workspace/util/tests/ResourceUndoContextTest.java (-14 / +17 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005, 2006 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 34-41 Link Here
34
import org.eclipse.emf.examples.extlibrary.Book;
34
import org.eclipse.emf.examples.extlibrary.Book;
35
import org.eclipse.emf.examples.extlibrary.BookOnTape;
35
import org.eclipse.emf.examples.extlibrary.BookOnTape;
36
import org.eclipse.emf.examples.extlibrary.EXTLibraryFactory;
36
import org.eclipse.emf.examples.extlibrary.EXTLibraryFactory;
37
import org.eclipse.emf.examples.extlibrary.Employee;
37
import org.eclipse.emf.examples.extlibrary.Library;
38
import org.eclipse.emf.examples.extlibrary.Library;
38
import org.eclipse.emf.examples.extlibrary.Person;
39
import org.eclipse.emf.examples.extlibrary.Writer;
39
import org.eclipse.emf.examples.extlibrary.Writer;
40
import org.eclipse.emf.transaction.TransactionalEditingDomain;
40
import org.eclipse.emf.transaction.TransactionalEditingDomain;
41
import org.eclipse.emf.workspace.ResourceUndoContext;
41
import org.eclipse.emf.workspace.ResourceUndoContext;
Lines 88-94 Link Here
88
		
88
		
89
		assertFalse(listener.notifications.isEmpty());
89
		assertFalse(listener.notifications.isEmpty());
90
		
90
		
91
		Set affected = ResourceUndoContext.getAffectedResources(
91
		Set<Resource> affected = ResourceUndoContext.getAffectedResources(
92
				listener.notifications);
92
				listener.notifications);
93
		
93
		
94
		assertEquals(Collections.singleton(res1), affected);
94
		assertEquals(Collections.singleton(res1), affected);
Lines 104-110 Link Here
104
		BookOnTape book = EXTLibraryFactory.eINSTANCE.createBookOnTape();
104
		BookOnTape book = EXTLibraryFactory.eINSTANCE.createBookOnTape();
105
		library.getStock().add(book);
105
		library.getStock().add(book);
106
		
106
		
107
		Person person = EXTLibraryFactory.eINSTANCE.createEmployee();
107
		Employee person = EXTLibraryFactory.eINSTANCE.createEmployee();
108
		library.getEmployees().add(person);
108
		library.getEmployees().add(person);
109
		
109
		
110
		// forget the events so far
110
		// forget the events so far
Lines 114-120 Link Here
114
		
114
		
115
		assertFalse(listener.notifications.isEmpty());
115
		assertFalse(listener.notifications.isEmpty());
116
		
116
		
117
		Set affected = ResourceUndoContext.getAffectedResources(
117
		Set<Resource> affected = ResourceUndoContext.getAffectedResources(
118
				listener.notifications);
118
				listener.notifications);
119
		
119
		
120
		assertEquals(Collections.singleton(res1), affected);
120
		assertEquals(Collections.singleton(res1), affected);
Lines 143-152 Link Here
143
		
143
		
144
		assertFalse(listener.notifications.isEmpty());
144
		assertFalse(listener.notifications.isEmpty());
145
		
145
		
146
		Set affected = ResourceUndoContext.getAffectedResources(
146
		Set<Resource> affected = ResourceUndoContext.getAffectedResources(
147
				listener.notifications);
147
				listener.notifications);
148
		
148
		
149
		Set expected = new java.util.HashSet();
149
		Set<Resource> expected = new java.util.HashSet<Resource>();
150
		expected.add(res1);
150
		expected.add(res1);
151
		expected.add(res2);
151
		expected.add(res2);
152
		
152
		
Lines 166-172 Link Here
166
		BookOnTape book = EXTLibraryFactory.eINSTANCE.createBookOnTape();
166
		BookOnTape book = EXTLibraryFactory.eINSTANCE.createBookOnTape();
167
		library1.getStock().add(book);
167
		library1.getStock().add(book);
168
		
168
		
169
		Person person = EXTLibraryFactory.eINSTANCE.createEmployee();
169
		Employee person = EXTLibraryFactory.eINSTANCE.createEmployee();
170
		library2.getEmployees().add(person);
170
		library2.getEmployees().add(person);
171
		
171
		
172
		// forget the events so far
172
		// forget the events so far
Lines 176-185 Link Here
176
		
176
		
177
		assertFalse(listener.notifications.isEmpty());
177
		assertFalse(listener.notifications.isEmpty());
178
		
178
		
179
		Set affected = ResourceUndoContext.getAffectedResources(
179
		Set<Resource> affected = ResourceUndoContext.getAffectedResources(
180
				listener.notifications);
180
				listener.notifications);
181
		
181
		
182
		Set expected = new java.util.HashSet();
182
		Set<Resource> expected = new java.util.HashSet<Resource>();
183
		expected.add(res1);
183
		expected.add(res1);
184
		expected.add(res2);
184
		expected.add(res2);
185
		
185
		
Lines 200-206 Link Here
200
		BookOnTape book = EXTLibraryFactory.eINSTANCE.createBookOnTape();
200
		BookOnTape book = EXTLibraryFactory.eINSTANCE.createBookOnTape();
201
		library1.getStock().add(book);
201
		library1.getStock().add(book);
202
		
202
		
203
		Person person = EXTLibraryFactory.eINSTANCE.createEmployee();
203
		Employee person = EXTLibraryFactory.eINSTANCE.createEmployee();
204
		library2.getEmployees().add(person);
204
		library2.getEmployees().add(person);
205
		
205
		
206
		book.setReader(person);
206
		book.setReader(person);
Lines 213-222 Link Here
213
		
213
		
214
		assertFalse(listener.notifications.isEmpty());
214
		assertFalse(listener.notifications.isEmpty());
215
		
215
		
216
		Set affected = ResourceUndoContext.getAffectedResources(
216
		Set<Resource> affected = ResourceUndoContext.getAffectedResources(
217
				listener.notifications);
217
				listener.notifications);
218
		
218
		
219
		Set expected = new java.util.HashSet();
219
		Set<Resource> expected = new java.util.HashSet<Resource>();
220
		expected.add(res1);
220
		expected.add(res1);
221
		expected.add(res2);
221
		expected.add(res2);
222
		
222
		
Lines 228-233 Link Here
228
	// Fixture methods
228
	// Fixture methods
229
	//
229
	//
230
	
230
	
231
	@Override
231
	protected void setUp()
232
	protected void setUp()
232
		throws Exception {
233
		throws Exception {
233
		
234
		
Lines 252-257 Link Here
252
		rset.eAdapters().add(listener);
253
		rset.eAdapters().add(listener);
253
	}
254
	}
254
	
255
	
256
	@Override
255
	protected void tearDown()
257
	protected void tearDown()
256
		throws Exception {
258
		throws Exception {
257
		
259
		
Lines 277-284 Link Here
277
	}
279
	}
278
	
280
	
279
	private static class Listener extends EContentAdapter {
281
	private static class Listener extends EContentAdapter {
280
		final List notifications = new java.util.ArrayList();
282
		final List<Notification> notifications = new java.util.ArrayList<Notification>();
281
		
283
		
284
		@Override
282
		public void notifyChanged(Notification notification) {
285
		public void notifyChanged(Notification notification) {
283
			notifications.add(notification);
286
			notifications.add(notification);
284
			
287
			
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:54:28 EST 2006
1
#Sun Nov 11 17:39:35 EST 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-)src/org/eclipse/emf/transaction/tests/PrivilegedRunnableTest.java (-10 / +16 lines)
Lines 16-27 Link Here
16
 */
16
 */
17
package org.eclipse.emf.transaction.tests;
17
package org.eclipse.emf.transaction.tests;
18
18
19
import java.util.List;
20
21
import junit.framework.Assert;
19
import junit.framework.Test;
22
import junit.framework.Test;
20
import junit.framework.TestCase;
21
import junit.framework.TestSuite;
23
import junit.framework.TestSuite;
22
24
23
import org.eclipse.core.runtime.IStatus;
25
import org.eclipse.core.runtime.IStatus;
24
import org.eclipse.core.runtime.Status;
26
import org.eclipse.core.runtime.Status;
27
import org.eclipse.emf.examples.extlibrary.Book;
25
import org.eclipse.emf.transaction.RunnableWithResult;
28
import org.eclipse.emf.transaction.RunnableWithResult;
26
29
27
30
Lines 56-62 Link Here
56
	 * Tests the sharing of a read-only transaction.
59
	 * Tests the sharing of a read-only transaction.
57
	 */
60
	 */
58
	public void test_sharingReadOnlyTransaction() {
61
	public void test_sharingReadOnlyTransaction() {
59
		RunnableWithResult privileged;
62
		RunnableWithResult<?> privileged;
60
		startReading();
63
		startReading();
61
		
64
		
62
		privileged = domain.createPrivilegedRunnable(read);
65
		privileged = domain.createPrivilegedRunnable(read);
Lines 91-97 Link Here
91
	 * Tests the sharing of a read-write transaction.
94
	 * Tests the sharing of a read-write transaction.
92
	 */
95
	 */
93
	public void test_sharingReadWriteTransaction() {
96
	public void test_sharingReadWriteTransaction() {
94
		RunnableWithResult privileged;
97
		RunnableWithResult<?> privileged;
95
		startWriting();
98
		startWriting();
96
		
99
		
97
		privileged = domain.createPrivilegedRunnable(write);
100
		privileged = domain.createPrivilegedRunnable(write);
Lines 147-153 Link Here
147
				thread2.syncExec(domain.createPrivilegedRunnable(write));
150
				thread2.syncExec(domain.createPrivilegedRunnable(write));
148
			}};
151
			}};
149
		
152
		
150
		RunnableWithResult privileged;
153
		RunnableWithResult<?> privileged;
151
		startWriting();
154
		startWriting();
152
		
155
		
153
		privileged = domain.createPrivilegedRunnable(nestingRunnable);
156
		privileged = domain.createPrivilegedRunnable(nestingRunnable);
Lines 167-173 Link Here
167
	 * a privileged runnable.
170
	 * a privileged runnable.
168
	 */
171
	 */
169
	public void test_transactionMustBeActive() {
172
	public void test_transactionMustBeActive() {
170
		RunnableWithResult privileged;
173
		RunnableWithResult<?> privileged;
171
		startWriting();
174
		startWriting();
172
		
175
		
173
		privileged = domain.createPrivilegedRunnable(write);
176
		privileged = domain.createPrivilegedRunnable(write);
Lines 186-192 Link Here
186
	 * transaction when executing a privileged runnable.
189
	 * transaction when executing a privileged runnable.
187
	 */
190
	 */
188
	public void test_transactionMustBeCurrent() {
191
	public void test_transactionMustBeCurrent() {
189
		RunnableWithResult privileged;
192
		RunnableWithResult<?> privileged;
190
		startWriting();
193
		startWriting();
191
		
194
		
192
		privileged = domain.createPrivilegedRunnable(write);
195
		privileged = domain.createPrivilegedRunnable(write);
Lines 213-219 Link Here
213
	public void test_runtimeExceptionInRunnable_146625() {
216
	public void test_runtimeExceptionInRunnable_146625() {
214
		final RuntimeException e = new RuntimeException();
217
		final RuntimeException e = new RuntimeException();
215
		
218
		
216
		RunnableWithResult privileged;
219
		RunnableWithResult<?> privileged;
217
		startReading();
220
		startReading();
218
		
221
		
219
		privileged = domain.createPrivilegedRunnable(new Runnable() {
222
		privileged = domain.createPrivilegedRunnable(new Runnable() {
Lines 299-304 Link Here
299
	// Fixture methods
302
	// Fixture methods
300
	//
303
	//
301
	
304
	
305
	@Override
302
	protected void doSetUp() throws Exception {
306
	protected void doSetUp() throws Exception {
303
		super.doSetUp();
307
		super.doSetUp();
304
		
308
		
Lines 311-316 Link Here
311
		writeWithResult = new TestWriteWithResult();
315
		writeWithResult = new TestWriteWithResult();
312
	}
316
	}
313
	
317
	
318
	@Override
314
	protected void doTearDown() throws Exception {
319
	protected void doTearDown() throws Exception {
315
		read = null;
320
		read = null;
316
		readWithResult = null;
321
		readWithResult = null;
Lines 348-354 Link Here
348
				try {
353
				try {
349
					wait();
354
					wait();
350
				} catch (InterruptedException e) {
355
				} catch (InterruptedException e) {
351
					TestCase.fail("Interrupted while waiting for runnable"); //$NON-NLS-1$
356
					Assert.fail("Interrupted while waiting for runnable"); //$NON-NLS-1$
352
				}
357
				}
353
			}
358
			}
354
		}
359
		}
Lines 359-364 Link Here
359
			return result;
364
			return result;
360
		}
365
		}
361
		
366
		
367
		@Override
362
		public void run() {
368
		public void run() {
363
			for (;;) {
369
			for (;;) {
364
				synchronized (this) {
370
				synchronized (this) {
Lines 401-407 Link Here
401
		}
407
		}
402
	}
408
	}
403
	
409
	
404
	class TestReadWithResult extends RunnableWithResult.Impl {
410
	class TestReadWithResult extends RunnableWithResult.Impl<List<Book>> {
405
		boolean wasExecuted = false;
411
		boolean wasExecuted = false;
406
		
412
		
407
		public void run() {
413
		public void run() {
Lines 420-426 Link Here
420
		}
426
		}
421
	}
427
	}
422
	
428
	
423
	class TestWriteWithResult extends RunnableWithResult.Impl {
429
	class TestWriteWithResult extends RunnableWithResult.Impl<List<Book>> {
424
		boolean wasExecuted = false;
430
		boolean wasExecuted = false;
425
		
431
		
426
		public void run() {
432
		public void run() {
(-)src/org/eclipse/emf/transaction/tests/TransactionChangeRecorderTest.java (-13 / +14 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 85-96 Link Here
85
		EPackage pkg = findPackage("root/nested1", true); //$NON-NLS-1$
85
		EPackage pkg = findPackage("root/nested1", true); //$NON-NLS-1$
86
		assertSame(recorder, getRecorder(pkg));
86
		assertSame(recorder, getRecorder(pkg));
87
		
87
		
88
		Iterator contents = ((InternalEList) pkg.eContents()).basicIterator();
88
		Iterator<EObject> contents = ((InternalEList<EObject>) pkg.eContents()).basicIterator();
89
		
89
		
90
		// check that the EPackage is not yet resolved
90
		// check that the EPackage is not yet resolved
91
		EObject obj = (EObject) contents.next();
91
		EObject obj = contents.next();
92
		assertTrue(!(obj instanceof EPackage) || obj.eIsProxy());
92
		assertTrue(!(obj instanceof EPackage) || obj.eIsProxy());
93
		obj = (EObject) contents.next();
93
		obj = contents.next();
94
		assertTrue(!(obj instanceof EPackage) || obj.eIsProxy());
94
		assertTrue(!(obj instanceof EPackage) || obj.eIsProxy());
95
		
95
		
96
		assertFalse(nestedResource1.isLoaded());
96
		assertFalse(nestedResource1.isLoaded());
Lines 166-177 Link Here
166
		EPackage pkg = findPackage("root/nested1", true); //$NON-NLS-1$
166
		EPackage pkg = findPackage("root/nested1", true); //$NON-NLS-1$
167
		assertSame(recorder, getRecorder(pkg));
167
		assertSame(recorder, getRecorder(pkg));
168
		
168
		
169
		Iterator contents = ((InternalEList) pkg.eContents()).basicIterator();
169
		Iterator<EObject> contents = ((InternalEList<EObject>) pkg.eContents()).basicIterator();
170
		
170
		
171
		// check that the EPackage is not yet resolved
171
		// check that the EPackage is not yet resolved
172
		EObject obj = (EObject) contents.next();
172
		EObject obj = contents.next();
173
		assertTrue(!(obj instanceof EPackage) || obj.eIsProxy());
173
		assertTrue(!(obj instanceof EPackage) || obj.eIsProxy());
174
		obj = (EObject) contents.next();
174
		obj = contents.next();
175
		assertTrue(!(obj instanceof EPackage) || obj.eIsProxy());
175
		assertTrue(!(obj instanceof EPackage) || obj.eIsProxy());
176
		
176
		
177
		assertFalse(nestedResource1.isLoaded());
177
		assertFalse(nestedResource1.isLoaded());
Lines 451-456 Link Here
451
	// Framework methods
451
	// Framework methods
452
	//
452
	//
453
	
453
	
454
	@Override
454
	protected void doSetUp() throws Exception {
455
	protected void doSetUp() throws Exception {
455
		super.doSetUp();
456
		super.doSetUp();
456
		
457
		
Lines 462-473 Link Here
462
						"/test_models/test_model.ecore").toString()), //$NON-NLS-1$
463
						"/test_models/test_model.ecore").toString()), //$NON-NLS-1$
463
						true);
464
						true);
464
			rootResource.setURI(URI.createPlatformResourceURI(
465
			rootResource.setURI(URI.createPlatformResourceURI(
465
					"/" + PROJECT_NAME + "/test_model.ecore")); //$NON-NLS-1$ //$NON-NLS-2$
466
					"/" + PROJECT_NAME + "/test_model.ecore", true)); //$NON-NLS-1$ //$NON-NLS-2$
466
			
467
			
467
			nestedResource1 = rset.createResource(URI.createPlatformResourceURI(
468
			nestedResource1 = rset.createResource(URI.createPlatformResourceURI(
468
					"/" + PROJECT_NAME + "/test_model1.ecore")); //$NON-NLS-1$ //$NON-NLS-2$
469
					"/" + PROJECT_NAME + "/test_model1.ecore", true)); //$NON-NLS-1$ //$NON-NLS-2$
469
			nestedResource2 = rset.createResource(URI.createPlatformResourceURI(
470
			nestedResource2 = rset.createResource(URI.createPlatformResourceURI(
470
					"/" + PROJECT_NAME + "/test_model2.ecore")); //$NON-NLS-1$ //$NON-NLS-2$
471
					"/" + PROJECT_NAME + "/test_model2.ecore", true)); //$NON-NLS-1$ //$NON-NLS-2$
471
			
472
			
472
			startWriting();
473
			startWriting();
473
			
474
			
Lines 497-502 Link Here
497
		}
498
		}
498
	}
499
	}
499
	
500
	
501
	@Override
500
	protected void doTearDown() throws Exception {
502
	protected void doTearDown() throws Exception {
501
		if (rootResource != null) {
503
		if (rootResource != null) {
502
			unloadAndRemove(rootResource);
504
			unloadAndRemove(rootResource);
Lines 542-547 Link Here
542
	 * @param object the object
544
	 * @param object the object
543
	 * @return its name
545
	 * @return its name
544
	 */
546
	 */
547
	@Override
545
	protected String getName(EObject object) {
548
	protected String getName(EObject object) {
546
		if (object instanceof ENamedElement) {
549
		if (object instanceof ENamedElement) {
547
			return ((ENamedElement) object).getName();
550
			return ((ENamedElement) object).getName();
Lines 562-570 Link Here
562
	protected TransactionChangeRecorder getRecorder(Notifier notifier) {
565
	protected TransactionChangeRecorder getRecorder(Notifier notifier) {
563
		TransactionChangeRecorder result = null;
566
		TransactionChangeRecorder result = null;
564
		
567
		
565
		for (Iterator iter = notifier.eAdapters().iterator(); iter.hasNext();) {
568
		for (Object next : notifier.eAdapters()) {
566
			Object next = iter.next();
567
			
568
			if (next instanceof TransactionChangeRecorder) {
569
			if (next instanceof TransactionChangeRecorder) {
569
				result = (TransactionChangeRecorder) next;
570
				result = (TransactionChangeRecorder) next;
570
				break;
571
				break;
(-)src/org/eclipse/emf/transaction/tests/NotificationFilterTest.java (-2 / +2 lines)
Lines 74-80 Link Here
74
			
74
			
75
			assertNotNull(bookListener.postcommit);
75
			assertNotNull(bookListener.postcommit);
76
			assertEquals(1, bookListener.postcommitNotifications.size());
76
			assertEquals(1, bookListener.postcommitNotifications.size());
77
			Notification notification = (Notification) bookListener.postcommitNotifications.get(0);
77
			Notification notification = bookListener.postcommitNotifications.get(0);
78
			assertSame(book, notification.getNotifier());
78
			assertSame(book, notification.getNotifier());
79
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
79
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
80
			assertSame(oldTitle, notification.getOldValue());
80
			assertSame(oldTitle, notification.getOldValue());
Lines 82-88 Link Here
82
			
82
			
83
			assertNotNull(authorListener.postcommit);
83
			assertNotNull(authorListener.postcommit);
84
			assertEquals(1, authorListener.postcommitNotifications.size());
84
			assertEquals(1, authorListener.postcommitNotifications.size());
85
			notification = (Notification) authorListener.postcommitNotifications.get(0);
85
			notification = authorListener.postcommitNotifications.get(0);
86
			assertSame(newAuthor, notification.getNotifier());
86
			assertSame(newAuthor, notification.getNotifier());
87
			assertSame(EXTLibraryPackage.eINSTANCE.getWriter_Books(), notification.getFeature());
87
			assertSame(EXTLibraryPackage.eINSTANCE.getWriter_Books(), notification.getFeature());
88
			assertSame(book, notification.getNewValue());
88
			assertSame(book, notification.getNewValue());
(-)src/org/eclipse/emf/transaction/tests/AllTests.java (-6 / +12 lines)
Lines 23-31 Link Here
23
import junit.framework.TestSuite;
23
import junit.framework.TestSuite;
24
import junit.textui.TestRunner;
24
import junit.textui.TestRunner;
25
25
26
import org.eclipse.core.runtime.IPlatformRunnable;
27
import org.eclipse.emf.transaction.multithread.tests.AbstractMultithreadTest;
26
import org.eclipse.emf.transaction.multithread.tests.AbstractMultithreadTest;
28
import org.eclipse.emf.transaction.util.tests.InternalUtilTests;
27
import org.eclipse.emf.transaction.util.tests.InternalUtilTests;
28
import org.eclipse.equinox.app.IApplication;
29
import org.eclipse.equinox.app.IApplicationContext;
29
30
30
/**
31
/**
31
 * Master JUnit test suite for the <em>EMF-TX API</em>.
32
 * Master JUnit test suite for the <em>EMF-TX API</em>.
Lines 34-40 Link Here
34
 */
35
 */
35
public class AllTests
36
public class AllTests
36
	extends TestCase
37
	extends TestCase
37
	implements IPlatformRunnable {
38
	implements IApplication {
38
39
39
	public AllTests() {
40
	public AllTests() {
40
		super(""); //$NON-NLS-1$
41
		super(""); //$NON-NLS-1$
Lines 62-72 Link Here
62
		return suite;
63
		return suite;
63
	}
64
	}
64
65
65
	public Object run(Object args)
66
	public Object start(IApplicationContext context)
66
		throws Exception {
67
		throws Exception {
67
68
		
68
		TestRunner.run(suite());
69
		TestRunner.run(suite());
69
		return Arrays
70
		
70
			.asList(new String[] {"Please see raw test suite output for details."}); //$NON-NLS-1$
71
		return Arrays.asList(new String[] {
72
			"Please see raw test suite output for details."}); //$NON-NLS-1$
73
	}
74
75
	public void stop() {
76
		// nothing to do
71
	}
77
	}
72
}
78
}
(-)src/org/eclipse/emf/transaction/tests/TestsPlugin.java (+2 lines)
Lines 27-38 Link Here
27
public class TestsPlugin extends Plugin {
27
public class TestsPlugin extends Plugin {
28
	public static TestsPlugin instance;
28
	public static TestsPlugin instance;
29
	
29
	
30
	@Override
30
	public void start(BundleContext context) throws Exception {
31
	public void start(BundleContext context) throws Exception {
31
		super.start(context);
32
		super.start(context);
32
		
33
		
33
		instance = this;
34
		instance = this;
34
	}
35
	}
35
	
36
	
37
	@Override
36
	public void stop(BundleContext context) throws Exception {
38
	public void stop(BundleContext context) throws Exception {
37
		instance = null;
39
		instance = null;
38
		
40
		
(-)src/org/eclipse/emf/transaction/tests/TransactionOptionsTest.java (-11 / +14 lines)
Lines 166-171 Link Here
166
	 */
166
	 */
167
	public void test_noUndo_recordingCommand() {
167
	public void test_noUndo_recordingCommand() {
168
		Command cmd = new RecordingCommand(domain) {
168
		Command cmd = new RecordingCommand(domain) {
169
			@Override
169
			protected void doExecute() {
170
			protected void doExecute() {
170
				final Book book = (Book) find("root/Root Book"); //$NON-NLS-1$
171
				final Book book = (Book) find("root/Root Book"); //$NON-NLS-1$
171
				assertNotNull(book);
172
				assertNotNull(book);
Lines 358-364 Link Here
358
			fail("Should have rolled back because of outer transaction validation"); //$NON-NLS-1$
359
			fail("Should have rolled back because of outer transaction validation"); //$NON-NLS-1$
359
		} catch (RollbackException e) {
360
		} catch (RollbackException e) {
360
			// expected exception
361
			// expected exception
361
			Collection errors = findValidationStatuses(
362
			Collection<IStatus> errors = findValidationStatuses(
362
					e.getStatus(), IStatus.ERROR);
363
					e.getStatus(), IStatus.ERROR);
363
			
364
			
364
			// the inner transaction's error was not detected
365
			// the inner transaction's error was not detected
Lines 367-374 Link Here
367
	}
368
	}
368
	
369
	
369
	public void test_transactionOptionInheritance_135569() {
370
	public void test_transactionOptionInheritance_135569() {
370
		Map options = new java.util.HashMap();
371
		Map<Object, Object> options = new java.util.HashMap<Object, Object>();
371
		Map active;
372
		Map<Object, Object> active;
372
		
373
		
373
		// test the inheritance of empty options
374
		// test the inheritance of empty options
374
		startWriting();
375
		startWriting();
Lines 465-473 Link Here
465
     * notifications, since they are not needed for anything.
466
     * notifications, since they are not needed for anything.
466
     */
467
     */
467
    public void test_noNotificationsInSilentUnprotected_152335() {
468
    public void test_noNotificationsInSilentUnprotected_152335() {
468
        Map options = new java.util.HashMap();
469
        Map<Object, Object> options = new java.util.HashMap<Object, Object>();
469
        options.put(Transaction.OPTION_NO_NOTIFICATIONS, Boolean.TRUE);
470
        options.put(Transaction.OPTION_NO_NOTIFICATIONS, true);
470
        options.put(Transaction.OPTION_UNPROTECTED, Boolean.TRUE);
471
        options.put(Transaction.OPTION_UNPROTECTED, true);
471
        
472
        
472
        startWriting(options);
473
        startWriting(options);
473
        InternalTransaction tx = getActiveTransaction();
474
        InternalTransaction tx = getActiveTransaction();
Lines 508-516 Link Here
508
        final String newTitle = "New Title"; //$NON-NLS-1$
509
        final String newTitle = "New Title"; //$NON-NLS-1$
509
        book.setTitle(newTitle);
510
        book.setTitle(newTitle);
510
        
511
        
511
        Map options = new java.util.HashMap();
512
        Map<Object, Object> options = new java.util.HashMap<Object, Object>();
512
        options.put(Transaction.OPTION_NO_NOTIFICATIONS, Boolean.TRUE);
513
        options.put(Transaction.OPTION_NO_NOTIFICATIONS, true);
513
        options.put(Transaction.OPTION_UNPROTECTED, Boolean.TRUE);
514
        options.put(Transaction.OPTION_UNPROTECTED, true);
514
        
515
        
515
        // intervening silent-unprotected
516
        // intervening silent-unprotected
516
        startWriting(options);
517
        startWriting(options);
Lines 537-543 Link Here
537
        //    and only that notification
538
        //    and only that notification
538
        assertNotNull(listener.postcommitNotifications);
539
        assertNotNull(listener.postcommitNotifications);
539
        assertEquals(1, listener.postcommitNotifications.size());
540
        assertEquals(1, listener.postcommitNotifications.size());
540
        Notification notification = (Notification) listener.postcommitNotifications.get(0);
541
        Notification notification = listener.postcommitNotifications.get(0);
541
        assertSame(EXTLibraryPackage.Literals.BOOK__TITLE, notification.getFeature());
542
        assertSame(EXTLibraryPackage.Literals.BOOK__TITLE, notification.getFeature());
542
    }
543
    }
543
    
544
    
Lines 601-607 Link Here
601
     * Tests that default transaction options are applied to new transactions.
602
     * Tests that default transaction options are applied to new transactions.
602
     */
603
     */
603
    public void test_defaultTransactionOptions() {
604
    public void test_defaultTransactionOptions() {
604
        TransactionalEditingDomain.DefaultOptions defaults = (TransactionalEditingDomain.DefaultOptions) TransactionUtil
605
        TransactionalEditingDomain.DefaultOptions defaults = TransactionUtil
605
            .getAdapter(domain, TransactionalEditingDomain.DefaultOptions.class);
606
            .getAdapter(domain, TransactionalEditingDomain.DefaultOptions.class);
606
        
607
        
607
        defaults.setDefaultTransactionOptions(Collections.singletonMap(
608
        defaults.setDefaultTransactionOptions(Collections.singletonMap(
Lines 621-626 Link Here
621
	// Fixture methods
622
	// Fixture methods
622
	//
623
	//
623
	
624
	
625
	@Override
624
	protected void doSetUp()
626
	protected void doSetUp()
625
		throws Exception {
627
		throws Exception {
626
		
628
		
Lines 636-641 Link Here
636
		ValidationRollbackTest.validationEnabled = true;
638
		ValidationRollbackTest.validationEnabled = true;
637
	}
639
	}
638
	
640
	
641
	@Override
639
	protected void doTearDown()
642
	protected void doTearDown()
640
		throws Exception {
643
		throws Exception {
641
		
644
		
(-)src/org/eclipse/emf/transaction/tests/EditingDomainValidatorTest.java (+2 lines)
Lines 44-53 Link Here
44
	}
44
	}
45
	
45
	
46
	/** May be overridden by subclasses to create non-default editing domains. */
46
	/** May be overridden by subclasses to create non-default editing domains. */
47
	@Override
47
	protected TransactionalEditingDomain createEditingDomain(ResourceSet rset) {
48
	protected TransactionalEditingDomain createEditingDomain(ResourceSet rset) {
48
		return myDomain;
49
		return myDomain;
49
	}
50
	}
50
	
51
	
52
	@Override
51
	protected ResourceSet createResourceSet() {
53
	protected ResourceSet createResourceSet() {
52
		return myDomain.getResourceSet();
54
		return myDomain.getResourceSet();
53
	}
55
	}
(-)src/org/eclipse/emf/transaction/tests/EditingDomainRegistryTest.java (-17 / +17 lines)
Lines 216-225 Link Here
216
		
216
		
217
		// should have gotten events from the read transaction, above
217
		// should have gotten events from the read transaction, above
218
		assertNotNull(TestListener1.getInstance().postcommit);
218
		assertNotNull(TestListener1.getInstance().postcommit);
219
		List notifications = TestListener1.getInstance().postcommit.getNotifications();
219
		List<Notification> notifications = TestListener1.getInstance().postcommit.getNotifications();
220
		assertFalse(notifications == null);
220
		assertFalse(notifications == null);
221
		assertEquals(1, notifications.size());
221
		assertEquals(1, notifications.size());
222
		Notification notification = (Notification) notifications.get(0);
222
		Notification notification = notifications.get(0);
223
		assertSame(domain3.getResourceSet(), notification.getNotifier());
223
		assertSame(domain3.getResourceSet(), notification.getNotifier());
224
		assertEquals(ResourceSet.RESOURCE_SET__RESOURCES, notification.getFeatureID(null));
224
		assertEquals(ResourceSet.RESOURCE_SET__RESOURCES, notification.getFeatureID(null));
225
		assertEquals(Notification.ADD, notification.getEventType());
225
		assertEquals(Notification.ADD, notification.getEventType());
Lines 282-291 Link Here
282
		
282
		
283
		// should have gotten events from the read transaction, above
283
		// should have gotten events from the read transaction, above
284
		assertNotNull(TestListener2.getInstance().postcommit);
284
		assertNotNull(TestListener2.getInstance().postcommit);
285
		List notifications = TestListener2.getInstance().postcommitNotifications;
285
		List<Notification> notifications = TestListener2.getInstance().postcommitNotifications;
286
		assertFalse(notifications == null);
286
		assertFalse(notifications == null);
287
		assertEquals(1, notifications.size());
287
		assertEquals(1, notifications.size());
288
		Notification notification = (Notification) notifications.get(0);
288
		Notification notification = notifications.get(0);
289
		assertSame(domain3.getResourceSet(), notification.getNotifier());
289
		assertSame(domain3.getResourceSet(), notification.getNotifier());
290
		assertEquals(ResourceSet.RESOURCE_SET__RESOURCES, notification.getFeatureID(null));
290
		assertEquals(ResourceSet.RESOURCE_SET__RESOURCES, notification.getFeatureID(null));
291
		assertEquals(Notification.ADD, notification.getEventType());
291
		assertEquals(Notification.ADD, notification.getEventType());
Lines 308-314 Link Here
308
		notifications = TestListener2.getInstance().postcommitNotifications;
308
		notifications = TestListener2.getInstance().postcommitNotifications;
309
		assertFalse(notifications == null);
309
		assertFalse(notifications == null);
310
		assertEquals(1, notifications.size());
310
		assertEquals(1, notifications.size());
311
		notification = (Notification) notifications.get(0);
311
		notification = notifications.get(0);
312
		assertSame(domain4.getResourceSet(), notification.getNotifier());
312
		assertSame(domain4.getResourceSet(), notification.getNotifier());
313
		assertEquals(ResourceSet.RESOURCE_SET__RESOURCES, notification.getFeatureID(null));
313
		assertEquals(ResourceSet.RESOURCE_SET__RESOURCES, notification.getFeatureID(null));
314
		assertEquals(Notification.ADD, notification.getEventType());
314
		assertEquals(Notification.ADD, notification.getEventType());
Lines 365-374 Link Here
365
		
365
		
366
		// should have gotten events from the read transaction, above
366
		// should have gotten events from the read transaction, above
367
		assertNotNull(TestListener3.getInstance().postcommit);
367
		assertNotNull(TestListener3.getInstance().postcommit);
368
		List notifications = TestListener3.getInstance().postcommitNotifications;
368
		List<Notification> notifications = TestListener3.getInstance().postcommitNotifications;
369
		assertFalse(notifications == null);
369
		assertFalse(notifications == null);
370
		assertEquals(1, notifications.size());
370
		assertEquals(1, notifications.size());
371
		Notification notification = (Notification) notifications.get(0);
371
		Notification notification = notifications.get(0);
372
		assertSame(domain3.getResourceSet(), notification.getNotifier());
372
		assertSame(domain3.getResourceSet(), notification.getNotifier());
373
		assertEquals(ResourceSet.RESOURCE_SET__RESOURCES, notification.getFeatureID(null));
373
		assertEquals(ResourceSet.RESOURCE_SET__RESOURCES, notification.getFeatureID(null));
374
		assertEquals(Notification.ADD, notification.getEventType());
374
		assertEquals(Notification.ADD, notification.getEventType());
Lines 391-397 Link Here
391
		notifications = TestListener3.getInstance().postcommitNotifications;
391
		notifications = TestListener3.getInstance().postcommitNotifications;
392
		assertFalse(notifications == null);
392
		assertFalse(notifications == null);
393
		assertEquals(1, notifications.size());
393
		assertEquals(1, notifications.size());
394
		notification = (Notification) notifications.get(0);
394
		notification = notifications.get(0);
395
		assertSame(domain4.getResourceSet(), notification.getNotifier());
395
		assertSame(domain4.getResourceSet(), notification.getNotifier());
396
		assertEquals(ResourceSet.RESOURCE_SET__RESOURCES, notification.getFeatureID(null));
396
		assertEquals(ResourceSet.RESOURCE_SET__RESOURCES, notification.getFeatureID(null));
397
		assertEquals(Notification.ADD, notification.getEventType());
397
		assertEquals(Notification.ADD, notification.getEventType());
Lines 421-460 Link Here
421
	
421
	
422
	/** Test listener registered against TestDomain3. */
422
	/** Test listener registered against TestDomain3. */
423
	public static class TestListener1 extends TestListener {
423
	public static class TestListener1 extends TestListener {
424
		private static WeakReference instance;
424
		private static WeakReference<TestListener1> instance;
425
		
425
		
426
		public TestListener1() {
426
		public TestListener1() {
427
			instance = new WeakReference(this);
427
			instance = new WeakReference<TestListener1>(this);
428
		}
428
		}
429
		
429
		
430
		public static TestListener1 getInstance() {
430
		public static TestListener1 getInstance() {
431
			return instance == null ? null : (TestListener1) instance.get();
431
			return instance == null ? null : instance.get();
432
		}
432
		}
433
	}
433
	}
434
	
434
	
435
	/** Test listener registered against TestDomain3. */
435
	/** Test listener registered against TestDomain3. */
436
	public static class TestListener2 extends TestListener {
436
	public static class TestListener2 extends TestListener {
437
		private static WeakReference instance;
437
		private static WeakReference<TestListener2> instance;
438
		
438
		
439
		public TestListener2() {
439
		public TestListener2() {
440
			instance = new WeakReference(this);
440
			instance = new WeakReference<TestListener2>(this);
441
		}
441
		}
442
		
442
		
443
		public static TestListener2 getInstance() {
443
		public static TestListener2 getInstance() {
444
			return instance == null ? null : (TestListener2) instance.get();
444
			return instance == null ? null : instance.get();
445
		}
445
		}
446
	}
446
	}
447
	
447
	
448
	/** Test listener registered against all domains. */
448
	/** Test listener registered against all domains. */
449
	public static class TestListener3 extends TestListener {
449
	public static class TestListener3 extends TestListener {
450
		private static WeakReference instance;
450
		private static WeakReference<TestListener3> instance;
451
		
451
		
452
		public TestListener3() {
452
		public TestListener3() {
453
			instance = new WeakReference(this);
453
			instance = new WeakReference<TestListener3>(this);
454
		}
454
		}
455
		
455
		
456
		public static TestListener3 getInstance() {
456
		public static TestListener3 getInstance() {
457
			return instance == null ? null : (TestListener3) instance.get();
457
			return instance == null ? null : instance.get();
458
		}
458
		}
459
	}
459
	}
460
	
460
	
(-)src/org/eclipse/emf/transaction/tests/BasicTransactionTest.java (-10 / +5 lines)
Lines 17-23 Link Here
17
package org.eclipse.emf.transaction.tests;
17
package org.eclipse.emf.transaction.tests;
18
18
19
import java.util.Collections;
19
import java.util.Collections;
20
import java.util.Iterator;
21
import java.util.List;
20
import java.util.List;
22
21
23
import junit.framework.Test;
22
import junit.framework.Test;
Lines 36-43 Link Here
36
import org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
35
import org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
37
import org.eclipse.emf.transaction.RollbackException;
36
import org.eclipse.emf.transaction.RollbackException;
38
import org.eclipse.emf.transaction.RunnableWithResult;
37
import org.eclipse.emf.transaction.RunnableWithResult;
39
import org.eclipse.emf.transaction.TransactionalCommandStack;
40
import org.eclipse.emf.transaction.Transaction;
38
import org.eclipse.emf.transaction.Transaction;
39
import org.eclipse.emf.transaction.TransactionalCommandStack;
41
import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
40
import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
42
import org.eclipse.emf.transaction.internal.EMFTransactionStatusCodes;
41
import org.eclipse.emf.transaction.internal.EMFTransactionStatusCodes;
43
import org.eclipse.emf.transaction.tests.fixtures.TestListener;
42
import org.eclipse.emf.transaction.tests.fixtures.TestListener;
Lines 354-360 Link Here
354
		
353
		
355
		// check that we got the expected events
354
		// check that we got the expected events
356
		assertNotNull(listener.postcommit);
355
		assertNotNull(listener.postcommit);
357
		List notifications = listener.postcommitNotifications;
356
		List<Notification> notifications = listener.postcommitNotifications;
358
		assertFalse(notifications.isEmpty());
357
		assertFalse(notifications.isEmpty());
359
		
358
		
360
		// look for an event indicating resource was loaded and one indicating
359
		// look for an event indicating resource was loaded and one indicating
Lines 362-370 Link Here
362
		Notification rootAdded = null;
361
		Notification rootAdded = null;
363
		Notification resLoaded = null;
362
		Notification resLoaded = null;
364
		
363
		
365
		for (Iterator iter = notifications.iterator(); iter.hasNext();) {
364
		for (Notification next : notifications) {
366
			Notification next = (Notification) iter.next();
367
			
368
			if (next.getNotifier() == res) {
365
			if (next.getNotifier() == res) {
369
				if (next.getFeatureID(null) == Resource.RESOURCE__IS_LOADED) {
366
				if (next.getFeatureID(null) == Resource.RESOURCE__IS_LOADED) {
370
					if (next.getNewBooleanValue()) {
367
					if (next.getNewBooleanValue()) {
Lines 400-408 Link Here
400
		Notification rootRemoved = null;
397
		Notification rootRemoved = null;
401
		Notification resUnloaded = null;
398
		Notification resUnloaded = null;
402
		
399
		
403
		for (Iterator iter = notifications.iterator(); iter.hasNext();) {
400
		for (Notification next : notifications) {
404
			Notification next = (Notification) iter.next();
405
			
406
			if (next.getNotifier() == res) {
401
			if (next.getNotifier() == res) {
407
				if (next.getFeatureID(null) == Resource.RESOURCE__IS_LOADED) {
402
				if (next.getFeatureID(null) == Resource.RESOURCE__IS_LOADED) {
408
					if (!next.getNewBooleanValue()) {
403
					if (!next.getNewBooleanValue()) {
Lines 525-531 Link Here
525
			}});
520
			}});
526
		
521
		
527
		try {
522
		try {
528
			RunnableWithResult rwr = new RunnableWithResult.Impl() {
523
			RunnableWithResult<?> rwr = new RunnableWithResult.Impl<Object>() {
529
				public void run() {
524
				public void run() {
530
					synchronized (monitor) {
525
					synchronized (monitor) {
531
						t.start();
526
						t.start();
(-)src/org/eclipse/emf/transaction/tests/MemoryLeakTest.java (-28 / +43 lines)
Lines 25-35 Link Here
25
import java.util.List;
25
import java.util.List;
26
import java.util.Map;
26
import java.util.Map;
27
27
28
import junit.framework.Test;
29
import junit.framework.TestSuite;
30
28
import org.eclipse.emf.common.command.Command;
31
import org.eclipse.emf.common.command.Command;
29
import org.eclipse.emf.common.notify.Notification;
32
import org.eclipse.emf.common.notify.Notification;
30
import org.eclipse.emf.common.util.BasicEList;
33
import org.eclipse.emf.common.util.BasicEList;
31
import org.eclipse.emf.ecore.EObject;
34
import org.eclipse.emf.ecore.EObject;
32
import org.eclipse.emf.ecore.EReference;
35
import org.eclipse.emf.ecore.EReference;
36
import org.eclipse.emf.ecore.change.ChangeDescription;
33
import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
37
import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
34
import org.eclipse.emf.ecore.util.EcoreUtil;
38
import org.eclipse.emf.ecore.util.EcoreUtil;
35
import org.eclipse.emf.edit.command.CommandParameter;
39
import org.eclipse.emf.edit.command.CommandParameter;
Lines 44-52 Link Here
44
import org.eclipse.emf.transaction.TriggerListener;
48
import org.eclipse.emf.transaction.TriggerListener;
45
import org.eclipse.emf.transaction.util.CompositeChangeDescription;
49
import org.eclipse.emf.transaction.util.CompositeChangeDescription;
46
50
47
import junit.framework.Test;
48
import junit.framework.TestSuite;
49
50
51
51
/**
52
/**
52
 * Tests to check for memory leaks.
53
 * Tests to check for memory leaks.
Lines 66-73 Link Here
66
	 * Tests that unloading a resource allows its root(s) to be reclaimed.
67
	 * Tests that unloading a resource allows its root(s) to be reclaimed.
67
	 */
68
	 */
68
	public void test_unloadResource() {
69
	public void test_unloadResource() {
69
		ReferenceQueue q = new ReferenceQueue();
70
		ReferenceQueue<EObject> q = new ReferenceQueue<EObject>();
70
		Reference ref = new WeakReference(root, q);
71
		Reference<EObject> ref = new WeakReference<EObject>(root, q);
71
		
72
		
72
		// make some change, causing a transaction to record a change description
73
		// make some change, causing a transaction to record a change description
73
		startWriting();
74
		startWriting();
Lines 94-101 Link Here
94
	 * to it and its resource set's contents.
95
	 * to it and its resource set's contents.
95
	 */
96
	 */
96
	public void test_reclaimEditingDomain() {
97
	public void test_reclaimEditingDomain() {
97
		ReferenceQueue q = new ReferenceQueue();
98
		ReferenceQueue<TransactionalEditingDomain> q =
98
		Reference ref = new WeakReference(domain, q);
99
			new ReferenceQueue<TransactionalEditingDomain>();
100
		Reference<TransactionalEditingDomain> ref =
101
			new WeakReference<TransactionalEditingDomain>(domain, q);
99
		
102
		
100
		// make some change, causing a transaction to record a change description
103
		// make some change, causing a transaction to record a change description
101
		startWriting();
104
		startWriting();
Lines 133-139 Link Here
133
		root.setName("foo"); //$NON-NLS-1$
136
		root.setName("foo"); //$NON-NLS-1$
134
		
137
		
135
		// now, create 1000 nested transactions, each doing a change, *but* unrecorded
138
		// now, create 1000 nested transactions, each doing a change, *but* unrecorded
136
		Map options = Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE);
139
		Map<Object, Object> options = Collections.<Object, Object>singletonMap(
140
			Transaction.OPTION_UNPROTECTED, Boolean.TRUE);
141
		
137
		for (int i = 0; i < 1000; i++) {
142
		for (int i = 0; i < 1000; i++) {
138
			startWriting(options);
143
			startWriting(options);
139
			
144
			
Lines 152-158 Link Here
152
		
157
		
153
		Transaction tx = commit();
158
		Transaction tx = commit();
154
		CompositeChangeDescription change = (CompositeChangeDescription) tx.getChangeDescription();
159
		CompositeChangeDescription change = (CompositeChangeDescription) tx.getChangeDescription();
155
		List children = getChildren(change);
160
		List<ChangeDescription> children = getChildren(change);
156
		
161
		
157
		assertEquals(1, children.size());
162
		assertEquals(1, children.size());
158
		
163
		
Lines 197-206 Link Here
197
        assertTrue(level1.eAdapters().contains(xrefAdapter));
202
        assertTrue(level1.eAdapters().contains(xrefAdapter));
198
        
203
        
199
        Command cmd = new RemoveCommand(domain, root, EXTLibraryPackage.Literals.LIBRARY__BRANCHES, level1) {
204
        Command cmd = new RemoveCommand(domain, root, EXTLibraryPackage.Literals.LIBRARY__BRANCHES, level1) {
200
            public void doDispose() {
205
            @Override
206
			public void doDispose() {
201
                if (feature instanceof EReference && ((EReference) feature).isContainment()) {
207
                if (feature instanceof EReference && ((EReference) feature).isContainment()) {
202
                    for (Iterator iter = collection.iterator(); iter.hasNext();) {
208
                    for (Object o : collection) {
203
                        EObject next = (EObject) iter.next();
209
                        EObject next = (EObject) o;
204
                        
210
                        
205
                        // clear adapters on the removed object if it is still removed
211
                        // clear adapters on the removed object if it is still removed
206
                        if (next.eContainer() != owner) {
212
                        if (next.eContainer() != owner) {
Lines 253-259 Link Here
253
        assertTrue(level1.eAdapters().contains(xrefAdapter));
259
        assertTrue(level1.eAdapters().contains(xrefAdapter));
254
        
260
        
255
        Command cmd = new RecordingCommand(domain, "Remove Branch") { //$NON-NLS-1$
261
        Command cmd = new RecordingCommand(domain, "Remove Branch") { //$NON-NLS-1$
256
            protected void doExecute() {
262
            @Override
263
			protected void doExecute() {
257
                root.getBranches().remove(level1);        
264
                root.getBranches().remove(level1);        
258
            }};
265
            }};
259
        
266
        
Lines 301-310 Link Here
301
        assertTrue(level1.eAdapters().contains(xrefAdapter));
308
        assertTrue(level1.eAdapters().contains(xrefAdapter));
302
        
309
        
303
        final Command trigger = new RemoveCommand(domain, root, EXTLibraryPackage.Literals.LIBRARY__BRANCHES, level1) {
310
        final Command trigger = new RemoveCommand(domain, root, EXTLibraryPackage.Literals.LIBRARY__BRANCHES, level1) {
304
            public void doDispose() {
311
            @Override
312
			public void doDispose() {
305
                if (feature instanceof EReference && ((EReference) feature).isContainment()) {
313
                if (feature instanceof EReference && ((EReference) feature).isContainment()) {
306
                    for (Iterator iter = collection.iterator(); iter.hasNext();) {
314
                    for (Object o : collection) {
307
                        EObject next = (EObject) iter.next();
315
                        EObject next = (EObject) o;
308
                        
316
                        
309
                        // clear adapters on the removed object if it is still removed
317
                        // clear adapters on the removed object if it is still removed
310
                        if (next.eContainer() != owner) {
318
                        if (next.eContainer() != owner) {
Lines 317-323 Link Here
317
            }};
325
            }};
318
        
326
        
319
        domain.addResourceSetListener(new TriggerListener() {
327
        domain.addResourceSetListener(new TriggerListener() {
320
            protected Command trigger(TransactionalEditingDomain domain,
328
            @Override
329
			protected Command trigger(TransactionalEditingDomain domain,
321
                    Notification notification) {
330
                    Notification notification) {
322
                // trigger on the name change only
331
                // trigger on the name change only
323
                if (notification.getFeature() == EXTLibraryPackage.Literals.LIBRARY__NAME) {
332
                if (notification.getFeature() == EXTLibraryPackage.Literals.LIBRARY__NAME) {
Lines 372-383 Link Here
372
        assertTrue(level1.eAdapters().contains(xrefAdapter));
381
        assertTrue(level1.eAdapters().contains(xrefAdapter));
373
        
382
        
374
        final Command trigger = new RecordingCommand(domain, "Remove Branch") { //$NON-NLS-1$
383
        final Command trigger = new RecordingCommand(domain, "Remove Branch") { //$NON-NLS-1$
375
            protected void doExecute() {
384
            @Override
385
			protected void doExecute() {
376
                root.getBranches().remove(level1);        
386
                root.getBranches().remove(level1);        
377
            }};
387
            }};
378
        
388
        
379
        domain.addResourceSetListener(new TriggerListener() {
389
        domain.addResourceSetListener(new TriggerListener() {
380
            protected Command trigger(TransactionalEditingDomain domain,
390
            @Override
391
			protected Command trigger(TransactionalEditingDomain domain,
381
                    Notification notification) {
392
                    Notification notification) {
382
                // trigger on the name change only
393
                // trigger on the name change only
383
                if (notification.getFeature() == EXTLibraryPackage.Literals.LIBRARY__NAME) {
394
                if (notification.getFeature() == EXTLibraryPackage.Literals.LIBRARY__NAME) {
Lines 427-440 Link Here
427
		return result;
438
		return result;
428
	}
439
	}
429
	
440
	
430
	static List getChildren(CompositeChangeDescription compositeChange) {
441
	@SuppressWarnings("unchecked")
431
		List result = null;
442
	static List<ChangeDescription> getChildren(CompositeChangeDescription compositeChange) {
443
		List<ChangeDescription> result = null;
432
		
444
		
433
		try {
445
		try {
434
			Field children = compositeChange.getClass().getDeclaredField("changes"); //$NON-NLS-1$
446
			Field children = compositeChange.getClass().getDeclaredField("changes"); //$NON-NLS-1$
435
			children.setAccessible(true);
447
			children.setAccessible(true);
436
			
448
			
437
			result = (List) children.get(compositeChange);
449
			result = (List<ChangeDescription>) children.get(compositeChange);
438
		} catch (Exception e) {
450
		} catch (Exception e) {
439
			e.printStackTrace();
451
			e.printStackTrace();
440
			fail(e.getLocalizedMessage());
452
			fail(e.getLocalizedMessage());
Lines 444-462 Link Here
444
	}
456
	}
445
    
457
    
446
    private static class TransactionSniffer extends ResourceSetListenerImpl {
458
    private static class TransactionSniffer extends ResourceSetListenerImpl {
447
        private TransactionalEditingDomain domain;
459
        private final TransactionalEditingDomain domain;
448
        private List changes = new BasicEList.FastCompare();
460
        private final List<ChangeDescription> changes =
461
        	new BasicEList.FastCompare<ChangeDescription>();
449
        
462
        
450
        TransactionSniffer(TransactionalEditingDomain domain) {
463
        TransactionSniffer(TransactionalEditingDomain domain) {
451
            this.domain = domain;
464
            this.domain = domain;
452
            domain.addResourceSetListener(this);
465
            domain.addResourceSetListener(this);
453
        }
466
        }
454
        
467
        
455
        public boolean isPostcommitOnly() {
468
        @Override
469
		public boolean isPostcommitOnly() {
456
            return true;
470
            return true;
457
        }
471
        }
458
        
472
        
459
        public void resourceSetChanged(ResourceSetChangeEvent event) {
473
        @Override
474
		public void resourceSetChanged(ResourceSetChangeEvent event) {
460
            Transaction tx = event.getTransaction();
475
            Transaction tx = event.getTransaction();
461
            
476
            
462
            if ((tx != null) && (tx.getChangeDescription()) != null) {
477
            if ((tx != null) && (tx.getChangeDescription()) != null) {
Lines 468-475 Link Here
468
            // stop listening, now
483
            // stop listening, now
469
            domain.removeResourceSetListener(this);
484
            domain.removeResourceSetListener(this);
470
            
485
            
471
            for (Iterator iter = EcoreUtil.getAllContents(changes); iter.hasNext();) {
486
            for (Iterator<EObject> iter = EcoreUtil.getAllContents(changes); iter.hasNext();) {
472
                EObject next = (EObject) iter.next();
487
                EObject next = iter.next();
473
                assertEquals("Adapters not cleared.", 0, next.eAdapters().size()); //$NON-NLS-1$
488
                assertEquals("Adapters not cleared.", 0, next.eAdapters().size()); //$NON-NLS-1$
474
            }
489
            }
475
        }
490
        }
(-)src/org/eclipse/emf/transaction/tests/PerformanceTest.java (-29 / +43 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 23-28 Link Here
23
import java.util.List;
23
import java.util.List;
24
import java.util.Map;
24
import java.util.Map;
25
25
26
import junit.framework.Test;
27
import junit.framework.TestSuite;
28
26
import org.eclipse.emf.common.command.Command;
29
import org.eclipse.emf.common.command.Command;
27
import org.eclipse.emf.common.command.CompoundCommand;
30
import org.eclipse.emf.common.command.CompoundCommand;
28
import org.eclipse.emf.common.util.EList;
31
import org.eclipse.emf.common.util.EList;
Lines 39-47 Link Here
39
import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
42
import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
40
import org.eclipse.emf.transaction.tests.fixtures.TestCommand;
43
import org.eclipse.emf.transaction.tests.fixtures.TestCommand;
41
44
42
import junit.framework.Test;
43
import junit.framework.TestSuite;
44
45
45
46
/**
46
/**
47
 * Regression tests for performance problems (time and memory).
47
 * Regression tests for performance problems (time and memory).
Lines 52-61 Link Here
52
	static final int RUNS = 10;
52
	static final int RUNS = 10;
53
	static final int OUTLIERS = 2;  // room for 1 high and 1 low outlier
53
	static final int OUTLIERS = 2;  // room for 1 high and 1 low outlier
54
	
54
	
55
	private List timings;
55
	private List<Long> timings;
56
	private long clock;
56
	private long clock;
57
	
57
	
58
	private int count = RUNS + OUTLIERS;
58
	private final int count = RUNS + OUTLIERS;
59
	
59
	
60
	public PerformanceTest(String name) {
60
	public PerformanceTest(String name) {
61
		super(name);
61
		super(name);
Lines 95-100 Link Here
95
		
95
		
96
		// add a listener to incur the cost of broadcasting pre- and post-commit
96
		// add a listener to incur the cost of broadcasting pre- and post-commit
97
		ResourceSetListener listener = new ResourceSetListenerImpl() {
97
		ResourceSetListener listener = new ResourceSetListenerImpl() {
98
			@Override
98
			public Command transactionAboutToCommit(ResourceSetChangeEvent event)
99
			public Command transactionAboutToCommit(ResourceSetChangeEvent event)
99
					throws RollbackException {
100
					throws RollbackException {
100
				CompoundCommand result = null;
101
				CompoundCommand result = null;
Lines 107-127 Link Here
107
					// only create a command on the first transaction
108
					// only create a command on the first transaction
108
					result = new CompoundCommand();
109
					result = new CompoundCommand();
109
					
110
					
110
					for (Iterator iter = event.getNotifications().iterator(); iter.hasNext();) {
111
					for (Iterator<?> iter = event.getNotifications().iterator(); iter.hasNext();) {
111
						iter.next();
112
						iter.next();
112
						
113
						
113
						precommitEvents[0]++;
114
						precommitEvents[0]++;
114
						
115
						
115
						result.append(new TestCommand() {
116
						result.append(new TestCommand() {
116
							public void execute() {}});
117
							public void execute() {/* nothing to do */}});
117
					}
118
					}
118
				}
119
				}
119
				
120
				
120
				return result;
121
				return result;
121
			}
122
			}
122
		
123
		
124
			@Override
123
			public void resourceSetChanged(ResourceSetChangeEvent event) {
125
			public void resourceSetChanged(ResourceSetChangeEvent event) {
124
				for (Iterator iter = event.getNotifications().iterator(); iter.hasNext();) { 
126
				for (Iterator<?> iter = event.getNotifications().iterator(); iter.hasNext();) { 
125
					iter.next();
127
					iter.next();
126
					
128
					
127
					// do a trivial amount of work
129
					// do a trivial amount of work
Lines 132-138 Link Here
132
134
133
		domain.addResourceSetListener(listener);
135
		domain.addResourceSetListener(listener);
134
		
136
		
135
		Map options = new java.util.HashMap();
137
		Map<Object, Object> options = new java.util.HashMap<Object, Object>();
136
//		options.put(Transaction.OPTION_NO_NOTIFICATIONS, Boolean.TRUE);
138
//		options.put(Transaction.OPTION_NO_NOTIFICATIONS, Boolean.TRUE);
137
//		options.put(Transaction.OPTION_NO_TRIGGERS, Boolean.TRUE);
139
//		options.put(Transaction.OPTION_NO_TRIGGERS, Boolean.TRUE);
138
//		options.put(Transaction.OPTION_NO_VALIDATION, Boolean.TRUE);
140
//		options.put(Transaction.OPTION_NO_VALIDATION, Boolean.TRUE);
Lines 190-220 Link Here
190
		final int[] receivedValidationNotifications = new int[1];
192
		final int[] receivedValidationNotifications = new int[1];
191
		
193
		
192
		ResourceSetListener prePostCommitCollector = new ResourceSetListenerImpl() {
194
		ResourceSetListener prePostCommitCollector = new ResourceSetListenerImpl() {
195
			@Override
193
			public NotificationFilter getFilter() {
196
			public NotificationFilter getFilter() {
194
				return NotificationFilter.ANY;
197
				return NotificationFilter.ANY;
195
			}
198
			}
196
			
199
			
200
			@Override
197
			public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {
201
			public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {
198
				receivedPrecommitNotifications[0] += event.getNotifications().size();
202
				receivedPrecommitNotifications[0] += event.getNotifications().size();
199
				return null;
203
				return null;
200
			}
204
			}
201
			
205
			
206
			@Override
202
			public void resourceSetChanged(ResourceSetChangeEvent event) {
207
			public void resourceSetChanged(ResourceSetChangeEvent event) {
203
				receivedPostcommitNotifications[0] = event.getNotifications().size();
208
				receivedPostcommitNotifications[0] = event.getNotifications().size();
204
			}};
209
			}};
205
		domain.addResourceSetListener(prePostCommitCollector);
210
		domain.addResourceSetListener(prePostCommitCollector);
206
		ResourceSetListener validationCollector = new ResourceSetListenerImpl() {
211
		ResourceSetListener validationCollector = new ResourceSetListenerImpl() {
212
			@Override
207
			public NotificationFilter getFilter() {
213
			public NotificationFilter getFilter() {
208
				return NotificationFilter.ANY;
214
				return NotificationFilter.ANY;
209
			}
215
			}
210
			
216
			
217
			@Override
211
			public boolean isPrecommitOnly() {
218
			public boolean isPrecommitOnly() {
212
				return true;
219
				return true;
213
			}
220
			}
221
			@Override
214
			public boolean isAggregatePrecommitListener() {
222
			public boolean isAggregatePrecommitListener() {
215
				return true;
223
				return true;
216
			}
224
			}
217
			
225
			
226
			@Override
218
			public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {
227
			public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {
219
				receivedValidationNotifications[0] =
228
				receivedValidationNotifications[0] =
220
					((InternalTransactionalEditingDomain) domain).getValidator()
229
					((InternalTransactionalEditingDomain) domain).getValidator()
Lines 270-284 Link Here
270
	// Fixture methods
279
	// Fixture methods
271
	//
280
	//
272
	
281
	
282
	@Override
273
	protected void doSetUp() throws Exception {
283
	protected void doSetUp() throws Exception {
274
		super.doSetUp();
284
		super.doSetUp();
275
		
285
		
276
		System.out.println("Performance test: " + getName()); //$NON-NLS-1$
286
		System.out.println("Performance test: " + getName()); //$NON-NLS-1$
277
		System.out.println("==============================="); //$NON-NLS-1$
287
		System.out.println("==============================="); //$NON-NLS-1$
278
		
288
		
279
		timings = new java.util.ArrayList();
289
		timings = new java.util.ArrayList<Long>();
280
	}
290
	}
281
	
291
	
292
	@Override
282
	protected void doTearDown() throws Exception {
293
	protected void doTearDown() throws Exception {
283
		removeOutliers();
294
		removeOutliers();
284
		
295
		
Lines 343-353 Link Here
343
	
354
	
344
	protected void addLibraryWithBooks(Date today) {
355
	protected void addLibraryWithBooks(Date today) {
345
		Library lib = EXTLibraryFactory.eINSTANCE.createLibrary();
356
		Library lib = EXTLibraryFactory.eINSTANCE.createLibrary();
346
		EList branches = lib.getBranches();
357
		EList<Library> branches = lib.getBranches();
347
		
358
		
348
		for (int j = 0; j < 20; j++) {
359
		for (int j = 0; j < 20; j++) {
349
			Library branch = EXTLibraryFactory.eINSTANCE.createLibrary();
360
			Library branch = EXTLibraryFactory.eINSTANCE.createLibrary();
350
			EList books = branch.getBooks();
361
			EList<Book> books = branch.getBooks();
351
			
362
			
352
			for (int i = 0; i < 10; i++) {
363
			for (int i = 0; i < 10; i++) {
353
				Book book = EXTLibraryFactory.eINSTANCE.createBook();
364
				Book book = EXTLibraryFactory.eINSTANCE.createBook();
Lines 452-470 Link Here
452
		root.setName(Long.toString(System.currentTimeMillis() ^ root.getName().hashCode()));
463
		root.setName(Long.toString(System.currentTimeMillis() ^ root.getName().hashCode()));
453
	}
464
	}
454
	
465
	
455
	private static Map allNotifications;
466
	private static Map<Object, Object> allNotifications;
456
	private static Map noTriggers;
467
	private static Map<Object, Object> noTriggers;
457
	private static Map validationOnly;
468
	private static Map<Object, Object> validationOnly;
458
	private static Map noNotifications;
469
	private static Map<Object, Object> noNotifications;
459
	static {
470
	static {
460
		allNotifications = Collections.EMPTY_MAP;
471
		allNotifications = Collections.emptyMap();
461
		noTriggers = Collections.singletonMap(Transaction.OPTION_NO_TRIGGERS, Boolean.TRUE);
472
		noTriggers = Collections.<Object, Object>singletonMap(
462
		validationOnly = new java.util.HashMap(noTriggers);
473
			Transaction.OPTION_NO_TRIGGERS, true);
463
		validationOnly.put(Transaction.OPTION_NO_NOTIFICATIONS, Boolean.TRUE);
474
		validationOnly = new java.util.HashMap<Object, Object>(noTriggers);
464
		noNotifications = new java.util.HashMap(validationOnly);
475
		validationOnly.put(Transaction.OPTION_NO_NOTIFICATIONS, true);
465
		noNotifications.put(Transaction.OPTION_NO_VALIDATION, Boolean.TRUE);
476
		noNotifications = new java.util.HashMap<Object, Object>(validationOnly);
477
		noNotifications.put(Transaction.OPTION_NO_VALIDATION, true);
466
	}
478
	}
467
	private Map getOptions(boolean trigger, boolean notify, boolean validate) {
479
	private Map<Object, Object> getOptions(boolean trigger, boolean notify,
480
			boolean validate) {
481
		
468
		if (!trigger) {
482
		if (!trigger) {
469
			if (!notify) {
483
			if (!notify) {
470
				if (!validate) {
484
				if (!validate) {
Lines 487-493 Link Here
487
	final long stopClock() {
501
	final long stopClock() {
488
		long result = System.currentTimeMillis() - clock;
502
		long result = System.currentTimeMillis() - clock;
489
		
503
		
490
		timings.add(new Long(result));
504
		timings.add(result);
491
		
505
		
492
		return result;
506
		return result;
493
	}
507
	}
Lines 506-515 Link Here
506
		int count = timings.size();
520
		int count = timings.size();
507
		
521
		
508
		for (int i = 0; i < count; i++) {
522
		for (int i = 0; i < count; i++) {
509
			result += ((Long) timings.get(i)).doubleValue();
523
			result += timings.get(i).doubleValue();
510
		}
524
		}
511
		
525
		
512
		result /= (double) count;
526
		result /= count;
513
		
527
		
514
		return result;
528
		return result;
515
	}
529
	}
Lines 521-532 Link Here
521
		int count = timings.size();
535
		int count = timings.size();
522
		
536
		
523
		for (int i = 0; i < count; i++) {
537
		for (int i = 0; i < count; i++) {
524
			dev = ((Long) timings.get(i)).doubleValue() - mean;
538
			dev = timings.get(i).doubleValue() - mean;
525
			
539
			
526
			result += dev * dev;
540
			result += dev * dev;
527
		}
541
		}
528
		
542
		
529
		result = Math.sqrt(result / (double) count);
543
		result = Math.sqrt(result / count);
530
		
544
		
531
		return result;
545
		return result;
532
	}
546
	}
(-)src/org/eclipse/emf/transaction/tests/UndoRedoTest.java (-12 / +30 lines)
Lines 16-22 Link Here
16
 */
16
 */
17
package org.eclipse.emf.transaction.tests;
17
package org.eclipse.emf.transaction.tests;
18
18
19
import java.util.Iterator;
20
import java.util.Set;
19
import java.util.Set;
21
20
22
import junit.framework.Test;
21
import junit.framework.Test;
Lines 88-93 Link Here
88
		commit();
87
		commit();
89
		
88
		
90
		Command cmd = new RecordingCommand(domain) {
89
		Command cmd = new RecordingCommand(domain) {
90
			@Override
91
			protected void doExecute() {
91
			protected void doExecute() {
92
				book.setTitle(newTitle);
92
				book.setTitle(newTitle);
93
				newAuthor.getBooks().add(book);
93
				newAuthor.getBooks().add(book);
Lines 157-163 Link Here
157
		
157
		
158
		assertSame(root, newLibrary.eContainer());
158
		assertSame(root, newLibrary.eContainer());
159
		assertEquals(1, newLibrary.getBooks().size());
159
		assertEquals(1, newLibrary.getBooks().size());
160
		Book book = (Book) newLibrary.getBooks().get(0);
160
		Book book = newLibrary.getBooks().get(0);
161
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
161
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
162
		assertNotNull(book.getPublicationDate());
162
		assertNotNull(book.getPublicationDate());
163
		
163
		
Lines 181-187 Link Here
181
		
181
		
182
		assertSame(root, newLibrary.eContainer());
182
		assertSame(root, newLibrary.eContainer());
183
		assertEquals(1, newLibrary.getBooks().size());
183
		assertEquals(1, newLibrary.getBooks().size());
184
		book = (Book) newLibrary.getBooks().get(0);
184
		book = newLibrary.getBooks().get(0);
185
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
185
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
186
		assertNotNull(book.getPublicationDate());
186
		assertNotNull(book.getPublicationDate());
187
		
187
		
Lines 202-207 Link Here
202
		final Library newLibrary = EXTLibraryFactory.eINSTANCE.createLibrary();
202
		final Library newLibrary = EXTLibraryFactory.eINSTANCE.createLibrary();
203
		
203
		
204
		Command cmd = new RecordingCommand(domain) {
204
		Command cmd = new RecordingCommand(domain) {
205
			@Override
205
			protected void doExecute() {
206
			protected void doExecute() {
206
				// add a new library.  Our triggers will set a default name and book
207
				// add a new library.  Our triggers will set a default name and book
207
				root.getBranches().add(newLibrary);
208
				root.getBranches().add(newLibrary);
Lines 217-223 Link Here
217
		
218
		
218
		assertSame(root, newLibrary.eContainer());
219
		assertSame(root, newLibrary.eContainer());
219
		assertEquals(1, newLibrary.getBooks().size());
220
		assertEquals(1, newLibrary.getBooks().size());
220
		Book book = (Book) newLibrary.getBooks().get(0);
221
		Book book = newLibrary.getBooks().get(0);
221
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
222
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
222
		assertNotNull(book.getPublicationDate());
223
		assertNotNull(book.getPublicationDate());
223
		
224
		
Lines 241-247 Link Here
241
		
242
		
242
		assertSame(root, newLibrary.eContainer());
243
		assertSame(root, newLibrary.eContainer());
243
		assertEquals(1, newLibrary.getBooks().size());
244
		assertEquals(1, newLibrary.getBooks().size());
244
		book = (Book) newLibrary.getBooks().get(0);
245
		book = newLibrary.getBooks().get(0);
245
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
246
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
246
		assertNotNull(book.getPublicationDate());
247
		assertNotNull(book.getPublicationDate());
247
		
248
		
Lines 369-383 Link Here
369
			void reset() { count = 0; }
370
			void reset() { count = 0; }
370
			
371
			
371
			public void execute() { reset(); }
372
			public void execute() { reset(); }
373
			@Override
372
			public void undo() { assertEquals(1, ++count); }
374
			public void undo() { assertEquals(1, ++count); }
375
			@Override
373
			public void redo() { assertEquals(1, ++count); }
376
			public void redo() { assertEquals(1, ++count); }
374
		}
377
		}
375
		
378
		
376
		final Set countingCommands = new java.util.HashSet();
379
		final Set<CountingCommand> countingCommands =
380
			new java.util.HashSet<CountingCommand>();
377
		
381
		
378
		// add the trigger to create a default book in a new library, combined
382
		// add the trigger to create a default book in a new library, combined
379
		//    with a counting command
383
		//    with a counting command
380
		domain.addResourceSetListener(new LibraryDefaultBookTrigger() {
384
		domain.addResourceSetListener(new LibraryDefaultBookTrigger() {
385
			@Override
381
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
386
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
382
				Command result = super.trigger(domain, notification);
387
				Command result = super.trigger(domain, notification);
383
				
388
				
Lines 393-398 Link Here
393
		// add another trigger that will set default publication dates for new
398
		// add another trigger that will set default publication dates for new
394
		//    items, combined with a counting command
399
		//    items, combined with a counting command
395
		domain.addResourceSetListener(new ItemDefaultPublicationDateTrigger() {
400
		domain.addResourceSetListener(new ItemDefaultPublicationDateTrigger() {
401
			@Override
396
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
402
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
397
				Command result = super.trigger(domain, notification);
403
				Command result = super.trigger(domain, notification);
398
				
404
				
Lines 423-430 Link Here
423
		
429
		
424
		commit();
430
		commit();
425
		
431
		
426
		for (Iterator iter = countingCommands.iterator(); iter.hasNext();) {
432
		for (CountingCommand next : countingCommands) {
427
			((CountingCommand) iter.next()).reset();
433
			next.reset();
428
		}
434
		}
429
		
435
		
430
		startWriting();
436
		startWriting();
Lines 434-441 Link Here
434
		
440
		
435
		commit();
441
		commit();
436
		
442
		
437
		for (Iterator iter = countingCommands.iterator(); iter.hasNext();) {
443
		for (CountingCommand next : countingCommands) {
438
			((CountingCommand) iter.next()).reset();
444
			next.reset();
439
		}
445
		}
440
		
446
		
441
		startWriting();
447
		startWriting();
Lines 445-452 Link Here
445
		
451
		
446
		commit();
452
		commit();
447
		
453
		
448
		for (Iterator iter = countingCommands.iterator(); iter.hasNext();) {
454
		for (CountingCommand next : countingCommands) {
449
			((CountingCommand) iter.next()).reset();
455
			next.reset();
450
		}
456
		}
451
	}
457
	}
452
	
458
	
Lines 459-464 Link Here
459
				// nothing to do
465
				// nothing to do
460
			}
466
			}
461
		
467
		
468
			@Override
462
			public boolean canRedo() {
469
			public boolean canRedo() {
463
				return false;
470
				return false;
464
			}};
471
			}};
Lines 479-490 Link Here
479
	public void test_nonredoableTriggerCommand_138287() {
486
	public void test_nonredoableTriggerCommand_138287() {
480
		// add a trigger command that is not redoable
487
		// add a trigger command that is not redoable
481
		domain.addResourceSetListener(new TriggerListener() {
488
		domain.addResourceSetListener(new TriggerListener() {
489
			@Override
482
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
490
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
483
				return new TestCommand.Redoable() {
491
				return new TestCommand.Redoable() {
484
					public void execute() {
492
					public void execute() {
485
						// nothing to do
493
						// nothing to do
486
					}
494
					}
487
				
495
				
496
					@Override
488
					public boolean canRedo() {
497
					public boolean canRedo() {
489
						return false;
498
						return false;
490
					}};
499
					}};
Lines 520-531 Link Here
520
	public void test_nonredoableTriggerCommands() {
529
	public void test_nonredoableTriggerCommands() {
521
		// add a trigger command that is not redoable
530
		// add a trigger command that is not redoable
522
		domain.addResourceSetListener(new TriggerListener() {
531
		domain.addResourceSetListener(new TriggerListener() {
532
			@Override
523
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
533
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
524
				return new TestCommand.Redoable() {
534
				return new TestCommand.Redoable() {
525
					public void execute() {
535
					public void execute() {
526
						// nothing to do
536
						// nothing to do
527
					}
537
					}
528
				
538
				
539
					@Override
529
					public boolean canRedo() {
540
					public boolean canRedo() {
530
						return false;
541
						return false;
531
					}};
542
					}};
Lines 533-544 Link Here
533
		
544
		
534
		// add a trigger command that is not redoable
545
		// add a trigger command that is not redoable
535
		domain.addResourceSetListener(new TriggerListener() {
546
		domain.addResourceSetListener(new TriggerListener() {
547
			@Override
536
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
548
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
537
				return new TestCommand.Redoable() {
549
				return new TestCommand.Redoable() {
538
					public void execute() {
550
					public void execute() {
539
						// nothing to do
551
						// nothing to do
540
					}
552
					}
541
				
553
				
554
					@Override
542
					public boolean canRedo() {
555
					public boolean canRedo() {
543
						return false;
556
						return false;
544
					}};
557
					}};
Lines 570-581 Link Here
570
	public void test_nonredoableTriggerCommand_RecordingCommand_138287() {
583
	public void test_nonredoableTriggerCommand_RecordingCommand_138287() {
571
		// add a trigger command that is not redoable
584
		// add a trigger command that is not redoable
572
		domain.addResourceSetListener(new TriggerListener() {
585
		domain.addResourceSetListener(new TriggerListener() {
586
			@Override
573
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
587
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
574
				return new TestCommand.Redoable() {
588
				return new TestCommand.Redoable() {
575
					public void execute() {
589
					public void execute() {
576
						// nothing to do
590
						// nothing to do
577
					}
591
					}
578
				
592
				
593
					@Override
579
					public boolean canRedo() {
594
					public boolean canRedo() {
580
						return false;
595
						return false;
581
					}};
596
					}};
Lines 585-590 Link Here
585
		
600
		
586
		// this command *is* implicitly redoable; it is the trigger that is not
601
		// this command *is* implicitly redoable; it is the trigger that is not
587
		RecordingCommand cmd = new RecordingCommand(domain) {
602
		RecordingCommand cmd = new RecordingCommand(domain) {
603
			@Override
588
			protected void doExecute() {
604
			protected void doExecute() {
589
				// add a new library, just to record some change
605
				// add a new library, just to record some change
590
				root.getBranches().add(newLibrary);
606
				root.getBranches().add(newLibrary);
Lines 633-638 Link Here
633
	// Fixture methods
649
	// Fixture methods
634
	//
650
	//
635
	
651
	
652
	@Override
636
	protected void doSetUp()
653
	protected void doSetUp()
637
		throws Exception {
654
		throws Exception {
638
		
655
		
Lines 642-647 Link Here
642
		ValidationRollbackTest.validationEnabled = true;
659
		ValidationRollbackTest.validationEnabled = true;
643
	}
660
	}
644
	
661
	
662
	@Override
645
	protected void doTearDown()
663
	protected void doTearDown()
646
		throws Exception {
664
		throws Exception {
647
		
665
		
(-)src/org/eclipse/emf/transaction/tests/AbstractTest.java (-34 / +39 lines)
Lines 20-26 Link Here
20
import java.io.InputStream;
20
import java.io.InputStream;
21
import java.util.Collection;
21
import java.util.Collection;
22
import java.util.Collections;
22
import java.util.Collections;
23
import java.util.Iterator;
24
import java.util.List;
23
import java.util.List;
25
import java.util.Map;
24
import java.util.Map;
26
import java.util.Set;
25
import java.util.Set;
Lines 73-81 Link Here
73
	protected static final String PROJECT_NAME = "emftxtests"; //$NON-NLS-1$
72
	protected static final String PROJECT_NAME = "emftxtests"; //$NON-NLS-1$
74
	protected static final String RESOURCE_NAME = "/" + PROJECT_NAME + "/testres.extlibrary";  //$NON-NLS-1$//$NON-NLS-2$
73
	protected static final String RESOURCE_NAME = "/" + PROJECT_NAME + "/testres.extlibrary";  //$NON-NLS-1$//$NON-NLS-2$
75
74
76
	private final List transactionStack = new java.util.ArrayList();
75
	private final List<InternalTransaction> transactionStack =
76
		new java.util.ArrayList<InternalTransaction>();
77
    
77
    
78
    private List tearDownActions;
78
    private List<Runnable> tearDownActions;
79
	
79
	
80
	public AbstractTest() {
80
	public AbstractTest() {
81
		super();
81
		super();
Lines 89-94 Link Here
89
	// Test configuration methods
89
	// Test configuration methods
90
	//
90
	//
91
	
91
	
92
	@Override
92
	protected final void setUp()
93
	protected final void setUp()
93
		throws Exception {
94
		throws Exception {
94
		
95
		
Lines 115-121 Link Here
115
				URI.createURI(EmfTransactionTestsBundle.getEntry(
116
				URI.createURI(EmfTransactionTestsBundle.getEntry(
116
					"/test_models/test_model.extlibrary").toString()), //$NON-NLS-1$
117
					"/test_models/test_model.extlibrary").toString()), //$NON-NLS-1$
117
					true);
118
					true);
118
			originalRes.setURI(URI.createPlatformResourceURI(RESOURCE_NAME));
119
			originalRes.setURI(URI.createPlatformResourceURI(RESOURCE_NAME, true));
119
			originalRes.save(Collections.EMPTY_MAP);
120
			originalRes.save(Collections.EMPTY_MAP);
120
			testResource = originalRes;
121
			testResource = originalRes;
121
			root = (Library) find("root"); //$NON-NLS-1$
122
			root = (Library) find("root"); //$NON-NLS-1$
Lines 146-157 Link Here
146
     */
147
     */
147
    protected final void addTearDownAction(Runnable action) {
148
    protected final void addTearDownAction(Runnable action) {
148
        if (tearDownActions == null) {
149
        if (tearDownActions == null) {
149
            tearDownActions = new java.util.ArrayList();
150
            tearDownActions = new java.util.ArrayList<Runnable>();
150
        }
151
        }
151
        
152
        
152
        tearDownActions.add(action);
153
        tearDownActions.add(action);
153
    }
154
    }
154
    
155
    
156
	@Override
155
	protected final void tearDown()
157
	protected final void tearDown()
156
		throws Exception {
158
		throws Exception {
157
		
159
		
Lines 165-173 Link Here
165
    
167
    
166
    private void processTearDownActions() {
168
    private void processTearDownActions() {
167
        if (tearDownActions != null) {
169
        if (tearDownActions != null) {
168
            for (Iterator iter = tearDownActions.iterator(); iter.hasNext();) {
170
            for (Runnable action : tearDownActions) {
169
                try {
171
                try {
170
                    Runnable action = (Runnable) iter.next();
171
                    action.run();
172
                    action.run();
172
                } catch (Exception e) {
173
                } catch (Exception e) {
173
                    System.err.println("Exception in tear-down action:"); //$NON-NLS-1$
174
                    System.err.println("Exception in tear-down action:"); //$NON-NLS-1$
Lines 231-237 Link Here
231
			file.create(input, true, null);
232
			file.create(input, true, null);
232
			
233
			
233
			result = domain.createResource(
234
			result = domain.createResource(
234
				URI.createPlatformResourceURI(file.getFullPath().toString()).toString());
235
				URI.createPlatformResourceURI(file.getFullPath().toString(), true).toString());
235
		} catch (Exception e) {
236
		} catch (Exception e) {
236
			e.printStackTrace();
237
			e.printStackTrace();
237
			fail("Exception creating test resource: " + e.getLocalizedMessage()); //$NON-NLS-1$
238
			fail("Exception creating test resource: " + e.getLocalizedMessage()); //$NON-NLS-1$
Lines 341-349 Link Here
341
			String name = names[i];
342
			String name = names[i];
342
			result = null;
343
			result = null;
343
			
344
			
344
			for (Iterator iter = getContents(current).iterator(); iter.hasNext();) {
345
			for (EObject child : getContents(current)) {
345
				EObject child = (EObject) iter.next();
346
				
347
				if (name.equals(getName(child))) {
346
				if (name.equals(getName(child))) {
348
					result = child;
347
					result = child;
349
					break;
348
					break;
Lines 363-369 Link Here
363
	 * @return its name
362
	 * @return its name
364
	 */
363
	 */
365
	protected String getName(EObject object) {
364
	protected String getName(EObject object) {
366
		return (String) GetName.INSTANCE.doSwitch(object);
365
		return GetName.INSTANCE.doSwitch(object);
367
	}
366
	}
368
	
367
	
369
	/**
368
	/**
Lines 372-384 Link Here
372
	 * @param object an object, which may be a resource or an element
371
	 * @param object an object, which may be a resource or an element
373
	 * @return its immediate contents (children)
372
	 * @return its immediate contents (children)
374
	 */
373
	 */
375
	private List getContents(Object object) {
374
	private List<EObject> getContents(Object object) {
376
		if (object instanceof EObject) {
375
		if (object instanceof EObject) {
377
			return ((EObject) object).eContents();
376
			return ((EObject) object).eContents();
378
		} else if (object instanceof Resource) {
377
		} else if (object instanceof Resource) {
379
			return ((Resource) object).getContents();
378
			return ((Resource) object).getContents();
380
		} else {
379
		} else {
381
			return Collections.EMPTY_LIST;
380
			return Collections.emptyList();
382
		}
381
		}
383
	}
382
	}
384
	
383
	
Lines 397-403 Link Here
397
	 *
396
	 *
398
	 * @author Christian W. Damus (cdamus)
397
	 * @author Christian W. Damus (cdamus)
399
	 */
398
	 */
400
	private static final class GetName extends EXTLibrarySwitch {
399
	private static final class GetName extends EXTLibrarySwitch<String> {
401
		static final GetName INSTANCE = new GetName();
400
		static final GetName INSTANCE = new GetName();
402
		
401
		
403
		private GetName() {
402
		private GetName() {
Lines 408-430 Link Here
408
			return object.getTitle();
407
			return object.getTitle();
409
		}
408
		}
410
409
411
		public Object caseBook(Book object) {
410
		@Override
411
		public String caseBook(Book object) {
412
			return object.getTitle();
412
			return object.getTitle();
413
		}
413
		}
414
414
415
		public Object caseLibrary(Library object) {
415
		@Override
416
		public String caseLibrary(Library object) {
416
			return object.getName();
417
			return object.getName();
417
		}
418
		}
418
419
419
		public Object casePeriodical(Periodical object) {
420
		@Override
421
		public String casePeriodical(Periodical object) {
420
			return object.getTitle();
422
			return object.getTitle();
421
		}
423
		}
422
		
424
		
423
		public Object caseWriter(Writer object) {
425
		@Override
426
		public String caseWriter(Writer object) {
424
			return object.getName();
427
			return object.getName();
425
		}
428
		}
426
429
427
		public Object casePerson(Person object) {
430
		@Override
431
		public String casePerson(Person object) {
428
			if (object.getFirstName() == null) {
432
			if (object.getFirstName() == null) {
429
				if (object.getLastName() == null) {
433
				if (object.getLastName() == null) {
430
					return ""; //$NON-NLS-1$
434
					return ""; //$NON-NLS-1$
Lines 443-449 Link Here
443
			}
447
			}
444
		}
448
		}
445
449
446
		public Object defaultCase(EObject object) {
450
		@Override
451
		public String defaultCase(EObject object) {
447
			return ""; //$NON-NLS-1$
452
			return ""; //$NON-NLS-1$
448
		}
453
		}
449
	}
454
	}
Lines 483-489 Link Here
483
	 * 
488
	 * 
484
	 * @param options the options
489
	 * @param options the options
485
	 */
490
	 */
486
	protected void startWriting(Map options) {
491
	protected void startWriting(Map<?, ?> options) {
487
		try {
492
		try {
488
			transactionStack.add(
493
			transactionStack.add(
489
					((InternalTransactionalEditingDomain) domain).startTransaction(false, options));
494
					((InternalTransactionalEditingDomain) domain).startTransaction(false, options));
Lines 518-524 Link Here
518
	 * 
523
	 * 
519
	 * @param options the options
524
	 * @param options the options
520
	 */
525
	 */
521
	protected void startReading(Map options) {
526
	protected void startReading(Map<?, ?> options) {
522
		try {
527
		try {
523
			transactionStack.add(
528
			transactionStack.add(
524
					((InternalTransactionalEditingDomain) domain).startTransaction(true, options));
529
					((InternalTransactionalEditingDomain) domain).startTransaction(true, options));
Lines 534-540 Link Here
534
		Transaction result = null;
539
		Transaction result = null;
535
		
540
		
536
		try {
541
		try {
537
			result = (Transaction) transactionStack.remove(transactionStack.size() - 1);
542
			result = transactionStack.remove(transactionStack.size() - 1);
538
			result.commit();
543
			result.commit();
539
		} catch (Exception e) {
544
		} catch (Exception e) {
540
			fail(e);
545
			fail(e);
Lines 550-556 Link Here
550
		Transaction result = null;
555
		Transaction result = null;
551
		
556
		
552
		try {
557
		try {
553
			result = (Transaction) transactionStack.remove(transactionStack.size() - 1);
558
			result = transactionStack.remove(transactionStack.size() - 1);
554
			result.rollback();
559
			result.rollback();
555
		} catch (Exception e) {
560
		} catch (Exception e) {
556
			fail(e);
561
			fail(e);
Lines 577-584 Link Here
577
	 * 
582
	 * 
578
	 * @return the map
583
	 * @return the map
579
	 */
584
	 */
580
	protected Map makeOptions(String option) {
585
	protected Map<Object, Object> makeOptions(String option) {
581
		return Collections.singletonMap(option, Boolean.TRUE);
586
		return Collections.<Object, Object>singletonMap(option, true);
582
	}
587
	}
583
	
588
	
584
	/**
589
	/**
Lines 590-610 Link Here
590
	 * 
595
	 * 
591
	 * @return the matching statuses, or an empty collection if none found
596
	 * @return the matching statuses, or an empty collection if none found
592
	 */
597
	 */
593
	protected Collection findValidationStatuses(IStatus status, int severity) {
598
	protected Collection<IStatus> findValidationStatuses(IStatus status, int severity) {
594
		Set result;
599
		Set<IStatus> result;
595
		
600
		
596
		if (status.isMultiStatus()) {
601
		if (status.isMultiStatus()) {
597
			result = new java.util.HashSet();
602
			result = new java.util.HashSet<IStatus>();
598
			IStatus[] children = status.getChildren();
603
			IStatus[] children = status.getChildren();
599
			
604
			
600
			for (int i = 0; i < children.length; i++) {
605
			for (IStatus element : children) {
601
				result.addAll(findValidationStatuses(children[i], severity));
606
				result.addAll(findValidationStatuses(element, severity));
602
			}
607
			}
603
		} else if ((status instanceof IConstraintStatus)
608
		} else if ((status instanceof IConstraintStatus)
604
				&& (status.getSeverity() == severity)) {
609
				&& (status.matches(severity))) {
605
			result = Collections.singleton(status);
610
			result = Collections.singleton(status);
606
		} else {
611
		} else {
607
			result = Collections.EMPTY_SET;
612
			result = Collections.emptySet();
608
		}
613
		}
609
		
614
		
610
		return result;
615
		return result;
(-)src/org/eclipse/emf/transaction/tests/ValidationRollbackTest.java (-11 / +24 lines)
Lines 331-337 Link Here
331
	 */
331
	 */
332
	public void test_rollbackNestingTransactionOnException_135673() {
332
	public void test_rollbackNestingTransactionOnException_135673() {
333
		Command command = new RecordingCommand(domain, "") { //$NON-NLS-1$
333
		Command command = new RecordingCommand(domain, "") { //$NON-NLS-1$
334
			@Override
334
			public boolean canUndo() { return true; }
335
			public boolean canUndo() { return true; }
336
			@Override
335
			protected void doExecute() {
337
			protected void doExecute() {
336
				// start some nested transactions
338
				// start some nested transactions
337
				try {
339
				try {
Lines 361-367 Link Here
361
        final Error error = new Error();
363
        final Error error = new Error();
362
        
364
        
363
        ResourceSetListener testListener = new DemultiplexingListener() {
365
        ResourceSetListener testListener = new DemultiplexingListener() {
364
            protected void handleNotification(TransactionalEditingDomain domain, Notification notification) {
366
            @Override
367
			protected void handleNotification(TransactionalEditingDomain domain, Notification notification) {
365
            	throw error;
368
            	throw error;
366
            }};
369
            }};
367
        
370
        
Lines 370-376 Link Here
370
            
373
            
371
            try {
374
            try {
372
                domain.getCommandStack().execute(new RecordingCommand(domain) {
375
                domain.getCommandStack().execute(new RecordingCommand(domain) {
373
                    protected void doExecute() {
376
                    @Override
377
					protected void doExecute() {
374
                        root.getWriters().clear();
378
                        root.getWriters().clear();
375
                        root.getStock().clear();
379
                        root.getStock().clear();
376
                        root.getBranches().clear();
380
                        root.getBranches().clear();
Lines 429-437 Link Here
429
        final RuntimeException error = new RuntimeException();
433
        final RuntimeException error = new RuntimeException();
430
        
434
        
431
        ResourceSetListener testListener = new TriggerListener() {
435
        ResourceSetListener testListener = new TriggerListener() {
432
        	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
436
        	@Override
437
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
433
        		return new RecordingCommand(domain, "Error") { //$NON-NLS-1$
438
        		return new RecordingCommand(domain, "Error") { //$NON-NLS-1$
434
        			protected void doExecute() {
439
        			@Override
440
					protected void doExecute() {
435
        				throw error;
441
        				throw error;
436
        			}};
442
        			}};
437
        	}};
443
        	}};
Lines 443-449 Link Here
443
            domain.addResourceSetListener(testListener);
449
            domain.addResourceSetListener(testListener);
444
            
450
            
445
            domain.getCommandStack().execute(new RecordingCommand(domain) {
451
            domain.getCommandStack().execute(new RecordingCommand(domain) {
446
                protected void doExecute() {
452
                @Override
453
				protected void doExecute() {
447
                    root.getWriters().clear();
454
                    root.getWriters().clear();
448
                    root.getStock().clear();
455
                    root.getStock().clear();
449
                    root.getBranches().clear();
456
                    root.getBranches().clear();
Lines 471-479 Link Here
471
        final RuntimeException error = new OperationCanceledException();
478
        final RuntimeException error = new OperationCanceledException();
472
        
479
        
473
        ResourceSetListener testListener = new TriggerListener() {
480
        ResourceSetListener testListener = new TriggerListener() {
474
        	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
481
        	@Override
482
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
475
        		return new RecordingCommand(domain, "Error") { //$NON-NLS-1$
483
        		return new RecordingCommand(domain, "Error") { //$NON-NLS-1$
476
        			protected void doExecute() {
484
        			@Override
485
					protected void doExecute() {
477
        				throw error;
486
        				throw error;
478
        			}};
487
        			}};
479
        	}};
488
        	}};
Lines 485-491 Link Here
485
            domain.addResourceSetListener(testListener);
494
            domain.addResourceSetListener(testListener);
486
            
495
            
487
            domain.getCommandStack().execute(new RecordingCommand(domain) {
496
            domain.getCommandStack().execute(new RecordingCommand(domain) {
488
                protected void doExecute() {
497
                @Override
498
				protected void doExecute() {
489
                    root.getWriters().clear();
499
                    root.getWriters().clear();
490
                    root.getStock().clear();
500
                    root.getStock().clear();
491
                    root.getBranches().clear();
501
                    root.getBranches().clear();
Lines 549-555 Link Here
549
        final Book book = (Book) find("root/Root Book"); //$NON-NLS-1$
559
        final Book book = (Book) find("root/Root Book"); //$NON-NLS-1$
550
        assertNotNull(book);
560
        assertNotNull(book);
551
        Command command = new RecordingCommand(domain) {
561
        Command command = new RecordingCommand(domain) {
552
            protected void doExecute() {
562
            @Override
563
			protected void doExecute() {
553
                book.setTitle("New Title"); //$NON-NLS-1$
564
                book.setTitle("New Title"); //$NON-NLS-1$
554
                throw new NullPointerException();
565
                throw new NullPointerException();
555
            }};
566
            }};
Lines 610-616 Link Here
610
            
621
            
611
            xa.rollback();
622
            xa.rollback();
612
            
623
            
613
            List notifications = l.postcommitNotifications;
624
            List<Notification> notifications = l.postcommitNotifications;
614
            
625
            
615
            // check that rollback worked
626
            // check that rollback worked
616
            startReading();
627
            startReading();
Lines 681-687 Link Here
681
            
692
            
682
            xa.rollback();
693
            xa.rollback();
683
            
694
            
684
            List notifications = l.postcommitNotifications;
695
            List<Notification> notifications = l.postcommitNotifications;
685
            
696
            
686
            // check that rollback worked
697
            // check that rollback worked
687
            startReading();
698
            startReading();
Lines 703-708 Link Here
703
	// Fixture methods
714
	// Fixture methods
704
	//
715
	//
705
	
716
	
717
	@Override
706
	protected void doSetUp()
718
	protected void doSetUp()
707
		throws Exception {
719
		throws Exception {
708
		
720
		
Lines 712-717 Link Here
712
		validationEnabled = true;
724
		validationEnabled = true;
713
	}
725
	}
714
	
726
	
727
	@Override
715
	protected void doTearDown()
728
	protected void doTearDown()
716
		throws Exception {
729
		throws Exception {
717
		
730
		
(-)src/org/eclipse/emf/transaction/tests/ValidateEditTest.java (-7 / +13 lines)
Lines 27-32 Link Here
27
import org.eclipse.core.runtime.IStatus;
27
import org.eclipse.core.runtime.IStatus;
28
import org.eclipse.core.runtime.Status;
28
import org.eclipse.core.runtime.Status;
29
import org.eclipse.emf.common.command.Command;
29
import org.eclipse.emf.common.command.Command;
30
import org.eclipse.emf.ecore.resource.Resource;
30
import org.eclipse.emf.examples.extlibrary.Book;
31
import org.eclipse.emf.examples.extlibrary.Book;
31
import org.eclipse.emf.transaction.RollbackException;
32
import org.eclipse.emf.transaction.RollbackException;
32
import org.eclipse.emf.transaction.Transaction;
33
import org.eclipse.emf.transaction.Transaction;
Lines 47-54 Link Here
47
    
48
    
48
    private Book book;
49
    private Book book;
49
    
50
    
50
    private Command setTitle = new TestCommand() {
51
    private final Command setTitle = new TestCommand() {
51
        public boolean canExecute() {
52
        @Override
53
		public boolean canExecute() {
52
            // command isn't executable if owner's resource is read-only
54
            // command isn't executable if owner's resource is read-only
53
            return true; 
55
            return true; 
54
        }
56
        }
Lines 61-68 Link Here
61
            }
63
            }
62
        }};
64
        }};
63
    
65
    
64
    private Command clearTitle = new TestCommand() {
66
    private final Command clearTitle = new TestCommand() {
65
        public boolean canExecute() {
67
        @Override
68
		public boolean canExecute() {
66
            // command isn't executable if owner's resource is read-only
69
            // command isn't executable if owner's resource is read-only
67
            return true; 
70
            return true; 
68
        }
71
        }
Lines 126-133 Link Here
126
        final boolean[] token = new boolean[1];
129
        final boolean[] token = new boolean[1];
127
        
130
        
128
        setValidateEdit(new ValidateEditSupport.Default() {
131
        setValidateEdit(new ValidateEditSupport.Default() {
129
            protected IStatus doValidateEdit(Transaction transaction,
132
            @Override
130
                    Collection resources, Object context) {
133
			protected IStatus doValidateEdit(Transaction transaction,
134
                    Collection<? extends Resource> resources, Object context) {
131
                token[0] = true;
135
                token[0] = true;
132
                return Status.CANCEL_STATUS;
136
                return Status.CANCEL_STATUS;
133
            }});
137
            }});
Lines 190-195 Link Here
190
	// Fixture methods
194
	// Fixture methods
191
	//
195
	//
192
	
196
	
197
	@Override
193
	protected void doSetUp()
198
	protected void doSetUp()
194
		throws Exception {
199
		throws Exception {
195
		
200
		
Lines 209-214 Link Here
209
        assertNotNull(book);
214
        assertNotNull(book);
210
	}
215
	}
211
	
216
	
217
	@Override
212
	protected void doTearDown()
218
	protected void doTearDown()
213
		throws Exception {
219
		throws Exception {
214
		
220
		
Lines 232-238 Link Here
232
	}
238
	}
233
	
239
	
234
	void setValidateEdit(Object optionValue) {
240
	void setValidateEdit(Object optionValue) {
235
        TransactionalEditingDomain.DefaultOptions defaults = (TransactionalEditingDomain.DefaultOptions) TransactionUtil
241
        TransactionalEditingDomain.DefaultOptions defaults = TransactionUtil
236
            .getAdapter(domain, TransactionalEditingDomain.DefaultOptions.class);
242
            .getAdapter(domain, TransactionalEditingDomain.DefaultOptions.class);
237
        
243
        
238
        defaults.setDefaultTransactionOptions(Collections.singletonMap(
244
        defaults.setDefaultTransactionOptions(Collections.singletonMap(
(-)src/org/eclipse/emf/transaction/tests/ResourceSetListenersTest.java (-31 / +52 lines)
Lines 85-95 Link Here
85
			assertFalse(listener.postcommit.getTransaction().isActive());
85
			assertFalse(listener.postcommit.getTransaction().isActive());
86
			assertSame(domain, listener.postcommit.getEditingDomain());
86
			assertSame(domain, listener.postcommit.getEditingDomain());
87
			
87
			
88
			List notifications = listener.postcommitNotifications;
88
			List<Notification> notifications = listener.postcommitNotifications;
89
			assertNotNull(notifications);
89
			assertNotNull(notifications);
90
			assertEquals(1, notifications.size());
90
			assertEquals(1, notifications.size());
91
			
91
			
92
			Notification notification = (Notification) notifications.get(0);
92
			Notification notification = notifications.get(0);
93
			assertSame(book, notification.getNotifier());
93
			assertSame(book, notification.getNotifier());
94
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
94
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
95
			assertSame(newTitle, notification.getNewValue());
95
			assertSame(newTitle, notification.getNewValue());
Lines 140-150 Link Here
140
			assertFalse(listener.postcommit.getTransaction().isActive());
140
			assertFalse(listener.postcommit.getTransaction().isActive());
141
			assertSame(domain, listener.postcommit.getEditingDomain());
141
			assertSame(domain, listener.postcommit.getEditingDomain());
142
			
142
			
143
			List notifications = listener.postcommitNotifications;
143
			List<Notification> notifications = listener.postcommitNotifications;
144
			assertNotNull(notifications);
144
			assertNotNull(notifications);
145
			assertEquals(1, notifications.size());
145
			assertEquals(1, notifications.size());
146
			
146
			
147
			Notification notification = (Notification) notifications.get(0);
147
			Notification notification = notifications.get(0);
148
			assertSame(book, notification.getNotifier());
148
			assertSame(book, notification.getNotifier());
149
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
149
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
150
			assertSame(newTitle, notification.getNewValue());
150
			assertSame(newTitle, notification.getNewValue());
Lines 196-216 Link Here
196
			assertFalse(listener.postcommit.getTransaction().isActive());
196
			assertFalse(listener.postcommit.getTransaction().isActive());
197
			assertSame(domain, listener.postcommit.getEditingDomain());
197
			assertSame(domain, listener.postcommit.getEditingDomain());
198
			
198
			
199
			List notifications = listener.postcommitNotifications;
199
			List<Notification> notifications = listener.postcommitNotifications;
200
			assertNotNull(notifications);
200
			assertNotNull(notifications);
201
			assertEquals(3, notifications.size());
201
			assertEquals(3, notifications.size());
202
			
202
			
203
			Notification notification = (Notification) notifications.get(0);
203
			Notification notification = notifications.get(0);
204
			assertSame(book, notification.getNotifier());
204
			assertSame(book, notification.getNotifier());
205
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Category(), notification.getFeature());
205
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Category(), notification.getFeature());
206
			assertSame(BookCategory.BIOGRAPHY_LITERAL, notification.getNewValue());
206
			assertSame(BookCategory.BIOGRAPHY_LITERAL, notification.getNewValue());
207
			
207
			
208
			notification = (Notification) notifications.get(1);
208
			notification = notifications.get(1);
209
			assertSame(book, notification.getNotifier());
209
			assertSame(book, notification.getNotifier());
210
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
210
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
211
			assertSame(newTitle, notification.getNewValue());
211
			assertSame(newTitle, notification.getNewValue());
212
			
212
			
213
			notification = (Notification) notifications.get(2);
213
			notification = notifications.get(2);
214
			assertSame(book, notification.getNotifier());
214
			assertSame(book, notification.getNotifier());
215
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Pages(), notification.getFeature());
215
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Pages(), notification.getFeature());
216
			assertEquals(new Integer(500), notification.getNewValue());
216
			assertEquals(new Integer(500), notification.getNewValue());
Lines 231-236 Link Here
231
		commit();
231
		commit();
232
		
232
		
233
		TestListener testListener = new TestListener() {
233
		TestListener testListener = new TestListener() {
234
			@Override
234
			public void resourceSetChanged(ResourceSetChangeEvent event) {
235
			public void resourceSetChanged(ResourceSetChangeEvent event) {
235
				try {
236
				try {
236
					// can execute read operations
237
					// can execute read operations
Lines 308-318 Link Here
308
			assertFalse(listener.precommit.getTransaction().isActive());
309
			assertFalse(listener.precommit.getTransaction().isActive());
309
			assertSame(domain, listener.precommit.getEditingDomain());
310
			assertSame(domain, listener.precommit.getEditingDomain());
310
			
311
			
311
			List notifications = listener.precommitNotifications;
312
			List<Notification> notifications = listener.precommitNotifications;
312
			assertNotNull(notifications);
313
			assertNotNull(notifications);
313
			assertEquals(1, notifications.size());
314
			assertEquals(1, notifications.size());
314
			
315
			
315
			Notification notification = (Notification) notifications.get(0);
316
			Notification notification = notifications.get(0);
316
			assertSame(book, notification.getNotifier());
317
			assertSame(book, notification.getNotifier());
317
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
318
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
318
			assertSame(newTitle, notification.getNewValue());
319
			assertSame(newTitle, notification.getNewValue());
Lines 397-407 Link Here
397
						assertFalse(listener.precommit.getTransaction().isActive());
398
						assertFalse(listener.precommit.getTransaction().isActive());
398
						assertSame(domain, listener.precommit.getEditingDomain());
399
						assertSame(domain, listener.precommit.getEditingDomain());
399
						
400
						
400
						List notifications = listener.precommitNotifications;
401
						List<Notification> notifications = listener.precommitNotifications;
401
						assertNotNull(notifications);
402
						assertNotNull(notifications);
402
						assertEquals(1, notifications.size());
403
						assertEquals(1, notifications.size());
403
						
404
						
404
						Notification notification = (Notification) notifications.get(0);
405
						Notification notification = notifications.get(0);
405
						assertSame(book, notification.getNotifier());
406
						assertSame(book, notification.getNotifier());
406
						assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
407
						assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
407
						assertSame(newTitle, notification.getNewValue());
408
						assertSame(newTitle, notification.getNewValue());
Lines 422-432 Link Here
422
			assertFalse(listener.precommit.getTransaction().isActive());
423
			assertFalse(listener.precommit.getTransaction().isActive());
423
			assertSame(domain, listener.precommit.getEditingDomain());
424
			assertSame(domain, listener.precommit.getEditingDomain());
424
			
425
			
425
			List notifications = listener.precommitNotifications;
426
			List<Notification> notifications = listener.precommitNotifications;
426
			assertNotNull(notifications);
427
			assertNotNull(notifications);
427
			assertEquals(1, notifications.size());
428
			assertEquals(1, notifications.size());
428
			
429
			
429
			Notification notification = (Notification) notifications.get(0);
430
			Notification notification = notifications.get(0);
430
			assertSame(book, notification.getNotifier());
431
			assertSame(book, notification.getNotifier());
431
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Category(), notification.getFeature());
432
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Category(), notification.getFeature());
432
			assertSame(BookCategory.BIOGRAPHY_LITERAL, notification.getNewValue());
433
			assertSame(BookCategory.BIOGRAPHY_LITERAL, notification.getNewValue());
Lines 447-452 Link Here
447
		commit();
448
		commit();
448
		
449
		
449
		TestListener testListener = new TestListener() {
450
		TestListener testListener = new TestListener() {
451
			@Override
450
			public Command transactionAboutToCommit(ResourceSetChangeEvent event) {
452
			public Command transactionAboutToCommit(ResourceSetChangeEvent event) {
451
				try {
453
				try {
452
					// can execute read operations
454
					// can execute read operations
Lines 515-520 Link Here
515
		commit();
517
		commit();
516
		
518
		
517
		TestListener testListener = new TestListener() {
519
		TestListener testListener = new TestListener() {
520
			@Override
518
			public Command transactionAboutToCommit(ResourceSetChangeEvent event) {
521
			public Command transactionAboutToCommit(ResourceSetChangeEvent event) {
519
				try {
522
				try {
520
					// cannot commit the transaction while it is committing
523
					// cannot commit the transaction while it is committing
Lines 581-587 Link Here
581
		
584
		
582
		assertEquals("New Library", newLibrary.getName()); //$NON-NLS-1$
585
		assertEquals("New Library", newLibrary.getName()); //$NON-NLS-1$
583
		assertEquals(1, newLibrary.getBooks().size());
586
		assertEquals(1, newLibrary.getBooks().size());
584
		assertEquals("New Book", ((Book) newLibrary.getBooks().get(0)).getTitle()); //$NON-NLS-1$
587
		assertEquals("New Book", newLibrary.getBooks().get(0).getTitle()); //$NON-NLS-1$
585
		
588
		
586
		commit();
589
		commit();
587
	}
590
	}
Lines 611-617 Link Here
611
		
614
		
612
		// the book is created by the first trigger
615
		// the book is created by the first trigger
613
		assertEquals(1, newLibrary.getBooks().size());
616
		assertEquals(1, newLibrary.getBooks().size());
614
		Book book = (Book) newLibrary.getBooks().get(0);
617
		Book book = newLibrary.getBooks().get(0);
615
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
618
		assertEquals("New Book", book.getTitle()); //$NON-NLS-1$
616
		
619
		
617
		// the publication date is created by the cascaded trigger
620
		// the publication date is created by the cascaded trigger
Lines 665-677 Link Here
665
			
668
			
666
			assertNotNull(listener.postcommit);
669
			assertNotNull(listener.postcommit);
667
			
670
			
668
			List notifications = listener.postcommitNotifications;
671
			List<Notification> notifications = listener.postcommitNotifications;
669
			assertNotNull(notifications);
672
			assertNotNull(notifications);
670
			
673
			
671
			// unbatched notifications are always singletons
674
			// unbatched notifications are always singletons
672
			assertEquals(1, notifications.size());
675
			assertEquals(1, notifications.size());
673
			
676
			
674
			Notification notification = (Notification) notifications.get(0);
677
			Notification notification = notifications.get(0);
675
			assertSame(domain.getResourceSet(), notification.getNotifier());
678
			assertSame(domain.getResourceSet(), notification.getNotifier());
676
			assertEquals(Notification.ADD, notification.getEventType());
679
			assertEquals(Notification.ADD, notification.getEventType());
677
			assertEquals(ResourceSet.RESOURCE_SET__RESOURCES, notification.getFeatureID(null));
680
			assertEquals(ResourceSet.RESOURCE_SET__RESOURCES, notification.getFeatureID(null));
Lines 688-696 Link Here
688
		try {
691
		try {
689
			class Listener extends ResourceSetListenerImpl {
692
			class Listener extends ResourceSetListenerImpl {
690
				ResourceSetChangeEvent lastEvent = null;
693
				ResourceSetChangeEvent lastEvent = null;
691
				List lastNotifications = null;
694
				List<Notification> lastNotifications = null;
692
				int count = 0;
695
				int count = 0;
693
				
696
				
697
				@Override
694
				public void resourceSetChanged(ResourceSetChangeEvent event) {
698
				public void resourceSetChanged(ResourceSetChangeEvent event) {
695
					count++;
699
					count++;
696
					
700
					
Lines 730-735 Link Here
730
		final Resource[] newRes = new Resource[1];
734
		final Resource[] newRes = new Resource[1];
731
		
735
		
732
		TestListener testListener = new TestListener() {
736
		TestListener testListener = new TestListener() {
737
			@Override
733
			public void resourceSetChanged(ResourceSetChangeEvent event) {
738
			public void resourceSetChanged(ResourceSetChangeEvent event) {
734
				// make sure that I only do this on the first time that I
739
				// make sure that I only do this on the first time that I
735
				//    am invoked (from the new library notification)
740
				//    am invoked (from the new library notification)
Lines 760-772 Link Here
760
			//     caused more notifications to the listeners)
765
			//     caused more notifications to the listeners)
761
			assertNotNull(listener.postcommit);
766
			assertNotNull(listener.postcommit);
762
			
767
			
763
			List notifications = listener.postcommitNotifications;
768
			List<Notification> notifications = listener.postcommitNotifications;
764
			assertNotNull(notifications);
769
			assertNotNull(notifications);
765
			
770
			
766
			// unbatched notifications are always singletons
771
			// unbatched notifications are always singletons
767
			assertEquals(1, notifications.size());
772
			assertEquals(1, notifications.size());
768
			
773
			
769
			Notification notification = (Notification) notifications.get(0);
774
			Notification notification = notifications.get(0);
770
			assertSame(domain.getResourceSet(), notification.getNotifier());
775
			assertSame(domain.getResourceSet(), notification.getNotifier());
771
			assertEquals(Notification.ADD, notification.getEventType());
776
			assertEquals(Notification.ADD, notification.getEventType());
772
			assertEquals(ResourceSet.RESOURCE_SET__RESOURCES, notification.getFeatureID(null));
777
			assertEquals(ResourceSet.RESOURCE_SET__RESOURCES, notification.getFeatureID(null));
Lines 786-791 Link Here
786
			class AggregatedListener extends TestListener {
791
			class AggregatedListener extends TestListener {
787
				int count = 0;
792
				int count = 0;
788
				
793
				
794
				@Override
789
				public Command transactionAboutToCommit(ResourceSetChangeEvent event)
795
				public Command transactionAboutToCommit(ResourceSetChangeEvent event)
790
					throws RollbackException {
796
					throws RollbackException {
791
					
797
					
Lines 794-805 Link Here
794
					return super.transactionAboutToCommit(event);
800
					return super.transactionAboutToCommit(event);
795
				}
801
				}
796
				
802
				
803
				@Override
797
				public void reset() {
804
				public void reset() {
798
					super.reset();
805
					super.reset();
799
					
806
					
800
					count = 0;
807
					count = 0;
801
				}
808
				}
802
				
809
				
810
				@Override
803
				public boolean isAggregatePrecommitListener() {
811
				public boolean isAggregatePrecommitListener() {
804
					return true;
812
					return true;
805
				}
813
				}
Lines 835-851 Link Here
835
			assertNotNull(localListener.precommit.getTransaction());
843
			assertNotNull(localListener.precommit.getTransaction());
836
			assertEquals(1, localListener.count);
844
			assertEquals(1, localListener.count);
837
			
845
			
838
			List notifications = localListener.precommitNotifications;
846
			List<Notification> notifications = localListener.precommitNotifications;
839
			assertNotNull(notifications);
847
			assertNotNull(notifications);
840
			assertEquals(2, notifications.size());
848
			assertEquals(2, notifications.size());
841
			
849
			
842
			// notifications came in the right order
850
			// notifications came in the right order
843
			Notification notification = (Notification) notifications.get(0);
851
			Notification notification = notifications.get(0);
844
			assertSame(book, notification.getNotifier());
852
			assertSame(book, notification.getNotifier());
845
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
853
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
846
			assertSame(newTitle1, notification.getNewValue());
854
			assertSame(newTitle1, notification.getNewValue());
847
			
855
			
848
			notification = (Notification) notifications.get(1);
856
			notification = notifications.get(1);
849
			assertSame(book, notification.getNotifier());
857
			assertSame(book, notification.getNotifier());
850
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
858
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
851
			assertSame(newTitle2, notification.getNewValue());
859
			assertSame(newTitle2, notification.getNewValue());
Lines 866-871 Link Here
866
			class AggregatedListener extends TestListener {
874
			class AggregatedListener extends TestListener {
867
				int count = 0;
875
				int count = 0;
868
				
876
				
877
				@Override
869
				public Command transactionAboutToCommit(ResourceSetChangeEvent event)
878
				public Command transactionAboutToCommit(ResourceSetChangeEvent event)
870
					throws RollbackException {
879
					throws RollbackException {
871
					
880
					
Lines 874-884 Link Here
874
					super.transactionAboutToCommit(event);
883
					super.transactionAboutToCommit(event);
875
					
884
					
876
					if (count < 2) {
885
					if (count < 2) {
877
						List notifications = event.getNotifications();
886
						List<Notification> notifications = event.getNotifications();
878
						assertNotNull(notifications);
887
						assertNotNull(notifications);
879
						assertEquals(1, notifications.size());
888
						assertEquals(1, notifications.size());
880
						
889
						
881
						Notification notification = (Notification) notifications.get(0);
890
						Notification notification = notifications.get(0);
882
						assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
891
						assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
883
						assertSame(newTitle1, notification.getNewValue());
892
						assertSame(newTitle1, notification.getNewValue());
884
						
893
						
Lines 893-904 Link Here
893
					return null;
902
					return null;
894
				}
903
				}
895
				
904
				
905
				@Override
896
				public void reset() {
906
				public void reset() {
897
					super.reset();
907
					super.reset();
898
					
908
					
899
					count = 0;
909
					count = 0;
900
				}
910
				}
901
				
911
				
912
				@Override
902
				public boolean isAggregatePrecommitListener() {
913
				public boolean isAggregatePrecommitListener() {
903
					return true;
914
					return true;
904
				}
915
				}
Lines 924-934 Link Here
924
			assertNotNull(localListener.precommit.getTransaction());
935
			assertNotNull(localListener.precommit.getTransaction());
925
			assertEquals(2, localListener.count);
936
			assertEquals(2, localListener.count);
926
			
937
			
927
			List notifications = localListener.precommitNotifications;
938
			List<Notification> notifications = localListener.precommitNotifications;
928
			assertNotNull(notifications);
939
			assertNotNull(notifications);
929
			assertEquals(1, notifications.size());
940
			assertEquals(1, notifications.size());
930
			
941
			
931
			Notification notification = (Notification) notifications.get(0);
942
			Notification notification = notifications.get(0);
932
			assertSame(book, notification.getNotifier());
943
			assertSame(book, notification.getNotifier());
933
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
944
			assertSame(EXTLibraryPackage.eINSTANCE.getBook_Title(), notification.getFeature());
934
			assertSame(newTitle2, notification.getNewValue());
945
			assertSame(newTitle2, notification.getNewValue());
Lines 946-951 Link Here
946
		class ResourceListener extends DemultiplexingListener {
957
		class ResourceListener extends DemultiplexingListener {
947
			boolean wasCalled;
958
			boolean wasCalled;
948
			
959
			
960
			@Override
949
			protected void handleNotification(TransactionalEditingDomain domain, Notification notification) {
961
			protected void handleNotification(TransactionalEditingDomain domain, Notification notification) {
950
				wasCalled = true;
962
				wasCalled = true;
951
			}
963
			}
Lines 994-999 Link Here
994
				interestingBook = book;
1006
				interestingBook = book;
995
			}
1007
			}
996
			
1008
			
1009
			@Override
997
			protected void handleNotification(TransactionalEditingDomain domain, Notification notification) {
1010
			protected void handleNotification(TransactionalEditingDomain domain, Notification notification) {
998
				Object notifier = notification.getNotifier();
1011
				Object notifier = notification.getNotifier();
999
				
1012
				
Lines 1048-1053 Link Here
1048
				interestingBook = book;
1061
				interestingBook = book;
1049
			}
1062
			}
1050
			
1063
			
1064
			@Override
1051
			protected void handleNotification(TransactionalEditingDomain domain, Notification notification) {
1065
			protected void handleNotification(TransactionalEditingDomain domain, Notification notification) {
1052
				Object notifier = notification.getNotifier();
1066
				Object notifier = notification.getNotifier();
1053
				
1067
				
Lines 1107-1112 Link Here
1107
				interestingBook = book;
1121
				interestingBook = book;
1108
			}
1122
			}
1109
			
1123
			
1124
			@Override
1110
			protected void handleNotification(TransactionalEditingDomain domain, Notification notification) {
1125
			protected void handleNotification(TransactionalEditingDomain domain, Notification notification) {
1111
				Object notifier = notification.getNotifier();
1126
				Object notifier = notification.getNotifier();
1112
				
1127
				
Lines 1163-1168 Link Here
1163
				interestingBook = book;
1178
				interestingBook = book;
1164
			}
1179
			}
1165
			
1180
			
1181
			@Override
1166
			protected void handleNotification(TransactionalEditingDomain domain, Notification notification) {
1182
			protected void handleNotification(TransactionalEditingDomain domain, Notification notification) {
1167
				Object notifier = notification.getNotifier();
1183
				Object notifier = notification.getNotifier();
1168
				
1184
				
Lines 1218-1230 Link Here
1218
    public void test_recordingCommandsAsTriggers_bug157103() {
1234
    public void test_recordingCommandsAsTriggers_bug157103() {
1219
        // one trigger sets default library names
1235
        // one trigger sets default library names
1220
        domain.addResourceSetListener(new LibraryDefaultNameTrigger() {
1236
        domain.addResourceSetListener(new LibraryDefaultNameTrigger() {
1221
            protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
1237
            @Override
1238
			protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
1222
                Command result = null;
1239
                Command result = null;
1223
                
1240
                
1224
                final Library newLibrary = (Library) notification.getNewValue();
1241
                final Library newLibrary = (Library) notification.getNewValue();
1225
                if ((newLibrary.getName() == null) || (newLibrary.getName().length() == 0)) {
1242
                if ((newLibrary.getName() == null) || (newLibrary.getName().length() == 0)) {
1226
                    result = new RecordingCommand(domain) {
1243
                    result = new RecordingCommand(domain) {
1227
                        protected void doExecute() {
1244
                        @Override
1245
						protected void doExecute() {
1228
                            newLibrary.setName("New Library"); //$NON-NLS-1$
1246
                            newLibrary.setName("New Library"); //$NON-NLS-1$
1229
                        }};
1247
                        }};
1230
                }
1248
                }
Lines 1236-1242 Link Here
1236
        
1254
        
1237
        // add a new library.  Our trigger will set a default name
1255
        // add a new library.  Our trigger will set a default name
1238
        domain.getCommandStack().execute(new RecordingCommand(domain) {
1256
        domain.getCommandStack().execute(new RecordingCommand(domain) {
1239
            protected void doExecute() {
1257
            @Override
1258
			protected void doExecute() {
1240
                newLibrary[0] = EXTLibraryFactory.eINSTANCE.createLibrary();
1259
                newLibrary[0] = EXTLibraryFactory.eINSTANCE.createLibrary();
1241
                root.getBranches().add(newLibrary[0]);
1260
                root.getBranches().add(newLibrary[0]);
1242
                
1261
                
Lines 1265-1270 Link Here
1265
	// Fixture methods
1284
	// Fixture methods
1266
	//
1285
	//
1267
	
1286
	
1287
	@Override
1268
	protected void doSetUp()
1288
	protected void doSetUp()
1269
		throws Exception {
1289
		throws Exception {
1270
		
1290
		
Lines 1280-1285 Link Here
1280
		domain.addResourceSetListener(listener);
1300
		domain.addResourceSetListener(listener);
1281
	}
1301
	}
1282
	
1302
	
1303
	@Override
1283
	protected void doTearDown()
1304
	protected void doTearDown()
1284
		throws Exception {
1305
		throws Exception {
1285
		
1306
		
(-)src/org/eclipse/emf/transaction/multithread/tests/ReadThread.java (+1 lines)
Lines 44-49 Link Here
44
	/**
44
	/**
45
	 * @see java.lang.Runnable#run()
45
	 * @see java.lang.Runnable#run()
46
	 */
46
	 */
47
	@Override
47
	public void run() {
48
	public void run() {
48
		try {
49
		try {
49
			if(notifyObject != null) {
50
			if(notifyObject != null) {
(-)src/org/eclipse/emf/transaction/multithread/tests/NestedReadThread.java (+1 lines)
Lines 46-51 Link Here
46
	/**
46
	/**
47
	 * @see java.lang.Runnable#run()
47
	 * @see java.lang.Runnable#run()
48
	 */
48
	 */
49
	@Override
49
	public void run() {
50
	public void run() {
50
		try {
51
		try {
51
			if (notifyObject != null) {
52
			if (notifyObject != null) {
(-)src/org/eclipse/emf/transaction/multithread/tests/WriteThread.java (+1 lines)
Lines 45-50 Link Here
45
	/**
45
	/**
46
	 * @see java.lang.Runnable#run()
46
	 * @see java.lang.Runnable#run()
47
	 */
47
	 */
48
	@Override
48
	public void run() {
49
	public void run() {
49
		if(notifyObject != null) {
50
		if(notifyObject != null) {
50
			synchronized(notifyObject) {
51
			synchronized(notifyObject) {
(-)src/org/eclipse/emf/transaction/multithread/tests/NestedWriteThread.java (+1 lines)
Lines 49-54 Link Here
49
	/** 
49
	/** 
50
	 * @see java.lang.Runnable#run()
50
	 * @see java.lang.Runnable#run()
51
	 */
51
	 */
52
	@Override
52
	public void run() {
53
	public void run() {
53
		if (notifyObject != null) {
54
		if (notifyObject != null) {
54
			synchronized (notifyObject) {
55
			synchronized (notifyObject) {
(-)src/org/eclipse/emf/transaction/multithread/tests/LongRunningReadThread.java (+1 lines)
Lines 38-43 Link Here
38
	/**
38
	/**
39
	 * @see java.lang.Runnable#run()
39
	 * @see java.lang.Runnable#run()
40
	 */
40
	 */
41
	@Override
41
	public void run() {
42
	public void run() {
42
		try {
43
		try {
43
			getDomain().runExclusive(new Runnable() {
44
			getDomain().runExclusive(new Runnable() {
(-)src/org/eclipse/emf/transaction/multithread/tests/NestedReadInWriteThread.java (+1 lines)
Lines 47-52 Link Here
47
	/**
47
	/**
48
	 * @see java.lang.Runnable#run()
48
	 * @see java.lang.Runnable#run()
49
	 */
49
	 */
50
	@Override
50
	public void run() {
51
	public void run() {
51
		if (notifyObject != null) {
52
		if (notifyObject != null) {
52
			synchronized (notifyObject) {
53
			synchronized (notifyObject) {
(-)src/org/eclipse/emf/transaction/multithread/tests/AbstractMultithreadTest.java (-14 / +3 lines)
Lines 16-29 Link Here
16
 */
16
 */
17
package org.eclipse.emf.transaction.multithread.tests;
17
package org.eclipse.emf.transaction.multithread.tests;
18
18
19
import java.util.Arrays;
20
21
import junit.framework.Test;
19
import junit.framework.Test;
22
import junit.framework.TestCase;
20
import junit.framework.TestCase;
23
import junit.framework.TestSuite;
21
import junit.framework.TestSuite;
24
import junit.textui.TestRunner;
25
22
26
import org.eclipse.core.runtime.IPlatformRunnable;
27
import org.eclipse.emf.transaction.TransactionalEditingDomain;
23
import org.eclipse.emf.transaction.TransactionalEditingDomain;
28
import org.eclipse.emf.transaction.tests.AbstractTest;
24
import org.eclipse.emf.transaction.tests.AbstractTest;
29
25
Lines 33-40 Link Here
33
 * @author Christian W. Damus (cdamus)
29
 * @author Christian W. Damus (cdamus)
34
 */
30
 */
35
public class AbstractMultithreadTest
31
public class AbstractMultithreadTest
36
	extends TestCase
32
	extends TestCase {
37
	implements IPlatformRunnable {
38
33
39
	private TransactionalEditingDomain domain = null;
34
	private TransactionalEditingDomain domain = null;
40
	
35
	
Lines 51-64 Link Here
51
46
52
		return suite;
47
		return suite;
53
	}
48
	}
54
55
	public Object run(Object args)
56
		throws Exception {
57
58
		TestRunner.run(suite());
59
		return Arrays
60
			.asList(new String[] {"Please see raw test suite output for details."}); //$NON-NLS-1$
61
	}
62
	
49
	
63
	//
50
	//
64
	// Fixture methods
51
	// Fixture methods
Lines 68-73 Link Here
68
		return domain;
55
		return domain;
69
	}
56
	}
70
	
57
	
58
	@Override
71
	protected void setUp()
59
	protected void setUp()
72
		throws Exception {
60
		throws Exception {
73
		
61
		
Lines 78-83 Link Here
78
		domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain();
66
		domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain();
79
	}
67
	}
80
	
68
	
69
	@Override
81
	protected void tearDown()
70
	protected void tearDown()
82
		throws Exception {
71
		throws Exception {
83
		
72
		
(-).settings/org.eclipse.jdt.ui.prefs (-3 lines)
Removed Link Here
1
#Wed Dec 20 11:58:47 EST 2006
2
eclipse.preferences.version=1
3
internal.default.compliance=user
(-).settings/org.eclipse.jdt.core.prefs (-6 / +10 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:58:47 EST 2006
1
#Sun Nov 11 13:25:48 EST 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6
org.eclipse.jdt.core.compiler.compliance=1.5
7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8
org.eclipse.jdt.core.compiler.debug.localVariable=generate
9
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
11
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
12
org.eclipse.jdt.core.compiler.source=1.5
(-)src/org/eclipse/emf/transaction/util/tests/InternalUtilTests.java (-16 / +2 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005, 2006 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 16-29 Link Here
16
 */
16
 */
17
package org.eclipse.emf.transaction.util.tests;
17
package org.eclipse.emf.transaction.util.tests;
18
18
19
import java.util.Arrays;
20
21
import junit.framework.Test;
19
import junit.framework.Test;
22
import junit.framework.TestCase;
20
import junit.framework.TestCase;
23
import junit.framework.TestSuite;
21
import junit.framework.TestSuite;
24
import junit.textui.TestRunner;
25
26
import org.eclipse.core.runtime.IPlatformRunnable;
27
22
28
/**
23
/**
29
 * Suite of tests for the utility classes in the EMF-TX API implementation.
24
 * Suite of tests for the utility classes in the EMF-TX API implementation.
Lines 31-38 Link Here
31
 * @author Christian W. Damus (cdamus)
26
 * @author Christian W. Damus (cdamus)
32
 */
27
 */
33
public class InternalUtilTests
28
public class InternalUtilTests
34
	extends TestCase
29
	extends TestCase {
35
	implements IPlatformRunnable {
36
30
37
	public InternalUtilTests() {
31
	public InternalUtilTests() {
38
		super(""); //$NON-NLS-1$
32
		super(""); //$NON-NLS-1$
Lines 47-58 Link Here
47
41
48
		return suite;
42
		return suite;
49
	}
43
	}
50
51
	public Object run(Object args)
52
		throws Exception {
53
54
		TestRunner.run(suite());
55
		return Arrays
56
			.asList(new String[] {"Please see raw test suite output for details."}); //$NON-NLS-1$
57
	}
58
}
44
}
(-)src/org/eclipse/emf/transaction/util/tests/LockTest.java (-8 / +9 lines)
Lines 23-29 Link Here
23
import junit.framework.TestSuite;
23
import junit.framework.TestSuite;
24
24
25
import org.eclipse.core.resources.ResourcesPlugin;
25
import org.eclipse.core.resources.ResourcesPlugin;
26
import org.eclipse.core.runtime.Platform;
27
import org.eclipse.core.runtime.jobs.ISchedulingRule;
26
import org.eclipse.core.runtime.jobs.ISchedulingRule;
28
import org.eclipse.core.runtime.jobs.Job;
27
import org.eclipse.core.runtime.jobs.Job;
29
import org.eclipse.emf.transaction.TransactionalEditingDomain;
28
import org.eclipse.emf.transaction.TransactionalEditingDomain;
Lines 456-462 Link Here
456
		try {
455
		try {
457
			lock.acquire(false);
456
			lock.acquire(false);
458
			
457
			
459
			Platform.getJobManager().addJobChangeListener(jl);
458
			Job.getJobManager().addJobChangeListener(jl);
460
			
459
			
461
			synchronized (monitor) {
460
			synchronized (monitor) {
462
				t.start();
461
				t.start();
Lines 488-494 Link Here
488
		} catch (Exception e) {
487
		} catch (Exception e) {
489
			fail(e);
488
			fail(e);
490
		} finally {
489
		} finally {
491
			Platform.getJobManager().removeJobChangeListener(jl);
490
			Job.getJobManager().removeJobChangeListener(jl);
492
		}
491
		}
493
	}
492
	}
494
	
493
	
Lines 519-525 Link Here
519
		try {
518
		try {
520
			lock.acquire(false);
519
			lock.acquire(false);
521
			
520
			
522
			Platform.getJobManager().addJobChangeListener(jl);
521
			Job.getJobManager().addJobChangeListener(jl);
523
			
522
			
524
			synchronized (monitor) {
523
			synchronized (monitor) {
525
				t.start();
524
				t.start();
Lines 547-553 Link Here
547
		} catch (Exception e) {
546
		} catch (Exception e) {
548
			fail(e);
547
			fail(e);
549
		} finally {
548
		} finally {
550
			Platform.getJobManager().removeJobChangeListener(jl);
549
			Job.getJobManager().removeJobChangeListener(jl);
551
		}
550
		}
552
	}
551
	}
553
	
552
	
Lines 621-627 Link Here
621
			}
620
			}
622
			
621
			
623
			// start an implicit job on our fake rule
622
			// start an implicit job on our fake rule
624
			Platform.getJobManager().beginRule(rule, null);
623
			Job.getJobManager().beginRule(rule, null);
625
			
624
			
626
			try {
625
			try {
627
				// now attempt to acquire the lock while the other thread sleeps
626
				// now attempt to acquire the lock while the other thread sleeps
Lines 635-641 Link Here
635
				
634
				
636
				lock.release();
635
				lock.release();
637
			} finally {
636
			} finally {
638
				Platform.getJobManager().endRule(rule);
637
				Job.getJobManager().endRule(rule);
639
			}
638
			}
640
		} catch (Exception e) {
639
		} catch (Exception e) {
641
			fail(e);
640
			fail(e);
Lines 726-731 Link Here
726
	// Fixture methods
725
	// Fixture methods
727
	//
726
	//
728
	
727
	
728
	@Override
729
	protected void setUp()
729
	protected void setUp()
730
		throws Exception {
730
		throws Exception {
731
		
731
		
Lines 735-740 Link Here
735
		monitor = new Object();
735
		monitor = new Object();
736
	}
736
	}
737
	
737
	
738
	@Override
738
	protected void tearDown()
739
	protected void tearDown()
739
		throws Exception {
740
		throws Exception {
740
		
741
		
Lines 767-773 Link Here
767
		Field field = null;
768
		Field field = null;
768
		
769
		
769
		try {
770
		try {
770
			Class clazz = domain.getClass();
771
			Class<?> clazz = domain.getClass();
771
			
772
			
772
			field = clazz.getDeclaredField("transactionLock"); //$NON-NLS-1$
773
			field = clazz.getDeclaredField("transactionLock"); //$NON-NLS-1$
773
			field.setAccessible(true);
774
			field.setAccessible(true);
(-)src/org/eclipse/emf/transaction/util/tests/TransactionUtilTests.java (-4 / +4 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 77-91 Link Here
77
		
77
		
78
		startReading();
78
		startReading();
79
		Transaction tx = commit();
79
		Transaction tx = commit();
80
		assertSame(domain, TransactionUtil.getEditingDomain((Object) tx));
80
		assertSame(domain, TransactionUtil.getEditingDomain(tx));
81
		
81
		
82
		assertSame(domain, TransactionUtil.getEditingDomain((Object) domain));
82
		assertSame(domain, TransactionUtil.getEditingDomain(domain));
83
		
83
		
84
		IEditingDomainProvider edp = new IEditingDomainProvider() {
84
		IEditingDomainProvider edp = new IEditingDomainProvider() {
85
			public EditingDomain getEditingDomain() {
85
			public EditingDomain getEditingDomain() {
86
				return domain;
86
				return domain;
87
			}};
87
			}};
88
			
88
			
89
		assertSame(domain, TransactionUtil.getEditingDomain((Object) edp));
89
		assertSame(domain, TransactionUtil.getEditingDomain(edp));
90
	}
90
	}
91
}
91
}
(-)src/org/eclipse/emf/transaction/util/tests/CompositeChangeDescriptionTest.java (-2 / +6 lines)
Lines 249-254 Link Here
249
	// Fixture methods
249
	// Fixture methods
250
	//
250
	//
251
	
251
	
252
	@Override
252
	protected void doSetUp()
253
	protected void doSetUp()
253
		throws Exception {
254
		throws Exception {
254
		
255
		
Lines 263-270 Link Here
263
		commit();
264
		commit();
264
		
265
		
265
		// brute-force remove the TransactionChangeRecorder
266
		// brute-force remove the TransactionChangeRecorder
266
		for (Iterator iter = testResource.getAllContents(); iter.hasNext();) {
267
		for (Iterator<? extends Notifier> iter = testResource.getAllContents();
267
			((Notifier) iter.next()).eAdapters().clear();  
268
				iter.hasNext();) {
269
			
270
			iter.next().eAdapters().clear();  
268
		}
271
		}
269
		testResource.eAdapters().clear();
272
		testResource.eAdapters().clear();
270
		
273
		
Lines 272-277 Link Here
272
		change = new CompositeChangeDescription();
275
		change = new CompositeChangeDescription();
273
	}
276
	}
274
	
277
	
278
	@Override
275
	protected void doTearDown()
279
	protected void doTearDown()
276
		throws Exception {
280
		throws Exception {
277
		
281
		
(-)src/org/eclipse/emf/transaction/tests/fixtures/ItemDefaultPublicationDateTrigger.java (+1 lines)
Lines 38-43 Link Here
38
									Notification.ADD)));
38
									Notification.ADD)));
39
	}
39
	}
40
	
40
	
41
	@Override
41
	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
42
	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
42
		Command result = null;
43
		Command result = null;
43
		
44
		
(-)src/org/eclipse/emf/transaction/tests/fixtures/LibraryDefaultBookTrigger.java (+1 lines)
Lines 40-45 Link Here
40
									Notification.ADD)));
40
									Notification.ADD)));
41
	}
41
	}
42
	
42
	
43
	@Override
43
	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
44
	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
44
		Command result = null;
45
		Command result = null;
45
		
46
		
(-)src/org/eclipse/emf/transaction/tests/fixtures/TestCommand.java (+2 lines)
Lines 29-38 Link Here
29
public abstract class TestCommand
29
public abstract class TestCommand
30
	extends AbstractCommand {
30
	extends AbstractCommand {
31
31
32
	@Override
32
	protected boolean prepare() {
33
	protected boolean prepare() {
33
		return true;
34
		return true;
34
	}
35
	}
35
	
36
	
37
	@Override
36
	public void undo() {
38
	public void undo() {
37
		// do nothing
39
		// do nothing
38
	}
40
	}
(-)src/org/eclipse/emf/transaction/tests/fixtures/TestValidationEditingDomain.java (-2 / +9 lines)
Lines 17-22 Link Here
17
package org.eclipse.emf.transaction.tests.fixtures;
17
package org.eclipse.emf.transaction.tests.fixtures;
18
18
19
import org.eclipse.emf.common.notify.AdapterFactory;
19
import org.eclipse.emf.common.notify.AdapterFactory;
20
import org.eclipse.emf.common.notify.Notification;
20
import org.eclipse.emf.ecore.EObject;
21
import org.eclipse.emf.ecore.EObject;
21
import org.eclipse.emf.ecore.resource.ResourceSet;
22
import org.eclipse.emf.ecore.resource.ResourceSet;
22
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
23
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
Lines 28-33 Link Here
28
import org.eclipse.emf.validation.model.EvaluationMode;
29
import org.eclipse.emf.validation.model.EvaluationMode;
29
import org.eclipse.emf.validation.service.IConstraintDescriptor;
30
import org.eclipse.emf.validation.service.IConstraintDescriptor;
30
import org.eclipse.emf.validation.service.IConstraintFilter;
31
import org.eclipse.emf.validation.service.IConstraintFilter;
32
import org.eclipse.emf.validation.service.ILiveValidator;
31
import org.eclipse.emf.validation.service.IValidator;
33
import org.eclipse.emf.validation.service.IValidator;
32
import org.eclipse.emf.validation.service.ModelValidationService;
34
import org.eclipse.emf.validation.service.ModelValidationService;
33
35
Lines 49-54 Link Here
49
					
51
					
50
	public static class FactoryImpl extends TransactionalEditingDomainImpl.FactoryImpl {
52
	public static class FactoryImpl extends TransactionalEditingDomainImpl.FactoryImpl {
51
53
54
		@Override
52
		public TransactionalEditingDomain createEditingDomain() {
55
		public TransactionalEditingDomain createEditingDomain() {
53
			TransactionalEditingDomainImpl result = new TestValidationEditingDomain(
56
			TransactionalEditingDomainImpl result = new TestValidationEditingDomain(
54
					new ComposedAdapterFactory(
57
					new ComposedAdapterFactory(
Lines 61-71 Link Here
61
			return result;
64
			return result;
62
		}
65
		}
63
66
67
		@Override
64
		public TransactionalEditingDomain createEditingDomain(ResourceSet rset) {
68
		public TransactionalEditingDomain createEditingDomain(ResourceSet rset) {
65
			// not used by the extension point
69
			// not used by the extension point
66
			return null;
70
			return null;
67
		}
71
		}
68
72
73
		@Override
69
		public TransactionalEditingDomain getEditingDomain(ResourceSet rset) {
74
		public TransactionalEditingDomain getEditingDomain(ResourceSet rset) {
70
			// not used by the extension point
75
			// not used by the extension point
71
			return null;
76
			return null;
Lines 82-91 Link Here
82
		}
87
		}
83
		
88
		
84
		public class TestReadWriteValidatorImpl extends ReadWriteValidatorImpl {
89
		public class TestReadWriteValidatorImpl extends ReadWriteValidatorImpl {
85
			protected IValidator createValidator() {
90
			@Override
91
			protected IValidator<Notification> createValidator() {
86
				if (enableCustomValidator) {
92
				if (enableCustomValidator) {
87
					readWriteValidatorHitCount++;
93
					readWriteValidatorHitCount++;
88
					IValidator validator = ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
94
					ILiveValidator validator = ModelValidationService.getInstance().newValidator(
95
						EvaluationMode.LIVE);
89
					validator.addConstraintFilter(new IConstraintFilter() {
96
					validator.addConstraintFilter(new IConstraintFilter() {
90
						public boolean accept(IConstraintDescriptor constraint,
97
						public boolean accept(IConstraintDescriptor constraint,
91
								EObject target) {
98
								EObject target) {
(-)src/org/eclipse/emf/transaction/tests/fixtures/TestListener.java (-4 / +7 lines)
Lines 20-25 Link Here
20
import java.util.List;
20
import java.util.List;
21
21
22
import org.eclipse.emf.common.command.Command;
22
import org.eclipse.emf.common.command.Command;
23
import org.eclipse.emf.common.notify.Notification;
23
import org.eclipse.emf.transaction.NotificationFilter;
24
import org.eclipse.emf.transaction.NotificationFilter;
24
import org.eclipse.emf.transaction.ResourceSetChangeEvent;
25
import org.eclipse.emf.transaction.ResourceSetChangeEvent;
25
import org.eclipse.emf.transaction.ResourceSetListenerImpl;
26
import org.eclipse.emf.transaction.ResourceSetListenerImpl;
Lines 36-48 Link Here
36
	public ResourceSetChangeEvent precommit;
37
	public ResourceSetChangeEvent precommit;
37
	
38
	
38
	/** The copied list of precommit notifications from the precommit event. */
39
	/** The copied list of precommit notifications from the precommit event. */
39
	public List precommitNotifications;
40
	public List<Notification> precommitNotifications;
40
	
41
	
41
	/** The last post-commit event received. */
42
	/** The last post-commit event received. */
42
	public ResourceSetChangeEvent postcommit;
43
	public ResourceSetChangeEvent postcommit;
43
	
44
	
44
	/** The copied list of postcommit notifications from the postcommit event.*/
45
	/** The copied list of postcommit notifications from the postcommit event.*/
45
	public List postcommitNotifications;
46
	public List<Notification> postcommitNotifications;
46
	
47
	
47
	public TestListener() {
48
	public TestListener() {
48
		super(NotificationFilter.ANY);
49
		super(NotificationFilter.ANY);
Lines 52-69 Link Here
52
		super(filter);
53
		super(filter);
53
	}
54
	}
54
	
55
	
56
	@Override
55
	public Command transactionAboutToCommit(ResourceSetChangeEvent event)
57
	public Command transactionAboutToCommit(ResourceSetChangeEvent event)
56
		throws RollbackException {
58
		throws RollbackException {
57
		
59
		
58
		precommit = event;
60
		precommit = event;
59
		precommitNotifications = new ArrayList(event.getNotifications());
61
		precommitNotifications = new ArrayList<Notification>(event.getNotifications());
60
		
62
		
61
		return null;
63
		return null;
62
	}
64
	}
63
	
65
	
66
	@Override
64
	public void resourceSetChanged(ResourceSetChangeEvent event) {
67
	public void resourceSetChanged(ResourceSetChangeEvent event) {
65
		postcommit = event;
68
		postcommit = event;
66
		postcommitNotifications = new ArrayList(event.getNotifications());
69
		postcommitNotifications = new ArrayList<Notification>(event.getNotifications());
67
	}
70
	}
68
	
71
	
69
	/**
72
	/**
(-)src/org/eclipse/emf/transaction/tests/fixtures/LibraryDefaultNameTrigger.java (+1 lines)
Lines 38-43 Link Here
38
									Notification.ADD)));
38
									Notification.ADD)));
39
	}
39
	}
40
	
40
	
41
	@Override
41
	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
42
	protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
42
		Command result = null;
43
		Command result = null;
43
		
44
		
(-)src/org/eclipse/emf/transaction/tests/fixtures/TestEditingDomain.java (+3 lines)
Lines 42-47 Link Here
42
42
43
	public static class FactoryImpl extends TransactionalEditingDomainImpl.FactoryImpl {
43
	public static class FactoryImpl extends TransactionalEditingDomainImpl.FactoryImpl {
44
44
45
		@Override
45
		public TransactionalEditingDomain createEditingDomain() {
46
		public TransactionalEditingDomain createEditingDomain() {
46
			TransactionalEditingDomain result = new TestEditingDomain(
47
			TransactionalEditingDomain result = new TestEditingDomain(
47
					new ComposedAdapterFactory(
48
					new ComposedAdapterFactory(
Lines 52-62 Link Here
52
			return result;
53
			return result;
53
		}
54
		}
54
55
56
		@Override
55
		public TransactionalEditingDomain createEditingDomain(ResourceSet rset) {
57
		public TransactionalEditingDomain createEditingDomain(ResourceSet rset) {
56
			// not used by the extension point
58
			// not used by the extension point
57
			return null;
59
			return null;
58
		}
60
		}
59
61
62
		@Override
60
		public TransactionalEditingDomain getEditingDomain(ResourceSet rset) {
63
		public TransactionalEditingDomain getEditingDomain(ResourceSet rset) {
61
			// not used by the extension point
64
			// not used by the extension point
62
			return null;
65
			return null;
(-)src/org/eclipse/emf/transaction/tests/fixtures/LogCapture.java (-6 / +6 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 18-24 Link Here
18
18
19
import java.util.List;
19
import java.util.List;
20
20
21
import junit.framework.TestCase;
21
import junit.framework.Assert;
22
22
23
import org.eclipse.core.runtime.ILogListener;
23
import org.eclipse.core.runtime.ILogListener;
24
import org.eclipse.core.runtime.IStatus;
24
import org.eclipse.core.runtime.IStatus;
Lines 46-52 Link Here
46
		}};
46
		}};
47
	private final TransactionalCommandStack stack;
47
	private final TransactionalCommandStack stack;
48
	
48
	
49
	private final List logs = new java.util.ArrayList();
49
	private final List<IStatus> logs = new java.util.ArrayList<IStatus>();
50
	private IStatus lastLog;
50
	private IStatus lastLog;
51
	
51
	
52
	/**
52
	/**
Lines 123-129 Link Here
123
	 * 
123
	 * 
124
	 * @return a list (possibly empty) of {@link IStatus}es
124
	 * @return a list (possibly empty) of {@link IStatus}es
125
	 */
125
	 */
126
	public List getLogs() {
126
	public List<IStatus> getLogs() {
127
		return logs;
127
		return logs;
128
	}
128
	}
129
	
129
	
Lines 134-142 Link Here
134
	 */
134
	 */
135
	public void assertLogged(Throwable throwable) {
135
	public void assertLogged(Throwable throwable) {
136
        IStatus log = getLastLog();
136
        IStatus log = getLastLog();
137
        TestCase.assertNotNull(log);
137
        Assert.assertNotNull(log);
138
        log = findStatus(log, throwable);
138
        log = findStatus(log, throwable);
139
        TestCase.assertNotNull(log);
139
        Assert.assertNotNull(log);
140
	}
140
	}
141
	
141
	
142
	private void record(IStatus log) {
142
	private void record(IStatus log) {
(-)src/org/eclipse/emf/transaction/tests/constraints/BookTitleConstraint.java (-1 / +2 lines)
Lines 30-35 Link Here
30
public class BookTitleConstraint
30
public class BookTitleConstraint
31
	extends AbstractModelConstraint {
31
	extends AbstractModelConstraint {
32
32
33
	@Override
33
	public IStatus validate(IValidationContext ctx) {
34
	public IStatus validate(IValidationContext ctx) {
34
		EMFEventType eType = ctx.getEventType();
35
		EMFEventType eType = ctx.getEventType();
35
		
36
		
Lines 38-44 Link Here
38
			
39
			
39
			if (newValue == null
40
			if (newValue == null
40
				|| ((String)newValue).length() == 0) {
41
				|| ((String)newValue).length() == 0) {
41
				return ctx.createFailureStatus(null);
42
				return ctx.createFailureStatus();
42
			}
43
			}
43
		}
44
		}
44
		
45
		
(-)META-INF/MANIFEST.MF (-2 / +2 lines)
Lines 7-13 Link Here
7
Bundle-Localization: plugin
7
Bundle-Localization: plugin
8
Require-Bundle: org.eclipse.emf.transaction;bundle-version="1.2.0",
8
Require-Bundle: org.eclipse.emf.transaction;bundle-version="1.2.0",
9
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
9
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
10
 org.eclipse.emf.examples.library.edit;bundle-version="[2.2.0,3.0.0)",
10
 org.eclipse.emf.examples.library.edit;bundle-version="[2.3.0,3.0.0)",
11
 org.junit;bundle-version="[3.8.1,4.0.0)",
11
 org.junit;bundle-version="[3.8.1,4.0.0)",
12
 org.eclipse.ui;bundle-version="[3.2.0,4.0.0)"
12
 org.eclipse.ui;bundle-version="[3.2.0,4.0.0)"
13
Eclipse-LazyStart: true; exceptions="org.eclipse.emf.transaction.tests.constraints"
13
Eclipse-LazyStart: true; exceptions="org.eclipse.emf.transaction.tests.constraints"
Lines 17-20 Link Here
17
 org.eclipse.emf.transaction.tests.fixtures,
17
 org.eclipse.emf.transaction.tests.fixtures,
18
 org.eclipse.emf.transaction.util.tests
18
 org.eclipse.emf.transaction.util.tests
19
Bundle-Activator: org.eclipse.emf.transaction.tests.TestsPlugin
19
Bundle-Activator: org.eclipse.emf.transaction.tests.TestsPlugin
20
Bundle-RequiredExecutionEnvironment: J2SE-1.4
20
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)build.properties (-2 / +2 lines)
Lines 25-29 Link Here
25
               about.ini,\
25
               about.ini,\
26
               about.html
26
               about.html
27
src.includes = about.html
27
src.includes = about.html
28
javacSource = 1.4
28
javacSource = 1.5
29
javacTarget = 1.4
29
javacTarget = 1.5

Return to bug 206811