Skip to content

Commit c86fecd

Browse files
committed
added support for specifying packages to import in library.properties (github issue# 2134)
1 parent 76f99a2 commit c86fecd

File tree

4 files changed

+217
-183
lines changed

4 files changed

+217
-183
lines changed

app/src/processing/app/Editor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ public void actionPerformed(ActionEvent e) {
899899
}
900900

901901

902-
abstract public void handleImportLibrary(String jarPath);
902+
abstract public void handleImportLibrary(String name);
903903

904904

905905
public JMenu getToolMenu() {

app/src/processing/app/Mode.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,10 @@ public void actionPerformed(ActionEvent e) {
448448
for (Library library : coreLibraries) {
449449
JMenuItem item = new JMenuItem(library.getName());
450450
item.addActionListener(listener);
451-
item.setActionCommand(library.getJarPath());
451+
452+
// changed to library-name to facilitate specification if imports from properties file
453+
item.setActionCommand(library.getName());
454+
452455
importMenu.add(item);
453456
}
454457
}
@@ -464,7 +467,9 @@ public void actionPerformed(ActionEvent e) {
464467
for (Library library : contribLibraries) {
465468
JMenuItem item = new JMenuItem(library.getName());
466469
item.addActionListener(listener);
467-
item.setActionCommand(library.getJarPath());
470+
471+
// changed to library-name to facilitate specification if imports from properties file
472+
item.setActionCommand(library.getName());
468473

469474
String group = library.getGroup();
470475
if (group != null) {
@@ -1033,6 +1038,26 @@ public boolean validExtension(String what) {
10331038

10341039
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10351040

1041+
/**
1042+
* Checks coreLibraries and contribLibraries in 'mode' for a library whose name is 'libName'
1043+
* @param mode the mode to check
1044+
* @param libName the name of the library
1045+
* @return the Library or null if not found
1046+
*/
1047+
public Library findLibraryByName(String libName) {
1048+
1049+
for (Library lib : this.coreLibraries) {
1050+
if (libName.equals(lib.getName()))
1051+
return lib;
1052+
}
1053+
1054+
for (Library lib : this.contribLibraries) {
1055+
if (libName.equals(lib.getName()))
1056+
return lib;
1057+
}
1058+
1059+
return null;
1060+
}
10361061

10371062
/**
10381063
* Create a fresh applet/application folder if the 'delete target folder'

0 commit comments

Comments
 (0)