Skip to content

Commit 72ffd8a

Browse files
committed
Merge pull request #2853 from joelmoniz/contribManagerFixes
A few fixes for Contributions Manager
2 parents c6bcd47 + 3c4bb42 commit 72ffd8a

6 files changed

Lines changed: 57 additions & 20 deletions

File tree

app/src/processing/app/Mode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ public void actionPerformed(ActionEvent e) {
414414
});
415415
toolbarMenu.add(item);
416416

417-
item = new JMenuItem("Add Examples...");
417+
item = new JMenuItem(Language.text("examples.add_examples"));
418418
item.addActionListener(new ActionListener() {
419419
public void actionPerformed(ActionEvent e) {
420420
base.handleOpenExampleManager();
@@ -843,7 +843,7 @@ public void actionPerformed(ActionEvent e) {
843843
examplesPanel.setBackground(Color.WHITE);
844844

845845
final JPanel openExamplesManagerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
846-
JLabel openExamplesManagerLabel = new JLabel("Add Examples...");
846+
JLabel openExamplesManagerLabel = new JLabel(Language.text("examples.add_examples"));
847847
// openExamplesManagerLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
848848
openExamplesManagerPanel.add(openExamplesManagerLabel);
849849
openExamplesManagerPanel.setOpaque(false);

app/src/processing/app/contrib/AvailableContribution.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,17 +309,17 @@ public boolean writePropertiesFile(File propFile) {
309309
minRev = Integer.parseInt(properties.get("minRevision"));
310310
} catch (NumberFormatException e) {
311311
minRev = getMinRevision();
312-
System.err.println("The minimum compatible revision for the “" + name
313-
+ "” contribution is not set properly. Assuming minimum revision 0.");
312+
// System.err.println("The minimum compatible revision for the “" + name
313+
// + "” contribution is not set properly. Assuming minimum revision 0.");
314314
}
315315

316316
int maxRev;
317317
try {
318318
maxRev = Integer.parseInt(properties.get("maxRevision"));
319319
} catch (NumberFormatException e) {
320320
maxRev = getMaxRevision();
321-
System.err.println("The maximum compatible revision for the “" + name
322-
+ "” contribution is not set properly. Assuming maximum revision INF.");
321+
// System.err.println("The maximum compatible revision for the “" + name
322+
// + "” contribution is not set properly. Assuming maximum revision INF.");
323323
}
324324

325325
if (propFile.delete() && propFile.createNewFile() && propFile.setWritable(true)) {

app/src/processing/app/contrib/ContributionManager.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,15 @@ static boolean download(URL source, File dest, ProgressMonitor progress) {
9797
success = true;
9898

9999
} catch (SocketTimeoutException ste) {
100-
if (progress != null)
100+
if (progress != null) {
101101
progress.error(ste);
102+
progress.cancel();
103+
}
102104
} catch (IOException ioe) {
103-
if (progress != null)
105+
if (progress != null) {
104106
progress.error(ioe);
107+
progress.cancel();
108+
}
105109
// Hiding stack trace. An error has been shown where needed.
106110
// ioe.printStackTrace();
107111
}
@@ -176,9 +180,13 @@ public void run() {
176180
.setErrorMessage(Language
177181
.interpolate("contrib.errors.download_and_install",
178182
ad.getName()));
183+
downloadProgress.cancel();
184+
installProgress.cancel();
179185
}
180186
} catch (IOException e) {
181187
status.setErrorMessage(Language.text("contrib.errors.temporary_directory"));
188+
downloadProgress.cancel();
189+
installProgress.cancel();
182190
}
183191
}
184192
}, "Contribution Installer").start();

app/src/processing/app/contrib/ContributionManagerDialog.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class ContributionManagerDialog {
5757
// the calling editor, so updates can be applied
5858
Editor editor;
5959
String category;
60-
String compatibleContribType;
60+
String compatibleCheckboxLabel;
6161
boolean isCompatibilityFilter;
6262
ContributionListing contribListing;
6363

@@ -66,21 +66,26 @@ public ContributionManagerDialog(ContributionType type) {
6666
if (type == null) {
6767
title = Language.text("contrib.manager_title.update");
6868
filter = ContributionType.createUpdateFilter();
69-
compatibleContribType = "Updates";
69+
compatibleCheckboxLabel = Language.text("contrib.show_only_compatible.update");
7070
} else {
71-
if (type == ContributionType.MODE)
71+
if (type == ContributionType.MODE) {
7272
title = Language.text("contrib.manager_title.mode");
73-
else if (type == ContributionType.TOOL)
73+
compatibleCheckboxLabel = Language.text("contrib.show_only_compatible.mode");
74+
}
75+
else if (type == ContributionType.TOOL) {
7476
title = Language.text("contrib.manager_title.tool");
75-
else if (type == ContributionType.LIBRARY)
77+
compatibleCheckboxLabel = Language.text("contrib.show_only_compatible.tool");
78+
}
79+
else if (type == ContributionType.LIBRARY) {
7680
title = Language.text("contrib.manager_title.library");
81+
compatibleCheckboxLabel = Language.text("contrib.show_only_compatible.library");
82+
}
83+
else if (type == ContributionType.EXAMPLES_PACKAGE) {
84+
title = Language.text("contrib.manager_title.examples-package");
85+
compatibleCheckboxLabel = Language.text("contrib.show_only_compatible.examples-package");
86+
}
7787

78-
filter = type.createFilter();
79-
80-
if (type == ContributionType.LIBRARY)
81-
compatibleContribType = "Libraries";
82-
else
83-
compatibleContribType = type.getTitle() + "s";
88+
filter = type.createFilter();
8489
}
8590
contribListing = ContributionListing.getInstance();
8691
contributionListPanel = new ContributionListPanel(this, filter);
@@ -237,7 +242,7 @@ public void itemStateChanged(ItemEvent e) {
237242

238243
filterPanel.add(Box.createHorizontalStrut(5));
239244

240-
final JCheckBox compatibleContrib = new JCheckBox("Show Only Compatible " + compatibleContribType);
245+
final JCheckBox compatibleContrib = new JCheckBox(compatibleCheckboxLabel);
241246
compatibleContrib.addItemListener(new ItemListener() {
242247

243248
@Override

app/src/processing/app/contrib/ContributionPanel.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,19 @@ private void installContribution(AvailableContribution ad, String url) {
726726
public void finishedAction() {
727727
// Finished downloading library
728728
}
729+
730+
public void cancel() {
731+
// Finished installing library
732+
resetInstallProgressBarState();
733+
installRemoveButton.setEnabled(!contrib.isUpdateFlagged());
734+
735+
((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, BUTTON_CONSTRAINT);
736+
isInstallInProgress = false;
737+
if(isUpdateInProgress)
738+
isUpdateInProgress = !isUpdateInProgress;
739+
updateButton.setVisible(contribListing.hasUpdates(contrib) && !contrib.isUpdateFlagged());
740+
setSelected(true);
741+
}
729742
};
730743

731744
JProgressMonitor installProgress = new JProgressMonitor(installProgressBar) {
@@ -744,6 +757,10 @@ public void finishedAction() {
744757
updateButton.setVisible(contribListing.hasUpdates(contrib) && !contrib.isUpdateFlagged());
745758
setSelected(true);
746759
}
760+
761+
public void cancel() {
762+
finishedAction();
763+
}
747764
};
748765

749766
ContributionManager.downloadAndInstall(listPanel.contribManager.editor,

app/src/processing/app/languages/PDE.properties

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ sketchbook.tree = Sketchbook
166166

167167
# examples (Frame)
168168
examples = Examples
169+
examples.add_examples = Add Examples...
169170

170171
# Export (Frame)
171172
export = Export Options
@@ -264,8 +265,14 @@ contrib.manager_title.update = Update Manager
264265
contrib.manager_title.mode = Mode Manager
265266
contrib.manager_title.tool = Tool Manager
266267
contrib.manager_title.library = Library Manager
268+
contrib.manager_title.examples-package = Examples-Package Manager
267269
contrib.category = Category:
268270
contrib.filter_your_search = Filter your search...
271+
contrib.show_only_compatible.mode = Show Only Compatible Modes
272+
contrib.show_only_compatible.tool = Show Only Compatible Tools
273+
contrib.show_only_compatible.library = Show Only Compatible Libraries
274+
contrib.show_only_compatible.examples-package = Show Only Compatible Examples
275+
contrib.show_only_compatible.update = Show Only Compatible Updates
269276
contrib.restart = Restart Processing
270277
contrib.unsaved_changes = Unsaved changes have been found
271278
contrib.unsaved_changes.prompt = Are you sure you want to restart Processing without saving first?

0 commit comments

Comments
 (0)