[Git][java-team/simplyhtml][master] 17 commits: Apply multi-arch hints.
Pierre Gruet (@pgt)
gitlab at salsa.debian.org
Sat Feb 21 10:19:44 GMT 2026
Pierre Gruet pushed to branch master at Debian Java Maintainers / simplyhtml
Commits:
6046ddc0 by Pierre Gruet at 2026-02-21T09:20:29+01:00
Apply multi-arch hints.
+ simplyhtml-doc: Add Multi-Arch: foreign.
Changes-By: apply-multiarch-hints
- - - - -
593e88b0 by Pierre Gruet at 2026-02-21T09:48:36+01:00
Updating Maven rules for mnemonicsetter
- - - - -
5f8d4dff by Pierre Gruet at 2026-02-21T09:49:46+01:00
Updating path to doc in d/simplyhtml-doc.doc-base
- - - - -
a29bb8b1 by Pierre Gruet at 2026-02-21T09:50:01+01:00
Adding Lintian override for embedded JS
- - - - -
68439234 by Pierre Gruet at 2026-02-21T09:52:50+01:00
Updating source in d/copyright
- - - - -
c9abec9f by Pierre Gruet at 2026-02-21T09:54:32+01:00
Removing empty Maven files in debian/
- - - - -
e0787cae by Pierre Gruet at 2026-02-21T09:56:30+01:00
Updating changelog
- - - - -
81e31420 by Pierre Gruet at 2026-02-21T10:11:50+01:00
Properly link mnemonicsetter jar at runtime
- - - - -
7e2a6a10 by Pierre Gruet at 2026-02-21T10:12:22+01:00
Removing Priority: optional, which is default
- - - - -
66c447c7 by Pierre Gruet at 2026-02-21T10:12:32+01:00
Raising Standards version to 4.7.3
- - - - -
8d7eedd6 by Pierre Gruet at 2026-02-21T10:18:20+01:00
Preparing to repack without two files with non-free license
- - - - -
f58163cc by Pierre Gruet at 2026-02-21T10:19:54+01:00
New upstream version 1.19.11+dfsg1
- - - - -
23ae557f by Pierre Gruet at 2026-02-21T10:19:55+01:00
Update upstream source from tag 'upstream/1.19.11+dfsg1'
Update to upstream version '1.19.11+dfsg1'
with Debian dir 3ddfe7c97c85d176475e28fc37d10c9c9d0e186e
- - - - -
2197b2e7 by Pierre Gruet at 2026-02-21T10:27:32+01:00
Rewriting d/copyright
- - - - -
d92ecac6 by Pierre Gruet at 2026-02-21T10:40:54+01:00
Updating changelog
- - - - -
474bb8ae by Pierre Gruet at 2026-02-21T10:56:02+01:00
Skipping usage of removed non-free files
- - - - -
83ee68e5 by Pierre Gruet at 2026-02-21T10:56:21+01:00
Upload to unstable
- - - - -
13 changed files:
- debian/changelog
- debian/control
- debian/copyright
- − debian/maven.cleanIgnoreRules
- − debian/maven.ignoreRules
- debian/maven.rules
- + debian/patches/02_excluded_non_free_files.patch
- debian/patches/series
- debian/simplyhtml-doc.doc-base
- + debian/simplyhtml-doc.lintian-overrides
- debian/simplyhtml.sh
- − src/com/sun/demo/ElementTreePanel.java
- − src/com/sun/demo/ExampleFileFilter.java
Changes:
=====================================
debian/changelog
=====================================
@@ -1,10 +1,21 @@
-simplyhtml (1.19.11+dfsg-1) UNRELEASED; urgency=medium
+simplyhtml (1.19.11+dfsg1-1) unstable; urgency=medium
* Team upload.
+ * New upstream version 1.19.11+dfsg1:
+ - Repacking without two files with non-free license
+ * Rewriting d/copyright
+ * Marking simplyhtml-doc as Multi-Arch: foreign
+ * Updating Maven rules for mnemonicsetter
+ * Updating path to doc in d/simplyhtml-doc.doc-base
+ * Adding Lintian override for embedded JS
+ * Updating source in d/copyright
+ * Removing empty Maven files in debian/
+ * Raising Standards version to 4.7.3:
+ - Removing Priority: optional, which is default
+
+ [ Andreas Tille ]
* Homepage moved to Github
* d/watch: version=5
- * New upstream version
- * Standards-Version: 4.7.2 (routine-update)
* debhelper-compat 13 (routine-update)
* Reorder sequence of d/control fields by cme (routine-update)
* Secure URI in copyright format (routine-update)
@@ -14,7 +25,10 @@ simplyhtml (1.19.11+dfsg-1) UNRELEASED; urgency=medium
* Fix day-of-week for changelog entry 0.9.0~beta9-1.
* debputy lint --auto-fix (routine-update)
- -- Andreas Tille <tille at debian.org> Thu, 23 Oct 2025 15:44:02 +0200
+ [ Vivek K J ]
+ * Properly link mnemonicsetter jar at runtime (Closes: #1104088)
+
+ -- Pierre Gruet <pgt at debian.org> Sat, 21 Feb 2026 10:56:10 +0100
simplyhtml (0.17.3+dfsg1-1.1) unstable; urgency=medium
=====================================
debian/control
=====================================
@@ -1,10 +1,9 @@
Source: simplyhtml
-Standards-Version: 4.7.2
+Standards-Version: 4.7.3
Maintainer: Debian Java Maintainers <pkg-java-maintainers at lists.alioth.debian.org>
Uploaders:
Felix Natter <fnatter at gmx.net>,
Section: web
-Priority: optional
Build-Depends:
debhelper-compat (= 13),
Build-Depends-Indep:
@@ -39,6 +38,7 @@ Description: Java word processor based on HTML and CSS
Package: simplyhtml-doc
Architecture: all
Section: doc
+Multi-Arch: foreign
Depends:
${misc:Depends},
Suggests:
=====================================
debian/copyright
=====================================
@@ -1,52 +1,46 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: simplyhtml
-Source: http://simplyhtml.sf.net/
+Source: https://github.com/freeplane/shtml
Upstream-Contact: Felix Natter <fnatter at gmx.net>
Files-Excluded: src/com/lightdev/app/shtm/help/JavaHelpTOC.jar
+ src/com/sun/demo/ElementTreePanel.java
+ src/com/sun/demo/ExampleFileFilter.java
+Comment: Excluding already built jar and two source files with non-free license
Files: *
-Copyright: 2006-2017 Dimitri Polivaev <dpolivaev at users.sourceforge.net>
- 2012-2016 Felix Natter <fnatter at gmx.net>
- 2002,2003 Ulrich Hilger <info at lightdev.com>
+Copyright: 2002-2003 Ulrich Hilger
+ 2006-2008 Dimitri Polivaev
License: GPL-2+
-Files: src/com/sun/demo/ElementTreePanel.java
- src/com/sun/demo/ExampleFileFilter.java
-Copyright: 2004 Sun Microsystems, Inc.
-License: Sun
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * -Redistribution of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * -Redistribution in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
- * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN")
- * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
- * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
- * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
- * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
- * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
- * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or intended
- * for use in the design, construction, operation or maintenance of any
- * nuclear facility.
+Files: src/com/lightdev/app/shtm/InternalUiResources.java
+ src/com/lightdev/app/shtm/SHTMLHelpBroker.java
+ src/com/lightdev/app/shtm/SHTMLPanel.java
+ src/com/lightdev/app/shtm/SHTMLPanelMultipleDocImpl.java
+ src/com/lightdev/app/shtm/SHTMLPanelSingleDocImpl.java
+ src/com/lightdev/app/shtm/UIResources.java
+Copyright: 2006 Dimitri Polivaev
+License: GPL-2+
Files: src/com/lightdev/app/shtm/NamedObject.java
-Copyright: 2006-2013 Dimitri Polivaev <dpolivaev at users.sourceforge.net>
- 2006-2013 Christian Foltin
+Copyright: 2000-2006 Joerg Mueller, Daniel Polansky, Christian Foltin, Dimitri Polivaev and others.
+License: GPL-2+
+
+Files: src/com/lightdev/app/shtm/SHTMLPanelImpl.java
+Copyright: 2006 Ulrich Hilger, Dimitri Polivaev
+License: GPL-2+
+
+Files: src/com/lightdev/app/shtm/ScaledStyleSheet.java
+Copyright: 2012 Freeplane team and others
+License: GPL-2+
+
+Files: src/com/lightdev/app/shtm/SplashScreen.java
+Copyright: 2006 Karsten Pawlik
+ 2006 Dimitri Polivaev
+ 2002 Ulrich Hilger
+License: GPL-2+
+
+Files: src/de/calcom/cclib/text/PseudoDamerauLevenshtein.java
+Copyright: 2012 Dimitry Polivaev
License: GPL-2+
Files: debian/*
=====================================
debian/maven.cleanIgnoreRules deleted
=====================================
@@ -1 +0,0 @@
-
=====================================
debian/maven.ignoreRules deleted
=====================================
@@ -1 +0,0 @@
-
=====================================
debian/maven.rules
=====================================
@@ -1,2 +1,2 @@
com.lightdev.app.shtm.simplyhtml SimplyHTML jar s/.*/debian/ * *
-org.dpolivaev.mnemonicsetter mnemonicsetter jar s/.*/debian/ * *
+s/org.freeplane.dpolivaev.mnemonicsetter/org.dpolivaev.mnemonicsetter/ mnemonicsetter jar s/.*/debian/ * *
=====================================
debian/patches/02_excluded_non_free_files.patch
=====================================
@@ -0,0 +1,96 @@
+Description: removing usage of the two non-free files we removed form the
+ source package
+Author: Pierre Gruet <pgt at debian.org>
+Forwarded: not-needed
+Last-Update: 2026-02-21
+
+--- a/src/com/lightdev/app/shtm/DocumentPane.java
++++ b/src/com/lightdev/app/shtm/DocumentPane.java
+@@ -48,8 +48,6 @@
+ import javax.swing.text.html.HTMLDocument;
+ import javax.swing.text.html.StyleSheet;
+
+-import com.sun.demo.ExampleFileFilter;
+-
+ import static java.lang.Boolean.TRUE;
+
+ /**
+@@ -407,10 +405,6 @@
+ final File destDir = SHTMLDocument.getImageDirectory(targetUrl);
+ try {
+ if (srcDir.exists()) {
+- final ExampleFileFilter filter = new ExampleFileFilter();
+- filter.addExtension("gif");
+- filter.addExtension("jpg");
+- filter.addExtension("jpeg");
+ final File[] imgFiles = srcDir.listFiles();
+ for (int i = 0; i < imgFiles.length; i++) {
+ Util.copyFile(imgFiles[i],
+--- a/src/com/lightdev/app/shtm/ImageDialog.java
++++ b/src/com/lightdev/app/shtm/ImageDialog.java
+@@ -56,8 +56,6 @@
+ import javax.swing.text.SimpleAttributeSet;
+ import javax.swing.text.html.HTML;
+
+-import com.sun.demo.ExampleFileFilter;
+-
+ /**
+ * A dialog providing an image repository and a way to edit display options
+ * for images from the repository.
+@@ -347,12 +345,6 @@
+ try {
+ final JFileChooser chooser = new JFileChooser();
+ chooser.setMultiSelectionEnabled(true);
+- final ExampleFileFilter filter = new ExampleFileFilter();
+- filter.addExtension("gif");
+- filter.addExtension("jpg");
+- filter.addExtension("jpeg");
+- filter.setDescription(Util.getResourceString("imageFileDesc"));
+- chooser.setFileFilter(filter);
+ if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
+ final File[] sFiles = chooser.getSelectedFiles();
+ File imgDir = doc.getImageDirectory();
+--- a/src/com/lightdev/app/shtm/SHTMLEditorKitActions.java
++++ b/src/com/lightdev/app/shtm/SHTMLEditorKitActions.java
+@@ -56,8 +56,6 @@
+ import com.lightdev.app.shtm.SHTMLEditorPane.PasteMode;
+ import com.lightdev.app.shtm.SHTMLPanelImpl.FontFamilyPicker;
+ import com.lightdev.app.shtm.SHTMLPanelImpl.FontSizePicker;
+-import com.sun.demo.ElementTreePanel;
+-import com.sun.demo.ExampleFileFilter;
+
+ import de.calcom.cclib.text.FindReplaceDialog;
+ import de.calcom.cclib.text.FindReplaceEvent;
+@@ -461,8 +459,6 @@
+ });
+ final Container fContentPane = elementTreeFrame.getContentPane();
+ fContentPane.setLayout(new BorderLayout());
+- final ElementTreePanel elementTreePanel = new ElementTreePanel(panel.getSHTMLEditorPane());
+- fContentPane.add(elementTreePanel);
+ elementTreeFrame.pack();
+ }
+ elementTreeFrame.setVisible(true);
+@@ -2088,11 +2084,6 @@
+ public void actionPerformed(final ActionEvent ae) {
+ final Preferences prefs = Preferences.userNodeForPackage(panel.getClass());
+ final JFileChooser chooser = new JFileChooser(); // create a file chooser
+- final ExampleFileFilter filter = new ExampleFileFilter(); // create a filter
+- filter.addExtension("htm");
+- filter.addExtension("html");
+- filter.setDescription(Util.getResourceString("htmlFileDesc"));
+- chooser.setFileFilter(filter); // apply the file filter
+ final String lastFileName = prefs.get(SHTMLPanelImpl.FILE_LAST_OPEN, "");
+ if (!lastFileName.isEmpty()) {
+ chooser.setCurrentDirectory(new File(lastFileName).getParentFile());
+@@ -2301,11 +2292,6 @@
+ boolean canSave = true;
+ final Preferences prefs = Preferences.userNodeForPackage(panel.getClass());
+ final JFileChooser chooser = new JFileChooser();
+- final ExampleFileFilter filter = new ExampleFileFilter();
+- filter.addExtension("htm");
+- filter.addExtension("html");
+- filter.setDescription(Util.getResourceString("htmlFileDesc"));
+- chooser.setFileFilter(filter);
+ final String lastSaveFileName = prefs.get(SHTMLPanelImpl.FILE_LAST_SAVE, "");
+ if (!lastSaveFileName.isEmpty()) {
+ chooser.setCurrentDirectory(new File(lastSaveFileName).getParentFile());
=====================================
debian/patches/series
=====================================
@@ -1 +1,2 @@
01_build.patch
+02_excluded_non_free_files.patch
=====================================
debian/simplyhtml-doc.doc-base
=====================================
@@ -6,5 +6,5 @@ Abstract: The programmer API of SimplyHTML, a Java
Section: Programming/Java
Format: HTML
-Index: /usr/share/doc/simplyhtml-doc/javadoc/index.html
-Files: /usr/share/doc/simplyhtml-doc/javadoc/*
+Index: /usr/share/doc/simplyhtml/javadoc/index.html
+Files: /usr/share/doc/simplyhtml/javadoc/*
=====================================
debian/simplyhtml-doc.lintian-overrides
=====================================
@@ -0,0 +1,4 @@
+# It would be too complicated to remove the javascript that is included in
+# javadocs, see the discussion on Debian Java mailing list starting at
+# https://lists.debian.org/debian-java/2018/06/msg00020.html.
+embedded-javascript-library please use * [usr/share/doc/simplyhtml/javadoc/script-dir/jquery*.*s]
=====================================
debian/simplyhtml.sh
=====================================
@@ -118,5 +118,14 @@ output_info
#/usr/share/java/SimplyHTMLHelp.jar:\
#/usr/share/java/SimplyHTML.jar:"
-_debug "Calling: '${JAVACMD} -jar /usr/share/java/SimplyHTML.jar com.lightdev.app.shtm.App $@'."
-"${JAVACMD}" -jar /usr/share/java/SimplyHTML.jar com.lightdev.app.shtm.App "$@"
+MNEMONICSETTER_JAR=$(find /usr/share/maven-repo/org/dpolivaev/mnemonicsetter/mnemonicsetter/ -name "mnemonicsetter-*.jar" | sort -V | tail -n 1)
+
+if [ ! -f "$MNEMONICSETTER_JAR" ]; then
+ _error "MnemonicSetter JAR not found in Maven repository."
+ exit 1
+fi
+
+CLASSPATH="/usr/share/java/SimplyHTML.jar:$MNEMONICSETTER_JAR"
+
+_debug "Calling: '${JAVACMD} -cp $CLASSPATH com.lightdev.app.shtm.App $@'."
+"${JAVACMD}" -cp "$CLASSPATH" com.lightdev.app.shtm.App "$@"
=====================================
src/com/sun/demo/ElementTreePanel.java deleted
=====================================
@@ -1,562 +0,0 @@
-/*
- * @(#)ElementTreePanel.java 1.16 04/07/26 slightly modified (line 121)
- *
- * Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * -Redistribution of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * -Redistribution in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
- * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN")
- * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
- * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
- * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
- * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
- * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
- * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or intended
- * for use in the design, construction, operation or maintenance of any
- * nuclear facility.
- */
-/*
- * @(#)ElementTreePanel.java 1.16 04/07/26
- */
-/* for use in SimplyHTML */
-package com.sun.demo;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.Font;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Enumeration;
-import java.util.Vector;
-
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTree;
-import javax.swing.SwingConstants;
-import javax.swing.event.CaretEvent;
-import javax.swing.event.CaretListener;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-import javax.swing.text.AttributeSet;
-import javax.swing.text.Document;
-import javax.swing.text.Element;
-import javax.swing.text.JTextComponent;
-import javax.swing.text.StyleConstants;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.DefaultTreeCellRenderer;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreeNode;
-import javax.swing.tree.TreePath;
-
-/**
- * Displays a tree showing all the elements in a text Document. Selecting
- * a node will result in reseting the selection of the JTextComponent.
- * This also becomes a CaretListener to know when the selection has changed
- * in the text to update the selected item in the tree.
- *
- * @author Scott Violet
- * @version 1.16 07/26/04
- */
-public class ElementTreePanel extends JPanel implements CaretListener, DocumentListener, PropertyChangeListener,
- TreeSelectionListener {
- /** Tree showing the documents element structure. */
- protected final JTree tree;
- /** Text component showing elemenst for. */
- protected JTextComponent editor;
- /** Model for the tree. */
- protected ElementTreeModel treeModel;
- /** Set to true when updating the selection. */
- protected boolean updatingSelection;
-
- public ElementTreePanel(final JTextComponent editor) {
- this.editor = editor;
- final Document document = editor.getDocument();
- // Create the tree.
- treeModel = new ElementTreeModel(document);
- tree = new JTree(treeModel) {
- public String convertValueToText(final Object value, final boolean selected, final boolean expanded,
- final boolean leaf, final int row, final boolean hasFocus) {
- // Should only happen for the root
- if (!(value instanceof Element)) {
- return value.toString();
- }
- final Element e = (Element) value;
- final AttributeSet as = e.getAttributes().copyAttributes();
- String asString;
- if (as != null) {
- final StringBuilder retBuffer = new StringBuilder("[");
- final Enumeration names = as.getAttributeNames();
- while (names.hasMoreElements()) {
- final Object nextName = names.nextElement();
- if (nextName != StyleConstants.ResolveAttribute) {
- retBuffer.append(" ");
- retBuffer.append(nextName);
- retBuffer.append("=");
- retBuffer.append(as.getAttribute(nextName));
- }
- }
- retBuffer.append(" ]");
- asString = retBuffer.toString();
- }
- else {
- asString = "[ ]";
- }
-
- return e.getName() + " [" + e.getStartOffset() + ", " + e.getEndOffset() + "] Attributes: " + asString;
- }
- };
- tree.addTreeSelectionListener(this);
- /* commented out for use in SimplyHTML */
- // Don't show the root, it is fake.
- tree.setRootVisible(false);
- // Since the display value of every node after the insertion point
- // changes every time the text changes and we don't generate a change
- // event for all those nodes the display value can become off.
- // This can be seen as '...' instead of the complete string value.
- // This is a temporary workaround, increase the needed size by 15,
- // hoping that will be enough.
- tree.setCellRenderer(new DefaultTreeCellRenderer() {
- public Dimension getPreferredSize() {
- final Dimension retValue = super.getPreferredSize();
- if (retValue != null) {
- retValue.width += 15;
- }
- return retValue;
- }
- });
- // become a listener on the document to update the tree.
- document.addDocumentListener(this);
- // become a PropertyChangeListener to know when the Document has
- // changed.
- editor.addPropertyChangeListener(this);
- // Become a CaretListener
- editor.addCaretListener(this);
- // configure the panel and frame containing it.
- setLayout(new BorderLayout());
- add(new JScrollPane(tree), BorderLayout.CENTER);
- // Add a label above tree to describe what is being shown
- final JLabel label = new JLabel("Elements that make up the current document", SwingConstants.CENTER);
- label.setFont(new Font("Dialog", Font.BOLD, 14));
- add(label, BorderLayout.NORTH);
- setPreferredSize(new Dimension(400, 400));
- }
-
- /**
- * Resets the JTextComponent to <code>editor</code>. This will update
- * the tree accordingly.
- */
- public void setEditor(final JTextComponent editor) {
- if (this.editor == editor) {
- return;
- }
- if (this.editor != null) {
- final Document oldDoc = this.editor.getDocument();
- oldDoc.removeDocumentListener(this);
- this.editor.removePropertyChangeListener(this);
- this.editor.removeCaretListener(this);
- }
- this.editor = editor;
- if (editor == null) {
- treeModel = null;
- tree.setModel(null);
- }
- else {
- final Document newDoc = editor.getDocument();
- newDoc.addDocumentListener(this);
- editor.addPropertyChangeListener(this);
- editor.addCaretListener(this);
- treeModel = new ElementTreeModel(newDoc);
- tree.setModel(treeModel);
- }
- }
-
- // PropertyChangeListener
- /**
- * Invoked when a property changes. We are only interested in when the
- * Document changes to reset the DocumentListener.
- */
- public void propertyChange(final PropertyChangeEvent e) {
- if (e.getSource() == getEditor() && e.getPropertyName().equals("document")) {
- final Document oldDoc = (Document) e.getOldValue();
- final Document newDoc = (Document) e.getNewValue();
- // Reset the DocumentListener
- oldDoc.removeDocumentListener(this);
- newDoc.addDocumentListener(this);
- // Recreate the TreeModel.
- treeModel = new ElementTreeModel(newDoc);
- tree.setModel(treeModel);
- }
- }
-
- // DocumentListener
- /**
- * Gives notification that there was an insert into the document. The
- * given range bounds the freshly inserted region.
- *
- * @param e the document event
- */
- public void insertUpdate(final DocumentEvent e) {
- updateTree(e);
- }
-
- /**
- * Gives notification that a portion of the document has been
- * removed. The range is given in terms of what the view last
- * saw (that is, before updating sticky positions).
- *
- * @param e the document event
- */
- public void removeUpdate(final DocumentEvent e) {
- updateTree(e);
- }
-
- /**
- * Gives notification that an attribute or set of attributes changed.
- *
- * @param e the document event
- */
- public void changedUpdate(final DocumentEvent e) {
- updateTree(e);
- }
-
- // CaretListener
- /**
- * Messaged when the selection in the editor has changed. Will update
- * the selection in the tree.
- */
- public void caretUpdate(final CaretEvent e) {
- if (!updatingSelection) {
- final int selBegin = Math.min(e.getDot(), e.getMark());
- final int end = Math.max(e.getDot(), e.getMark());
- final Vector paths = new Vector();
- final TreeModel model = getTreeModel();
- final Object root = model.getRoot();
- final int rootCount = model.getChildCount(root);
- // Build an array of all the paths to all the character elements
- // in the selection.
- for (int counter = 0; counter < rootCount; counter++) {
- int start = selBegin;
- while (start <= end) {
- final TreePath path = getPathForIndex(start, root, (Element) model.getChild(root, counter));
- final Element charElement = (Element) path.getLastPathComponent();
- paths.addElement(path);
- if (start >= charElement.getEndOffset()) {
- start++;
- }
- else {
- start = charElement.getEndOffset();
- }
- }
- }
- // If a path was found, select it (them).
- final int numPaths = paths.size();
- if (numPaths > 0) {
- final TreePath[] pathArray = new TreePath[numPaths];
- paths.copyInto(pathArray);
- updatingSelection = true;
- try {
- getTree().setSelectionPaths(pathArray);
- getTree().scrollPathToVisible(pathArray[0]);
- }
- finally {
- updatingSelection = false;
- }
- }
- }
- }
-
- // TreeSelectionListener
- /**
- * Called whenever the value of the selection changes.
- * @param e the event that characterizes the change.
- */
- public void valueChanged(final TreeSelectionEvent e) {
- final JTree tree = getTree();
- if (!updatingSelection && tree.getSelectionCount() == 1) {
- final TreePath selPath = tree.getSelectionPath();
- final Object lastPathComponent = selPath.getLastPathComponent();
- if (!(lastPathComponent instanceof DefaultMutableTreeNode)) {
- final Element selElement = (Element) lastPathComponent;
- updatingSelection = true;
- try {
- getEditor().select(selElement.getStartOffset(), selElement.getEndOffset());
- }
- finally {
- updatingSelection = false;
- }
- }
- }
- }
-
- // Local methods
- /**
- * @return tree showing elements.
- */
- protected JTree getTree() {
- return tree;
- }
-
- /**
- * @return JTextComponent showing elements for.
- */
- protected JTextComponent getEditor() {
- return editor;
- }
-
- /**
- * @return TreeModel implementation used to represent the elements.
- */
- public DefaultTreeModel getTreeModel() {
- return treeModel;
- }
-
- /**
- * Updates the tree based on the event type. This will invoke either
- * updateTree with the root element, or handleChange.
- */
- protected void updateTree(final DocumentEvent event) {
- updatingSelection = true;
- try {
- final TreeModel model = getTreeModel();
- final Object root = model.getRoot();
- for (int counter = model.getChildCount(root) - 1; counter >= 0; counter--) {
- updateTree(event, (Element) model.getChild(root, counter));
- }
- }
- finally {
- updatingSelection = false;
- }
- }
-
- /**
- * Creates TreeModelEvents based on the DocumentEvent and messages
- * the treemodel. This recursively invokes this method with children
- * elements.
- * @param event indicates what elements in the tree hierarchy have
- * changed.
- * @param element Current element to check for changes against.
- */
- protected void updateTree(final DocumentEvent event, final Element element) {
- final DocumentEvent.ElementChange ec = event.getChange(element);
- if (ec != null) {
- final Element[] removed = ec.getChildrenRemoved();
- final Element[] added = ec.getChildrenAdded();
- final int startIndex = ec.getIndex();
- // Check for removed.
- if (removed != null && removed.length > 0) {
- final int[] indices = new int[removed.length];
- for (int counter = 0; counter < removed.length; counter++) {
- indices[counter] = startIndex + counter;
- }
- getTreeModel().nodesWereRemoved((TreeNode) element, indices, removed);
- }
- // check for added
- if (added != null && added.length > 0) {
- final int[] indices = new int[added.length];
- for (int counter = 0; counter < added.length; counter++) {
- indices[counter] = startIndex + counter;
- }
- getTreeModel().nodesWereInserted((TreeNode) element, indices);
- }
- }
- if (!element.isLeaf()) {
- int startIndex = element.getElementIndex(event.getOffset());
- final int elementCount = element.getElementCount();
- final int endIndex = Math.min(elementCount - 1,
- element.getElementIndex(event.getOffset() + event.getLength()));
- if (startIndex > 0 && startIndex < elementCount
- && element.getElement(startIndex).getStartOffset() == event.getOffset()) {
- // Force checking the previous element.
- startIndex--;
- }
- if (startIndex != -1 && endIndex != -1) {
- for (int counter = startIndex; counter <= endIndex; counter++) {
- updateTree(event, element.getElement(counter));
- }
- }
- }
- else {
- // Element is a leaf, assume it changed
- getTreeModel().nodeChanged((TreeNode) element);
- }
- }
-
- /**
- * Returns a TreePath to the element at <code>position</code>.
- */
- protected TreePath getPathForIndex(final int position, final Object root, final Element rootElement) {
- TreePath path = new TreePath(root);
- Element child = rootElement.getElement(rootElement.getElementIndex(position));
- path = path.pathByAddingChild(rootElement);
- path = path.pathByAddingChild(child);
- while (!child.isLeaf()) {
- child = child.getElement(child.getElementIndex(position));
- path = path.pathByAddingChild(child);
- }
- return path;
- }
-
- /**
- * ElementTreeModel is an implementation of TreeModel to handle displaying
- * the Elements from a Document. AbstractDocument.AbstractElement is
- * the default implementation used by the swing text package to implement
- * Element, and it implements TreeNode. This makes it trivial to create
- * a DefaultTreeModel rooted at a particular Element from the Document.
- * Unfortunately each Document can have more than one root Element.
- * Implying that to display all the root elements as a child of another
- * root a fake node has be created. This class creates a fake node as
- * the root with the children being the root elements of the Document
- * (getRootElements).
- * <p>This subclasses DefaultTreeModel. The majority of the TreeModel
- * methods have been subclassed, primarily to special case the root.
- */
- public static class ElementTreeModel extends DefaultTreeModel {
- protected final Element[] rootElements;
-
- public ElementTreeModel(final Document document) {
- super(new DefaultMutableTreeNode("root"), false);
- rootElements = document.getRootElements();
- }
-
- /**
- * Returns the child of <I>parent</I> at index <I>index</I> in
- * the parent's child array. <I>parent</I> must be a node
- * previously obtained from this data source. This should
- * not return null if <i>index</i> is a valid index for
- * <i>parent</i> (that is <i>index</i> >= 0 && <i>index</i>
- * < getChildCount(<i>parent</i>)).
- *
- * @param parent a node in the tree, obtained from this data source
- * @return the child of <I>parent</I> at index <I>index</I>
- */
- public Object getChild(final Object parent, final int index) {
- if (parent == root) {
- return rootElements[index];
- }
- return super.getChild(parent, index);
- }
-
- /**
- * Returns the number of children of <I>parent</I>. Returns 0
- * if the node is a leaf or if it has no children.
- * <I>parent</I> must be a node previously obtained from this
- * data source.
- *
- * @param parent a node in the tree, obtained from this data source
- * @return the number of children of the node <I>parent</I>
- */
- public int getChildCount(final Object parent) {
- if (parent == root) {
- return rootElements.length;
- }
- return super.getChildCount(parent);
- }
-
- /**
- * Returns true if <I>node</I> is a leaf. It is possible for
- * this method to return false even if <I>node</I> has no
- * children. A directory in a filesystem, for example, may
- * contain no files; the node representing the directory is
- * not a leaf, but it also has no children.
- *
- * @param node a node in the tree, obtained from this data source
- * @return true if <I>node</I> is a leaf
- */
- public boolean isLeaf(final Object node) {
- if (node == root) {
- return false;
- }
- return super.isLeaf(node);
- }
-
- /**
- * Returns the index of child in parent.
- */
- public int getIndexOfChild(final Object parent, final Object child) {
- if (parent == root) {
- for (int counter = rootElements.length - 1; counter >= 0; counter--) {
- if (rootElements[counter] == child) {
- return counter;
- }
- }
- return -1;
- }
- return super.getIndexOfChild(parent, child);
- }
-
- /**
- * Invoke this method after you've changed how node is to be
- * represented in the tree.
- */
- public void nodeChanged(final TreeNode node) {
- if (listenerList != null && node != null) {
- TreeNode parent = node.getParent();
- if (parent == null && node != root) {
- parent = root;
- }
- if (parent != null) {
- final int anIndex = getIndexOfChild(parent, node);
- if (anIndex != -1) {
- final int[] cIndexs = new int[1];
- cIndexs[0] = anIndex;
- nodesChanged(parent, cIndexs);
- }
- }
- }
- }
-
- /**
- * Returns the path to a particular node. This is recursive.
- */
- protected TreeNode[] getPathToRoot(final TreeNode aNode, int depth) {
- TreeNode[] retNodes;
- /* Check for null, in case someone passed in a null node, or
- they passed in an element that isn't rooted at root. */
- if (aNode == null) {
- if (depth == 0) {
- return null;
- }
- else {
- retNodes = new TreeNode[depth];
- }
- }
- else {
- depth++;
- if (aNode == root) {
- retNodes = new TreeNode[depth];
- }
- else {
- TreeNode parent = aNode.getParent();
- if (parent == null) {
- parent = root;
- }
- retNodes = getPathToRoot(parent, depth);
- }
- retNodes[retNodes.length - depth] = aNode;
- }
- return retNodes;
- }
- }
-}
=====================================
src/com/sun/demo/ExampleFileFilter.java deleted
=====================================
@@ -1,266 +0,0 @@
-/*
- * @(#)ExampleFileFilter.java 1.8 04/07/26
- *
- * Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * -Redistribution of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * -Redistribution in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
- * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN")
- * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
- * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
- * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
- * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
- * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
- * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or intended
- * for use in the design, construction, operation or maintenance of any
- * nuclear facility.
- */
-/*
- * @(#)ExampleFileFilter.java 1.8 04/07/26
- */
-/* for use in SimplyHTML */
-package com.sun.demo;
-
-import java.io.File;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import javax.swing.filechooser.FileFilter;
-
-/**
- * A convenience implementation of FileFilter that filters out
- * all files except for those type extensions that it knows about.
- * Extensions are of the type ".foo", which is typically found on
- * Windows and Unix boxes, but not on Macintosh. Case is ignored.
- * Example - create a new filter that filters out all files
- * but gif and jpg image files:
- * JFileChooser chooser = new JFileChooser();
- * ExampleFileFilter filter = new ExampleFileFilter(
- * new String{"gif", "jpg"}, "JPEG & GIF Images")
- * chooser.addChoosableFileFilter(filter);
- * chooser.showOpenDialog(this);
- *
- * @version 1.8 07/26/04
- * @author Jeff Dinkins
- */
-public class ExampleFileFilter extends FileFilter {
- private static final String TYPE_UNKNOWN = "Type Unknown";
- private static final String HIDDEN_FILE = "Hidden File";
- private Hashtable filters = null;
- private String description = null;
- private String fullDescription = null;
- private boolean useExtensionsInDescription = true;
-
- /**
- * Creates a file filter. If no filters are added, then all
- * files are accepted.
- *
- * @see #addExtension
- */
- public ExampleFileFilter() {
- filters = new Hashtable();
- }
-
- /**
- * Creates a file filter that accepts files with the given extension.
- * Example: new ExampleFileFilter("jpg");
- *
- * @see #addExtension
- */
- public ExampleFileFilter(final String extension) {
- this(extension, null);
- }
-
- /**
- * Creates a file filter that accepts the given file type.
- * Example: new ExampleFileFilter("jpg", "JPEG Image Images");
- * Note that the "." before the extension is not needed. If
- * provided, it will be ignored.
- *
- * @see #addExtension
- */
- public ExampleFileFilter(final String extension, final String description) {
- this();
- if (extension != null) {
- addExtension(extension);
- }
- if (description != null) {
- setDescription(description);
- }
- }
-
- /**
- * Creates a file filter from the given string array.
- * Example: new ExampleFileFilter(String {"gif", "jpg"});
- * Note that the "." before the extension is not needed adn
- * will be ignored.
- *
- * @see #addExtension
- */
- public ExampleFileFilter(final String[] filters) {
- this(filters, null);
- }
-
- /**
- * Creates a file filter from the given string array and description.
- * Example: new ExampleFileFilter(String {"gif", "jpg"}, "Gif and JPG Images");
- * Note that the "." before the extension is not needed and will be ignored.
- *
- * @see #addExtension
- */
- public ExampleFileFilter(final String[] filters, final String description) {
- this();
- for (int i = 0; i < filters.length; i++) {
- // add filters one by one
- addExtension(filters[i]);
- }
- if (description != null) {
- setDescription(description);
- }
- }
-
- /**
- * Return true if this file should be shown in the directory pane,
- * false if it shouldn't.
- * Files that begin with "." are ignored.
- *
- * @see #getExtension
- * @see FileFilter#accept
- */
- public boolean accept(final File f) {
- if (f != null) {
- if (f.isDirectory()) {
- return true;
- }
- final String extension = getExtension(f);
- if (extension != null && filters.get(getExtension(f)) != null) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return the extension portion of the file's name .
- *
- * @see #getExtension
- * @see FileFilter#accept
- */
- public String getExtension(final File f) {
- if (f != null) {
- final String filename = f.getName();
- final int i = filename.lastIndexOf('.');
- if (i > 0 && i < filename.length() - 1) {
- return filename.substring(i + 1).toLowerCase();
- }
- }
- return null;
- }
-
- /**
- * Adds a filetype "dot" extension to filter against.
- * For example: the following code will create a filter that filters
- * out all files except those that end in ".jpg" and ".tif":
- * ExampleFileFilter filter = new ExampleFileFilter();
- * filter.addExtension("jpg");
- * filter.addExtension("tif");
- * Note that the "." before the extension is not needed and will be ignored.
- */
- public void addExtension(final String extension) {
- if (filters == null) {
- filters = new Hashtable(5);
- }
- filters.put(extension.toLowerCase(), this);
- fullDescription = null;
- }
-
- /**
- * Returns the human readable description of this filter. For
- * example: "JPEG and GIF Image Files (*.jpg, *.gif)"
- *
- * @see #setDescription
- * @see #setExtensionListInDescription
- * @see #isExtensionListInDescription
- * @see FileFilter#getDescription
- */
- public String getDescription() {
- if (fullDescription == null) {
- if (description == null || isExtensionListInDescription()) {
- fullDescription = description == null ? "(" : description + " (";
- // build the description from the extension list
- final Enumeration extensions = filters.keys();
- if (extensions != null) {
- fullDescription += "." + extensions.nextElement();
- while (extensions.hasMoreElements()) {
- fullDescription += ", ." + extensions.nextElement();
- }
- }
- fullDescription += ")";
- }
- else {
- fullDescription = description;
- }
- }
- return fullDescription;
- }
-
- /**
- * Sets the human readable description of this filter. For
- * example: filter.setDescription("Gif and JPG Images");
- *
- * @see #setDescription
- * @see #setExtensionListInDescription
- * @see #isExtensionListInDescription
- */
- public void setDescription(final String description) {
- this.description = description;
- fullDescription = null;
- }
-
- /**
- * Determines whether the extension list (.jpg, .gif, etc) should
- * show up in the human readable description.
- * Only relevant if a description was provided in the constructor
- * or using setDescription();
- *
- * @see #getDescription
- * @see #setDescription
- * @see #isExtensionListInDescription
- */
- public void setExtensionListInDescription(final boolean b) {
- useExtensionsInDescription = b;
- fullDescription = null;
- }
-
- /**
- * Returns whether the extension list (.jpg, .gif, etc) should
- * show up in the human readable description.
- * Only relevant if a description was provided in the constructor
- * or using setDescription();
- *
- * @see #getDescription
- * @see #setDescription
- * @see #setExtensionListInDescription
- */
- public boolean isExtensionListInDescription() {
- return useExtensionsInDescription;
- }
-}
View it on GitLab: https://salsa.debian.org/java-team/simplyhtml/-/compare/41643528d7d120b9cb2efbb04ef9d2f90b00fd76...83ee68e5ed9f408b66789774b8f5bb9b0dfcd03e
--
View it on GitLab: https://salsa.debian.org/java-team/simplyhtml/-/compare/41643528d7d120b9cb2efbb04ef9d2f90b00fd76...83ee68e5ed9f408b66789774b8f5bb9b0dfcd03e
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20260221/29c27c2d/attachment.htm>
More information about the pkg-java-commits
mailing list