use of javax.swing.event.ListSelectionListener 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 javax.swing.event.ListSelectionListener 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 javax.swing.event.ListSelectionListener 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();
}
use of javax.swing.event.ListSelectionListener in project keystore-explorer by kaikramer.
the class JPolicyMappings method initComponents.
private void initComponents() {
jbAdd = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JPolicyMappings.jbAdd.image")))));
jbAdd.setMargin(new Insets(2, 2, 0, 0));
jbAdd.setToolTipText(res.getString("JPolicyMappings.jbAdd.tooltip"));
jbAdd.setMnemonic(res.getString("JPolicyMappings.jbAdd.mnemonic").charAt(0));
jbAdd.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(JPolicyMappings.this);
addPressed();
} finally {
CursorUtil.setCursorFree(JPolicyMappings.this);
}
}
});
jbEdit = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JPolicyMappings.jbEdit.image")))));
jbEdit.setMargin(new Insets(2, 2, 0, 0));
jbEdit.setToolTipText(res.getString("JPolicyMappings.jbEdit.tooltip"));
jbEdit.setMnemonic(res.getString("JPolicyMappings.jbEdit.mnemonic").charAt(0));
jbEdit.setEnabled(false);
jbEdit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(JPolicyMappings.this);
editPressed();
} finally {
CursorUtil.setCursorFree(JPolicyMappings.this);
}
}
});
jbRemove = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JPolicyMappings.jbRemove.image")))));
jbRemove.setMargin(new Insets(2, 2, 0, 0));
jbRemove.setToolTipText(res.getString("JPolicyMappings.jbRemove.tooltip"));
jbRemove.setMnemonic(res.getString("JPolicyMappings.jbRemove.mnemonic").charAt(0));
jbRemove.setEnabled(false);
jbRemove.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(JPolicyMappings.this);
removePressed();
} finally {
CursorUtil.setCursorFree(JPolicyMappings.this);
}
}
});
jpPolicyMappingButtons = new JPanel();
jpPolicyMappingButtons.setLayout(new BoxLayout(jpPolicyMappingButtons, BoxLayout.Y_AXIS));
jpPolicyMappingButtons.add(Box.createVerticalGlue());
jpPolicyMappingButtons.add(jbAdd);
jpPolicyMappingButtons.add(Box.createVerticalStrut(3));
jpPolicyMappingButtons.add(jbEdit);
jpPolicyMappingButtons.add(Box.createVerticalStrut(3));
jpPolicyMappingButtons.add(jbRemove);
jpPolicyMappingButtons.add(Box.createVerticalGlue());
PolicyMappingsTableModel policyMappingsTableModel = new PolicyMappingsTableModel();
jtPolicyMappings = new JKseTable(policyMappingsTableModel);
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(policyMappingsTableModel);
sorter.setComparator(0, new PolicyMappingsTableModel.IssuerDomainPolicyComparator());
sorter.setComparator(1, new PolicyMappingsTableModel.SubjectDomainPolicyComparator());
jtPolicyMappings.setRowSorter(sorter);
jtPolicyMappings.setShowGrid(false);
jtPolicyMappings.setRowMargin(0);
jtPolicyMappings.getColumnModel().setColumnMargin(0);
jtPolicyMappings.getTableHeader().setReorderingAllowed(false);
jtPolicyMappings.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS);
jtPolicyMappings.setRowHeight(Math.max(18, jtPolicyMappings.getRowHeight()));
for (int i = 0; i < jtPolicyMappings.getColumnCount(); i++) {
TableColumn column = jtPolicyMappings.getColumnModel().getColumn(i);
column.setHeaderRenderer(new PolicyMappingsTableHeadRend(jtPolicyMappings.getTableHeader().getDefaultRenderer()));
column.setCellRenderer(new PolicyMappingsTableCellRend());
}
ListSelectionModel selectionModel = jtPolicyMappings.getSelectionModel();
selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
selectionModel.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent evt) {
if (!evt.getValueIsAdjusting()) {
updateButtonControls();
}
}
});
jtPolicyMappings.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent evt) {
maybeEditPolicyMapping(evt);
}
});
jtPolicyMappings.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(JPolicyMappings.this);
deleteLastPressed = false;
removeSelectedPolicyMapping();
} finally {
CursorUtil.setCursorFree(JPolicyMappings.this);
}
}
}
@Override
public void keyTyped(KeyEvent evt) {
// Delete on Mac if back space typed
if (OperatingSystem.isMacOs() && evt.getKeyChar() == 0x08) {
try {
CursorUtil.setCursorBusy(JPolicyMappings.this);
removeSelectedPolicyMapping();
} finally {
CursorUtil.setCursorFree(JPolicyMappings.this);
}
}
}
});
jspPolicyMappings = PlatformUtil.createScrollPane(jtPolicyMappings, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
jspPolicyMappings.getViewport().setBackground(jtPolicyMappings.getBackground());
this.setLayout(new BorderLayout(5, 5));
setPreferredSize(new Dimension(400, 150));
add(jspPolicyMappings, BorderLayout.CENTER);
add(jpPolicyMappingButtons, BorderLayout.EAST);
populate();
}
use of javax.swing.event.ListSelectionListener in project cytoscape-impl by cytoscape.
the class BrowserTable method init.
// ==[ PRIVATE METHODS ]============================================================================================
protected void init() {
final JTableHeader header = getTableHeader();
header.setOpaque(false);
header.setDefaultRenderer(new BrowserTableHeaderRenderer(serviceRegistrar.getService(IconManager.class)));
header.getColumnModel().setColumnSelectionAllowed(true);
header.addMouseMotionListener(this);
header.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
maybeShowHeaderPopup(e);
}
@Override
public void mouseReleased(final MouseEvent e) {
maybeShowHeaderPopup(e);
}
});
setSelectionModel(new BrowserTableListSelectionModel());
setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
addMouseListener(this);
getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(final ListSelectionEvent e) {
if (!e.getValueIsAdjusting() && !ignoreRowSelectionEvents)
selectFromTable();
}
});
}
Aggregations