use of javax.swing.JButton in project lombok by rzwitserloot.
the class InstallerGUI method buildIdeArea.
private Component buildIdeArea() {
JPanel container = new JPanel();
container.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.anchor = GridBagConstraints.WEST;
constraints.insets = new Insets(8, 0, 0, 16);
container.add(new JLabel(IDE_TITLE), constraints);
constraints.gridy = 1;
container.add(new JLabel(IDE_EXPLANATION), constraints);
constraints.gridy = 2;
loadingExpl = Box.createHorizontalBox();
loadingExpl.add(new JLabel(new ImageIcon(Installer.class.getResource("loading.gif"))));
loadingExpl.add(new JLabel(IDE_LOADING_EXPLANATION));
container.add(loadingExpl, constraints);
constraints.weightx = 1.0;
constraints.gridy = 3;
constraints.fill = GridBagConstraints.HORIZONTAL;
idesList = new IdesList();
JScrollPane idesListScroll = new JScrollPane(idesList);
idesListScroll.setBackground(Color.WHITE);
idesListScroll.getViewport().setBackground(Color.WHITE);
container.add(idesListScroll, constraints);
Thread findIdesThread = new Thread() {
@Override
public void run() {
try {
final List<IdeLocation> locations = new ArrayList<IdeLocation>();
final List<CorruptedIdeLocationException> problems = new ArrayList<CorruptedIdeLocationException>();
Installer.autoDiscover(locations, problems);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
for (IdeLocation location : locations) {
try {
idesList.addLocation(location);
} catch (Throwable t) {
handleException(t);
}
}
for (CorruptedIdeLocationException problem : problems) {
problem.showDialog(appWindow);
}
loadingExpl.setVisible(false);
if (locations.size() + problems.size() == 0) {
JOptionPane.showMessageDialog(appWindow, "I can't find any IDEs on your computer.\n" + "If you have IDEs installed on this computer, please use the " + "'Specify Location...' button to manually point out the \n" + "location of your IDE installation to me. Thanks!", "Can't find IDE", JOptionPane.INFORMATION_MESSAGE);
}
}
});
} catch (Throwable t) {
handleException(t);
}
}
};
findIdesThread.start();
Box buttonBar = Box.createHorizontalBox();
JButton specifyIdeLocationButton = new JButton("Specify location...");
buttonBar.add(specifyIdeLocationButton);
specifyIdeLocationButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
final List<Pattern> exeNames = Installer.getIdeExecutableNames();
String file = null;
if (OsUtils.getOS() == OS.MAC_OS_X) {
FileDialog chooser = new FileDialog(appWindow);
chooser.setMode(FileDialog.LOAD);
chooser.setFilenameFilter(new FilenameFilter() {
@Override
public boolean accept(File dir, String fileName) {
for (Pattern exeName : exeNames) if (exeName.matcher(fileName).matches())
return true;
return false;
}
});
chooser.setVisible(true);
if (chooser.getDirectory() != null && chooser.getFile() != null) {
file = new File(chooser.getDirectory(), chooser.getFile()).getAbsolutePath();
}
} else {
JFileChooser chooser = new JFileChooser();
chooser.setAcceptAllFileFilterUsed(false);
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
chooser.setFileFilter(new FileFilter() {
@Override
public boolean accept(File f) {
if (f.isDirectory())
return true;
for (Pattern exeName : exeNames) if (exeName.matcher(f.getName()).matches())
return true;
return false;
}
@Override
public String getDescription() {
return "IDE Installation";
}
});
switch(chooser.showDialog(appWindow, "Select")) {
case JFileChooser.APPROVE_OPTION:
file = chooser.getSelectedFile().getAbsolutePath();
}
}
if (file != null) {
try {
IdeLocation loc = Installer.tryAllProviders(file);
if (loc != null)
idesList.addLocation(loc);
else
JOptionPane.showMessageDialog(appWindow, "I can't find any IDE that lombok supports at location: " + file, "No IDE found", JOptionPane.WARNING_MESSAGE);
} catch (CorruptedIdeLocationException e) {
e.showDialog(appWindow);
} catch (Throwable t) {
handleException(t);
}
}
}
});
buttonBar.add(Box.createHorizontalGlue());
installButton = new JButton("Install / Update");
buttonBar.add(installButton);
installButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
List<IdeLocation> locationsToInstall = new ArrayList<IdeLocation>(idesList.getSelectedIdes());
if (locationsToInstall.isEmpty()) {
JOptionPane.showMessageDialog(appWindow, "You haven't selected any IDE installations!.", "No Selection", JOptionPane.WARNING_MESSAGE);
return;
}
install(locationsToInstall);
}
});
constraints.gridy = 4;
constraints.weightx = 0;
container.add(buttonBar, constraints);
constraints.gridy = 5;
constraints.fill = GridBagConstraints.NONE;
JHyperLink showMe = new JHyperLink("Show me what this installer will do to my IDE installation.");
container.add(showMe, constraints);
showMe.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
showWhatIDo();
}
});
constraints.gridy = 6;
uninstallButton = new JHyperLink("Uninstall lombok from selected IDE installations.");
uninstallPlaceholder = new JLabel("<html> </html>");
uninstallButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
List<IdeLocation> locationsToUninstall = new ArrayList<IdeLocation>();
for (IdeLocation location : idesList.getSelectedIdes()) {
if (location.hasLombok())
locationsToUninstall.add(location);
}
if (locationsToUninstall.isEmpty()) {
JOptionPane.showMessageDialog(appWindow, "You haven't selected any IDE installations that have been lombok-enabled.", "No Selection", JOptionPane.WARNING_MESSAGE);
return;
}
uninstall(locationsToUninstall);
}
});
container.add(uninstallButton, constraints);
uninstallPlaceholder.setVisible(false);
container.add(uninstallPlaceholder, constraints);
container.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH, 296));
return container;
}
use of javax.swing.JButton in project lombok by rzwitserloot.
the class InstallerGUI method buildUninstallArea.
private Component buildUninstallArea() {
JPanel container = new JPanel();
container.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.anchor = GridBagConstraints.WEST;
container.add(new JLabel(UNINSTALL_TITLE), constraints);
constraints.gridy = 1;
constraints.insets = new Insets(8, 0, 0, 16);
container.add(new JLabel(UNINSTALL_EXPLANATION), constraints);
uninstallBox = Box.createVerticalBox();
constraints.gridy = 2;
constraints.fill = GridBagConstraints.HORIZONTAL;
container.add(uninstallBox, constraints);
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.gridy = 3;
container.add(new JLabel("Are you sure?"), constraints);
Box buttonBar = Box.createHorizontalBox();
JButton noButton = new JButton("No - Don't uninstall");
buttonBar.add(noButton);
buttonBar.add(Box.createHorizontalGlue());
JButton yesButton = new JButton("Yes - uninstall Lombok");
buttonBar.add(yesButton);
noButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
uninstallArea.setVisible(false);
javacArea.setVisible(true);
ideArea.setVisible(true);
appWindow.pack();
}
});
yesButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
doUninstall();
}
});
constraints.gridy = 4;
container.add(buttonBar, constraints);
container.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH, 415));
return container;
}
use of javax.swing.JButton in project lombok by rzwitserloot.
the class InstallerGUI method buildHowIWorkArea.
private Component buildHowIWorkArea() {
JPanel container = new JPanel();
container.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.anchor = GridBagConstraints.WEST;
container.add(new JLabel(HOW_I_WORK_TITLE), constraints);
constraints.gridy = 1;
constraints.insets = new Insets(8, 0, 0, 16);
container.add(new JLabel(String.format(HOW_I_WORK_EXPLANATION, File.separator)), constraints);
Box buttonBar = Box.createHorizontalBox();
JButton backButton = new JButton("Okay - Good to know!");
buttonBar.add(Box.createHorizontalGlue());
buttonBar.add(backButton);
backButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
howIWorkArea.setVisible(false);
javacArea.setVisible(true);
ideArea.setVisible(true);
successArea.setVisible(false);
appWindow.pack();
}
});
constraints.gridy = 2;
container.add(buttonBar, constraints);
container.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH, 415));
return container;
}
use of javax.swing.JButton in project jadx by skylot.
the class LogViewer method initUI.
public final void initUI() {
textPane = new RSyntaxTextArea();
textPane.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
JPanel controlPane = new JPanel();
controlPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
@SuppressWarnings("unchecked") final JComboBox cb = new JComboBox(LEVEL_ITEMS);
cb.setSelectedItem(level);
cb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int i = cb.getSelectedIndex();
level = LEVEL_ITEMS[i];
registerLogListener();
}
});
JLabel levelLabel = new JLabel(NLS.str("log.level"));
levelLabel.setLabelFor(cb);
controlPane.add(levelLabel);
controlPane.add(cb);
JScrollPane scrollPane = new JScrollPane(textPane);
JButton close = new JButton(NLS.str("tabs.close"));
close.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
close();
}
});
close.setAlignmentX(0.5f);
Container contentPane = getContentPane();
contentPane.add(controlPane, BorderLayout.PAGE_START);
contentPane.add(scrollPane, BorderLayout.CENTER);
contentPane.add(close, BorderLayout.PAGE_END);
setTitle("Log Viewer");
pack();
setSize(800, 600);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setModalityType(ModalityType.MODELESS);
setLocationRelativeTo(null);
}
use of javax.swing.JButton in project jadx by skylot.
the class TabbedPane method makeTabComponent.
private Component makeTabComponent(final ContentPanel contentPanel) {
JNode node = contentPanel.getNode();
String name = node.makeLongString();
final JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 3, 0));
panel.setOpaque(false);
final JLabel label = new JLabel(name);
label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
label.setIcon(node.getIcon());
final JButton button = new JButton();
button.setIcon(ICON_CLOSE_INACTIVE);
button.setRolloverIcon(ICON_CLOSE);
button.setRolloverEnabled(true);
button.setOpaque(false);
button.setUI(new BasicButtonUI());
button.setContentAreaFilled(false);
button.setFocusable(false);
button.setBorder(null);
button.setBorderPainted(false);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
closeCodePanel(contentPanel);
}
});
panel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isMiddleMouseButton(e)) {
closeCodePanel(contentPanel);
} else if (SwingUtilities.isRightMouseButton(e)) {
JPopupMenu menu = createTabPopupMenu(contentPanel);
menu.show(panel, e.getX(), e.getY());
} else {
// TODO: make correct event delegation to tabbed pane
setSelectedComponent(contentPanel);
}
}
});
panel.add(label);
panel.add(button);
panel.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
return panel;
}
Aggregations