<commit_before>/**
 * ***************************************************************
 * Agent.GUI is a framework to develop Multi-agent based simulation 
 * applications based on the JADE - Framework in compliance with the 
 * FIPA specifications. 
 * Copyright (C) 2010 <NAME> and DAWIS
 * http://www.dawis.wiwi.uni-due.de
 * http://sourceforge.net/projects/agentgui/
 * http://www.agentgui.org 
 *
 * GNU Lesser General Public License
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation,
 * version 2.1 of the License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA  02111-1307, USA.
 * **************************************************************
 */
package agentgui.core.project;

import java.awt.Component;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.io.Writer;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Observable;
import java.util.Vector;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JDesktopPane;
import javax.swing.JOptionPane;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import org.agentgui.gui.AwbProjectEditorWindow;
import org.agentgui.gui.AwbProjectEditorWindow.ProjectCloseUserFeedback;
import org.agentgui.gui.UiBridge;
import org.agentgui.gui.swing.project.ProjectWindow;
import org.agentgui.gui.swing.project.ProjectWindowTab;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;

import agentgui.core.application.Application;
import agentgui.core.application.Language;
import agentgui.core.classLoadService.ClassLoadServiceUtility;
import agentgui.core.config.GlobalInfo.ExecutionEnvironment;
import agentgui.core.config.GlobalInfo.ExecutionMode;
import agentgui.core.environment.EnvironmentController;
import agentgui.core.environment.EnvironmentPanel;
import agentgui.core.environment.EnvironmentType;
import agentgui.core.gui.components.JPanel4Visualization;
import agentgui.core.gui.projectwindow.simsetup.TimeModelController;
import agentgui.core.plugin.PlugIn;
import agentgui.core.plugin.PlugInLoadException;
import agentgui.core.plugin.PlugInNotification;
import agentgui.core.plugin.PlugInsLoaded;
import agentgui.core.project.setup.SimulationSetupNotification;
import agentgui.core.project.setup.SimulationSetupNotification.SimNoteReason;
import agentgui.core.project.setup.SimulationSetups;
import agentgui.core.project.transfer.ProjectExportController;
import agentgui.core.project.transfer.ProjectExportControllerProvider;
import agentgui.core.project.transfer.ProjectExportSettings;
import agentgui.core.update.ProjectRepositoryExport;
import agentgui.core.update.ProjectRepositoryUpdate;
import de.enflexit.common.classLoadService.ObjectInputStreamForClassLoadService;
import de.enflexit.common.featureEvaluation.FeatureInfo;
import de.enflexit.common.ontology.AgentStartConfiguration;
import de.enflexit.common.ontology.OntologyVisualisationHelper;
import de.enflexit.common.p2.P2OperationsHandler;

/**
 * This is the class, which holds all necessary informations about a project.<br>
 * In order to allow multiple access to the instance of Project, we designed it <br>
 * in the common <b>MVC pattern</b> (Model-View-Controller)<br>
 * 
 * @author <NAME> - DAWIS - ICB - University of Duisburg - Essen
 */
@XmlRootElement public class Project extends Observable {

	// --- public statics --------------------------------------
	@XmlTransient public static final String PREPARE_FOR_SAVING = "ProjectPrepare4Saving";
	@XmlTransient public static final String SAVED = "ProjectSaved";
	@XmlTransient public static final String CHANGED_ProjectName = "ProjectName";
	@XmlTransient public static final String CHANGED_ProjectDescription = "ProjectDescription";
	@XmlTransient public static final String CHANGED_ProjectView = "ProjectView";
	@XmlTransient public static final String CHANGED_ProjectStartTab = "ProjectStartTab";
	@XmlTransient public static final String CHANGED_ProjectFolder= "ProjectFolder";

	@XmlTransient public static final String CHANGED_VersionTag = "VersionTag";
	@XmlTransient public static final String CHANGED_Version = "Version";
	@XmlTransient public static final String CHANGED_UpdateAutoConfiguration= "UpdateAutoConfiguration";
	@XmlTransient public static final String CHANGED_UpdateSite = "UpdateSite";
	@XmlTransient public static final String CHANGED_UpdateDateLastChecked= "UpdateDateLastChecked";

	@XmlTransient public static final String CHANGED_EnvironmentModelType= "EnvironmentModelType";
	@XmlTransient public static final String CHANGED_StartArguments4BaseAgent = "StartArguments4BaseAgents";
	@XmlTransient public static final String CHANGED_TimeModelClass = "TimeModelConfiguration";
	@XmlTransient public static final String CHANGED_ProjectOntology = "ProjectOntology";
	@XmlTransient public static final String CHANGED_ProjectResources = "ProjectResources";
	@XmlTransient public static final String CHANGED_ProjectFeatures = "ProjectFeatures";
	@XmlTransient public static final String CHANGED_JadeConfiguration = "JadeConfiguration";
	@XmlTransient public static final String CHANGED_DistributionSetup = "DistributionSetup";
	@XmlTransient public static final String CHANGED_RemoteContainerConfiguration = "RemoteContainerConfiguration";
	@XmlTransient public static final String CHANGED_UserRuntimeObject = "UserRuntimeObject";

	// --- Constant value in order to set the project view ----------
	@XmlTransient public static final String VIEW_Developer = "Developer";
	@XmlTransient public static final String VIEW_User = "User";
	@XmlTransient public static final String VIEW_Maximize = "MaximizeView";
	@XmlTransient public static final String VIEW_Restore = "RestoreView";
	@XmlTransient public static final String VIEW_TabsLoaded = "TabsLoaded";

	// --- Constants for the the agent distribution metric ----------
	@XmlTransient public static final String AGENT_METRIC_Reset = "AgentMetric_Reset";
	@XmlTransient public static final String AGENT_METRIC_ChangedDataSource = "AgentMetric_ChangedDataSource";
	@XmlTransient public static final String AGENT_METRIC_AgentDescriptionAdded = "AgentMetric_AgentDescriptionAdded";
	@XmlTransient public static final String AGENT_METRIC_AgentDescriptionEdited = "AgentMetric_AgentDescriptionEdited";
	@XmlTransient public static final String AGENT_METRIC_AgentDescriptionRemoved = "AgentMetric_AgentDescriptionRemoved";

	// --- Constants -------------------------------------------
	@XmlTransient public static final String DEFAULT_SUB_FOLDER_4_SETUPS   = "setups";
	@XmlTransient public static final String DEFAULT_SUB_FOLDER_ENV_SETUPS = "setupsEnv";
	@XmlTransient public static final String DEFAULT_SUB_FOLDER_SECURITY = "security";
	@XmlTransient private final String[] DEFAULT_SUB_FOLDERS = {DEFAULT_SUB_FOLDER_4_SETUPS, DEFAULT_SUB_FOLDER_ENV_SETUPS};
	@XmlTransient public static final String DEFAULT_TEMP_FOLDER = "~tmp";

	/** The OSGI-bundle of the current project */
	@XmlTransient private ProjectBundleLoader projectBundleLoader;

	/** This is the 'view' in the context of the mentioned MVC pattern */
	@XmlTransient private AwbProjectEditorWindow projectEditorWindow;
	/** This panel holds the instance of environment model display */
	@XmlTransient private JPanel4Visualization visualizationTab4SetupExecution;
	/** This JDesktopPane that can be used as project desktop. */
	@XmlTransient private JDesktopPane projectDesktop;

	/** Indicates that the project is unsaved or not */
	@XmlTransient private boolean isUnsaved = false;

	@XmlTransient private String projectFolder;
	@XmlTransient private String projectFolderFullPath;
	@XmlTransient private String projectSecurtiyFolderFullPath;
	
	// --- Variables saved within the project file ------------------
	@XmlElement(name="projectName")				private String projectName;
	@XmlElement(name="projectDescription")		private String projectDescription;
	@XmlElement(name="projectStartTab")			private String projectStartTab;	
	@XmlElement(name="projectView")				private String projectView;			// --- View for developer or end-user ---
<commit_msg>Added variable for agent working directory to Project class<commit_after>/**
 * ***************************************************************
 * Agent.GUI is a framework to develop Multi-agent based simulation 
 * applications based on the JADE - Framework in compliance with the 
 * FIPA specifications. 
 * Copyright (C) 2010 <NAME> and DAWIS
 * http://www.dawis.wiwi.uni-due.de
 * http://sourceforge.net/projects/agentgui/
 * http://www.agentgui.org 
 *
 * GNU Lesser General Public License
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation,
 * version 2.1 of the License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA  02111-1307, USA.
 * **************************************************************
 */
package agentgui.core.project;

import java.awt.Component;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.io.Writer;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Observable;
import java.util.Vector;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JDesktopPane;
import javax.swing.JOptionPane;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import org.agentgui.gui.AwbProjectEditorWindow;
import org.agentgui.gui.AwbProjectEditorWindow.ProjectCloseUserFeedback;
import org.agentgui.gui.UiBridge;
import org.agentgui.gui.swing.project.ProjectWindow;
import org.agentgui.gui.swing.project.ProjectWindowTab;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;

import agentgui.core.application.Application;
import agentgui.core.application.Language;
import agentgui.core.classLoadService.ClassLoadServiceUtility;
import agentgui.core.config.GlobalInfo.ExecutionEnvironment;
import agentgui.core.config.GlobalInfo.ExecutionMode;
import agentgui.core.environment.EnvironmentController;
import agentgui.core.environment.EnvironmentPanel;
import agentgui.core.environment.EnvironmentType;
import agentgui.core.gui.components.JPanel4Visualization;
import agentgui.core.gui.projectwindow.simsetup.TimeModelController;
import agentgui.core.plugin.PlugIn;
import agentgui.core.plugin.PlugInLoadException;
import agentgui.core.plugin.PlugInNotification;
import agentgui.core.plugin.PlugInsLoaded;
import agentgui.core.project.setup.SimulationSetupNotification;
import agentgui.core.project.setup.SimulationSetupNotification.SimNoteReason;
import agentgui.core.project.setup.SimulationSetups;
import agentgui.core.project.transfer.ProjectExportController;
import agentgui.core.project.transfer.ProjectExportControllerProvider;
import agentgui.core.project.transfer.ProjectExportSettings;
import agentgui.core.update.ProjectRepositoryExport;
import agentgui.core.update.ProjectRepositoryUpdate;
import de.enflexit.common.classLoadService.ObjectInputStreamForClassLoadService;
import de.enflexit.common.featureEvaluation.FeatureInfo;
import de.enflexit.common.ontology.AgentStartConfiguration;
import de.enflexit.common.ontology.OntologyVisualisationHelper;
import de.enflexit.common.p2.P2OperationsHandler;

/**
 * This is the class, which holds all necessary informations about a project.<br>
 * In order to allow multiple access to the instance of Project, we designed it <br>
 * in the common <b>MVC pattern</b> (Model-View-Controller)<br>
 * 
 * @author <NAME> - DAWIS - ICB - University of Duisburg - Essen
 */
@XmlRootElement public class Project extends Observable {

	// --- public statics --------------------------------------
	@XmlTransient public static final String PREPARE_FOR_SAVING = "ProjectPrepare4Saving";
	@XmlTransient public static final String SAVED = "ProjectSaved";
	@XmlTransient public static final String CHANGED_ProjectName = "ProjectName";
	@XmlTransient public static final String CHANGED_ProjectDescription = "ProjectDescription";
	@XmlTransient public static final String CHANGED_ProjectView = "ProjectView";
	@XmlTransient public static final String CHANGED_ProjectStartTab = "ProjectStartTab";
	@XmlTransient public static final String CHANGED_ProjectFolder= "ProjectFolder";

	@XmlTransient public static final String CHANGED_VersionTag = "VersionTag";
	@XmlTransient public static final String CHANGED_Version = "Version";
	@XmlTransient public static final String CHANGED_UpdateAutoConfiguration= "UpdateAutoConfiguration";
	@XmlTransient public static final String CHANGED_UpdateSite = "UpdateSite";
	@XmlTransient public static final String CHANGED_UpdateDateLastChecked= "UpdateDateLastChecked";

	@XmlTransient public static final String CHANGED_EnvironmentModelType= "EnvironmentModelType";
	@XmlTransient public static final String CHANGED_StartArguments4BaseAgent = "StartArguments4BaseAgents";
	@XmlTransient public static final String CHANGED_TimeModelClass = "TimeModelConfiguration";
	@XmlTransient public static final String CHANGED_ProjectOntology = "ProjectOntology";
	@XmlTransient public static final String CHANGED_ProjectResources = "ProjectResources";
	@XmlTransient public static final String CHANGED_ProjectFeatures = "ProjectFeatures";
	@XmlTransient public static final String CHANGED_JadeConfiguration = "JadeConfiguration";
	@XmlTransient public static final String CHANGED_DistributionSetup = "DistributionSetup";
	@XmlTransient public static final String CHANGED_RemoteContainerConfiguration = "RemoteContainerConfiguration";
	@XmlTransient public static final String CHANGED_UserRuntimeObject = "UserRuntimeObject";

	// --- Constant value in order to set the project view ----------
	@XmlTransient public static final String VIEW_Developer = "Developer";
	@XmlTransient public static final String VIEW_User = "User";
	@XmlTransient public static final String VIEW_Maximize = "MaximizeView";
	@XmlTransient public static final String VIEW_Restore = "RestoreView";
	@XmlTransient public static final String VIEW_TabsLoaded = "TabsLoaded";

	// --- Constants for the the agent distribution metric ----------
	@XmlTransient public static final String AGENT_METRIC_Reset = "AgentMetric_Reset";
	@XmlTransient public static final String AGENT_METRIC_ChangedDataSource = "AgentMetric_ChangedDataSource";
	@XmlTransient public static final String AGENT_METRIC_AgentDescriptionAdded = "AgentMetric_AgentDescriptionAdded";
	@XmlTransient public static final String AGENT_METRIC_AgentDescriptionEdited = "AgentMetric_AgentDescriptionEdited";
	@XmlTransient public static final String AGENT_METRIC_AgentDescriptionRemoved = "AgentMetric_AgentDescriptionRemoved";

	// --- Constants -------------------------------------------
	@XmlTransient public static final String DEFAULT_SUB_FOLDER_4_SETUPS   = "setups";
	@XmlTransient public static final String DEFAULT_SUB_FOLDER_ENV_SETUPS = "setupsEnv";
	@XmlTransient public static final String DEFAULT_SUB_FOLDER_SECURITY = "security";
	@XmlTransient private final String[] DEFAULT_SUB_FOLDERS = {DEFAULT_SUB_FOLDER_4_SETUPS, DEFAULT_SUB_FOLDER_ENV_SETUPS};
	@XmlTransient public static final String DEFAULT_TEMP_FOLDER = "~tmp";
	@XmlTransient public static final String DEFAULT_AGENT_WORKING_DIRECTORY = "agentWorkingDirectory";

	/** The OSGI-bundle of the current project */
	@XmlTransient private ProjectBundleLoader projectBundleLoader;

	/** This is the 'view' in the context of the mentioned MVC pattern */
	@XmlTransient private AwbProjectEditorWindow projectEditorWindow;
	/** This panel holds the instance of environment model display */
	@XmlTransient private JPanel4Visualization visualizationTab4SetupExecution;
	/** This JDesktopPane that can be used as project desktop. */
	@XmlTransient private JDesktopPane projectDesktop;

	/** Indicates that the project is unsaved or not */
	@XmlTransient private boolean isUnsaved = false;

	@XmlTransient private String projectFolder;
	@XmlTransient private String projectFolderFullPath;
	@XmlTransient private String projectSecurtiyFolderFullPath;
	
	// --- Variables saved within the project file ------------------
	@XmlElement(name="projectName")				private String projectName;
	@XmlElement(name="projectDescription")		private String projectDescription;
	@XmlElement(name="projectStartTab")			private String projectStartTab;	
	@XmlElement(name="projectView")				private String projectView;			// --- View for developer or end-user ---

{'fraction_non_alphanumeric': 0.10013322675193179, 'fraction_numerical': 0.0035171862509992004, 'mean_word_length': 5.86896046852123, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 16}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1895905', 'n_tokens_mistral': 5118, 'n_tokens_neox': 4990, 'n_words': 1421}