use of java.awt.event.ComponentEvent in project cytoscape-impl by cytoscape.
the class CheckForUpdatesPanel method initComponents.
private void initComponents() {
updatesAvailableLabel = new JLabel("0 updates available.");
installSelectedButton = new JButton("Update Selected");
installAllButton = new JButton("Update All");
updatesScrollPane = new JScrollPane();
updatesTable = new JTable();
lastCheckForUpdatesLabel = new JLabel("Last check for updates:");
updateCheckTimeLabel = new JLabel("Today, at 6:00 pm");
descriptionLabel = new JLabel("Update Description:");
descriptionScrollPane = new JScrollPane();
descriptionTextArea = new JTextArea();
manageUpdateSites = new JButton("Manage Sites...");
installSelectedButton.setEnabled(false);
installSelectedButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
installUpdates(getSelectedUpdates());
}
});
installAllButton.setEnabled(false);
installAllButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
installUpdates(updateManager.getUpdates());
}
});
updatesTable.setModel(new DefaultTableModel(new Object[][] {}, new String[] { "App Name", "Version" }) {
boolean[] canEdit = new boolean[] { false, false };
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit[columnIndex];
}
});
updatesScrollPane.setViewportView(updatesTable);
descriptionTextArea.setEditable(false);
descriptionTextArea.setLineWrap(true);
descriptionTextArea.setWrapStyleWord(true);
descriptionTextArea.setFocusable(false);
descriptionScrollPane.setViewportView(descriptionTextArea);
manageUpdateSites.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
manageUpdateSitesActionPerformed(evt);
}
});
LookAndFeelUtil.equalizeSize(installSelectedButton, installAllButton);
final GroupLayout layout = new GroupLayout(this);
setLayout(layout);
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(true);
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(updatesAvailableLabel).addGap(10, 20, Short.MAX_VALUE).addComponent(lastCheckForUpdatesLabel).addComponent(updateCheckTimeLabel)).addComponent(updatesScrollPane, DEFAULT_SIZE, 652, Short.MAX_VALUE).addComponent(descriptionLabel).addComponent(descriptionScrollPane).addGroup(layout.createSequentialGroup().addComponent(installSelectedButton).addComponent(installAllButton).addGap(10, 20, Short.MAX_VALUE).addComponent(manageUpdateSites)));
layout.setVerticalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(Alignment.CENTER, false).addComponent(updatesAvailableLabel).addComponent(lastCheckForUpdatesLabel).addComponent(updateCheckTimeLabel)).addComponent(updatesScrollPane, DEFAULT_SIZE, 327, Short.MAX_VALUE).addComponent(descriptionLabel, PREFERRED_SIZE, 16, PREFERRED_SIZE).addComponent(descriptionScrollPane, PREFERRED_SIZE, 106, PREFERRED_SIZE).addGroup(layout.createParallelGroup(Alignment.CENTER, false).addComponent(installSelectedButton).addComponent(installAllButton).addComponent(manageUpdateSites)));
updateManager.addUpdatesChangedListener(new UpdatesChangedListener() {
@Override
public void updatesChanged(UpdatesChangedEvent event) {
int updateCount = updateManager.getUpdates().size();
updatesAvailableLabel.setText(updateCount + " " + (updateCount == 1 ? "update" : "updates") + " available.");
Calendar lastUpdateCheckTime = updateManager.getLastUpdateCheckTime();
int minute = lastUpdateCheckTime.get(Calendar.MINUTE);
updateCheckTimeLabel.setText("Today, at " + (lastUpdateCheckTime.get(Calendar.HOUR) == 0 ? "12" : lastUpdateCheckTime.get(Calendar.HOUR)) + ":" + (minute < 10 ? "0" : "") + minute + " " + (lastUpdateCheckTime.get(Calendar.AM_PM) == Calendar.AM ? "am" : "pm"));
repopulateUpdatesTable();
// Enable/disable the update all button depending on update availability
if (event.getSource().getUpdates().size() > 0) {
if (!installAllButton.isEnabled()) {
installAllButton.setEnabled(true);
}
} else {
if (installAllButton.isEnabled()) {
installAllButton.setEnabled(false);
}
}
}
});
installAllButton.setEnabled(true);
this.addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(ComponentEvent e) {
checkUpdates();
}
});
setupDescriptionListener();
}
use of java.awt.event.ComponentEvent in project cytoscape-impl by cytoscape.
the class CurrentlyInstalledAppsPanel method initComponents.
private void initComponents() {
appsAvailableScrollPane = new JScrollPane();
appsAvailableTable = new JTable();
appsInstalledLabel = new JLabel("0 Apps installed.");
enableSelectedButton = new JButton("Enable");
disableSelectedButton = new JButton("Disable");
uninstallSelectedButton = new JButton("Uninstall");
descriptionLabel = new JLabel("App Information:");
descriptionScrollPane = new JScrollPane();
descriptionTextArea = new JTextArea();
// The table of apps has a hidden first column that contains a reference to the actual App object
appsAvailableTable.setModel(new DefaultTableModel(new Object[][] {}, new String[] { "App", "Name", "Version", "Status" }) {
private static final long serialVersionUID = 919039586559362963L;
boolean[] canEdit = new boolean[] { false, false, false, false };
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit[columnIndex];
}
});
appsAvailableScrollPane.setViewportView(appsAvailableTable);
appsAvailableTable.getColumnModel().getColumn(1).setPreferredWidth(195);
appsAvailableTable.removeColumn(appsAvailableTable.getColumn("App"));
appsAvailableTable.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (table.getValueAt(row, 2).equals(AppStatus.FAILED_TO_LOAD.toString()) || table.getValueAt(row, 2).equals(AppStatus.FAILED_TO_START.toString()))
setForeground(LookAndFeelUtil.getErrorColor());
else
setForeground(null);
return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
}
});
enableSelectedButton.setEnabled(false);
enableSelectedButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
enableSelectedButtonActionPerformed(evt);
}
});
disableSelectedButton.setEnabled(false);
disableSelectedButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
disableSelectedButtonActionPerformed(evt);
}
});
uninstallSelectedButton.setEnabled(false);
uninstallSelectedButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
uninstallSelectedButtonActionPerformed(evt);
}
});
descriptionScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
descriptionTextArea.setEditable(false);
descriptionTextArea.setLineWrap(true);
descriptionTextArea.setWrapStyleWord(true);
descriptionTextArea.setFocusable(false);
descriptionScrollPane.setViewportView(descriptionTextArea);
LookAndFeelUtil.equalizeSize(enableSelectedButton, disableSelectedButton, uninstallSelectedButton);
final GroupLayout layout = new GroupLayout(this);
setLayout(layout);
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(true);
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(appsInstalledLabel).addComponent(appsAvailableScrollPane, DEFAULT_SIZE, 634, Short.MAX_VALUE).addComponent(descriptionLabel).addComponent(descriptionScrollPane).addGroup(layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent(enableSelectedButton).addComponent(disableSelectedButton).addComponent(uninstallSelectedButton).addGap(0, 0, Short.MAX_VALUE)));
layout.setVerticalGroup(layout.createSequentialGroup().addComponent(appsInstalledLabel).addComponent(appsAvailableScrollPane, DEFAULT_SIZE, 311, Short.MAX_VALUE).addComponent(descriptionLabel).addComponent(descriptionScrollPane, PREFERRED_SIZE, 106, PREFERRED_SIZE).addGroup(layout.createParallelGroup(Alignment.CENTER).addComponent(enableSelectedButton).addComponent(disableSelectedButton).addComponent(uninstallSelectedButton)));
// Add listener to obtain descriptions for available apps
this.addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(ComponentEvent e) {
appManager.getWebQuerier().findAppDescriptions(appManager.getApps());
}
});
updateLabels();
}
use of java.awt.event.ComponentEvent in project cytoscape-impl by cytoscape.
the class BiModalJSplitPane method addNotify.
@Override
public void addNotify() {
super.addNotify();
getParent().addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
if (getParent() != null)
dividerLocation = -1;
}
});
}
use of java.awt.event.ComponentEvent in project Spark by igniterealtime.
the class BroadcastDialog method invokeDialog.
/**
* Displays the broadcast dialog.
*/
public void invokeDialog() {
final JDialog dlg;
TitlePanel titlePanel;
// Create the title panel for this dialog
titlePanel = new TitlePanel(Res.getString("title.broadcast.message"), Res.getString("message.enter.broadcast.message"), null, true);
// Construct main panel w/ layout.
final JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.add(titlePanel, BorderLayout.NORTH);
// The user should only be able to close this dialog.
JButton okButton = new JButton(Res.getString("ok"));
JButton closeButton = new JButton(Res.getString("close"));
mainPanel.add(this, BorderLayout.CENTER);
JPanel buttonpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
buttonpanel.add(okButton);
buttonpanel.add(closeButton);
mainPanel.add(buttonpanel, BorderLayout.SOUTH);
dlg = new JDialog(SparkManager.getMainWindow(), Res.getString("broadcast"));
dlg.setContentPane(mainPanel);
dlg.pack();
final Rectangle bounds = LayoutSettingsManager.getLayoutSettings().getBroadcastMessageBounds();
if (bounds == null || bounds.width <= 0 || bounds.height <= 0) {
// Use default settings.
dlg.setSize(800, 600);
dlg.setLocationRelativeTo(null);
} else {
dlg.setBounds(bounds);
}
dlg.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
LayoutSettingsManager.getLayoutSettings().setBroadcastMessageBounds(dlg.getBounds());
}
@Override
public void componentMoved(ComponentEvent e) {
LayoutSettingsManager.getLayoutSettings().setBroadcastMessageBounds(dlg.getBounds());
}
});
dlg.setResizable(false);
// Add listener
okButton.addActionListener(e -> {
try {
if (sendBroadcasts(dlg)) {
dlg.setVisible(false);
}
} catch (SmackException.NotConnectedException e1) {
Log.warning("Unable to broadcast.", e1);
}
});
closeButton.addActionListener(e -> dlg.setVisible(false));
dlg.setVisible(true);
dlg.toFront();
dlg.requestFocus();
messageBox.requestFocus();
}
use of java.awt.event.ComponentEvent in project Spark by igniterealtime.
the class BroadcastHistoryFrame method initComponents.
private void initComponents() {
SearchButton = new javax.swing.JToggleButton();
DateField = new javax.swing.JFormattedTextField();
SearchDate = new javax.swing.JLabel();
Date date = new Date();
Format formatter = new SimpleDateFormat("yyy-MM");
String myDate = formatter.format(date);
DateField.setValue(myDate);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
JScrollPane panelPane = new JScrollPane(BroadcastHistoryArea);
SearchDate.setText(Res.getString("label.broadcast.history.search.date"));
setTitle(Res.getString("title.broadcast.history"));
try {
readFromFile(myDate);
} catch (IOException ex) {
Log.error("Couldn't read from file" + ex.getMessage() + ex.getStackTrace());
}
SearchButton.setText((Res.getString("button.search")));
SearchButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
SearchButtonMouseClicked(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(panelPane, javax.swing.GroupLayout.DEFAULT_SIZE, 533, javax.swing.GroupLayout.DEFAULT_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(SearchDate).addComponent(SearchButton).addComponent(DateField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addGap(22, 22, 22)));
layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(15, 15, 15).addComponent(panelPane, javax.swing.GroupLayout.DEFAULT_SIZE, 350, javax.swing.GroupLayout.DEFAULT_SIZE)).addGroup(layout.createSequentialGroup().addGap(15, 15, 15).addComponent(SearchDate).addGap(10, 10, 10).addComponent(DateField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(10, 10, 10).addComponent(SearchButton))).addContainerGap(15, Short.MAX_VALUE)));
pack();
final Rectangle bounds = LayoutSettingsManager.getLayoutSettings().getBroadcastHistoryBounds();
if (bounds == null || bounds.width <= 0 || bounds.height <= 0) {
// Use default settings.
setLocationRelativeTo(null);
} else {
setBounds(bounds);
}
addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
LayoutSettingsManager.getLayoutSettings().setBroadcastHistoryBounds(getBounds());
}
@Override
public void componentMoved(ComponentEvent e) {
LayoutSettingsManager.getLayoutSettings().setBroadcastHistoryBounds(getBounds());
}
});
}
Aggregations