コード例 #1
0
ファイル: HarvesterGUI.java プロジェクト: migoe/delving
 private void fetchLocalLog() {
   // todo: when the log is very very large, this fails with OutOfMemoryError
   final File logFile = new File(outputDirectory, selectedTask.getOutput() + ".log");
   logTab.setTitleAt(1, "Local log: " + logFile.getName());
   if (logFile.exists()) {
     Thread thread =
         new Thread(
             new Runnable() {
               public void run() {
                 final StringBuilder logText = new StringBuilder();
                 try {
                   BufferedReader in = new BufferedReader(new FileReader(logFile));
                   String line;
                   while ((line = in.readLine()) != null) {
                     logText.append(line);
                     logText.append("\n");
                   }
                 } catch (IOException e) {
                   logText.append("Cannot load: ").append(logFile.getAbsolutePath());
                   logText.append(e.toString());
                 }
                 SwingUtilities.invokeLater(
                     new Runnable() {
                       public void run() {
                         localLog.setText(logText.toString());
                       }
                     });
               }
             });
     thread.start();
   } else {
     localLog.setText("No log found: " + logFile.getAbsolutePath());
   }
 }
コード例 #2
0
ファイル: HarvesterGUI.java プロジェクト: migoe/delving
 public void actionPerformed(ActionEvent event) {
   int answer =
       JOptionPane.showConfirmDialog(
           HarvesterGUI.this,
           "Are you sure you want to start all?",
           "Start All",
           JOptionPane.YES_NO_OPTION);
   System.out.println("answer " + answer);
   if (answer == JOptionPane.YES_OPTION) {
     for (HarvestTask task : tableModel.getTasks()) {
       if (HarvestTask.isStartable(task.getStatus())) {
         control.add(task);
       }
     }
     setEnablement();
   }
 }
コード例 #3
0
ファイル: HarvesterGUI.java プロジェクト: migoe/delving
 private Component createTable(List<HarvestConfig.Harvest> harvests) {
   tableModel = new HarvestTableModel(harvests);
   final JTable table =
       new JTable(tableModel, HarvestTask.getTableColumnModel(tableModel.getCellRenderer()));
   table
       .getModel()
       .addTableModelListener(
           new TableModelListener() {
             public void tableChanged(TableModelEvent event) {
               int row = table.getSelectedRow();
               selectedTask = ((HarvestTableModel) table.getModel()).getRow(row);
               setEnablement();
             }
           });
   table
       .getTableHeader()
       .addMouseListener(
           new MouseAdapter() {
             public void mouseClicked(MouseEvent mouseEvent) {
               TableColumnModel columnModel = table.getColumnModel();
               int viewColumn = columnModel.getColumnIndexAtX(mouseEvent.getX());
               int column = table.convertColumnIndexToModel(viewColumn);
               if (mouseEvent.getClickCount() == 1 && column != -1) {
                 ((HarvestTableModel) table.getModel()).sortOn(column);
               }
             }
           });
   table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   table
       .getSelectionModel()
       .addListSelectionListener(
           new ListSelectionListener() {
             public void valueChanged(ListSelectionEvent event) {
               int row = table.getSelectedRow();
               selectedTask = ((HarvestTableModel) table.getModel()).getRow(row);
               if (selectedTask != null) {
                 fetchLocalLog();
               }
               setEnablement();
             }
           });
   JScrollPane pane =
       new JScrollPane(
           table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
   pane.setPreferredSize(new Dimension(800, 300));
   return pane;
 }
コード例 #4
0
ファイル: HarvesterGUI.java プロジェクト: migoe/delving
 private void setEnablement() {
   startSelectedAction.setEnabled(
       selectedTask != null && HarvestTask.isStartable(selectedTask.getStatus()));
   abortAction.setEnabled(
       selectedTask != null && !HarvestTask.isStartable(selectedTask.getStatus()));
 }