mirror of
https://github.com/processing/processing4.git
synced 2026-02-03 05:39:18 +01:00
Renamed classes for contributions manager
This commit is contained in:
@@ -77,7 +77,7 @@ public class Base {
|
||||
Preferences preferencesFrame;
|
||||
|
||||
// A single instance of the library manager window
|
||||
LibraryManager libraryManagerFrame;
|
||||
ContributionManager libraryManagerFrame;
|
||||
|
||||
// set to true after the first time the menu is built.
|
||||
// so that the errors while building don't show up again.
|
||||
@@ -1404,7 +1404,7 @@ public class Base {
|
||||
* Show the library installer window.
|
||||
*/
|
||||
public void handleAddOrRemoveLibrary() {
|
||||
if (libraryManagerFrame == null) libraryManagerFrame = new LibraryManager();
|
||||
if (libraryManagerFrame == null) libraryManagerFrame = new ContributionManager();
|
||||
libraryManagerFrame.showFrame(activeEditor);
|
||||
}
|
||||
|
||||
@@ -1413,7 +1413,7 @@ public class Base {
|
||||
* user. Returns the number of libraries installed.
|
||||
*/
|
||||
public int handleConfirmAndInstallLibrary(File libFile) {
|
||||
if (libraryManagerFrame == null) libraryManagerFrame = new LibraryManager();
|
||||
if (libraryManagerFrame == null) libraryManagerFrame = new ContributionManager();
|
||||
return libraryManagerFrame.confirmAndInstallLibrary(activeEditor, libFile).size();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,11 +40,11 @@ import java.text.*;
|
||||
import processing.app.Library.LibraryInfo;
|
||||
import processing.app.ContributionInfo.Author;
|
||||
import processing.app.ContributionInfo.ContributionType;
|
||||
import processing.app.LibraryListing.LibraryChangeListener;
|
||||
import processing.app.ContributionListing.ContributionChangeListener;
|
||||
|
||||
public class LibraryListPanel extends JPanel implements Scrollable, LibraryChangeListener {
|
||||
public class ContributionListPanel extends JPanel implements Scrollable, ContributionChangeListener {
|
||||
|
||||
LibraryManager contributionManager;
|
||||
ContributionManager contributionManager;
|
||||
|
||||
JProgressBar setupProgressBar;
|
||||
|
||||
@@ -63,7 +63,7 @@ public class LibraryListPanel extends JPanel implements Scrollable, LibraryChang
|
||||
HashMap<ContributionPanel, Integer> rowForEachPanel;
|
||||
|
||||
|
||||
public LibraryListPanel(LibraryManager libraryManager, LibraryListing libraryListing) {
|
||||
public ContributionListPanel(ContributionManager libraryManager, ContributionListing libraryListing) {
|
||||
super();
|
||||
|
||||
this.contributionManager = libraryManager;
|
||||
@@ -114,13 +114,13 @@ public class LibraryListPanel extends JPanel implements Scrollable, LibraryChang
|
||||
} else {
|
||||
// Add all the libraries in libraryListing to this panel
|
||||
for (ContributionInfo info : libraryListing.getAllLibararies()) {
|
||||
libraryAdded(info);
|
||||
contributionAdded(info);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void libraryAdded(ContributionInfo contributionInfo) {
|
||||
public void contributionAdded(ContributionInfo contributionInfo) {
|
||||
|
||||
ContributionPanel newPanel = null;
|
||||
if (contributionInfo.getType() == ContributionType.LIBRARY) {
|
||||
@@ -177,7 +177,7 @@ public class LibraryListPanel extends JPanel implements Scrollable, LibraryChang
|
||||
return lastRow + ((nextRow - lastRow) / 2);
|
||||
}
|
||||
|
||||
public void libraryRemoved(ContributionInfo contributionInfo) {
|
||||
public void contributionRemoved(ContributionInfo contributionInfo) {
|
||||
|
||||
synchronized (contributionPanels) {
|
||||
Iterator<ContributionPanel> it = contributionPanels.iterator();
|
||||
@@ -319,7 +319,7 @@ public class LibraryListPanel extends JPanel implements Scrollable, LibraryChang
|
||||
|
||||
libPanel.setBorder(border);
|
||||
|
||||
libPanel.setBackground(LibraryListPanel.this.getBackground());
|
||||
libPanel.setBackground(ContributionListPanel.this.getBackground());
|
||||
cascadeForgroundColor(libPanel,
|
||||
UIManager.getColor("List.foreground"));
|
||||
}
|
||||
@@ -560,7 +560,7 @@ public class LibraryListPanel extends JPanel implements Scrollable, LibraryChang
|
||||
addPaneComponents();
|
||||
addProgressBarAndButton();
|
||||
|
||||
setBackground(LibraryListPanel.this.getBackground());
|
||||
setBackground(ContributionListPanel.this.getBackground());
|
||||
setOpaque(true);
|
||||
setFocusable(true);
|
||||
setSelected(false);
|
||||
@@ -571,7 +571,7 @@ public class LibraryListPanel extends JPanel implements Scrollable, LibraryChang
|
||||
okayToOpenHyperLink = isSelected;
|
||||
|
||||
if (!isSelected) {
|
||||
for (Component c : LibraryListPanel.this.getComponents()) {
|
||||
for (Component c : ContributionListPanel.this.getComponents()) {
|
||||
if (c instanceof ContributionPanel) {
|
||||
ContributionPanel lp = (ContributionPanel) c;
|
||||
if (lp.isSelected) {
|
||||
@@ -36,9 +36,9 @@ import processing.app.Library.LibraryInfo;
|
||||
import processing.app.Library.LibraryCompilationInfo;
|
||||
import processing.app.ContributionInfo.Author;
|
||||
|
||||
public class LibraryListing {
|
||||
public class ContributionListing {
|
||||
|
||||
ArrayList<LibraryChangeListener> listeners;
|
||||
ArrayList<ContributionChangeListener> listeners;
|
||||
|
||||
ArrayList<ContributionInfo> advertisedLibraries;
|
||||
|
||||
@@ -49,8 +49,8 @@ public class LibraryListing {
|
||||
boolean hasDownloadedList;
|
||||
|
||||
|
||||
public LibraryListing() {
|
||||
listeners = new ArrayList<LibraryChangeListener>();
|
||||
public ContributionListing() {
|
||||
listeners = new ArrayList<ContributionChangeListener>();
|
||||
librariesByCategory = new HashMap<String, List<ContributionInfo>>();
|
||||
allLibraries = new ArrayList<ContributionInfo>();
|
||||
hasDownloadedList = false;
|
||||
@@ -61,7 +61,7 @@ public class LibraryListing {
|
||||
|
||||
hasDownloadedList = true;
|
||||
|
||||
LibraryXmlParser xmlParser = new LibraryXmlParser(xmlFile);
|
||||
ContributionXmlParser xmlParser = new ContributionXmlParser(xmlFile);
|
||||
advertisedLibraries = xmlParser.getLibraries();
|
||||
updateList(advertisedLibraries);
|
||||
|
||||
@@ -76,20 +76,20 @@ public class LibraryListing {
|
||||
public void updateList(List<ContributionInfo> libraries) {
|
||||
|
||||
// First, record the names of all the libraries in installedLibraries
|
||||
HashSet<String> installedLibraryNames = new HashSet<String>();
|
||||
HashSet<String> installedContributionNames = new HashSet<String>();
|
||||
for (ContributionInfo libInfo : libraries) {
|
||||
installedLibraryNames.add(libInfo.name);
|
||||
installedContributionNames.add(libInfo.name);
|
||||
}
|
||||
|
||||
// We also want to remember categories of libraries that happen to already
|
||||
// exist since there is no 'category' attribute in export.txt. For this, we
|
||||
// use a mapping of library names to category names.
|
||||
// use a mapping of contributions names to category names.
|
||||
HashMap<String, String> categoriesByName = new HashMap<String, String>();
|
||||
|
||||
Iterator<ContributionInfo> it = allLibraries.iterator();
|
||||
while (it.hasNext()) {
|
||||
ContributionInfo libInfo = it.next();
|
||||
if (installedLibraryNames.contains(libInfo.name)) {
|
||||
if (installedContributionNames.contains(libInfo.name)) {
|
||||
if (librariesByCategory.containsKey(libInfo.category)) {
|
||||
librariesByCategory.get(libInfo.category).remove(libInfo);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class LibraryListing {
|
||||
if (category != null) {
|
||||
libInfo.category = category;
|
||||
}
|
||||
addLibrary(libInfo);
|
||||
addContribution(libInfo);
|
||||
}
|
||||
|
||||
Collections.sort(allLibraries);
|
||||
@@ -137,7 +137,7 @@ public class LibraryListing {
|
||||
notifyChange(oldLib, newLib);
|
||||
}
|
||||
|
||||
public void addLibrary(ContributionInfo libInfo) {
|
||||
public void addContribution(ContributionInfo libInfo) {
|
||||
|
||||
if (librariesByCategory.containsKey(libInfo.category)) {
|
||||
List<ContributionInfo> list = librariesByCategory.get(libInfo.category);
|
||||
@@ -234,48 +234,48 @@ public class LibraryListing {
|
||||
}
|
||||
|
||||
private void notifyRemove(ContributionInfo ContributionInfo) {
|
||||
for (LibraryChangeListener listener : listeners) {
|
||||
listener.libraryRemoved(ContributionInfo);
|
||||
for (ContributionChangeListener listener : listeners) {
|
||||
listener.contributionRemoved(ContributionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyAdd(ContributionInfo ContributionInfo) {
|
||||
for (LibraryChangeListener listener : listeners) {
|
||||
listener.libraryAdded(ContributionInfo);
|
||||
for (ContributionChangeListener listener : listeners) {
|
||||
listener.contributionAdded(ContributionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyChange(ContributionInfo oldLib, ContributionInfo newLib) {
|
||||
for (LibraryChangeListener listener : listeners) {
|
||||
for (ContributionChangeListener listener : listeners) {
|
||||
listener.contributionChanged(oldLib, newLib);
|
||||
}
|
||||
}
|
||||
|
||||
public void addLibraryListener(LibraryChangeListener listener) {
|
||||
public void addContributionListener(ContributionChangeListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeLibraryListener(LibraryChangeListener listener) {
|
||||
public void removeContributionListener(ContributionChangeListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
public ArrayList<LibraryChangeListener> getLibraryListeners() {
|
||||
return new ArrayList<LibraryChangeListener>(listeners);
|
||||
public ArrayList<ContributionChangeListener> getContributionListeners() {
|
||||
return new ArrayList<ContributionChangeListener>(listeners);
|
||||
}
|
||||
|
||||
public static interface LibraryChangeListener {
|
||||
public static interface ContributionChangeListener {
|
||||
|
||||
public void libraryAdded(ContributionInfo ContributionInfo);
|
||||
public void contributionAdded(ContributionInfo ContributionInfo);
|
||||
|
||||
public void libraryRemoved(ContributionInfo ContributionInfo);
|
||||
public void contributionRemoved(ContributionInfo ContributionInfo);
|
||||
|
||||
public void contributionChanged(ContributionInfo oldLib, ContributionInfo newLib);
|
||||
|
||||
}
|
||||
|
||||
public static class LibraryListFetcher implements Runnable {
|
||||
public static class ContributionListFetcher implements Runnable {
|
||||
|
||||
LibraryListing libListing;
|
||||
ContributionListing libListing;
|
||||
|
||||
File dest;
|
||||
|
||||
@@ -287,7 +287,7 @@ public class LibraryListing {
|
||||
|
||||
ProgressMonitor progressMonitor;
|
||||
|
||||
public LibraryListFetcher(LibraryListing libListing) {
|
||||
public ContributionListFetcher(ContributionListing libListing) {
|
||||
|
||||
this.libListing = libListing;
|
||||
|
||||
@@ -326,7 +326,7 @@ public class LibraryListing {
|
||||
downloader.run();
|
||||
}
|
||||
|
||||
public LibraryListing getLibraryListing() {
|
||||
public ContributionListing getContributionListing() {
|
||||
return libListing;
|
||||
}
|
||||
}
|
||||
@@ -334,7 +334,7 @@ public class LibraryListing {
|
||||
/**
|
||||
* Class to parse the libraries xml file
|
||||
*/
|
||||
private static class LibraryXmlParser extends DefaultHandler {
|
||||
private static class ContributionXmlParser extends DefaultHandler {
|
||||
|
||||
ArrayList<ContributionInfo> libraries;
|
||||
|
||||
@@ -342,7 +342,7 @@ public class LibraryListing {
|
||||
|
||||
ContributionInfo currentInfo;
|
||||
|
||||
LibraryXmlParser(File xmlFile) {
|
||||
ContributionXmlParser(File xmlFile) {
|
||||
SAXParserFactory spf = SAXParserFactory.newInstance();
|
||||
spf.setValidating(false);
|
||||
|
||||
@@ -355,16 +355,16 @@ public class LibraryListing {
|
||||
sp.parse(input, this); // throws SAXException
|
||||
|
||||
} catch (ParserConfigurationException e) {
|
||||
Base.showWarning("Error reading library list",
|
||||
Base.showWarning("Error reading contributions list",
|
||||
"An internal error occured when preparing to read the list\n" +
|
||||
"of libraries. You can still install libraries manually while\n" +
|
||||
"we work on fixing this.", e);
|
||||
} catch (IOException e) {
|
||||
Base.showWarning("Error reading library list",
|
||||
Base.showWarning("Error reading contributions list",
|
||||
"A error occured while reading the list of available libraries.\n" +
|
||||
"Try restarting the Library Manager.\n", e);
|
||||
"Try restarting the Contribution Manager.\n", e);
|
||||
} catch (SAXException e) {
|
||||
Base.showWarning("Error reading library list",
|
||||
Base.showWarning("Error reading contributions list",
|
||||
"The list of libraries downloaded from Processing.org\n" +
|
||||
"appears to be malformed. You can still install libraries\n" +
|
||||
"manually while we work on fixing this.", e);
|
||||
@@ -27,8 +27,7 @@ import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.zip.*;
|
||||
@@ -36,15 +35,14 @@ import java.util.zip.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
|
||||
import processing.app.Library.LibraryInfo;
|
||||
import processing.app.LibraryListPanel.ContributionPanel;
|
||||
import processing.app.LibraryListPanel.PreferredViewPositionListener;
|
||||
import processing.app.LibraryListing.LibraryListFetcher;
|
||||
import processing.app.ContributionListPanel.ContributionPanel;
|
||||
import processing.app.ContributionListPanel.PreferredViewPositionListener;
|
||||
import processing.app.ContributionListing.ContributionListFetcher;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class LibraryManager {
|
||||
public class ContributionManager {
|
||||
|
||||
File backupFolder = null;
|
||||
|
||||
@@ -58,11 +56,11 @@ public class LibraryManager {
|
||||
|
||||
JFrame dialog;
|
||||
|
||||
LibraryListing contributionListing;
|
||||
ContributionListing contributionListing;
|
||||
|
||||
FilterField filterField;
|
||||
|
||||
LibraryListPanel contributionListPanel;
|
||||
ContributionListPanel contributionListPanel;
|
||||
|
||||
JComboBox categoryChooser;
|
||||
|
||||
@@ -74,7 +72,7 @@ public class LibraryManager {
|
||||
|
||||
JProgressBar installProgressBar;
|
||||
|
||||
public LibraryManager() {
|
||||
public ContributionManager() {
|
||||
|
||||
dialog = new JFrame("Contribution Manager");
|
||||
|
||||
@@ -109,10 +107,10 @@ public class LibraryManager {
|
||||
|
||||
pane.add(filterField, c);
|
||||
|
||||
contributionListPanel = new LibraryListPanel(this, contributionListing);
|
||||
contributionListPanel = new ContributionListPanel(this, contributionListing);
|
||||
if (contributionListing == null) {
|
||||
JProgressBar progressBar = contributionListPanel.getSetupProgressBar();
|
||||
getLibraryListing(progressBar);
|
||||
getContributionListing(progressBar);
|
||||
}
|
||||
|
||||
c = new GridBagConstraints();
|
||||
@@ -229,7 +227,7 @@ public class LibraryManager {
|
||||
/**
|
||||
* @return true if the library listing has already been downloaded
|
||||
*/
|
||||
public boolean hasLibraryListing() {
|
||||
public boolean hasContributionListing() {
|
||||
return contributionListing != null;
|
||||
}
|
||||
|
||||
@@ -244,19 +242,19 @@ public class LibraryManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void getLibraryListing(JProgressBar progressBar) {
|
||||
private void getContributionListing(JProgressBar progressBar) {
|
||||
if (contributionListing == null) {
|
||||
contributionListing = new LibraryListing();
|
||||
contributionListing.addLibraryListener(contributionListPanel);
|
||||
contributionListing = new ContributionListing();
|
||||
contributionListing.addContributionListener(contributionListPanel);
|
||||
|
||||
final LibraryListFetcher llf = new LibraryListFetcher(contributionListing);
|
||||
final ContributionListFetcher llf = new ContributionListFetcher(contributionListing);
|
||||
llf.setProgressMonitor(new JProgressMonitor(progressBar) {
|
||||
|
||||
@Override
|
||||
public void finishedAction() {
|
||||
contributionListing = llf.getLibraryListing();
|
||||
contributionListing = llf.getContributionListing();
|
||||
synchronized (contributionListing) {
|
||||
updateLibraryListing();
|
||||
updateContributionListing();
|
||||
updateCategoryChooser();
|
||||
|
||||
progressBar.setVisible(false);
|
||||
@@ -267,7 +265,7 @@ public class LibraryManager {
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateLibraryListing() {
|
||||
protected void updateContributionListing() {
|
||||
ArrayList<Library> libraries = editor.getMode().contribLibraries;
|
||||
|
||||
ArrayList<ContributionInfo> infoList = new ArrayList<ContributionInfo>();
|
||||
Reference in New Issue
Block a user