Esempio n. 1
0
        public static GISADataset.NivelRow GetNivelED(GISATreeNode produtor)
        {
            while (produtor.Parent != null)
            {
                produtor = (GISATreeNode)produtor.Parent;
            }

            return(produtor.NivelRow);
        }
Esempio n. 2
0
		// constroi uma chave que permite indexar um nó na hashtable
		public static string getKey(GISATreeNode node)
		{
			if (node.NivelUpperRow == null)
			{
				return node.NivelRow.ID.ToString() + ":";
			}
			else
			{
				return node.NivelRow.ID.ToString() + ":" + node.NivelUpperRow.ID.ToString();
			}
		}
Esempio n. 3
0
//INSTANT C# NOTE: C# does not support optional parameters. Overloaded method(s) are created above.
//ORIGINAL LINE: Public Sub RemoveFromTreeview(ByVal node As GISATreeNode, Optional ByVal key As String = null)
		public void RemoveFromTreeview(GISATreeNode node, string key)
		{
			Hashtable table = tableEstrutural;

			node.Remove();
			if (table != null)
			{
				object somethingAlreadyThere = null;
				ArrayList nodesAlreadyThere = null;
				GISATreeNode nodeAlreadyThere = null;
				if (key == null)
				{
					somethingAlreadyThere = table[getKey(node)];
				}
				else
				{
					somethingAlreadyThere = table[key];
				}
				if (somethingAlreadyThere is GISATreeNode)
				{
					table.Remove(somethingAlreadyThere);
				}
				else // trata-se de um arraylist
				{
					Debug.Assert(somethingAlreadyThere is ArrayList);
					nodesAlreadyThere = (ArrayList)somethingAlreadyThere;
					//For Each nodeAlreadyThere As GISATreeNode In nodesAlreadyThere
					//    If nodeAlreadyThere Is node Then
					//        nodesAlreadyThere.Remove(nodeAlreadyThere)
					//    End If
					//Next


					int i = 0;
					while (i < nodesAlreadyThere.Count)
					{
						nodeAlreadyThere = (GISATreeNode)(nodesAlreadyThere[i]);
						if (nodeAlreadyThere == node)
						{
							nodesAlreadyThere.Remove(nodeAlreadyThere);
						}
						else
						{
							i = i + 1;
						}
					}
				}
			}
		}
Esempio n. 4
0
		public void RemoveFromTreeview(GISATreeNode node)
		{
			RemoveFromTreeview(node, null);
		}
Esempio n. 5
0
//INSTANT C# NOTE: C# does not support optional parameters. Overloaded method(s) are created above.
//ORIGINAL LINE: Private Sub AddToTreeview(ByVal nodes As TreeNodeCollection, ByVal node As GISATreeNode, Optional ByVal insertAt As Integer = -1)
		private void AddToTreeview(TreeNodeCollection nodes, GISATreeNode node, int insertAt)
		{

			if (insertAt == -1)
			{
				nodes.Add(node);
			}
			else
			{
				nodes.Insert(insertAt, node);
			}
			AddToTable(node);
		}
Esempio n. 6
0
		private void ExpandNivel(GISATreeNode node)
		{
			GISADataset.NivelRow CurrentNivelUpperRow = node.NivelUpperRow;
			GISADataset.NivelRow CurrentNivelRow = node.NivelRow;
			long startTicks = 0;

			if (CurrentNivelRow == null || CurrentNivelRow.RowState == DataRowState.Detached)
				node.Nodes.Clear();
			else
			{
				try
				{
					// prever a situações onde não se está dentro do frmMain
                    this.Cursor = Cursors.WaitCursor;
					GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
					try
					{
						GisaDataSetHelper.ManageDatasetConstraints(false);

						startTicks = DateTime.Now.Ticks;
						
                        var filhos = DBAbstractDataLayer.DataAccessRules.NivelRule.Current.GetNivelChildren(CurrentNivelRow.ID, SessionHelper.GetGisaPrincipal().TrusteeUserOperator.ID, TipoNivelRelLimitExcl(), ho.Connection);
						DBAbstractDataLayer.DataAccessRules.NivelRule.Current.LoadNivelChildren(CurrentNivelRow.ID, true, GisaDataSetHelper.GetInstance(), ho.Connection);
						Debug.WriteLine("<<Get Tree Nodes>>: " + new TimeSpan(DateTime.Now.Ticks - startTicks).ToString());

						GisaDataSetHelper.ManageDatasetConstraints(true);

						startTicks = DateTime.Now.Ticks;

						trVwLocalizacao.BeginUpdate();
						node.Nodes.Clear();
						accum = 0;
						int iconIndex = 0;

						foreach (DBAbstractDataLayer.DataAccessRules.NivelRule.MyNode filho in filhos) //DBAbstractDataLayer.DataAccessRules.NivelRule.Current.GetSortedData(CurrentNivelRow.ID, ho.Connection)
						{
							iconIndex = System.Convert.ToInt32(filho.TipoNivelRelacionado);
							GISATreeNode newNode = new GISATreeNode(filho.Designacao);

							if (filho.TipoNivel.Trim().Equals("CA"))
                                newNode.ImageIndex = iconIndex == -1 ? SharedResourcesOld.CurrentSharedResources.NivelImageIncognitoControloAut() : SharedResourcesOld.CurrentSharedResources.NivelImageControloAut(iconIndex);
							else
                                newNode.ImageIndex = iconIndex == -1 ? SharedResourcesOld.CurrentSharedResources.NivelImageIncognito() : SharedResourcesOld.CurrentSharedResources.NivelImageBase(iconIndex);

							newNode.SelectedImageIndex = newNode.ImageIndex;

							if (filho.AnoFim != null || filho.AnoInicio != null)
							{
								string data = FormatYearsInterval(filho.AnoInicio, filho.AnoFim);
								if (data.Length > 0)
									newNode.Text = string.Format("{0}   {1}", newNode.Text, data);
							}

							try
							{
								long a = DateTime.Now.Ticks;
								if (filho.Age > 0)
									newNode.Nodes.Add("<A actualizar...>");

								long b = DateTime.Now.Ticks;
								accum += (b - a);
							}
							catch (Exception ex)
							{
								Trace.WriteLine(ex);
								throw;
							}

							newNode.NivelRow = (GISADataset.NivelRow)(GisaDataSetHelper.GetInstance().Nivel.Select("ID = " + filho.IDNivel.ToString())[0]);
							newNode.NivelUpperRow = node.NivelRow;

							node.Nodes.Add(newNode);
                            AddToTable(newNode);
						}
						trVwLocalizacao.EndUpdate();
						Debug.WriteLine("<<EstimateChildCount>>: " + new TimeSpan(accum).ToString());
						Debug.WriteLine("<<Populate Tree Nodes>>: " + new TimeSpan(DateTime.Now.Ticks - startTicks).ToString());
					}
					catch (System.Data.ConstraintException ex)
					{
						Trace.WriteLine(ex);
						Debug.Assert(false, ex.ToString());
						GisaDataSetHelper.FixDataSet(GisaDataSetHelper.GetInstance(), ho.Connection);
					}
					finally
					{
						ho.Dispose();
					}
				}
				finally
				{
                    this.Cursor = Cursors.Default;
				}
			}
		}
		private GISADataset.NivelRow GetSelectedNivelRowED(GISATreeNode selectedNode)
		{
			GISATreeNode parentNode = selectedNode;
			while (parentNode.Parent != null)
				parentNode = (GISATreeNode)parentNode.Parent;
            
            return parentNode.NivelRow;
		}
Esempio n. 8
0
		private bool beforeNewSelection(GISATreeNode node)
		{
			bool selectionChange = false;

			// prever a situações onde não se está dentro do frmMain
            this.Cursor = Cursors.WaitCursor;

			trVwLocalizacao.BeginUpdate();
			try
			{
				BeforeNewSelectionEventArgs e = new BeforeNewSelectionEventArgs(null, null);
				if (node == null)
				{
					e.nivel = null;
					e.node = null;
					if (beforeNewSelectionEvent != null)
						beforeNewSelectionEvent(e);
					selectionChange = e.selectionChange;
				}
				else
				{
					GISADataset.NivelRow nRow = node.NivelRow;
					e.nivel = nRow;
					e.node = node;
					if (beforeNewSelectionEvent != null)
						beforeNewSelectionEvent(e);
					selectionChange = e.selectionChange;
				}
			}
			finally
			{
				trVwLocalizacao.EndUpdate();
                this.Cursor = Cursors.Default;
			}
			return selectionChange;
		}
Esempio n. 9
0
		private void afterNewSelection(GISATreeNode node)
		{
			if (UpdateToolBarButtonsEvent != null)
				UpdateToolBarButtonsEvent(new EventArgs());

			if (node != null && node.NivelRow.RowState != DataRowState.Detached && node.Nodes.Count == 0)
				AddToTable(node);
		}
Esempio n. 10
0
        private void trVwLocalizacao_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
		{
            // Find the node under the mouse.
			GISATreeNode currentNode = (GISATreeNode)(trVwLocalizacao.GetNodeAt(e.X, e.Y));

			if (currentNode == trVwLocalizacao_MouseMove_previousNode)
				return;

			trVwLocalizacao_MouseMove_previousNode = currentNode;

			// See if we have a valid node under mouse pointer
            if (setToolTipEvent != null)
                setToolTipEvent(this, currentNode);
		}
Esempio n. 11
0
		public static ArrayList GetCodigoCompletoCaminhoUnico(GISATreeNode currentNode)
		{
			GISADataset.RelacaoHierarquicaRow rhCurrentRow = null;

			ArrayList result = new ArrayList();
			while (currentNode != null)
			{
				// prever o caso em que um dos nós do caminho foi eliminado (por 
				// outro utilizador). nesse caso não é possível calcular o caminho
				if (currentNode.NivelRow.RowState == DataRowState.Detached)
					return null;

				rhCurrentRow = currentNode.RelacaoHierarquicaRow;
				if (rhCurrentRow != null)
					result.Insert(0, rhCurrentRow);

				currentNode = (GISATreeNode)currentNode.Parent;
			}
			return result;
		}
Esempio n. 12
0
 public void RemoveFromTreeview(GISATreeNode node, string key)
 {
     this.controloNivelListEstrutural1.RemoveFromTreeview(node, key);
 }
Esempio n. 13
0
 public void SelectParentNode(GISATreeNode parentNode)
 {
     this.controloNivelListEstrutural1.SelectParentNode(parentNode);
 }
Esempio n. 14
0
		public ArrayList AddNivel(TreeView trvw, GISADataset.NivelRow nRow, GISADataset.NivelRow nUpperRow, IDbConnection connection)
		{
			ArrayList result = new ArrayList();
			GISATreeNode node = null;
			// Para as EDs (em relação às quais não existem níveis superiores)
			if (nUpperRow == null)
			{
				node = FindTreeNodeByNivelRow(trvw.Nodes, nRow);
				if (node == null)
				{
					node = new GISATreeNode(Nivel.GetDesignacao(nRow));
					//Node.Tag = rhRow
					node.NivelRow = nRow;
					node.NivelUpperRow = null;

					GISADataset.TipoNivelRelacionadoRow tnrRow = null;
					int iconIndex = 0;
					tnrRow = TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(node.NivelRow, node.NivelUpperRow);
					iconIndex = -1;

					if (tnrRow != null)
					{
						iconIndex = System.Convert.ToInt32(tnrRow.GUIOrder);
					}
					if (nRow.CatCode.Trim().Equals("CA"))
					{
						if (iconIndex == -1)
						{
							node.ImageIndex = SharedResourcesOld.CurrentSharedResources.NivelImageIncognitoControloAut();
						}
						else
						{
							node.ImageIndex = SharedResourcesOld.CurrentSharedResources.NivelImageControloAut(iconIndex);
						}
					}
					else
					{
						if (iconIndex == -1)
						{
							node.ImageIndex = SharedResourcesOld.CurrentSharedResources.NivelImageIncognito();
						}
						else
						{
							node.ImageIndex = SharedResourcesOld.CurrentSharedResources.NivelImageBase(iconIndex);
						}
					}
					node.SelectedImageIndex = node.ImageIndex;
					trvw.Nodes.Add(node);
				}
				result.Add(node);
			}
			else
			{
				ArrayList ParentNodes = new ArrayList();
				GISADataset.RelacaoHierarquicaRow[] TempParentRelations = Nivel.GetParentRelations(nRow, nUpperRow, connection);

				//Obter os nós pai com base nas rows pai
				if (TempParentRelations.Length == 0)
				{
					ArrayList nodes = null;
					nodes = AddNivel(trvw, nUpperRow, null, connection);
					ParentNodes.AddRange(nodes);
				}
				foreach (GISADataset.RelacaoHierarquicaRow parentRhRow in TempParentRelations)
				{
					ArrayList nodes = null;
					nodes = AddNivel(trvw, parentRhRow.NivelRowByNivelRelacaoHierarquica, parentRhRow.NivelRowByNivelRelacaoHierarquicaUpper, connection);
					ParentNodes.AddRange(nodes);
				}

				// Neste ponto ParentNodes contém todos os nós a que um nó de nRow deverá ser adicionado
				foreach (TreeNode parentNode in ParentNodes)
				{
					node = FindTreeNodeByNivelRow(parentNode.Nodes, nRow);
					if (node == null)
					{
						node = new GISATreeNode(Nivel.GetDesignacao(nRow));
						//node.Tag = rhRow
						node.NivelRow = nRow;
						node.NivelUpperRow = nUpperRow;
						string data = FormatYearsInterval(node.RelacaoHierarquicaRow);
						if (data.Length > 0)
						{
							node.Text = string.Format("{0}   {1}", node.Text, data);
						}
						if (nRow.CatCode.Trim().Equals("CA"))
						{
							node.ImageIndex = SharedResourcesOld.CurrentSharedResources.NivelImageControloAut(System.Convert.ToInt32(TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(node.RelacaoHierarquicaRow).GUIOrder));
						}
						else
						{
							node.ImageIndex = SharedResourcesOld.CurrentSharedResources.NivelImageBase(System.Convert.ToInt32(TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(node.RelacaoHierarquicaRow).GUIOrder));
						}
						node.SelectedImageIndex = node.ImageIndex;
						parentNode.Nodes.Add(node);
					}
					result.Add(node);
				}
			}
			return result;
		}
Esempio n. 15
0
			public BeforeNewSelectionEventArgs(GISATreeNode node, GISADataset.NivelRow nivel) : base()
			{
				this.node = node;
				this.nivel = nivel;
			}
Esempio n. 16
0
		public void SelectParentNode(GISATreeNode parentNode)
		{
			// parentNode será nothing no caso de eliminarmos o último 
			// nível apresentado (pode ser a ED na vista da estrutura ou 
			// pode ser um nível de estrutura que seja usado como raiz 
			// na vista de documentos)
			trVwLocalizacao.SelectedNode = parentNode;
			if (trVwLocalizacao.SelectedNode != null)
			{
				trVwLocalizacao.SelectedNode.Collapse();
				if (trVwLocalizacao.SelectedNode.Nodes.Count == 0)
				{
					trVwLocalizacao.SelectedNode.Nodes.Add("<A atualizar...>");
				}
				trVwLocalizacao.SelectedNode.Collapse();
				trVwLocalizacao.SelectedNode.Expand();
			}
			else
			{
				// Chegamos a este ponto se estivermos na vista estrutural e 
				// se não existir um nó pai para selecionar após a eliminação 
				// do nó actual. No entanto, na vista estrutural podemos ter 
				// vários nós raiz (várias EDs), por isso ao eliminarmos uma 
				// das raizes podemos tentar selecionar uma outra que possa existir
				if (trVwLocalizacao.Nodes.Count > 0)
				{
					trVwLocalizacao.SelectedNode = trVwLocalizacao.Nodes[0];
				}
				else
				{
					// Apenas no caso de termos removido o último nó existente 
					// é que se dará o caso de não existir uma selecção.
					// Colocar o SelectedNode a Nothing não é o suficiente 
					// para provocar um BeforeSelect na treeview, por isso 
					// forçamos um.
					TreeViewCancelEventArgs cea = null;
					cea = new TreeViewCancelEventArgs(null, false, TreeViewAction.Unknown);
					this.treeviews_BeforeSelect(this, cea);
				}
			}
		}
Esempio n. 17
0
			public itemDragSelectionEventArgs(GISATreeNode node, GISADataset.NivelRow nivel)
			{
				this.node = node;
				this.nivel = nivel;
			}
Esempio n. 18
0
		private void AddToTable(GISATreeNode node)
		{
			Hashtable table = tableEstrutural;

			if (table != null)
			{
				string key = getKey(node);
				object somethingAlreadyThere = null;
				somethingAlreadyThere = table[key];
				// se já existe um ou vários nós
				if (somethingAlreadyThere != null)
				{
					GISATreeNode nodeAlreadyThere = null;
					ArrayList nodesAlreadyThere = null;

					// se se tratar de um nó individual
					if (somethingAlreadyThere is GISATreeNode)
					{
						nodesAlreadyThere = new ArrayList();
						nodeAlreadyThere = (GISATreeNode)somethingAlreadyThere;
						if (nodeAlreadyThere.TreeView != null)
						{
							nodesAlreadyThere.Add(nodeAlreadyThere); // adicionar o nó que já existia naquele ponto
						}
						nodesAlreadyThere.Add(node); // adicionar o novo nó
						table.Remove(key); // remover o nó individual que existia
						table.Add(key, nodesAlreadyThere); // adicionar a arraylist contendo o nó individual anterior e o novo nó a adicionar
					}
					else // trata-se de um arraylist
					{
						Debug.Assert(somethingAlreadyThere is ArrayList);
						nodesAlreadyThere = (ArrayList)somethingAlreadyThere;

						// remover os nós ainda incluidos na hashtable mas que já nao pertençam à treeview
						int i = 0;
						while (i < nodesAlreadyThere.Count)
						{
							nodeAlreadyThere = (GISATreeNode)(nodesAlreadyThere[i]);
							if (nodeAlreadyThere.TreeView == null)
							{
								nodesAlreadyThere.Remove(nodeAlreadyThere);
							}
							else
							{
								i = i + 1;
							}
						}

						if (nodesAlreadyThere.Count > 0)
						{
							nodesAlreadyThere.Add(node);
						}
						else
						{
							table.Remove(key); // remover a arraylist vazia
							table.Add(key, node); // adicionar o novo nó
						}
					}
				}
				else
				{
					table.Add(key, node);
				}
			}

		}
Esempio n. 19
0
		private void AddNivelDesignado(TreeNodeCollection TargetNodes, GISADataset.NivelRow nRow, GISADataset.NivelRow nUpperRow, GISADataset.TipoNivelRelacionadoRow tnrRow, IDbConnection connection)
		{
			GISATreeNode node = new GISATreeNode(Nivel.GetDesignacao(nRow));
			node.NivelRow = nRow;
			node.NivelUpperRow = nUpperRow;
			if (node.RelacaoHierarquicaRow != null)
			{
				string data = FormatYearsInterval(node.RelacaoHierarquicaRow);
				if (data.Length > 0)
					node.Text = string.Format("{0}   {1}", node.Text, data);
			}

			int iconIndex = 0;
			iconIndex = -1;
			if (tnrRow != null)
				iconIndex = System.Convert.ToInt32(tnrRow.GUIOrder);

			if (nRow.CatCode.Trim().Equals("CA"))
                node.ImageIndex = iconIndex == -1 ? SharedResourcesOld.CurrentSharedResources.NivelImageIncognitoControloAut() : SharedResourcesOld.CurrentSharedResources.NivelImageControloAut(iconIndex);
			else
                node.ImageIndex = iconIndex == -1 ? SharedResourcesOld.CurrentSharedResources.NivelImageIncognito() : SharedResourcesOld.CurrentSharedResources.NivelImageBase(iconIndex);

			node.SelectedImageIndex = node.ImageIndex;
			try
			{
				if (nUpperRow == null)
				{
                    if (DBAbstractDataLayer.DataAccessRules.NivelRule.Current.getDirectChildCount(nRow.ID.ToString(), "rh.IDTipoNivelRelacionado != 11", connection) > 0)
                            node.Nodes.Add("<A atualizar...>");
				}
				else
				{
					long a = DateTime.Now.Ticks;
					if (DBAbstractDataLayer.DataAccessRules.NivelRule.Current.EstimateChildCount(nUpperRow.ID.ToString(), true, connection).Contains(nRow.ID))
						node.Nodes.Add("<A atualizar...>");
					long b = DateTime.Now.Ticks;
					accum += (b - a);
				}
			}
			catch (Exception ex)
			{
				Trace.WriteLine(ex);
				throw;
			}
			AddToTreeview(TargetNodes, node, -1);
		}        
Esempio n. 20
0
		private void AddToTreeview(TreeNodeCollection nodes, GISATreeNode node)
		{
			AddToTreeview(nodes, node, -1);
		}
		private void AcceptNode(GISATreeNode node)
		{
			string codigoCompleto = GetCodigoCompleto(node);
			acceptAssociation(((GISATreeNode)node).NivelRow, codigoCompleto);
		}
Esempio n. 22
0
        private bool UpdateContext(GISATreeNode node)
        {
            // foi selecionado um nível estrutural
            bool successfulSave = false;
            GISADataset.NivelRow nRow = null;

            if (this.nivelNavigator1.SelectedNode != null)
            {
                node = this.nivelNavigator1.SelectedNode;
                nRow = ((GISATreeNode)node).NivelRow;
                successfulSave = UpdateContext(nRow);
            }
            else
            {
                nRow = null;
                successfulSave = UpdateContext(nRow);
            }

            if (successfulSave)
                updateContextStatusBar(node);

            return successfulSave;
        }