text:
package org.eclipse.bpel.ui;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.eclipse.bpel.common.extension.model.ExtensionMap;
import org.eclipse.bpel.common.ui.editmodel.IEditModelListener;
import org.eclipse.bpel.common.ui.editmodel.ResourceInfo;
import org.eclipse.bpel.model.Activity;
import org.eclipse.bpel.model.CorrelationSet;
import org.eclipse.bpel.model.BPELExtensibleElement;
import org.eclipse.bpel.model.Import;
import org.eclipse.bpel.model.MessageExchange;
import org.eclipse.bpel.model.PartnerLink;
import org.eclipse.bpel.model.Process;
import org.eclipse.bpel.model.Variable;
import org.eclipse.bpel.model.resource.BPELResourceSetImpl;
import org.eclipse.bpel.model.util.BPELUtils;
import org.eclipse.bpel.ui.adapters.AdapterNotification;
import org.eclipse.bpel.ui.adapters.IMarkerHolder;
import org.eclipse.bpel.ui.editparts.ProcessTrayEditPart;
import org.eclipse.bpel.ui.editparts.util.OutlineTreePartFactory;
import org.eclipse.bpel.ui.properties.BPELPropertySection;
import org.eclipse.bpel.ui.uiextensionmodel.StartNode;
import org.eclipse.bpel.ui.util.BPELEditModelClient;
import org.eclipse.bpel.ui.util.BPELEditorUtil;
import org.eclipse.bpel.ui.util.BPELReader;
import org.eclipse.bpel.ui.util.BPELUtil;
import org.eclipse.bpel.ui.util.ModelHelper;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.core.resources.IProject;
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.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.Viewport;
import org.eclipse.draw2d.parts.ScrollableThumbnail;
import org.eclipse.draw2d.parts.Thumbnail;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.NotificationImpl;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gef.ContextMenuProvider;
import org.eclipse.gef.DefaultEditDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.LayerConstants;
import org.eclipse.gef.RootEditPart;
import org.eclipse.gef.commands.CommandStack;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.gef.ui.parts.ContentOutlinePage;
import org.eclipse.gef.ui.parts.TreeViewer;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.viewers.IPostSelectionProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.ui.ide.IGotoMarker;
import org.eclipse.ui.internal.views.properties.tabbed.view.TabDescriptor;
import org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyViewer;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.ui.views.properties.tabbed.ISection;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
import org.eclipse.ui.views.properties.tabbed.TabContents;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class BPELMultipageEditorPart extends MultiPageEditorPart
implements IEditModelListener,
IGotoMarker/*, CommandStackListener*/ {

	class OutlinePage extends ContentOutlinePage {
		private PageBook pageBook;
		private Control outline;
		private Canvas overview;
		private IAction showOutlineAction, showOverviewAction;
		static final int ID_OUTLINE  = 0;
		static final int ID_OVERVIEW = 1;
		private Thumbnail thumbnail;

		public OutlinePage(EditPartViewer viewer) {
			super(viewer);
		}

		// increase visibility.

		public EditPartViewer getViewer() {
			return super.getViewer();
		}

		private void configureOutlineViewer() {
			getViewer().setEditDomain(getEditDomain());
			getViewer().setEditPartFactory(new OutlineTreePartFactory());

			BPELMultipageEditorPart.this.fDesignViewer.registerViewer(getViewer());

			//FIXME should we add the same for src tab?
			ContextMenuProvider provider = new ProcessContextMenuProvider(getDesignEditor(), BPELMultipageEditorPart.this.fDesignViewer.getActionRegistry());

			getViewer().setContextMenu(provider);
			getSite().registerContextMenu("org.eclipse.bpel.outline.contextmenu", //$NON-NLS-1$
					provider,
					getSite().getSelectionProvider());
			getViewer().setKeyHandler(BPELMultipageEditorPart.this.fDesignViewer.getKeyHandler());
			// TODO: Drag and drop support goes here
			// getViewer().addDropTargetListener(new BPELTemplateTransferDropTargetListener(getViewer()));
			IToolBarManager tbm = getSite().getActionBars().getToolBarManager();
			this.showOutlineAction = new Action() {

				public void run() {
					showPage(ID_OUTLINE);
				}

				public String getToolTipText() {
					return Messages.OutlinePage_showOutlineView;
				}
			};
			this.showOutlineAction.setImageDescriptor(BPELUIPlugin.INSTANCE.getImageDescriptor(IBPELUIConstants.ICON_OUTLINE_16));
			tbm.add(this.showOutlineAction);
			this.showOverviewAction = new Action() {

				public void run() {
					showPage(ID_OVERVIEW);
				}

				public String getToolTipText() {
					return Messages.OutlinePage_showOverviewView;
				}
			};
			this.showOverviewAction.setImageDescriptor(BPELUIPlugin.INSTANCE.getImageDescriptor(IBPELUIConstants.ICON_OVERVIEW_16));
			tbm.add(this.showOverviewAction);
			showPage(ID_OUTLINE);
		}

		public Control getControl() {
			return this.pageBook;
		}

		public void createControl(Composite parent) {
			this.pageBook = new PageBook(parent, SWT.NONE);
			this.outline = getViewer().createControl(this.pageBook);
			this.overview = new Canvas(this.pageBook, SWT.NONE);
			this.pageBook.showPage(this.outline);
			configureOutlineViewer();
			// TODO: Add to the adapting selection provider
			//getSelectionSynchronizer().addViewer(getViewer());

			getViewer().setContents(getProcess());
		}

		private void initializeOverview() {
			LightweightSystem lws = new LightweightSystem(this.overview);
			RootEditPart rep = BPELMultipageEditorPart.this.fDesignViewer.getGraphicalViewer().getRootEditPart();
			if (rep instanceof GraphicalBPELRootEditPart) {
				GraphicalBPELRootEditPart root = (GraphicalBPELRootEditPart)rep;
				this.thumbnail = new ScrollableThumbnail((Viewport)root.getFigure());
				this.thumbnail.setSource(root.getLayer(LayerConstants.PRINTABLE_LAYERS));
				lws.setContents(this.thumbnail);
			}
		}

		private void showPage(int id) {
			if (id == ID_OUTLINE) {
				this.showOutlineAction.setChecked(true);
				this.showOverviewAction.setChecked(false);
				this.pageBook.showPage(this.outline);
				if (this.thumbnail != null)
					this.thumbnail.setVisible(false);
			} else if (id == ID_OVERVIEW) {
				initializeOverview();
				this.showOutlineAction.setChecked(false);
				this.showOverviewAction.setChecked(true);
				this.pageBook.showPage(this.overview);
				this.thumbnail.setVisible(true);
			}
		}

		public void dispose() {
			super.dispose();
		}

		public void init(IPageSite pageSite) {
			super.init(pageSite);
			//should ActionRegistry be here too?
			ActionRegistry registry = BPELMultipageEditorPart.this.fDesignViewer.getActionRegistry();
			IActionBars bars = pageSite.getActionBars();
			String id = ActionFactory.UNDO.getId();
			bars.setGlobalActionHandler(id, registry.getAction(id));
			id = ActionFactory.REDO.getId();
			bars.setGlobalActionHandler(id, registry.getAction(id));
			id = ActionFactory.DELETE.getId();
			bars.setGlobalActionHandler(id, registry.getAction(id));
			id = ActionFactory.REVERT.getId();
			bars.setGlobalActionHandler(id, registry.getAction(id));
			bars.updateActionBars();
		}
	}

	protected class TextEditorSelectionListener implements ISelectionChangedListener {
		public void selectionChanged(SelectionChangedEvent event) {
			if (getActivePage() != DESIGN_PAGE_INDEX) {
				ISelection selection = event.getSelection();
				if (selection instanceof IStructuredSelection) {
					List<Object> selections = new ArrayList<Object>();
					for (Iterator<Object> i = ((IStructuredSelection) selection).iterator(); i.hasNext();) {
						Object domNode = i.next();
						if (domNode instanceof Element) {
							Object facade = BPELEditorUtil.getInstance().findModelObjectForElement(BPELMultipageEditorPart.this.process, (Element)domNode);
							if (facade != null) {
								selections.add(facade);
							}
						}
					}

					if (!selections.isEmpty()) {
						StructuredSelection bpelSelection = new StructuredSelection(selections);
						BPELMultipageEditorPart.this.fDesignViewer.getAdaptingSelectionProvider().setSelection(bpelSelection);
					}
				}
			}
		}
	}

	protected class DesignViewerSelectionListener implements ISelectionChangedListener {
		public void selectionChanged(SelectionChangedEvent event) {
			//force selection update if only source page is not active
			if (getActivePage() != SOURCE_PAGE_INDEX) {
				try {
					ISelection sel = BPELMultipageEditorPart.this.fDesignViewer.getSelection();
					Object selectedNode = ((IStructuredSelection)sel).getFirstElement();
					Element selectedNodeElement = null;

					if (selectedNode instanceof StartNode) {
						selectedNodeElement = ((StartNode)selectedNode).getProcess().getElement();
					} else if (selectedNode instanceof BPELExtensibleElement) {
						selectedNodeElement = ((BPELExtensibleElement)selectedNode).getElement();
					}

					if (selectedNodeElement != null) {
						if (selectedNodeElement instanceof IDOMNode && ((IDOMNode)selectedNodeElement).getModel().isModelStateChanging()) {
							return;
						}
						StructuredSelection nodeSelection = new StructuredSelection(selectedNodeElement);
						getTextEditor().getSelectionProvider().setSelection(nodeSelection);
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}

	private Process process;

	private DefaultEditDomain editDomain;

	protected ModelListenerAdapter modelListenerAdapter;

	private Resource extensionsResource;

	private ExtensionMap extensionMap;

	protected StructuredTextEditor fTextEditor = null;
	protected BPELEditor fDesignViewer = null;
	protected int currentPage = -1;

	protected TextEditorSelectionListener textEditorSelectionListener;
	protected DesignViewerSelectionListener designViewerSelectionListener;

	// reacts to changes on the BPEL file (e.g. move, rename)
	private IFileChangeListener fileChangeListener;

	// refactoring listeners
	protected IResourceChangeListener postBuildRefactoringListener;

	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=330813
	protected IResourceChangeListener preBuildRefactoringListener;
	BPELModelReconcileAdapter bpelModelReconcileAdapter;

	private OutlinePage outlinePage;
	protected BPELTabbedPropertySheetPage currentPropertySheetPage;

	protected ActionRegistry actionRegistry;

	private static int DESIGN_PAGE_INDEX = 0;
	private static int SOURCE_PAGE_INDEX = 1;

	private final Map<Long, EObject>fMarkers2EObject = new HashMap<Long, EObject>();
	private final Notification fMarkersStale = new NotificationImpl(
			AdapterNotification.NOTIFICATION_MARKERS_STALE, null, null);

	public BPELMultipageEditorPart() {
		super();
		setEditDomain(new BPELEditDomain(this));
	}

	/**
	 * Connects the design viewer with the viewer selection manager. Should be
	 * done after createSourcePage() is done because we need to get the
	 * ViewerSelectionManager from the TextEditor. setModel is also done here
	 * because getModel() needs to reference the TextEditor.
	 */
	protected void connectDesignPage() {

		/*
		 * Connect selection from the Design page to the selection provider of
		 * the Source page so that selection in the Design page will drive
		 * selection in the Source page.
		 */
		this.designViewerSelectionListener = new DesignViewerSelectionListener();
		this.fDesignViewer.getAdaptingSelectionProvider().addSelectionChangedListener(this.designViewerSelectionListener);

		/*
		 * Connect selection from the Source page to the selection provider of
		 * the Design page so that selection in the Source page will drive
		 * selection in the Design page.
		 */
		this.textEditorSelectionListener = new TextEditorSelectionListener();
		ISelectionProvider provider = getTextEditor().getSelectionProvider();
		if (provider instanceof IPostSelectionProvider) {
			((IPostSelectionProvider) provider).addPostSelectionChangedListener(this.textEditorSelectionListener);
		} else {
			provider.addSelectionChangedListener(this.textEditorSelectionListener);
		}

	}

	/**
	 * Creates the design page of the multi-page editor.
	 */
	protected void createDesignPage() {
		this.fDesignViewer = new BPELEditor(getEditDomain(), this);
		// Bug #209341 - starting patch
		if( getFileInput() == null ) {
			MessageDialog.openError(
					getSite().getShell(),
					Messages.Editor_load_error_title, // Bugzilla 330513
					Messages.Editor_load_error
			);
			return;
		}
		// End of patch
		try
		{
			loadModel();
			addPage(0, this.fDesignViewer, getEditorInput());
			//FIXME I18N
			setPageText(0, "Design");
		} catch (PartInitException e) {
			ErrorDialog.openError(
					getSite().getShell(),
					Messages.Editor_design_page_error, // Bugzilla 330513
					null,
					e.getStatus()); //$NON-NLS-1$
		} catch (CoreException e) {
			// TODO: what to do here?
		}
	}

	// https://jira.jboss.org/browse/JBIDE-6917

	protected IEditorSite createSite(IEditorPart page) {
		IEditorSite site = null;
		if (page == fTextEditor) {
			site = new org.eclipse.ui.part.MultiPageEditorSite(this, page) {
				public String getId() {
					// Sets this ID so nested editor is configured for BPEL source
					return BPELResourceSetImpl.BPEL_CONTENT_TYPE;
				}
			};
		}
		else {
			site = super.createSite(page);
		}
		return site;
	}

	/**
	 * Creates the source page of the multi-page editor.
	 */
	protected void createSourcePage() throws PartInitException {
		this.fTextEditor = new StructuredTextEditor();
		try
		{
			addPage(0, this.fTextEditor, getEditorInput());
			//FIXME I18N
			setPageText(0, "Source");
		} catch (PartInitException e) {
			ErrorDialog.openError(getSite().getShell(), "Error creating Source page", null, e.getStatus()); //$NON-NLS-1$
		}
	}

	/**
	 * Creates the pages of this multi-page editor.
	 */

	protected void createPages() {
		try {
			// source page must be created before design page
			createSourcePage();
			createDesignPage();
			firePropertyChange(PROP_TITLE);
			connectDesignPage();
			initializeFileChangeListener();
			initializeRefactoringListener();
		} catch (PartInitException e) {
			//Logger.logException(e);
			throw new RuntimeException(e);
		}

		if (BPELUIPlugin.INSTANCE.getDefaultPage().equals(IBPELUIConstants.SOURCE_PAGE)) {
			setActivePage(SOURCE_PAGE_INDEX);
		} else {
			setActivePage(DESIGN_PAGE_INDEX);
		}

		//updateTitle();
	}

	public void dispose() {
		/*if (outlinePage != null && outlinePage.getViewer() != null) {
			outlinePage.getViewer().setContents(null);
		}*/
		if (this.currentPage == SOURCE_PAGE_INDEX) {
			BPELUIPlugin.INSTANCE.setDefaultPage(IBPELUIConstants.SOURCE_PAGE);
		} else {
			BPELUIPlugin.INSTANCE.setDefaultPage(IBPELUIConstants.DESIGN_PAGE);
		}

		this.outlinePage = null;
		this.process = null;

		if (this.fileChangeListener != null) {
			BPELUIPlugin.INSTANCE.getResourceChangeListener().removeListener(this.fileChangeListener);
		}

		if (this.postBuildRefactoringListener != null) {
			IWorkspace workspace = ResourcesPlugin.getWorkspace();
			workspace.removeResourceChangeListener(this.postBuildRefactoringListener);
		}

		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=330813
		// https://jira.jboss.org/browse/JBIDE-6365
		if (this.preBuildRefactoringListener != null) {
			IWorkspace workspace = ResourcesPlugin.getWorkspace();
			workspace.removeResourceChangeListener(this.preBuildRefactoringListener);
		}
		IStructuredModel model = this.fTextEditor.getModel();
		if (model != null) {
			model.releaseFromEdit();
			this.fDesignViewer.dispose();
			this.fTextEditor.dispose();
		}

		super.dispose();
	}

	public void doRevertToSaved(IProgressMonitor monitor) {
		// Do the work within an operation because this is a long running activity that modifies the workbench.
//		WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
//			protected void execute(IProgressMonitor monitor) throws CoreException {
//				try {
//					getCommandFramework().abortCurrentChange();
//					getCommandStack().flush();
//
//					// de-select anything selected on the canvas!  Otherwise removing things
//					// will trigger a bunch of behaviour when the selected object(s) are
//					// removed..
//					adaptingSelectionProvider.setSelection(StructuredSelection.EMPTY);
//
//					process = null;
//					extensionMap = null;
//					extensionsResource = null;
//					lastSelectedEditPart = null;
//					// unload all resources (otherwise they stay around taking up space..?)
//					for (Iterator it = getResourceSet().getResources().iterator(); it.hasNext(); ) {
//						Resource res = (Resource)it.next();
//						res.unload();
//					}
//					loadModel();
//					getGraphicalViewer().setContents(process);
//					getTrayViewer().setContents(process);
//					if (outlinePage != null && outlinePage.getViewer() != null) {
//                      // hack!
//						if (Platform.getWS().equals(Platform.WS_GTK)) {
//							Tree tree = (Tree) outlinePage.getViewer().getControl();
//							if (tree != null) {
//								tree.setRedraw(false);
//								TreeItem[] items = tree.getItems();
//								for (int i = 0; i < items.length; i++) {
//									items[i].dispose();
//								}
//								tree.setRedraw(true);
//							}
//						}
//						outlinePage.getViewer().setContents(process);
//					}
//					selectModelObject(getProcess());
//				}
//				catch (Exception e) {
//					BPELUIPlugin.log(e);
//				}
//			}
//		};
//
//		try {
//			// This runs the options, and shows progress.
//			// (It appears to be a bad thing to fork this onto another thread.)
//			new ProgressMonitorDialog(getSite().getShell()).run(false, false, operation);
//
//			// Refresh the necessary state.
//			firePropertyChange(IEditorPart.PROP_DIRTY);
//		} catch (Exception e) {
//			BPELUIPlugin.log(e);
//		}
	}

	/**
	 * @see org.eclipse.ui.IEditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
	 */

	public void doSave(IProgressMonitor progressMonitor) {
		// We use fTextEditor to save, because fDesignViewer.doSave() removes comments on save
		// Save bpel only
		this.fDesignViewer.getCommandFramework().applyCurrentChange();
		this.fTextEditor.doSave(progressMonitor);
		// Reset sync stamp and modified flag after save
		this.fDesignViewer.getEditModelClient().getPrimaryResourceInfo().resetSynchronizeStamp();
		this.fDesignViewer.getEditModelClient().getPrimaryResourceInfo().getResource().setModified(false);
		// Save extensions
		this.fDesignViewer.doSave(progressMonitor);
		getCommandStack().markSaveLocation();
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see org.eclipse.ui.ISaveablePart#doSaveAs()
	 */

	public void doSaveAs() {
		//saveAs is not allowed; do nothing
	}

	protected BPELTabbedPropertySheetPage createBPELTabbedPropertySheetPage() {
		//FIXME should the BPELTabbedPropertySheetPage has BPELMultiPageEditorPart as the 2nd argument?
		return new BPELTabbedPropertySheetPage(new ITabbedPropertySheetPageContributor() {
			public String getContributorId() {
				// same as the palette one
				//return fDesignViewer.getPaletteAdditionsContributorId();
				return IBPELUIConstants.BPEL_EDITOR_ID;
			}
		}, this.fDesignViewer);
	}

	protected ActionRegistry getActionRegistry() {
		if (this.actionRegistry == null)
			this.actionRegistry = new ActionRegistry();
		return this.actionRegistry;
	}

	public Object getAdapter(Class type) {
		if (type == Process.class) {
			return this.process;
		}

		if (type == BPELEditModelClient.class) {
			return this.process;
		}

		//FIXME should we kill it?
		if (type == ModelListenerAdapter.class) {
			return this.modelListenerAdapter;
		}

		//FIXME should we kill it?
		if (type == Resource.class) {
			return this.extensionsResource;
		}

		//FIXME should we kill it?
		if (type == ExtensionMap.class) {
			return this.extensionMap;
		}

		//FIXME should we kill it?
		if (type == CommandStack.class) {
			return getCommandStack();
		}

		if (type == IContentOutlinePage.class) {
			if (this.outlinePage == null) {
				this.outlinePage = new OutlinePage(new TreeViewer());
			}
			return this.outlinePage;
		}

		if (type == IPropertySheetPage.class) {
			// We can't cache this object because the properties framework needs a new instance
			// every time it calls this method.
			this.currentPropertySheetPage = createBPELTabbedPropertySheetPage();
			return this.currentPropertySheetPage;
		}

		if (type == ActionRegistry.class) {
			return getActionRegistry();
		}

		return super.getAdapter(type);
	}

	public CommandStack getCommandStack() {
		return getEditDomain().getCommandStack();
	}

	protected int getDefaultPageTypeIndex() {
		int pageIndex = DESIGN_PAGE_INDEX;
		if (BPELUIPlugin.INSTANCE.getDefaultPage().equals(IBPELUIConstants.SOURCE_PAGE)) {
			pageIndex = SOURCE_PAGE_INDEX;
		}
		return pageIndex;
	}

	/**
	 * Returns the design viewer
	 * @return the design viewer
	 */
	protected BPELEditor getDesignEditor() {
		return this.fDesignViewer;
	}

	/**
	 * Returns the edit domain.
	 * @return the edit domain
	 */
	protected DefaultEditDomain getEditDomain() {
		return this.editDomain;
	}

	// Bug #209341 - patch
	// By Vincent Zurczak - EBM WebSourcing
	private IFile openFile;
	private static String filePrefix = new SimpleDateFormat( "yyyyMMF_" ).format( new GregorianCalendar().getTime());

	/**
	 *
	 * @return
	 */
	protected IFile getFileInput() {

		if( this.openFile == null ) {
			try {
				// Case where the file is in the workspace
				if( getEditorInput() instanceof IFileEditorInput )
					this.openFile = ((IFileEditorInput) getEditorInput()).getFile();

				// Outside the workspace
				// Since everything relies on IFiles, we create a temporary file in the workspace
				// linking to the file outside the workspace
				else if( getEditorInput() instanceof FileStoreEditorInput ) {
					File f = new File(((FileStoreEditorInput) getEditorInput()).getURI());
					IPath path = new Path( f.getAbsolutePath());

					// Create a temporary project
					IProgressMonitor monitor =  new NullProgressMonitor();
					IProject tempProject = ResourcesPlugin.getWorkspace().getRoot().getProject( ".temp" );
					if( ! tempProject.exists())
						tempProject.create( monitor );

					if( ! tempProject.isOpen())
						tempProject.open( monitor );

					// Remove old temporary files
					// The file prefix is designed so that natural comparison order is enough
					for( IResource res : tempProject.members()) {
						if( res.getName().substring( 0, 7 ).compareTo( filePrefix ) < 0 ) {
							try {
								res.delete( false, monitor );
							} catch( Exception e ) {
								e.printStackTrace();
							}
						}
					}

					// Create a temporary file
					this.openFile = tempProject.getFile( filePrefix + path.lastSegment());
					this.openFile.createLink( path, IResource.NONE, monitor );
				}

			} catch( CoreException e ) {
				e.printStackTrace();
			}
		}

		return this.openFile;
	}
	// End of patch

	public Process getProcess() {
		return this.process;
	}

	/**
	 * Returns the design viewer
	 * @return the design viewer
	 */
	protected StructuredTextEditor getSourceViewer() {
		return this.fTextEditor;
	}

	StructuredTextEditor getTextEditor() {
		return this.fTextEditor;
	}

	public void gotoMarker(IMarker marker) {

		// One such mechanism is to use the href of the model object
		// generated by the validator or whatever ...

		String href = null;
		try {
			href = (String) marker.getAttribute( "address.model" );
		} catch (CoreException ex) {
			BPELUIPlugin.log(ex);
		}

		// lookup by object href in the model.
		EObject modelObject = null;

		if (href != null) {
			try {
				modelObject = this.fDesignViewer.getResource().getEObject( href );
			} catch (Throwable t) {
				BPELUIPlugin.log(t);
			}
		}

		gotoText(marker);

		if (modelObject == null) {
			return;
		}

		gotoMarker ( marker, modelObject );
	}

	private void gotoText(IMarker marker) {
		Integer charStart = null;
		Integer charEnd = null;
		try {
			charStart = (Integer) marker.getAttribute( "charStart" );
			charEnd = (Integer) marker.getAttribute( "charEnd" );
		} catch (CoreException ex) {
			BPELUIPlugin.log(ex);
		}
		charStart = charStart == null ? 0 : charStart;
		charEnd = charEnd == null ? charStart : charEnd;
		try {
			this.fTextEditor.setHighlightRange(charStart, charEnd - charStart, true);
		} catch (Throwable t) {
			BPELUIPlugin.log(t);
		}
	}

	void gotoMarker ( IMarker marker, EObject modelObject ) {

		// TODO: is this bogus now that we have AdaptingSelectionProvider?

		// The closest parent which has an edit part in the graph view.
		//
		// The following do not have viewers in the graph view:
		//  1) Variables, PartnerLinks, Correlation Sets, Message Exchanges
		// If it's any of those, then we have to reveal the closest container
		// and then select the model object and show the properties.

		GraphicalViewer graphViewer = this.fDesignViewer.getGraphicalViewer();
		EObject refObj = null;

		EditPart editPart = null;
		if ( modelObject instanceof Variable ||
				modelObject instanceof PartnerLink ||
				modelObject instanceof CorrelationSet ||
				modelObject instanceof MessageExchange) {

			refObj = ModelHelper.getContainingScope(modelObject);
			editPart = (EditPart)graphViewer.getEditPartRegistry().get(refObj);
			if (editPart != null) {
				graphViewer.reveal(editPart);
			}
			this.fDesignViewer.selectModelObject(modelObject);

		} else if (modelObject instanceof Activity) {

			// activity objects are on the graphical viewer
			refObj = modelObject;
			editPart = (EditPart)graphViewer.getEditPartRegistry().get(refObj);

			if (editPart != null) {
				graphViewer.reveal(editPart);
			}

			this.fDesignViewer.selectModelObject(modelObject);

		} else {

			refObj = modelObject;
			while (refObj != null && !(refObj instanceof Activity) ) {
				refObj = refObj.eContainer();
			}

			// select process by default.
			if (refObj == null) {
				refObj = BPELUtils.getProcess( modelObject ) ;
			}

			modelObject = refObj;

			editPart = (EditPart)graphViewer.getEditPartRegistry().get(modelObject);

			if (editPart != null) {
				graphViewer.reveal(editPart);
			}

			this.fDesignViewer.selectModelObject(modelObject);
		}

		// If possible, try to display the marker in a property section.
		BPELTabbedPropertySheetPage propertySheetPage = this.currentPropertySheetPage;
		if (propertySheetPage == null) {
			return;
			// if currentPropertySheetPage is null it means that the properties
			// page hasn't shown yet. Since we only want to show it if we have
			// markers for it we create a new BPELTabbedPropertySheetPage. This
			// new one should only be used to select which tab and section to show.
			// TODO: this doesn't work
			//propertySheetPage = createBPELTabbedPropertySheetPage();
		}

		TabbedPropertyViewer viewer = propertySheetPage.getTabbedPropertyViewer();

		int j = 0;
		while (true) { // while we don't get an exception...
			TabDescriptor descriptor = null;
			try {
				descriptor = (TabDescriptor)viewer.getElementAt(j++);
			} catch (IndexOutOfBoundsException iobe) {
				break;
			}

			if (descriptor == null) {
				break; // no more descriptors
			}

			TabContents tab = descriptor.createTab();
			ISection[] sections = tab.getSections();
			for (int i = 0; i < sections.length; i++) {

				if (BPELPropertySection.class.isInstance( sections[i]) == false) {
					continue;
				}

				BPELPropertySection section = (BPELPropertySection)sections[i];

				// HACK: we have to fake the initialization of this section in order to
				// make isValidMarker work. This section should not be used as a normal section.
				section.createControls(new Composite(getSite().getShell(), 0), propertySheetPage);
				section.setInput(this, new StructuredSelection(modelObject));

				if (section.isValidMarker (marker) ) {

					// the first section that handles this kind of marker wins
					showPropertiesView();
					// get real viewer, Tab and ISection objects since we are probably using fake ones
					viewer = this.currentPropertySheetPage.getTabbedPropertyViewer();
					viewer.setSelection(new StructuredSelection(descriptor));
					tab = this.currentPropertySheetPage.getCurrentTab();
					section = (BPELPropertySection)tab.getSectionAtIndex(i);
					section.gotoMarker(marker);
					return; // ignore other sections and tabs

				}
			}
		}
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite,
	 *      org.eclipse.ui.IEditorInput)
	 */

	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
		try {
			super.init(site, input);
			//			getCommandStack().addCommandStackListener(this);
		} catch (Exception e) {
			e.printStackTrace();
		}
		setPartName(input.getName());
	}

	protected void initializeFileChangeListener() {
		this.fileChangeListener = new IFileChangeListener() {
			public void deleted(IFile file) {
				IFile current = ((IFileEditorInput)getEditorInput()).getFile();
				if (current.equals(file)) {
					// Close the editor.
					Display display = getSite().getShell().getDisplay();
					display.asyncExec(new Runnable() {
						public void run() {
							getSite().getPage().closeEditor(BPELMultipageEditorPart.this, false);
						}
					});
				}
			}
			public void moved(IFile source, final IFile destination) {
//				IFile current = ((IFileEditorInput) getEditorInput()).getFile();
//				if (!current.equals(source)) {
//					return;
//				}
//				// update editors input
//				final IFileEditorInput input = new FileEditorInput(destination);
//				Display display = getDetailsEditor().getSite().getShell().getDisplay();
//				display.syncExec(new Runnable() {
//					public void run() {
//						getBPELDetailsEditor().setInput(input);
//						setInput(input);
//					}
//				});
//				// update resources
//				IPath path = destination.getFullPath();
//				URI uri = URI.createPlatformResourceURI(path.toString());
//				processResource.setURI(uri);
//				// JM: Comment out. We don't want to re-name the process just because
//				// the file name has changed
////				display.syncExec(new Runnable() {
////					public void run() {
////						BPELUtil.updateNameAndNamespace(destination, process);
////					}
////				});
//				path = path.removeFileExtension().addFileExtension(IBPELUIConstants.EXTENSION_MODEL_EXTENSIONS);
//				URI extensionsUri = URI.createPlatformResourceURI(path.toString());
//				extensionsResource = resourceSet.createResource(extensionsUri);
//				extensionsResource.setURI(extensionsUri);
//				try {
//					// JM: Comment out for now. We should re-test this
////					processResource.save(Collections.EMPTY_MAP);
////					destination.refreshLocal(IResource.DEPTH_ZERO, null);
//				} catch (Exception e) {
//					BPELUIPlugin.log(e);
//				}
			}
		};
		BPELUIPlugin.INSTANCE.getResourceChangeListener().addListener(this.fileChangeListener);
	}

	/**
	 * Installs the refactoring listener
	 */
	protected void initializeRefactoringListener() {
		final IWorkspace workspace = ResourcesPlugin.getWorkspace();
		this.postBuildRefactoringListener = new IResourceChangeListener() {
			public void resourceChanged(IResourceChangeEvent event) {
				IFile newFile = ((FileEditorInput)getEditorInput()).getFile();
				final IResourceDelta bpelFileDelta = event.getDelta().findMember(newFile.getFullPath());
				// we only care about the change if it is a move or a rename
				if (bpelFileDelta != null && (bpelFileDelta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
					getSite().getShell().getDisplay().syncExec(new Runnable() {
						public void run() {
							doRevertToSaved(null);
						}
					});
				}
			}
		};
		workspace.addResourceChangeListener(this.postBuildRefactoringListener, IResourceChangeEvent.POST_BUILD);

		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=330813
		// https://jira.jboss.org/browse/JBIDE-6365
		this.preBuildRefactoringListener = new RefactoringListener();
		workspace.addResourceChangeListener(this.preBuildRefactoringListener, IResourceChangeEvent.PRE_BUILD);
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
	 */

	public boolean isSaveAsAllowed() {
		return false;
	}

	protected void loadModel() throws CoreException {
		Document structuredDocument = null;

		try {
			IDocument doc = this.fTextEditor.getDocumentProvider().getDocument(getEditorInput());
			if (doc instanceof IStructuredDocument) {
				IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForEdit(doc);
				if (model == null) {
					model = StructuredModelManager.getModelManager().getModelForEdit((IStructuredDocument) doc);
				}
				if (model != null) {
					structuredDocument = ((IDOMModel) model).getDocument();
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		HashMap<String, Document> loadOptions = null;
		if (structuredDocument != null) {
			loadOptions = new HashMap<String, Document> (1);
			loadOptions.put("DOMDocument", structuredDocument);
		}

		//FIXME WSDLEditor has gef command stack; in order to have gef command stack we need to add design page first

		// Bug # 209341 - starting patch
		// By Vincent Zurczak
		IFile file = null;
		BPELEditModelClient editModelClient = new BPELEditModelClient(this);

		// Bugzilla 330513
		// first load the primary resource (the *.bpel file)
		boolean keepGoing = false;
		Shell shell = getEditorSite().getShell();
		try {
			file = getFileInput();
			editModelClient.loadPrimaryResource(file,loadOptions);
		}
		catch (RuntimeException ex) {
			String msg = NLS.bind(Messages.EditModelClient_bpel_load_error,
					new String[]{file.toString()}
			);

			keepGoing = MessageDialog.openQuestion(
					shell,
					Messages.EditModelClient_load_error_title,
					msg);

			if (!keepGoing)
				throw ex;
		}

		// next load the extensions resource (the *.bpelex file)
		try {
			editModelClient.loadExtensionsResource();
		}
		catch (RuntimeException ex) {
			file = editModelClient.getExtensionsFile();
			String msg = NLS.bind(Messages.EditModelClient_bpelex_load_error,
					new String[]{file.toString()}
			);

			keepGoing = MessageDialog.openQuestion(
					shell,
					Messages.EditModelClient_load_error_title,
					msg);

			if (!keepGoing)
				throw ex;

			try {
				file.delete(true, null);
				editModelClient.loadExtensionsResource();
			} catch (CoreException ce) {
				MessageDialog.openError(shell, Messages.EditModelClient_delete_error_title, Messages.EditModelClient_delete_error_message);
				throw ce;
			}
		}

		// finally load the artifacts resource (the *.wsdl file)
		try {
			editModelClient.loadArtifactsResource();
		}
		catch (RuntimeException ex) {
			file = editModelClient.getArtifactsFile();
			String msg = NLS.bind(Messages.EditModelClient_wsdl_load_error,
					new String[]{file.toString()}
			);

			keepGoing = MessageDialog.openQuestion(
					shell,
					Messages.EditModelClient_load_error_title,
					msg);

			if (!keepGoing)
				throw ex;

			try {
				file.delete(true, null);
				editModelClient.loadArtifactsResource();
			} catch (CoreException ce) {
				MessageDialog.openError(shell, Messages.EditModelClient_delete_error_title, Messages.EditModelClient_delete_error_message);
				throw ce;
			}
		}
		this.fDesignViewer.setEditModelClient(editModelClient);
		getEditDomain().setCommandStack(editModelClient.getCommandStack());

		Resource bpelResource = editModelClient.getPrimaryResourceInfo().getResource();
		BPELReader reader = new BPELReader();
		reader.read(bpelResource, getFileInput(), this.fDesignViewer.getResourceSet());
		// End of patch

		this.process = reader.getProcess();
		this.bpelModelReconcileAdapter = new BPELModelReconcileAdapter (structuredDocument, this.process, bpelResource, this.fDesignViewer);

		if (getEditDomain() != null) {
			((BPELEditDomain)getEditDomain()).setProcess(getProcess());
		}
		this.extensionsResource = reader.getExtensionsResource();
		this.extensionMap = reader.getExtensionMap();

		this.modelListenerAdapter = new ModelListenerAdapter();
		this.modelListenerAdapter.setExtensionMap(this.extensionMap);

		// Bugzilla 330519
		updateMarkersHard();
	}

	public void modelDeleted(ResourceInfo resourceInfo) {
		if (!isDirty()) {
			getSite().getPage().closeEditor(this, false);
		}
	}

	public void modelDirtyStateChanged(ResourceInfo resourceInfo) {
		firePropertyChange(PROP_DIRTY);
	}

	public void modelLocationChanged(ResourceInfo resourceInfo, IFile movedToFile) {
		// TODO!
		//updateInputFile(movedToFile.getFullPath());
	}

	public void modelReloaded(ResourceInfo resourceInfo) {
		Resource bpelResource = this.fDesignViewer.getEditModelClient().getPrimaryResourceInfo().getResource();

		IFile file = getFileInput();
		BPELReader reader = new BPELReader();
		reader.read(bpelResource, file, this.fDesignViewer.getResourceSet());

		this.process = reader.getProcess();
		if (getEditDomain() != null) {
			((BPELEditDomain)getEditDomain()).setProcess(getProcess());
		}
		this.extensionMap = reader.getExtensionMap();

		this.modelListenerAdapter.setExtensionMap(this.fDesignViewer.getExtensionMap());

		this.fDesignViewer.getGraphicalViewer().setContents(getProcess());

		// The ProcessTrayEditPart tries to remove its selection listener on deactivate.
		// In this case, it will fail because the edit part can't find the editor because
		// the process no longer belongs to a resource. Help it out and remove the
		// listener manually.
		ProcessTrayEditPart processTrayEditPart = (ProcessTrayEditPart)this.fDesignViewer.getTrayViewer().getContents();
		this.fDesignViewer.getGraphicalViewer().removeSelectionChangedListener(processTrayEditPart.getSelectionChangedListener());

		this.fDesignViewer.getTrayViewer().setContents(getProcess());

		//Bugzilla 294501 - When markers are added on the BPEL file, the meta-model
		//objects are notified about the marker change. But the display of the markers
		//on the diagram fails because of several invalid thread access exceptions.
		//Thus, encapsulating the marker update into a separate thread
		//Note: supposedly only happens on Galileo (== Eclipse 3.5)
		Display.getDefault().asyncExec( new Runnable() {
		    public void run() {
		    	updateMarkersHard();
		    }
		});

	}

	/**
	 * Erase and reload markers for the given model object.
	 * This will create the necessary adapters so that marker
	 * notifications are delegated to the correct activity displayed
	 * in the graphical viewer.
	 *
	 * @param modelObject
	 * @see Bugzilla 330519
	 */
	public void updateMarkers(EObject modelObject) {
		List<Long> removed = new ArrayList<Long>();
		for (Entry<Long, EObject> e : fMarkers2EObject.entrySet()){
			if (e.getValue() == modelObject)
				removed.add(e.getKey());
		}
		for (Long key : removed) {
			fMarkers2EObject.remove(key);
		}

		modelObject.eNotify(fMarkersStale);

		for (TreeIterator<EObject> iter=EcoreUtil.getAllContents((EObject)modelObject, true); iter.hasNext(); ){
			EObject obj = iter.next();
			BPELUtil.adapt(obj, IMarkerHolder.class);
		}

		IMarker[] markers = null;
		IFile file = getFileInput();
		Resource resource = getProcess().eResource();

		try {
			markers = file.findMarkers(null, true, IResource.DEPTH_ZERO);
		} catch (CoreException ex) {
			BPELUIPlugin.log(ex);
			return;
		}

		for (IMarker m : markers) {

			String href = null;
			EObject target = null;
			try {
				href = (String) m.getAttribute( "address.model" ); //$NON-NLS-1$
				if (href == null) {
					continue;
				}
				target = resource.getEObject(href);
			} catch (CoreException ex) {
				continue;
			}

			if (target == modelObject) {
				this.fMarkers2EObject.put(m.getId(), target);
				EObject obj = target;
				while (obj!=null) {
					BPELUtil.adapt(obj, IMarkerHolder.class);
					obj = obj.eContainer();
				}
				target.eNotify( new NotificationImpl (AdapterNotification.NOTIFICATION_MARKER_ADDED , null, m ));
			}
		}

	}

	protected void updateMarkersHard () {

		for(EObject obj : this.fMarkers2EObject.values()) {
			obj.eNotify(this.fMarkersStale);
		}

		this.fMarkers2EObject.clear();

		IMarker[] markers = null;
		IFile file = getFileInput();
		Resource resource = getProcess().eResource();

		try {
			markers = file.findMarkers(null, true, IResource.DEPTH_ZERO);
		} catch (CoreException ex) {
			BPELUIPlugin.log(ex);
			return;
		}

		for (IMarker m : markers) {

			String href = null;
			EObject target = null;
			try {
				href = (String) m.getAttribute( "address.model" ); //$NON-NLS-1$
				if (href == null) {
					continue;
				}
				target = resource.getEObject(href);
			} catch (CoreException ex) {
				continue;
			}
			if (target == null) {
				continue;
			}

			this.fMarkers2EObject.put(m.getId(), target);
			EObject obj = target;
			while (obj!=null) {
				BPELUtil.adapt(obj, IMarkerHolder.class);
				obj = obj.eContainer();
			}
			target.eNotify( new NotificationImpl (AdapterNotification.NOTIFICATION_MARKER_ADDED , null, m ));
		}

	}

	protected void pageChange(int newPageIndex) {
		this.currentPage = newPageIndex;
		super.pageChange(newPageIndex);
	}

	/**
	 * Sets the EditDomain for this EditorPart.
	 * @param ed the domain
	 */
	protected void setEditDomain(DefaultEditDomain ed) {
		this.editDomain = ed;
	}

	protected void showPropertiesView() {
		IWorkbench workbench = PlatformUI.getWorkbench();
		IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
		try {
			page.showView(IBPELUIConstants.PROPERTY_VIEW_ID);
		} catch (PartInitException e) {
			BPELUIPlugin.log(e);
		}
	}

	/**
	 * The editor part name should be the same as the one appearing in the logical view.
	 */
	protected void updateTitle() {
		setPartName(getProcess().getName());
	}

	public void modelMarkersChanged ( ResourceInfo resourceInfo , IMarkerDelta [] markerDelta ) {

		Resource resource = resourceInfo.getResource();

		for ( IMarkerDelta delta : markerDelta ) {

			String href = (String) delta.getAttribute( "address.model" ); //$NON-NLS-1$
			if (href == null) {
				continue;
			}

			EObject target = null;

			switch (delta.getKind()) {
			case IResourceDelta.ADDED :
				target = resource.getEObject(href);
				if (target != null) {
					this.fMarkers2EObject.put(delta.getId(),target);
					target.eNotify( new NotificationImpl(AdapterNotification.NOTIFICATION_MARKER_ADDED,null,delta.getMarker() ));
				}
				break;
			case IResourceDelta.CHANGED :
				target = this.fMarkers2EObject.remove(delta.getId());
				if (target != null) {
					target.eNotify( new NotificationImpl(AdapterNotification.NOTIFICATION_MARKER_CHANGED,delta.getMarker(),null));
				}
				break;
			case IResourceDelta.REMOVED :
				target = this.fMarkers2EObject.remove(delta.getId());
				if (target != null) {
					target.eNotify( new NotificationImpl(AdapterNotification.NOTIFICATION_MARKER_DELETED,delta.getMarker(),null));
				}
				break;
			}

		}
	}

	public boolean isDirty() {
		return this.fTextEditor.isDirty() || this.editDomain.getCommandStack().isDirty();
	}

	public IEditorPart getActiveEditor() {
		return super.getActiveEditor();
	}

	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=330813
	// https://jira.jboss.org/browse/JBIDE-6365
	// TODO: this is just a quick hack to get past the problem of import files being moved/renamed.
	// The proper way to do this is to implement the eclipse refactoring framework for bpel files.
	public class RefactoringListener implements IResourceChangeListener {

		public void resourceChanged(IResourceChangeEvent event) {

			IResourceDeltaVisitor dv = new IResourceDeltaVisitor() {

				public boolean visit(IResourceDelta delta) throws CoreException {
					IPath newPath = delta.getMovedToPath();
					if (delta.getKind()==IResourceDelta.REMOVED && newPath!=null) {
						// a file was moved or renamed - check if it's an imported file
						List<Import> imports = process.getImports();
						for (Import imp : imports)
						{
							IPath path = new Path(imp.getLocation());
							IPath folder = ((IFileEditorInput)getEditorInput()).getFile().getFullPath().removeLastSegments(1);
							if (!path.isAbsolute()) {
								// need absolute path
								path = folder.append(path);
							}
							if (path.equals(delta.getResource().getFullPath())) {
								IPath relPath = newPath.makeRelativeTo(folder);
								imp.setLocation(relPath.toString());

								Display.getDefault().asyncExec( new Runnable() {
								    public void run() {
										doSave(null);
								    }
								});
							}
						}
					}
					return true;
				}
			};

			try {
				event.getDelta().accept(dv);
			} catch (CoreException e) {
				BPELUIPlugin.log(e);
			}
		}

	}
}


text:
Übung 3

Frist: 28.10.2015

            137

        In Bearbeitung!

           0 / 45 erledigt!

Übung 2

            120
            / 240

        Korrigieren!

           40 korrigiert!

Übung 1

            Abgeschlossen

redpajama_set_name: RedPajamaGithub


text:
export const WEB_PORT = process.env.PORT || 8000
export const STATIC_PATH = '/static'
export const APP_NAME = 'Hello App'


text:
package tw.edu.sinica.iis.SSHadoop;

import java.io.IOException;
import java.io.OutputStream;
import java.util.concurrent.Callable;

import com.jcraft.jsch.Channel;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;

public class SSHShell implements Callable<String> {
	protected Session session = null;
	protected Channel channel = null;
	protected String execCommand = "";
	protected OutputStream shellStdout = null;

	public boolean execFinish = false;
	public int execStatus = -1;

	public SSHShell() {
	}

	public SSHShell(final Session sess, final String command) {
		setSession(sess);
		setCommand(command);
	}

	public void setSession(final Session sess) {
		session = sess;
	}

	public void setCommand(final String command) {
		execCommand = command;
	}

	protected void openChannel() {
		if (session != null && session.isConnected()) {
			try {
				channel = session.openChannel("shell");
				// if (channel != null) {
				// channel.setInputStream(System.in);
				// channel.setOutputStream(System.out);
				// }
			} catch (JSchException e) {
				e.printStackTrace();
			}
		}
	}

	protected void execChannel() {
		if (session != null && session.isConnected()) {
			if (channel != null) {
				try {
					channel.connect();

					shellStdout = channel.getOutputStream();
					shellStdout.write((execCommand + "\n").getBytes());
					shellStdout.flush();
				} catch (JSchException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

	protected void closeChannel() {
		if (channel != null && channel.isConnected()) {
			channel.disconnect();
		}
	}

	@Override
	public String call() throws Exception {
		openChannel();
		execChannel();
		// TODO: when we can close channel?
		// closeChannel();

		return "";
	}

}


text:
package ecologylab.bigsemantics.metadata;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;

import org.junit.Test;

import ecologylab.bigsemantics.generated.library.RepositoryMetadataTypesScope;
import ecologylab.bigsemantics.metadata.builtins.CreativeAct;
import ecologylab.bigsemantics.metadata.builtins.HtmlText;
import ecologylab.bigsemantics.metadata.builtins.RichArtifact;
import ecologylab.bigsemantics.metadata.builtins.person.author.IdeaMacheUser;
import ecologylab.net.ParsedURL;
import ecologylab.serialization.SIMPLTranslationException;
import ecologylab.serialization.SimplTypesScope;
import ecologylab.serialization.formatenums.StringFormat;

public class AnnotationSerializeDeserialize
{

	private static final SimplTypesScope	META_METADATA_TRANSLATIONS	= RepositoryMetadataTypesScope.get();

	RichArtifact<HtmlText> annotation;

	public AnnotationSerializeDeserialize() throws MalformedURLException
	{
		annotation = new RichArtifact<HtmlText>();
		HtmlText text = new HtmlText();
		text.setText("annotation. booyah!");
		text.setHtmlString("
annotation. booyah!
");
		annotation.setMedia(text);

		CreativeAct creativeAct = new CreativeAct();
		creativeAct.setAction(2);
		IdeaMacheUser creator = new IdeaMacheUser();
		creator.setTitle("andrew");
		creator.setLocation(new ParsedURL(new URL("http://ecologylab.net/people/andrew")));
		creativeAct.setCreator(creator);
		creativeAct.setTime(new Date());
		ArrayList<CreativeAct> creativeActs = new ArrayList<CreativeAct>();
		creativeActs.add(creativeAct);
		annotation.setCreativeActs(creativeActs);
	}

	@Test
	public void testAnnotationSerializeDeserialize()
	{
		try
		{
			StringBuilder serializedString = new StringBuilder();
			SimplTypesScope.serialize(annotation, serializedString, StringFormat.JSON);
			System.out.println(serializedString);

			Object deserialized = META_METADATA_TRANSLATIONS.deserialize(serializedString, StringFormat.JSON);
			serializedString = new StringBuilder();
			SimplTypesScope.serialize(deserialized, serializedString, StringFormat.JSON);
			System.out.println(serializedString);

		} catch (SIMPLTranslationException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public static void main(String[] args)
	{
		AnnotationSerializeDeserialize test;
		try
		{
			test = new AnnotationSerializeDeserialize();
			test.testAnnotationSerializeDeserialize();
		}
		catch (MalformedURLException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}


text:
My dotfiles

These dotfiles have been inspired by https://github.com/posquit0/vimrc


text:
package org.springframework.boot.build.mavenplugin;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Arrays;
import java.util.Properties;
import java.util.function.BiConsumer;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

import io.spring.javaformat.formatter.FileEdit;
import io.spring.javaformat.formatter.FileFormatter;
import org.gradle.api.DefaultTask;
import org.gradle.api.GradleException;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.artifacts.ComponentMetadataContext;
import org.gradle.api.artifacts.ComponentMetadataRule;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.ModuleVersionIdentifier;
import org.gradle.api.artifacts.VariantMetadata;
import org.gradle.api.artifacts.component.ModuleComponentIdentifier;
import org.gradle.api.artifacts.result.ResolvedArtifactResult;
import org.gradle.api.attributes.DocsType;
import org.gradle.api.attributes.Usage;
import org.gradle.api.file.CopySpec;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.plugins.JavaLibraryPlugin;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.publish.maven.MavenPublication;
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
import org.gradle.api.tasks.Classpath;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.JavaExec;
import org.gradle.api.tasks.OutputDirectory;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.PathSensitive;
import org.gradle.api.tasks.PathSensitivity;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.Sync;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.TaskExecutionException;
import org.gradle.api.tasks.bundling.Jar;
import org.gradle.api.tasks.javadoc.Javadoc;
import org.gradle.external.javadoc.StandardJavadocDocletOptions;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;

import org.springframework.boot.build.DeployedPlugin;
import org.springframework.boot.build.MavenRepositoryPlugin;
import org.springframework.boot.build.test.IntegrationTestPlugin;
import org.springframework.core.CollectionFactory;
import org.springframework.util.Assert;

/**
 * Plugin for building Spring Boot's Maven Plugin.
 *
 * @author Andy Wilkinson
 * @author Phillip Webb
 */
public class MavenPluginPlugin implements Plugin<Project> {

	@Override
	public void apply(Project project) {
		project.getPlugins().apply(JavaLibraryPlugin.class);
		project.getPlugins().apply(MavenPublishPlugin.class);
		project.getPlugins().apply(DeployedPlugin.class);
		project.getPlugins().apply(MavenRepositoryPlugin.class);
		project.getPlugins().apply(IntegrationTestPlugin.class);
		Jar jarTask = (Jar) project.getTasks().getByName(JavaPlugin.JAR_TASK_NAME);
		configurePomPackaging(project);
		addPopulateIntTestMavenRepositoryTask(project);
		MavenExec generateHelpMojoTask = addGenerateHelpMojoTask(project, jarTask);
		MavenExec generatePluginDescriptorTask = addGeneratePluginDescriptorTask(project, jarTask,
				generateHelpMojoTask);
		addDocumentPluginGoalsTask(project, generatePluginDescriptorTask);
		addPrepareMavenBinariesTask(project);
		addExtractVersionPropertiesTask(project);
	}

	private void configurePomPackaging(Project project) {
		PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
		publishing.getPublications().withType(MavenPublication.class, this::setPackaging);
	}

	private void setPackaging(MavenPublication mavenPublication) {
		mavenPublication.pom((pom) -> pom.setPackaging("maven-plugin"));
	}

	private void addPopulateIntTestMavenRepositoryTask(Project project) {
		Configuration runtimeClasspathWithMetadata = project.getConfigurations().create("runtimeClasspathWithMetadata");
		runtimeClasspathWithMetadata
				.extendsFrom(project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME));
		runtimeClasspathWithMetadata.attributes((attributes) -> attributes.attribute(DocsType.DOCS_TYPE_ATTRIBUTE,
				project.getObjects().named(DocsType.class, "maven-repository")));
		RuntimeClasspathMavenRepository runtimeClasspathMavenRepository = project.getTasks()
				.create("runtimeClasspathMavenRepository", RuntimeClasspathMavenRepository.class);
		runtimeClasspathMavenRepository.getOutputDirectory()
				.set(new File(project.getBuildDir(), "runtime-classpath-repository"));
		project.getDependencies()
				.components((components) -> components.all(MavenRepositoryComponentMetadataRule.class));
		Sync task = project.getTasks().create("populateIntTestMavenRepository", Sync.class);
		task.setDestinationDir(new File(project.getBuildDir(), "int-test-maven-repository"));
		task.with(copyIntTestMavenRepositoryFiles(project, runtimeClasspathMavenRepository));
		task.dependsOn(project.getTasks().getByName(MavenRepositoryPlugin.PUBLISH_TO_PROJECT_REPOSITORY_TASK_NAME));
		project.getTasks().getByName(IntegrationTestPlugin.INT_TEST_TASK_NAME).dependsOn(task);
	}

	private CopySpec copyIntTestMavenRepositoryFiles(Project project,
			RuntimeClasspathMavenRepository runtimeClasspathMavenRepository) {
		CopySpec copySpec = project.copySpec();
		copySpec.from(project.getConfigurations().getByName(MavenRepositoryPlugin.MAVEN_REPOSITORY_CONFIGURATION_NAME));
		copySpec.from(new File(project.getBuildDir(), "maven-repository"));
		copySpec.from(runtimeClasspathMavenRepository);
		return copySpec;
	}

	private void addDocumentPluginGoalsTask(Project project, MavenExec generatePluginDescriptorTask) {
		DocumentPluginGoals task = project.getTasks().create("documentPluginGoals", DocumentPluginGoals.class);
		File pluginXml = new File(generatePluginDescriptorTask.getOutputs().getFiles().getSingleFile(), "plugin.xml");
		task.setPluginXml(pluginXml);
		task.setOutputDir(new File(project.getBuildDir(), "docs/generated/goals/"));
		task.dependsOn(generatePluginDescriptorTask);
	}

	private MavenExec addGenerateHelpMojoTask(Project project, Jar jarTask) {
		File helpMojoDir = new File(project.getBuildDir(), "help-mojo");
		MavenExec task = createGenerateHelpMojoTask(project, helpMojoDir);
		task.dependsOn(createSyncHelpMojoInputsTask(project, helpMojoDir));
		includeHelpMojoInJar(jarTask, task);
		return task;
	}

	private MavenExec createGenerateHelpMojoTask(Project project, File helpMojoDir) {
		MavenExec task = project.getTasks().create("generateHelpMojo", MavenExec.class);
		task.setProjectDir(helpMojoDir);
		task.args("org.apache.maven.plugins:maven-plugin-plugin:3.6.1:helpmojo");
		task.getOutputs().dir(new File(helpMojoDir, "target/generated-sources/plugin"));
		return task;
	}

	private Sync createSyncHelpMojoInputsTask(Project project, File helpMojoDir) {
		Sync task = project.getTasks().create("syncHelpMojoInputs", Sync.class);
		task.setDestinationDir(helpMojoDir);
		File pomFile = new File(project.getProjectDir(), "src/maven/resources/pom.xml");
		task.from(pomFile, (copy) -> replaceVersionPlaceholder(copy, project));
		return task;
	}

	private void includeHelpMojoInJar(Jar jarTask, JavaExec generateHelpMojoTask) {
		jarTask.from(generateHelpMojoTask).exclude("**/*.java");
		jarTask.dependsOn(generateHelpMojoTask);
	}

	private MavenExec addGeneratePluginDescriptorTask(Project project, Jar jarTask, MavenExec generateHelpMojoTask) {
		File pluginDescriptorDir = new File(project.getBuildDir(), "plugin-descriptor");
		File generatedHelpMojoDir = new File(project.getBuildDir(), "generated/sources/helpMojo");
		SourceSet mainSourceSet = getMainSourceSet(project);
		project.getTasks().withType(Javadoc.class, this::setJavadocOptions);
		FormatHelpMojoSource formattedHelpMojoSource = createFormatHelpMojoSource(project, generateHelpMojoTask,
				generatedHelpMojoDir);
		project.getTasks().getByName(mainSourceSet.getCompileJavaTaskName()).dependsOn(formattedHelpMojoSource);
		mainSourceSet.java((javaSources) -> javaSources.srcDir(formattedHelpMojoSource));
		Sync pluginDescriptorInputs = createSyncPluginDescriptorInputs(project, pluginDescriptorDir, mainSourceSet);
		pluginDescriptorInputs.dependsOn(mainSourceSet.getClassesTaskName());
		MavenExec task = createGeneratePluginDescriptorTask(project, pluginDescriptorDir);
		task.dependsOn(pluginDescriptorInputs);
		includeDescriptorInJar(jarTask, task);
		return task;
	}

	private SourceSet getMainSourceSet(Project project) {
		SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
		return sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
	}

	private void setJavadocOptions(Javadoc javadoc) {
		StandardJavadocDocletOptions options = (StandardJavadocDocletOptions) javadoc.getOptions();
		options.addMultilineStringsOption("tag").setValue(Arrays.asList("goal:X", "requiresProject:X", "threadSafe:X"));
	}

	private FormatHelpMojoSource createFormatHelpMojoSource(Project project, MavenExec generateHelpMojoTask,
			File generatedHelpMojoDir) {
		FormatHelpMojoSource formatHelpMojoSource = project.getTasks().create("formatHelpMojoSource",
				FormatHelpMojoSource.class);
		formatHelpMojoSource.setGenerator(generateHelpMojoTask);
		formatHelpMojoSource.setOutputDir(generatedHelpMojoDir);
		return formatHelpMojoSource;
	}

	private Sync createSyncPluginDescriptorInputs(Project project, File destination, SourceSet sourceSet) {
		Sync pluginDescriptorInputs = project.getTasks().create("syncPluginDescriptorInputs", Sync.class);
		pluginDescriptorInputs.setDestinationDir(destination);
		File pomFile = new File(project.getProjectDir(), "src/maven/resources/pom.xml");
		pluginDescriptorInputs.from(pomFile, (copy) -> replaceVersionPlaceholder(copy, project));
		pluginDescriptorInputs.from(sourceSet.getOutput().getClassesDirs(), (sync) -> sync.into("target/classes"));
		pluginDescriptorInputs.from(sourceSet.getAllJava().getSrcDirs(), (sync) -> sync.into("src/main/java"));
		pluginDescriptorInputs.getInputs().property("version", project.getVersion());
		return pluginDescriptorInputs;
	}

	private MavenExec createGeneratePluginDescriptorTask(Project project, File mavenDir) {
		MavenExec generatePluginDescriptor = project.getTasks().create("generatePluginDescriptor", MavenExec.class);
		generatePluginDescriptor.args("org.apache.maven.plugins:maven-plugin-plugin:3.6.1:descriptor");
		generatePluginDescriptor.getOutputs().dir(new File(mavenDir, "target/classes/META-INF/maven"));
		generatePluginDescriptor.getInputs().dir(new File(mavenDir, "target/classes/org"))
				.withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("plugin classes");
		generatePluginDescriptor.setProjectDir(mavenDir);
		return generatePluginDescriptor;
	}

	private void includeDescriptorInJar(Jar jar, JavaExec generatePluginDescriptorTask) {
		jar.from(generatePluginDescriptorTask, (copy) -> copy.into("META-INF/maven/"));
		jar.dependsOn(generatePluginDescriptorTask);
	}

	private void addPrepareMavenBinariesTask(Project project) {
		PrepareMavenBinaries task = project.getTasks().create("prepareMavenBinaries", PrepareMavenBinaries.class);
		task.setOutputDir(new File(project.getBuildDir(), "maven-binaries"));
		project.getTasks().getByName(IntegrationTestPlugin.INT_TEST_TASK_NAME).dependsOn(task);
	}

	private void replaceVersionPlaceholder(CopySpec copy, Project project) {
		copy.filter((input) -> replaceVersionPlaceholder(project, input));
	}

	private String replaceVersionPlaceholder(Project project, String input) {
		return input.replace("{{version}}", project.getVersion().toString());
	}

	private void addExtractVersionPropertiesTask(Project project) {
		ExtractVersionProperties extractVersionProperties = project.getTasks().create("extractVersionProperties",
				ExtractVersionProperties.class);
		extractVersionProperties.setEffectiveBoms(project.getConfigurations().create("versionProperties"));
		extractVersionProperties.getDestination().set(project.getLayout().getBuildDirectory().dir("generated-resources")
				.map((dir) -> dir.file("extracted-versions.properties")));
	}

	public static class FormatHelpMojoSource extends DefaultTask {

		private Task generator;

		private File outputDir;

		void setGenerator(Task generator) {
			this.generator = generator;
			getInputs().files(this.generator).withPathSensitivity(PathSensitivity.RELATIVE)
					.withPropertyName("generated source");
		}

		@OutputDirectory
		public File getOutputDir() {
			return this.outputDir;
		}

		void setOutputDir(File outputDir) {
			this.outputDir = outputDir;
		}

		@TaskAction
		void syncAndFormat() {
			FileFormatter formatter = new FileFormatter();
			for (File output : this.generator.getOutputs().getFiles()) {
				formatter.formatFiles(getProject().fileTree(output), StandardCharsets.UTF_8)
						.forEach((edit) -> save(output, edit));
			}
		}

		private void save(File output, FileEdit edit) {
			Path relativePath = output.toPath().relativize(edit.getFile().toPath());
			Path outputLocation = this.outputDir.toPath().resolve(relativePath);
			try {
				Files.createDirectories(outputLocation.getParent());
				Files.writeString(outputLocation, edit.getFormattedContent());
			}
			catch (Exception ex) {
				throw new TaskExecutionException(this, ex);
			}
		}

	}

	public static class MavenRepositoryComponentMetadataRule implements ComponentMetadataRule {

		private final ObjectFactory objects;

		@javax.inject.Inject
		public MavenRepositoryComponentMetadataRule(ObjectFactory objects) {
			this.objects = objects;
		}

		@Override
		public void execute(ComponentMetadataContext context) {
			context.getDetails().maybeAddVariant("compileWithMetadata", "compile",
					(variant) -> configureVariant(context, variant));
			context.getDetails().maybeAddVariant("apiElementsWithMetadata", "apiElements",
					(variant) -> configureVariant(context, variant));
		}

		private void configureVariant(ComponentMetadataContext context, VariantMetadata variant) {
			variant.attributes((attributes) -> {
				attributes.attribute(DocsType.DOCS_TYPE_ATTRIBUTE,
						this.objects.named(DocsType.class, "maven-repository"));
				attributes.attribute(Usage.USAGE_ATTRIBUTE, this.objects.named(Usage.class, "maven-repository"));
			});
			variant.withFiles((files) -> {
				ModuleVersionIdentifier id = context.getDetails().getId();
				files.addFile(id.getName() + "-" + id.getVersion() + ".pom");
			});
		}

	}

	public static class RuntimeClasspathMavenRepository extends DefaultTask {

		private final Configuration runtimeClasspath;

		private final DirectoryProperty outputDirectory;

		public RuntimeClasspathMavenRepository() {
			this.runtimeClasspath = getProject().getConfigurations().getByName("runtimeClasspathWithMetadata");
			this.outputDirectory = getProject().getObjects().directoryProperty();
		}

		@OutputDirectory
		public DirectoryProperty getOutputDirectory() {
			return this.outputDirectory;
		}

		@Classpath
		public Configuration getRuntimeClasspath() {
			return this.runtimeClasspath;
		}

		@TaskAction
		public void createRepository() {
			for (ResolvedArtifactResult result : this.runtimeClasspath.getIncoming().getArtifacts()) {
				if (result.getId().getComponentIdentifier() instanceof ModuleComponentIdentifier identifier) {
					String fileName = result.getFile().getName()
							.replace(identifier.getVersion() + "-" + identifier.getVersion(), identifier.getVersion());
					File repositoryLocation = this.outputDirectory.dir(identifier.getGroup().replace('.', '/') + "/"
							+ identifier.getModule() + "/" + identifier.getVersion() + "/" + fileName).get()
							.getAsFile();
					repositoryLocation.getParentFile().mkdirs();
					try {
						Files.copy(result.getFile().toPath(), repositoryLocation.toPath(),
								StandardCopyOption.REPLACE_EXISTING);
					}
					catch (IOException ex) {
						throw new RuntimeException("Failed to copy artifact '" + result + "'", ex);
					}
				}
			}
		}

	}

	public static class ExtractVersionProperties extends DefaultTask {

		private final RegularFileProperty destination;

		private FileCollection effectiveBoms;

		public ExtractVersionProperties() {
			this.destination = getProject().getObjects().fileProperty();
		}

		@InputFiles
		@PathSensitive(PathSensitivity.RELATIVE)
		public FileCollection getEffectiveBoms() {
			return this.effectiveBoms;
		}

		public void setEffectiveBoms(FileCollection effectiveBoms) {
			this.effectiveBoms = effectiveBoms;
		}

		@OutputFile
		public RegularFileProperty getDestination() {
			return this.destination;
		}

		@TaskAction
		public void extractVersionProperties() {
			EffectiveBom effectiveBom = new EffectiveBom(this.effectiveBoms.getSingleFile());
			Properties versions = extractVersionProperties(effectiveBom);
			writeProperties(versions);
		}

		private void writeProperties(Properties versions) {
			File outputFile = this.destination.getAsFile().get();
			outputFile.getParentFile().mkdirs();
			try (Writer writer = new FileWriter(outputFile)) {
				versions.store(writer, null);
			}
			catch (IOException ex) {
				throw new GradleException("Failed to write extracted version properties", ex);
			}
		}

		private Properties extractVersionProperties(EffectiveBom effectiveBom) {
			Properties versions = CollectionFactory.createSortedProperties(true);
			versions.setProperty("project.version", effectiveBom.version());
			effectiveBom.property("log4j2.version", versions::setProperty);
			effectiveBom.property("maven-jar-plugin.version", versions::setProperty);
			effectiveBom.property("maven-war-plugin.version", versions::setProperty);
			effectiveBom.property("build-helper-maven-plugin.version", versions::setProperty);
			effectiveBom.property("spring-framework.version", versions::setProperty);
			effectiveBom.property("jakarta-servlet.version", versions::setProperty);
			effectiveBom.property("kotlin.version", versions::setProperty);
			effectiveBom.property("assertj.version", versions::setProperty);
			effectiveBom.property("junit-jupiter.version", versions::setProperty);
			return versions;
		}

	}

	private static final class EffectiveBom {

		private final Document document;

		private final XPath xpath;

		private EffectiveBom(File bomFile) {
			this.document = loadDocument(bomFile);
			this.xpath = XPathFactory.newInstance().newXPath();
		}

		private Document loadDocument(File bomFile) {
			try {
				try (InputStream inputStream = new FileInputStream(bomFile)) {
					DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
					DocumentBuilder builder = builderFactory.newDocumentBuilder();
					return builder.parse(inputStream);
				}
			}
			catch (ParserConfigurationException | SAXException | IOException ex) {
				throw new IllegalStateException(ex);
			}
		}

		private String version() {
			return get("version");
		}

		private void property(String name, BiConsumer<String, String> handler) {
			handler.accept(name, get("properties/" + name));
		}

		private String get(String expression) {
			try {
				Node node = (Node) this.xpath.compile("/project/" + expression).evaluate(this.document,
						XPathConstants.NODE);
				String text = (node != null) ? node.getTextContent() : null;
				Assert.hasLength(text, () -> "No result for expression " + expression);
				return text;
			}
			catch (XPathExpressionException ex) {
				throw new IllegalStateException(ex);
			}
		}

	}

}


text:
/**
 * Created by Newton on 2014/4/23.
 */
var TokenType = {};
Object.defineProperties(TokenType, {
  StringSQ: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'StringSQ'
  },
  StringDQ: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'StringDQ'
  },
  CommentML: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'CommentML'
  },
  CommentSL: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'CommentSL'
  },
  Newline: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'Newline'
  },
  Enter: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'Enter'
  },
  Space: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'Space'
  },
  Tab: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'Tab'
  },
  // !
  ExclamationMark: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'ExclamationMark'
  },
  // "
  QuotationMark: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'QuotationMark'
  },
  // #
  NumberSign: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'NumberSign'
  },
  // $
  DollarSign: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'DollarSign'
  },
  // %
  PercentSign: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'PercentSign'
  },
  // &
  Ampersand: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'Ampersand'
  },
  // '
  Apostrophe: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'Apostrophe'
  },
  // (
  LeftParenthesis: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'LeftParenthesis'
  },
  // )
  RightParenthesis: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'RightParenthesis'
  },
  // *
  Asterisk: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'Asterisk'
  },
  // +
  PlusSign: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'PlusSign'
  },
  // ,
  Comma: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'Comma'
  },
  // -
  HyphenMinus: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'HyphenMinus'
  },
  // .
  FullStop: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'FullStop'
  },
  // /
  Solidus: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'Solidus'
  },
  // :
  Colon: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'Colon'
  },
  // ;
  Semicolon: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'Semicolon'
  },
  // <
  LessThanSign: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'LessThanSign'
  },
  // =
  EqualsSign: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'EqualsSign'
  },
  // >
  GreaterThanSign: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'GreaterThanSign'
  },
  // ?
  QuestionMark: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'QuestionMark'
  },
  // @
  CommercialAt: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'CommercialAt'
  },
  // [
  LeftSquareBracket: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'LeftSquareBracket'
  },
  // \
  ReverseSolidus: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'ReverseSolidus'
  },
  // ]
  RightSquareBracket: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'RightSquareBracket'
  },
  // ^
  CircumflexAccent: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'CircumflexAccent'
  },
  // _
  LowLine: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'LowLine'
  },
  // {
  LeftCurlyBracket: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'LeftCurlyBracket'
  },
  // |
  VerticalLine: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'VerticalLine'
  },
  // }
  RightCurlyBracket: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'RightCurlyBracket'
  },
  // ~
  Tilde: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'Tilde'
  },
  Identifier: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'Identifier'
  },
  DecimalNumber: {
    enumerable: true,
    configurable: false,
    writable: false,
    value: 'DecimalNumber'
  }
});

module.exports = TokenType;


text:
echo2() {
    echo $@ >&2
}

trap end 0
end() {
    [ "$?" = 0 ] && echo2 "Pass." || (echo2 "Fail."; exit 1)
}

cross() {
    os=$1
    shift
    echo2 "Build for $os."
    for arch in $@; do
      echo2 "  - $os/$arch"
      GOOS=$os GOARCH=$arch go build
    done
    echo2
}

set -e

cross linux     amd64 386 arm arm64 ppc64 ppc64le s390x mips mipsle mips64 mips64le
cross darwin    amd64 arm64
cross freebsd   amd64 386 arm arm64
cross netbsd    amd64 386 arm arm64
cross openbsd   amd64 386 arm arm64
cross dragonfly amd64
cross solaris   amd64

# Not expected to work but should still compile.
cross windows amd64 386 arm

# TODO: Fix compilation error on openbsd/arm.
# TODO: Merge the solaris PR.

# Some os/arch require a different compiler. Run in docker.
if ! hash docker; then
    # If docker is not present, stop here.
    return
fi

echo2 "Build for linux."
echo2 "  - linux/riscv"
docker build -t creack-pty-test -f Dockerfile.riscv .

# Golang dropped support for darwin 32bits since go1.15. Make sure the lib still compile with go1.14 on those archs.
echo2 "Build for darwin (32bits)."
echo2 "  - darwin/386"
docker build -t creack-pty-test -f Dockerfile.golang --build-arg=GOVERSION=1.14 --build-arg=GOOS=darwin --build-arg=GOARCH=386 .
echo2 "  - darwin/arm"
docker build -t creack-pty-test -f Dockerfile.golang --build-arg=GOVERSION=1.14 --build-arg=GOOS=darwin --build-arg=GOARCH=arm .

# Run a single test for an old go version. Would be best with go1.0, but not available on Dockerhub.
# Using 1.6 as it is the base version for the RISCV compiler.
# Would also be better to run all the tests, not just one, need to refactor this file to allow for specifc archs per version.
echo2 "Build for linux - go1.6."
echo2 "  - linux/amd64"
docker build -t creack-pty-test -f Dockerfile.golang --build-arg=GOVERSION=1.6 --build-arg=GOOS=linux --build-arg=GOARCH=amd64 .


text:
package com.codeprep.easyops.dto;

import org.springframework.stereotype.Component;

@Component
public class StateDTO implements BaseDTO {

	private Integer stateId;
	private String State;

	public Integer getStateId() {
		return stateId;
	}

	public void setStateId(Integer stateId) {
		this.stateId = stateId;
	}

	public String getState() {
		return State;
	}

	public void setState(String state) {
		State = state;
	}

}


text:
<!DOCTYPE html>

    <title></title>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/semantic.min.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/blueimp-gallery.min.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/default.css') }}">

                 Upload
                 Galleries
                 Help
                 Logout

            {% block content %}{% endblock %}

                Drop your images in this area to upload

 Cancel

 Save


text:
{-# LANGUAGE RankNTypes, TypeApplications #-}

module VtaCoerce where

import Data.Coerce (coerce)

newtype Age = Age Int

convert :: Int -> Age
convert = coerce @Int @Age


text:
<?php

?>
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>White DB</title>

    <link href="../css/bootstrap.min.css" rel="stylesheet">

    <link href="../css/sb-admin.css" rel="stylesheet">

    <link href="../font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">

                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                    Toggle navigation

                </button>
                white DB

                     <?php  ?>

                             Log Out

                         Productos

                         Perfil

                         Cotización

                         Pedidos

                         FAQ

                         Chat


text:
<?php
/**
 * see http://unstats.un.org/unsd/methods/m49/m49alpha.htm
 * see http://www.foreignword.com/countries/  for a comprehensive list, with translations
 * see http://susning.nu/Landskod  (list #7) for another list, taken from ISO standards
 * see http://helpdesk.rootsweb.com/codes for a comprehensive list of Chapman codes.
 * see http://www.rootsweb.com/~wlsgfhs/ChapmanCodes.htm for another list of Chapman codes
 *
 * The list that follows is the list of Chapman country codes, with additions from the
 * other sources mentioned above.
 *
 * These codes do not appear in the two Chapman lists cited:
 *		ALA		Åland Islands
 *		CAT		Catalonia
 *		COD		Congo (Brazzaville)		This country was known as Zaire
 *		NFK		Norfolk Island
 *		PRI		Puerto Rico				Chapman lists this as a state of the USA
 *		SCG		Serbia and Montenegro	Chapman lists these separately
 *		TLS		Timor-Leste
 *		UMI		US Minor Outlying Islands
 *		VIR		US Virgin Islands		Chapman lists this as a state of the USA
 *
 * These Chapman country codes do not appear in the list following:
 *		UEL		United Empire Loyalist		This is NOT a country or region, it's
 *											a group of people
 *		UK		United Kingdom				This is the only two-letter country code,
 *											and GBR or one of its components should be
 *											used instead.
 *		SLK		Slovakia					This code, listed in the last source cited,
 *											should be SVK
 *		SLO		Slovenia					This code, listed in the last source cited,
 *											should be SVN
 *		SAM		South America				This code, listed in the last source cited,
 *											is not precise enough
 *		TMP		East Timor					Official name is TLS "Timor-Leste"
 *		HOL		Holland						Official name is NLD "Netherlands"
 *		ESM		Western Samoa				Official name is WSM "Samoa"
 *
 * # $Id: countries.no.php 4944 2009-01-29 03:04:28Z canajun2eh $
 *
 * @translator Geir Håkon Eikland
 * @translator Thomas Rindal
 * @package PhpGedView
 * @subpackage Languages
 */

if (!defined('PGV_PHPGEDVIEW')) {
	header('HTTP/1.0 403 Forbidden');
	exit;
}

$countries["ABW"]="Aruba";
$countries["ACA"]="Akadia";
$countries["AFG"]="Afghanistan";
$countries["AGO"]="Angola";
$countries["AIA"]="Anguilla";
$countries["ALA"]="Åland";
$countries["ALB"]="Albania";
$countries["AND"]="Andorra";
$countries["ANT"]="De nederlandske antiller";
$countries["ARE"]="De forente arabiske emirater";
$countries["ARG"]="Argentina";
$countries["ARM"]="Armenia";
$countries["ASM"]="Amerikansk Samoa";
$countries["ATA"]="Antarktis";
$countries["ATF"]="De franske sørterritorier";
$countries["ATG"]="Antigua og Barbuda";
$countries["AUS"]="Australia";
$countries["AUT"]="Østerrike";
$countries["AZR"]="Asorene";
$countries["AZE"]="Aserbajdsjan";
$countries["BDI"]="Burundi";
$countries["BEL"]="Belgia";
$countries["BEN"]="Benin";
$countries["BFA"]="Burkina Faso";
$countries["BGD"]="Bangladesh";
$countries["BGR"]="Bulgaria";
$countries["BHR"]="Bahrain";
$countries["BHS"]="Bahamas";
$countries["BIH"]="Bosnia-Hercegovina";
$countries["BLR"]="Hviterussland";
$countries["BLZ"]="Belize";
$countries["BMU"]="Bermuda";
$countries["BOL"]="Bolivia";
$countries["BRA"]="Brasil";
$countries["BRB"]="Barbados";
$countries["BRN"]="Brunei";
$countries["BTN"]="Bhutan";
$countries["BVT"]="Bouvetøya";
$countries["BWA"]="Botswana";
$countries["BWI"]="Britisk Vestindia";
$countries["CAF"]="Den sentralafrikanske republikk";
$countries["CAN"]="Canada";
$countries["CAP"]="Kappkolonien";
$countries["CAT"]="Catalonia";
$countries["CCK"]="Kokosøyene";
$countries["CHE"]="Sveits";
$countries["CHI"]="Kanaløyene";
$countries["CHL"]="Chile";
$countries["CHN"]="Kina";
$countries["CIV"]="Elfenbeinskysten";
$countries["CMR"]="Kamerun";
$countries["COD"]="Kongo";
$countries["COG"]="Kongo-Brazaville";
$countries["COK"]="Cookøyene";
$countries["COL"]="Colombia";
$countries["COM"]="Komorene";
$countries["CPV"]="Kapp Verde";
$countries["CRI"]="Costa Rica";
$countries["CSK"]="Tsjekkoslovakia";
$countries["CUB"]="Cuba";
$countries["CXR"]="Juløya";
$countries["CYM"]="Caymanøyene";
$countries["CYP"]="Kypros";
$countries["CZE"]="Tsjekkia";
$countries["DEU"]="Tyskland";
$countries["DJI"]="Djibouti";
$countries["DMA"]="Dominica";
$countries["DNK"]="Danmark";
$countries["DOM"]="Den dominikanske republikk";
$countries["DZA"]="Algerie";
$countries["ECU"]="Ecuador";
$countries["EGY"]="Egypt";
$countries["EIR"]="Eire";
$countries["ENG"]="England";
$countries["ERI"]="Eritrea";
$countries["ESH"]="Vest-Sahara";
$countries["ESP"]="Spania";
$countries["EST"]="Estland";
$countries["ETH"]="Etiopia";
$countries["FIN"]="Finland";
$countries["FJI"]="Fiji";
$countries["FLD"]="Flandern";
$countries["FLK"]="Falklandsøyene";
$countries["FRA"]="Frankrike";
$countries["FRO"]="Færøyene";
$countries["FSM"]="Mikronesiaføderasjonen";
$countries["GAB"]="Gabon";
$countries["GBR"]="Storbritannia";
$countries["GEO"]="Georgia";
$countries["GHA"]="Ghana";
$countries["GIB"]="Gibraltar";
$countries["GIN"]="Guinea";
$countries["GLP"]="Guadeloupe";
$countries["GMB"]="Gambia";
$countries["GNB"]="Guinea Bissau";
$countries["GNQ"]="Ekvatorial-Guinea";
$countries["GRC"]="Hellas";
$countries["GRD"]="Grenada";
$countries["GRL"]="Grønland";
$countries["GTM"]="Guatemala";
$countries["GUF"]="Fransk Guyana";
$countries["GUM"]="Guam";
$countries["GUY"]="Guyana";
$countries["HKG"]="Hong Kong";
$countries["HMD"]="Heard- og McDonald-øyene";
$countries["HND"]="Honduras";
$countries["HRV"]="Kroatia";
$countries["HTI"]="Haiti";
$countries["HUN"]="Ungarn";
$countries["IDN"]="Indonesia";
$countries["IND"]="India";
$countries["IOT"]="Britisk territorium i Indiahavet";
$countries["IRL"]="Irland";
$countries["IRN"]="Iran";
$countries["IRQ"]="Irak";
$countries["ISL"]="Island";
$countries["ISR"]="Israel";
$countries["ITA"]="Italia";
$countries["JAM"]="Jamaica";
$countries["JOR"]="Jordan";
$countries["JPN"]="Japan";
$countries["KAZ"]="Kazakstan";
$countries["KEN"]="Kenya";
$countries["KGZ"]="Kirgizistan";
$countries["KHM"]="Kambodja";
$countries["KIR"]="Kiribati";
$countries["KNA"]="St. Kitts og Nevis";
$countries["KOR"]="Sør-Korea";
$countries["KWT"]="Kuwait";
$countries["LAO"]="Laos";
$countries["LBN"]="Libanon";
$countries["LBR"]="Liberia";
$countries["LBY"]="Libya";
$countries["LCA"]="St. Lucia";
$countries["LIE"]="Liechtenstein";
$countries["LKA"]="Sri Lanka";
$countries["LSO"]="Lesotho";
$countries["LTU"]="Litauen";
$countries["LUX"]="Luxemburg";
$countries["LVA"]="Latvia";
$countries["MAC"]="Macao";
$countries["MAR"]="Marokko";
$countries["MCO"]="Monaco";
$countries["MDA"]="Moldavia";
$countries["MDG"]="Madagaskar";
$countries["MDV"]="Maldivane";
$countries["MEX"]="Mexiko";
$countries["MHL"]="Marshalløyene";
$countries["MKD"]="Makedonia";
$countries["MLI"]="Mali";
$countries["MLT"]="Malta";
$countries["MMR"]="Myanmar";
$countries["MNG"]="Mongolia";
$countries["MNP"]="Nord-Marianene";
$countries["MNT"]="Montenegro";
$countries["MOZ"]="Mosambik";
$countries["MRT"]="Mauretania";
$countries["MSR"]="Montserrat";
$countries["MTQ"]="Martinique";
$countries["MUS"]="Mauritius";
$countries["MWI"]="Malawi";
$countries["MYS"]="Malaysia";
$countries["MYT"]="Mayotte";
$countries["NAM"]="Namibia";
$countries["NCL"]="Ny-Caledonia";
$countries["NER"]="Niger";
$countries["NFK"]="Norfolkøya";
$countries["NGA"]="Nigeria";
$countries["NIC"]="Nicaragua";
$countries["NIR"]="Nord-Irland";
$countries["NIU"]="Niue";
$countries["NLD"]="Nederland";
$countries["NOR"]="Norge";
$countries["NPL"]="Nepal";
$countries["NRU"]="Nauru";
$countries["NTZ"]="Nøytralsonen";
$countries["NZL"]="New Zealand";
$countries["OMN"]="Oman";
$countries["PAK"]="Pakistan";
$countries["PAN"]="Panama";
$countries["PCN"]="Pitcairnøyene";
$countries["PER"]="Peru";
$countries["PHL"]="Filippinene";
$countries["PLW"]="Palau";
$countries["PNG"]="Papua Ny-Guinea";
$countries["POL"]="Polen";
$countries["PRI"]="Puerto Rico";
$countries["PRK"]="Nord-Korea";
$countries["PRT"]="Portugal";
$countries["PRY"]="Paraguay";
$countries["PSE"]="Palestina";
$countries["PYF"]="Fransk Polynesia";
$countries["QAT"]="Qatar";
$countries["REU"]="Reunion";
$countries["ROM"]="Romania";
$countries["RUS"]="Russland";
$countries["RWA"]="Rwanda";
$countries["SAU"]="Saudi-Arabia";
$countries["SCG"]="Serbia og Montenegro";
$countries["SCT"]="Skottland";
$countries["SDN"]="Sudan";
$countries["SEA"]="Til sjøs";
$countries["SEN"]="Senegal";
$countries["SER"]="Serbia";
$countries["SGP"]="Singapore";
$countries["SGS"]="Sør-Georgia og Sør-Sandwichøyene";
$countries["SHN"]="St. Helena";
$countries["SIC"]="Sicilia";
$countries["SJM"]="Svalbard og Jan Mayen";
$countries["SLB"]="Salomonyene";
$countries["SLE"]="Sierra Leone";
$countries["SLV"]="El Salvador";
$countries["SMR"]="San Marino";
$countries["SOM"]="Somalia";
$countries["SPM"]="St. Pierre og Miquelon";
$countries["STP"]="São Tomé og Príncipe";
$countries["SUN"]="USSR";
$countries["SUR"]="Surinam";
$countries["SVK"]="Slovakia";
$countries["SVN"]="Slovenia";
$countries["SWE"]="Sverige";
$countries["SWZ"]="Swaziland";
$countries["SYC"]="Seychellene";
$countries["SYR"]="Syria";
$countries["TCA"]="Turks- og Caicosøyene";
$countries["TCD"]="Tsjad";
$countries["TGO"]="Togo";
$countries["THA"]="Thailand";
$countries["TJK"]="Tajikistan";
$countries["TKL"]="Tokelau";
$countries["TKM"]="Turkmenistan";
$countries["TLS"]="Øst-Timor";
$countries["TON"]="Tonga";
$countries["TRN"]="Transylvania";
$countries["TTO"]="Trinidad og Tobago";
$countries["TUN"]="Tunisia";
$countries["TUR"]="Turkia";
$countries["TUV"]="Tuvalu";
$countries["TWN"]="Taiwan";
$countries["TZA"]="Tanzania";
$countries["UGA"]="Uganda";
$countries["UKR"]="Ukraina";
$countries["UMI"]="USA mindre utenforliggende øyer";
$countries["URY"]="Uruguay";
$countries["USA"]="USA";
$countries["UZB"]="Usbekistan";
$countries["VAT"]="Vatikanstaten";
$countries["VCT"]="St. Vincent og Grenadinene";
$countries["VEN"]="Venezuela";
$countries["VGB"]="Jomfruøyene (UK)";
$countries["VIR"]="Jomfruøyene (USA)";
$countries["VNM"]="Vietnam";
$countries["VUT"]="Vanuatu";
$countries["WAF"]="Vest-Afrika";
$countries["WLF"]="Wallis- og Futunaøyene";
$countries["WLS"]="Wales";
$countries["WSM"]="Samoa";
$countries["YEM"]="Jemen";
$countries["YUG"]="Jugoslavia";
$countries["ZAF"]="Sør-Afrika";
$countries["ZAR"]="Zaire";
$countries["ZMB"]="Zambia";
$countries["ZWE"]="Zimbabwe";
$countries["???"]="Ukjent";

/*
 * The following table lists alternate names for various Chapman codes.
 * It will be used when country names have to be converted to Chapman codes.
 * You do not have to list all the possibilities in all page languages.  This
 * will be done automatically by the country-to-Chapman conversion routine.
 *
 * Because the list, and its contents, are specific to each language, the
 * Translator Tool won't let you work on the list directly.  The list will
 * have to be updated and amended manually.
 *
 * Suppose Chapman code "XYZ" represents the same country, and that country
 * had the names "Name1", "Name2", "Name3" in its history.  It is now known
 * as "Current name".  You can list the various names like this:
 *
 * ##$countries["XYZ"]="Current name";
 * $altCountryName["XYZ"]="Name1; Name2; Name3";
 *
 * The Chapman-to-country conversion will always use the $countries list of
 * the current page language, no matter what the original country name was.
 *
 */
$altCountryNames["COD"]="Zaïre";
$altCountryNames["DEU"]="Øst-Tyskland; Vest-Tyskland; DDR; GER";
$altCountryNames["FLK"]="Malvinene";
$altCountryNames["GBR"]="Storbritania";
$altCountryNames["LKA"]="Ceylon";
$altCountryNames["MAC"]="Macao";
$altCountryNames["MMR"]="Burma";
$altCountryNames["NLD"]="Holland";
$altCountryNames["PLW"]="Belau";
$altCountryNames["SUN"]="Sovjetunionen";
$altCountryNames["TLS"]="Øst-Timor";
$altCountryNames["VAT"]="Vatikanet";
$altCountryNames["WSM"]="Vest-Samoa";

?>