예제 #1
0
 /// <summary>
 /// A MultiPoint is simple if it has no repeated points.
 /// </summary>
 public bool IsSimple(IMultiPoint mp)
 {
     if (mp.IsEmpty) 
         return true;
     Set<ICoordinate> points = new Set<ICoordinate>();
     for (int i = 0; i < mp.NumGeometries; i++)
     {
         IPoint pt = (IPoint) mp.GetGeometryN(i);
         ICoordinate p = pt.Coordinate;
         if (points.Contains(p))
             return false;
         points.Add(p);
     }
     return true;
 }   
        public void IntersectionTest()
        {
            Set<int> a = new Set<int>();
            for(int i = 0; i < 16; i += 2)
                a.Add(i);

            Set<int> b = new Set<int>();
            for(int i = 0; i < 16; i += 3)
                b.Add(i);

            Set<int> inter = a.Intersect(b);

            Assert.AreEqual(3, inter.Count, "A01");
            Assert.AreEqual(0, inter[0], "A02");
            Assert.AreEqual(6, inter[1], "A03");
            Assert.AreEqual(12, inter[2], "A04");
        }
예제 #3
0
		public void Init(FdoCache cache, bool enableCancel)
		{
			CheckDisposed();

			m_cache = cache;
			m_btnCancel.Visible = enableCancel;
			Set<int> revIdxWs = new Set<int>(4);
			foreach (IReversalIndex ri in cache.LangProject.LexDbOA.ReversalIndexesOC)
				revIdxWs.Add(ri.WritingSystemRAHvo);
			// Include only the analysis writing systems chosen by the user.  See LT-7514 and LT-7239.
			Set<int> activeWs = new Set<int>(8);
			foreach (int ws in cache.LangProject.AnalysisWssRC.HvoArray)
				activeWs.Add(ws);
			m_cbWritingSystems.Sorted = true;
			m_cbWritingSystems.DisplayMember = "Name";
			NamedWritingSystem nwsSelected = null;
			foreach (NamedWritingSystem nws in cache.LangProject.GetDbNamedWritingSystems())
			{
				if (revIdxWs.Contains(nws.Hvo))
				{
					AddLanguageForExistingRevIdx(nws.IcuLocale);
					continue;
				}
				if (!activeWs.Contains(nws.Hvo))
					continue;
				m_cbWritingSystems.Items.Add(nws);
				if (nwsSelected == null && !LanguageMatchesExistingRevIdx(nws.IcuLocale))
					nwsSelected = nws;
			}
			if (nwsSelected != null)
				m_cbWritingSystems.SelectedItem = nwsSelected;
			if (m_cbWritingSystems.Items.Count > 0 && m_cbWritingSystems.SelectedIndex < 0)
				m_cbWritingSystems.SelectedIndex = 0;
			if (!enableCancel && m_cbWritingSystems.Items.Count == 0)
				throw new ApplicationException("Cancel is disabled, but there are none to choose, so the user has no way to get out of this dialog.");
		}
        /// <summary>
        ///     Determines which types are produced by this mapping.
        /// </summary>
        private Set<EntityType> FindReachableTypes(
            DomainConstraintConversionContext<string, ValueCondition> converter, Vertex[] mappingConditions)
        {
            // For each entity type, create a candidate function that evaluates to true given
            // discriminator assignments iff. all of that type's conditions evaluate to true
            // and its negative conditions evaluate to false.
            var candidateFunctions = new Vertex[MappedEntityTypes.Count];
            for (var i = 0; i < candidateFunctions.Length; i++)
            {
                // Seed the candidate function conjunction with 'true'.
                var candidateFunction = Vertex.One;
                for (var j = 0; j < NormalizedEntityTypeMappings.Count; j++)
                {
                    var entityTypeMapping = NormalizedEntityTypeMappings[j];

                    // Determine if this mapping is a positive or negative case for the current type.
                    if (entityTypeMapping.ImpliedEntityTypes[i])
                    {
                        candidateFunction = converter.Solver.And(candidateFunction, mappingConditions[j]);
                    }
                    else
                    {
                        candidateFunction = converter.Solver.And(candidateFunction, converter.Solver.Not(mappingConditions[j]));
                    }
                }
                candidateFunctions[i] = candidateFunction;
            }

            // Make sure that for each type there is an assignment that resolves to only that type.
            var reachableTypes = new Set<EntityType>();
            for (var i = 0; i < candidateFunctions.Length; i++)
            {
                // Create a function that evaluates to true iff. the current candidate function is true
                // and every other candidate function is false.
                var isExactlyThisTypeCondition = converter.Solver.And(
                    candidateFunctions.Select(
                        (typeCondition, ordinal) => ordinal == i
                                                        ? typeCondition
                                                        : converter.Solver.Not(typeCondition)));

                // If the above conjunction is satisfiable, it means some row configuration exists producing the type.
                if (!isExactlyThisTypeCondition.IsZero())
                {
                    reachableTypes.Add(MappedEntityTypes[i]);
                }
            }

            return reachableTypes;
        }
예제 #5
0
		static void ConsumeParsingQueue ()
		{
			int pending = 0;
			IProgressMonitor monitor = null;
			
			try {
				Set<ProjectDom> dbsToFlush = new Set<ProjectDom> ();
				do {
					if (pending > 5 && monitor == null) {
						monitor = GetParseProgressMonitor ();
						monitor.BeginTask (GettextCatalog.GetString ("Generating database"), 0);
					}
					
					ParsingJob job = DequeueParseJob ();
					
					if (job != null) {
						try {
							job.ParseCallback (job.File, monitor);
							if (job.Database != null)
								dbsToFlush.Add (job.Database);
						} catch (Exception ex) {
							if (monitor == null)
								monitor = GetParseProgressMonitor ();
							monitor.ReportError (null, ex);
						}
					}
					
					pending = PendingJobCount;
					
				}
				while (pending > 0);
				
				queueEmptied.Set ();
				
				// Flush the parsed databases
				foreach (ProjectDom db in dbsToFlush)
					db.Flush ();
				
			} finally {
				if (monitor != null) monitor.Dispose ();
			}
		}
		/**
		 * returns a set of projects that a combine contains and a set of projects
		 * that are referenced from combine projects but not part of the combine
		 */
		void GetAllProjects (SolutionFolder folder, SolutionConfiguration config, out Set<SolutionFolderItem> projects, out Set<SolutionFolderItem> references)
		{
			List<SolutionFolderItem> subitems = new List<SolutionFolderItem> ();
			GetSubItems (subitems, folder);

			projects = (Set<SolutionFolderItem>) combineProjects [folder];
			if (projects != null) {
				references = (Set<SolutionFolderItem>) combineReferences [folder];
				return;
			}

			projects = new Set<SolutionFolderItem>();
			references = new Set<SolutionFolderItem>();
			
			foreach (SolutionFolderItem item in subitems) 
			{
				if (item is SolutionItem)
				{
					SolutionItem entry = (SolutionItem) item;
					if (!config.BuildEnabledForItem (entry))
						continue;
					projects.Add (entry);
					references.Union (entry.GetReferencedItems (config.Selector));
				}
				else if (item is SolutionFolder) 
				{
					Set<SolutionFolderItem> subProjects;
					Set<SolutionFolderItem> subReferences;
					GetAllProjects ((SolutionFolder)item, config, out subProjects, out subReferences);
					projects.Union (subProjects);
					references.Union (subReferences);
				}
			}
			
			references.Without (projects);
			combineProjects [folder] = projects;
			combineReferences [folder] = references;
		}
		public void IncludeFileToProject ()
		{
			Set<IWorkspaceFileObject> projects = new Set<IWorkspaceFileObject> ();
			var nodesByProject = CurrentNodes.GroupBy (n => n.GetParentDataItem (typeof(Project), true) as Project);
			
			foreach (var projectGroup in nodesByProject) {
				Project project = projectGroup.Key;
				List<FilePath> newFiles = new List<FilePath> ();
				foreach (ITreeNavigator node in projectGroup) {
					SystemFile file = (SystemFile) node.DataItem;
					if (project != null) {
						newFiles.Add (file.Path);
						projects.Add (project);
					}
					else {
						SolutionFolder folder = node.GetParentDataItem (typeof(SolutionFolder), true) as SolutionFolder;
						if (folder != null) {
							folder.Files.Add (file.Path);
							projects.Add (folder.ParentSolution);
						}
						else {
							Solution sol = node.GetParentDataItem (typeof(Solution), true) as Solution;
							sol.RootFolder.Files.Add (file.Path);
							projects.Add (sol);
						}
					}
				}
				if (newFiles.Count > 0)
					project.AddFiles (newFiles);
			}
			IdeApp.ProjectOperations.SaveAsync (projects);
		}
예제 #8
0
		/// <summary>
		/// On Refresh, we want to reload the XML configuration files.  This greatly facilitates developing
		/// those files, even though it's not as useful for normal use.  It might prove useful whenever we
		/// get around to allowing user customization (or it might not).
		/// </summary>
		/// <param name="sender"></param>
		/// <returns></returns>
		public bool OnRefresh(object sender)
		{
			CheckDisposed();
			Set<string> setDatabases = new Set<string>();
			foreach (FwXWindow wnd in m_rgMainWindows)
			{
				string sDatabase = wnd.Cache.DatabaseName;
				if (setDatabases.Contains(sDatabase))
					continue;
				setDatabases.Add(sDatabase);
				Inventory.GetInventory("layouts", sDatabase).ReloadIfChanges();
				Inventory.GetInventory("parts", sDatabase).ReloadIfChanges();
			}
			return false;
		}
        public override void DeleteMultipleItems()
        {
            var projects = new Set<SolutionEntityItem> ();
            var folders = new List<ProjectFolder> ();
            foreach (ITreeNavigator node in CurrentNodes)
                folders.Add ((ProjectFolder) node.DataItem);

            var removeButton = new AlertButton (GettextCatalog.GetString ("_Remove from Project"), Gtk.Stock.Remove);
            var question = new QuestionMessage () {
                AllowApplyToAll = folders.Count > 1,
                SecondaryText = GettextCatalog.GetString (
                "The Delete option permanently removes the directory and any files it contains from your hard disk. " +
                "Click Remove from Project if you only want to remove it from your current solution.")
            };
            question.Buttons.Add (AlertButton.Cancel);
            question.Buttons.Add (AlertButton.Delete);
            question.Buttons.Add (removeButton);

            var deleteOnlyQuestion = new QuestionMessage () {
                AllowApplyToAll = folders.Count > 1,
                SecondaryText = GettextCatalog.GetString ("The directory and any files it contains will be permanently removed from your hard disk. ")
            };
            deleteOnlyQuestion.Buttons.Add (AlertButton.Cancel);
            deleteOnlyQuestion.Buttons.Add (AlertButton.Delete);

            foreach (var folder in folders) {
                var project = folder.Project;

                AlertButton result;

                if (project == null) {
                    deleteOnlyQuestion.Text = GettextCatalog.GetString ("Are you sure you want to remove directory {0}?", folder.Name);
                    result = MessageService.AskQuestion (deleteOnlyQuestion);
                    if (result == AlertButton.Delete) {
                        DeleteFolder (folder);
                        continue;
                    } else
                        break;
                }

                var folderRelativePath = folder.Path.ToRelative (project.BaseDirectory);
                var files = project.Files.GetFilesInVirtualPath (folderRelativePath).ToList ();
                var folderPf = project.Files.GetFileWithVirtualPath (folderRelativePath);
                bool isProjectFolder = files.Count == 0 && folderPf == null;

                //if the parent directory has already been removed, there may be nothing to do
                if (isProjectFolder) {
                    deleteOnlyQuestion.Text = GettextCatalog.GetString ("Are you sure you want to remove directory {0}?", folder.Name);
                    result = MessageService.AskQuestion (deleteOnlyQuestion);
                    if (result != AlertButton.Delete)
                        break;
                }
                else {
                    question.Text = GettextCatalog.GetString ("Are you sure you want to remove directory {0} from project {1}?",
                        folder.Name, project.Name);
                    result = MessageService.AskQuestion (question);
                    if (result != removeButton && result != AlertButton.Delete)
                        break;

                    projects.Add (project);

                    //remove the files and link files in the directory
                    foreach (var f in files)
                        project.Files.Remove (f);

                    // also remove the folder's own ProjectFile, if it exists
                    // FIXME: it probably was already in the files list
                    if (folderPf != null)
                        project.Files.Remove (folderPf);
                }

                if (result == AlertButton.Delete) {
                    DeleteFolder (folder);
                } else {
                    //explictly remove the node from the tree, since it currently only tracks real folder deletions
                    folder.Remove ();
                }

                if (isProjectFolder && folder.Path.ParentDirectory != project.BaseDirectory) {
                    // If it's the last item in the parent folder, make sure we keep a reference to the parent
                    // folder, so it is not deleted from the tree.
                    var inParentFolder = project.Files.GetFilesInVirtualPath (folderRelativePath.ParentDirectory);
                    if (!inParentFolder.Skip (1).Any ()) {
                        project.Files.Add (new ProjectFile (folder.Path.ParentDirectory) {
                            Subtype = Subtype.Directory,
                        });
                    }
                }
            }
            IdeApp.ProjectOperations.Save (projects);
        }
예제 #10
0
		static internal bool TryFirstWsInList(SIL.FieldWorks.Common.COMInterfaces.ISilDataAccess sda, int hvo, int flid,
			int[] wssToTry, ref Set<int> wssTried, out int retWs, out ITsString retTss)
		{
			retTss = null;
			retWs = 0;
			foreach (int wsLoop in wssToTry)
			{
				if (wssTried.Contains(wsLoop))
					continue;
				wssTried.Add(wsLoop);
				retTss = sda.get_MultiStringAlt(hvo, flid, wsLoop);
				if (retTss.Length > 0)
				{
					retWs = wsLoop;
					return true;
				}
			}
			return false;
		}
예제 #11
0
		/// <summary>
		/// This method is the one to override if you need side effects when DeleteUnderlyingObject
		/// is called. If other objects should be deleted also, do NOT delete them directly; this
		/// tends to produce abysmal performance. Rather, add them to objectsToDeleteAlso, and the
		/// whole lot (including this) will be deleted in one relatively efficient operation.
		/// You should not modify objectsToDeleteAlso except to add HVOs to it.
		/// You must not use the FDO object after calling this, it has been put into the deleted state.
		/// </summary>
		/// <param name="objectsToDeleteAlso">hashtable of HVOs (value typically just true, it's really a set).</param>
		/// <param name="state"></param>
		public override void DeleteObjectSideEffects(Set<int> objectsToDeleteAlso, ProgressState state)
		{
			if (Owner.ClassID == PhMetathesisRule.kclsidPhMetathesisRule)
			{
				// update the StrucChange field to reflect the removed simple context
				IPhMetathesisRule rule = Owner as IPhMetathesisRule;
				int removeCtxt = rule.UpdateStrucChange(rule.GetStrucChangeIndex(Hvo), IndexInOwner, false);
				if (removeCtxt != 0)
					objectsToDeleteAlso.Add(removeCtxt);
			}

			base.DeleteObjectSideEffects(objectsToDeleteAlso, state);
		}
예제 #12
0
		/// <summary>
		/// This method is the one to override if you need side effects when DeleteUnderlyingObject
		/// is called. If other objects should be deleted also, do NOT delete them directly; this
		/// tends to produce abysmal performance. Rather, add them to objectsToDeleteAlso, and the
		/// whole lot (including this) will be deleted in one relatively efficient operation.
		/// You should not modify objectsToDeleteAlso except to add HVOs to it.
		/// You must not use the FDO object after calling this, it has been put into the deleted state.
		/// </summary>
		/// <param name="objectsToDeleteAlso">hashtable of HVOs (value typically just true, it's really a set).</param>
		/// <param name="state"></param>
		public override void DeleteObjectSideEffects(Set<int> objectsToDeleteAlso, ProgressState state)
		{
			switch (Owner.ClassID)
			{
				case MoAffixProcess.kclsidMoAffixProcess:
					// if this is owned by a MoAffixProcess we must remove all of the associated output mappings
					IMoAffixProcess rule = Owner as IMoAffixProcess;
					foreach (int mappingHvo in rule.OutputOS.HvoArray)
					{
						switch (m_cache.GetClassOfObject(mappingHvo))
						{
							case MoCopyFromInput.kclsidMoCopyFromInput:
								IMoCopyFromInput copy = new MoCopyFromInput(m_cache, mappingHvo);
								if (copy.ContentRAHvo == Hvo)
									objectsToDeleteAlso.Add(mappingHvo);
								break;

							case MoModifyFromInput.kclsidMoModifyFromInput:
								IMoModifyFromInput modify = new MoModifyFromInput(m_cache, mappingHvo);
								if (modify.ContentRAHvo == Hvo)
									objectsToDeleteAlso.Add(mappingHvo);
								break;
						}
					}
					break;

				case PhPhonData.kclsidPhPhonData:
					List<LinkedObjectInfo> linkedObjs = LinkedObjects;
					foreach (LinkedObjectInfo loi in linkedObjs)
					{
						if (loi.RelObjClass == PhIterationContext.kclsidPhIterationContext
							&& loi.RelObjField == (int)PhIterationContext.PhIterationContextTags.kflidMember)
						{
							IPhIterationContext ctxt = new PhIterationContext(m_cache, loi.RelObjId);
							ctxt.DeleteObjectSideEffects(objectsToDeleteAlso, state);
							objectsToDeleteAlso.Add(loi.RelObjId);
						}
						else if (loi.RelObjClass == PhSequenceContext.kclsidPhSequenceContext
							&& loi.RelObjField == (int)PhSequenceContext.PhSequenceContextTags.kflidMembers
							&& m_cache.GetVectorSize(loi.RelObjId, (int)PhSequenceContext.PhSequenceContextTags.kflidMembers) == 1)
						{
							IPhSequenceContext ctxt = new PhSequenceContext(m_cache, loi.RelObjId);
							ctxt.DeleteObjectSideEffects(objectsToDeleteAlso, state);
							objectsToDeleteAlso.Add(loi.RelObjId);
						}
					}
					break;
			}
			base.DeleteObjectSideEffects(objectsToDeleteAlso, state);
		}
예제 #13
0
		/// <summary>
		/// This method is the one to override if you need side effects when DeleteUnderlyingObject
		/// is called. If other objects should be deleted also, do NOT delete them directly; this
		/// tends to produce abysmal performance. Rather, add them to objectsToDeleteAlso, and the
		/// whole lot (including this) will be deleted in one relatively efficient operation.
		/// You should not modify objectsToDeleteAlso except to add HVOs to it.
		/// You must not use the FDO object after calling this, it has been put into the deleted state.
		/// </summary>
		/// <param name="objectsToDeleteAlso">hashtable of HVOs (value typically just true, it's really a set).</param>
		/// <param name="state"></param>
		public override void DeleteObjectSideEffects(Set<int> objectsToDeleteAlso, ProgressState state)
		{
			if (MemberRAHvo != 0)
				objectsToDeleteAlso.Add(MemberRAHvo);

			base.DeleteObjectSideEffects(objectsToDeleteAlso, state);
		}
예제 #14
0
		/// <summary>
		/// Get a set of hvos that are suitable for targets to a reference property.
		/// Subclasses should override this method to return a sensible list of IDs.
		/// </summary>
		/// <param name="flid">The reference property that can store the IDs.</param>
		/// <returns>A set of hvos.</returns>
		public override Set<int> ReferenceTargetCandidates(int flid)
		{
			Set<int> set = null;
			switch (flid)
			{
				case (int)PartOfSpeech.PartOfSpeechTags.kflidDefaultInflectionClass:
					set = new Set<int>();
					foreach (IMoInflClass ic in AllInflectionClasses)
						set.Add(ic.Hvo);
					break;
				case (int)PartOfSpeech.PartOfSpeechTags.kflidBearableFeatures:
					set = new Set<int>();
					ILangProject lp = m_cache.LangProject;
					if (lp != null)
					{
						IFsFeatStrucType exceps = lp.ExceptionFeatureType;
						set.AddRange(exceps.FeaturesRS.HvoArray);
					}
					break;
				case (int)PartOfSpeech.PartOfSpeechTags.kflidInflectableFeats:
					set = new Set<int>();
					set.AddRange(m_cache.LangProject.MsFeatureSystemOA.FeaturesOC.HvoArray);
					break;
				default:
					set = base.ReferenceTargetCandidates(flid);
					break;
			}
			return set;
		}
예제 #15
0
		/// <summary>
		/// This method is called by the ReversalEntriesText virtual handler when text may have changed in the
		/// property, in order to update the actual list of reversal entries appropriately.
		/// </summary>
		/// <param name="tssVal">The new string.</param>
		/// <param name="ws">The ws.</param>
		public void CommitReversalEntriesText(ITsString tssVal, int ws)
		{
			LexSenseReversalEntriesTextHandler vh = BaseVirtualHandler.GetInstalledHandler(m_cache,
				"LexSense", LexSenseReversalEntriesTextHandler.StandardFieldName) as LexSenseReversalEntriesTextHandler;
			Debug.Assert(vh != null, "The 'LexSenseReversalEntriesTextHandler' virtual handler has to be created at application startup now.");

			ITsString tssOld = vh.GetValue(m_hvo, ws);
			// The old and new values could be in another order, and this test won't catch that case.
			// That condition won't be fatal, however, so don't fret about it.
			if (tssOld.Equals(tssVal))
				return; // no change has occurred

			string val = tssVal.Text;
			if (val == null)
				val = ""; // This will effectively cause any extant entries for the given 'ws' to be removed in the end.

			StringCollection formsColl = new StringCollection();
			foreach (string form in val.Split(';'))
			{
				// These strings will be null, if there are two semi-colons together.
				// Or, it may be just whitespace, if it is '; ;'.
				if (form == null || form.Trim().Length == 0)
					continue;
				formsColl.Add(form.Trim());
			}
			int[] senseEntries = ReversalEntriesRC.HvoArray;
			int originalSenseEntriesCount = senseEntries.Length;
			int indexId;
			DbOps.ReadOneIntFromCommand(m_cache, "SELECT id FROM ReversalIndex WHERE WritingSystem=?", ws, out indexId);
			ReversalIndex revIndex;
			if (indexId == 0)
			{
				// Create the missing reversal index instead of crashing.  See LT-10186.
				ILgWritingSystem lgws = LgWritingSystem.CreateFromDBObject(m_cache, ws);
				IReversalIndex newIdx = m_cache.LangProject.LexDbOA.ReversalIndexesOC.Add(new ReversalIndex());
				newIdx.WritingSystemRA = lgws;
				// Copy any and all alternatives from lgws.Name to newIdx.Name
				foreach (ILgWritingSystem lgwsLoop in m_cache.LanguageEncodings)
				{
					string lgsNameAlt = lgws.Name.GetAlternative(lgwsLoop.Hvo);
					if (lgsNameAlt != null && lgsNameAlt.Length > 0)
						newIdx.Name.SetAlternative(lgsNameAlt, lgws.Hvo);
				}
				revIndex = (ReversalIndex)newIdx;
			}
			else
			{
				revIndex = (ReversalIndex)CmObject.CreateFromDBObject(m_cache, indexId, false);
			}

			// We need the list of ReversalIndexEntries that this sense references, but which belong
			// to another reversal index. Those hvos, plus any entry hvos from the given 'ws' that are reused,
			// get put into 'survivingEntries'.
			Set<int> survivingEntries = new Set<int>(originalSenseEntriesCount + formsColl.Count);
			// 'entriesNeedingPropChangeBackRef' will hold the hvos of all ReversalIndexEntry objects that need to have
			// their 'ReferringSenses' virtual property (re)computed.
			// Any reversal index entry that gains or loses a reference will need this (re)computing.
			List<int> entriesNeedingPropChangeBackRef = new List<int>(originalSenseEntriesCount + formsColl.Count);
			foreach (int entryHvo in senseEntries)
			{
				// Use 'cheapo' FDO object maker, since it is supposed to all be in the cache already.
				ReversalIndexEntry rie = (ReversalIndexEntry)CmObject.CreateFromDBObject(m_cache, entryHvo, false);
				int wsIndex = 0;
				int hvoIndex = m_cache.GetOwnerOfObjectOfClass(rie.Hvo, ReversalIndex.kclsidReversalIndex);
				if (hvoIndex != 0)
					wsIndex = m_cache.GetIntProperty(hvoIndex, (int)ReversalIndex.ReversalIndexTags.kflidWritingSystem);
				if (wsIndex == ws)
				{
					string form = rie.LongName;
					if (formsColl.Contains(form))
					{
						// Recycling an entry.
						survivingEntries.Add(rie.Hvo);
						formsColl.Remove(form); // Don't need to mess with it later on.
					}
					else
					{
						// It is being removed from the extant reference property,
						// so needs to recompute its back ref virtual handler.
						entriesNeedingPropChangeBackRef.Add(rie.Hvo);
					}
				}
				else
				{
					// These are all in some other ws, so they certainly must survive (cf. LT-3391).
					// Any entries that are reused will get added to this array later on.
					survivingEntries.Add(rie.Hvo);
				}
			}

			// Start Undoable section of code.
			m_cache.BeginUndoTask(Strings.ksUndoMakeRevEntries, Strings.ksRedoMakeRevEntries);
			ISilDataAccess sda = m_cache.MainCacheAccessor;
			IActionHandler acth = sda.GetActionHandler();
			try
			{
				// add undo actions to reload the virtual handler and send prop changes to update displays
				if (acth != null)
				{
					List<PropChangedInfo> pciList = new List<PropChangedInfo>();
					pciList.Add(new PropChangedInfo(m_hvo, vh.Tag, ws, 0, 0));
					acth.AddAction(new PropChangedUndoAction(m_cache, true, PropChangeType.kpctNotifyAll, pciList));
					acth.AddAction(new ReloadVirtualHandlerUndoAction(m_cache, true, vh, m_hvo, vh.Tag, ws));
				}

				int cOldEntries = revIndex.EntriesOC.Count;
				foreach (string currentForm in formsColl)
				{
					int idRevEntry = revIndex.FindOrCreateReversalEntry(currentForm);
					entriesNeedingPropChangeBackRef.Add(idRevEntry);
					survivingEntries.Add(idRevEntry);
				}

				// Notify everyone, and his brother, about the changes done here.
				// PropChanged (1 of 3) Main: Replace main sense property with current set of entries.
				sda.Replace(m_hvo, (int)LexSense.LexSenseTags.kflidReversalEntries, 0, originalSenseEntriesCount,
					survivingEntries.ToArray(), survivingEntries.Count);
				sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll, m_hvo,
					(int)LexSense.LexSenseTags.kflidReversalEntries, 0, survivingEntries.Count, originalSenseEntriesCount);

				// remove entries from the index that are no longer valid
				foreach (int rieHvo in senseEntries)
				{
					if (!survivingEntries.Contains(rieHvo))
					{
						// the entry is no longer a reversal entry for this sense
						ReversalIndexEntry rie = new ReversalIndexEntry(m_cache, rieHvo);
						if (rie.SenseIds.Count == 0)
							// the entry is longer a reversal entry for any sense
							revIndex.EntriesOC.Remove(rie);
					}
				}

				// PropChanged (2 of 3) Affected Entries: (Re)compute
				// on the virtual property of select reversal index entries.
				ReversalIndexEntry.ResetReferringSenses(m_cache, entriesNeedingPropChangeBackRef);

				// PropChanged (3 of 3) Index Entries: Simulate a complete replacement of the entries collection,
				// BUT only if new entries were added in this method.
				int cNewEntries = revIndex.EntriesOC.Count;
				if (cNewEntries > cOldEntries)
				{
					sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll, indexId,
						(int)ReversalIndex.ReversalIndexTags.kflidEntries,
						0, cNewEntries, cOldEntries);
				}

				// add redo actions to reload the virtual handler and send prop changes to update displays
				if (acth != null)
				{
					acth.AddAction(new ReloadVirtualHandlerUndoAction(m_cache, false, vh, m_hvo, vh.Tag, ws));
					List<PropChangedInfo> pciList = new List<PropChangedInfo>();
					pciList.Add(new PropChangedInfo(m_hvo, vh.Tag, ws, 0, 0));
					acth.AddAction(new PropChangedUndoAction(m_cache, false, PropChangeType.kpctNotifyAll, pciList));
				}
			}
			finally
			{
				if (acth != null && Marshal.IsComObject(acth))
					Marshal.ReleaseComObject(acth);
			}
			// End undoable section of code.
			m_cache.EndUndoTask();
		}
        public void FindCurves(string whereClause = null)
        {
            IMap pMap = ArcMap.Document.ActiveView.FocusMap;

            if (hasOpenJob())
                return;

            IRelationshipClass relationshipClass = null;
            ISelectionSet relatedSelectionSet = null;

            myAOProgressor progressor = new myAOProgressor();
            try
            {
                Finished = false;

                progressor.setStepProgressorProperties(1, "Initializing");
                ICadastralFabricLayer CFLayer = GetFabricLayer(pMap);

                IFeatureLayer CFLineLayer = CFLayer.get_CadastralSubLayer(esriCadastralFabricRenderer.esriCFRLines);
                IFeatureLayer CFParcelLayer = CFLayer.get_CadastralSubLayer(esriCadastralFabricRenderer.esriCFRParcels);
                                    
                //for each CF line feature class 
                IFeatureSelection CFLineFeatureSelection = (IFeatureSelection)CFLineLayer;
                IFeatureSelection CFParcelFeatureSelection = (IFeatureSelection)CFParcelLayer;

                ISelectionSet selectionSet = null;
                if (CFParcelFeatureSelection.SelectionSet.Count > 0)
                {
                    //parcels selected
                        
                    //Create memory relationship class to help with the mapping
                    IMemoryRelationshipClassFactory MemoryRCF = new MemoryRelationshipClassFactoryClass();
                    relationshipClass = MemoryRCF.Open("Parcel_Layer_Rel", CFParcelLayer.FeatureClass, "ObjectID", CFLineLayer.FeatureClass, "ParcelID", "forward", "backward", esriRelCardinality.esriRelCardinalityOneToMany);

                    //convert selection set to ISet of rows
                    ISet polySet = new Set();
                    ICursor cursor;
                    CFParcelFeatureSelection.SelectionSet.Search(null, false, out cursor);
                    IRow row = null;
                    while((row = cursor.NextRow()) != null)
                        polySet.Add(row);
                    polySet.Reset();

                    //use the relationship class to find related rows
                    ISet lineSet = relationshipClass.GetObjectsRelatedToObjectSet(polySet);

                    //convert set back to selection set
                    lineSet.Reset();
                        
                    //create an empty selection set (there should be a better way to do this....
                        
                    //will only evaluate the lines related to the parcels that are selected
                    //selectionSet = CFLineLayer.FeatureClass.Select(new QueryFilter() { WhereClause = "1=0" }, esriSelectionType.esriSelectionTypeIDSet, esriSelectionOption.esriSelectionOptionNormal, null);

                    //will union the current line selection and the parcel selection
                    relatedSelectionSet = CFLineFeatureSelection.SelectionSet.Select(null, esriSelectionType.esriSelectionTypeIDSet, esriSelectionOption.esriSelectionOptionNormal, null);
                        
                    while ((row = (IRow)lineSet.Next()) != null)
                    {
                        relatedSelectionSet.Add(row.OID);
                        Marshal.ReleaseComObject(row);
                    }
                    Marshal.ReleaseComObject(lineSet);
                    polySet.Reset();
                    while ((row = (IRow)polySet.Next()) != null)
                        Marshal.ReleaseComObject(row);
                    Marshal.ReleaseComObject(polySet);

                    selectionSet = relatedSelectionSet;
                }
                else if (CFLineFeatureSelection.SelectionSet.Count > 0)
                {
                    //lines selected
                    selectionSet = CFLineFeatureSelection.SelectionSet;
                }
                    
                else
                {
                    if (DialogResult.OK != messageBox.Show("You are about to run the add-in on the entire feature class, this could take a long time.  Proceeed?", "Long Operation", MessageBoxButtons.OKCancel))
                        return;
                }

                    
                FindCurves(CFLineLayer.Name, CFLineLayer.FeatureClass, selectionSet, whereClause, progressor);
                if (Curves.Count == 0)
                {
                    messageBox.Show("No inferred curved lines found.");
                    return;
                }
            }
            catch (Exception Exx)
            {
                messageBox.Show(Exx.Message);

                if (relationshipClass != null)
                    Marshal.ReleaseComObject(relationshipClass);
                if (relatedSelectionSet != null)
                    Marshal.ReleaseComObject(relatedSelectionSet);
            }
            finally
            {
                progressor.Dispose();
                Finished = true;
            }
        }
        public void IncludeToProject()
        {
            Set<SolutionEntityItem> projects = new Set<SolutionEntityItem> ();
            foreach (ITreeNavigator node in CurrentNodes) {
                Project project = node.GetParentDataItem (typeof(Project), true) as Project;
                if (node.HasChildren ()) {
                    List<SystemFile> filesToAdd = new List<SystemFile> ();
                    ITreeNavigator nav = node.Clone ();
                    GetFiles (nav, filesToAdd);

                    foreach (SystemFile file in filesToAdd)
                        project.AddFile (file.Path);

                    projects.Add (project);
                } else {
                    ProjectFolder pf = node.DataItem as ProjectFolder;
                    if (pf != null) {
                        project.AddDirectory (FileService.AbsoluteToRelativePath (project.BaseDirectory, pf.Path));
                        projects.Add (project);
                    }
                }
            }
            IdeApp.ProjectOperations.Save (projects);
        }
예제 #18
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds all of the LgWritingSystems in source to the namedWritingSystems set.
		/// </summary>
		/// <param name="namedWritingSystems"></param>
		/// <param name="source"></param>
		/// <param name="displayLocale">REVIEW (TimS): Looks like this param is not used (maybe
		/// used to be used). Is there a plan to use it or can it be removed?</param>
		/// ------------------------------------------------------------------------------------
		private static void AddWsNamedObjsToSet(Set<NamedWritingSystem> namedWritingSystems,
			IEnumerable source, string displayLocale)
		{
			foreach (LgWritingSystem ws in source)
			{
				NamedWritingSystem nws = new NamedWritingSystem(ws.ShortName, ws.ICULocale, ws.Hvo);
				// TE-6958 kept crashing when we tried to get a hashcode for a malformed ws. Instead
				// of crashing, let's just skip the bum ws. It's still a mystery how we apparently get
				// a ws without a name since the name will default to the IcuLocale if it is missing.
				if (nws.Name != null && nws.IcuLocale != null)
					namedWritingSystems.Add(nws);
			}
		}
		void PublishDir (Set<FilePath> dirs, FilePath dir, bool rec, IProgressMonitor monitor)
		{
			string ndir = (string) dir;
			while (ndir[ndir.Length - 1] == Path.DirectorySeparatorChar)
				ndir = ndir.Substring (0, ndir.Length - 1);

			dir = ndir;
			if (dirs.Contains (dir))
				return;

			dirs.Add (dir);
			if (rec) {
				PublishDir (dirs, dir.ParentDirectory, true, monitor);
				Add (dir, false, monitor);
			}
		}
예제 #20
0
		private static Set<NamedWritingSystem> GetNamedWritingSystemsFromLDFs(ILgWritingSystemFactory wsf,
			string[] fileList, Set<NamedWritingSystem> namedWritingSystems)
		{
			Set<string> names = new Set<string>();
			foreach (NamedWritingSystem nws in namedWritingSystems)
				names.Add(nws.IcuLocale);
			// Now add the ones from the XML files.
			foreach (string pathname in fileList)
			{
				string[] bits = pathname.Split('\\');
				string filename = bits[bits.Length - 1];
				bits = filename.Split('.');
				string icuLocale = bits[0]; // Name up to first '.'.
				// The first test excludes names like en.xml1.
				if (bits[1] == "xml" && !names.Contains(icuLocale.ToLowerInvariant()))
				{
					try
					{
						// This will get the language name from the XML language def. file. This
						// should be the same name the user chose to call the language when creating
						// its writing system.
						LanguageDefinitionFactory ldf = new LanguageDefinitionFactory(wsf, icuLocale);
						if (ldf.LanguageDefinition == null)
						{
							System.Diagnostics.Debug.WriteLine("The XML file for " + icuLocale +
								" did not parse properly.");
						}
						else
						{
							string displayName = ldf.LanguageDefinition.DisplayName;

							// REVIEW: These two lines are how we used to get the display name. Now we read
							// it from the language def. file (i.e. the .xml file). Will the name from the
							// XML file always be in the display locale?
							//Icu.UErrorCode err;
							//Icu.GetDisplayName(icuLocale, displayLocale, out displayName, out err);

							// If it can't find a name, the normal behavior is to return the icuLocale.
							// If that happens we leave this one out.
							// If anything worse happens (e.g., that might produce a bad error code),
							// the other checks we make here should detect it.
							if (displayName != null && displayName != icuLocale && displayName.Length != 0)
								namedWritingSystems.Add(new NamedWritingSystem(displayName, icuLocale));
						}
					}
					catch (FileNotFoundException e)
					{
						System.Diagnostics.Debug.WriteLine(e.Message);
						// LanguageDefinitionFactory can throw this error. Just ignore it.
					}
				}
			}
			return namedWritingSystems;
		}
예제 #21
0
			private int ConvertDummiesToReal(int hvoDummy)
			{
				List<int> currentEntries = new List<int>();
				int countIndices = m_silCache.get_VecSize(m_sense.Hvo, kFlidIndices);
				int hvoReal = 0;
				Set<int> writingSystemsModified = new Set<int>();
				for (int i = 0; i < countIndices; ++i)
				{
					int hvoIndex = m_silCache.get_VecItem(m_sense.Hvo, kFlidIndices, i);
					ReversalIndex revIndex = ReversalIndex.CreateFromDBObject(m_fdoCache, hvoIndex) as ReversalIndex;
					writingSystemsModified.Add(revIndex.WritingSystemRAHvo);
					int countRealEntries = m_silCache.get_VecSize(hvoIndex, kFlidEntries) - 1; // Skip the dummy entry at the end.
					// Go through it from the far end, since we may be deleting empty items.
					for (int j = countRealEntries - 1; j >= 0; --j)
					{
						int hvoEntry = m_silCache.get_VecItem(hvoIndex, kFlidEntries, j);
						// If hvoEntry is greater than 0, then it started as a real entry.
						// If hvoEntry is less than 0, it is clearly a new one.
						// The text may have changed for a real one, so check to see if is the same.
						// If it is the same, then just add it to the currentEntries array.
						// If it is different, or if it is a new one, then we need to
						// see if it already exists in the index.
						// If it exists, then add it to the currentEntries array.
						// If it does not exist, we have to create it, and add it to the currentEntries array.
						List<string> rgsFromDummy = new List<string>();
						if (GetReversalFormsAndCheckExisting(currentEntries, hvoIndex,
							revIndex.WritingSystemRAHvo, j, hvoEntry, rgsFromDummy))
						{
							continue;
						}
						// At this point, we need to find or create one or more entries.
						int hvo = revIndex.FindOrCreateReversalEntry(rgsFromDummy);
						currentEntries.Add(hvo);
						if (hvoEntry == hvoDummy)
							hvoReal = hvo;
					}
				}
				// Reset the sense's ref. property to all the ids in the currentEntries array.
				int[] ids = currentEntries.ToArray();
				int senseFlid = (int)LexSense.LexSenseTags.kflidReversalEntries;
				if (!m_fdoCache.IsValidObject(m_sense.Hvo))
					return 0; // our object has been deleted while we weren't looking!
				int countEntries = m_fdoCache.GetVectorSize(m_sense.Hvo, senseFlid);
				// Check the current state and don't save (or create an Undo stack item) if
				// nothing has changed.
				bool fChanged = true;
				if (countEntries == ids.Length)
				{
					fChanged = false;
					for (int i = 0; i < countEntries; ++i)
					{
						int id = m_fdoCache.GetVectorItem(m_sense.Hvo, senseFlid, i);
						if (id != ids[i])
						{
							fChanged = true;
							break;
						}
					}
				}
				if (fChanged)
				{
					m_fdoCache.BeginUndoTask(LexEdStrings.ksUndoSetRevEntries,
						LexEdStrings.ksRedoSetRevEntries);
					m_fdoCache.ReplaceReferenceProperty(m_sense.Hvo, senseFlid, 0, countEntries, ref ids);
					m_fdoCache.EndUndoTask();
					// Also recompute and issue a PropChanged for the virtual property which may be displaying these
					// senses as a string in bulk edit.
					IVwVirtualHandler vh = m_fdoCache.VwCacheDaAccessor.GetVirtualHandlerName("LexSense",
						LexSenseReversalEntriesTextHandler.StandardFieldName);
					if (vh != null)
					{
						foreach (int ws in writingSystemsModified)
						{
							vh.Load(m_sense.Hvo, vh.Tag, ws, m_fdoCache.VwCacheDaAccessor);
							m_fdoCache.PropChanged(m_sense.Hvo, vh.Tag, ws, 0, 0);
						}
					}
				}
				return hvoReal;
			}
예제 #22
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Returns a set of NamedWritingSystem objects for the current pronunciation
		/// writing systems.  If that set is empty, writing systems from the vernacular set
		/// with ICULocale variants of IPA or EMC are added to the current pronunciation writing
		/// systems.  If the pronunciation set is still empty, the first vernacular writing
		/// system is added to it.
		/// </summary>
		/// <returns>
		/// Set of current pronunciation writing systems as NamedWritingSystem objects
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public Set<NamedWritingSystem> GetPronunciationWritingSystems()
		{
			InitializePronunciationWritingSystems();
			string displayLocale =
				m_cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(m_cache.DefaultUserWs);
			Set<NamedWritingSystem> writingSystems = GetDbNamedWritingSystems();
			ILgWritingSystem wsVern = CurVernWssRS[0];
			string sVern = wsVern.ICULocale;
			int idx = sVern.IndexOf("_");
			if (idx > 0)
				sVern = sVern.Substring(0, idx + 1).ToLowerInvariant();
			else
				sVern = sVern.ToLower() + "_";
			Set<NamedWritingSystem> pronunciationWritingSystems =
				new Set<NamedWritingSystem>(CurPronunWssRS.Count + 1);
			AddWsNamedObjsToSet(pronunciationWritingSystems, CurPronunWssRS, displayLocale);
			foreach (NamedWritingSystem nws in writingSystems)
			{
				if (nws.IcuLocale == wsVern.ICULocale || nws.IcuLocale.IndexOf(sVern) == 0)
					pronunciationWritingSystems.Add(nws);
			}
			return pronunciationWritingSystems;
		}
		// utility function for finding the correct order to process directories
		List<SolutionFolderItem> CalculateSubDirOrder (AutotoolsContext ctx, SolutionFolder folder, SolutionConfiguration config)
		{
			List<SolutionFolderItem> resultOrder = new List<SolutionFolderItem>();
			Set<SolutionFolderItem> dependenciesMet = new Set<SolutionFolderItem>();
			Set<SolutionFolderItem> inResult = new Set<SolutionFolderItem>();
			
			// We don't have to worry about projects built in parent combines
			dependenciesMet.Union (ctx.GetBuiltProjects ());

			bool added;
			string notMet;
			do 
			{
				added = false;
				notMet = null;
				
				List<SolutionFolderItem> items = new List<SolutionFolderItem> ();
				GetSubItems (items, folder);

				foreach (SolutionFolderItem item in items) 
				{
					Set<SolutionFolderItem> references, provides;
					
					if (inResult.Contains (item))
						continue;
					
					if (item is SolutionItem)
					{
						SolutionItem entry = (SolutionItem) item;
						if (!config.BuildEnabledForItem (entry))
							continue;
						
						references = new Set<SolutionFolderItem> ();
						provides = new Set<SolutionFolderItem>();
						references.Union (entry.GetReferencedItems (config.Selector));
						provides.Add (entry);
					}
					else if (item is SolutionFolder) {
						GetAllProjects ((SolutionFolder) item, config, out provides, out references);
					}
					else
						continue;
	
					if (dependenciesMet.ContainsSet (references) ) 
					{
						resultOrder.Add (item);
						dependenciesMet.Union(provides);
						inResult.Add(item);
						added = true;
					} 
					else notMet = item.Name;
				}
			} while (added);

			if (notMet != null) 
				throw new Exception("Impossible to find a solution order that satisfies project references for '" + notMet + "'");

			return resultOrder;
		}
예제 #24
0
		/// <summary>
		/// Get a Set of zero or more actual writing system IDs for the given ws identifier.
		/// </summary>
		/// <param name="sWs">One of our magic strings that signifies one or more writing systems</param>
		/// <param name="cache"></param>
		/// <param name="currentWS"></param>
		/// <param name="hvo">object to use in determining 'best' names</param>
		/// <param name="flid">flid to use in determining 'best' names</param>
		/// <returns></returns>
		public static Set<int> GetAllWritingSystems(string sWs, FdoCache cache, IWritingSystem currentWS, int hvo, int flid)
		{
			Set<int> allWsIds = new Set<int>();
			if (sWs != null)
			{
				switch (sWs)
				{
					case "all analysis":
						allWsIds.AddRange(cache.LangProject.CurAnalysisWssRS.HvoArray);
						break;
					case "all vernacular":
						allWsIds.AddRange(cache.LangProject.CurVernWssRS.HvoArray);
						break;
					case "analysis vernacular":
						allWsIds.AddRange(cache.LangProject.CurAnalysisWssRS.HvoArray);
						allWsIds.AddRange(cache.LangProject.CurVernWssRS.HvoArray);
						break;
					case "vernacular analysis":
						allWsIds.AddRange(cache.LangProject.CurVernWssRS.HvoArray);
						allWsIds.AddRange(cache.LangProject.CurAnalysisWssRS.HvoArray);
						break;
					case "all pronunciation":
						cache.LangProject.InitializePronunciationWritingSystems();
						allWsIds.AddRange(cache.LangProject.CurPronunWssRS.HvoArray);
						//if (allWsIds.Count == 0)
						//	allWsIds.Add(cache.LangProject.DefaultPronunciationWritingSystem);
						break;
					default:
						sWs = GetWsSpecWithoutPrefix(sWs);
						string[] rgsWs = sWs.Split(new char[] { ',' });
						for (int i = 0; i < rgsWs.Length; ++i)
						{
							int ws = InterpretWsLabel(cache, rgsWs[i], 0, hvo, flid, currentWS);
							if (ws != 0)
								allWsIds.Add(ws);
						}
						break;
				}
			}

			return allWsIds;
		}
예제 #25
0
		static void CheckModifiedFiles ()
		{
			// Check databases following a bottom-up strategy in the dependency
			// tree. This will help resolving parsed classes.
			
			Set<ProjectDom> list = new Set<ProjectDom> ();
			lock (databases) {
				// There may be several uris for the same db
				foreach (ProjectDom ob in databases.Values)
					list.Add (ob);
			}
			
			Set<ProjectDom> done = new Set<ProjectDom> ();
			while (list.Count > 0) 
			{
				ProjectDom readydb = null;
				ProjectDom bestdb = null;
				int bestRefCount = int.MaxValue;
				
				// Look for a db with all references resolved
				foreach (ProjectDom db in list)
				{
					bool allDone = true;
					foreach (ProjectDom refdb in db.References) {
						if (!done.Contains (refdb)) {
							allDone = false;
							break;
						}
					}
					
					if (allDone) {
						readydb = db;
						break;
					}
					else if (db.References.Count < bestRefCount) {
						bestdb = db;
						bestRefCount = db.References.Count;
						break;
					}
				}

				// It may not find any db without resolved references if there
				// are circular dependencies. In this case, take the one with
				// less references
				
				if (readydb == null)
					readydb = bestdb;
				
				readydb.CheckModifiedFiles ();
				list.Remove (readydb);
				done.Add (readydb);
			}
		}
예제 #26
0
		/// <summary>
		/// Return the possible writing systems that we might want to preload for the given fragment.
		/// Note that currently this is for optimization and preloading; it is not (yet) guaranteed to
		/// return EVERY writing system that might be displayed by the given fragment.
		/// </summary>
		/// <param name="frag"></param>
		/// <param name="cache"></param>
		/// <returns></returns>
		public static Set<int> GetWritingSystems(XmlNode frag, FdoCache cache)
		{
			string wsSpec = null;
			XmlAttribute xa = frag.Attributes["ws"];
			if (xa == null)
				return new Set<int>(0);
			wsSpec = GetWsSpecWithoutPrefix(xa.Value);
			Set<int> result = new Set<int>();

			switch (wsSpec)
			{
				case "vernacular":
					result.Add(cache.DefaultVernWs);
					break;
				case "analysis":
					result.Add(cache.DefaultAnalWs);
					break;
				case "pronunciation":
				case "all pronunciation":
					result.Add(cache.LangProject.DefaultPronunciationWritingSystem);
					break;
				case "current":
					break;
				case "reversal":
					// Enhance JohnT: make this (currently for optimization preloading) routine work
					// better for reversal views
					//actualWS = GetReversalIndexEntryWritingSystem(cache, hvoObj, wsDefault);
					break;
				case "best analorvern":
				case "best vernoranal":
					return cache.LangProject.CurrentAnalysisAndVernWss;
				// Enhance JohnT: make this (currently for optimization preloading) routine work
				// better for the above two cases: possibly add all current analysis and vernacular writing systems
				case "analysis vernacular":
				case "av":
				case "vernacular analysis":
				case "va":
					result.Add(cache.DefaultVernWs);
					result.Add(cache.DefaultAnalWs);
					break;
				case "user":
					result.Add(cache.DefaultUserWs);
					break;
				case "best analysis":
				case "all analysis":
					result.AddRange(cache.LangProject.CurAnalysisWssRS.HvoArray);
					break;
				case "best vernacular":
				case "all vernacular":
					result.AddRange(cache.LangProject.CurVernWssRS.HvoArray);
					break;
				default:
					// See if we can get anywhere by treating it as an ICU locale.
					// Note that it is important to do this in a way that won't create a new writing system for
					// an invalid locale name, for example, if 'all analysis' is mistakenly passed to this routine.
					// Note however that the behavior of recognizing an ICU locale name for an existing writing system
					// definitely IS needed, e.g., when the user configures a Browse view to show an explicit writing system.
					int wsT = cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr(wsSpec);
					if (wsT != 0)
						result.Add(wsT);
					break;
			}
			return result;
		}
예제 #27
0
		public override void DeleteMultipleItems ()
		{
			Set<IWorkspaceFileObject> items = new Set<IWorkspaceFileObject> ();
			foreach (ITreeNavigator node in CurrentNodes) {
				Solution solution = node.DataItem as Solution;
				Workspace parent = node.GetParentDataItem (typeof(Workspace), false) as Workspace;
				if (parent == null) return;
				
				if (MessageService.Confirm (GettextCatalog.GetString ("Do you really want to remove solution {0} from workspace {1}?", solution.Name, parent.Name), AlertButton.Remove)) {
					if (IdeApp.Workspace.RequestItemUnload (solution)) {
						parent.Items.Remove (solution);
						solution.Dispose ();
						items.Add (parent);
					}
				}
			}
			IdeApp.ProjectOperations.Save (items);
		}
예제 #28
0
		/// <summary>
		/// Try to get an actual writing system id from some ws string specification.
		/// If it does not recognize the ws spec string, it returns 0.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="wsSpec"></param>
		/// <param name="wsDefault"></param>
		/// <param name="hvoObj"></param>
		/// <param name="flid"></param>
		/// <param name="currentWS"></param>
		/// <returns>A Set of writing system ids, or an empty Set, if it can't recognize the wsSpec parameter.</returns>
		internal static Set<int> GetWritingSystemIdsFromLabel(FdoCache cache, string wsSpec, int wsDefault, int hvoObj, int flid, IWritingSystem currentWS)
		{
			Set<int> writingSystemIds = new Set<int>();

			switch (wsSpec.Trim().ToLowerInvariant())
			{
				case "all analysis":
					{
						writingSystemIds.AddRange(cache.LangProject.CurAnalysisWssRS.HvoArray);
						break;
					}
				case "all vernacular":
					{
						writingSystemIds.AddRange(cache.LangProject.CurVernWssRS.HvoArray);
						break;
					}
				case "analysis vernacular":
					{
						writingSystemIds.AddRange(cache.LangProject.CurAnalysisWssRS.HvoArray);
						writingSystemIds.AddRange(cache.LangProject.CurVernWssRS.HvoArray);
						break;
					}
				case "vernacular analysis":
					{
						writingSystemIds.AddRange(cache.LangProject.CurVernWssRS.HvoArray);
						writingSystemIds.AddRange(cache.LangProject.CurAnalysisWssRS.HvoArray);
						break;
					}
				default:
					writingSystemIds.Add(InterpretWsLabel(cache, wsSpec, wsDefault, hvoObj, flid, currentWS));
					break;
			}

			return writingSystemIds;
		}
        /// <summary>
        ///     Determines which types are produced by this mapping.
        /// </summary>
        private Set<EntityType> FindUnambiguouslyReachableTypes(
            DomainConstraintConversionContext<string, ValueCondition> converter, Vertex[] mappingConditions)
        {
            // For each entity type, create a candidate function that evaluates to true given
            // discriminator assignments iff. all of that type's conditions evaluate to true.
            var candidateFunctions = new Vertex[MappedEntityTypes.Count];
            for (var i = 0; i < candidateFunctions.Length; i++)
            {
                // Seed the candidate function conjunction with 'true'.
                var candidateFunction = Vertex.One;
                for (var j = 0; j < NormalizedEntityTypeMappings.Count; j++)
                {
                    var entityTypeMapping = NormalizedEntityTypeMappings[j];

                    // Determine if this mapping is a positive or negative case for the current type.
                    if (entityTypeMapping.ImpliedEntityTypes[i])
                    {
                        candidateFunction = converter.Solver.And(candidateFunction, mappingConditions[j]);
                    }
                }
                candidateFunctions[i] = candidateFunction;
            }

            // Make sure that for each type with satisfiable candidateFunction all assignments for the type resolve to only that type.
            var unambigouslyReachableMap = new BitArray(candidateFunctions.Length, true);
            for (var i = 0; i < candidateFunctions.Length; ++i)
            {
                if (candidateFunctions[i].IsZero())
                {
                    // The i-th type is unreachable regardless of other types.
                    unambigouslyReachableMap[i] = false;
                }
                else
                {
                    for (var j = i + 1; j < candidateFunctions.Length; ++j)
                    {
                        if (!converter.Solver.And(candidateFunctions[i], candidateFunctions[j]).IsZero())
                        {
                            // The i-th and j-th types have common assignments, hence they aren't unambiguously reachable.
                            unambigouslyReachableMap[i] = false;
                            unambigouslyReachableMap[j] = false;
                        }
                    }
                }
            }
            var reachableTypes = new Set<EntityType>();
            for (var i = 0; i < candidateFunctions.Length; ++i)
            {
                if (unambigouslyReachableMap[i])
                {
                    reachableTypes.Add(MappedEntityTypes[i]);
                }
            }

            return reachableTypes;
        }
예제 #30
0
		public override void OnMultipleNodeDrop (object[] dataObjects, DragOperation operation)
		{
			Set<IWorkspaceFileObject> toSave = new Set<IWorkspaceFileObject> ();
			foreach (object dataObject in dataObjects) {
				Workspace ws = (Workspace) CurrentNode.DataItem;
				WorkspaceItem it = (WorkspaceItem) dataObject;
				
				if (!MessageService.Confirm (GettextCatalog.GetString ("Are you sure you want to move the item '{0}' to the workspace '{1}'?", it.Name, ws.Name), AlertButton.Move))
					return;
				
				if (it.ParentWorkspace != null) {
					it.ParentWorkspace.Items.Remove (it);
					ws.Items.Add (it);
					toSave.Add (it.ParentWorkspace);
					toSave.Add (ws);
				} else {
					IdeApp.Workspace.Items.Remove (it);
					ws.Items.Add (it);
					toSave.Add (ws);
				}
			}
			IdeApp.ProjectOperations.Save (toSave);
		}