3 import java
.awt
.event
.*;
9 import com
.easysw
.cups
.*;
11 public class GLPjobList
implements ActionListener
14 GridLayout mainLayout
= null;
15 JPanel errorPanel
= null;
16 JScrollPane jobPane
= null;
18 public GLPjobList(CupsPrinter cp
)
24 public void load(CupsPrinter cp
)
32 u
= new URL("http://" + GLPvars
.cupsServerName
+ ":631/printers/" +
35 cups
.setUser(GLPvars
.cupsUser
);
36 cups
.setPasswd(GLPvars
.cupsPasswd
);
38 jobs
= cups
.cupsGetJobs(GLPvars
.showMyJobs
,
39 GLPvars
.showCompletedJobs
);
43 GLPjobTableModel tm
= new GLPjobTableModel(1,1);
44 tm
.setValueAt("Error getting job list(IOException)",0,0);
45 JTable table
= new JTable(tm
);
46 jobPane
= new JScrollPane(table
);
47 jobPane
.setBackground(GLPcolors
.backgroundColor
);
55 if (GLPvars
.showCompletedJobs
)
56 job_type
= "No completed jobs";
58 job_type
= "No active jobs";
59 if (GLPvars
.showMyJobs
)
60 job_user
= " for " + GLPvars
.cupsUser
;
62 GLPjobTableModel tm
= new GLPjobTableModel(1,1);
63 tm
.setValueAt(job_type
+ job_user
+ ".",0,0);
64 JTable table
= new JTable(tm
);
65 jobPane
= new JScrollPane(table
);
66 jobPane
.setBackground(GLPcolors
.backgroundColor
);
70 num_jobs
= jobs
.length
;
72 for (int i
=0; i
< num_jobs
; i
++)
74 if (jobs
[i
].job_id
< 0)
81 GLPjobTableModel tm
= new GLPjobTableModel(1,1);
82 String comp_str
= "active";
83 if (GLPvars
.showCompletedJobs
)
84 comp_str
= "completed";
86 tm
.setValueAt("No " + comp_str
+ " jobs on " +
87 cp
.getPrinterName(),0,0);
88 JTable table
= new JTable(tm
);
89 jobPane
= new JScrollPane(table
);
90 jobPane
.setBackground(GLPcolors
.backgroundColor
);
94 GLPjobTableModel tm
= new GLPjobTableModel(jobcount
,6);
95 tm
.setColumnName(0,"ID");
96 tm
.setColumnName(1,"Name");
97 tm
.setColumnName(2,"User");
98 tm
.setColumnName(3,"Create Time");
99 tm
.setColumnName(4,"Size");
100 tm
.setColumnName(5,"Status");
103 Date date
= new Date();
105 for (int i
=0; i
< num_jobs
; i
++)
108 // Bug in cupsGetJobs?
110 if (jobs
[i
].job_id
< 0)
113 tm
.setValueAt( new Integer( jobs
[i
].job_id
), currjob
, 0 );
114 tm
.setValueAt( (Object
)jobs
[i
].job_name
, currjob
, 1 );
115 tm
.setValueAt( (Object
)jobs
[i
].job_originating_user_name
,currjob
,2);
117 date
.setTime(jobs
[i
].time_at_creation
* 1000);
118 tm
.setValueAt( date
.toString(), currjob
, 3 );
120 if (jobs
[i
].job_k_octets
< 1000)
121 szString
= Integer
.toString(jobs
[i
].job_k_octets
) + "k";
123 szString
= Double
.toString((float)jobs
[i
].job_k_octets
/ 1000.0) + "mb";
124 tm
.setValueAt( szString
, currjob
, 4 );
125 tm
.setValueAt( jobs
[i
].jobStatusText(), currjob
, 5 );
129 JTable table
= new JTable( tm
);
131 jobPane
= new JScrollPane(table
);
132 jobPane
.setBackground(GLPcolors
.backgroundColor
);
133 jobPane
.setVerticalScrollBarPolicy(JScrollPane
.VERTICAL_SCROLLBAR_ALWAYS
);
134 jobPane
.setHorizontalScrollBarPolicy(JScrollPane
.HORIZONTAL_SCROLLBAR_AS_NEEDED
);
137 public void actionPerformed(ActionEvent e
)
139 // if (e.getActionCommand().equals(maskFieldString))
145 public JScrollPane
getPanel()