Example usage for java.awt Container removeAll

List of usage examples for java.awt Container removeAll

Introduction

In this page you can find the example usage for java.awt Container removeAll.

Prototype

public void removeAll() 

Source Link

Document

Removes all the components from this container.

Usage

From source file:edu.harvard.i2b2.patientMapping.ui.MainComposite.java

public void PerformMiniVisualization(java.awt.Container poAwtContainer, String result, boolean writeFile) {
    try {//from ww  w. ja va2 s  .com
        poAwtContainer.removeAll();

        log.info("Got to PerformMiniVisualization");
        //Record record1 = new Record();
        //poAwtContainer.add(record1);
        // record1.start();
        if (writeFile) {
            //record1.init();
        } else {
            //record1.init(result);
        }
        //theRecord = record1;
        if (returnedNumber >= 0) {
            getDisplay().syncExec(new Runnable() {
                public void run() {

                    MessageBox mBox = new MessageBox(getShell(), SWT.ICON_INFORMATION | SWT.OK);
                    mBox.setText("Please Note ...");
                    mBox.setMessage("Only " + (returnedNumber) + " patients returned");
                    mBox.open();
                }
            });
        }

    } catch (Exception e) {
        log.error("done"); //
    }
}

From source file:edu.harvard.i2b2.explorer.ui.MainComposite.java

public void PerformMiniVisualization(java.awt.Container poAwtContainer, String result, boolean writeFile) {
    try {//from   w w  w  .j  av  a 2  s  .co  m
        poAwtContainer.removeAll();

        log.info("Got to PerformMiniVisualization");
        Record record1 = new Record();
        poAwtContainer.add(record1);
        // record1.start();
        if (writeFile) {
            record1.init();
        } else {
            record1.init(result);
        }
        theRecord = record1;
        if (returnedNumber >= 0) {
            getDisplay().syncExec(new Runnable() {
                public void run() {

                    MessageBox mBox = new MessageBox(getShell(), SWT.ICON_INFORMATION | SWT.OK);
                    mBox.setText("Please Note ...");
                    mBox.setMessage("Only " + (returnedNumber) + " patients returned");
                    mBox.open();
                }
            });
        }

    } catch (Exception e) {
        log.error("done"); //
    }
}

From source file:edu.harvard.i2b2.patientMapping.ui.MainComposite.java

@SuppressWarnings("deprecation")
public void DestroyMiniVisualization(final java.awt.Container poAwtContainer) {
    try {/*from w w w . j av  a 2s  . c  o  m*/
        if (p != null) {
            p.stop();
            p.setVisible(false);
            p = null;
        }
        if (visualizationQueryThread != null) {
            visualizationQueryThread.stop();
            visualizationQueryThread = null;
        }
        if (oConnection != null) {
            oConnection = null;
        }
        log.debug("got to destroy");
        //theRecord.removeAll();
        //theRecord = null;
        poAwtContainer.removeAll();
    } catch (Exception e) {
        // log.error("done");
    }
}

From source file:edu.harvard.i2b2.explorer.ui.MainComposite.java

@SuppressWarnings("deprecation")
public void DestroyMiniVisualization(final java.awt.Container poAwtContainer) {
    try {//w  ww.ja  v a 2  s. c om
        if (p != null) {
            p.stop();
            p.setVisible(false);
            p = null;
        }
        if (visualizationQueryThread != null) {
            visualizationQueryThread.stop();
            visualizationQueryThread = null;
        }
        if (oConnection != null) {
            oConnection = null;
        }
        log.debug("got to destroy");
        theRecord.removeAll();
        theRecord = null;
        poAwtContainer.removeAll();
    } catch (Exception e) {
        // log.error("done");
    }
}

From source file:org.omelogic.tome.EpiTome.java

public void init() {
    backingGraph = null;//from   w  w  w. ja v a2 s. c  om
    tomeGraph = null;
    idFilter = null;

    JPanel tablePanel = new JPanel();
    tomeTable = new JTable();
    JScrollPane tomeTableScroller = new JScrollPane(tomeTable);
    tablePanel.setLayout(new BoxLayout(tablePanel, BoxLayout.PAGE_AXIS));
    tablePanel.add(tomeTableScroller);
    tomeProps = new JLabel("");

    JPanel tomePropsPanel = new JPanel(new BorderLayout());
    tomePropsPanel.add(tomeProps, BorderLayout.LINE_START);
    //tablePanel.add(tomeTableFixed);
    tablePanel.add(tomePropsPanel);
    //JScrollPane tablePanelScroller = new JScrollPane(tablePanel);
    tablePanel.setPreferredSize(new Dimension(300, 400));

    //####### CONTROLS #########################################
    JPanel controlPanel = new JPanel();
    JButton load = new JButton("LOAD");
    load.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent act) {
            JFileChooser chooser = new JFileChooser();
            chooser.setFileFilter(new SIFFileFilter());
            chooser.setMultiSelectionEnabled(false);
            int returnVal = chooser.showOpenDialog(tomeFrame);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                System.out.println("You chose to open this file: " + chooser.getSelectedFile().getName());
            } else {
                return;
            }
            File sifFile = chooser.getSelectedFile();
            UndirectedSparseGraph result = null;
            try {
                result = SIFHandler.load(sifFile);
            } catch (Exception e) {
                System.out.println(e.toString());
            }
            System.out.println("Loaded file!");
            backingGraph = result;
            FilterDialog filterMe = new FilterDialog();
            idFilter = filterMe.getFilter();
            loadInitialGraph((UndirectedSparseGraph) TomeGraphUtilities.filterGraph(backingGraph, idFilter));

        }
    });

    JButton save = new JButton("SAVE");
    save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent act) {
            if (tomeGraph == null) {
                JOptionPane.showMessageDialog(null, "No graph is loaded!", "ERROR!", JOptionPane.ERROR_MESSAGE);
                return;
            }
            JFileChooser chooser = new JFileChooser();
            if (((Double) ((HashMap<String, Double>) (tomeGraph.getUserDatum("GraphStatistics")))
                    .get("AveragePathLength")).isInfinite()) {
                JOptionPane.showMessageDialog(null,
                        "Graph is not fully connected! This renders most output useless. Try trimming the graph first...",
                        "ERROR!", JOptionPane.ERROR_MESSAGE);
                return;
            }

            int returnVal = chooser.showSaveDialog(EpiTome.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();

                FileOutputStream out; // declare a file output object
                PrintStream p; // declare a print stream object

                try {
                    // Create a new file output stream
                    out = new FileOutputStream(file);

                    // Connect print stream to the output stream
                    p = new PrintStream(out);

                    HashMap<String, Double> graphProps = (HashMap<String, Double>) tomeGraph
                            .getUserDatum("GraphStatistics");

                    p.println("#---SUMMARY---");
                    p.println("#NumNodes:\t" + tomeGraph.numVertices());
                    p.println("#NumEdges:\t" + tomeGraph.numEdges());
                    p.println("#ClustCoeff:\t" + graphProps.get(TomeGraphUtilities.CLUSTERING_COEFFICIENT));
                    p.println("#AvgPathLen:\t" + graphProps.get(TomeGraphUtilities.AVERAGE_PATH_LENGTH));
                    p.println("#AvgDegree:\t" + graphProps.get(TomeGraphUtilities.AVERAGE_DEGREE));
                    p.println("#-------------");
                    p.println("\n\n");

                    p.println("NodeID\tClustCoeff\tAvgPathLen\tAvgDegree");
                    Iterator<TomeVertex> vertIter = tomeGraph.getVertices().iterator();
                    while (vertIter.hasNext()) {
                        TomeVertex vert = vertIter.next();
                        p.println(vert.getID() + "\t" + vert.getClusteringCoefficient() + "\t"
                                + vert.getAverageDistance() + "\t" + vert.getDegree());
                    }

                    p.close();
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Error writing to file!\n" + e.toString(), "ERROR!",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    });

    JButton trim = new JButton("TRIM");
    trim.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (tomeGraph == null) {
                JOptionPane.showMessageDialog(null, "No graph is loaded!", "ERROR!", JOptionPane.ERROR_MESSAGE);
                return;
            }
            TrimDialog trimMe = new TrimDialog();
            loadSubGraph(trimMe.getTrimmedGraph(tomeGraph));

        }
    });

    JButton rset = new JButton("RSET");
    rset.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (backingGraph == null) {
                JOptionPane.showMessageDialog(null, "No graph is loaded!", "ERROR!", JOptionPane.ERROR_MESSAGE);
                return;
            }
            loadInitialGraph((UndirectedSparseGraph) TomeGraphUtilities.filterGraph(backingGraph, idFilter));
        }
    });

    JButton view = new JButton("VIEW");
    view.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (tomeGraph == null) {
                JOptionPane.showMessageDialog(null, "No graph is loaded!", "ERROR!", JOptionPane.ERROR_MESSAGE);
                return;
            }
            GraphDialog graf = new GraphDialog(tomeGraph, getSelectedNodeSubGraph());
        }
    });

    JButton ctrl = new JButton("CTRL");
    ctrl.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (tomeGraph == null) {
                JOptionPane.showMessageDialog(null, "No graph is loaded!", "ERROR!", JOptionPane.ERROR_MESSAGE);
                return;
            }
            try {
                ControlsDialog ctrls = new ControlsDialog(tomeGraph, backingGraph, NUM_CONTROLS, NUM_BINS_MAX);
            } catch (Exception excep) {
            }
        }
    });

    JButton help = new JButton("HELP");
    help.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            HelpDialog.display();
        }
    });

    controlPanel.add(load);
    controlPanel.add(save);
    controlPanel.add(trim);
    controlPanel.add(rset);
    controlPanel.add(view);
    controlPanel.add(ctrl);
    controlPanel.add(help);

    //##########################################################

    Container content = tomeFrame.getContentPane();

    content.removeAll();
    content.add(tablePanel, BorderLayout.CENTER);
    content.add(controlPanel, BorderLayout.SOUTH);

}

From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptingDialog.java

/** Builds and lays out the UI. */
private void buildGUI() {
    String text = TEXT;/* w  w w .  j av  a 2s  .  c o m*/
    TitlePanel tp = new TitlePanel(TITLE, text, script.getIconLarge());
    Container c = getContentPane();
    c.removeAll();
    c.setLayout(new BorderLayout(0, 0));
    c.add(tp, BorderLayout.NORTH);
    c.add(buildBody(), BorderLayout.CENTER);
}