Skip to content

Commit c84fb7f

Browse files
author
Federico Fissore
committed
Removed a handful of static methods delegates
1 parent 8c83281 commit c84fb7f

File tree

10 files changed

+31
-184
lines changed

10 files changed

+31
-184
lines changed

app/src/cc/arduino/packages/formatter/AStyle.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
package cc.arduino.packages.formatter;
3333

3434
import processing.app.Base;
35+
import processing.app.BaseNoGui;
3536
import processing.app.Editor;
3637
import processing.app.helpers.FileUtils;
3738
import processing.app.syntax.SketchTextArea;
@@ -53,7 +54,7 @@ public class AStyle implements Tool {
5354

5455
public AStyle() {
5556
this.aStyleInterface = new AStyleInterface();
56-
File customFormatterConf = Base.getSettingsFile(FORMATTER_CONF);
57+
File customFormatterConf = BaseNoGui.getSettingsFile(FORMATTER_CONF);
5758
File defaultFormatterConf = new File(Base.getContentFile("lib"), FORMATTER_CONF);
5859

5960
File formatterConf;

app/src/cc/arduino/view/preferences/Preferences.java

+6-9
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@
2929

3030
package cc.arduino.view.preferences;
3131

32-
import processing.app.Base;
33-
import processing.app.Editor;
34-
import processing.app.I18n;
35-
import processing.app.PreferencesData;
32+
import processing.app.*;
3633
import processing.app.helpers.FileUtils;
3734
import processing.app.legacy.PApplet;
3835

@@ -552,10 +549,10 @@ private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
552549
File file = Base.selectFolder(_("Select new sketchbook location"), dflt, this);
553550
if (file != null) {
554551
String path = file.getAbsolutePath();
555-
if (Base.getPortableFolder() != null) {
556-
path = FileUtils.relativePath(Base.getPortableFolder().toString(), path);
552+
if (BaseNoGui.getPortableFolder() != null) {
553+
path = FileUtils.relativePath(BaseNoGui.getPortableFolder().toString(), path);
557554
if (path == null) {
558-
path = Base.getPortableSketchbookFolder();
555+
path = BaseNoGui.getPortableSketchbookFolder();
559556
}
560557
}
561558
sketchbookLocationField.setText(path);
@@ -626,10 +623,10 @@ private void savePreferencesData() {
626623
String oldPath = PreferencesData.get("sketchbook.path");
627624
String newPath = sketchbookLocationField.getText();
628625
if (newPath.isEmpty()) {
629-
if (base.getPortableFolder() == null) {
626+
if (BaseNoGui.getPortableFolder() == null) {
630627
newPath = base.getDefaultSketchbookFolderOrPromptForIt().toString();
631628
} else {
632-
newPath = base.getPortableSketchbookFolder();
629+
newPath = BaseNoGui.getPortableSketchbookFolder();
633630
}
634631
}
635632
if (!newPath.equals(oldPath)) {

app/src/processing/app/Base.java

+10-161
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static public void guardedMain(String args[]) throws Exception {
217217
}
218218

219219
// Create a location for untitled sketches
220-
untitledFolder = createTempFolder("untitled");
220+
untitledFolder = BaseNoGui.createTempFolder("untitled");
221221
DeleteFilesOnShutdown.add(untitledFolder);
222222

223223
INSTANCE = new Base(args);
@@ -347,7 +347,7 @@ protected void onProgress(Progress progress) {
347347
List<String> downloadedPackageIndexFiles = installer.updateIndex();
348348
installer.deleteUnknownFiles(downloadedPackageIndexFiles);
349349
indexer.parseIndex();
350-
indexer.syncWithFilesystem(getHardwareFolder());
350+
indexer.syncWithFilesystem(BaseNoGui.getHardwareFolder());
351351

352352
String[] boardToInstallParts = parser.getBoardToInstall().split(":");
353353

@@ -680,7 +680,7 @@ protected File createNewUntitled() throws IOException {
680680

681681
// In 0126, untitled sketches will begin in the temp folder,
682682
// and then moved to a new location because Save will default to Save As.
683-
File sketchbookDir = getSketchbookFolder();
683+
File sketchbookDir = BaseNoGui.getSketchbookFolder();
684684
File newbieParentDir = untitledFolder;
685685

686686
// Use a generic name like sketch_031008a, the date plus a char
@@ -805,7 +805,7 @@ public void handleOpenReplace(File file) {
805805
public void handleOpenPrompt() throws Exception {
806806
// get the frontmost window frame for placing file dialog
807807
FileDialog fd = new FileDialog(activeEditor, _("Open an Arduino sketch..."), FileDialog.LOAD);
808-
File lastFolder = new File(PreferencesData.get("last.folder", getSketchbookFolder().getAbsolutePath()));
808+
File lastFolder = new File(PreferencesData.get("last.folder", BaseNoGui.getSketchbookFolder().getAbsolutePath()));
809809
if (lastFolder.exists() && lastFolder.isFile()) {
810810
lastFolder = lastFolder.getParentFile();
811811
}
@@ -1037,7 +1037,7 @@ public void actionPerformed(ActionEvent e) {
10371037

10381038
// Add a list of all sketches and subfolders
10391039
try {
1040-
boolean sketches = addSketches(menu, getSketchbookFolder(), true);
1040+
boolean sketches = addSketches(menu, BaseNoGui.getSketchbookFolder(), true);
10411041
if (sketches) menu.addSeparator();
10421042
} catch (IOException e) {
10431043
e.printStackTrace();
@@ -1058,7 +1058,7 @@ protected void rebuildSketchbookMenu(JMenu menu) {
10581058
//new Exception().printStackTrace();
10591059
try {
10601060
menu.removeAll();
1061-
addSketches(menu, getSketchbookFolder(), false);
1061+
addSketches(menu, BaseNoGui.getSketchbookFolder(), false);
10621062
//addSketches(menu, getSketchbookFolder());
10631063
} catch (IOException e) {
10641064
e.printStackTrace();
@@ -1111,7 +1111,7 @@ public void actionPerformed(ActionEvent e) {
11111111
importMenu.addSeparator();
11121112

11131113
// Split between user supplied libraries and IDE libraries
1114-
TargetPlatform targetPlatform = getTargetPlatform();
1114+
TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
11151115

11161116
if (targetPlatform != null) {
11171117
List<ContributedLibrary> libs = getSortedLibraries();
@@ -1338,7 +1338,7 @@ private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
13381338
@SuppressWarnings("serial")
13391339
Action action = new AbstractAction(board.getName()) {
13401340
public void actionPerformed(ActionEvent actionevent) {
1341-
selectBoard((TargetBoard) getValue("b"));
1341+
BaseNoGui.selectBoard((TargetBoard) getValue("b"));
13421342
filterVisibilityOfSubsequentBoardMenus(boardsCustomMenus, (TargetBoard) getValue("b"), 1);
13431343

13441344
onBoardOrPortChange();
@@ -1461,15 +1461,6 @@ private static JMenuItem selectFirstEnabledMenuItem(JMenu menu) {
14611461
throw new IllegalStateException("Menu has no enabled items");
14621462
}
14631463

1464-
1465-
private void selectBoard(TargetBoard targetBoard) {
1466-
BaseNoGui.selectBoard(targetBoard);
1467-
}
1468-
1469-
public static void selectSerialPort(String port) {
1470-
BaseNoGui.selectSerialPort(port);
1471-
}
1472-
14731464
public void rebuildProgrammerMenu(JMenu menu) {
14741465
menu.removeAll();
14751466
ButtonGroup group = new ButtonGroup();
@@ -1658,14 +1649,6 @@ static public String[] headerListFromIncludePath(File path) throws IOException {
16581649
return list;
16591650
}
16601651

1661-
protected void loadHardware(File folder) {
1662-
BaseNoGui.loadHardware(folder);
1663-
}
1664-
1665-
1666-
// .................................................................
1667-
1668-
16691652
/**
16701653
* Show the About box.
16711654
*/
@@ -1712,153 +1695,19 @@ public void handlePrefs() {
17121695
dialog.setVisible(true);
17131696
}
17141697

1715-
/**
1716-
* Convenience method to get a File object for the specified filename inside
1717-
* the settings folder.
1718-
* For now, only used by Preferences to get the preferences.txt file.
1719-
*
1720-
* @param filename A file inside the settings folder.
1721-
* @return filename wrapped as a File object inside the settings folder
1722-
*/
1723-
static public File getSettingsFile(String filename) {
1724-
return BaseNoGui.getSettingsFile(filename);
1725-
}
1726-
1727-
1728-
static public File getBuildFolder() {
1729-
return BaseNoGui.getBuildFolder();
1730-
}
1731-
1732-
1733-
/**
1734-
* Get the path to the platform's temporary folder, by creating
1735-
* a temporary temporary file and getting its parent folder.
1736-
* <br/>
1737-
* Modified for revision 0094 to actually make the folder randomized
1738-
* to avoid conflicts in multi-user environments. (Bug 177)
1739-
*/
1740-
static public File createTempFolder(String name) {
1741-
return BaseNoGui.createTempFolder(name);
1742-
}
1743-
1744-
17451698
// XXX: Remove this method and make librariesIndexer non-static
17461699
static public LibraryList getLibraries() {
17471700
return BaseNoGui.librariesIndexer.getInstalledLibraries();
17481701
}
17491702

1750-
1751-
static public String getExamplesPath() {
1752-
return BaseNoGui.getExamplesPath();
1753-
}
1754-
1755-
1756-
static public List<File> getLibrariesPath() {
1757-
return BaseNoGui.getLibrariesPath();
1758-
}
1759-
1760-
1761-
static public File getToolsFolder() {
1762-
return BaseNoGui.getToolsFolder();
1763-
}
1764-
1765-
1766-
static public String getToolsPath() {
1767-
return BaseNoGui.getToolsPath();
1768-
}
1769-
1770-
1771-
static public File getHardwareFolder() {
1772-
return BaseNoGui.getHardwareFolder();
1773-
}
1774-
1775-
//Get the core libraries
1776-
static public File getCoreLibraries(String path) {
1777-
return getContentFile(path);
1778-
}
1779-
1780-
static public String getHardwarePath() {
1781-
return BaseNoGui.getHardwarePath();
1782-
}
1783-
1784-
1785-
static public String getAvrBasePath() {
1786-
return BaseNoGui.getAvrBasePath();
1787-
}
1788-
1789-
/**
1790-
* Returns a specific TargetPackage
1791-
*
1792-
* @param packageName
1793-
* @return
1794-
*/
1795-
static public TargetPackage getTargetPackage(String packageName) {
1796-
return BaseNoGui.getTargetPackage(packageName);
1797-
}
1798-
1799-
/**
1800-
* Returns the currently selected TargetPlatform.
1801-
*
1802-
* @return
1803-
*/
1804-
static public TargetPlatform getTargetPlatform() {
1805-
return BaseNoGui.getTargetPlatform();
1806-
}
1807-
1808-
/**
1809-
* Returns a specific TargetPlatform searching Package/Platform
1810-
*
1811-
* @param packageName
1812-
* @param platformName
1813-
* @return
1814-
*/
1815-
static public TargetPlatform getTargetPlatform(String packageName,
1816-
String platformName) {
1817-
return BaseNoGui.getTargetPlatform(packageName, platformName);
1818-
}
1819-
1820-
static public TargetPlatform getCurrentTargetPlatformFromPackage(String pack) {
1821-
return BaseNoGui.getCurrentTargetPlatformFromPackage(pack);
1822-
}
1823-
1824-
static public PreferencesMap getBoardPreferences() {
1825-
return BaseNoGui.getBoardPreferences();
1826-
}
1827-
18281703
public List<JMenu> getBoardsCustomMenus() {
18291704
return boardsCustomMenus;
18301705
}
18311706

1832-
static public File getPortableFolder() {
1833-
return BaseNoGui.getPortableFolder();
1834-
}
1835-
1836-
1837-
static public String getPortableSketchbookFolder() {
1838-
return BaseNoGui.getPortableSketchbookFolder();
1839-
}
1840-
1841-
1842-
static public File getSketchbookFolder() {
1843-
return BaseNoGui.getSketchbookFolder();
1844-
}
1845-
1846-
1847-
static public File getSketchbookLibrariesFolder() {
1848-
return BaseNoGui.getSketchbookLibrariesFolder();
1849-
}
1850-
1851-
18521707
static public String getSketchbookLibrariesPath() {
1853-
return getSketchbookLibrariesFolder().getAbsolutePath();
1708+
return BaseNoGui.getSketchbookLibrariesFolder().getAbsolutePath();
18541709
}
18551710

1856-
1857-
static public File getSketchbookHardwareFolder() {
1858-
return BaseNoGui.getSketchbookHardwareFolder();
1859-
}
1860-
1861-
18621711
public File getDefaultSketchbookFolderOrPromptForIt() {
18631712

18641713
File sketchbookFolder = BaseNoGui.getDefaultSketchbookFolder();
@@ -2578,7 +2427,7 @@ public void handleAddLibrary() {
25782427
}
25792428

25802429
// copy folder
2581-
File destinationFolder = new File(getSketchbookLibrariesFolder(), sourceFile.getName());
2430+
File destinationFolder = new File(BaseNoGui.getSketchbookLibrariesFolder(), sourceFile.getName());
25822431
if (!destinationFolder.mkdir()) {
25832432
activeEditor.statusError(I18n.format(_("A library named {0} already exists"), sourceFile.getName()));
25842433
return;

app/src/processing/app/Editor.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -766,8 +766,8 @@ public void actionPerformed(ActionEvent e) {
766766
});
767767
toolsMenu.add(item);
768768

769-
addTools(toolsMenu, Base.getToolsFolder());
770-
File sketchbookTools = new File(Base.getSketchbookFolder(), "tools");
769+
addTools(toolsMenu, BaseNoGui.getToolsFolder());
770+
File sketchbookTools = new File(BaseNoGui.getSketchbookFolder(), "tools");
771771
addTools(toolsMenu, sketchbookTools);
772772

773773
toolsMenu.addSeparator();
@@ -1108,7 +1108,7 @@ protected void selectSerialPort(String name) {
11081108
}
11091109
if (selection != null) selection.setState(true);
11101110
//System.out.println(item.getLabel());
1111-
Base.selectSerialPort(name);
1111+
BaseNoGui.selectSerialPort(name);
11121112
if (serialMonitor != null) {
11131113
try {
11141114
serialMonitor.close();
@@ -2891,7 +2891,7 @@ public void statusEmpty() {
28912891
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
28922892

28932893
protected void onBoardOrPortChange() {
2894-
Map<String, String> boardPreferences = Base.getBoardPreferences();
2894+
Map<String, String> boardPreferences = BaseNoGui.getBoardPreferences();
28952895
if (boardPreferences != null)
28962896
lineStatus.setBoardName(boardPreferences.get("name"));
28972897
else

app/src/processing/app/EditorConsoleStream.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static void init() {
3535
// sister IDEs) might collide with the file causing permissions problems.
3636
// The files and folders are not deleted on exit because they may be
3737
// needed for debugging or bug reporting.
38-
tempFolder = Base.createTempFolder("console");
38+
tempFolder = BaseNoGui.createTempFolder("console");
3939
DeleteFilesOnShutdown.add(tempFolder);
4040
try {
4141
String outFileName = PreferencesData.get("console.output.file");

app/src/processing/app/EditorLineStatus.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void set(int newStart, int newStop) {
9191

9292
public void paintComponent(Graphics g) {
9393
if (name == "" && serialport == "") {
94-
PreferencesMap boardPreferences = Base.getBoardPreferences();
94+
PreferencesMap boardPreferences = BaseNoGui.getBoardPreferences();
9595
if (boardPreferences != null)
9696
setBoardName(boardPreferences.get("name"));
9797
else

app/src/processing/app/EditorStatus.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ public void keyTyped(KeyEvent event) {
465465
public void actionPerformed(ActionEvent e) {
466466
String message = "";
467467
message += _("Arduino: ") + BaseNoGui.VERSION_NAME_LONG + " (" + System.getProperty("os.name") + "), ";
468-
message += _("Board: ") + "\"" + Base.getBoardPreferences().get("name") + "\"\n\n";
468+
message += _("Board: ") + "\"" + BaseNoGui.getBoardPreferences().get("name") + "\"\n\n";
469469
message += editor.console.consoleTextPane.getText().trim();
470470
if ((PreferencesData.getBoolean("build.verbose")) == false) {
471471
message += "\n\n";

0 commit comments

Comments
 (0)