<commit_before>/*******************************************************************************
 * Copyright (c) 2004, 2009 <NAME>.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     <NAME> (XMLmodeling.com) - initial API and implementation
 *     
 * $Id$
 *******************************************************************************/
package org.openhealthtools.mdht.uml.common.ui.saveable;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.transaction.NotificationFilter;
import org.eclipse.emf.transaction.ResourceSetChangeEvent;
import org.eclipse.emf.transaction.ResourceSetListener;
import org.eclipse.emf.transaction.ResourceSetListenerImpl;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.Saveable;
import org.openhealthtools.mdht.uml.common.ui.internal.Logger;
import org.openhealthtools.mdht.uml.common.ui.internal.l10n.Messages;

/**
 * Support for managing views and editors that implement ISaveablesSource.
 */
public class ModelManager {

	private static ModelManager Manager = new ModelManager();

	private ListenerList listeners = new ListenerList();

	private Map<URI,ModelDocument> uriToDocumentMap = new HashMap<URI,ModelDocument>();

	private Collection<Resource> changedResources = new ArrayList<Resource>();

	private Collection<Resource> removedResources = new ArrayList<Resource>();

	private Collection<Resource> savedResources = new ArrayList<Resource>();

	private Shell shell;

	public static ModelManager getManager() {
		return Manager;
	}
	
	private ModelManager() {
		ResourcesPlugin.getWorkspace().addResourceChangeListener(
				resourceChangeListener, IResourceChangeEvent.POST_CHANGE);
	}

	private ResourceSetListener resourceLoadListener = new ResourceSetListenerImpl(
			NotificationFilter.RESOURCE_LOADED.or(NotificationFilter.RESOURCE_UNLOADED)) {
        public void resourceSetChanged(ResourceSetChangeEvent event) {
			for (Notification notification : event.getNotifications()) {
				Resource resource = (Resource) notification.getNotifier();<commit_msg>Change ArrayList to Vector to resolve concurrent modification error in Helios.<commit_after>/*******************************************************************************
 * Copyright (c) 2004, 2009 <NAME>.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     <NAME> (XMLmodeling.com) - initial API and implementation
 *     
 * $Id$
 *******************************************************************************/
package org.openhealthtools.mdht.uml.common.ui.saveable;

import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.transaction.NotificationFilter;
import org.eclipse.emf.transaction.ResourceSetChangeEvent;
import org.eclipse.emf.transaction.ResourceSetListener;
import org.eclipse.emf.transaction.ResourceSetListenerImpl;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.Saveable;
import org.openhealthtools.mdht.uml.common.ui.internal.Logger;
import org.openhealthtools.mdht.uml.common.ui.internal.l10n.Messages;

/**
 * Support for managing views and editors that implement ISaveablesSource.
 */
public class ModelManager {

	private static ModelManager Manager = new ModelManager();

	private ListenerList listeners = new ListenerList();

	private Map<URI,ModelDocument> uriToDocumentMap = new HashMap<URI,ModelDocument>();

	private Collection<Resource> changedResources = new Vector<Resource>();

	private Collection<Resource> removedResources = new Vector<Resource>();

	private Collection<Resource> savedResources = new Vector<Resource>();

	private Shell shell;

	public static ModelManager getManager() {
		return Manager;
	}
	
	private ModelManager() {
		ResourcesPlugin.getWorkspace().addResourceChangeListener(
				resourceChangeListener, IResourceChangeEvent.POST_CHANGE);
	}

	private ResourceSetListener resourceLoadListener = new ResourceSetListenerImpl(
			NotificationFilter.RESOURCE_LOADED.or(NotificationFilter.RESOURCE_UNLOADED)) {
        public void resourceSetChanged(ResourceSetChangeEvent event) {
			for (Notification notification : event.getNotifications()) {
				Resource resource = (Resource) notification.getNotifier();
{'fraction_non_alphanumeric': 0.13919469160006032, 'fraction_numerical': 0.004222590861106922, 'mean_word_length': 6.271929824561403, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4633565', 'n_tokens_mistral': 1813, 'n_tokens_neox': 1735, 'n_words': 379}