elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Estamos en la red social de Mastodon


  Mostrar Mensajes
Páginas: 1 2 3 [4] 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... 63
31  Programación / Java / Re: Incremento y decremento de tamaño de figura en: 27 Octubre 2021, 16:33 pm
XD
32  Programación / Java / Re: Programa de un reloj recibir la hora y mostrarla en 3 relojes con manecillas representados graficamente en: 27 Octubre 2021, 16:33 pm
no se hacen tareas
33  Programación / Programación General / Re: Quiero crear un programa ayuda por favor en: 6 Octubre 2021, 21:16 pm
eso es crear un batch en windows

en google lo encuentras rápido y fácil
34  Programación / Programación General / Re: buen lenguage para programa en: 6 Octubre 2021, 21:03 pm
el problema no es de lenguaje es  no tener el hemisferio de adorno y atrofiado por desuso

en la medida que uses bien la principal herramienta de trabajo podrás aprender cualquier lenguaje en horas o uno o dos días y ser igual o mas productivo que el resto en dias

también el hemisferio izquierdo sirve para resolver cualquier tipo de problemas y puedes trasladar tus habilidades de de resolver problemas de un dominio que aparentemente no tienen ningún tipo de parecido a otro

https://www.youtube.com/watch?v=Hl-zzrqQoSE&list=PLFE2CE09D83EE3E28

y si no te gusto o te resulta difícil programar es una decisión individual
solo se excelente en cualquier cosa que decidas serlo mediocres sobran en cualquier rama

35  Programación / Programación General / Re: No arranca mi aplicacion de Spring boot en: 6 Octubre 2021, 20:56 pm
tines que leer el mensaje de error con calma si tienes que aprender ingles aprendes

falla --generqado por->  catPlantasDaoJpa --generado por--> AreaImpactoVo


AreaImpactoVo es muy probable que tenga mal anotacion jpa

tambien puede ser que en la clase catPlantasDaoJpa (que por nomenclatura de clases deberia comenzar con Mayuscula) no pusiste el autowired a un objeto del tipo AreaImpactoVo
36  Programación / Java / contribucion inspecionar archivos office por dentro en: 5 Octubre 2021, 01:03 am
les presento una herramienta para que puedan ver sus  documento word excel y ppt de office 2003 2007 desde adentro

en futuras entregas mejorare la herramienta para que pueda comparar archivos de office
y también hacer una super búsqueda en varios archivos de office

Código
  1. package office;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6. import java.io.StringReader;
  7. import java.io.StringWriter;
  8. import java.util.ArrayList;
  9. import java.util.Collection;
  10. import java.util.Collections;
  11. import java.util.Comparator;
  12. import java.util.Enumeration;
  13. import java.util.HashMap;
  14. import java.util.HashSet;
  15. import java.util.LinkedHashMap;
  16. import java.util.Set;
  17. import java.util.List;
  18. import java.util.Map;
  19. import java.util.Scanner;
  20. import java.util.Stack;
  21. import java.util.zip.ZipEntry;
  22. import java.util.zip.ZipFile;
  23.  
  24. import javax.xml.XMLConstants;
  25. import javax.xml.parsers.DocumentBuilderFactory;
  26. import javax.xml.transform.OutputKeys;
  27. import javax.xml.transform.Source;
  28. import javax.xml.transform.Transformer;
  29. import javax.xml.transform.TransformerFactory;
  30. import javax.xml.transform.stream.StreamResult;
  31. import javax.xml.transform.stream.StreamSource;
  32.  
  33. import org.w3c.dom.Node;
  34. import org.w3c.dom.bootstrap.DOMImplementationRegistry;
  35. import org.w3c.dom.ls.DOMImplementationLS;
  36. import org.w3c.dom.ls.LSSerializer;
  37. import org.xml.sax.InputSource;
  38.  
  39. import javafx.application.Application;
  40. import javafx.beans.value.ChangeListener;
  41. import javafx.beans.value.ObservableValue;
  42. import javafx.event.ActionEvent;
  43. import javafx.geometry.Insets;
  44. import javafx.geometry.Pos;
  45. import javafx.scene.Scene;
  46. import javafx.scene.control.Alert;
  47. import javafx.scene.control.Button;
  48. import javafx.scene.control.Label;
  49. import javafx.scene.control.Menu;
  50. import javafx.scene.control.MenuBar;
  51. import javafx.scene.control.MenuItem;
  52. import javafx.scene.control.TextArea;
  53. import javafx.scene.control.TextField;
  54. import javafx.scene.control.TreeItem;
  55. import javafx.scene.control.TreeView;
  56. import javafx.scene.control.Alert.AlertType;
  57. import javafx.scene.layout.Background;
  58. import javafx.scene.layout.BorderPane;
  59. import javafx.scene.layout.HBox;
  60. import javafx.scene.layout.VBox;
  61. import javafx.stage.FileChooser;
  62. import javafx.stage.FileChooser.ExtensionFilter;
  63. import javafx.stage.Stage;
  64.  
  65. import java.util.Collection;
  66. import java.util.Collections;
  67. import java.util.regex.Matcher;
  68. import java.util.regex.Pattern;
  69.  
  70. import org.fxmisc.flowless.VirtualizedScrollPane;
  71. import org.fxmisc.richtext.CodeArea;
  72. import org.fxmisc.richtext.LineNumberFactory;
  73. import org.fxmisc.richtext.model.StyleSpans;
  74. import org.fxmisc.richtext.model.StyleSpansBuilder;
  75.  
  76. public class TreeViewExample extends Application {
  77.  
  78. Stage primaryStage;
  79. BorderPane root;
  80. Map<String, TreeItem> map;
  81. Map<String, String> inmemory;
  82.   CodeArea textArea = new    CodeArea();
  83.   TextField label  = new TextField("File:");
  84.  
  85. private static final Pattern XML_TAG = Pattern.compile("(?<ELEMENT>(</?\\h*)(\\w+)([^<>]*)(\\h*/?>))"
  86. +"|(?<COMMENT><!--[^<>]+-->)");
  87.  
  88. private static final Pattern ATTRIBUTES = Pattern.compile("(\\w+\\h*)(=)(\\h*\"[^\"]+\")");
  89.  
  90. private static final int GROUP_OPEN_BRACKET = 2;
  91. private static final int GROUP_ELEMENT_NAME = 3;
  92. private static final int GROUP_ATTRIBUTES_SECTION = 4;
  93. private static final int GROUP_CLOSE_BRACKET = 5;
  94. private static final int GROUP_ATTRIBUTE_NAME = 1;
  95. private static final int GROUP_EQUAL_SYMBOL = 2;
  96. private static final int GROUP_ATTRIBUTE_VALUE = 3;
  97.  
  98.  
  99. public static void main(String[] args) {
  100. Application.launch(args);
  101.  
  102. }
  103.  
  104. public void open(ActionEvent actionEvent) {
  105. textArea.clear();
  106. inmemory=new HashMap<String, String>();
  107. FileChooser fileChooser = new FileChooser();
  108. fileChooser.setTitle("selecione el excel");
  109.  
  110. fileChooser.getExtensionFilters().addAll(new ExtensionFilter("Excel", "*.xlsx"),
  111. new ExtensionFilter("Doc", "*.docx"), new ExtensionFilter("Ppt", "*..pptx"));
  112. File file = fileChooser.showOpenDialog(primaryStage);
  113.  
  114. if (file != null) {
  115. label.setText(file.getAbsolutePath());
  116. try (ZipFile zipFile = new ZipFile(file);) {
  117.  
  118. Enumeration<?> enu = zipFile.entries();
  119. Set<String> nodes = new HashSet<>();
  120. while (enu.hasMoreElements()) {
  121. ZipEntry zipEntry = (ZipEntry) enu.nextElement();
  122.  
  123. InputStream inputStream= zipFile.getInputStream(zipEntry);
  124.  
  125.  
  126.  
  127. String name = zipEntry.getName();
  128.  
  129. inmemory.put(name+"/", convertToString(inputStream));
  130. inputStream.close();
  131. String[] split = name.split("/");
  132.  
  133.  
  134.  
  135. String node = "";
  136. for (String current : split) {
  137. node += current + "/";
  138. nodes.add(node);
  139. }
  140.  
  141. }
  142. List<String> listnodes = new ArrayList<String>(nodes);
  143.  
  144. Collections.sort(listnodes, this::compare);
  145.  
  146. TreeItem rootItem = root(listnodes, file.getName());
  147.  
  148. TreeView treeView = new TreeView();
  149. treeView.getSelectionModel().selectedItemProperty().addListener(this::selectedFile);
  150. treeView.setRoot(rootItem);
  151.  
  152. treeView.setShowRoot(true);
  153.  
  154. root.setLeft(treeView);
  155.  
  156. } catch (Exception e) {
  157. Alert alert = new Alert(AlertType.ERROR);
  158. alert.setContentText(e.getMessage());
  159. e.printStackTrace();
  160. alert.showAndWait();
  161. }
  162.  
  163. }
  164.  
  165. }
  166.  
  167. String convertToString(InputStream in){
  168.    Scanner scanner = new Scanner(in);
  169.    scanner.useDelimiter("\\A");
  170.  
  171.    boolean hasInput = scanner.hasNext();
  172.    if (hasInput) {
  173.        return scanner.next();
  174.    } else {
  175.        return null;
  176.    }
  177.  
  178. }
  179.  
  180. void selectedFile(ObservableValue observable, Object oldValue,
  181.            Object newValue){
  182.        TreeItem<String> selectedItem = (TreeItem<String>) newValue;
  183.         for(String current: map.keySet()) {
  184.         if(map.get(current)==selectedItem) {
  185.         String text=inmemory.get(current);
  186.         if(text!=null) {
  187.         textArea.replaceText(prettyFormat(text));
  188.         }
  189.         }
  190.         }
  191. }
  192.  
  193. public int compare(String o1, String o2) {
  194. int result = (Integer.valueOf(o1.split("/").length)).compareTo(o2.split("/").length);
  195. if (result == 0)
  196. result = o1.compareTo(o2);
  197. return result;
  198. }
  199.  
  200. private TreeItem root(List<String> listnodes, String name) {
  201.  
  202. TreeItem rootItem = new TreeItem(name);
  203.  
  204. rootItem.setExpanded(true);
  205. map = new LinkedHashMap<String, TreeItem>();
  206. for (String current : listnodes) {
  207. String[] split = current.substring(0, current.length() - 1).split("/");
  208.  
  209. map.put(current, new TreeItem(split[split.length - 1]));
  210. }
  211.  
  212. for (String key : map.keySet()) {
  213.  
  214. if (key.split("/", -1).length == 2) {
  215.  
  216. rootItem.getChildren().add(map.get(key));
  217.  
  218. } else {
  219.  
  220. String currentName = map.get(key).getValue() + "";
  221. String result = key.substring(0, key.lastIndexOf(currentName + "/"));
  222.  
  223. TreeItem parent = map.get(result);
  224. parent.setExpanded(true);
  225. parent.getChildren().add(map.get(key));
  226.  
  227. }
  228.  
  229. }
  230.  
  231. return rootItem;
  232. }
  233.  
  234.  
  235.  
  236. public String prettyFormat(String xml) {
  237.  
  238.        try {
  239.            final InputSource src = new InputSource(new StringReader(xml));
  240.            final Node document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(src).getDocumentElement();
  241.            final Boolean keepDeclaration = Boolean.valueOf(xml.startsWith("<?xml"));
  242.  
  243.        //May need this: System.setProperty(DOMImplementationRegistry.PROPERTY,"com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
  244.  
  245.  
  246.            final DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
  247.            final DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
  248.            final LSSerializer writer = impl.createLSSerializer();
  249.  
  250.            writer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE); // Set this to true if the output needs to be beautified.
  251.            writer.getDomConfig().setParameter("xml-declaration", keepDeclaration); // Set this to true if the declaration is needed to be outputted.
  252.  
  253.            return writer.writeToString(document);
  254.        } catch (Exception e) {
  255.            throw new RuntimeException(e);
  256.        }
  257.    }
  258.  
  259. @Override
  260. public void start(Stage primaryStage) {  
  261. label.setEditable(false);
  262. label.setStyle("-fx-background-color:#ced1d6;");
  263. textArea.setParagraphGraphicFactory(LineNumberFactory.get(textArea));
  264. this.primaryStage = primaryStage;
  265. Menu m = new Menu("Archivo");
  266.  
  267. MenuItem open = new MenuItem("Inspect");
  268.  
  269.  
  270. open.setOnAction(this::open);
  271. m.getItems().add(open);
  272.  
  273. MenuBar mb = new MenuBar();
  274. mb.getMenus().add(m);
  275.  
  276. root = new BorderPane();
  277.  
  278. VBox head = new VBox();
  279. head.getChildren().add(mb);
  280. head.getChildren().add(label);
  281. root.setTop(head);
  282.  
  283.  
  284. textArea.setEditable(false);
  285. textArea.textProperty().addListener((obs, oldText, newText) -> {
  286. textArea.setStyleSpans(0, computeHighlighting(newText));
  287.        });
  288. root.setCenter(new VirtualizedScrollPane<>(textArea));
  289.  
  290. Scene scene = new Scene(root, 550, 250);
  291. scene.getStylesheets().add(TreeViewExample.class.getResource("xml-highlighting.css").toExternalForm());
  292. primaryStage.setTitle("OpenXml Comparator");
  293. primaryStage.setScene(scene);
  294. // primaryStage.setMaximized(true);
  295.  
  296. primaryStage.show();
  297.  
  298. }
  299. private static StyleSpans<Collection<String>> computeHighlighting(String text) {
  300.  
  301.        Matcher matcher = XML_TAG.matcher(text);
  302.        int lastKwEnd = 0;
  303.        StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
  304.        while(matcher.find()) {
  305.  
  306.         spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
  307.         if(matcher.group("COMMENT") != null) {
  308.         spansBuilder.add(Collections.singleton("comment"), matcher.end() - matcher.start());
  309.         }
  310.         else {
  311.         if(matcher.group("ELEMENT") != null) {
  312.         String attributesText = matcher.group(GROUP_ATTRIBUTES_SECTION);
  313.  
  314.         spansBuilder.add(Collections.singleton("tagmark"), matcher.end(GROUP_OPEN_BRACKET) - matcher.start(GROUP_OPEN_BRACKET));
  315.         spansBuilder.add(Collections.singleton("anytag"), matcher.end(GROUP_ELEMENT_NAME) - matcher.end(GROUP_OPEN_BRACKET));
  316.  
  317.         if(!attributesText.isEmpty()) {
  318.  
  319.         lastKwEnd = 0;
  320.  
  321.         Matcher amatcher = ATTRIBUTES.matcher(attributesText);
  322.         while(amatcher.find()) {
  323.         spansBuilder.add(Collections.emptyList(), amatcher.start() - lastKwEnd);
  324.         spansBuilder.add(Collections.singleton("attribute"), amatcher.end(GROUP_ATTRIBUTE_NAME) - amatcher.start(GROUP_ATTRIBUTE_NAME));
  325.         spansBuilder.add(Collections.singleton("tagmark"), amatcher.end(GROUP_EQUAL_SYMBOL) - amatcher.end(GROUP_ATTRIBUTE_NAME));
  326.         spansBuilder.add(Collections.singleton("avalue"), amatcher.end(GROUP_ATTRIBUTE_VALUE) - amatcher.end(GROUP_EQUAL_SYMBOL));
  327.         lastKwEnd = amatcher.end();
  328.         }
  329.         if(attributesText.length() > lastKwEnd)
  330.         spansBuilder.add(Collections.emptyList(), attributesText.length() - lastKwEnd);
  331.         }
  332.  
  333.         lastKwEnd = matcher.end(GROUP_ATTRIBUTES_SECTION);
  334.  
  335.         spansBuilder.add(Collections.singleton("tagmark"), matcher.end(GROUP_CLOSE_BRACKET) - lastKwEnd);
  336.         }
  337.         }
  338.            lastKwEnd = matcher.end();
  339.        }
  340.        spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
  341.        return spansBuilder.create();
  342.    }
  343. }

Código
  1. <project xmlns="http://maven.apache.org/POM/4.0.0"
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <groupId>tool</groupId>
  6. <artifactId>office</artifactId>
  7. <version>0.0.1-SNAPSHOT</version>
  8. <packaging>jar</packaging>
  9. <properties>
  10. <maven.compiler.source>1.8</maven.compiler.source>
  11. <maven.compiler.target>1.8</maven.compiler.target>
  12. </properties>
  13.  
  14. <dependencies>
  15. <dependency>
  16. <groupId>org.fxmisc.richtext</groupId>
  17. <artifactId>richtextfx</artifactId>
  18. <version>0.10.6
  19.    </version>
  20. </dependency>
  21. </dependencies>
  22.  
  23. </project>


Código
  1. .tagmark {
  2.    -fx-fill: gray;
  3. }
  4. .anytag {
  5.    -fx-fill: crimson;
  6. }
  7. .paren {
  8.    -fx-fill: firebrick;
  9.    -fx-font-weight: bold;
  10. }
  11. .attribute {
  12.    -fx-fill: darkviolet;
  13. }
  14. .avalue {
  15.    -fx-fill: black;
  16. }
  17.  
  18. .comment {
  19. -fx-fill: teal;
  20. }
  21.  
  22. .red-text {
  23.    -fx-font-color: red;
  24. }
  25. .red-green {
  26.    -fx-font-color: blue;
  27. }
  28. .styleClassName {
  29.  
  30.        -fx-background-color:gray;
  31.  
  32.     }
37  Programación / Java / Re: que usar para una Interfaz grafica en: 3 Octubre 2021, 05:35 am
javafx con Scene Builder

https://www.youtube.com/watch?v=OGMDmHFfhig
38  Programación / Java / Re: validad modal form en spring boot con thymeleaf en: 24 Junio 2021, 21:43 pm
solucion simple usa jquery validation

XD
las variables en aplicaciones web son mas complicadas que en aplicacion de escritorio

la forma por defecto de como funciona la inmensa mayoría de framewors web del lado del servidor las variables se pierden por cada request (petición )
es por eso que cuando validas no te va a funcionar el if de thymelift por que ya se resete las variables despues de hacer la peticion

si lo quieres hacer del lado del servidor no lo recomiendo tendrias que usar el alcanse flash
https://www.baeldung.com/spring-web-flash-attributes







39  Programación / Java / Re: contribucion ejemplo de eventbus en: 19 Enero 2021, 05:20 am
me van a tener que seguir soportando
40  Programación / Java / Re: contribucion ejemplo de eventbus en: 18 Enero 2021, 02:52 am
se siente raro quedar hablando solo
Páginas: 1 2 3 [4] 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... 63
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines