use of java.awt.event.KeyEvent in project sldeditor by robward-scisys.
the class WKTDialog method createUI.
/**
* Creates the ui.
*/
@SuppressWarnings("unchecked")
private void createUI() {
JPanel wktSelectionPanel = new JPanel();
getContentPane().add(wktSelectionPanel, BorderLayout.NORTH);
model = new WKTTypeComboBoxModel(WKTConversion.getWKTTypeData());
geometryTypeComboBox = new JComboBox<WKTType>(model);
geometryTypeComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
geometryTypeUpdated();
}
});
wktSelectionPanel.add(geometryTypeComboBox);
JPanel buttonPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
flowLayout.setAlignment(FlowLayout.RIGHT);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
JButton btnOk = new JButton(Localisation.getString(WKTDialog.class, "common.ok"));
btnOk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
okButtonPressed = true;
setVisible(false);
}
});
buttonPanel.add(btnOk);
JButton btnCancel = new JButton(Localisation.getString(WKTDialog.class, "common.cancel"));
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
okButtonPressed = false;
setVisible(false);
}
});
buttonPanel.add(btnCancel);
JPanel mainPanel = new JPanel();
getContentPane().add(mainPanel, BorderLayout.CENTER);
mainPanel.setLayout(new BorderLayout(0, 0));
JPanel panel = new JPanel();
BoxLayout boxLayout = new BoxLayout(panel, BoxLayout.X_AXIS);
panel.setLayout(boxLayout);
mainPanel.add(panel, BorderLayout.WEST);
//
// Multi shape panel
//
createMultiShapePanel(panel);
panel.add(Box.createRigidArea(new Dimension(5, 0)));
//
// Segment panel
//
createSegmentPanel(panel);
panel.add(Box.createRigidArea(new Dimension(5, 0)));
//
// Coordinate panel
//
createPointPanel(panel);
//
// Text area
//
JPanel stringPanel = new JPanel();
mainPanel.add(stringPanel, BorderLayout.SOUTH);
stringPanel.setLayout(new BorderLayout(0, 0));
JScrollPane textAreaScrollPane = new JScrollPane();
stringPanel.add(textAreaScrollPane);
wktTextArea = new JTextArea();
wktTextArea.setRows(5);
wktTextArea.setEditable(true);
wktTextArea.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
btnReload.setEnabled(true);
}
@Override
public void keyPressed(KeyEvent e) {
// Do nothing
}
@Override
public void keyReleased(KeyEvent e) {
// Do nothing
}
});
textAreaScrollPane.setViewportView(wktTextArea);
JPanel textAreaButtonPanel = new JPanel();
stringPanel.add(textAreaButtonPanel, BorderLayout.EAST);
btnReload = new JButton(Localisation.getString(WKTDialog.class, "WKTDialog.reload"));
btnReload.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
reload();
}
});
textAreaButtonPanel.add(btnReload);
this.setSize(520, 365);
}
use of java.awt.event.KeyEvent in project keystore-explorer by kaikramer.
the class KseFrame method createEmptyKeyStoreTable.
private JTable createEmptyKeyStoreTable() {
KeyStoreTableModel ksModel = new KeyStoreTableModel();
final JTable jtKeyStore = new JKseTable(ksModel);
RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(ksModel);
jtKeyStore.setRowSorter(sorter);
jtKeyStore.setShowGrid(false);
jtKeyStore.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jtKeyStore.getTableHeader().setReorderingAllowed(false);
jtKeyStore.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
// min. height of 18 because of 16x16 icons
jtKeyStore.setRowHeight(Math.max(18, jtKeyStore.getRowHeight()));
// Register cut, copy and paste actions with the relevant keystrokes
jtKeyStore.getInputMap().put((KeyStroke) cutAction.getValue(Action.ACCELERATOR_KEY), CUT_KEY);
jtKeyStore.getActionMap().put(CUT_KEY, cutAction);
jtKeyStore.getInputMap().put((KeyStroke) copyAction.getValue(Action.ACCELERATOR_KEY), COPY_KEY);
jtKeyStore.getActionMap().put(COPY_KEY, copyAction);
jtKeyStore.getInputMap().put((KeyStroke) pasteAction.getValue(Action.ACCELERATOR_KEY), PASTE_KEY);
jtKeyStore.getActionMap().put(PASTE_KEY, pasteAction);
// open keystore entry details when user presses enter key
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
jtKeyStore.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(enter, "Enter");
jtKeyStore.getActionMap().put("Enter", new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent ae) {
try {
int selectedRow = jtKeyStore.getSelectedRow();
if (selectedRow != -1) {
CursorUtil.setCursorBusy(frame);
showSelectedEntryDetails(jtKeyStore, selectedRow);
}
} finally {
CursorUtil.setCursorFree(frame);
}
}
});
// Add DnD source support to KeyStore
DragSource ds = DragSource.getDefaultDragSource();
ds.createDefaultDragGestureRecognizer(jtKeyStore, DnDConstants.ACTION_MOVE, new KeyStoreEntryDragGestureListener(this));
// Add custom renderers for headers and cells
for (int i = 0; i < jtKeyStore.getColumnCount(); i++) {
TableColumn column = jtKeyStore.getColumnModel().getColumn(i);
column.setHeaderRenderer(new KeyStoreTableHeadRend(jtKeyStore.getTableHeader().getDefaultRenderer()));
column.setCellRenderer(new KeyStoreTableCellRend());
}
// Make the first three columns small and not resizable as they hold icons
TableColumn typeCol = jtKeyStore.getColumnModel().getColumn(0);
typeCol.setResizable(false);
typeCol.setMinWidth(28);
typeCol.setMaxWidth(28);
typeCol.setPreferredWidth(28);
TableColumn statusCol = jtKeyStore.getColumnModel().getColumn(1);
statusCol.setResizable(false);
statusCol.setMinWidth(28);
statusCol.setMaxWidth(28);
statusCol.setPreferredWidth(28);
TableColumn certExpiredCol = jtKeyStore.getColumnModel().getColumn(2);
certExpiredCol.setResizable(false);
certExpiredCol.setMinWidth(28);
certExpiredCol.setMaxWidth(28);
certExpiredCol.setPreferredWidth(28);
jtKeyStore.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent evt) {
maybeShowSelectedEntryDetails(evt);
}
@Override
public void mousePressed(MouseEvent evt) {
maybeShowSelectedEntryPopupMenu(evt);
}
@Override
public void mouseReleased(MouseEvent evt) {
maybeShowSelectedEntryPopupMenu(evt);
}
});
jtKeyStore.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) {
deleteLastPressed = false;
handleDeleteSelectedEntry();
}
}
@Override
public void keyTyped(KeyEvent evt) {
// Delete on Mac if back space typed
if (OperatingSystem.isMacOs() && evt.getKeyChar() == 0x08) {
handleDeleteSelectedEntry();
}
}
});
return jtKeyStore;
}
use of java.awt.event.KeyEvent in project keystore-explorer by kaikramer.
the class JGeneralSubtrees method initComponents.
private void initComponents() {
jbAdd = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JGeneralSubtrees.jbAdd.image")))));
jbAdd.setMargin(new Insets(2, 2, 0, 0));
jbAdd.setToolTipText(res.getString("JGeneralSubtrees.jbAdd.tooltip"));
jbAdd.setMnemonic(res.getString("JGeneralSubtrees.jbAdd.mnemonic").charAt(0));
jbAdd.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(JGeneralSubtrees.this);
addPressed();
} finally {
CursorUtil.setCursorFree(JGeneralSubtrees.this);
}
}
});
jbEdit = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JGeneralSubtrees.jbEdit.image")))));
jbEdit.setMargin(new Insets(2, 2, 0, 0));
jbEdit.setToolTipText(res.getString("JGeneralSubtrees.jbEdit.tooltip"));
jbEdit.setMnemonic(res.getString("JGeneralSubtrees.jbEdit.mnemonic").charAt(0));
jbEdit.setEnabled(false);
jbEdit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(JGeneralSubtrees.this);
editPressed();
} finally {
CursorUtil.setCursorFree(JGeneralSubtrees.this);
}
}
});
jbRemove = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JGeneralSubtrees.jbRemove.image")))));
jbRemove.setMargin(new Insets(2, 2, 0, 0));
jbRemove.setToolTipText(res.getString("JGeneralSubtrees.jbRemove.tooltip"));
jbRemove.setMnemonic(res.getString("JGeneralSubtrees.jbRemove.mnemonic").charAt(0));
jbRemove.setEnabled(false);
jbRemove.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(JGeneralSubtrees.this);
removePressed();
} finally {
CursorUtil.setCursorFree(JGeneralSubtrees.this);
}
}
});
jpGeneralSubtreeButtons = new JPanel();
jpGeneralSubtreeButtons.setLayout(new BoxLayout(jpGeneralSubtreeButtons, BoxLayout.Y_AXIS));
jpGeneralSubtreeButtons.add(Box.createVerticalGlue());
jpGeneralSubtreeButtons.add(jbAdd);
jpGeneralSubtreeButtons.add(Box.createVerticalStrut(3));
jpGeneralSubtreeButtons.add(jbEdit);
jpGeneralSubtreeButtons.add(Box.createVerticalStrut(3));
jpGeneralSubtreeButtons.add(jbRemove);
jpGeneralSubtreeButtons.add(Box.createVerticalGlue());
GeneralSubtreesTableModel generalSubtreesTableModel = new GeneralSubtreesTableModel();
jtGeneralSubtrees = new JKseTable(generalSubtreesTableModel);
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(generalSubtreesTableModel);
sorter.setComparator(0, new GeneralSubtreesTableModel.GeneralSubtreeBaseComparator());
sorter.setComparator(1, new GeneralSubtreesTableModel.GeneralSubtreeMinimumComparator());
sorter.setComparator(2, new GeneralSubtreesTableModel.GeneralSubtreeMaximumComparator());
jtGeneralSubtrees.setRowSorter(sorter);
jtGeneralSubtrees.setShowGrid(false);
jtGeneralSubtrees.setRowMargin(0);
jtGeneralSubtrees.getColumnModel().setColumnMargin(0);
jtGeneralSubtrees.getTableHeader().setReorderingAllowed(false);
jtGeneralSubtrees.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS);
jtGeneralSubtrees.setRowHeight(Math.max(18, jtGeneralSubtrees.getRowHeight()));
for (int i = 0; i < jtGeneralSubtrees.getColumnCount(); i++) {
TableColumn column = jtGeneralSubtrees.getColumnModel().getColumn(i);
column.setHeaderRenderer(new GeneralSubtreesTableHeadRend(jtGeneralSubtrees.getTableHeader().getDefaultRenderer()));
column.setCellRenderer(new GeneralSubtreesTableCellRend());
}
ListSelectionModel selectionModel = jtGeneralSubtrees.getSelectionModel();
selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
selectionModel.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent evt) {
if (!evt.getValueIsAdjusting()) {
updateButtonControls();
}
}
});
jtGeneralSubtrees.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent evt) {
maybeEditGeneralSubtree(evt);
}
});
jtGeneralSubtrees.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(JGeneralSubtrees.this);
deleteLastPressed = false;
removeSelectedGeneralSubtree();
} finally {
CursorUtil.setCursorFree(JGeneralSubtrees.this);
}
}
}
@Override
public void keyTyped(KeyEvent evt) {
// Delete on Mac if back space typed
if (OperatingSystem.isMacOs() && evt.getKeyChar() == 0x08) {
try {
CursorUtil.setCursorBusy(JGeneralSubtrees.this);
removeSelectedGeneralSubtree();
} finally {
CursorUtil.setCursorFree(JGeneralSubtrees.this);
}
}
}
});
jspGeneralSubtrees = PlatformUtil.createScrollPane(jtGeneralSubtrees, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
jspGeneralSubtrees.getViewport().setBackground(jtGeneralSubtrees.getBackground());
this.setLayout(new BorderLayout(5, 5));
setPreferredSize(new Dimension(400, 150));
add(jspGeneralSubtrees, BorderLayout.CENTER);
add(jpGeneralSubtreeButtons, BorderLayout.EAST);
populate();
}
use of java.awt.event.KeyEvent in project keystore-explorer by kaikramer.
the class JPolicyInformation method initComponents.
private void initComponents() {
jbAdd = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JPolicyInformation.jbAdd.image")))));
jbAdd.setMargin(new Insets(2, 2, 0, 0));
jbAdd.setToolTipText(res.getString("JPolicyInformation.jbAdd.tooltip"));
jbAdd.setMnemonic(res.getString("JPolicyInformation.jbAdd.mnemonic").charAt(0));
jbAdd.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(JPolicyInformation.this);
addPressed();
} finally {
CursorUtil.setCursorFree(JPolicyInformation.this);
}
}
});
jbEdit = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JPolicyInformation.jbEdit.image")))));
jbEdit.setMargin(new Insets(2, 2, 0, 0));
jbEdit.setToolTipText(res.getString("JPolicyInformation.jbEdit.tooltip"));
jbEdit.setMnemonic(res.getString("JPolicyInformation.jbEdit.mnemonic").charAt(0));
jbEdit.setEnabled(false);
jbEdit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(JPolicyInformation.this);
editPressed();
} finally {
CursorUtil.setCursorFree(JPolicyInformation.this);
}
}
});
jbRemove = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JPolicyInformation.jbRemove.image")))));
jbRemove.setMargin(new Insets(2, 2, 0, 0));
jbRemove.setToolTipText(res.getString("JPolicyInformation.jbRemove.tooltip"));
jbRemove.setMnemonic(res.getString("JPolicyInformation.jbRemove.mnemonic").charAt(0));
jbRemove.setEnabled(false);
jbRemove.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(JPolicyInformation.this);
removePressed();
} finally {
CursorUtil.setCursorFree(JPolicyInformation.this);
}
}
});
jpPolicyInformationButtons = new JPanel();
jpPolicyInformationButtons.setLayout(new BoxLayout(jpPolicyInformationButtons, BoxLayout.Y_AXIS));
jpPolicyInformationButtons.add(Box.createVerticalGlue());
jpPolicyInformationButtons.add(jbAdd);
jpPolicyInformationButtons.add(Box.createVerticalStrut(3));
jpPolicyInformationButtons.add(jbEdit);
jpPolicyInformationButtons.add(Box.createVerticalStrut(3));
jpPolicyInformationButtons.add(jbRemove);
jpPolicyInformationButtons.add(Box.createVerticalGlue());
PolicyInformationTableModel policyInformationTableModel = new PolicyInformationTableModel();
jtPolicyInformation = new JKseTable(policyInformationTableModel);
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(policyInformationTableModel);
sorter.setComparator(0, new PolicyInformationTableModel.PolicyInformationComparator());
jtPolicyInformation.setRowSorter(sorter);
jtPolicyInformation.setShowGrid(false);
jtPolicyInformation.setRowMargin(0);
jtPolicyInformation.getColumnModel().setColumnMargin(0);
jtPolicyInformation.getTableHeader().setReorderingAllowed(false);
jtPolicyInformation.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS);
jtPolicyInformation.setRowHeight(Math.max(18, jtPolicyInformation.getRowHeight()));
for (int i = 0; i < jtPolicyInformation.getColumnCount(); i++) {
TableColumn column = jtPolicyInformation.getColumnModel().getColumn(i);
column.setHeaderRenderer(new PolicyInformationTableHeadRend(jtPolicyInformation.getTableHeader().getDefaultRenderer()));
column.setCellRenderer(new PolicyInformationTableCellRend());
}
ListSelectionModel selectionModel = jtPolicyInformation.getSelectionModel();
selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
selectionModel.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent evt) {
if (!evt.getValueIsAdjusting()) {
updateButtonControls();
}
}
});
jtPolicyInformation.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent evt) {
maybeEditPolicyInformation(evt);
}
});
jtPolicyInformation.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(JPolicyInformation.this);
deleteLastPressed = false;
removeSelectedPolicyInformation();
} finally {
CursorUtil.setCursorFree(JPolicyInformation.this);
}
}
}
@Override
public void keyTyped(KeyEvent evt) {
// Delete on Mac if back space typed
if (OperatingSystem.isMacOs() && evt.getKeyChar() == 0x08) {
try {
CursorUtil.setCursorBusy(JPolicyInformation.this);
removeSelectedPolicyInformation();
} finally {
CursorUtil.setCursorFree(JPolicyInformation.this);
}
}
}
});
jspPolicyInformation = PlatformUtil.createScrollPane(jtPolicyInformation, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
jspPolicyInformation.getViewport().setBackground(jtPolicyInformation.getBackground());
this.setLayout(new BorderLayout(5, 5));
setPreferredSize(new Dimension(250, 150));
add(jspPolicyInformation, BorderLayout.CENTER);
add(jpPolicyInformationButtons, BorderLayout.EAST);
populate();
}
use of java.awt.event.KeyEvent in project keystore-explorer by kaikramer.
the class JAccessDescriptions method initComponents.
private void initComponents() {
jbAdd = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JAccessDescriptions.jbAdd.image")))));
jbAdd.setMargin(new Insets(2, 2, 0, 0));
jbAdd.setToolTipText(res.getString("JAccessDescriptions.jbAdd.tooltip"));
jbAdd.setMnemonic(res.getString("JAccessDescriptions.jbAdd.mnemonic").charAt(0));
jbAdd.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(JAccessDescriptions.this);
addPressed();
} finally {
CursorUtil.setCursorFree(JAccessDescriptions.this);
}
}
});
jbEdit = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JAccessDescriptions.jbEdit.image")))));
jbEdit.setMargin(new Insets(2, 2, 0, 0));
jbEdit.setToolTipText(res.getString("JAccessDescriptions.jbEdit.tooltip"));
jbEdit.setMnemonic(res.getString("JAccessDescriptions.jbEdit.mnemonic").charAt(0));
jbEdit.setEnabled(false);
jbEdit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(JAccessDescriptions.this);
editPressed();
} finally {
CursorUtil.setCursorFree(JAccessDescriptions.this);
}
}
});
jbRemove = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JAccessDescriptions.jbRemove.image")))));
jbRemove.setMargin(new Insets(2, 2, 0, 0));
jbRemove.setToolTipText(res.getString("JAccessDescriptions.jbRemove.tooltip"));
jbRemove.setMnemonic(res.getString("JAccessDescriptions.jbRemove.mnemonic").charAt(0));
jbRemove.setEnabled(false);
jbRemove.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(JAccessDescriptions.this);
removePressed();
} finally {
CursorUtil.setCursorFree(JAccessDescriptions.this);
}
}
});
jpAccessDescriptionButtons = new JPanel();
jpAccessDescriptionButtons.setLayout(new BoxLayout(jpAccessDescriptionButtons, BoxLayout.Y_AXIS));
jpAccessDescriptionButtons.add(Box.createVerticalGlue());
jpAccessDescriptionButtons.add(jbAdd);
jpAccessDescriptionButtons.add(Box.createVerticalStrut(3));
jpAccessDescriptionButtons.add(jbEdit);
jpAccessDescriptionButtons.add(Box.createVerticalStrut(3));
jpAccessDescriptionButtons.add(jbRemove);
jpAccessDescriptionButtons.add(Box.createVerticalGlue());
AccessDescriptionsTableModel accessDescriptionsTableModel = new AccessDescriptionsTableModel();
jtAccessDescriptions = new JKseTable(accessDescriptionsTableModel);
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(accessDescriptionsTableModel);
sorter.setComparator(0, new AccessDescriptionsTableModel.AccessDescriptionMethodComparator());
sorter.setComparator(1, new AccessDescriptionsTableModel.AccessDescriptionLocationComparator());
jtAccessDescriptions.setRowSorter(sorter);
jtAccessDescriptions.setShowGrid(false);
jtAccessDescriptions.setRowMargin(0);
jtAccessDescriptions.getColumnModel().setColumnMargin(0);
jtAccessDescriptions.getTableHeader().setReorderingAllowed(false);
jtAccessDescriptions.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS);
jtAccessDescriptions.setRowHeight(Math.max(18, jtAccessDescriptions.getRowHeight()));
for (int i = 0; i < jtAccessDescriptions.getColumnCount(); i++) {
TableColumn column = jtAccessDescriptions.getColumnModel().getColumn(i);
column.setHeaderRenderer(new AccessDescriptionsTableHeadRend(jtAccessDescriptions.getTableHeader().getDefaultRenderer()));
column.setCellRenderer(new AccessDescriptionsTableCellRend());
}
ListSelectionModel selectionModel = jtAccessDescriptions.getSelectionModel();
selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
selectionModel.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent evt) {
if (!evt.getValueIsAdjusting()) {
updateButtonControls();
}
}
});
jtAccessDescriptions.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent evt) {
maybeEditAccessDescription(evt);
}
});
jtAccessDescriptions.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(JAccessDescriptions.this);
deleteLastPressed = false;
removeSelectedAccessDescription();
} finally {
CursorUtil.setCursorFree(JAccessDescriptions.this);
}
}
}
@Override
public void keyTyped(KeyEvent evt) {
// Delete on Mac if back space typed
if (OperatingSystem.isMacOs() && evt.getKeyChar() == 0x08) {
try {
CursorUtil.setCursorBusy(JAccessDescriptions.this);
removeSelectedAccessDescription();
} finally {
CursorUtil.setCursorFree(JAccessDescriptions.this);
}
}
}
});
jspAccessDescriptions = PlatformUtil.createScrollPane(jtAccessDescriptions, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
jspAccessDescriptions.getViewport().setBackground(jtAccessDescriptions.getBackground());
this.setLayout(new BorderLayout(5, 5));
setPreferredSize(new Dimension(400, 150));
add(jspAccessDescriptions, BorderLayout.CENTER);
add(jpAccessDescriptionButtons, BorderLayout.EAST);
populate();
}
Aggregations