/** Load the data of the selected parameter into the table */ private void list_selected() { String key; try { key = getCurrentKey(); } catch (Exception e1) { return; } MeasurementHistoryController hist = master.getHistoryController(); MeasurementHistory data; try { if (getCurrentTimeBase().equals("hours")) data = hist.getDataHours().get(key); else data = hist.getDataDays().get(key); } catch (Exception ex) { return; } Vector<MeasurementHistoryEntry> newData = new Vector<MeasurementHistoryEntry>(data.getValues().size()); newData.addAll(data.getValues()); Collections.sort(newData); Collections.reverse(newData); dataTable.removeAll(); SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); for (MeasurementHistoryEntry e : newData) { TableItem item = new TableItem(dataTable, SWT.NONE); item.setText(new String[] {sdf.format(e.getTimestamp()), "" + e.getValue()}); } }
protected void selectionChanged() { TableItem[] items = fIdMapsTable.getSelection(); if (items.length > 0) { // Refresh Mappings Table fMappingsTable.removeAll(); Vector Mappings = ((IdMap) items[0].getData()).getMappings(); for (Enumeration enumeration = Mappings.elements(); enumeration.hasMoreElements(); ) { newMappingsTableItem((Mapping) enumeration.nextElement(), false); } // Refresh Ordered Table fOrderedTable.removeAll(); ArrayList Ordered = ((IdMap) items[0].getData()).getOrdered(); if (Ordered != null) { for (Iterator iter_ordered = Ordered.iterator(); iter_ordered.hasNext(); ) { newOrderedTableItem((Mapping) iter_ordered.next(), false); } } } updateEnabledState(); }
private void openFile(String fileName, Table table) { String outStr; try { CSVReader reader = new CSVReader(new FileReader(fileName), ',', '"'); String[] strLineArr; // Open the file that is the first // command line parameter FileInputStream fstream = new FileInputStream(fileName); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; table.clearAll(); table.removeAll(); table.redraw(); int length = 0; boolean first = true; // Read File Line By Line while ((strLineArr = reader.readNext()) != null) { // while ((strLine = br.readLine()) != null) { // Print the content on the console // outStr = strLine; TableItem item = null; if (first) { length = strLineArr.length; } else { item = new TableItem(table, SWT.NONE); } int thisLen = strLineArr.length; if (thisLen <= length) { // String[] line = new String[length]; for (int i = 0; i < thisLen; i++) { // line[i] = st.nextToken(); // item.setText (i, st.nextToken()); if (first) { TableColumn column = new TableColumn(table, SWT.NONE); column.setText(strLineArr[i]); } else { // System.out.println("-- "+i+" -- " + strLineArr[i]); item.setText(i, strLineArr[i]); } } } first = false; } // System.out.println("Finisehd file"); for (int i = 0; i < length; i++) { table.getColumn(i).pack(); } // System.out.println("finished packing"); // Close the input stream in.close(); } catch (Exception e) { // Catch exception if any System.err.println("Error: " + e.getMessage()); e.printStackTrace(); } }