34
34
import cc .arduino .files .DeleteFilesOnShutdown ;
35
35
import cc .arduino .packages .DiscoveryManager ;
36
36
import cc .arduino .utils .Progress ;
37
- import cc .arduino .view .*;
38
37
import cc .arduino .view .Event ;
38
+ import cc .arduino .view .JMenuUtils ;
39
+ import cc .arduino .view .SplashScreenHelper ;
39
40
import com .google .common .base .Predicate ;
40
41
import com .google .common .base .Predicates ;
41
42
import com .google .common .collect .Collections2 ;
58
59
import processing .app .tools .ZipDeflater ;
59
60
60
61
import javax .swing .*;
61
-
62
62
import java .awt .*;
63
63
import java .awt .event .*;
64
64
import java .io .*;
@@ -1122,18 +1122,18 @@ public void actionPerformed(ActionEvent e) {
1122
1122
menu .addSeparator ();
1123
1123
1124
1124
// Add a list of all sketches and subfolders
1125
- boolean sketches = addSketches (menu , BaseNoGui .getSketchbookFolder (), true );
1125
+ boolean sketches = addSketches (menu , BaseNoGui .getSketchbookFolder ());
1126
1126
if (sketches ) menu .addSeparator ();
1127
1127
1128
1128
// Add each of the subfolders of examples directly to the menu
1129
- boolean found = addSketches (menu , BaseNoGui .getExamplesFolder (), true );
1129
+ boolean found = addSketches (menu , BaseNoGui .getExamplesFolder ());
1130
1130
if (found ) menu .addSeparator ();
1131
1131
}
1132
1132
1133
1133
1134
1134
protected void rebuildSketchbookMenu (JMenu menu ) {
1135
1135
menu .removeAll ();
1136
- addSketches (menu , BaseNoGui .getSketchbookFolder (), false );
1136
+ addSketches (menu , BaseNoGui .getSketchbookFolder ());
1137
1137
1138
1138
JMenu librariesMenu = JMenuUtils .findSubMenuWithLabel (menu , "libraries" );
1139
1139
if (librariesMenu != null ) {
@@ -1235,21 +1235,21 @@ public void rebuildExamplesMenu(JMenu menu) {
1235
1235
menu .removeAll ();
1236
1236
1237
1237
// Add examples from distribution "example" folder
1238
- boolean found = addSketches (menu , BaseNoGui .getExamplesFolder (), false );
1238
+ boolean found = addSketches (menu , BaseNoGui .getExamplesFolder ());
1239
1239
if (found ) menu .addSeparator ();
1240
1240
1241
1241
// Add examples from libraries
1242
1242
LibraryList ideLibs = getIDELibs ();
1243
1243
ideLibs .sort ();
1244
1244
for (UserLibrary lib : ideLibs )
1245
- addSketchesSubmenu (menu , lib , false );
1245
+ addSketchesSubmenu (menu , lib );
1246
1246
1247
1247
LibraryList userLibs = getUserLibs ();
1248
1248
if (userLibs .size () > 0 ) {
1249
1249
menu .addSeparator ();
1250
1250
userLibs .sort ();
1251
1251
for (UserLibrary lib : userLibs )
1252
- addSketchesSubmenu (menu , lib , false );
1252
+ addSketchesSubmenu (menu , lib );
1253
1253
}
1254
1254
}
1255
1255
@@ -1580,7 +1580,7 @@ public void actionPerformed(ActionEvent actionevent) {
1580
1580
* should replace the sketch in the current window, or false when the
1581
1581
* sketch should open in a new window.
1582
1582
*/
1583
- protected boolean addSketches (JMenu menu , File folder , final boolean replaceExisting ) {
1583
+ protected boolean addSketches (JMenu menu , File folder ) {
1584
1584
if (folder == null )
1585
1585
return false ;
1586
1586
@@ -1607,40 +1607,29 @@ public int compare(File file, File file2) {
1607
1607
1608
1608
if (!subfolder .isDirectory ()) continue ;
1609
1609
1610
- if (addSketchesSubmenu (menu , subfolder .getName (), subfolder , replaceExisting )) {
1610
+ if (addSketchesSubmenu (menu , subfolder .getName (), subfolder )) {
1611
1611
ifound = true ;
1612
1612
}
1613
1613
}
1614
1614
1615
1615
return ifound ;
1616
1616
}
1617
1617
1618
- private boolean addSketchesSubmenu (JMenu menu , UserLibrary lib ,
1619
- boolean replaceExisting ) {
1620
- return addSketchesSubmenu (menu , lib .getName (), lib .getInstalledFolder (),
1621
- replaceExisting );
1618
+ private boolean addSketchesSubmenu (JMenu menu , UserLibrary lib ) {
1619
+ return addSketchesSubmenu (menu , lib .getName (), lib .getInstalledFolder ());
1622
1620
}
1623
1621
1624
- private boolean addSketchesSubmenu (JMenu menu , String name , File folder ,
1625
- final boolean replaceExisting ) {
1622
+ private boolean addSketchesSubmenu (JMenu menu , String name , File folder ) {
1626
1623
1627
1624
ActionListener listener = new ActionListener () {
1628
1625
public void actionPerformed (ActionEvent e ) {
1629
1626
String path = e .getActionCommand ();
1630
1627
File file = new File (path );
1631
1628
if (file .exists ()) {
1632
- boolean replace = replaceExisting ;
1633
- if ((e .getModifiers () & ActionEvent .SHIFT_MASK ) != 0 ) {
1634
- replace = !replace ;
1635
- }
1636
- if (replace ) {
1637
- handleOpenReplace (file );
1638
- } else {
1639
- try {
1640
- handleOpen (file );
1641
- } catch (Exception e1 ) {
1642
- e1 .printStackTrace ();
1643
- }
1629
+ try {
1630
+ handleOpen (file );
1631
+ } catch (Exception e1 ) {
1632
+ e1 .printStackTrace ();
1644
1633
}
1645
1634
} else {
1646
1635
showWarning (_ ("Sketch Does Not Exist" ),
@@ -1682,11 +1671,11 @@ public void actionPerformed(ActionEvent e) {
1682
1671
1683
1672
// don't create an extra menu level for a folder named "examples"
1684
1673
if (folder .getName ().equals ("examples" ))
1685
- return addSketches (menu , folder , replaceExisting );
1674
+ return addSketches (menu , folder );
1686
1675
1687
1676
// not a sketch folder, but maybe a subfolder containing sketches
1688
1677
JMenu submenu = new JMenu (name );
1689
- boolean found = addSketches (submenu , folder , replaceExisting );
1678
+ boolean found = addSketches (submenu , folder );
1690
1679
if (found ) {
1691
1680
menu .add (submenu );
1692
1681
MenuScroller .setScrollerFor (submenu );
0 commit comments