| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,7 @@ | |||
| 3 | 3 | /* | |
| 4 | 4 | Part of the Processing project - http://processing.org | |
| 5 | 5 | ||
| 6 | - Copyright (c) 2013 The Processing Foundation | ||
| 6 | + Copyright (c) 2013-15 The Processing Foundation | ||
| 7 | 7 | Copyright (c) 2011-12 Ben Fry and Casey Reas | |
| 8 | 8 | ||
| 9 | 9 | This program is free software; you can redistribute it and/or modify | |
@@ -15,52 +15,44 @@ | |||
| 15 | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | 16 | GNU General Public License for more details. | |
| 17 | 17 | ||
| 18 | - You should have received a copy of the GNU General Public License along | ||
| 18 | + You should have received a copy of the GNU General Public License along | ||
| 19 | 19 | with this program; if not, write to the Free Software Foundation, Inc. | |
| 20 | 20 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 | 21 | */ | |
| 22 | 22 | package processing.app.contrib; | |
| 23 | 23 | ||
| 24 | - import java.awt.BorderLayout; | ||
| 25 | 24 | import java.awt.Color; | |
| 26 | 25 | import java.awt.event.ActionEvent; | |
| 27 | 26 | import java.awt.event.ActionListener; | |
| 28 | - import java.text.DateFormat; | ||
| 29 | - import java.util.Date; | ||
| 30 | 27 | ||
| 31 | 28 | import javax.swing.GroupLayout; | |
| 32 | - import javax.swing.ImageIcon; | ||
| 33 | 29 | import javax.swing.JButton; | |
| 34 | 30 | import javax.swing.JLabel; | |
| 35 | 31 | import javax.swing.JPanel; | |
| 36 | 32 | import javax.swing.JProgressBar; | |
| 37 | 33 | import javax.swing.JTextPane; | |
| 38 | 34 | import javax.swing.LayoutStyle; | |
| 39 | 35 | import javax.swing.SwingConstants; | |
| 40 | - import javax.swing.border.EmptyBorder; | ||
| 41 | 36 | import javax.swing.event.HyperlinkEvent; | |
| 42 | 37 | import javax.swing.event.HyperlinkListener; | |
| 43 | 38 | ||
| 44 | 39 | import processing.app.Base; | |
| 45 | - import processing.app.Language; | ||
| 46 | - import processing.app.Toolkit; | ||
| 47 | - | ||
| 48 | 40 | ||
| 49 | 41 | ||
| 50 | 42 | class StatusPanel extends JPanel { | |
| 51 | - | ||
| 43 | + | ||
| 52 | 44 | final int BUTTON_WIDTH = 20; | |
| 53 | - | ||
| 45 | + | ||
| 54 | 46 | JTextPane label; | |
| 55 | 47 | JButton installButton; | |
| 56 | 48 | JProgressBar installProgressBar; | |
| 57 | 49 | JLabel updateLabel; | |
| 58 | 50 | JButton updateButton; | |
| 59 | 51 | JButton removeButton; | |
| 60 | - | ||
| 52 | + | ||
| 61 | 53 | ContributionListing contributionListing = ContributionListing.getInstance(); | |
| 62 | 54 | ContributionManagerDialog contributionManagerDialog; | |
| 63 | - | ||
| 55 | + | ||
| 64 | 56 | public StatusPanel(int width, ContributionManagerDialog contributionManagerDialog) { | |
| 65 | 57 | final int BUTTON_WIDTH = 150; | |
| 66 | 58 | this.contributionManagerDialog = contributionManagerDialog; | |
@@ -81,7 +73,7 @@ public void hyperlinkUpdate(HyperlinkEvent e) { | |||
| 81 | 73 | }); | |
| 82 | 74 | installButton = new JButton("Install"); | |
| 83 | 75 | installButton.addActionListener(new ActionListener() { | |
| 84 | - | ||
| 76 | + | ||
| 85 | 77 | @Override | |
| 86 | 78 | public void actionPerformed(ActionEvent e) { | |
| 87 | 79 | StatusPanel.this.contributionManagerDialog.getActiveTab().contributionListPanel | |
@@ -92,16 +84,16 @@ public void actionPerformed(ActionEvent e) { | |||
| 92 | 84 | updateLabel = new JLabel(" "); | |
| 93 | 85 | updateButton = new JButton("Update"); | |
| 94 | 86 | updateButton.addActionListener(new ActionListener() { | |
| 95 | - | ||
| 87 | + | ||
| 96 | 88 | @Override | |
| 97 | 89 | public void actionPerformed(ActionEvent e) { | |
| 98 | 90 | StatusPanel.this.contributionManagerDialog.getActiveTab().contributionListPanel.getSelectedPanel().update(); | |
| 99 | 91 | } | |
| 100 | 92 | }); | |
| 101 | - | ||
| 93 | + | ||
| 102 | 94 | removeButton = new JButton("Remove"); | |
| 103 | 95 | removeButton.addActionListener(new ActionListener() { | |
| 104 | - | ||
| 96 | + | ||
| 105 | 97 | @Override | |
| 106 | 98 | public void actionPerformed(ActionEvent e) { | |
| 107 | 99 | StatusPanel.this.contributionManagerDialog.getActiveTab().contributionListPanel.getSelectedPanel().remove(); | |
@@ -111,7 +103,7 @@ public void actionPerformed(ActionEvent e) { | |||
| 111 | 103 | int labelWidth = width != 0 ? width * 3 / 4 : GroupLayout.PREFERRED_SIZE; | |
| 112 | 104 | GroupLayout layout = new GroupLayout(this); | |
| 113 | 105 | this.setLayout(layout); | |
| 114 | - | ||
| 106 | + | ||
| 115 | 107 | layout.setAutoCreateContainerGaps(true); | |
| 116 | 108 | layout.setAutoCreateGaps(true); | |
| 117 | 109 | ||
@@ -140,76 +132,76 @@ public void actionPerformed(ActionEvent e) { | |||
| 140 | 132 | ||
| 141 | 133 | layout | |
| 142 | 134 | .linkSize(SwingConstants.HORIZONTAL, installButton, installProgressBar, updateButton, removeButton); | |
| 143 | - | ||
| 135 | + | ||
| 144 | 136 | installProgressBar.setVisible(false); | |
| 145 | 137 | updateLabel.setVisible(false); | |
| 146 | - | ||
| 138 | + | ||
| 147 | 139 | installButton.setEnabled(false); | |
| 148 | 140 | updateButton.setEnabled(false); | |
| 149 | 141 | removeButton.setEnabled(false); | |
| 150 | - | ||
| 142 | + | ||
| 151 | 143 | layout.setHonorsVisibility(updateLabel, false); // Makes the label take up space even though not visible | |
| 152 | - | ||
| 144 | + | ||
| 153 | 145 | } | |
| 154 | - | ||
| 146 | + | ||
| 155 | 147 | void setMessage(String message) { | |
| 156 | 148 | label.setForeground(Color.BLACK); | |
| 157 | 149 | label.setText(message); | |
| 158 | 150 | label.repaint(); | |
| 159 | 151 | } | |
| 160 | - | ||
| 152 | + | ||
| 161 | 153 | void setErrorMessage(String message) { | |
| 162 | 154 | //setForeground(Color.RED); | |
| 163 | 155 | label.setForeground(new Color(160, 0, 0)); | |
| 164 | 156 | label.setText(message); | |
| 165 | 157 | label.repaint(); | |
| 166 | 158 | } | |
| 167 | - | ||
| 159 | + | ||
| 168 | 160 | void clear() { | |
| 169 | 161 | label.setText(null); | |
| 170 | 162 | label.repaint(); | |
| 171 | 163 | } | |
| 172 | 164 | ||
| 173 | 165 | public void update(ContributionPanel panel) { | |
| 174 | - | ||
| 166 | + | ||
| 175 | 167 | label.setText(panel.description.toString()); | |
| 176 | 168 | ||
| 177 | 169 | updateButton.setEnabled(!contributionListing.hasListDownloadFailed() | |
| 178 | 170 | && (contributionListing.hasUpdates(panel.getContrib()) && !panel | |
| 179 | 171 | .getContrib().isUpdateFlagged())); | |
| 180 | - | ||
| 172 | + | ||
| 181 | 173 | String latestVersion = contributionListing.getLatestVersion(panel.getContrib()); | |
| 182 | 174 | String currentVersion = panel.getContrib().getPrettyVersion(); | |
| 183 | - | ||
| 175 | + | ||
| 184 | 176 | if(latestVersion != null){ | |
| 185 | 177 | latestVersion = "Update to " + latestVersion; | |
| 186 | 178 | }else{ | |
| 187 | 179 | latestVersion = "Update"; | |
| 188 | 180 | } | |
| 189 | - | ||
| 181 | + | ||
| 190 | 182 | if(currentVersion != null){ | |
| 191 | 183 | currentVersion = "Version " + currentVersion; | |
| 192 | 184 | }else{ | |
| 193 | 185 | currentVersion = ""; | |
| 194 | 186 | } | |
| 195 | - | ||
| 187 | + | ||
| 196 | 188 | if(updateButton.isEnabled()){ | |
| 197 | 189 | updateButton.setText(latestVersion); | |
| 198 | 190 | }else{ | |
| 199 | 191 | updateButton.setText("Update"); | |
| 200 | 192 | } | |
| 201 | - | ||
| 193 | + | ||
| 202 | 194 | installButton.setEnabled(!panel.getContrib().isInstalled() && !contributionListing.hasListDownloadFailed()); | |
| 203 | - | ||
| 204 | - | ||
| 195 | + | ||
| 196 | + | ||
| 205 | 197 | if(installButton.isEnabled()){ | |
| 206 | 198 | updateLabel.setText(currentVersion + " available"); | |
| 207 | 199 | }else{ | |
| 208 | 200 | updateLabel.setText(currentVersion + " installed"); | |
| 209 | 201 | } | |
| 210 | - | ||
| 202 | + | ||
| 211 | 203 | updateLabel.setVisible(true); | |
| 212 | - | ||
| 204 | + | ||
| 213 | 205 | removeButton.setEnabled(panel.getContrib().isInstalled()); | |
| 214 | 206 | ||
| 215 | 207 | } | |
@@ -272,5 +264,5 @@ void clearErrorMessage() { | |||
| 272 | 264 | ||
| 273 | 265 | getPlaceholder().setVisible(false); | |
| 274 | 266 | } | |
| 275 | - } | ||
| 267 | + } | ||
| 276 | 268 | */ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments