in taverna-xpath-activity-ui/src/main/java/org/apache/taverna/activities/xpath/ui/contextualview/XPathActivityMainContextualView.java [93:177]
public JComponent getMainFrame() {
jpMainPanel = new JPanel(new GridBagLayout());
jpMainPanel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(4, 2, 4, 2), BorderFactory.createEmptyBorder()));
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.WEST;
c.weighty = 0;
// --- XPath Expression ---
c.gridx = 0;
c.gridy = 0;
c.insets = new Insets(5, 5, 5, 5);
JLabel jlXPathExpression = new JLabel("XPath Expression:");
jlXPathExpression.setFont(jlXPathExpression.getFont().deriveFont(Font.BOLD));
jpMainPanel.add(jlXPathExpression, c);
c.gridx++;
c.weightx = 1.0;
tfXPathExpression = new JTextField();
tfXPathExpression.setEditable(false);
jpMainPanel.add(tfXPathExpression, c);
// --- Label to Show/Hide Mapping Table ---
final JLabel jlShowHideNamespaceMappings = new JLabel("Show namespace mappings...");
jlShowHideNamespaceMappings.setForeground(Color.BLUE);
jlShowHideNamespaceMappings.setCursor(new Cursor(Cursor.HAND_CURSOR));
jlShowHideNamespaceMappings.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
spXPathNamespaceMappings.setVisible(!spXPathNamespaceMappings.isVisible());
jlShowHideNamespaceMappings.setText((spXPathNamespaceMappings.isVisible() ? "Hide"
: "Show") + " namespace mappings...");
thisContextualView.revalidate();
}
});
c.gridx = 0;
c.gridy++;
c.gridwidth = 2;
c.weightx = 1.0;
c.weighty = 0;
c.fill = GridBagConstraints.HORIZONTAL;
jpMainPanel.add(jlShowHideNamespaceMappings, c);
// --- Namespace Mapping Table ---
xpathNamespaceMappingsTableModel = new DefaultTableModel() {
/**
* No cells should be editable
*/
public boolean isCellEditable(int rowIndex, int columnIndex) {
return (false);
}
};
xpathNamespaceMappingsTableModel.addColumn("Namespace Prefix");
xpathNamespaceMappingsTableModel.addColumn("Namespace URI");
jtXPathNamespaceMappings = new JTable();
jtXPathNamespaceMappings.setModel(xpathNamespaceMappingsTableModel);
jtXPathNamespaceMappings.setPreferredScrollableViewportSize(new Dimension(200, 90));
// TODO - next line is to be enabled when Taverna is migrated to Java
// 1.6; for now it's fine to run without this
// jtXPathNamespaceMappings.setFillsViewportHeight(true); // makes sure
// that when the dedicated area is larger than the table, the latter is
// stretched vertically to fill the empty space
jtXPathNamespaceMappings.getColumnModel().getColumn(0).setPreferredWidth(20); // set
// relative
// sizes of
// columns
jtXPathNamespaceMappings.getColumnModel().getColumn(1).setPreferredWidth(300);
c.gridy++;
spXPathNamespaceMappings = new JScrollPane(jtXPathNamespaceMappings);
spXPathNamespaceMappings.setVisible(false);
jpMainPanel.add(spXPathNamespaceMappings, c);
// populate the view with values
refreshView();
return jpMainPanel;
}