use of org.kse.gui.JKseTable in project keystore-explorer by kaikramer.
the class JPolicyQualifierInfo method initComponents.
private void initComponents() {
jbAdd = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JPolicyQualifierInfo.jbAdd.image")))));
jbAdd.setMargin(new Insets(2, 2, 0, 0));
jbAdd.setToolTipText(res.getString("JPolicyQualifierInfo.jbAdd.tooltip"));
jbAdd.setMnemonic(res.getString("JPolicyQualifierInfo.jbAdd.mnemonic").charAt(0));
jbAdd.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(JPolicyQualifierInfo.this);
addPressed();
} finally {
CursorUtil.setCursorFree(JPolicyQualifierInfo.this);
}
}
});
jbEdit = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JPolicyQualifierInfo.jbEdit.image")))));
jbEdit.setMargin(new Insets(2, 2, 0, 0));
jbEdit.setToolTipText(res.getString("JPolicyQualifierInfo.jbEdit.tooltip"));
jbEdit.setMnemonic(res.getString("JPolicyQualifierInfo.jbEdit.mnemonic").charAt(0));
jbEdit.setEnabled(false);
jbEdit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(JPolicyQualifierInfo.this);
editPressed();
} finally {
CursorUtil.setCursorFree(JPolicyQualifierInfo.this);
}
}
});
jbRemove = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JPolicyQualifierInfo.jbRemove.image")))));
jbRemove.setMargin(new Insets(2, 2, 0, 0));
jbRemove.setToolTipText(res.getString("JPolicyQualifierInfo.jbRemove.tooltip"));
jbRemove.setMnemonic(res.getString("JPolicyQualifierInfo.jbRemove.mnemonic").charAt(0));
jbRemove.setEnabled(false);
jbRemove.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(JPolicyQualifierInfo.this);
removePressed();
} finally {
CursorUtil.setCursorFree(JPolicyQualifierInfo.this);
}
}
});
jpPolicyQualifierInfoButtons = new JPanel();
jpPolicyQualifierInfoButtons.setLayout(new BoxLayout(jpPolicyQualifierInfoButtons, BoxLayout.Y_AXIS));
jpPolicyQualifierInfoButtons.add(Box.createVerticalGlue());
jpPolicyQualifierInfoButtons.add(jbAdd);
jpPolicyQualifierInfoButtons.add(Box.createVerticalStrut(3));
jpPolicyQualifierInfoButtons.add(jbEdit);
jpPolicyQualifierInfoButtons.add(Box.createVerticalStrut(3));
jpPolicyQualifierInfoButtons.add(jbRemove);
jpPolicyQualifierInfoButtons.add(Box.createVerticalGlue());
PolicyQualifierInfoTableModel policyQualifierInfoTableModel = new PolicyQualifierInfoTableModel();
jtPolicyQualifierInfo = new JKseTable(policyQualifierInfoTableModel);
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(policyQualifierInfoTableModel);
sorter.setComparator(0, new PolicyQualifierInfoTableModel.PolicyQualifierInfoComparator());
jtPolicyQualifierInfo.setRowSorter(sorter);
jtPolicyQualifierInfo.setShowGrid(false);
jtPolicyQualifierInfo.setRowMargin(0);
jtPolicyQualifierInfo.getColumnModel().setColumnMargin(0);
jtPolicyQualifierInfo.getTableHeader().setReorderingAllowed(false);
jtPolicyQualifierInfo.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS);
jtPolicyQualifierInfo.setRowHeight(Math.max(18, jtPolicyQualifierInfo.getRowHeight()));
for (int i = 0; i < jtPolicyQualifierInfo.getColumnCount(); i++) {
TableColumn column = jtPolicyQualifierInfo.getColumnModel().getColumn(i);
column.setHeaderRenderer(new PolicyQualifierInfoTableHeadRend(jtPolicyQualifierInfo.getTableHeader().getDefaultRenderer()));
column.setCellRenderer(new PolicyQualifierInfoTableCellRend());
}
ListSelectionModel selectionModel = jtPolicyQualifierInfo.getSelectionModel();
selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
selectionModel.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent evt) {
if (!evt.getValueIsAdjusting()) {
updateButtonControls();
}
}
});
jtPolicyQualifierInfo.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent evt) {
maybeEditPolicyQualifierInfo(evt);
}
});
jtPolicyQualifierInfo.addKeyListener(new KeyAdapter() {
boolean deleteLastPressed = false;
@Override
public void keyPressed(KeyEvent evt) {
// Record delete pressed on non-Macs
if (!OperatingSystem.isMacOs()) {
deleteLastPressed = evt.getKeyCode() == KeyEvent.VK_DELETE;
}
}
@Override
public void keyReleased(KeyEvent evt) {
// Delete on non-Mac if delete was pressed and is now released
if (!OperatingSystem.isMacOs() && deleteLastPressed && evt.getKeyCode() == KeyEvent.VK_DELETE) {
try {
CursorUtil.setCursorBusy(JPolicyQualifierInfo.this);
deleteLastPressed = false;
removeSelectedPolicyQualifierInfo();
} finally {
CursorUtil.setCursorFree(JPolicyQualifierInfo.this);
}
}
}
@Override
public void keyTyped(KeyEvent evt) {
// Delete on Mac if back space typed
if (OperatingSystem.isMacOs() && evt.getKeyChar() == 0x08) {
try {
CursorUtil.setCursorBusy(JPolicyQualifierInfo.this);
removeSelectedPolicyQualifierInfo();
} finally {
CursorUtil.setCursorFree(JPolicyQualifierInfo.this);
}
}
}
});
jspPolicyQualifierInfo = PlatformUtil.createScrollPane(jtPolicyQualifierInfo, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
jspPolicyQualifierInfo.getViewport().setBackground(jtPolicyQualifierInfo.getBackground());
this.setLayout(new BorderLayout(5, 5));
setPreferredSize(new Dimension(400, 150));
add(jspPolicyQualifierInfo, BorderLayout.CENTER);
add(jpPolicyQualifierInfoButtons, BorderLayout.EAST);
populate();
}
use of org.kse.gui.JKseTable in project keystore-explorer by kaikramer.
the class DViewExtensions method initComponents.
private void initComponents() {
ExtensionsTableModel extensionsTableModel = new ExtensionsTableModel();
jtExtensions = new JKseTable(extensionsTableModel);
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(extensionsTableModel);
sorter.setComparator(2, new ObjectIdComparator());
jtExtensions.setRowSorter(sorter);
jtExtensions.setShowGrid(false);
jtExtensions.setRowMargin(0);
jtExtensions.getColumnModel().setColumnMargin(0);
jtExtensions.getTableHeader().setReorderingAllowed(false);
jtExtensions.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS);
jtExtensions.setRowHeight(Math.max(18, jtExtensions.getRowHeight()));
for (int i = 0; i < jtExtensions.getColumnCount(); i++) {
TableColumn column = jtExtensions.getColumnModel().getColumn(i);
column.setHeaderRenderer(new ExtensionsTableHeadRend(jtExtensions.getTableHeader().getDefaultRenderer()));
column.setCellRenderer(new ExtensionsTableCellRend());
}
TableColumn criticalCol = jtExtensions.getColumnModel().getColumn(0);
criticalCol.setResizable(false);
criticalCol.setMinWidth(28);
criticalCol.setMaxWidth(28);
criticalCol.setPreferredWidth(28);
ListSelectionModel selectionModel = jtExtensions.getSelectionModel();
selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
selectionModel.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent evt) {
if (!evt.getValueIsAdjusting()) {
try {
CursorUtil.setCursorBusy(DViewExtensions.this);
updateExtensionValue();
} finally {
CursorUtil.setCursorFree(DViewExtensions.this);
}
}
}
});
jspExtensionsTable = PlatformUtil.createScrollPane(jtExtensions, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
jspExtensionsTable.getViewport().setBackground(jtExtensions.getBackground());
jpExtensionsTable = new JPanel(new BorderLayout(5, 5));
jpExtensionsTable.setPreferredSize(new Dimension(500, 200));
jpExtensionsTable.add(jspExtensionsTable, BorderLayout.CENTER);
jpExtensionValue = new JPanel(new BorderLayout(5, 5));
jlExtensionValue = new JLabel(res.getString("DViewExtensions.jlExtensionValue.text"));
jpExtensionValue.add(jlExtensionValue, BorderLayout.NORTH);
jepExtensionValue = new JEditorPane();
jepExtensionValue.setFont(new Font(Font.MONOSPACED, Font.PLAIN, LnfUtil.getDefaultFontSize()));
jepExtensionValue.setEditable(false);
jepExtensionValue.setToolTipText(res.getString("DViewExtensions.jtaExtensionValue.tooltip"));
// JGoodies - keep uneditable color same as editable
jepExtensionValue.putClientProperty("JTextArea.infoBackground", Boolean.TRUE);
// for displaying URLs in extensions as clickable links
jepExtensionValue.setContentType("text/html");
jepExtensionValue.addHyperlinkListener(this);
// use default font and foreground color from the component
jepExtensionValue.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
jspExtensionValue = PlatformUtil.createScrollPane(jepExtensionValue, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jpExtensionValueTextArea = new JPanel(new BorderLayout(5, 5));
jpExtensionValueTextArea.setPreferredSize(new Dimension(500, 200));
jpExtensionValueTextArea.add(jspExtensionValue, BorderLayout.CENTER);
jpExtensionValue.add(jpExtensionValueTextArea, BorderLayout.CENTER);
jbAsn1 = new JButton(res.getString("DViewExtensions.jbAsn1.text"));
PlatformUtil.setMnemonic(jbAsn1, res.getString("DViewExtensions.jbAsn1.mnemonic").charAt(0));
jbAsn1.setToolTipText(res.getString("DViewExtensions.jbAsn1.tooltip"));
jbAsn1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(DViewExtensions.this);
asn1DumpPressed();
} finally {
CursorUtil.setCursorFree(DViewExtensions.this);
}
}
});
jpExtensionValueAsn1 = new JPanel(new FlowLayout(FlowLayout.RIGHT));
jpExtensionValueAsn1.add(jbAsn1);
jpExtensionValue.add(jpExtensionValueAsn1, BorderLayout.SOUTH);
jpExtensions = new JPanel(new GridLayout(2, 1, 5, 5));
jpExtensions.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5))));
jpExtensions.add(jpExtensionsTable);
jpExtensions.add(jpExtensionValue);
jbOK = new JButton(res.getString("DViewExtensions.jbOK.text"));
jbOK.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
okPressed();
}
});
jpOK = PlatformUtil.createDialogButtonPanel(jbOK, false);
extensionsTableModel.load(extensions);
if (extensionsTableModel.getRowCount() > 0) {
jtExtensions.changeSelection(0, 0, false, false);
}
getContentPane().add(jpExtensions, BorderLayout.CENTER);
getContentPane().add(jpOK, BorderLayout.SOUTH);
setResizable(false);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
closeDialog();
}
});
getRootPane().setDefaultButton(jbOK);
pack();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
jbOK.requestFocus();
}
});
}
Aggregations