--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project name="swing-utils" default="usage" basedir=".">
+ <import file="../../common-tasks.xml"/>
+ <description>Builds, tests, and runs the project XEMELIOS swing-utils</description>
+ <property file="${user.home}/.ant.properties"/>
+ <xmlproperty file="component-definition-properties.xml"/>
+
+ <target name="usage">
+ <echo>${component.name}</echo>
+ <echo>${component.release}</echo>
+ <echo>${component.url}</echo>
+ </target>
+
+ <target name="compile" depends="mk-output-dirs,define-compile-debug,prepare">
+ <javac srcdir="java" destdir="build/classes" debug="${compile.debug}" encoding="ISO-8859-1">
+ <classpath>
+ <fileset dir="lib" includes="*.jar"/>
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="jars" depends="prepare">
+ <property file="component.properties"/>
+ <copy file="manifest/manifest.txt" tofile="build/manifest.txt">
+ <filterset>
+ <filter token="version" value="${component.release}"/>
+ <filter token="name" value="${component.name}"/>
+ </filterset>
+ </copy>
+ <jar destfile="build/jars/${component.name}.jar" basedir="build/classes"
+ manifest="build/manifest.txt"/>
+ </target>
+
+ <target name="clean">
+ <delete dir="build"/>
+ </target>
+
+
+ <target name="mk-output-dirs">
+ <mkdir dir="build/classes"/>
+ <mkdir dir="build/jars"/>
+ </target>
+
+ <target name="config" description="Genere l'arborescence de mise a jour"
+ depends="get-configuration">
+ <!--xmlproperty file="component-definition-properties.xml"/-->
+ <property name="component.dir"
+ value="build/config/source/${component.name}/${component.release}"/>
+ <copy file="component-definition-properties.xml"
+ tofile="build/config/source/component-definition-properties.xml"/>
+ <mkdir dir="${component.dir}"/>
+ <copy todir="${component.dir}">
+ <fileset dir="build/jars" includes="*.jar"/>
+ <fileset dir="lib" includes="*.jar"/>
+ </copy>
+ <antcall target="generate-update"/>
+ </target>
+
+ <target name="setup">
+ <copy todir="../../build/setup/root/lib">
+ <fileset dir="build/jars" includes="*.jar"/>
+ </copy>
+ <copy todir="../../build/setup/root/lib">
+ <fileset dir="lib" includes="*.jar"/>
+ </copy>
+ <copy todir="../../build/setup/root/resources">
+ <fileset dir="res">
+ <include name="**/*"/>
+ <exclude name="**/CVS"/>
+ <exclude name="log4j.*"/>
+ <exclude name="viewdoc.cmd"/>
+ </fileset>
+ </copy>
+ <copy todir="../../build/setup/root">
+ <fileset dir="res">
+ <include name="log4j.*"/>
+ <include name="viewdoc.cmd"/>
+ </fileset>
+ <fileset dir="lib">
+ <include name="RegAccess.dll"/>
+ </fileset>
+ </copy>
+ </target>
+
+</project>
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<component xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="../../defs/technical-component-definition.xsd">
+ <name>swing-utils</name>
+ <description>Utilitaires Swing</description>
+ <release>5.0.0.2</release>
+ <url>http://xemelios.org/updatesV5/swing-utils</url>
+ <type>COMPOSANT</type>
+ <destination>
+ <base>${xemelios.prg}/lib</base>
+ </destination>
+ <release-notes>
+ <release v="5.0.0.2">
+ <note visibility="dev">Suppression des références à Log4J</note>
+ </release>
+ <release v="5.0.0.1">
+ <note visibility="public">Mise à jour des notes de versions</note>
+ <note visibility="dev">Ajout de la DlgGetDirectory</note>
+ </release>
+ </release-notes>
+</component>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="2"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="jScrollPane1" alignment="0" pref="214" max="32767" attributes="2"/>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="pbOk" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbCancel" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <Component id="cbxDrives" alignment="0" pref="214" max="32767" attributes="2"/>
+ <Component id="lbl" alignment="0" pref="214" max="32767" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="lbl" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="cbxDrives" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Component id="jScrollPane1" pref="288" max="32767" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="pbCancel" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="pbOk" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JComboBox" name="cbxDrives">
+ <Properties>
+ <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="cbxModel" type="code"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="cbxDrivesItemStateChanged"/>
+ </Events>
+ </Component>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="org.jdesktop.swingx.JXTree" name="tree">
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new JXTree(fsm)"/>
+ <AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value="tree.setCellRenderer(new DefaultTreeRenderer(IconValues.FILE_ICON, StringValues.FILE_NAME)); 
"/>
+ </AuxValues>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JButton" name="pbCancel">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Annuler"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbCancelActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbOk">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Ok"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbOkActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JLabel" name="lbl">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="jLabel1"/>
+ </Properties>
+ </Component>
+ </SubComponents>
+</Form>
--- /dev/null
+/*
+ * Copyright
+ * 2011 axYus - http://www.axyus.com
+ * 2011 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS_NB.
+ *
+ * XEMELIOS_NB is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * XEMELIOS_NB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with XEMELIOS_NB; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+package fr.gouv.finances.dgfip.xemelios.swing;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.KeyEvent;
+import java.io.File;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.TreeSet;
+import javax.swing.AbstractAction;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JComponent;
+import javax.swing.JRootPane;
+import javax.swing.KeyStroke;
+import org.jdesktop.swingx.JXTree;
+import org.jdesktop.swingx.renderer.DefaultTreeRenderer;
+import org.jdesktop.swingx.renderer.IconValues;
+import org.jdesktop.swingx.renderer.StringValues;
+import org.jdesktop.swingx.treetable.FileSystemModel;
+
+/**
+ * Une boite qui permet de choisir un directory
+ * @author cmarchand
+ */
+public class DlgGetDirectory extends javax.swing.JDialog {
+ private DefaultComboBoxModel cbxModel;
+ private FileSystemModel fsm;
+ private boolean ret = false;
+ private File selectedDir = null;
+
+ /** Creates new form DlgGetDirectory */
+ public DlgGetDirectory(java.awt.Frame parent, String title) {
+ super(parent, title, true);
+ ret = false;
+ cbxModel = new DefaultComboBoxModel(File.listRoots());
+ fsm = new DirFileSystemModel();
+ initComponents();
+ setLocationRelativeTo(getParent());
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ cbxDrives = new javax.swing.JComboBox();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ tree = new JXTree(fsm);
+ tree.setCellRenderer(new DefaultTreeRenderer(IconValues.FILE_ICON, StringValues.FILE_NAME));
+ pbCancel = new javax.swing.JButton();
+ pbOk = new javax.swing.JButton();
+ lbl = new javax.swing.JLabel();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+
+ cbxDrives.setModel(cbxModel);
+ cbxDrives.addItemListener(new java.awt.event.ItemListener() {
+ public void itemStateChanged(java.awt.event.ItemEvent evt) {
+ cbxDrivesItemStateChanged(evt);
+ }
+ });
+
+ jScrollPane1.setViewportView(tree);
+
+ pbCancel.setText("Annuler");
+ pbCancel.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbCancelActionPerformed(evt);
+ }
+ });
+
+ pbOk.setText("Ok");
+ pbOk.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbOkActionPerformed(evt);
+ }
+ });
+
+ lbl.setText("jLabel1");
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(pbOk)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(pbCancel))
+ .addComponent(cbxDrives, javax.swing.GroupLayout.Alignment.LEADING, 0, 214, Short.MAX_VALUE)
+ .addComponent(lbl, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(lbl)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(cbxDrives, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(pbCancel)
+ .addComponent(pbOk))
+ .addContainerGap())
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void cbxDrivesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbxDrivesItemStateChanged
+ if(evt.getStateChange()==ItemEvent.SELECTED) {
+ fsm.setRoot((File)cbxDrives.getSelectedItem());
+ }
+ }//GEN-LAST:event_cbxDrivesItemStateChanged
+
+ private void pbCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbCancelActionPerformed
+ setVisible(false);
+ }//GEN-LAST:event_pbCancelActionPerformed
+
+ private void pbOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbOkActionPerformed
+ ret = true;
+ selectedDir = (File)tree.getSelectionPaths()[0].getLastPathComponent();
+ setVisible(false);
+ }//GEN-LAST:event_pbOkActionPerformed
+
+ /**
+ * Displays this dialog, and returns true if user has accepted a selection
+ * @param message
+ * @return
+ */
+ public boolean run(String message) {
+ lbl.setText(message);
+ pack();
+ setVisible(true);
+ return ret;
+ }
+ public File getSelectedDir() { return selectedDir; }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JComboBox cbxDrives;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JLabel lbl;
+ private javax.swing.JButton pbCancel;
+ private javax.swing.JButton pbOk;
+ private org.jdesktop.swingx.JXTree tree;
+ // End of variables declaration//GEN-END:variables
+
+ @Override
+ protected JRootPane createRootPane() {
+ KeyStroke ksEscape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
+ KeyStroke ksEnter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
+ JRootPane rp = new JRootPane();
+ AbstractAction escapeAction = new AbstractAction("Annuler") {
+ @Override
+ public void actionPerformed(ActionEvent evt) {
+ pbCancel.doClick();
+ }
+ };
+ rp.registerKeyboardAction(escapeAction, "CANCEL", ksEscape, JComponent.WHEN_IN_FOCUSED_WINDOW);
+ AbstractAction okAction = new AbstractAction("Ok") {
+ @Override
+ public void actionPerformed(ActionEvent evt) {
+ pbOk.doClick();
+ }
+ };
+ rp.registerKeyboardAction(okAction, "OK", ksEnter, JComponent.WHEN_IN_FOCUSED_WINDOW);
+ return rp;
+ }
+
+ private static class DirFileSystemModel extends FileSystemModel {
+ public DirFileSystemModel() { super(); }
+ public DirFileSystemModel(File root) { super(root); }
+
+ @Override
+ public int getChildCount(Object parent) {
+ File parentFile = (File)parent;
+ File[] childs = parentFile.listFiles();
+ int count = 0;
+ for(File f:childs) if(f.isDirectory()) count++;
+ return count;
+ }
+
+ @Override
+ public File getChild(Object parent, int index) {
+ Comparator<File> cp = new Comparator<File>() {
+ @Override
+ public int compare(File f1, File f2) {
+ return f1.getName().compareTo(f2.getName());
+ }
+ public boolean equals(File f1, File f2) { return f1.equals(f2); }
+ };
+ TreeSet<File> ts = new TreeSet<File>(cp);
+ File parentFile = (File)parent;
+// logger.debug("getChild("+parentFile.getName()+","+index+")");
+ File[] childs = parentFile.listFiles();
+ for(File f:childs) {
+ if(f.isDirectory()) {
+// logger.debug("adding "+f.getName());
+ ts.add(f);
+ }
+ }
+ int count = -1;
+ File ret = null;
+ Iterator<File> it = ts.iterator();
+ while(count<index) {
+ ret = it.next();
+ count++;
+ }
+ return ret;
+ }
+
+ }
+}
--- /dev/null
+/*
+ * Copyright
+ * 2005 axYus - www.axyus.com
+ * 2005 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * XEMELIOS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package fr.gouv.finances.dgfip.xemelios.swing;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+
+import javax.swing.JComponent;
+/**
+ * This class draws something that seems to be a clock
+ * on a translucid background. Use it in a GlassPane to
+ * drive users patient ;-))
+ * This class is only used to draw the background when necessary ; real job
+ * is done by {@link JRotatePanel}
+ * @author chm
+ *
+ */
+public class InfiniteGlassPane extends JComponent {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 6381799807769407898L;
+ protected JRotatePanel rotor=null;
+ public InfiniteGlassPane() {
+ super();
+ initComponents();
+ }
+ protected void initComponents() {
+// setOpaque(false);
+ add(rotor=new JRotatePanel());
+ setVisible(false);
+ addComponentListener(new ComponentAdapter() {
+ @Override
+ public void componentResized(ComponentEvent e) {
+ rotor.setSize(getSize());
+ }
+ });
+ }
+ @Override
+ protected void paintComponent(Graphics g) {
+// super.paintComponent(g);
+ rotor.paintBackground(g);
+ rotor.paintComponent(g);
+ }
+ @Override
+ public void setVisible(boolean aFlag) {
+ super.setVisible(aFlag);
+ rotor.setSize(getSize());
+ rotor.setVisible(aFlag);
+ }
+ @Override
+ public void setSize(Dimension d) {
+ super.setSize(d);
+ rotor.setSize(d);
+ }
+ @Override
+ public void setSize(int width, int height) {
+ super.setSize(width, height);
+ rotor.setSize(width,height);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright
+ * 2007 axYus - www.axyus.com
+ * 2007 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * XEMELIOS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package fr.gouv.finances.dgfip.xemelios.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.OverlayLayout;
+import javax.swing.SwingConstants;
+import org.jdesktop.swingworker.SwingWorker;
+
+/**
+ * An {@link InfiniteGlassPane} that displays a cancel button.
+ * @author chm
+ */
+public class InterruptibleInfiniteGlassPane extends InfiniteGlassPane {
+ private SwingWorker threadToInterrupt;
+ protected JButton pbCancel;
+ protected JLabel lblStop;
+
+ /** Creates a new instance of InterruptibleInfiniteGlassPane */
+ public InterruptibleInfiniteGlassPane() {
+ super();
+ setAlignmentX(0.5f);
+ setAlignmentY(0.5f);
+ }
+ @Override
+ protected void initComponents() {
+ setLayout(new OverlayLayout(this));
+ lblStop = new JLabel("Arrêt en cours...");
+ lblStop.setForeground(Color.RED);
+ lblStop.setAlignmentX(0.5f);
+ lblStop.setAlignmentY(0.5f);
+ lblStop.setHorizontalAlignment(SwingConstants.CENTER);
+ JPanel p1 = new JPanel(new BorderLayout());
+ p1.setOpaque(false);
+ p1.setSize(150,80);
+ Dimension dim = new Dimension(150,80);
+ p1.setPreferredSize(dim);
+ p1.setMinimumSize(dim);
+ p1.setMaximumSize(dim);
+ p1.add(lblStop,BorderLayout.SOUTH);
+ add(p1);
+
+ pbCancel=new JButton("Annuler");
+ pbCancel.setAlignmentX(0.5f);
+ pbCancel.setAlignmentY(0.5f);
+ add(pbCancel);
+ rotor=new JRotatePanel();
+ rotor.setAlignmentX(0.5f);
+ rotor.setAlignmentY(0.5f);
+ add(rotor);
+ setVisible(false);
+ addComponentListener(new ComponentAdapter() {
+ @Override
+ public void componentResized(ComponentEvent e) {
+ rotor.setSize(getSize());
+ pbCancel.setLocation(3,(int)(getSize().getHeight()-pbCancel.getHeight()-3));
+ }
+ });
+ pbCancel.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ lblStop.setVisible(true);
+ if(threadToInterrupt!=null) threadToInterrupt.cancel(true);
+ }
+ });
+ }
+ @Override
+ public void setSize(Dimension d) {
+ super.setSize(d);
+ rotor.setSize(d);
+ }
+ @Override
+ public void setSize(int width, int height) {
+ super.setSize(width, height);
+ rotor.setSize(width,height);
+ }
+ public void setVisible(SwingWorker sw) {
+ threadToInterrupt=sw;
+ lblStop.setVisible(false);
+ super.setVisible(true);
+ rotor.setSize(getSize());
+ rotor.setVisible(true);
+ pbCancel.setVisible(true);
+ }
+ @Override
+ public void setVisible(boolean aFlag) {
+ if(aFlag && threadToInterrupt==null) throw new UnsupportedOperationException("You must use setVisible(SwingWorker) to show this glassPane");
+ super.setVisible(aFlag);
+ if(!aFlag) lblStop.setVisible(false);
+ rotor.setSize(getSize());
+ rotor.setVisible(aFlag);
+ pbCancel.setVisible(aFlag);
+ }
+ @Override
+ protected void paintComponent(Graphics g) {
+ rotor.paintBackground(g);
+ rotor.paintComponent(g);
+ }
+
+ public void setThreadToInterrupt(SwingWorker threadToInterrupt) {
+ this.threadToInterrupt = threadToInterrupt;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright
+ * 2005 axYus - www.axyus.com
+ * 2005 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * XEMELIOS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package fr.gouv.finances.dgfip.xemelios.swing;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionAdapter;
+import java.awt.event.MouseMotionListener;
+import java.awt.geom.AffineTransform;
+
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+/**
+ * This class draws the rotating clock-like panel while it is visible
+ * @author chm
+ *
+ */
+public class JRotatePanel extends JComponent {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -8892664236789395368L;
+ private boolean stop;
+// private boolean alreadyPaintBack = false;
+ MouseListener ml = null;
+ MouseMotionListener mml = null;
+ KeyListener kl = null;
+ public JRotatePanel() {
+ super();
+ ml = new MouseAdapter(){};
+ mml = new MouseMotionAdapter() {};
+ kl = new KeyAdapter() {};
+ }
+
+ public void start() {
+ setVisible(true);
+ }
+
+ @Override
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ Graphics2D g2d = (Graphics2D)g;
+ Image drkImg = createImage(false);
+ Image clrImg = createImage(true);
+
+ int midX = getWidth()/2;
+ int midY = getHeight()/2;
+ int imgWidth = drkImg.getWidth(this)/2;
+ int imgHeight = drkImg.getHeight(this)/2;
+
+// int xRadius = (int)((midX-clrImg.getWidth(this)) * 0.8);
+// int yRadius = (int)((midY-clrImg.getHeight(this)) * 0.8);
+
+ int width = clrImg.getWidth(this);
+// int xRadius = (int)(Math.min(midX,midY)-width);
+ int xRadius = 50;
+ int yRadius = xRadius;
+
+// if(!alreadyPaintBack) {
+// alreadyPaintBack = true;
+// }
+
+ int sec = (int)((System.currentTimeMillis() / 500 ) % 12)+1;
+ for(int i=1;i<=12;i++) {
+
+ double angle = Math.PI/2.0 + Math.PI*2*i/12;
+ int xPos = (int)(midX + Math.cos(angle)*xRadius);
+ int yPos = (int)(midY + Math.sin(angle)*yRadius);
+
+ AffineTransform at = AffineTransform.getTranslateInstance(xPos,yPos);
+ at.rotate(angle);
+ at.translate(-imgWidth,-imgHeight);
+
+ g2d.drawImage(i==sec?clrImg:drkImg,at,this);
+ }
+ }
+ public void paintBackground(Graphics g) {
+// if(g!=null) {
+// g.setColor(new Color(255,255,255,167));
+// g.fillRect(0,0,getWidth(),getHeight());
+// }
+ }
+
+ @Override
+ public void setVisible(boolean aFlag) {
+ super.setVisible(aFlag);
+ if(aFlag) {
+ stop = false;
+// alreadyPaintBack=false;
+ RePainter rp = new RePainter();
+ setFocusTraversalKeysEnabled(false);
+ addMouseListener(ml);
+ addMouseMotionListener(mml);
+ addKeyListener(kl);
+ requestFocusInWindow();
+ paintBackground(getGraphics());
+ rp.start();
+ } else {
+ stop = true;
+ setFocusTraversalKeysEnabled(true);
+ removeMouseListener(ml);
+ removeMouseMotionListener(mml);
+ removeKeyListener(kl);
+ }
+ }
+
+ private Image createImage(boolean light) {
+ Image img = createImage(25,10);
+ if(img!=null) {
+ Graphics g = img.getGraphics();
+ g.setColor(light?Color.GRAY:Color.LIGHT_GRAY);
+ g.fill3DRect(0,0,25,10,true);
+ }
+ return img;
+ }
+
+ private class RePainter extends Thread {
+ @Override
+ public void run() {
+ setPriority(Thread.MIN_PRIORITY);
+ while(!JRotatePanel.this.stop) {
+ try {
+ SwingUtilities.invokeAndWait(new Thread() {
+ @Override
+ public void run() {
+ JRotatePanel.this.paint(JRotatePanel.this.getGraphics());
+ }
+ });
+ Thread.sleep(500);
+ } catch(Throwable t) {}
+ }
+ }
+ }
+}
--- /dev/null
+Manifest-version: 1.0
+Jar-Version: @version@
+Jar-Content: @name@
\ No newline at end of file