mirror of
https://github.com/processing/processing4.git
synced 2026-02-13 02:20:45 +01:00
Merge pull request #3452 from Akarshit/gsoc-CMstatus
CM with updated statusPanel and error popup
This commit is contained in:
@@ -88,16 +88,39 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
|
||||
|
||||
|
||||
private void updatePanelOrdering() {
|
||||
int row = 0;
|
||||
for (Entry<Contribution, ContributionPanel> entry : panelByContribution.entrySet()) {
|
||||
if(contributionTab.contributionType != null){
|
||||
int row = 0;
|
||||
for (Entry<Contribution, ContributionPanel> entry : panelByContribution.entrySet()) {
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.fill = GridBagConstraints.HORIZONTAL;
|
||||
c.weightx = 1;
|
||||
c.gridx = 0;
|
||||
c.gridy = row++;
|
||||
c.anchor = GridBagConstraints.NORTH;
|
||||
|
||||
add(entry.getValue(), c);
|
||||
}
|
||||
} else {
|
||||
//TODO This is where the status tab will be made
|
||||
|
||||
int row = 0;
|
||||
for (Entry<Contribution, ContributionPanel> entry : panelByContribution.entrySet()) {
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.fill = GridBagConstraints.HORIZONTAL;
|
||||
c.weightx = 1;
|
||||
c.gridx = 0;
|
||||
c.gridy = row++;
|
||||
c.anchor = GridBagConstraints.NORTH;
|
||||
|
||||
add(entry.getValue(), c);
|
||||
}
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.fill = GridBagConstraints.HORIZONTAL;
|
||||
c.fill = GridBagConstraints.BOTH;
|
||||
c.weightx = 1;
|
||||
c.weighty = 1;
|
||||
c.gridx = 0;
|
||||
c.gridy = row++;
|
||||
c.anchor = GridBagConstraints.NORTH;
|
||||
|
||||
add(entry.getValue(), c);
|
||||
}
|
||||
/*
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
@@ -203,12 +226,12 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
|
||||
|
||||
|
||||
protected void setSelectedPanel(ContributionPanel contributionPanel) {
|
||||
contributionTab.contributionManagerDialog.updateStatusPanel(contributionPanel);
|
||||
if (selectedPanel == contributionPanel) {
|
||||
selectedPanel.setSelected(true);
|
||||
|
||||
} else {
|
||||
|
||||
contributionTab.contributionManagerDialog.updateStatusPanel(contributionPanel);
|
||||
ContributionPanel lastSelected = selectedPanel;
|
||||
selectedPanel = contributionPanel;
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
*/
|
||||
package processing.app.contrib;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -29,6 +31,11 @@ import java.net.SocketTimeoutException;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.text.SimpleAttributeSet;
|
||||
import javax.swing.text.StyleConstants;
|
||||
import javax.swing.text.StyledDocument;
|
||||
|
||||
import processing.app.*;
|
||||
import processing.app.ui.Editor;
|
||||
@@ -50,7 +57,13 @@ public class ContributionManagerDialog {
|
||||
String title;
|
||||
JButton restartButton;
|
||||
StatusPanel statusPanel;
|
||||
|
||||
|
||||
|
||||
JPanel errorPanel;
|
||||
JTextPane errorMessage;
|
||||
JButton tryAgainButton;
|
||||
JButton closeButton;
|
||||
|
||||
// the calling editor, so updates can be applied
|
||||
Editor editor;
|
||||
|
||||
@@ -138,12 +151,24 @@ public class ContributionManagerDialog {
|
||||
tabbedPane.addTab("Updates", null, updatesContributionTab.panel, "Updates");
|
||||
tabbedPane.setMnemonicAt(3, KeyEvent.VK_5);
|
||||
|
||||
GroupLayout layout = new GroupLayout(dialog.getContentPane());
|
||||
dialog.getContentPane().setLayout(layout);
|
||||
tabbedPane.addChangeListener(new ChangeListener() {
|
||||
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
// When the tab is changed update status to the current selected panel
|
||||
ContributionPanel currentPanel = getActiveTab().contributionListPanel
|
||||
.getSelectedPanel();
|
||||
if (currentPanel != null) {
|
||||
getActiveTab().contributionListPanel.setSelectedPanel(currentPanel);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// tabbedPane.setSize(450, 400);
|
||||
buildErrorPanel();
|
||||
setLayoutWithoutError();
|
||||
|
||||
layout.setHorizontalGroup(layout.createParallelGroup().addComponent(tabbedPane).addComponent(statusPanel));
|
||||
layout.setVerticalGroup(layout.createSequentialGroup().addComponent(tabbedPane).addComponent(statusPanel));
|
||||
|
||||
restartButton = new JButton(Language.text("contrib.restart"));
|
||||
restartButton.setVisible(false);
|
||||
restartButton.addActionListener(new ActionListener() {
|
||||
@@ -197,6 +222,103 @@ public class ContributionManagerDialog {
|
||||
dialog.setLocationRelativeTo(null);
|
||||
}
|
||||
|
||||
private void setLayoutWithError() {
|
||||
GroupLayout layout = new GroupLayout(dialog.getContentPane());
|
||||
dialog.getContentPane().setLayout(layout);
|
||||
dialog.setResizable(true);
|
||||
layout.setHorizontalGroup(layout.createParallelGroup()
|
||||
.addComponent(statusPanel).addComponent(errorPanel)
|
||||
.addComponent(tabbedPane));
|
||||
layout.setVerticalGroup(layout
|
||||
.createSequentialGroup()
|
||||
.addComponent(tabbedPane,
|
||||
tabbedPane.getSize().height
|
||||
- errorPanel.getPreferredSize().height - 200,
|
||||
tabbedPane.getSize().height
|
||||
- errorPanel.getPreferredSize().height,
|
||||
GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(errorPanel, GroupLayout.PREFERRED_SIZE,
|
||||
GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(statusPanel, GroupLayout.PREFERRED_SIZE,
|
||||
GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE));
|
||||
errorPanel.setVisible(true);
|
||||
dialog.validate();
|
||||
dialog.pack();
|
||||
dialog.repaint();
|
||||
}
|
||||
|
||||
private void setLayoutWithoutError() {
|
||||
GroupLayout layout = new GroupLayout(dialog.getContentPane());
|
||||
dialog.getContentPane().setLayout(layout);
|
||||
|
||||
layout.setVerticalGroup(layout
|
||||
.createSequentialGroup()
|
||||
.addComponent(tabbedPane)
|
||||
.addComponent(statusPanel));
|
||||
layout.setHorizontalGroup(layout.createParallelGroup()
|
||||
.addComponent(tabbedPane)
|
||||
.addComponent(statusPanel));
|
||||
|
||||
dialog.pack();
|
||||
}
|
||||
|
||||
private void buildErrorPanel(){
|
||||
errorPanel = new JPanel();
|
||||
GroupLayout layout = new GroupLayout(errorPanel);
|
||||
layout.setAutoCreateGaps(true);
|
||||
layout.setAutoCreateContainerGaps(true);
|
||||
errorPanel.setLayout(layout);
|
||||
errorMessage = new JTextPane();
|
||||
errorMessage.setEditable(false);
|
||||
errorMessage.setText("Could not connect to the Processing server. "
|
||||
+ "Contributions cannot be installed or updated without an Internet connection. "
|
||||
+ "Please verify your network connection again, then try connecting again.");
|
||||
errorMessage.setMaximumSize(new Dimension(450, 50));
|
||||
errorMessage.setOpaque(false);
|
||||
|
||||
StyledDocument doc = errorMessage.getStyledDocument();
|
||||
SimpleAttributeSet center = new SimpleAttributeSet();
|
||||
StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
|
||||
doc.setParagraphAttributes(0, doc.getLength(), center, false);
|
||||
|
||||
|
||||
closeButton = new JButton("");
|
||||
closeButton.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
errorPanel.setVisible(false);
|
||||
setLayoutWithoutError();
|
||||
}
|
||||
});
|
||||
tryAgainButton = new JButton("Try Again");
|
||||
tryAgainButton.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO see if this is complete
|
||||
closeButton.doClick();
|
||||
downloadAndUpdateContributionListing(editor.getBase());
|
||||
}
|
||||
});
|
||||
layout.setHorizontalGroup(layout
|
||||
.createSequentialGroup()
|
||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,
|
||||
GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
|
||||
.addComponent(errorMessage).addComponent(tryAgainButton))
|
||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,
|
||||
GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(closeButton));
|
||||
layout.setVerticalGroup(layout
|
||||
.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup().addComponent(errorMessage)
|
||||
.addComponent(closeButton)).addComponent(tryAgainButton));
|
||||
errorPanel.setBackground(Color.BLUE);
|
||||
|
||||
errorPanel.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the window after an OK or Cancel.
|
||||
*/
|
||||
@@ -478,7 +600,6 @@ public class ContributionManagerDialog {
|
||||
//activeTab is required now but should be removed
|
||||
//as there is only one instance of contribListing and it should be present in this class
|
||||
final ContributionTab activeTab = getActiveTab();
|
||||
activeTab.retryConnectingButton.setEnabled(false);
|
||||
activeTab.statusPanel.setMessage(Language
|
||||
.text("contrib.status.downloading_list"));
|
||||
activeTab.contribListing.downloadAvailableList(base, new ContribProgressBar(
|
||||
@@ -507,7 +628,6 @@ public class ContributionManagerDialog {
|
||||
activeTab.updateContributionListing();
|
||||
activeTab.updateCategoryChooser();
|
||||
|
||||
activeTab.retryConnectingButton.setEnabled(true);
|
||||
|
||||
if (error) {
|
||||
if (exception instanceof SocketTimeoutException) {
|
||||
@@ -518,16 +638,18 @@ public class ContributionManagerDialog {
|
||||
.text("contrib.errors.list_download"));
|
||||
}
|
||||
exception.printStackTrace();
|
||||
activeTab.retryConnectingButton.setVisible(true);
|
||||
|
||||
|
||||
setLayoutWithError();
|
||||
|
||||
} else {
|
||||
activeTab.statusPanel.setMessage(Language.text("contrib.status.done"));
|
||||
activeTab.retryConnectingButton.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the currently selected tab
|
||||
|
||||
@@ -98,7 +98,7 @@ class ContributionPanel extends JPanel {
|
||||
private JTextPane descriptionPane;
|
||||
private JLabel notificationLabel;
|
||||
private JButton updateButton;
|
||||
private JProgressBar installProgressBar;
|
||||
JProgressBar installProgressBar;
|
||||
private JButton installRemoveButton;
|
||||
private JPopupMenu contextMenu;
|
||||
private JMenuItem openFolder;
|
||||
@@ -114,7 +114,6 @@ class ContributionPanel extends JPanel {
|
||||
|
||||
StringBuilder description;
|
||||
|
||||
|
||||
ContributionPanel(ContributionListPanel contributionListPanel) {
|
||||
listPanel = contributionListPanel;
|
||||
barButtonCardPane = new JPanel();
|
||||
@@ -316,7 +315,7 @@ class ContributionPanel extends JPanel {
|
||||
|
||||
JPanel barPane = new JPanel();
|
||||
barPane.setOpaque(false);
|
||||
barPane.add(installProgressBar);
|
||||
// barPane.add(installProgressBar);
|
||||
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setOpaque(false);
|
||||
@@ -373,7 +372,7 @@ class ContributionPanel extends JPanel {
|
||||
JPanel barPane = new JPanel();
|
||||
barPane.setOpaque(false);
|
||||
barPane.setInheritsPopupMenu(true);
|
||||
barPane.add(installProgressBar);
|
||||
// barPane.add(installProgressBar);
|
||||
rightPane.add(barPane);
|
||||
|
||||
if (isUpdateInProgress)
|
||||
@@ -387,7 +386,7 @@ class ContributionPanel extends JPanel {
|
||||
JPanel barPane = new JPanel();
|
||||
barPane.setOpaque(false);
|
||||
barPane.setInheritsPopupMenu(true);
|
||||
barPane.add(installProgressBar);
|
||||
// barPane.add(installProgressBar);
|
||||
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setOpaque(false);
|
||||
|
||||
@@ -55,7 +55,6 @@ public class ContributionTab {
|
||||
StatusPanel statusPanel;
|
||||
FilterField filterField;
|
||||
JButton restartButton;
|
||||
JButton retryConnectingButton;
|
||||
JProgressBar progressBar;
|
||||
|
||||
// the calling editor, so updates can be applied
|
||||
@@ -91,6 +90,7 @@ public class ContributionTab {
|
||||
|
||||
filter = type.createFilter();
|
||||
}
|
||||
this.contributionType = type;
|
||||
this.statusPanel = statusPanel;
|
||||
this.contributionManagerDialog = contributionManagerDialog;
|
||||
contribListing = ContributionListing.getInstance();
|
||||
@@ -183,18 +183,6 @@ public class ContributionTab {
|
||||
|
||||
});
|
||||
|
||||
retryConnectingButton = new JButton("Retry");
|
||||
retryConnectingButton.setVisible(false);
|
||||
retryConnectingButton.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
// The message is set to null so that every time the retry button is hit
|
||||
// no previous error is displayed in the status
|
||||
statusPanel.setMessage(null);
|
||||
downloadAndUpdateContributionListing(editor.getBase());
|
||||
}
|
||||
});
|
||||
|
||||
progressBar = new JProgressBar();
|
||||
progressBar.setVisible(false);
|
||||
@@ -366,7 +354,7 @@ public class ContributionTab {
|
||||
// pane.add(filterField, c);
|
||||
// }
|
||||
|
||||
panel.setMinimumSize(new Dimension(450, 400));
|
||||
// panel.setSize(new Dimension(450, 400));//TODO try to remove this
|
||||
}
|
||||
|
||||
|
||||
@@ -445,7 +433,6 @@ public class ContributionTab {
|
||||
|
||||
|
||||
protected void downloadAndUpdateContributionListing(Base base) {
|
||||
retryConnectingButton.setEnabled(false);
|
||||
statusPanel.setMessage(Language.text("contrib.status.downloading_list"));
|
||||
contribListing.downloadAvailableList(base, new ContribProgressBar(progressBar) {
|
||||
|
||||
@@ -472,7 +459,6 @@ public class ContributionTab {
|
||||
updateContributionListing();
|
||||
updateCategoryChooser();
|
||||
|
||||
retryConnectingButton.setEnabled(true);
|
||||
|
||||
if (error) {
|
||||
if (exception instanceof SocketTimeoutException) {
|
||||
@@ -483,11 +469,8 @@ public class ContributionTab {
|
||||
.text("contrib.errors.list_download"));
|
||||
}
|
||||
exception.printStackTrace();
|
||||
retryConnectingButton.setVisible(true);
|
||||
|
||||
} else {
|
||||
statusPanel.setMessage(Language.text("contrib.status.done"));
|
||||
retryConnectingButton.setVisible(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
package processing.app.contrib;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@@ -29,7 +30,6 @@ import javax.swing.GroupLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.JTextPane;
|
||||
import javax.swing.LayoutStyle;
|
||||
import javax.swing.SwingConstants;
|
||||
@@ -45,10 +45,11 @@ class StatusPanel extends JPanel {
|
||||
|
||||
JTextPane label;
|
||||
JButton installButton;
|
||||
JProgressBar installProgressBar;
|
||||
JPanel progressBarPanel;
|
||||
JLabel updateLabel;
|
||||
JButton updateButton;
|
||||
JButton removeButton;
|
||||
GroupLayout layout;
|
||||
|
||||
ContributionListing contributionListing = ContributionListing.getInstance();
|
||||
ContributionManagerDialog contributionManagerDialog;
|
||||
@@ -76,18 +77,24 @@ class StatusPanel extends JPanel {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
StatusPanel.this.contributionManagerDialog.getActiveTab().contributionListPanel
|
||||
.getSelectedPanel().install();
|
||||
ContributionPanel currentPanel = StatusPanel.this.contributionManagerDialog.getActiveTab().contributionListPanel
|
||||
.getSelectedPanel();
|
||||
currentPanel.install();
|
||||
StatusPanel.this.update(currentPanel);
|
||||
}
|
||||
});
|
||||
installProgressBar = new JProgressBar();
|
||||
progressBarPanel = new JPanel();
|
||||
progressBarPanel.setLayout(new BorderLayout());;
|
||||
updateLabel = new JLabel(" ");
|
||||
updateButton = new JButton("Update");
|
||||
updateButton.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
StatusPanel.this.contributionManagerDialog.getActiveTab().contributionListPanel.getSelectedPanel().update();
|
||||
ContributionPanel currentPanel = StatusPanel.this.contributionManagerDialog.getActiveTab().contributionListPanel
|
||||
.getSelectedPanel();
|
||||
currentPanel.update();
|
||||
StatusPanel.this.update(currentPanel);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -96,12 +103,15 @@ class StatusPanel extends JPanel {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
StatusPanel.this.contributionManagerDialog.getActiveTab().contributionListPanel.getSelectedPanel().remove();
|
||||
ContributionPanel currentPanel = StatusPanel.this.contributionManagerDialog.getActiveTab().contributionListPanel
|
||||
.getSelectedPanel();
|
||||
currentPanel.remove();
|
||||
StatusPanel.this.update(currentPanel);
|
||||
}
|
||||
});
|
||||
|
||||
int labelWidth = width != 0 ? width * 3 / 4 : GroupLayout.PREFERRED_SIZE;
|
||||
GroupLayout layout = new GroupLayout(this);
|
||||
layout = new GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
|
||||
layout.setAutoCreateContainerGaps(true);
|
||||
@@ -115,7 +125,7 @@ class StatusPanel extends JPanel {
|
||||
.addGroup(layout
|
||||
.createParallelGroup(GroupLayout.Alignment.CENTER)
|
||||
.addComponent(installButton, BUTTON_WIDTH, BUTTON_WIDTH,
|
||||
BUTTON_WIDTH).addComponent(installProgressBar)
|
||||
BUTTON_WIDTH).addComponent(progressBarPanel)
|
||||
.addComponent(updateLabel).addComponent(updateButton)
|
||||
.addComponent(removeButton)));
|
||||
|
||||
@@ -126,14 +136,14 @@ class StatusPanel extends JPanel {
|
||||
.createSequentialGroup()
|
||||
.addComponent(installButton)
|
||||
.addGroup(layout.createParallelGroup()
|
||||
.addComponent(installProgressBar)
|
||||
.addComponent(progressBarPanel)
|
||||
.addComponent(updateLabel))
|
||||
.addComponent(updateButton).addComponent(removeButton)));
|
||||
|
||||
layout
|
||||
.linkSize(SwingConstants.HORIZONTAL, installButton, installProgressBar, updateButton, removeButton);
|
||||
.linkSize(SwingConstants.HORIZONTAL, installButton, progressBarPanel, updateButton, removeButton);
|
||||
|
||||
installProgressBar.setVisible(false);
|
||||
progressBarPanel.setVisible(false);
|
||||
updateLabel.setVisible(false);
|
||||
|
||||
installButton.setEnabled(false);
|
||||
@@ -164,9 +174,11 @@ class StatusPanel extends JPanel {
|
||||
|
||||
public void update(ContributionPanel panel) {
|
||||
|
||||
progressBarPanel.removeAll();
|
||||
|
||||
label.setText(panel.description.toString());
|
||||
|
||||
updateButton.setEnabled(!contributionListing.hasListDownloadFailed()
|
||||
updateButton.setEnabled(contributionListing.hasDownloadedLatestList()
|
||||
&& (contributionListing.hasUpdates(panel.getContrib()) && !panel
|
||||
.getContrib().isUpdateFlagged()));
|
||||
|
||||
@@ -191,7 +203,7 @@ class StatusPanel extends JPanel {
|
||||
updateButton.setText("Update");
|
||||
}
|
||||
|
||||
installButton.setEnabled(!panel.getContrib().isInstalled() && !contributionListing.hasListDownloadFailed());
|
||||
installButton.setEnabled(!panel.getContrib().isInstalled() && contributionListing.hasDownloadedLatestList());
|
||||
|
||||
|
||||
if(installButton.isEnabled()){
|
||||
@@ -200,10 +212,13 @@ class StatusPanel extends JPanel {
|
||||
updateLabel.setText(currentVersion + " installed");
|
||||
}
|
||||
|
||||
updateLabel.setVisible(true);
|
||||
|
||||
removeButton.setEnabled(panel.getContrib().isInstalled());
|
||||
|
||||
progressBarPanel.add(panel.installProgressBar);
|
||||
if (panel.installProgressBar.isEnabled()) {
|
||||
progressBarPanel.setVisible(true);
|
||||
updateLabel.setVisible(false);
|
||||
progressBarPanel.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user