123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 |
- /*
- * Copyright (C) 2015 iZc
- *
- * This program 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 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package de.nplusc.izc.InstallPak.legacy;
- import de.nplusc.izc.InstallPak.Definitions;
- import de.nplusc.izc.InstallPak.Main;
- import de.nplusc.izc.tools.baseTools.HidableTableColumnModel;
- import de.nplusc.izc.tools.baseTools.Tools;
- import java.awt.Point;
- import javax.swing.table.DefaultTableModel;
- /**
- *
- * @author LH
- */
- public class PackagerGUI extends javax.swing.JFrame
- {
- /**
- * Creates new form PackagerGUI
- */
- private PackManager p;
- public PackagerGUI()
- {
- initComponents();
- updatePosition();
- lblVID.setText(Definitions.VERSION_GUI_TXT);
- packStatus.setVisible(false);
- p = new PackManager();
- p.loadPackageData(Main.filePath);
- ((HidableTableColumnModel)(tblSelector.getColumnModel())).setColumnVisible(0, false);
- //^auskommentieren um id-spalte sichtbar zu bekommenTempcode fürs Testen
- int rows=1;
- String[] tablefill = p.getPackList();
- for (int i = 0; i < tablefill.length; i++)
- {
- String GRP = tablefill[i];
- String[] data = GRP.split("\\|");
- if(i>=rows)
- ((DefaultTableModel)tblSelector.getModel()).addRow(new String[3]);
- ((DefaultTableModel)tblSelector.getModel()).setValueAt(data[0], i, 0);
- ((DefaultTableModel)tblSelector.getModel()).setValueAt(data[1], i, 1);
- ((DefaultTableModel)tblSelector.getModel()).setValueAt("Wird installiert", i, 2);
- if(p.packIsInstalled(data[0]))
- {
- ((DefaultTableModel)tblSelector.getModel()).setValueAt("Bereits installiert", i, 2);
- }
- }
- }
- private void updatePosition()
- {
- Point p = new Point(Main.topleft_coords_x, Main.topleft_coords_y);
- setLocation(p);
- }
- /**
- * 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()
- {
- jScrollPane1 = new javax.swing.JScrollPane();
- tblSelector = new javax.swing.JTable();
- jScrollPane2 = new javax.swing.JScrollPane();
- packDesc = new javax.swing.JTextArea();
- packTitle = new javax.swing.JLabel();
- btnInstall = new javax.swing.JButton();
- packStatus = new javax.swing.JLabel();
- jLabel1 = new javax.swing.JLabel();
- lblVID = new javax.swing.JLabel();
- jSeparator1 = new javax.swing.JSeparator();
- jSeparator3 = new javax.swing.JSeparator();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- addComponentListener(new java.awt.event.ComponentAdapter()
- {
- public void componentMoved(java.awt.event.ComponentEvent evt)
- {
- formComponentMoved(evt);
- }
- });
- tblSelector.setModel(new javax.swing.table.DefaultTableModel(
- new Object [][]
- {
- {null, null, null}
- },
- new String []
- {
- "meta:id", "Name", "Status"
- }
- )
- {
- boolean[] canEdit = new boolean []
- {
- false, false, false
- };
- public boolean isCellEditable(int rowIndex, int columnIndex)
- {
- return canEdit [columnIndex];
- }
- });
- tblSelector.addMouseListener(new java.awt.event.MouseAdapter()
- {
- public void mouseClicked(java.awt.event.MouseEvent evt)
- {
- tblSelectorMouseClicked(evt);
- }
- });
- jScrollPane1.setViewportView(tblSelector);
- tblSelector.setColumnModel(new HidableTableColumnModel(tblSelector.getColumnModel()));
- if (tblSelector.getColumnModel().getColumnCount() > 0)
- {
- tblSelector.getColumnModel().getColumn(0).setResizable(false);
- tblSelector.getColumnModel().getColumn(0).setPreferredWidth(30);
- tblSelector.getColumnModel().getColumn(1).setMinWidth(80);
- tblSelector.getColumnModel().getColumn(1).setPreferredWidth(80);
- tblSelector.getColumnModel().getColumn(1).setMaxWidth(80);
- tblSelector.getColumnModel().getColumn(2).setPreferredWidth(80);
- }
- packDesc.setColumns(20);
- packDesc.setRows(5);
- packDesc.addComponentListener(new java.awt.event.ComponentAdapter()
- {
- public void componentMoved(java.awt.event.ComponentEvent evt)
- {
- packDescComponentMoved(evt);
- }
- });
- jScrollPane2.setViewportView(packDesc);
- packTitle.setText("{PackTitle}");
- btnInstall.setText("Installation starten");
- btnInstall.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(java.awt.event.ActionEvent evt)
- {
- btnInstallActionPerformed(evt);
- }
- });
- packStatus.setText("{DepDetails}");
- jLabel1.setText("Doppelklicken um Status zu ändern");
- lblVID.setText("izSetup 1.0.0 (c) 2012 iZc");
- 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)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(34, 34, 34)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(packStatus)
- .addComponent(packTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 429, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, 12, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(btnInstall, javax.swing.GroupLayout.PREFERRED_SIZE, 597, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 584, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(8, 8, 8))))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(lblVID)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 642, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(10, 10, 10)))
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(17, 17, 17)
- .addComponent(packStatus))
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabel1)))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addGroup(layout.createSequentialGroup()
- .addComponent(packTitle)
- .addGap(18, 18, 18)
- .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(btnInstall, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(lblVID, javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jSeparator3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap())
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- private void tblSelectorMouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_tblSelectorMouseClicked
- {//GEN-HEADEREND:event_tblSelectorMouseClicked
- int x = tblSelector.getSelectedRow();
- String packid=(String)((DefaultTableModel)tblSelector.getModel()).getValueAt(x, 0);
- boolean sel = p.packIsScheduled(packid);
- if(evt.getClickCount()==2)
- {
- if(sel==false&&p.packIsInstallable(packid))
- {
- sel=true;
- }
- else
- {
- sel=false;
- }
- p.setPackInstallState(packid, sel);
- }
- rebuildTable();
- String _packTitle = p.getPackName(packid);
- String packDescr = p.getPackDescription(packid);
- packTitle.setText(_packTitle);
- packDesc.setText(packDescr);
- }//GEN-LAST:event_tblSelectorMouseClicked
- private String[] handoverqueue;
- private void btnInstallActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnInstallActionPerformed
- {//GEN-HEADEREND:event_btnInstallActionPerformed
- p.createQueue();
- handoverqueue = p.getQueue();
- new Thread(new Runnable()
- {
- @Override
- @SuppressWarnings("SleepWhileInLoop")
- public void run()
- {
- new InstallProgressGui(handoverqueue).setVisible(true);
- }
- }).start();
- this.setVisible(false);
- }//GEN-LAST:event_btnInstallActionPerformed
- private void packDescComponentMoved(java.awt.event.ComponentEvent evt)//GEN-FIRST:event_packDescComponentMoved
- {//GEN-HEADEREND:event_packDescComponentMoved
- //NOP
- }//GEN-LAST:event_packDescComponentMoved
- private void formComponentMoved(java.awt.event.ComponentEvent evt)//GEN-FIRST:event_formComponentMoved
- {//GEN-HEADEREND:event_formComponentMoved
- Main.topleft_coords_x = getLocation().x;
- Main.topleft_coords_y = getLocation().x;
- }//GEN-LAST:event_formComponentMoved
- private void rebuildTable()
- {
- String[] tablefill = p.getPackList();
- for (int i = 0; i < tablefill.length; i++)
- {
- String GRP = tablefill[i];
- String[] data = GRP.split("\\|");
- String packid = data[0];
- ((DefaultTableModel)tblSelector.getModel()).setValueAt(data[0], i, 0);
- ((DefaultTableModel)tblSelector.getModel()).setValueAt(data[1], i, 1);
- ((DefaultTableModel)tblSelector.getModel()).setValueAt("0xFA11", i, 2);
- if(p.packIsScheduled(packid))
- {
- Tools.DebugHelperPrint(packid+"|sched", true, "iZsetup.enableFinerDebug");
- ((DefaultTableModel)tblSelector.getModel()).setValueAt("Wird installiert", i, 2);
- }
- else
- {
- if(p.packIsInstalled(data[0]))
- {
- Tools.DebugHelperPrint(packid+"|exis", true, "iZsetup.enableFinerDebug");
- ((DefaultTableModel)tblSelector.getModel()).setValueAt("Bereits installiert", i, 2);
- }
- else
- {
- if(!p.packIsInstallable(packid))
- {
- String depName = "";
- String depID = p.packDependency(data[0]);
- try
- {
- depName = p.getPackName(depID);
- }
- catch(Exception e)
- {
- }
- Tools.DebugHelperPrint(packid+"|reqdep:"+depID, true, "iZsetup.enableFinerDebug");
- ((DefaultTableModel)tblSelector.getModel()).setValueAt(depName+" benötigt", i, 2);
- }
- else
- {
- ((DefaultTableModel)tblSelector.getModel()).setValueAt("Abgewählt", i, 2);
- }
- }
- }
- }
- }
-
-
- /**
- * @param args the command line arguments
- */
- public static void main(String args[])
- {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try
- {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels())
- {
- if ("Nimbus".equals(info.getName()))
- {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- }
- catch (ClassNotFoundException ex)
- {
- java.util.logging.Logger.getLogger(PackagerGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- catch (InstantiationException ex)
- {
- java.util.logging.Logger.getLogger(PackagerGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- catch (IllegalAccessException ex)
- {
- java.util.logging.Logger.getLogger(PackagerGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- catch (javax.swing.UnsupportedLookAndFeelException ex)
- {
- java.util.logging.Logger.getLogger(PackagerGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable()
- {
- public void run()
- {
- new PackagerGUI().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton btnInstall;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JScrollPane jScrollPane2;
- private javax.swing.JSeparator jSeparator1;
- private javax.swing.JSeparator jSeparator3;
- private javax.swing.JLabel lblVID;
- private javax.swing.JTextArea packDesc;
- private javax.swing.JLabel packStatus;
- private javax.swing.JLabel packTitle;
- private javax.swing.JTable tblSelector;
- // End of variables declaration//GEN-END:variables
- }
|