use of gate.gui.annedit.SearchAndAnnotatePanel in project gate-core by GateNLP.
the class AnnotationEditor method initGUI.
protected void initGUI() {
popupWindow = new JWindow(SwingUtilities.getWindowAncestor(owner.getTextComponent())) {
@Override
public void pack() {
// than the main frame
if (isVisible()) {
int maxHeight = MainFrame.getInstance().getHeight();
int otherHeight = getHeight() - featuresScroller.getHeight();
maxHeight -= otherHeight;
if (featuresScroller.getPreferredSize().height > maxHeight) {
featuresScroller.setMaximumSize(new Dimension(featuresScroller.getMaximumSize().width, maxHeight));
featuresScroller.setPreferredSize(new Dimension(featuresScroller.getPreferredSize().width, maxHeight));
}
}
super.pack();
}
@Override
public void setVisible(boolean b) {
super.setVisible(b);
// when the editor is shown put the focus in the type combo box
if (b) {
typeCombo.requestFocus();
}
}
};
JPanel pane = new JPanel();
pane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
pane.setLayout(new GridBagLayout());
pane.setBackground(UIManager.getLookAndFeelDefaults().getColor("ToolTip.background"));
popupWindow.setContentPane(pane);
Insets insets0 = new Insets(0, 0, 0, 0);
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.NONE;
constraints.anchor = GridBagConstraints.CENTER;
constraints.gridwidth = 1;
constraints.gridy = 0;
constraints.gridx = GridBagConstraints.RELATIVE;
constraints.weightx = 0;
constraints.weighty = 0;
constraints.insets = insets0;
solButton = new JButton();
solButton.setContentAreaFilled(false);
solButton.setBorderPainted(false);
solButton.setMargin(insets0);
pane.add(solButton, constraints);
sorButton = new JButton();
sorButton.setContentAreaFilled(false);
sorButton.setBorderPainted(false);
sorButton.setMargin(insets0);
pane.add(sorButton, constraints);
delButton = new JButton();
delButton.setContentAreaFilled(false);
delButton.setBorderPainted(false);
delButton.setMargin(insets0);
constraints.insets = new Insets(0, 20, 0, 20);
pane.add(delButton, constraints);
constraints.insets = insets0;
eolButton = new JButton();
eolButton.setContentAreaFilled(false);
eolButton.setBorderPainted(false);
eolButton.setMargin(insets0);
pane.add(eolButton, constraints);
eorButton = new JButton();
eorButton.setContentAreaFilled(false);
eorButton.setBorderPainted(false);
eorButton.setMargin(insets0);
pane.add(eorButton, constraints);
pinnedButton = new JToggleButton(MainFrame.getIcon("pin"));
pinnedButton.setSelectedIcon(MainFrame.getIcon("pin-in"));
pinnedButton.setSelected(false);
pinnedButton.setBorderPainted(false);
pinnedButton.setContentAreaFilled(false);
constraints.weightx = 1;
constraints.insets = new Insets(0, 0, 0, 0);
constraints.anchor = GridBagConstraints.EAST;
pane.add(pinnedButton, constraints);
dismissButton = new JButton();
dismissButton.setBorder(null);
constraints.anchor = GridBagConstraints.NORTHEAST;
pane.add(dismissButton, constraints);
constraints.anchor = GridBagConstraints.CENTER;
constraints.insets = insets0;
typeCombo = new JComboBox<String>();
typeCombo.setEditable(true);
typeCombo.setBackground(UIManager.getLookAndFeelDefaults().getColor("ToolTip.background"));
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.gridy = 1;
constraints.gridwidth = 7;
constraints.weightx = 1;
constraints.insets = new Insets(3, 2, 2, 2);
pane.add(typeCombo, constraints);
featuresEditor = new FeaturesSchemaEditor();
featuresEditor.setBackground(UIManager.getLookAndFeelDefaults().getColor("ToolTip.background"));
try {
featuresEditor.init();
} catch (ResourceInstantiationException rie) {
throw new GateRuntimeException(rie);
}
constraints.gridy = 2;
constraints.weighty = 1;
constraints.fill = GridBagConstraints.BOTH;
featuresScroller = new JScrollPane(featuresEditor);
pane.add(featuresScroller, constraints);
// add the search and annotate GUI at the bottom of the annotator editor
SearchAndAnnotatePanel searchPanel = new SearchAndAnnotatePanel(pane.getBackground(), this, popupWindow);
constraints.insets = new Insets(0, 0, 0, 0);
constraints.fill = GridBagConstraints.BOTH;
constraints.anchor = GridBagConstraints.WEST;
constraints.gridx = 0;
constraints.gridy = GridBagConstraints.RELATIVE;
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.gridheight = GridBagConstraints.REMAINDER;
constraints.weightx = 0.0;
constraints.weighty = 0.0;
pane.add(searchPanel, constraints);
popupWindow.pack();
}
Aggregations