/** Create a tree of issues with relationship between parent and child issues */ public void loadIssues() { if (this.getIssues() != null) { this.getIssues().clear(); } issueListTree = new DefaultTreeNode("root", null); List<Issue> issuestemp = issueService.findIssuesParent(projectId, sprintId); try { issuestemp.addAll(issueService.findIssuesSingle(sprintId)); } catch (Exception e) { LOGGER.warn(e); } try { for (Issue i : issuestemp) { TreeNode parent = new DefaultTreeNode(String.valueOf(i.getIssueId()), i, issueListTree); parent.setExpanded(true); List<Issue> subissues = issueService.findIssueByParent(i); if (subissues == null || subissues.size() <= 0) { this.getIssues().add(i); } try { for (Issue j : subissues) { new DefaultTreeNode(String.valueOf(j.getIssueId()), j, parent); this.getIssues().add(j); } } catch (Exception e) { LOGGER.warn(e); } } } catch (Exception e) { LOGGER.warn(e); } }
/** * @param parent * @param indexes * @return */ protected TreeNode findNodeFromPath(TreeNode parent, List<Integer> indexes) { if (indexes.size() > 1) { return findNodeFromPath( parent.getChildren().get(indexes.get(0)), indexes.subList(1, indexes.size())); } else { return parent.getChildren().get(indexes.get(0)); } }
public TreeBean(String name, Component treeData) { // root = new DefaultTreeNode("Original File", null); root = new DefaultTreeNode("Root", null); TreeNode level = new DefaultTreeNode(name, root); level.setExpanded(false); generateTreeNode((DefaultTreeNode) level, treeData); }
/** @return the filterNode */ public TreeNode getFilterNode() { if (model != null && model.isInitialized()) { Hierarchy hierarchy = getHierarchy(); if (filterNode == null && hierarchy != null) { this.filterNode = new DefaultTreeNode(); filterNode.setExpanded(true); List<Member> members; boolean isMeasure; try { members = hierarchy.getRootMembers(); isMeasure = hierarchy.getDimension().getDimensionType() == Type.MEASURE; } catch (OlapException e) { throw new FacesException(e); } for (Member member : members) { if (isMeasure && !member.isVisible()) { continue; } MemberNode node = new MemberNode(member); node.setNodeFilter(this); node.setExpanded(true); node.setSelectable(true); node.setSelected(isSelected(member)); filterNode.getChildren().add(node); } List<TreeNode> initialSelection = ((DefaultTreeNode) filterNode) .collectNodes( new NodeCollector() { @Override public boolean collectNode(TreeNode node) { return node.isSelected(); } @Override public boolean searchNode(TreeNode node) { return node.isExpanded(); } }); this.selection = initialSelection.toArray(new TreeNode[initialSelection.size()]); } } else { this.filterNode = null; } return filterNode; }
private void createAvailableColumns() { availableColumns = new DefaultTreeNode("Root", null); TreeNode root = new DefaultTreeNode("Columns", availableColumns); root.setExpanded(true); TreeNode model = new DefaultTreeNode("column", new ColumnModel("Id", "id"), root); TreeNode year = new DefaultTreeNode("column", new ColumnModel("Year", "year"), root); TreeNode manufacturer = new DefaultTreeNode("column", new ColumnModel("Brand", "brand"), root); TreeNode color = new DefaultTreeNode("column", new ColumnModel("Color", "color"), root); }
@SuppressWarnings("unchecked") private static Set<String> toSelection(final TreeNode treeNodes) { Set<String> selection = new HashSet<String>(); for (TreeNode treeNode : treeNodes.getChildren()) { if (treeNode.isSelected()) { selection.add(((Pair<String, String>) treeNode.getData()).getValue()); } } return selection; }
/** Removes all child nodes of the supplied root node. */ private void removeAllChildsOfRootNode(final TreeNode rootNode) { if ((rootNode != null) && (rootNode.getChildCount() > 0)) { final TreeNode[] array = rootNode.getChildren().toArray(new TreeNode[rootNode.getChildCount()]); for (TreeNode child : array) { child.setParent(null); child = null; } } }
/** * Método que carrega a arvore para uma lista de permissoes * * @param permissoes - as permissoes a serem exibidas * @param permissoesParaSelecionar - as permissoes que ficarao selecionadas * @return */ public TreeNode getTreeNode( List<Permissao> permissoes, List<Permissao> permissoesParaSelecionar) { TreeNode root = new DefaultTreeNode(); root.setExpanded(true); Map<Permissao, TreeNode> nodeMap = new LinkedHashMap<Permissao, TreeNode>(); // criar nó para cada permissao for (Permissao permissao : permissoes) { adicionarPermissaoAoMap(root, permissao, nodeMap, permissoes, permissoesParaSelecionar, true); } for (Map.Entry<Permissao, TreeNode> entry : nodeMap.entrySet()) { Permissao permissao = entry.getKey(); TreeNode node = entry.getValue(); if (permissao.getPermissaoPai() != null) { TreeNode parent = nodeMap.get(permissao.getPermissaoPai()); // selecionar apenas ate o segundo nivel if (parent != null && parent.isSelected()) { node.setSelected(true); } node.setExpanded(false); if (parent != null) { parent.getChildren().add(node); } else { root.getChildren().add(node); } } } return root; }
public void displaySelectedMultiple() { if (selectedNodes != null && selectedNodes.length > 0) { StringBuilder builder = new StringBuilder(); for (TreeNode node : selectedNodes) { builder.append(node.getData().toString()); builder.append("<br />"); } FacesMessage message = new FacesMessage("Selected: " + builder.toString()); FacesContext.getCurrentInstance().addMessage(null, message); } }
private void selectClassificationInTree(TreeNode raiz, List<Classification> selectedlist) { List<TreeNode> children = raiz.getChildren(); for (Classification c : selectedlist) { if (raiz.getData() != null && raiz.getData().equals(c)) { raiz.setSelected(true); getSelectednodesList().add(raiz); } } for (TreeNode hijo : children) { selectClassificationInTree(hijo, selectedlist); } }
private void updateNodeForSelected(final TreeNode treeNode, final TreeNode selectedTreeNode) { if ((selectedTreeNode != null) && (treeNode != null)) { if (treeNode == selectedTreeNode) { selectedTreeNode.setSelected(true); } else { treeNode.setSelected(false); } if (treeNode.getChildCount() != 0) { for (final TreeNode child : treeNode.getChildren()) { updateNodeForSelected(child, selectedTreeNode); } } } }
/** * RECURSIVO! Converte a ArvoreSimples para o TreeNode do PrimeFaces. Na primeira chamada, o * segundo argumento deve ser nulo, simbolizando a raiz. O retorno da primeira chamada eh a raiz. */ public TreeNode converterArvoreSimplesParaArvorePrime( ArvoreSimples arvore, TreeNode treeNode, boolean desabilitar, boolean expandir) { TreeNode arvorePrime = null; if (arvore != null) { arvorePrime = new DefaultTreeNode( new ChaveValor<String, String>(arvore.getChave(), arvore.getValor()), treeNode); arvorePrime.setExpanded(expandir); arvorePrime.setSelectable(!desabilitar); for (ArvoreSimples nivel : arvore.getFilhos()) { converterArvoreSimplesParaArvorePrime(nivel, arvorePrime, desabilitar, expandir); } } return arvorePrime; }
/** * Cambio de pestaña de los grupo, enlista las actividades por el grupo seleccionado y refresca el * datatable * * @param event */ public void onTabChange(TabChangeEvent event) { activi = new Actividad(); Grupo gSeleccionado = (Grupo) event.getData(); grupoSeleccionado = gSeleccionado; activi.setEstado(estadoSeleccionado.getData().toString()); actividad = consultarActividades(idusu, activi); actividades = new ArrayList<Actividad>(); if (actividad.getActividads().isEmpty()) { actividades = null; } Grupo g = new Grupo(); for (int i = 0; i < grupos.size(); i++) { if (grupos.get(i).getNombre().compareTo(gSeleccionado.getNombre()) == 0) { g = grupos.get(i); indice = i; } } int j = 0; while (actividad.getActividads().size() > j) { act = actividad.getActividads().get(j); if (act.getIdInstancia().getIdPeriodoGrupoProceso().getIdGrupo().getId().compareTo(g.getId()) == 0) { actividades.add(act); } j++; } }
public void setNode(TreeNode node) { this.node = node; if (node != null) { setFolder((Folder) node.getData()); } }
/** * Metodo que permite cargar los valores de un dto existente y construye el formulario para editar * un registro * * @since 28/01/2014 */ public void editarUbigeo() { this.ubigeoSeleccionadoDto = (UbigeoDto) selectedUbigeo.getData(); this.validarBotonGuardar = this.manager.validarEdicionTipo(this.ubigeoSeleccionadoDto.getUbigeoPadreDto()); this.dto = this.ubigeoSeleccionadoDto; sessionMBean.setAccion(applicationMBean.getEditar()); }
// Lo que se cambio para el Primefaces3.2 private void createClassificationTree() { try { Classification raiz = classificationFacade.findRootByClient(getClient()); classificationList = classificationFacade.getEagerClassificationListByClient(getClient()); root = new DefaultTreeNode("root", null); TreeNode arbol = createTree(getRootFromClassificationList(raiz), getClassificationList()); arbol.setExpanded(true); arbol.setParent(root); // root.getChildren().add(arbol); classificationList = null; } catch (GenericFacadeException ex) { Logger.getLogger(CrudUserphoneBean.class.getName()).log(Level.SEVERE, null, ex); } }
private boolean possuiFilhoSelecionado(TreeNode node) { boolean possui = false; if (node.getChildCount() > 0) { for (TreeNode filho : node.getChildren()) { if (filho.isSelected()) { possui = true; break; } else { possui = possuiFilhoSelecionado(filho); if (possui) { break; } } } } return possui; }
private TreeNode createTree(Classification raiz, Collection<Classification> lista) { TreeNode node = new DefaultTreeNode(raiz, null); TreeNode child = null; Collection<Classification> hijos = getChildren(raiz, lista); for (Classification hijo : hijos) { if (hijo.getClassificationList() != null) { child = createTree(hijo, lista); child.setParent(node); } else { child = new DefaultTreeNode(hijo, node); child.setParent(node); } // node.addChild(child); } return node; }
public void tableToTree() { Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); int colIndex = Integer.parseInt(params.get("colIndex")); // remove from table ColumnModel model = this.columns.remove(colIndex); // add to nodes TreeNode property = new DefaultTreeNode("column", model, availableColumns.getChildren().get(0)); }
public void adicionarPermissaoAoMap( TreeNode root, Permissao permissao, Map<Permissao, TreeNode> nodeMap, List<Permissao> permissoes, List<Permissao> permissoesParaSelecionar, boolean selectable) { TreeNode node = new DefaultTreeNode(permissao, root); node.setExpanded(true); node.setSelectable(selectable); if (permissoesParaSelecionar != null && permissoesParaSelecionar.contains(permissao)) { node.setSelected(true); } nodeMap.put(permissao, node); if (permissao.getPermissaoPai() != null) { Permissao permissaoPai = permissaoDAO.getInitialized(permissao.getPermissaoPai()); if (!permissoes.contains(permissaoPai) && nodeMap.get(permissaoPai) == null) { adicionarPermissaoAoMap( root, permissaoPai, nodeMap, permissoes, permissoesParaSelecionar, false); } } }
/** * Metodo que permite gestionar los dias feriados * * @since 28/01/2014 * @return retorna una valor vacio */ public String gestionFeriados() { this.ubigeoSeleccionadoDto = (UbigeoDto) selectedUbigeo.getData(); if (this.ubigeoSeleccionadoDto.getUbigeoPadreDto().getId() == 0) { FeriadoPaisMBean feriadoPaisMBean = (FeriadoPaisMBean) WebServletContextListener.getApplicationContext().getBean("feriadoPaisMBean"); return feriadoPaisMBean.iniciar(ubigeoSeleccionadoDto); } else { recursosManager.showWarning( UtilCore.Internacionalizacion.getMensajeInternacional("ubigeo.mensaje.no.feriados")); } return ""; }
public void loadStudentTree() { if (this.isLoadStudentTreeFlag()) { if (this.studentBean.getStudent() != null && this.studentBean.getStudent().getId() != null) { Student student = this.studentBean.getStudent(); // Some sorting login need to implemented. this.studentRootNode = new DefaultTreeNode("Root", null); this.studentRootNode.setExpanded(Boolean.TRUE); // Tree for class name node. this.studentNameNode = new DefaultTreeNode(student.getDisplayName(), this.studentRootNode); this.studentNameNode.setSelected(true); this.studentNameNode.setExpanded(true); TreeNode studentAcademicYearsTreeNode = new DefaultTreeNode("Academic years", this.studentNameNode); studentAcademicYearsTreeNode.setExpanded(true); studentAcademicYearsTreeNode.setSelectable(false); Collection<StudentAcademicYear> studentAcademicYears = this.serviceAcademicYearService.findStudentAcademicYearsByStudentId(student.getId()); for (StudentAcademicYear studentAcademicYear : studentAcademicYears) { StudentAcademicYearTreeNode studentAcademicYearTreeNode = new StudentAcademicYearTreeNode( studentAcademicYear.getAcademicYear().getDisplayLabel(), studentAcademicYear.getAcademicYear(), studentAcademicYearsTreeNode); studentAcademicYearTreeNode.setSelectable(true); } this.setLoadStudentTreeFlag(false); } } }
/** * RECURSIVO! Converte o TreeNode do PrimeFaces para a ArvoreSimples Na primeira chamada, o * segundo argumento deve ser nulo, simbolizando a raiz. O retorno da primeira chamada eh a raiz. */ public ArvoreSimples converterArvorePrimeParaArvoreSimples( TreeNode treeNode, ArvoreSimples arvore, boolean apenasSelecionados) { ChaveValor<String, String> chaveValor = (ChaveValor<String, String>) treeNode.getData(); ArvoreSimples arvoreSimples = new ArvoreSimples(chaveValor.getChave(), chaveValor.getValor()); if (arvore != null) { // -- da primeira vez nao tem pai, nas proximas eh a recursao dos filhos arvore.getFilhos().add(arvoreSimples); } if (treeNode.getChildCount() > 0) { for (TreeNode nivel : treeNode.getChildren()) { if (apenasSelecionados) { boolean possui = possuiFilhoSelecionado(nivel); if (!possui && !nivel.isSelected()) { continue; } } converterArvorePrimeParaArvoreSimples(nivel, arvoreSimples, apenasSelecionados); } } return arvoreSimples; }
@Override public String saveEditing() { if (getEntity().getPasswordChr() == null) { getEntity().setPasswordChr(""); getEntity().setChangepasswChr(true); } // SAVE CLASSIFICATION List<Classification> classifList = new ArrayList<Classification>(); selectednodesList = Arrays.asList(selectedNodes); if (getSelectednodesList() != null && getSelectednodesList().size() > 0) { for (TreeNode nodo : getSelectednodesList()) { Classification actualClassif = (Classification) nodo.getData(); if (actualClassif != null) { // Classification classif = // classificationFacade.find(actualClassif.getClassificationCod()); classifList.add(actualClassif); } } } // if (getSelectedRoleclientList() != null && // getSelectedRoleclientList().size() > 0) { getEntity().setRoleClientList(getSelectedRoleclientList()); // } getEntity().setClassificationList(classifList); String retVal = super.saveEditing(); if (getEntity() == null) { setSelectedRoleclientList(null); setSelectednodesList(null); setTreeChecked(false); } return retVal; }
private void prepareBranchTree(final TreeNode branchTreeNode) { // For each of building block type which can be coupled to branch. for (final BuildingBlockConstant buildingBlockType : BuildingBlockConstant.getAllSortedBuildingBlocksForBranchAssemblies()) { Collection<BuildingBlock> branchBuildBlocksByType = null; try { branchBuildBlocksByType = this.buildingBlockService.findBuildingBlocksbyBranchIdAndBuildingBlockType( getBranch().getId(), buildingBlockType); } catch (final ApplicationException ex) { log.info(ex.getMessage()); ViewExceptionHandler.handle(ex); } if ((branchBuildBlocksByType != null) && !branchBuildBlocksByType.isEmpty()) { final TreeNode buildingBlockTypeNode = new DefaultTreeNode(buildingBlockType.getLabel(), branchTreeNode); buildingBlockTypeNode.setExpanded(true); buildingBlockTypeNode.setSelectable(false); final List<BuildingBlock> sortedBuildingBlocks = new ArrayList<BuildingBlock>(branchBuildBlocksByType); Collections.sort( sortedBuildingBlocks, new BuildingBlockComparator(BuildingBlockComparator.NAME)); for (final BuildingBlock buildingBlock : sortedBuildingBlocks) { final BuildingBlockTreeNode buildingBlockTreeNode = new BuildingBlockTreeNode( buildingBlock.getName(), buildingBlock, buildingBlockTypeNode); buildingBlockTreeNode.setSelectable(false); } } } }
/** * Metodo que setea los valores del dto y construye el formulario para crear un nuevo registro * * @since 28/01/2014 */ public void nuevaUbigeo() { this.ubigeoSeleccionadoDto = (UbigeoDto) selectedUbigeo.getData(); this.dto = new UbigeoDto(); this.dto.setEstado(Boolean.TRUE); this.dto.setUsuarioDto(sessionMBean.getSessionUsuarioDto()); this.dto.setFecha(UtilCore.Fecha.obtenerFechaActualDate()); this.dto.setUbigeoPadreDto(this.ubigeoSeleccionadoDto); this.dto.setRetencion(BigDecimal.ZERO); this.dto.setRetencionHonorarios(BigDecimal.ZERO); this.dto.setTipo(this.manager.evaluarTipo(this.ubigeoSeleccionadoDto)); validarBotonGuardar = Boolean.FALSE; sessionMBean.setAccion(applicationMBean.getNuevo()); }
/** * cambia el estado de la actividad pendiente a abierta, inicia la actividad y refresca el * datatable * * @param evento */ public void cambiarEstado(CloseEvent evento) { resul = iniciarActividad(act, sesion_actual); FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(resul.getEstatus())); int j = 0; activi = new Actividad(); activi.setEstado(estadoSeleccionado.toString()); actividad = consultarActividades(idusu, activi); actividades = new ArrayList<Actividad>(); if (actividad.getActividads().isEmpty()) { actividades = null; } while (actividad.getActividads().size() > j) { act = actividad.getActividads().get(j); actividades.add(act); j++; } }
public void onNodeSelect(NodeSelectEvent event) { TreeNode selectedNode = event.getTreeNode(); TreeNode parentNode = selectedNode.getParent(); if (parentNode != root) { log.info("在课程下的某个节点被选择后取得相应的班级,并加载到页面中供教师选择"); classesForChoose = new ArrayList<>(classMap.get(parentNode.getData().toString())); for (Iterator<Tclass> it = classesForChoose.iterator(); it.hasNext(); ) { Tclass tclass = it.next(); if (!tclass.getType().getLabel().equals(selectedNode.getData().toString())) { it.remove(); } } selectedCourse = parentNode.getData().toString(); } }
/** se toma la condicion, la sesion y la actividad y se cierra la actividad a dedo */ public void cerraractividad() { ses = new Sesion(); ses.setIdUsuario(idusu); cond = new Condicion(); cond.setEstado("activa"); resul = finalizarActividad(act, ses, cond); FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(resul.getEstatus())); int j = 0; activi = new Actividad(); activi.setEstado(estadoSeleccionado.toString()); actividad = consultarActividades(idusu, activi); actividades = new ArrayList<Actividad>(); if (actividad.getActividads().isEmpty()) { actividades = null; } while (actividad.getActividads().size() > j) { act = actividad.getActividads().get(j); actividades.add(act); j++; } }
public void treeToTable() { Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); String property = params.get("property"); String droppedColumnId = params.get("droppedColumnId"); String dropPos = params.get("dropPos"); String[] droppedColumnTokens = droppedColumnId.split(":"); int draggedColumnIndex = Integer.parseInt(droppedColumnTokens[droppedColumnTokens.length - 1]); int dropColumnIndex = draggedColumnIndex + Integer.parseInt(dropPos); // add to columns this.columns.add(dropColumnIndex, new ColumnModel(property.toUpperCase(), property)); // remove from nodes TreeNode root = availableColumns.getChildren().get(0); for (TreeNode node : root.getChildren()) { ColumnModel model = (ColumnModel) node.getData(); if (model.getProperty().equals(property)) { root.getChildren().remove(node); break; } } }