in uimaj-tools/src/main/java/org/apache/uima/tools/docanalyzer/AnnotationViewerDialog.java [240:407]
public AnnotationViewerDialog(JFrame aParentFrame, String aDialogTitle, PrefsMediator med,
File aStyleMapFile, String aPerformanceStats, TypeSystem aTypeSystem,
final String[] aTypesToDisplay, boolean generatedStyleMap, CAS cas) {
super(aParentFrame, aDialogTitle);
this.med1 = med;
this.cas = cas;
styleMapFile = aStyleMapFile;
final String performanceStats = aPerformanceStats;
typeSystem = aTypeSystem;
typesToDisplay = aTypesToDisplay;
// create the AnnotationViewGenerator (for HTML view generation)
annotationViewGenerator = new AnnotationViewGenerator(tempDir);
// create StyleMapEditor dialog
styleMapEditor = new StyleMapEditor(aParentFrame, cas);
JPanel resultsTitlePanel = new JPanel();
resultsTitlePanel.setLayout(new BoxLayout(resultsTitlePanel, BoxLayout.Y_AXIS));
resultsTitlePanel.add(new JLabel("These are the Analyzed Documents."));
resultsTitlePanel.add(new JLabel("Select viewer type and double-click file to open."));
// create an jlist to list the the analyzed documents
inputDirPath = med.getOutputDir();
analyzedResultsList = new JList<>();
resetFiles("");
/*
* File[] documents = dir.listFiles(); Vector docVector = new Vector(); for (int i = 0; i <
* documents.length; i++) { if (documents[i].isFile()) { docVector.add(documents[i].getName());
* } } final JList analyzedResultsList = new JList(docVector);
*/
JScrollPane scrollPane = new JScrollPane();
scrollPane.getViewport().add(analyzedResultsList, null);
JPanel southernPanel = new JPanel();
southernPanel.setLayout(new BoxLayout(southernPanel, BoxLayout.Y_AXIS));
JPanel filterPanel = new JPanel();
filterPanel.setLayout(new BoxLayout(filterPanel, BoxLayout.X_AXIS));
filterPanel.add(new JLabel("Filter: Filename contains "));
final JTextField filenameFilter = new JTextField();
filenameFilter.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
resetFiles(filenameFilter.getText());
}
@Override
public void removeUpdate(DocumentEvent e) {
resetFiles(filenameFilter.getText());
}
@Override
public void changedUpdate(DocumentEvent e) {
resetFiles(filenameFilter.getText());
}
});
filterPanel.add(filenameFilter);
filterPanel.setBorder(new EmptyBorder(4, 4, 4, 4));
southernPanel.add(filterPanel);
JPanel controlsPanel = new JPanel();
controlsPanel.setLayout(new SpringLayout());
Caption displayFormatLabel = new Caption("Results Display Format:");
controlsPanel.add(displayFormatLabel);
JPanel displayFormatPanel = new JPanel();
displayFormatPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
displayFormatPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
javaViewerRB = new JRadioButton("Java Viewer");
javaViewerUCRB = new JRadioButton("JV user colors");
htmlRB = new JRadioButton("HTML");
xmlRB = new JRadioButton("XML");
ButtonGroup displayFormatButtonGroup = new ButtonGroup();
displayFormatButtonGroup.add(javaViewerRB);
displayFormatButtonGroup.add(javaViewerUCRB);
displayFormatButtonGroup.add(htmlRB);
displayFormatButtonGroup.add(xmlRB);
// select the appropraite viewer button according to user's prefs
javaViewerRB.setSelected(true); // default, overriden below
if ("Java Viewer".equals(med.getViewType())) {
javaViewerRB.setSelected(true);
} else if ("JV User Colors".equals(med.getViewType())) {
javaViewerUCRB.setSelected(true);
} else if ("HTML".equals(med.getViewType())) {
htmlRB.setSelected(true);
} else if ("XML".equals(med.getViewType())) {
xmlRB.setSelected(true);
}
displayFormatPanel.add(javaViewerRB);
displayFormatPanel.add(javaViewerUCRB);
displayFormatPanel.add(htmlRB);
displayFormatPanel.add(xmlRB);
controlsPanel.add(displayFormatPanel);
SpringUtilities.makeCompactGrid(controlsPanel, 1, 2, // rows, cols
4, 4, // initX, initY
0, 0); // xPad, yPad
JButton editStyleMapButton = new JButton("Edit Style Map");
// event for the editStyleMapButton button
editStyleMapButton.addActionListener(this);
southernPanel.add(controlsPanel);
// southernPanel.add( new JSeparator() );
JPanel buttonsPanel = new JPanel();
buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
// APL: edit style map feature disabled for SDK
buttonsPanel.add(editStyleMapButton);
if (performanceStats != null) {
JButton perfStatsButton = new JButton("Performance Stats");
perfStatsButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
JOptionPane.showMessageDialog((Component) ae.getSource(), performanceStats, null,
JOptionPane.PLAIN_MESSAGE);
}
});
buttonsPanel.add(perfStatsButton);
}
JButton closeButton = new JButton("Close");
buttonsPanel.add(closeButton);
southernPanel.add(buttonsPanel);
// add jlist and panel container to Dialog
getContentPane().add(resultsTitlePanel, BorderLayout.NORTH);
getContentPane().add(scrollPane, BorderLayout.CENTER);
getContentPane().add(southernPanel, BorderLayout.SOUTH);
// event for the closeButton button
closeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
AnnotationViewerDialog.this.setVisible(false);
}
});
// event for analyzedResultsDialog window closing
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setLF(); // set default look and feel
analyzedResultsList.setCellRenderer(new MyListCellRenderer());
// doubleclicking on document shows the annotated result
MouseListener mouseListener = new ListMouseAdapter();
// styleMapFile, analyzedResultsList,
// inputDirPath,typeSystem , typesToDisplay ,
// javaViewerRB , javaViewerUCRB ,xmlRB ,
// viewerDirectory , this);
// add mouse Listener to the list
analyzedResultsList.addMouseListener(mouseListener);
}