@Override
public String getToolTipText(MouseEvent e) {
java.awt.Point p = e.getPoint();
int rowIndex = rowAtPoint(p);
DownloadPlugins plugin = plugins.get(rowIndex);
return plugin.htmlString();
}
};
refresh(table, cols);
table.setRowHeight(22);
table.setIntercellSpacing(new Dimension(8, 0));
// Define column widths
TableColumn nameColumn = table.getColumnModel().getColumn(0);
nameColumn.setMinWidth(70);
TableColumn versionColumn = table.getColumnModel().getColumn(2);
versionColumn.setPreferredWidth(45);
TableColumn ratingColumn = table.getColumnModel().getColumn(2);
ratingColumn.setPreferredWidth(45);
TableColumn authorColumn = table.getColumnModel().getColumn(3);
authorColumn.setMinWidth(150);
TableColumn descriptionColumn = table.getColumnModel().getColumn(4);
descriptionColumn.setMinWidth(300);
JScrollPane pane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
pane.setBorder(BorderFactory.createEmptyBorder());
pane.setPreferredSize(new Dimension(200, 139));
builder.add(pane, FormLayoutUtil.flip(cc.xyw(1, 3, 9), colSpec, orientation));
CustomJButton install = new CustomJButton(Messages.getString("NetworkTab.39"));
builder.add(install, FormLayoutUtil.flip(cc.xy(1, 5), colSpec, orientation));
install.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!ExternalFactory.localPluginsInstalled()) {
JOptionPane.showMessageDialog(
looksFrame,
Messages.getString("NetworkTab.40")
);
return;
}
if (!configuration.isAdmin()) {
JOptionPane.showMessageDialog(
looksFrame,
Messages.getString("PluginTab.15"),
Messages.getString("Dialog.PermissionsError"),
JOptionPane.ERROR_MESSAGE
);
return;
}
final int[] rows = table.getSelectedRows();
JPanel panel = new JPanel();
GridLayout layout = new GridLayout(3, 1);
panel.setLayout(layout);
final JFrame frame = new JFrame(Messages.getString("NetworkTab.46"));
frame.setSize(250, 110);
JProgressBar progressBar = new JProgressBar();
progressBar.setIndeterminate(true);
panel.add(progressBar);
final JLabel label = new JLabel("");
final JLabel inst = new JLabel("");
panel.add(inst);
panel.add(label);
frame.add(panel);
// Center the installation progress window
frame.setLocationRelativeTo(null);
Runnable r = new Runnable() {
@Override
public void run() {
for (int i = 0; i < rows.length; i++) {
DownloadPlugins plugin = plugins.get(rows[i]);
if (plugin.isOld()) {
// This plugin requires newer UMS
// display error and skip it.
JOptionPane.showMessageDialog(
looksFrame,
"Plugin " + plugin.getName() + " requires a newer version of UMS. Please upgrade.",
"Version Error",
JOptionPane.ERROR_MESSAGE
);
frame.setVisible(false);
continue;
}
frame.setVisible(true);
inst.setText(Messages.getString("NetworkTab.50") + ": " + plugin.getName());
try {
plugin.install(label);
} catch (Exception e) {
LOGGER.debug("An error occurred when trying to install the plugin: " + plugin.getName());
LOGGER.debug("Full error: " + e);
}
}
frame.setVisible(false);
}