private void selfUpdate() { URL url = updateUrl; if (url != null) { SelfUpdater downloader = new SelfUpdater(launcher, url); ObservableFuture<File> future = new ObservableFuture<File>( launcher.getExecutor().submit(downloader), downloader); Futures.addCallback(future, new FutureCallback<File>() { @Override public void onSuccess(File result) { selfUpdateButton.setVisible(false); SwingHelper.showMessageDialog( LauncherFrame.this, _("launcher.selfUpdateComplete"), _("launcher.selfUpdateCompleteTitle"), null, JOptionPane.INFORMATION_MESSAGE); } @Override public void onFailure(Throwable t) { } }, SwingExecutor.INSTANCE); ProgressDialog.showProgress(this, future, _("launcher.selfUpdatingTitle"), _("launcher.selfUpdatingStatus")); SwingHelper.addErrorDialogCallback(this, future); } else { selfUpdateButton.setVisible(false); } }
private void initComponents() { webView = WebpagePanel.forURL(launcher.getNewsURL(), false); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, instanceScroll, webView); configureFeaturesCheck.setSelected(false); instancesTable.setModel(instancesModel); launchButton.setFont(launchButton.getFont().deriveFont(Font.BOLD)); splitPane.setDividerLocation(200); splitPane.setDividerSize(4); SwingHelper.flattenJSplitPane(splitPane); buttonsPanel.addElement(refreshButton); buttonsPanel.addElement(configureFeaturesCheck); buttonsPanel.addGlue(); buttonsPanel.addElement(optionsButton); buttonsPanel.addElement(launchButton); container.setLayout(new BorderLayout()); container.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); container.add(splitPane, BorderLayout.CENTER); add(buttonsPanel, BorderLayout.SOUTH); add(container, BorderLayout.CENTER); instancesModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { if (instancesTable.getRowCount() > 0) { instancesTable.setRowSelectionInterval(0, 0); } } }); instancesTable.addMouseListener(new DoubleClickToButtonAdapter(launchButton)); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loadInstances(); checkLauncherUpdate(); } }); optionsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showOptions(); } }); launchButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { launch(); } }); instancesTable.addMouseListener(new PopupMouseAdapter() { @Override protected void showPopup(MouseEvent e) { int index = instancesTable.rowAtPoint(e.getPoint()); Instance selected = null; if (index >= 0) { instancesTable.setRowSelectionInterval(index, index); selected = launcher.getInstances().get(index); } popupInstanceMenu(e.getComponent(), e.getX(), e.getY(), selected); } }); }
private void requestUpdate(URL url) { this.updateUrl = url; selfUpdateButton.setVisible(true); }