Search in sources :

Example 1 with KillHpcJobAction

use of edu.cmu.tetradapp.app.hpc.action.KillHpcJobAction in project tetrad by cmu-phil.

the class HpcJobActivityEditor method buildActivityContent.

private void buildActivityContent(final JPanel activityPanel, final TetradDesktop desktop) throws Exception {
    jobsTable = new JTable();
    jobsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    final JScrollPane scrollTablePane = new JScrollPane(jobsTable);
    tabbedPane = new JTabbedPane();
    final JPanel activeJobsPanel = new JPanel(new BorderLayout());
    activeJobsPanel.add(scrollTablePane, BorderLayout.CENTER);
    tabbedPane.add("Active Jobs", activeJobsPanel);
    final KillHpcJobAction killJobAction = new KillHpcJobAction(this);
    final JPanel finishedJobsPanel = new JPanel(new BorderLayout());
    tabbedPane.add("Finished Jobs", finishedJobsPanel);
    final DeleteHpcJobInfoAction deleteJobAction = new DeleteHpcJobInfoAction(this);
    ChangeListener changeListener = new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            JTabbedPane sourceTabbedPane = (JTabbedPane) e.getSource();
            int index = sourceTabbedPane.getSelectedIndex();
            if (index == 0) {
                finishedJobsPanel.remove(scrollTablePane);
                activeJobsPanel.add(scrollTablePane, BorderLayout.CENTER);
                try {
                    final Vector<String> activeColumnNames = genActiveJobColumnNames();
                    final Vector<Vector<String>> activeRowData = getActiveRowData(desktop, checkedHpcAccountList);
                    final DefaultTableModel activeJobTableModel = new HpcJobInfoTableModel(activeRowData, activeColumnNames, KILL_BUTTON_COLUMN);
                    jobsTable.setModel(activeJobTableModel);
                    if (activeRowData.size() > 0) {
                        new ButtonColumn(jobsTable, killJobAction, KILL_BUTTON_COLUMN);
                    }
                    adjustActiveJobsWidthColumns(jobsTable);
                    jobsTable.updateUI();
                } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
            } else if (index == 1) {
                activeJobsPanel.remove(scrollTablePane);
                finishedJobsPanel.add(scrollTablePane, BorderLayout.CENTER);
                try {
                    final Vector<String> finishedColumnNames = genFinishedJobColumnNames();
                    final Vector<Vector<String>> finishedRowData = getFinishedRowData(desktop, checkedHpcAccountList);
                    final DefaultTableModel finishedJobTableModel = new HpcJobInfoTableModel(finishedRowData, finishedColumnNames, DELETE_BUTTON_COLUMN);
                    jobsTable.setModel(finishedJobTableModel);
                    if (finishedRowData.size() > 0) {
                        new ButtonColumn(jobsTable, deleteJobAction, DELETE_BUTTON_COLUMN);
                    }
                    adjustFinishedJobsWidthColumns(jobsTable);
                    jobsTable.updateUI();
                } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
            }
        }
    };
    tabbedPane.addChangeListener(changeListener);
    activityPanel.add(tabbedPane, BorderLayout.CENTER);
    final HpcJobManager hpcJobManager = desktop.getHpcJobManager();
    // Start active job updater
    pendingJobUpdater = new PendingHpcJobUpdaterTask(hpcJobManager, this);
    submittedJobUpdater = new SubmittedHpcJobUpdaterTask(hpcJobManager, this);
    tabbedPane.setSelectedIndex(-1);
    tabbedPane.setSelectedIndex(0);
    startUpdaters();
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) DeleteHpcJobInfoAction(edu.cmu.tetradapp.app.hpc.action.DeleteHpcJobInfoAction) JTabbedPane(javax.swing.JTabbedPane) DefaultTableModel(javax.swing.table.DefaultTableModel) KillHpcJobAction(edu.cmu.tetradapp.app.hpc.action.KillHpcJobAction) FilePrint(edu.pitt.dbmi.ccd.commons.file.FilePrint) PendingHpcJobUpdaterTask(edu.cmu.tetradapp.app.hpc.task.PendingHpcJobUpdaterTask) BorderLayout(java.awt.BorderLayout) ChangeEvent(javax.swing.event.ChangeEvent) HpcJobManager(edu.cmu.tetradapp.app.hpc.manager.HpcJobManager) JTable(javax.swing.JTable) ChangeListener(javax.swing.event.ChangeListener) SubmittedHpcJobUpdaterTask(edu.cmu.tetradapp.app.hpc.task.SubmittedHpcJobUpdaterTask) Vector(java.util.Vector)

Aggregations

DeleteHpcJobInfoAction (edu.cmu.tetradapp.app.hpc.action.DeleteHpcJobInfoAction)1 KillHpcJobAction (edu.cmu.tetradapp.app.hpc.action.KillHpcJobAction)1 HpcJobManager (edu.cmu.tetradapp.app.hpc.manager.HpcJobManager)1 PendingHpcJobUpdaterTask (edu.cmu.tetradapp.app.hpc.task.PendingHpcJobUpdaterTask)1 SubmittedHpcJobUpdaterTask (edu.cmu.tetradapp.app.hpc.task.SubmittedHpcJobUpdaterTask)1 FilePrint (edu.pitt.dbmi.ccd.commons.file.FilePrint)1 BorderLayout (java.awt.BorderLayout)1 Vector (java.util.Vector)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 JTabbedPane (javax.swing.JTabbedPane)1 JTable (javax.swing.JTable)1 ChangeEvent (javax.swing.event.ChangeEvent)1 ChangeListener (javax.swing.event.ChangeListener)1 DefaultTableModel (javax.swing.table.DefaultTableModel)1