--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project name="XEMELIOS-mysql-maintenance" default="jars" basedir=".">
+ <import file="../../common-tasks.xml"/>
+ <description>Builds, tests the plugin generator-pes-pj</description>
+ <property file="${user.home}/.ant.properties"/>
+ <property name="compile.debug" value="true"/>
+ <xmlproperty file="component-definition-properties.xml"/>
+
+ <target name="usage">
+ <echo>
+ Using ${ant.version}
+
+ These are targets supported by this ANT build script:
+
+ compile - compile all .java files, except
+ thoses in ./tmp folder.
+ clean - deletes all compiled and generated
+ files and resources.
+ jars - build jar files.
+
+ Do not call this script directly, use the one located
+ at root of projet (in ../..) instead.
+ </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>
+ <pathelement path="../api-plugin/build/classes"/>
+ <pathelement path="../core/build/classes"/>
+ <pathelement path="../starter/build/classes"/>
+ <pathelement path="../xml-marshall/build/classes"/>
+ <fileset dir="../core/lib" includes="*.jar"/>
+ <fileset dir="../swing-utils/lib" includes="*.jar"/>
+ </classpath>
+ </javac>
+ <copy todir="build/classes">
+ <fileset dir="java">
+ <include name="**/*"/>
+ <exclude name="**/*.java"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="jars">
+ <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="config" depends="get-configuration,prepare">
+ <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"/>
+ </copy>
+ <antcall target="generate-update"/>
+ </target>
+
+ <target name="setup">
+ <copy todir="../../build/setup/root/tools">
+ <fileset dir="build/jars" includes="*.jar"/>
+ </copy>
+ </target>
+
+ <target name="clean">
+ <delete dir="build"/>
+ </target>
+
+
+ <target name="mk-output-dirs">
+ <mkdir dir="build/classes"/>
+ <mkdir dir="build/jars"/>
+ <mkdir dir="build/config"/>
+ </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>mysql-maintenance</name>
+ <description>Outil de maintenance de la base MySql</description>
+ <release>5.0.0.0</release>
+ <url>http://xemelios.org/updatesV5/mysql-maintenance</url>
+ <type>COMPOSANT</type>
+ <destination>
+ <base>${xemelios.tools.directory}</base>
+ </destination>
+ <release-notes>
+ <release v="5.0.0.0">
+ <note visibility="public">Première version pour recette</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" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="jScrollPane1" alignment="1" pref="506" max="32767" attributes="0"/>
+ <Group type="102" alignment="0" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="lblTablName" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="lblStatus" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace pref="65" max="32767" attributes="0"/>
+ <Group type="103" groupAlignment="1" max="-2" attributes="0">
+ <Component id="dfTableName" max="32767" attributes="1"/>
+ <Component id="dfStatus" alignment="1" pref="401" max="32767" attributes="1"/>
+ </Group>
+ </Group>
+ <Component id="pbClose" alignment="1" min="-2" max="-2" attributes="0"/>
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="lblRows" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="dfRows" pref="401" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Component id="lblTablName" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Component id="lblStatus" min="-2" max="-2" attributes="0"/>
+ <EmptySpace pref="16" max="32767" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="dfTableName" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="dfStatus" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="lblRows" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="dfRows" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace type="separate" max="-2" attributes="0"/>
+ <Component id="jScrollPane1" min="-2" pref="103" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbClose" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="lblTablName">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Table"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="lblStatus">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Statut"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="dfTableName">
+ <Properties>
+ <Property name="editable" type="boolean" value="false"/>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="table.getTableName()" type="code"/>
+ </Property>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
+ <EmptyBorder/>
+ </Border>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="dfStatus">
+ <Properties>
+ <Property name="editable" type="boolean" value="false"/>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="Integer.toString(table.getStatus())" type="code"/>
+ </Property>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
+ <EmptyBorder/>
+ </Border>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbClose">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/org/xemelios/mysql/maintenance/resources/exit.png"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Fermer"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbCloseActionPerformed"/>
+ </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="javax.swing.JTable" name="tblCheck">
+ <Properties>
+ <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="model" type="code"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JLabel" name="lblRows">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Nombre lignes"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="dfRows">
+ <Properties>
+ <Property name="editable" type="boolean" value="false"/>
+ <Property name="horizontalAlignment" type="int" value="11"/>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="Integer.toString(table.getRows())" type="code"/>
+ </Property>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
+ <EmptyBorder/>
+ </Border>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+</Form>
--- /dev/null
+/*
+ * Copyright
+ * 2012 axYus - http://www.axyus.com
+ * 2012 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 org.xemelios.mysql.maintenance;
+
+import java.util.ArrayList;
+import javax.swing.table.AbstractTableModel;
+
+/**
+ *
+ * @author cmarchand
+ */
+class DlgDetailTable extends javax.swing.JDialog {
+ private DlgMaintMySql.TableInformations table;
+ private TableCheckModel model;
+
+ /** Creates new form DlgDetailTable */
+ DlgDetailTable(java.awt.Dialog parent, DlgMaintMySql.TableInformations table) {
+ super(parent, "Détails de la table "+ table.getTableName() , true);
+ this.table = table;
+ this.model=new TableCheckModel(table);
+ initComponents();
+ setLocationRelativeTo(parent);
+ }
+
+ /** 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() {
+
+ lblTablName = new javax.swing.JLabel();
+ lblStatus = new javax.swing.JLabel();
+ dfTableName = new javax.swing.JTextField();
+ dfStatus = new javax.swing.JTextField();
+ pbClose = new javax.swing.JButton();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ tblCheck = new javax.swing.JTable();
+ lblRows = new javax.swing.JLabel();
+ dfRows = new javax.swing.JTextField();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+
+ lblTablName.setText("Table");
+
+ lblStatus.setText("Statut");
+
+ dfTableName.setEditable(false);
+ dfTableName.setText(table.getTableName());
+ dfTableName.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
+
+ dfStatus.setEditable(false);
+ dfStatus.setText(Integer.toString(table.getStatus()));
+ dfStatus.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
+
+ pbClose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/xemelios/mysql/maintenance/resources/exit.png"))); // NOI18N
+ pbClose.setText("Fermer");
+ pbClose.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbCloseActionPerformed(evt);
+ }
+ });
+
+ tblCheck.setModel(model);
+ jScrollPane1.setViewportView(tblCheck);
+
+ lblRows.setText("Nombre lignes");
+
+ dfRows.setEditable(false);
+ dfRows.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
+ dfRows.setText(Integer.toString(table.getRows()));
+ dfRows.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 506, Short.MAX_VALUE)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(lblTablName)
+ .addComponent(lblStatus))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 65, Short.MAX_VALUE)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
+ .addComponent(dfTableName)
+ .addComponent(dfStatus, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE)))
+ .addComponent(pbClose, javax.swing.GroupLayout.Alignment.TRAILING)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(lblRows)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(dfRows, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(lblTablName)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(lblStatus)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, Short.MAX_VALUE))
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(dfTableName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(dfStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(lblRows)
+ .addComponent(dfRows, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(18, 18, 18)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(pbClose)
+ .addContainerGap())
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void pbCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbCloseActionPerformed
+ setVisible(false);
+ }//GEN-LAST:event_pbCloseActionPerformed
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JTextField dfRows;
+ private javax.swing.JTextField dfStatus;
+ private javax.swing.JTextField dfTableName;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JLabel lblRows;
+ private javax.swing.JLabel lblStatus;
+ private javax.swing.JLabel lblTablName;
+ private javax.swing.JButton pbClose;
+ private javax.swing.JTable tblCheck;
+ // End of variables declaration//GEN-END:variables
+
+ private class TableCheckModel extends AbstractTableModel {
+ private ArrayList<DlgMaintMySql.CheckResult> results;
+ public TableCheckModel(DlgMaintMySql.TableInformations ti) {
+ super();
+ this.results = ti.getResults();
+ }
+ @Override
+ public int getRowCount() {
+ return results.size();
+ }
+ @Override
+ public int getColumnCount() {
+ return 2;
+ }
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ switch(columnIndex) {
+ case 0: return results.get(rowIndex).getMsgType();
+ default: return results.get(rowIndex).getMsgText();
+ }
+ }
+ @Override
+ public String getColumnName(int column) {
+ if(column==0) return "Type";
+ else return "Message";
+ }
+ }
+}
--- /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 max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="scrollPane" pref="488" max="32767" attributes="0"/>
+ <Component id="chkHideCorrect" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="pbExit" linkSize="3" min="-2" max="-2" attributes="0"/>
+ <Group type="103" alignment="1" groupAlignment="0" attributes="0">
+ <Component id="pbRepair" linkSize="3" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="pbDetails" linkSize="3" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="chkHideCorrect" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="scrollPane" alignment="1" pref="307" max="32767" attributes="0"/>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="pbRepair" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
+ <Component id="pbDetails" min="-2" max="-2" attributes="0"/>
+ <EmptySpace pref="238" max="32767" attributes="0"/>
+ <Component id="pbExit" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Container class="javax.swing.JScrollPane" name="scrollPane">
+ <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.JXTable" name="table">
+ <Properties>
+ <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="model" type="code"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JButton" name="pbExit">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/org/xemelios/mysql/maintenance/resources/exit.png"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Quitter"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbExitActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbRepair">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/org/xemelios/mysql/maintenance/resources/tools.png"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Réparer"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbRepairActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbDetails">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/org/xemelios/mysql/maintenance/resources/details.png"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Détails"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbDetailsActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JCheckBox" name="chkHideCorrect">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Masquer les tables correctes"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chkHideCorrectActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+</Form>
--- /dev/null
+/*
+ * Copyright
+ * 2012 axYus - http://www.axyus.com
+ * 2012 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 org.xemelios.mysql.maintenance;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Properties;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import javax.swing.JOptionPane;
+import javax.swing.ListSelectionModel;
+import javax.swing.WindowConstants;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.AbstractTableModel;
+import org.apache.log4j.Logger;
+import org.jdesktop.swingx.decorator.ColorHighlighter;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.FilterPipeline;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.PatternFilter;
+
+/**
+ *
+ * @author cmarchand
+ */
+public class DlgMaintMySql extends javax.swing.JDialog {
+ private static final int STATUS_VALID = 0;
+ private static final int STATUS_UNCHECKED = -1;
+ private static final int STATUS_ERROR = 1;
+ private static final int STATUS_REPAIRING = -2;
+ private static final int STATUS_REPAIR_ASKED = 2;
+ private static final Logger logger = Logger.getLogger(DlgMaintMySql.class);
+ private Properties mysqlProperties;
+ private Connection con;
+ private DbTableModel model = null;
+ private ExecutorService service = null;
+
+ /** Creates new form DlgMaintMySql */
+ public DlgMaintMySql(java.awt.Frame parent, Properties props) {
+ super(parent, "Maintenance de la base de données", false);
+ mysqlProperties = props;
+ addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosed(WindowEvent e) {
+ if(con!=null)
+ try {
+ con.close();
+ } catch(SQLException sqlEx) {
+ logger.error("while closing connection",sqlEx);
+ }
+ super.windowClosed(e);
+ }
+ });
+ try {
+ initializeConnection();
+ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+ initializeModel();
+ } catch(Exception ex) {
+ logger.error("<init>", ex);
+ JOptionPane.showMessageDialog(parent, ex.getMessage());
+ return;
+ }
+ initComponents();
+ table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ ColorHighlighter greyH = new ColorHighlighter(new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component cmpnt, ComponentAdapter ca) {
+ try {
+ Integer status = (Integer)ca.getValue(1);
+ return status.equals(STATUS_UNCHECKED);
+ } catch(Throwable t) {
+ return false;
+ }
+ }
+ }, Color.LIGHT_GRAY, null);
+ ColorHighlighter greenH = new ColorHighlighter(new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component cmpnt, ComponentAdapter ca) {
+ Integer status = (Integer)ca.getValue(1);
+ return status.equals(STATUS_VALID);
+ }
+ }, null, new Color(58, 174, 80));
+ ColorHighlighter redH = new ColorHighlighter(new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component cmpnt, ComponentAdapter ca) {
+ Integer status = (Integer)ca.getValue(1);
+ return status.equals(STATUS_ERROR);
+ }
+ }, null, Color.RED);
+ ColorHighlighter brownH = new ColorHighlighter(new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component cmpnt, ComponentAdapter ca) {
+ Integer status = (Integer)ca.getValue(1);
+ return status.equals(STATUS_REPAIRING);
+ }
+ }, null, Color.BLUE);
+ table.setHighlighters(greyH, greenH, redH);
+ table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ int __row = table.getSelectedRow();
+ if(__row<0) {
+ pbDetails.setEnabled(false);
+ pbRepair.setEnabled(false);
+ return;
+ }
+ int selectedRow = table.convertRowIndexToModel(__row);
+ TableInformations ti = model.getTableInfosAt(selectedRow);
+ if(selectedRow>=0) {
+ pbRepair.setEnabled(ti.getStatus()==STATUS_ERROR);
+ pbDetails.setEnabled(ti.status!=STATUS_UNCHECKED);
+ } else {
+ pbDetails.setEnabled(false);
+ pbRepair.setEnabled(false);
+ }
+ }
+ });
+ service = Executors.newFixedThreadPool(1);
+ }
+
+ @Override
+ public void setVisible(boolean b) {
+ super.setVisible(b);
+ if(b) {
+ for(int i=0;i<model.getRowCount();i++) {
+ TableInformations ti = model.getTableInfosAt(i);
+ service.submit(new TableInformationUpdater(ti, con, model, i));
+ }
+ chkHideCorrect.doClick();
+ } else {
+ if(service!=null)
+ service.shutdownNow();
+ if(con!=null)
+ try {
+ con.close();
+ } catch(Throwable t) {}
+ }
+ }
+
+ /** 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() {
+
+ scrollPane = new javax.swing.JScrollPane();
+ table = new org.jdesktop.swingx.JXTable();
+ pbExit = new javax.swing.JButton();
+ pbRepair = new javax.swing.JButton();
+ pbDetails = new javax.swing.JButton();
+ chkHideCorrect = new javax.swing.JCheckBox();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+
+ table.setModel(model);
+ scrollPane.setViewportView(table);
+
+ pbExit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/xemelios/mysql/maintenance/resources/exit.png"))); // NOI18N
+ pbExit.setText("Quitter");
+ pbExit.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbExitActionPerformed(evt);
+ }
+ });
+
+ pbRepair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/xemelios/mysql/maintenance/resources/tools.png"))); // NOI18N
+ pbRepair.setText("Réparer");
+ pbRepair.setEnabled(false);
+ pbRepair.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbRepairActionPerformed(evt);
+ }
+ });
+
+ pbDetails.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/xemelios/mysql/maintenance/resources/details.png"))); // NOI18N
+ pbDetails.setText("Détails");
+ pbDetails.setEnabled(false);
+ pbDetails.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbDetailsActionPerformed(evt);
+ }
+ });
+
+ chkHideCorrect.setText("Masquer les tables correctes");
+ chkHideCorrect.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ chkHideCorrectActionPerformed(evt);
+ }
+ });
+
+ 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.LEADING)
+ .addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 488, Short.MAX_VALUE)
+ .addComponent(chkHideCorrect))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(pbExit)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(pbRepair)
+ .addComponent(pbDetails)))
+ .addContainerGap())
+ );
+
+ layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {pbDetails, pbExit, pbRepair});
+
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(chkHideCorrect)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(scrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addComponent(pbRepair)
+ .addGap(0, 0, 0)
+ .addComponent(pbDetails)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 238, Short.MAX_VALUE)
+ .addComponent(pbExit)))
+ .addContainerGap())
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void pbExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbExitActionPerformed
+ setVisible(false);
+ }//GEN-LAST:event_pbExitActionPerformed
+
+ private void pbRepairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbRepairActionPerformed
+ int __row = table.getSelectedRow();
+ if(__row<0) return;
+ int row = table.convertRowIndexToModel(__row);
+ TableInformations ti = model.getTableInfosAt(row);
+ service.submit(new TableReparator(ti, con, model, row));
+ ti.status = STATUS_REPAIR_ASKED;
+ model.fireTableRowsUpdated(row, row);
+ }//GEN-LAST:event_pbRepairActionPerformed
+
+ private void chkHideCorrectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkHideCorrectActionPerformed
+ if(chkHideCorrect.isSelected()) {
+ table.setFilters(new FilterPipeline(new PatternFilter("^[^0]+$", 0, 1) {
+ @Override
+ public String getStringAt(int row, int column) {
+ return Integer.toString(model.getTableInfosAt(row).status);
+ }
+ }));
+ } else {
+ table.setFilters(new FilterPipeline(new FilterPipeline.IdentityFilter()));
+ }
+ }//GEN-LAST:event_chkHideCorrectActionPerformed
+
+ private void pbDetailsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbDetailsActionPerformed
+ if(table.getSelectedRow()<0) return;
+ new DlgDetailTable(this, model.getTableInfosAt(table.convertRowIndexToModel(table.getSelectedRow()))).setVisible(true);
+ }//GEN-LAST:event_pbDetailsActionPerformed
+
+ private void initializeConnection() throws Exception {
+ String unScrambledPasswd = null;
+ Class clazz = Class.forName("fr.gouv.finances.dgfip.xemelios.common.Scramble");
+ Method meth = clazz.getMethod("unScramblePassword", String.class);
+ unScrambledPasswd = meth.invoke(null, mysqlProperties.getProperty("password")).toString();
+ Class driver = Class.forName(mysqlProperties.getProperty("driver.class"));
+ con = DriverManager.getConnection(mysqlProperties.getProperty("database.url"),mysqlProperties.getProperty("user"),unScrambledPasswd);
+ }
+ private void initializeModel() throws SQLException {
+ ArrayList<TableInformations> tables = new ArrayList<TableInformations>();
+ Statement st = con.createStatement();
+ ResultSet rs = st.executeQuery("SHOW TABLES");
+ while(rs.next()) {
+ String tableName = rs.getString(1);
+ TableInformations ti = new TableInformations(tableName);
+ tables.add(ti);
+ }
+ for(TableInformations ti:tables) {
+ try {
+ ti.countRows(con);
+ } catch(SQLException sqlEx) {
+ logger.warn("while counting in "+ti.tableName,sqlEx);
+ // c'est arbitraire, et pi c'est tout !
+ ti.rows = -10000;
+ }
+ }
+ Collections.sort(tables, new Comparator<TableInformations>() {
+
+ @Override
+ public int compare(TableInformations o1, TableInformations o2) {
+ return o1.rows - o2.rows;
+ }
+ });
+ model = new DbTableModel(tables);
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JCheckBox chkHideCorrect;
+ private javax.swing.JButton pbDetails;
+ private javax.swing.JButton pbExit;
+ private javax.swing.JButton pbRepair;
+ private javax.swing.JScrollPane scrollPane;
+ private org.jdesktop.swingx.JXTable table;
+ // End of variables declaration//GEN-END:variables
+
+ public String getStatusLibelle(int status) {
+ switch(status) {
+ case STATUS_ERROR: return "Corrompue";
+ case STATUS_REPAIRING: return "En cours de réparation";
+ case STATUS_REPAIR_ASKED: return "Réparation demandée";
+ case STATUS_UNCHECKED: return "Non vérifiée";
+ case STATUS_VALID: return "Valide";
+ default: return "Inconnu";
+ }
+ }
+ private class DbTableModel extends AbstractTableModel {
+ private ArrayList<TableInformations> data;
+
+ public DbTableModel(ArrayList<TableInformations> originalData) {
+ super();
+ data = originalData;
+ }
+ @Override
+ public int getRowCount() {
+ return data.size();
+ }
+ @Override
+ public int getColumnCount() {
+ return 4;
+ }
+ @Override
+ public String getColumnName(int column) {
+ switch(column) {
+ case 0: return "Table";
+ case 1 : return "Statut";
+ case 2: return "Statut";
+ default: return "Message";
+ }
+ }
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ if(columnIndex==1) return Integer.class;
+ else return String.class;
+ }
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ TableInformations ti = getTableInfosAt(rowIndex);
+ switch(columnIndex) {
+ case 0: return ti.getTableName();
+ case 1: return ti.getStatus();
+ case 2: return getStatusLibelle(ti.getStatus());
+ default: return ti.getStatusMsg();
+ }
+ }
+ public TableInformations getTableInfosAt(int row) {
+ return data.get(row);
+ }
+
+ }
+ class TableInformations {
+ private String tableName;
+ private int status;
+ private String statusMsg;
+ private ArrayList<CheckResult> results;
+ private int rows;
+ public TableInformations(String tableName) {
+ super();
+ this.tableName = tableName;
+ this.status = STATUS_UNCHECKED;
+ this.statusMsg = "En cours d'évaluation...";
+ }
+ public String getTableName() {
+ return tableName;
+ }
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+ public void analyseTable(Connection con) throws SQLException {
+ ResultSet rs = con.createStatement().executeQuery("CHECK TABLE "+tableName); // +" extended"
+ results = new ArrayList<CheckResult>();
+ while(rs.next()) {
+ // 1 : tableName
+ // 2 : Op = always check
+ // 3 : Msg_type : status,error,info,warning,note
+ // 4 : Msg_text
+ results.add(new CheckResult(rs.getString(3), rs.getString(4)));
+ }
+ rs.close();
+ CheckResult lastResult = results.get(results.size()-1);
+ if(!"status".equals(lastResult.msgType)) {
+ logger.error("check table did not finished with a status row");
+ status = STATUS_ERROR;
+ }
+ if("OK".equals(lastResult.msgText) || "Table is already up to date".equals(lastResult.msgText)) {
+ status = STATUS_VALID;
+ } else {
+ status = STATUS_ERROR;
+ }
+ statusMsg = lastResult.msgText;
+ }
+ public ArrayList<CheckResult> getResults() {
+ return results;
+ }
+ public int getStatus() {
+ return status;
+ }
+ public String getStatusMsg() {
+ return statusMsg;
+ }
+ public void countRows(Connection con) throws SQLException {
+ ResultSet rs = con.createStatement().executeQuery("SELECT COUNT(*) FROM "+tableName);
+ rs.next();
+ rows = rs.getInt(1);
+ }
+
+ public int getRows() {
+ return rows;
+ }
+ }
+ class CheckResult {
+ private String msgType, msgText;
+ public CheckResult(String type, String text) {
+ super();
+ this.msgType = type;
+ this.msgText = text;
+ }
+ public String getMsgText() {
+ return msgText;
+ }
+ public String getMsgType() {
+ return msgType;
+ }
+ }
+ private class TableInformationUpdater implements Runnable {
+ private TableInformations ti;
+ private Connection con;
+ private DbTableModel model;
+ private int row;
+ public TableInformationUpdater(TableInformations table, Connection con, DbTableModel model, int row) {
+ super();
+ this.ti = table;
+ this.con = con;
+ this.model = model;
+ this.row = row;
+ }
+
+ @Override
+ public void run() {
+ try {
+ ti.analyseTable(con);
+ } catch(Exception ex) {
+ logger.error("while analysing "+ti.getTableName(), ex);
+ }
+ model.fireTableRowsUpdated(row, row);
+ }
+
+ }
+ private class TableReparator implements Runnable {
+ private TableInformations table;
+ private Connection con;
+ private DbTableModel model;
+ private int row;
+ public TableReparator(TableInformations table, Connection con, DbTableModel model, int row) {
+ super();
+ this.table=table;
+ this.con = con;
+ this.model=model;
+ this.row=row;
+ }
+
+ @Override
+ public void run() {
+ try {
+ con.createStatement().execute("REPAIR TABLE "+table.tableName+" EXTENDED USE_FRM");
+ table.analyseTable(con);
+ table.countRows(con);
+ } catch(Exception ex) {
+ logger.error("while repairing "+table.tableName,ex);
+ }
+ model.fireTableRowsUpdated(row, row);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright
+ * 2012 axYus - http://www.axyus.com
+ * 2012 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 org.xemelios.mysql.maintenance;
+
+import fr.gouv.finances.dgfip.xemelios.tools.AbstractTool;
+import fr.gouv.finances.dgfip.xemelios.tools.MenuTitle;
+import fr.gouv.finances.dgfip.xemelios.tools.ToolServiceProviderFactory;
+import fr.gouv.finances.dgfip.xemelios.tools.XemeliosToolServiceProvider;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Properties;
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+import org.apache.log4j.Logger;
+
+/**
+ * Le point d'entrée de l'outil compagnon
+ * @author cmarchand
+ */
+@MenuTitle(value = "Maintenance de la base de donnée MySql")
+public class MySqlMaintTool extends AbstractTool {
+ private static final Logger logger = Logger.getLogger(MySqlMaintTool.class);
+ private JFrame parentWindow = null;
+ private XemeliosToolServiceProvider serviceProvider = null;
+
+ @Override
+ public void setParentWindow(JFrame parentWindow) {
+ this.parentWindow = parentWindow;
+ }
+
+ @Override
+ public void run() {
+ ToolServiceProviderFactory toolServiceFactory = ToolServiceProviderFactory.newInstance();
+ serviceProvider = toolServiceFactory.getServiceProvider();
+ // on ne peut pas mettre la constante ici.
+ String mySqlPropertyFile = serviceProvider.getApplicationProperties().getProperty("xemelios.mysql.config.filename");
+ if(mySqlPropertyFile==null || mySqlPropertyFile.length()==0) {
+ JOptionPane.showMessageDialog(parentWindow, "Vous n'utilisez probablement pas une base de données\nMySql. En conséquence, cet outil compagnon est\nincapable de fonctionner.");
+ return;
+ }
+ File f = new File(mySqlPropertyFile);
+ if(!f.exists()) {
+ JOptionPane.showMessageDialog(parentWindow, "Impossible de lire ce fichier :\n"+f.getAbsolutePath()+"\ncet outil ne peut se lancer.");
+ return;
+ }
+ Properties props = new Properties();
+ try {
+ props.load(new FileInputStream(f));
+ DlgMaintMySql dlg = new DlgMaintMySql(this.parentWindow, props);
+ dlg.setLocationRelativeTo(parentWindow);
+ dlg.setVisible(true);
+ } catch(Exception ex) {
+ logger.error("Pendant le chargement de "+f.getAbsolutePath(),ex);
+ return;
+ }
+ }
+
+
+}
--- /dev/null
+Manifest-version: 1.0
+Jar-Version: @version@
+Jar-Content: @name@
+Tool-Class: org.xemelios.mysql.maintenance.MySqlMaintTool
+Tool-Requires: