Revision 37539

View differences:

branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/SelectPackagesPanel.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.swing.impl.execution.panel;
29

  
30
import java.awt.BorderLayout;
31
import java.awt.Dimension;
32
import java.util.ArrayList;
33
import java.util.List;
34

  
35
import javax.swing.JPanel;
36

  
37
import org.gvsig.installer.lib.api.PackageInfo;
38
import org.gvsig.installer.lib.api.execution.InstallPackageService;
39
import org.gvsig.installer.swing.api.SwingInstallerLocator;
40
import org.gvsig.installer.swing.impl.DefaultSwingInstallerManager;
41
import org.gvsig.installer.swing.impl.execution.DefaultInstallPackageWizard;
42
import org.gvsig.installer.swing.impl.execution.panel.selectPackages.PackagesTablePanel;
43
import org.gvsig.installer.swing.impl.execution.panel.selectPackages.model.PackagesTableModel;
44
import org.gvsig.installer.swing.impl.execution.wizard.SelectPackagesWizard;
45

  
46
/**
47
 * @author gvSIG Team
48
 * @version $Id$
49
 */
50
public class SelectPackagesPanel extends JPanel {
51

  
52
    private SelectPackagesWizard wizard;
53
    private static final long serialVersionUID = -7554097983061858479L;
54
    protected DefaultSwingInstallerManager swingInstallerManager = null;
55
    private PackagesTablePanel packagesTablePanel;
56

  
57
    private PackagesTableModel pluginsTableModel = null;
58

  
59
    public SelectPackagesPanel(SelectPackagesWizard selectPackagesWizard) {
60
        super();
61
        this.wizard = selectPackagesWizard;
62
        swingInstallerManager =
63
            (DefaultSwingInstallerManager) SwingInstallerLocator
64
                .getSwingInstallerManager();
65
        initComponents();
66
    }
67

  
68
    public JPanel getJPanel() {
69
        return this;
70
    }
71

  
72
    public void updateTableModel(PackagesTableModel pluginsTableModel) {
73
        packagesTablePanel.setTableModel(pluginsTableModel);
74
        add(packagesTablePanel, BorderLayout.CENTER);
75
    }
76

  
77
    public void selectPackages() {
78
        packagesTablePanel.selectPackages();
79
    }
80

  
81
    private void initComponents() {
82
        setLayout(new BorderLayout(0, 0));
83
        setPreferredSize(new Dimension(640, 480));
84

  
85
        packagesTablePanel = new PackagesTablePanel(this);
86
        add(packagesTablePanel, BorderLayout.CENTER);
87
    }
88

  
89
    public List<PackageInfo> getPackagesToInstall() {
90

  
91
        List<PackageInfo> packages = packagesTablePanel.getPackagesToInstall();
92

  
93
        List<PackageInfo> packagesToInstall = new ArrayList<PackageInfo>();
94
        packagesToInstall.addAll(packages);
95
        return packagesToInstall;
96
    }
97

  
98
    public boolean isPackageSelected() {
99
        return packagesTablePanel.isPackageSelected();
100
    }
101

  
102
    public void checkIfPluginSelected() {
103
        wizard.checkIfPluginSelected();
104
    }
105

  
106
    public void packageSelectionChanged(Object value, int row, int column) {
107
    }
108

  
109
    public void updatePanel() {
110

  
111
        InstallPackageService installerExecutionService =
112
            wizard.getDefaultInstallPackageWizard()
113
                .getInstallerExecutionService();
114

  
115
        if (pluginsTableModel == null) {
116
            pluginsTableModel =
117
                new PackagesTableModel(swingInstallerManager,
118
                    installerExecutionService, true, wizard.getPluginsFolder());
119
        }
120
        pluginsTableModel.updatePackages();
121

  
122
        updateTableModel(pluginsTableModel);
123
        
124
    }
125

  
126
    public DefaultInstallPackageWizard getDefaultInstallPackageWizard() {
127
        return wizard.getDefaultInstallPackageWizard();
128
    }
129
    
130
    public PackagesTableModel getModel() {
131
        return this.pluginsTableModel;
132
    }
133

  
134
}
0 135

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/selectPackages/TypeFilter.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.installer.swing.impl.execution.panel.selectPackages;
23

  
24
import org.gvsig.installer.lib.api.PackageInfo;
25

  
26

  
27
/**
28
 * @author gvSIG Team
29
 * @version $Id$
30
 *
31
 */
32
public class TypeFilter implements PackageFilter{
33
    
34
    private String type;
35

  
36
    public TypeFilter(String type) {
37
        this.type = type;
38
    }
39

  
40
    public String toString() {
41
        return type;
42
    }
43
    
44
    public boolean match(PackageInfo pkg) {
45
        // TODO Auto-generated method stub
46
        return false;
47
    }
48

  
49
}
0 50

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/selectPackages/renderers/OsAndArchitectureCellRenderer.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.installer.swing.impl.execution.panel.selectPackages.renderers;
23

  
24
import java.awt.Component;
25
import java.net.URL;
26

  
27
import javax.swing.Icon;
28
import javax.swing.ImageIcon;
29
import javax.swing.JLabel;
30
import javax.swing.JTable;
31
import javax.swing.table.DefaultTableCellRenderer;
32

  
33
import org.gvsig.installer.swing.impl.execution.panel.selectPackages.model.PackagesTableModel.PackageOsAndArchitecture;
34

  
35
/**
36
 * @author gvSIG Team
37
 * @version $Id$
38
 * 
39
 */
40
public class OsAndArchitectureCellRenderer extends DefaultTableCellRenderer {
41

  
42

  
43
    private static final long serialVersionUID = 3767874502044161245L;
44

  
45
    public OsAndArchitectureCellRenderer() {
46
    }
47

  
48
    public Component getTableCellRendererComponent(JTable table, Object value,
49
        boolean isSelected, boolean hasFocus, int row, int column) {
50

  
51
        Icon icon;
52
        PackageOsAndArchitecture osArch = (PackageOsAndArchitecture) value;
53
        JLabel check = new JLabel();
54
        URL resource;
55

  
56
        switch (osArch) {
57

  
58
        case LINUX_32:
59
            resource = this.getClass().getResource("/images/linux_x86.png");
60
            icon = new ImageIcon(resource);
61
            check.setIcon(icon);
62

  
63
            return check;
64

  
65
        case LINUX_64:
66
            resource = this.getClass().getResource("/images/linux_AMD64.png");
67
            icon = new ImageIcon(resource);
68
            check.setIcon(icon);
69

  
70
            return check;
71

  
72
        case WINDOLS_32:
73
            resource = this.getClass().getResource("/images/windows_x86.png");
74
            icon = new ImageIcon(resource);
75
            check.setIcon(icon);
76
            return check;
77

  
78
        case WINDOLS_64:
79
            icon = new ImageIcon("/home/nfrancisco/Imatges/windows_AMD64");
80
            check.setIcon(icon);
81
            return check;
82

  
83
        default:
84
            return check;
85
        }
86

  
87
    }
88

  
89
}
0 90

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/selectPackages/renderers/InstallStatusCellEditor.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.installer.swing.impl.execution.panel.selectPackages.renderers;
23

  
24
import java.awt.Component;
25

  
26
import javax.swing.DefaultCellEditor;
27
import javax.swing.JCheckBox;
28
import javax.swing.JTable;
29

  
30
import org.gvsig.installer.swing.impl.execution.panel.SelectPackagesPanel;
31
import org.gvsig.installer.swing.impl.execution.panel.selectPackages.model.PackagesTableModel.PackageStatus;
32

  
33
/**
34
 * @author gvSIG Team
35
 * @version $Id$
36
 * 
37
 */
38
public class InstallStatusCellEditor extends DefaultCellEditor {
39

  
40
    private static final long serialVersionUID = 1271382732175530111L;
41
    PackageStatus status;
42
    SelectPackagesPanel panel;
43

  
44
    public InstallStatusCellEditor(SelectPackagesPanel selectPackagesPanel) {
45
        super(new JCheckBox());
46
        this.panel = selectPackagesPanel;
47
    }
48

  
49
    public Component getTableCellEditorComponent(JTable arg0, Object value,
50
        boolean isSelected, int row, int col) {
51
        JCheckBox check = (JCheckBox) this.getComponent();
52
        status = (PackageStatus) value;
53
        
54
        switch (status) {
55

  
56
        case INSTALLED:
57
            check.setSelected(false);
58
            break;
59

  
60
        case TO_REINSTALL:
61
            check.setSelected(true);
62
            break;
63

  
64
        case NOT_INSTALLED:
65
            check.setSelected(false);
66
            break;
67

  
68
        case TO_INSTALL:
69
            check.setSelected(true);
70
            break;
71

  
72
        case INSTALLED_NOT_INSTALLABLE:
73
            check.setEnabled(false);
74
            break;
75

  
76
        default:
77
            check.setSelected(false);
78
            break;
79
        }
80
        return check;
81
    }
82

  
83
    public Object getCellEditorValue() {
84
        JCheckBox check = (JCheckBox) this.getComponent();
85
        switch (status) {
86
        case INSTALLED:
87
            if (check.isSelected()) {
88
                status = PackageStatus.TO_REINSTALL;
89
            }
90
            break;
91

  
92
        case TO_REINSTALL:
93
            if (!check.isSelected()) {
94
                status = PackageStatus.INSTALLED;
95
            }
96
            break;
97

  
98
        case NOT_INSTALLED:
99
            if (check.isSelected()) {
100
                status = PackageStatus.TO_INSTALL;
101
            }
102
            break;
103

  
104
        case TO_INSTALL:
105
            if (!check.isSelected()) {
106
                status = PackageStatus.NOT_INSTALLED;
107
            }
108
            break;
109

  
110
        default:
111
            break;
112
        }
113
        return status;
114
    }
115
}
0 116

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/selectPackages/renderers/InstallStatusCellRenderer.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.installer.swing.impl.execution.panel.selectPackages.renderers;
23

  
24
import java.awt.Component;
25
import java.net.URL;
26

  
27
import javax.swing.Icon;
28
import javax.swing.ImageIcon;
29
import javax.swing.JLabel;
30
import javax.swing.JTable;
31
import javax.swing.table.DefaultTableCellRenderer;
32

  
33
import org.gvsig.installer.swing.impl.execution.panel.selectPackages.model.PackagesTableModel.PackageStatus;
34

  
35
/**
36
 * @author gvSIG Team
37
 * @version $Id$
38
 * 
39
 */
40
public class InstallStatusCellRenderer extends DefaultTableCellRenderer {
41

  
42
    private static final long serialVersionUID = 1195015856704835320L;
43

  
44
    public InstallStatusCellRenderer() {
45
    }
46

  
47
    public Component getTableCellRendererComponent(JTable table, Object value,
48
        boolean isSelected, boolean hasFocus, int row, int column) {
49

  
50
        Icon icon;
51
        PackageStatus status = (PackageStatus) value;
52
        JLabel check = new JLabel();
53
        URL resource;
54

  
55
        switch (status) {
56

  
57
        case INSTALLED:
58
            resource = this.getClass().getResource("/images/installed.png");
59
            icon = new ImageIcon(resource);
60
            check.setIcon(icon);
61

  
62
            return check;
63

  
64
        case TO_REINSTALL:
65
            resource = this.getClass().getResource("/images/toReinstall.png");
66
            icon = new ImageIcon(resource);
67
            check.setIcon(icon);
68

  
69
            return check;
70

  
71
        case NOT_INSTALLED:
72
            resource = this.getClass().getResource("/images/notInstalled.png");
73
            icon = new ImageIcon(resource);
74
            check.setIcon(icon);
75
            return check;
76

  
77
        case TO_INSTALL:
78
            icon = new ImageIcon("/home/nfrancisco/Imatges/to_install.png");
79
            check.setIcon(icon);
80
            return check;
81

  
82
        case INSTALLED_NOT_INSTALLABLE:
83
            icon =
84
                new ImageIcon(
85
                    "/home/nfrancisco/Imatges/installedNotInstallable.png");
86
            check.setIcon(icon);
87
            return check;
88

  
89
        default:
90
            return check;
91
        }
92

  
93
    }
94

  
95
}
0 96

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/selectPackages/renderers/InstalledPackageCellRenderer.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.installer.swing.impl.execution.panel.selectPackages.renderers;
23

  
24
import java.awt.Color;
25
import java.awt.Component;
26

  
27
import javax.swing.JTable;
28

  
29
import org.gvsig.installer.swing.impl.execution.panel.selectPackages.model.PackagesTableModel.TablePackageInfo;
30

  
31
/**
32
 * @author gvSIG Team
33
 * @version $Id$
34
 */
35
public class InstalledPackageCellRenderer extends
36
    AbstractTablePackageInfoCellRenderer {
37

  
38
    private static final long serialVersionUID = 746811910254748285L;
39

  
40
    public InstalledPackageCellRenderer() {
41
    }
42

  
43
    protected Component getTableCellRendererComponent(TablePackageInfo info,
44
        Component defaultComponent, JTable table, Object value,
45
        boolean isSelected, boolean hasFocus, int row, int column) {
46

  
47
        defaultComponent.setForeground(Color.black);
48

  
49
        return defaultComponent;
50

  
51
    }
52
}
0 53

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/selectPackages/renderers/OfficialRecommendedCellRenderer.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.installer.swing.impl.execution.panel.selectPackages.renderers;
23

  
24
import java.awt.Component;
25
import java.net.URL;
26

  
27
import javax.swing.Icon;
28
import javax.swing.ImageIcon;
29
import javax.swing.JLabel;
30
import javax.swing.JTable;
31
import javax.swing.table.DefaultTableCellRenderer;
32

  
33
import org.gvsig.installer.swing.impl.execution.panel.selectPackages.model.PackagesTableModel.PackageOfficialRecommended;
34

  
35
/**
36
 * @author gvSIG Team
37
 * @version $Id$
38
 * 
39
 */
40
public class OfficialRecommendedCellRenderer extends DefaultTableCellRenderer {
41

  
42
    private static final long serialVersionUID = 1195015856704835320L;
43

  
44
    public OfficialRecommendedCellRenderer() {
45
    }
46

  
47
    public Component getTableCellRendererComponent(JTable table, Object value,
48
        boolean isSelected, boolean hasFocus, int row, int column) {
49

  
50
        Icon icon;
51
        PackageOfficialRecommended status = (PackageOfficialRecommended) value;
52
        JLabel check = new JLabel();
53
        URL resource;
54

  
55
        switch (status) {
56

  
57
        case OFFICIAL_RECOMMENDED:
58
            resource =
59
                this.getClass().getResource("/images/officialRecommended.png");
60
            icon = new ImageIcon(resource);
61
            setToolTipText("_official_recommended");
62
            check.setIcon(icon);
63

  
64
            return check;
65

  
66
        case OFFICIAL_NOT_RECOMMENDED:
67
            resource =
68
                this.getClass().getResource(
69
                    "/images/officialNotRecommended.png");
70
            icon = new ImageIcon(resource);
71
            setToolTipText("_official");
72
            check.setIcon(icon);
73

  
74
            return check;
75

  
76
        case NOT_OFFICIAL_RECOMMENDED:
77
            resource =
78
                this.getClass().getResource(
79
                    "/images/notOfficialRecommended.png");
80
            icon = new ImageIcon(resource);
81
            check.setIcon(icon);
82
            setToolTipText("_not_official_recommended");
83
            return check;
84

  
85
        case NOT_OFFICIAL_NOT_RECOMMENDED:
86
            resource =
87
                this.getClass().getResource(
88
                    "/images/notOfficial.png");
89
            icon = new ImageIcon(resource);
90
            check.setIcon(icon);
91
            setToolTipText("_not_official");
92
            return check;
93

  
94
        default:
95
            // no image as default
96
            return check;
97

  
98
        }
99
    }
100

  
101
}
0 102

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/selectPackages/renderers/AbstractTablePackageInfoCellRenderer.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.installer.swing.impl.execution.panel.selectPackages.renderers;
23

  
24
import java.awt.Component;
25

  
26
import javax.swing.JTable;
27
import javax.swing.table.DefaultTableCellRenderer;
28
import javax.swing.table.TableModel;
29

  
30
import org.gvsig.installer.swing.impl.execution.panel.selectPackages.model.PackagesTableModel;
31
import org.gvsig.installer.swing.impl.execution.panel.selectPackages.model.PackagesTableModel.TablePackageInfo;
32

  
33
/**
34
 * @author gvSIG Team
35
 * @version $Id$
36
 */
37
public abstract class AbstractTablePackageInfoCellRenderer extends
38
    DefaultTableCellRenderer {
39

  
40
    private static final long serialVersionUID = -8534540354786328208L;
41

  
42
    public Component getTableCellRendererComponent(JTable table, Object value,
43
        boolean isSelected, boolean hasFocus, int row, int column) {
44

  
45
        Component defaultComponent =
46
            super.getTableCellRendererComponent(table, value, isSelected,
47
                hasFocus, row, column);
48

  
49
        TableModel tableModel = table.getModel();
50

  
51
        if (tableModel instanceof PackagesTableModel) {
52
            PackagesTableModel packagesTableModel =
53
                (PackagesTableModel) tableModel;
54

  
55
            TablePackageInfo info = packagesTableModel.getPackageInfo(row);
56

  
57
            return getTableCellRendererComponent(info, defaultComponent, table,
58
                value, isSelected, hasFocus, row, column);
59
        }
60
        return defaultComponent;
61
    }
62

  
63
    protected abstract Component getTableCellRendererComponent(
64
        TablePackageInfo info, Component defaultComponent, JTable table,
65
        Object value, boolean isSelected, boolean hasFocus, int row, int column);
66
}
0 67

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/selectPackages/CategoriesFilterPanel.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.installer.swing.impl.execution.panel.selectPackages;
23

  
24
import java.awt.GridBagConstraints;
25
import java.awt.GridBagLayout;
26
import java.awt.Insets;
27
import java.util.ArrayList;
28

  
29
import javax.swing.JButton;
30
import javax.swing.JList;
31
import javax.swing.JPanel;
32
import javax.swing.JScrollPane;
33

  
34
/**
35
 * @author gvSIG Team
36
 * @version $Id$
37
 * 
38
 */
39
public class CategoriesFilterPanel extends JPanel {
40

  
41
    private static final long serialVersionUID = 3767011079359743742L;
42

  
43
    // private PackagesTablePanel packagesTablePanel;
44

  
45
    // private JScrollPane filterScrollPane;
46
    private JList jList;
47
    private ArrayList<String> itemsArrayList = null;
48

  
49
    public CategoriesFilterPanel(PackagesTablePanel packagesTablePanel) {
50
        // this.packagesTablePanel = packagesTablePanel;
51
        initComponents();
52
    }
53

  
54
    private void initComponents() {
55

  
56
        // TODO: init arrayList
57
        itemsArrayList = new ArrayList<String>();
58

  
59
        jList = new JList(itemsArrayList.toArray());
60

  
61
        JScrollPane filterScrollPane = new JScrollPane(jList);
62
        JButton categoriesButton = new JButton("Categories");
63
        JButton typesButton = new JButton("Types");
64
        // filterScrollPane.add(jList);
65

  
66
        typesButton = new JButton("Types");
67

  
68
        this.setLayout(new GridBagLayout());
69

  
70
        java.awt.GridBagConstraints gridBagConstraints;
71

  
72
        gridBagConstraints = new GridBagConstraints();
73
        gridBagConstraints.fill = GridBagConstraints.BOTH;
74
        gridBagConstraints.gridx = 0;
75
        gridBagConstraints.gridy = 0;
76
        gridBagConstraints.weightx = 1;
77
        gridBagConstraints.weighty = 1;
78
        // gridBagConstraints.gridheight = 3;
79
        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
80
        this.add(filterScrollPane, gridBagConstraints);
81

  
82
        gridBagConstraints = new GridBagConstraints();
83
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
84
        gridBagConstraints.gridx = 0;
85
        gridBagConstraints.gridy = 1;
86
        gridBagConstraints.weightx = 1;
87
        gridBagConstraints.weighty = 0;
88
        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
89
        this.add(categoriesButton, gridBagConstraints);
90

  
91
        gridBagConstraints = new GridBagConstraints();
92
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
93
        gridBagConstraints.gridx = 0;
94
        gridBagConstraints.gridy = 2;
95
        gridBagConstraints.weightx = 1;
96
        gridBagConstraints.weighty = 0;
97
        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
98
        this.add(typesButton, gridBagConstraints);
99

  
100
    }
101

  
102
    // private void initComponents() {
103
    //
104
    // JLabel fastFilterLabel = new JLabel("fast_filter");
105
    //
106
    // textField = new JTextField(20);
107
    //
108
    // KeyListener l = new KeyListener() {
109
    //
110
    // public void keyTyped(KeyEvent e) {
111
    // }
112
    //
113
    // public void keyReleased(KeyEvent e) {
114
    // if (e.getKeyChar() == '\n') {
115
    // searchAction();
116
    // }
117
    // }
118
    //
119
    // public void keyPressed(KeyEvent e) {
120
    // }
121
    // };
122
    //
123
    // textField.addKeyListener(l);
124
    //
125
    // searchButton = new JButton("search");
126
    // searchButton.setActionCommand("search");
127
    // searchButton.addActionListener(this);
128
    //
129
    // resetButton = new JButton("reset");
130
    // resetButton.setActionCommand("reset");
131
    // resetButton.addActionListener(this);
132
    //
133
    // setLayout(new FlowLayout(FlowLayout.LEFT));
134
    //
135
    // add(fastFilterLabel);
136
    // add(textField);
137
    // add(searchButton);
138
    // add(resetButton);
139
    //
140
    // }
141
    //
142
    // public void actionPerformed(ActionEvent e) {
143
    // if ("search".equals(e.getActionCommand())) {
144
    // searchAction();
145
    // } else
146
    // if ("reset".equals(e.getActionCommand())) {
147
    // resetAction();
148
    // }
149
    // }
150
    //
151
    // private void searchAction() {
152
    // if (textField.equals("")) {
153
    // panel.setFilter(null);
154
    // } else {
155
    // panel.setFilter(new NameAndDescriptionFilter(textField.getText()));
156
    // }
157
    // }
158
    //
159
    // private void resetAction() {
160
    // panel.setFilter(null);
161
    // textField.setText("");
162
    // }
163

  
164
}
0 165

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/selectPackages/NameAndDescriptionFilter.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.installer.swing.impl.execution.panel.selectPackages;
23

  
24
import org.gvsig.installer.lib.api.PackageInfo;
25

  
26
/**
27
 * @author gvSIG Team
28
 * @version $Id$
29
 * 
30
 */
31
public class NameAndDescriptionFilter implements PackageFilter {
32

  
33
    private String filterString;
34

  
35
    public NameAndDescriptionFilter(String filterString) {
36
        this.filterString = filterString;
37
    }
38

  
39
    public boolean match(PackageInfo pkg) {
40
        Boolean matchesName;
41
        Boolean matchesDescription;
42
        String regularExpressionString = "(?i).*" + filterString + ".*";
43
        String packageString;
44

  
45
        packageString = pkg.getName();
46
        matchesName = packageString.matches(regularExpressionString);
47
        packageString = pkg.getDescription();
48
        matchesDescription = packageString.matches(regularExpressionString);
49

  
50
        return matchesName || matchesDescription;
51
    }
52

  
53
}
0 54

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/selectPackages/model/IPackageSelectionListener.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.swing.impl.execution.panel.selectPackages.model;
29

  
30
/**
31
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
32
 */
33
public interface IPackageSelectionListener {
34

  
35
    public void packageSelectionChanged(Object value, int row, int column);
36
}
0 37

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/selectPackages/model/PackagesTableModel.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.swing.impl.execution.panel.selectPackages.model;
29

  
30
import java.io.File;
31
import java.net.URL;
32
import java.util.ArrayList;
33
import java.util.Arrays;
34
import java.util.Comparator;
35
import java.util.HashMap;
36
import java.util.List;
37
import java.util.Map;
38

  
39
import javax.swing.table.AbstractTableModel;
40

  
41
import org.gvsig.installer.lib.api.InstallerLocator;
42
import org.gvsig.installer.lib.api.InstallerManager;
43
import org.gvsig.installer.lib.api.PackageInfo;
44
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException;
45
import org.gvsig.installer.lib.api.execution.InstallPackageService;
46
import org.gvsig.installer.swing.api.SwingInstallerManager;
47
import org.gvsig.installer.swing.impl.execution.panel.selectPackages.PackageFilter;
48

  
49
public class PackagesTableModel extends AbstractTableModel {
50

  
51
    private static final long serialVersionUID = -454014676003979512L;
52

  
53
    public enum PackageStatus {
54
        INSTALLED, NOT_INSTALLED, TO_REINSTALL, TO_INSTALL, INSTALLED_NOT_INSTALLABLE;
55
    }
56

  
57
    public enum PackageOfficialRecommended {
58
        OFFICIAL_NOT_RECOMMENDED, OFFICIAL_RECOMMENDED, NOT_OFFICIAL_RECOMMENDED, NOT_OFFICIAL_NOT_RECOMMENDED
59
    }
60

  
61
    public enum PackageOsAndArchitecture {
62
        WINDOLS_32, WINDOLS_64, LINUX_32, LINUX_64, ALL, OTHER
63
    }
64

  
65
    private TablePackageInfo[] installerInfos = null;
66

  
67
    private final String[] columnNames;
68

  
69
    private InstallerManager installerManager =
70
        InstallerLocator.getInstallerManager();
71
    InstallPackageService installerExecutionService;
72

  
73
    boolean isOfficial;
74
    File pluginsFolder;
75
    private PackageFilter packageFilter = null;
76

  
77
    public PackagesTableModel(SwingInstallerManager swingInstallerManager,
78
        InstallPackageService installerExecutionService, boolean isOfficial,
79
        File pluginsFolder) {
80

  
81
        this.installerExecutionService = installerExecutionService;
82
        this.isOfficial = isOfficial;
83
        this.pluginsFolder = pluginsFolder;
84
        Map<String, TablePackageInfo> infos = getDefaultPackages();
85

  
86
        installerInfos =
87
            infos.values().toArray(new TablePackageInfo[infos.size()]);
88
        sortInstallerInfos();
89

  
90
        columnNames =
91
            new String[] {
92
                "", // Check column
93
                "", "", swingInstallerManager.getText("name"),
94
                swingInstallerManager.getText("version"),
95
                swingInstallerManager.getText("type") };
96

  
97
    }
98

  
99
    private void sortInstallerInfos() {
100
        Arrays.sort(this.installerInfos, new Comparator<TablePackageInfo>() {
101

  
102
            public int compare(TablePackageInfo o1, TablePackageInfo o2) {
103
                return o1.getPackageInfo().getName().compareToIgnoreCase(
104
                    o2.getPackageInfo().getName());
105
            }
106
        });
107
    }
108

  
109
    private Map<String, TablePackageInfo> getDefaultPackages() {
110

  
111
        List<String> defaultIDs =
112
            installerExecutionService.getDefaultSelectedPackagesIDs();
113

  
114
        Map<String, TablePackageInfo> infos =
115
            new HashMap<String, TablePackageInfo>();
116
        // Add installable package infos
117
        for (int i = 0; i < installerExecutionService.getPackageCount(); i++) {
118
            PackageInfo installerInfo =
119
                installerExecutionService.getPackageInfo(i);
120
            if (installerInfo.isOfficial() == isOfficial) {
121
                TablePackageInfo info =
122
                    new TablePackageInfo(installerInfo, false, true);
123
                if (defaultIDs != null) {
124

  
125
                    for (int j = 0; j < defaultIDs.size(); j++) {
126
                        if (info.getPackageInfo().matchID(defaultIDs.get(j))) {
127
                            if (info.getPackageInfo().getOperatingSystem()
128
                                .equals(installerManager.getOperatingSystem())
129
                                || info.getPackageInfo().getOperatingSystem()
130
                                    .equals("all")) {
131
                                info.setDefault(true);
132
                                break;
133
                            }
134

  
135
                        }
136
                    }
137

  
138
                }
139
                infos.put(info.getID(), info);
140
            }
141
        }
142
        // Add already installed package infos
143
        try {
144
            PackageInfo[] installedPackages =
145
                installerManager.getInstalledPackages(pluginsFolder);
146

  
147
            for (int i = 0; i < installedPackages.length; i++) {
148
                if (installedPackages[i].isOfficial() == isOfficial) {
149
                    TablePackageInfo info =
150
                        new TablePackageInfo(installedPackages[i], true, false);
151
                    TablePackageInfo x = infos.get(info.getID());
152
                    if (x == null) {
153
                        infos.put(info.getID(), info);
154
                    } else {
155
                        x.setInstalled(true);
156
                    }
157
                }
158
            }
159
        } catch (MakePluginPackageServiceException e) {
160
            throw new RuntimeException(e);
161
        }
162

  
163
        return infos;
164
    }
165

  
166
    // get filtered packages
167
    private Map<String, TablePackageInfo> getFilteredPackages(
168
        Map<String, TablePackageInfo> packageInfos) {
169

  
170
        Map<String, TablePackageInfo> infos =
171
            new HashMap<String, TablePackageInfo>();
172

  
173
        TablePackageInfo[] packs =
174
            packageInfos.values().toArray(new TablePackageInfo[infos.size()]);
175

  
176
        for (int i = 0; i < packs.length; i++) {
177
            PackageInfo installerInfo = packs[i].getPackageInfo();
178

  
179
            if (packageFilter.match(installerInfo)) {
180
                TablePackageInfo info = packs[i];
181
                infos.put(installerInfo.getID(), info);
182
            }
183
        }
184
        return infos;
185
    }
186

  
187
    // selects default packages
188
    public void selectDefaultPackages() {
189
        for (int i = 0; i < installerInfos.length; i++) {
190
            if (installerInfos[i].isDefault()) {
191
                installerInfos[i].setSelected(true);
192
            } else {
193
                installerInfos[i].setSelected(false);
194
            }
195
        }
196
    }
197

  
198
    public void selectPackage(PackageInfo pkg) {
199
        for (int i = 0; i < installerInfos.length; i++) {
200
            if (pkg.equals(installerInfos[i].getPackageInfo())) {
201
                installerInfos[i].setSelected(true);
202
                return;
203
            }
204
        }
205
    }
206

  
207
    public void updatePackages() {
208

  
209
        Map<String, TablePackageInfo> infos = getDefaultPackages();
210

  
211
        if (isFilterSet()) {
212
            infos = getFilteredPackages(infos);
213
        }
214

  
215
        for (int i = 0; i < installerInfos.length; i++) {
216
            TablePackageInfo installerInfo =
217
                infos.get(installerInfos[i].getID());
218
            if (installerInfo != null) {
219
                installerInfo.setSelected(installerInfos[i].isSelected());
220
            }
221
        }
222

  
223
        installerInfos =
224
            infos.values().toArray(new TablePackageInfo[infos.size()]);
225
        sortInstallerInfos();
226

  
227
        List<String> idList =
228
            installerExecutionService.getDefaultSelectedPackagesIDs();
229

  
230
        if (idList != null) {
231
            for (int i = 0; i < installerInfos.length; i++) {
232
                for (int j = 0; j < idList.size(); j++) {
233
                    if (installerInfos[i].getPackageInfo().matchID(
234
                        idList.get(j))) {
235
                        if (installerInfos[i].getPackageInfo()
236
                            .getOperatingSystem().equals(
237
                                installerManager.getOperatingSystem())
238
                            || installerInfos[i].getPackageInfo()
239
                                .getOperatingSystem().equals("all")) {
240
                            installerInfos[i].setDefault(true);
241
                        }
242
                    }
243
                }
244
            }
245
        }
246
    }
247

  
248
    public Class<?> getColumnClass(int columnIndex) {
249
        switch (columnIndex) {
250
        case 0:
251
            return PackageStatus.class;
252
        case 1:
253
            return PackageOfficialRecommended.class;
254
        case 2:
255
            return PackageOsAndArchitecture.class;
256
        default:
257
            return String.class;
258
        }
259
    }
260

  
261
    public int getColumnCount() {
262
        return columnNames.length;
263
    }
264

  
265
    public String getColumnName(int columnIndex) {
266
        return columnIndex >= columnNames.length ? ""
267
            : columnNames[columnIndex];
268
    }
269

  
270
    public int getRowCount() {
271
        return installerInfos.length;
272
    }
273

  
274
    public Object getValueAt(int rowIndex, int columnIndex) {
275
        TablePackageInfo tableInfo = installerInfos[rowIndex];
276
        PackageInfo installerInfo = tableInfo.getPackageInfo();
277

  
278
        switch (columnIndex) {
279
        case 0:
280
            PackageStatus installStatus = checkStatus(rowIndex);
281
            return installStatus;
282
        case 1:
283
            PackageOfficialRecommended officialRecommended =
284
                checkOfficialRecommended(rowIndex);
285
            return officialRecommended;
286
        case 2:
287
            PackageOsAndArchitecture packageSystem =
288
                checkPackageSystem(rowIndex);
289
            return packageSystem;
290
        case 3:
291
            return installerInfo.getName();
292
        case 4:
293
            return installerInfo.getVersion();
294
        case 5:
295
            return installerInfo.getType();
296
            // case 5:
297
            // if (installerInfo.getOperatingSystem().equals(
298
            // installerInfo.getArchitecture())) {
299
            // return "all";
300
            // } else {
301
            // return installerInfo.getOperatingSystem() + " "
302
            // + installerInfo.getArchitecture();
303
            // }
304
        default:
305
            return "";
306

  
307
        }
308
    }
309

  
310
    /**
311
     * @param rowIndex
312
     * @return
313
     */
314
    private PackageOsAndArchitecture checkPackageSystem(int rowIndex) {
315
        TablePackageInfo tableInfo = installerInfos[rowIndex];
316
        PackageInfo installerInfo = tableInfo.getPackageInfo();
317
        PackageOsAndArchitecture oSArch;
318

  
319
        if (installerInfo.getOperatingSystem().equals(
320
            installerInfo.getArchitecture())) {
321
            oSArch = PackageOsAndArchitecture.ALL;
322
        } else
323
            if ((installerInfo.getOperatingSystem().equals("lin"))) {
324
                if (installerInfo.getArchitecture().equals("x86")) {
325
                    oSArch = PackageOsAndArchitecture.LINUX_32;
326
                } else {
327
                    oSArch = PackageOsAndArchitecture.LINUX_64;
328
                }
329
            } else
330
                if ((installerInfo.getOperatingSystem().equals("win"))) {
331
                    if (installerInfo.getArchitecture().equals("x86")) {
332
                        oSArch = PackageOsAndArchitecture.WINDOLS_32;
333
                    } else {
334
                        oSArch = PackageOsAndArchitecture.WINDOLS_64;
335
                    }
336
                } else {
337
                    oSArch = PackageOsAndArchitecture.OTHER;
338
                }
339
        return oSArch;
340
    }
341

  
342
    /**
343
     * @return
344
     */
345
    private PackageStatus checkStatus(int rowIndex) {
346
        TablePackageInfo tableInfo = installerInfos[rowIndex];
347

  
348
        if (tableInfo.isInstalled()) {
349
            if (tableInfo.isInstallable()) {
350
                if (tableInfo.isSelected()) {
351
                    return PackageStatus.TO_REINSTALL;
352
                } else {
353
                    return PackageStatus.INSTALLED;
354
                }
355
            } else {
356
                return PackageStatus.INSTALLED_NOT_INSTALLABLE;
357
            }
358

  
359
        } else {
360
            if (tableInfo.isSelected()) {
361
                return PackageStatus.TO_INSTALL;
362
            } else {
363
                return PackageStatus.NOT_INSTALLED;
364
            }
365
        }
366
    }
367

  
368
    private PackageOfficialRecommended checkOfficialRecommended(int rowIndex) {
369
        TablePackageInfo tableInfo = installerInfos[rowIndex];
370
        PackageInfo packageInfo = tableInfo.getPackageInfo();
371

  
372
        if (packageInfo.isOfficial()) {
373
            if (installerInfos[rowIndex].isDefault()) {
374
                return PackageOfficialRecommended.OFFICIAL_RECOMMENDED;
375
            } else {
376
                return PackageOfficialRecommended.OFFICIAL_NOT_RECOMMENDED;
377
            }
378
        } else {
379
            if (installerInfos[rowIndex].isDefault()) {
380
                return PackageOfficialRecommended.NOT_OFFICIAL_RECOMMENDED;
381
            } else {
382
                return PackageOfficialRecommended.NOT_OFFICIAL_NOT_RECOMMENDED;
383
            }
384
        }
385
    }
386

  
387
    public PackageInfo getPackageInfoAt(int rowIndex) {
388
        return installerInfos[rowIndex].getPackageInfo();
389
    }
390

  
391
    public String getDescriptionAt(int rowIndex) {
392
        return getPackageInfoAt(rowIndex).getDescription();
393
    }
394

  
395
    public URL getSourcesAt(int rowIndex) {
396
        return getPackageInfoAt(rowIndex).getSourcesURL();
397
    }
398

  
399
    public String getOwnerAt(int rowIndex) {
400
        return getPackageInfoAt(rowIndex).getOwner();
401
    }
402

  
403
    public boolean isCellEditable(int rowIndex, int columnIndex) {
404
        return (columnIndex == 0) && installerInfos[rowIndex].isInstallable();
405
    }
406

  
407
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
408

  
409
        if (columnIndex == 0) {
410
            PackageStatus status = (PackageStatus) aValue;
411
            TablePackageInfo tableInfo = installerInfos[rowIndex];
412
            switch (status) {
413
            case INSTALLED:
414
            case NOT_INSTALLED:
415
                tableInfo.setSelected(false);
416
                break;
417

  
418
            case TO_REINSTALL:
419
            case TO_INSTALL:
420
                tableInfo.setSelected(true);
421
                break;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff