[fixes bug#5532]
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@36823 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
561ec785b9
commit
7d3df63668
|
@ -6,8 +6,8 @@ import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.zkoss.zk.ui.Desktop;
|
import org.zkoss.zk.ui.Desktop;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
|
@ -25,11 +25,14 @@ public class MenuFactoryPropertiesImpl implements MenuFactory {
|
||||||
|
|
||||||
private List<No> tree = new ArrayList<No>();// Una lista con los itens del menu
|
private List<No> tree = new ArrayList<No>();// Una lista con los itens del menu
|
||||||
private BufferedReader menuReader; // El reader para leer el properties como un archivo texto
|
private BufferedReader menuReader; // El reader para leer el properties como un archivo texto
|
||||||
private Properties miProperties; // El properties cargado normalmente. Asi se puede ocupar con las claves, etc
|
|
||||||
private Desktop desktop; // Desktop de la aplicación
|
private Desktop desktop; // Desktop de la aplicación
|
||||||
private List<UsuarioPerfil> listUsuarioPerfil;// El perfil del usuario
|
private List<UsuarioPerfil> listUsuarioPerfil;// El perfil del usuario
|
||||||
private List<String> listClavesPermisos;
|
private List<String> listClavesPermisos;
|
||||||
|
|
||||||
|
public MenuFactoryPropertiesImpl() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public MenuFactoryPropertiesImpl(Desktop desktop, List<UsuarioPerfil> listUsuarioPerfil) {
|
public MenuFactoryPropertiesImpl(Desktop desktop, List<UsuarioPerfil> listUsuarioPerfil) {
|
||||||
super();
|
super();
|
||||||
this.desktop = desktop;
|
this.desktop = desktop;
|
||||||
|
@ -59,7 +62,7 @@ public class MenuFactoryPropertiesImpl implements MenuFactory {
|
||||||
this.contruir(null);
|
this.contruir(null);
|
||||||
|
|
||||||
for (No no : tree) {
|
for (No no : tree) {
|
||||||
String klass = miProperties.getProperty(no.getNombre());
|
String klass = no.getKlass();
|
||||||
|
|
||||||
Menu menu = this.createMenu(klass);
|
Menu menu = this.createMenu(klass);
|
||||||
menuBar.appendChild(menu);
|
menuBar.appendChild(menu);
|
||||||
|
@ -80,7 +83,7 @@ public class MenuFactoryPropertiesImpl implements MenuFactory {
|
||||||
*/
|
*/
|
||||||
private void contruirMenus(No no, Menu menu) {
|
private void contruirMenus(No no, Menu menu) {
|
||||||
for (No noH : no.getHijos()) {
|
for (No noH : no.getHijos()) {
|
||||||
String klass = miProperties.getProperty(noH.getNombre());
|
String klass = noH.getKlass();
|
||||||
if (noH.getHijos().isEmpty()) {
|
if (noH.getHijos().isEmpty()) {
|
||||||
Menupopup menupopup = menu.getMenupopup();
|
Menupopup menupopup = menu.getMenupopup();
|
||||||
if (menupopup == null) {
|
if (menupopup == null) {
|
||||||
|
@ -96,7 +99,7 @@ public class MenuFactoryPropertiesImpl implements MenuFactory {
|
||||||
nuevoMenupopup.appendChild(menuHijo);
|
nuevoMenupopup.appendChild(menuHijo);
|
||||||
Menupopup menupopup = menu.getMenupopup();
|
Menupopup menupopup = menu.getMenupopup();
|
||||||
|
|
||||||
menupopup.appendChild(nuevoMenupopup);
|
menupopup.appendChild(menuHijo);
|
||||||
contruirMenus(noH, menuHijo);
|
contruirMenus(noH, menuHijo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,40 +112,34 @@ public class MenuFactoryPropertiesImpl implements MenuFactory {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void contruir(No noPadre) throws IOException {
|
public void contruir(No noPadre) throws IOException {
|
||||||
String linea = menuReader.readLine();
|
String linea = null;
|
||||||
|
|
||||||
if (linea == null) {
|
while((linea = menuReader.readLine()) != null){
|
||||||
return;
|
No no = new No(linea);
|
||||||
}
|
|
||||||
|
|
||||||
String[] arregloLinea = linea.split("=");
|
if (no.getNivel() == 1){
|
||||||
|
tree.add(no);
|
||||||
if (noPadre == null) {
|
}else{
|
||||||
No padre = new No(arregloLinea[0]);
|
for(No n1: tree){
|
||||||
tree.add(padre);
|
if (adicionarFilho(no, n1)){
|
||||||
this.contruir(padre);
|
|
||||||
} else {
|
|
||||||
No hijo = new No(arregloLinea[0]);
|
|
||||||
|
|
||||||
if (hijo.getNivel() == 1) {
|
|
||||||
tree.add(hijo);
|
|
||||||
contruir(hijo);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ((noPadre.getNivel() + 1) == hijo.getNivel()) {
|
|
||||||
noPadre.add(hijo);
|
|
||||||
contruir(hijo);
|
|
||||||
} else {
|
|
||||||
for (No no : tree) {
|
|
||||||
if (((no.getNivel() + 1) == hijo.getNivel()) && (hijo.getNombre().startsWith(no.getNombre()))) {
|
|
||||||
no.add(hijo);
|
|
||||||
contruir(no);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
private boolean adicionarFilho(No noHijo,No noPadre){
|
||||||
|
boolean encontrou = false;
|
||||||
|
if (noPadre.getNombre().equals(noHijo.getPadre())){
|
||||||
|
noPadre.getHijos().add(noHijo);
|
||||||
|
encontrou=true;
|
||||||
|
}else{
|
||||||
|
for(No n1 : noPadre.getHijos()){
|
||||||
|
encontrou=adicionarFilho(noHijo, n1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return encontrou;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,9 +153,6 @@ public class MenuFactoryPropertiesImpl implements MenuFactory {
|
||||||
|
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
Menu j = new Menu(item.getDescItemMenu());
|
Menu j = new Menu(item.getDescItemMenu());
|
||||||
// if (item.getClaveMenu() != null) { não é usado. O arquivo de menu que deve controlar isso
|
|
||||||
// j.setVisible(listClavesPermisos.contains(item.getClaveMenu()));
|
|
||||||
// }
|
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -203,8 +197,6 @@ public class MenuFactoryPropertiesImpl implements MenuFactory {
|
||||||
|
|
||||||
classe = (ItemMenuSistema) c.newInstance();
|
classe = (ItemMenuSistema) c.newInstance();
|
||||||
classe.setDesktop(desktop);
|
classe.setDesktop(desktop);
|
||||||
// Constructor constructor = c.getConstructor(new Class[]{Desktop.class});
|
|
||||||
// classe = (ItemMenuSistema) constructor.newInstance(Executions.getCurrent().getDesktop());
|
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new MenuNoExisteException("El menu " + strClass + " no fue encontrado.", e);
|
throw new MenuNoExisteException("El menu " + strClass + " no fue encontrado.", e);
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
|
@ -224,11 +216,6 @@ public class MenuFactoryPropertiesImpl implements MenuFactory {
|
||||||
private void cargarMenuProperties() throws IOException {
|
private void cargarMenuProperties() throws IOException {
|
||||||
InputStream miStream = this.getClass().getResourceAsStream("/com/rjconsultores/ventaboletos/web/cliente/menu/menu.properties");
|
InputStream miStream = this.getClass().getResourceAsStream("/com/rjconsultores/ventaboletos/web/cliente/menu/menu.properties");
|
||||||
menuReader = new BufferedReader(new InputStreamReader(miStream));
|
menuReader = new BufferedReader(new InputStreamReader(miStream));
|
||||||
|
|
||||||
InputStream miStream2 = this.getClass().getResourceAsStream("/com/rjconsultores/ventaboletos/web/cliente/menu/menu.properties");
|
|
||||||
|
|
||||||
miProperties = new Properties();
|
|
||||||
miProperties.load(miStream2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -237,13 +224,27 @@ public class MenuFactoryPropertiesImpl implements MenuFactory {
|
||||||
* @author gleimar
|
* @author gleimar
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class No {
|
public static class No {
|
||||||
String nombre;
|
String nombre;
|
||||||
List<No> hijos;
|
List<No> hijos;
|
||||||
|
String klass;
|
||||||
|
String padre;
|
||||||
|
String path;
|
||||||
|
|
||||||
public No(String nombre) {
|
public No(String linea){
|
||||||
this.nombre = nombre;
|
hijos = new ArrayList<No>();;
|
||||||
this.hijos = new ArrayList<No>();
|
String[] arrayLinea = linea.split("=");
|
||||||
|
|
||||||
|
path=arrayLinea[0];
|
||||||
|
klass=arrayLinea[1];
|
||||||
|
|
||||||
|
String[] tmp = path.split("\\.");
|
||||||
|
if (tmp.length != 1){
|
||||||
|
padre = tmp[tmp.length-2];
|
||||||
|
nombre = tmp[tmp.length-1];
|
||||||
|
}else{
|
||||||
|
nombre = tmp[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public No(String nombre, String hijo) {
|
public No(String nombre, String hijo) {
|
||||||
|
@ -280,9 +281,50 @@ public class MenuFactoryPropertiesImpl implements MenuFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNivel() {
|
public int getNivel() {
|
||||||
return nombre.split("\\.").length;
|
return path.split("\\.").length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getKlass() {
|
||||||
|
return klass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setKlass(String klass) {
|
||||||
|
this.klass = klass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPadre() {
|
||||||
|
return padre;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
public void print(){
|
||||||
|
Integer nivel = 1;
|
||||||
|
for(No n : tree){
|
||||||
|
System.out.println(StringUtils.repeat("*", nivel)+n.getNombre());
|
||||||
|
print(n, nivel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void print(No n,Integer nivel){
|
||||||
|
int mNivel = nivel+1;
|
||||||
|
for(No n1 : n.getHijos()){
|
||||||
|
System.out.println(StringUtils.repeat("*", mNivel)+n1.getNombre());
|
||||||
|
if (!n1.getHijos().isEmpty()){
|
||||||
|
print(n1, mNivel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void main(String args[]){
|
||||||
|
try {
|
||||||
|
MenuFactoryPropertiesImpl menuFactoryTestes = new MenuFactoryPropertiesImpl();
|
||||||
|
menuFactoryTestes.cargarMenuProperties();
|
||||||
|
menuFactoryTestes.contruir(null);
|
||||||
|
menuFactoryTestes.print();
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.rjconsultores.ventaboletos.web.utilerias.menu.item.tarifas.segopcional;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.menu.DefaultItemMenuSistema;
|
||||||
|
|
||||||
|
public class SubMenuSegOpcional extends DefaultItemMenuSistema {
|
||||||
|
|
||||||
|
public SubMenuSegOpcional() {
|
||||||
|
super("indexController.mnSubSegOpcional.label");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getClaveMenu() {
|
||||||
|
return "COM.RJCONSULTORES.ADMINISTRACION.GUI.TARIFAS";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -88,6 +88,7 @@ indexController.mnConfiguracionesComerciales.label = Configuración comercial
|
||||||
indexController.mnEsquemaOperacional.label = Esquema operacional
|
indexController.mnEsquemaOperacional.label = Esquema operacional
|
||||||
indexController.mnPricing.label = Pricing
|
indexController.mnPricing.label = Pricing
|
||||||
indexController.mnTarifas.label = Adm. de precio
|
indexController.mnTarifas.label = Adm. de precio
|
||||||
|
indexController.mnSubSegOpcional.label= Seg. Opcional
|
||||||
indexController.mnTarifasOficial.label = Cálculo de precio
|
indexController.mnTarifasOficial.label = Cálculo de precio
|
||||||
indexController.mnSendaAmigo.label = Pasajero frecuente
|
indexController.mnSendaAmigo.label = Pasajero frecuente
|
||||||
indexController.mniMarcas.label = Marcas
|
indexController.mniMarcas.label = Marcas
|
||||||
|
|
|
@ -90,6 +90,7 @@ indexController.mnConfiguracionesComerciales.label = Configuração Comercial
|
||||||
indexController.mnEsquemaOperacional.label = Esquema Operacional
|
indexController.mnEsquemaOperacional.label = Esquema Operacional
|
||||||
indexController.mnPricing.label = Pricing
|
indexController.mnPricing.label = Pricing
|
||||||
indexController.mnTarifas.label = Adm. de Preço
|
indexController.mnTarifas.label = Adm. de Preço
|
||||||
|
indexController.mnSubSegOpcional.label= Seg. Opcional
|
||||||
indexController.mnTarifasOficial.label = Cálculo de Preço
|
indexController.mnTarifasOficial.label = Cálculo de Preço
|
||||||
indexController.mnSendaAmigo.label = Passageiro Frequente
|
indexController.mnSendaAmigo.label = Passageiro Frequente
|
||||||
indexController.mniMarcas.label = Marcas
|
indexController.mniMarcas.label = Marcas
|
||||||
|
|
Loading…
Reference in New Issue