use of javax.swing.event.ListSelectionEvent in project gradle by gradle.
the class AbstractFilterEditorPanel method createListPanel.
private Component createListPanel() {
model = new DefaultListModel();
list = new JList(model);
list.setCellRenderer(new FilterRenderer());
list.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
enableAppropriately();
}
}
});
return new JScrollPane(list);
}
use of javax.swing.event.ListSelectionEvent in project zaproxy by zaproxy.
the class ManageAddOnsDialog method getUninstalledAddOnsTable.
private JXTable getUninstalledAddOnsTable() {
if (uninstalledAddOnsTable == null) {
uninstalledAddOnsTable = new JXTable();
uninstalledAddOnsModel.addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
getInstallButton().setEnabled(uninstalledAddOnsModel.canIinstallSelected());
}
});
uninstalledAddOnsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
getAddOnInfoButton().setEnabled(false);
if (DesktopUtils.canOpenUrlInBrowser() && getUninstalledAddOnsTable().getSelectedRowCount() == 1) {
//convertRowIndexToModel in-case they sorted
AddOnWrapper ao = uninstalledAddOnsModel.getAddOnWrapper(getUninstalledAddOnsTable().convertRowIndexToModel(getUninstalledAddOnsTable().getSelectedRow()));
if (ao != null && ao.getAddOn().getInfo() != null) {
getAddOnInfoButton().setEnabled(true);
}
}
}
});
uninstalledAddOnsTable.setModel(uninstalledAddOnsModel);
//Icon
uninstalledAddOnsTable.getColumnModel().getColumn(0).setMaxWidth(20);
//Icon doesn't need sorting
uninstalledAddOnsTable.getColumnExt(0).setSortable(false);
//Status
uninstalledAddOnsTable.getColumnModel().getColumn(1).setPreferredWidth(50);
//Name
uninstalledAddOnsTable.getColumnModel().getColumn(2).setPreferredWidth(150);
//Description
uninstalledAddOnsTable.getColumnModel().getColumn(3).setPreferredWidth(300);
//Description doesn't need sorting
uninstalledAddOnsTable.getColumnExt(3).setSortable(false);
//Update (version number)
uninstalledAddOnsTable.getColumnModel().getColumn(4).setPreferredWidth(60);
//Update doesn't need sorting
uninstalledAddOnsTable.getColumnExt(4).setSortable(false);
//Checkbox
uninstalledAddOnsTable.getColumnModel().getColumn(5).setPreferredWidth(40);
//Checkbox doesn't need sorting
uninstalledAddOnsTable.getColumnExt(5).setSortable(false);
//Default sort by status (column 1) descending (Release, Beta, Alpha), and name (column 2) ascending
List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>(2);
sortKeys.add(new RowSorter.SortKey(1, SortOrder.DESCENDING));
sortKeys.add(new RowSorter.SortKey(2, SortOrder.ASCENDING));
uninstalledAddOnsTable.getRowSorter().setSortKeys(sortKeys);
DefaultAddOnToolTipHighlighter toolTipHighlighter = new DefaultAddOnToolTipHighlighter(UninstalledAddOnsTableModel.COLUMN_ADD_ON_WRAPPER);
for (int i = 1; i < uninstalledAddOnsTable.getColumnCount(); i++) {
uninstalledAddOnsTable.getColumnExt(i).addHighlighter(toolTipHighlighter);
}
uninstalledAddOnsTable.getColumnExt(0).setCellRenderer(new DefaultTableRenderer(new MappedValue(StringValues.EMPTY, IconValues.NONE), JLabel.CENTER));
uninstalledAddOnsTable.getColumnExt(0).setHighlighters(new CompoundHighlighter(new WarningRunningIssuesHighlighter(AddOnsTableModel.COLUMN_ADD_ON_WRAPPER), new WarningRunningIssuesToolTipHighlighter(UninstalledAddOnsTableModel.COLUMN_ADD_ON_WRAPPER)));
uninstalledAddOnsTable.getColumnExt(5).addHighlighter(new DisableSelectionHighlighter(UninstalledAddOnsTableModel.COLUMN_ADD_ON_WRAPPER));
}
return uninstalledAddOnsTable;
}
use of javax.swing.event.ListSelectionEvent in project zaproxy by zaproxy.
the class PolicyManagerDialog method getParamsTable.
private JTable getParamsTable() {
if (paramsTable == null) {
paramsTable = new JTable();
paramsTable.setModel(getParamsModel());
paramsTable.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
if (e.getClickCount() >= 2) {
int row = paramsTable.rowAtPoint(e.getPoint());
if (row >= 0) {
String name = (String) getParamsModel().getValueAt(row, 0);
if (name != null) {
try {
extension.showPolicyDialog(PolicyManagerDialog.this, name);
} catch (ConfigurationException e1) {
logger.error(e1.getMessage(), e1);
}
}
}
}
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
});
paramsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (getParamsTable().getSelectedRowCount() == 0) {
getModifyButton().setEnabled(false);
getRemoveButton().setEnabled(false);
getExportButton().setEnabled(false);
} else if (getParamsTable().getSelectedRowCount() == 1) {
getModifyButton().setEnabled(true);
// Dont let the last policy be removed
getRemoveButton().setEnabled(getParamsModel().getRowCount() > 1);
getExportButton().setEnabled(true);
} else {
getModifyButton().setEnabled(false);
getRemoveButton().setEnabled(false);
getExportButton().setEnabled(false);
}
}
});
}
return paramsTable;
}
use of javax.swing.event.ListSelectionEvent in project azure-tools-for-java by Microsoft.
the class WebAppDeployDialog method createUIComponents.
private void createUIComponents() {
DefaultTableModel tableModel = new DefaultTableModel() {
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
};
tableModel.addColumn("Name");
tableModel.addColumn("JDK");
tableModel.addColumn("Web container");
tableModel.addColumn("Resource group");
table = new JBTable(tableModel);
table.setRowSelectionAllowed(true);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent event) {
if (event.getValueIsAdjusting())
return;
//System.out.println("row : " + table.getValueAt(table.getSelectedRow(), 0).toString());
fillAppServiceDetails();
}
});
AnActionButton refreshAction = new AnActionButton("Refresh", AllIcons.Actions.Refresh) {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
refreshAppServices();
}
};
ToolbarDecorator tableToolbarDecorator = ToolbarDecorator.createDecorator(table).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
createAppService();
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
deleteAppService();
}
}).setRemoveActionUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
return table.getSelectedRow() != -1;
}
}).disableUpDownActions().addExtraActions(refreshAction);
panelTable = tableToolbarDecorator.createPanel();
}
use of javax.swing.event.ListSelectionEvent in project pcgen by PCGen.
the class CampaignPanel method setupDisplay.
/**
* @see pcgen.gui2.converter.panel.ConvertSubPanel#setupDisplay(javax.swing.JPanel, pcgen.cdom.base.CDOMObject)
*/
@Override
public void setupDisplay(JPanel panel, final CDOMObject pc) {
panel.setLayout(new GridBagLayout());
JLabel introLabel = new JLabel("Please select the Campaign(s) to Convert:");
GridBagConstraints gbc = new GridBagConstraints();
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
gbc.insets = new Insets(25, 25, 5, 25);
panel.add(introLabel, gbc);
final CampaignTableModel model = new CampaignTableModel(gameModeCampaigns, folderName);
final JTable table = new JTable(model) {
//Implement table cell tool tips.
@Override
public String getToolTipText(MouseEvent e) {
java.awt.Point p = e.getPoint();
int rowIndex = rowAtPoint(p);
int colIndex = columnAtPoint(p);
String tip = String.valueOf(getValueAt(rowIndex, colIndex));
return tip;
}
};
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent event) {
pc.removeListFor(ListKey.CAMPAIGN);
int[] selRows = table.getSelectedRows();
if (selRows.length == 0) {
saveSourceSelection(pc);
fireProgressEvent(ProgressEvent.NOT_ALLOWED);
} else {
for (int row : selRows) {
Campaign selCampaign = (Campaign) model.getValueAt(row, 0);
pc.addToListFor(ListKey.CAMPAIGN, selCampaign);
}
saveSourceSelection(pc);
fireProgressEvent(ProgressEvent.ALLOWED);
}
}
});
JScrollPane listScroller = new JScrollPane(table);
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0);
gbc.fill = GridBagConstraints.BOTH;
panel.add(listScroller, gbc);
initSourceSelection(model, table);
}
Aggregations