Skip to content

Commit

Permalink
general corrections and research for OSX port
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanCheshire committed Mar 11, 2023
1 parent d1e3af6 commit 6e03a6b
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 37 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ allprojects {
}
}

for (it in tasks.withType(JavaCompile)) {
tasks.withType(JavaCompile).each {
it.options.compilerArgs.add('--enable-preview')
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
"shownWelcomeMessage": true,
"accountCreationTime": 0,
"audioPlayerVolumePercent": 13
}
}
2 changes: 1 addition & 1 deletion src/main/java/cyder/constants/CyderIcons.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public final class CyderIcons {
public static final ImageIcon CYDER_ICON = new ImageIcon(StaticUtil.getStaticPath("CyderIcon.png"));

/**
* The x easter egg icon.
* The x Easter egg icon.
*/
public static final ImageIcon X_ICON = new ImageIcon(StaticUtil.getStaticPath("x.png"));

Expand Down
12 changes: 7 additions & 5 deletions src/main/java/cyder/getter/GetterUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import cyder.ui.label.CyderLabel;
import cyder.ui.list.CyderScrollList;
import cyder.utils.HtmlUtil;
import cyder.utils.OsUtil;

import javax.swing.*;
import javax.swing.border.LineBorder;
Expand Down Expand Up @@ -71,7 +72,7 @@ public static GetterUtil getInstance() {
private final ArrayList<CyderFrame> getFileFrames = new ArrayList<>();

/**
* All the currently active get confirmation confirmation associated with this instance.
* All the currently active get confirmation frames associated with this instance.
*/
private final ArrayList<CyderFrame> getConfirmationFrames = new ArrayList<>();

Expand Down Expand Up @@ -132,7 +133,7 @@ public void closeAllGetFrames() {
/**
* Opens up frame with a field and a label for the user to enter input to be returned.
* <p>
* See usage below for how to setup usage of this method so that the calling thread is not blocked.
* See usage below for how to set up usage of this method so that the calling thread is not blocked.
* <p>
* Usage:
* <pre>
Expand Down Expand Up @@ -420,7 +421,7 @@ public Optional<String> getInput(GetInputBuilder getInputBuilder) {
private CyderButton submitFileButton;

/**
* The submit text for the submit button.
* The "submit" text for the submit button.
*/
private static final String SUBMIT = "Submit";

Expand All @@ -438,7 +439,7 @@ public Optional<String> getInput(GetInputBuilder getInputBuilder) {
* Opens up frame with a field and a file chooser for the user to enter
* a file location or navigate to a file/directory and submit it.
* <p>
* See usage below for how to setup usage of this method so that the calling thread is not blocked.
* See usage below for how to set up usage of this method so that the calling thread is not blocked.
* <p>
* Usage:
* <pre>
Expand Down Expand Up @@ -788,7 +789,7 @@ private void setNavComponentsEnabled(boolean enabled) {
/**
* Opens up a frame with a label and a yes/no button for the user to confirm or deny some action.
* <p>
* See usage below for how to setup usage of this method so that the calling thread is not blocked.
* See usage below for how to set up usage of this method so that the calling thread is not blocked.
* <p>
* Usage:
* <pre>
Expand Down Expand Up @@ -884,6 +885,7 @@ public boolean getConfirmation(GetConfirmationBuilder getConfirmationBuilder) {

confirmationFrame.setLocationRelativeTo(relativeTo);
confirmationFrame.setVisible(true);
OsUtil.setMouseLocation(noButton);
} catch (Exception e) {
ExceptionHandler.handle(e);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/cyder/logging/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private static void setupLogFileWithAsciiArt() {
}

/**
* Creates the top level logs directory, the log sub-directory for today,
* Creates the top level logs directory, the log subdirectory for today,
* and the log file for this session if it is not generated or set.
*/
private static void generateAndSetLogFile() {
Expand Down Expand Up @@ -679,7 +679,7 @@ private static void logSpecificObjectsCreated() {
if (StringUtil.in(bottomLevelClassName, true,
Props.specificObjectCreationLogs.getValue().getList())) {
String line = bottomLevelClassName + space + "objects created since last delta"
+ space + openingParenthesis + objectCreationLogFrequency
+ space + openingParenthesis + objectCreationLogFrequency.toMillis()
+ TimeUtil.MILLISECOND_ABBREVIATION + closingParenthesis
+ colon + space + objectCreationCounter.get(key).get();

Expand All @@ -698,7 +698,7 @@ private static void logTotalObjectsCreated() {
totalObjectsCreated += currentObjectsCreated;

String line = objectsCreatedSinceLastDelta
+ space + openingParenthesis + objectCreationLogFrequency
+ space + openingParenthesis + objectCreationLogFrequency.toMillis()
+ TimeUtil.MILLISECOND_ABBREVIATION + closingParenthesis
+ colon + space + currentObjectsCreated;

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/cyder/props/PropConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cyder.enumerations.Extension;
import cyder.exceptions.IllegalMethodException;
import cyder.strings.CyderStrings;
import cyder.utils.OsUtil;

import java.io.File;

Expand Down Expand Up @@ -49,7 +50,7 @@ public String getAnnotation() {
static final String commentPrefix = CyderStrings.hash;

/**
* The local props directory.
* The local propositional argument directory.
*/
static final File localPropsDirectory = new File("props");

Expand All @@ -76,7 +77,8 @@ public String getAnnotation() {
/**
* The string to split a prop file contents at to separate the raw file master string into separate lines.
*/
static final String splitPropFileContentsAt = CyderStrings.carriageReturnChar + CyderStrings.newline;
static final String splitPropFileContentsAt = OsUtil.OPERATING_SYSTEM == OsUtil.OperatingSystem.WINDOWS
? CyderStrings.carriageReturnChar + CyderStrings.newline : CyderStrings.newline;

/**
* The token to split a string into a list of strings at.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cyder/snakes/PythonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class PythonUtil {
private static final String versionPrefix = "Version" + CyderStrings.colon + CyderStrings.space;

/**
* The install keyword for pip installations.
* The "install" keyword for pip installations.
*/
private static final String INSTALL = "install";

Expand Down
8 changes: 2 additions & 6 deletions src/main/java/cyder/subroutines/NecessarySubroutines.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import cyder.strings.StringUtil;
import cyder.user.UserUtil;
import cyder.utils.ArrayUtil;
import cyder.utils.OsUtil;
import cyder.utils.ReflectionUtil;
import cyder.utils.StaticUtil;

Expand Down Expand Up @@ -125,9 +124,6 @@ public static void executeSubroutines() {
new Subroutine(NecessarySubroutines::validateWidgets,
"Validating Widgets", "Validation of Widgets failed"),

new Subroutine(() -> !OsUtil.OperatingSystem.OSX.isCurrentOperatingSystem(),
"Ensuring Supported OS", "Unsupported OS"),

new Subroutine(NecessarySubroutines::validateVanillaAnnotations,
"Validating vanilla classes", "Validation of vanilla classes failed"),

Expand Down Expand Up @@ -263,7 +259,7 @@ private static boolean validateWidgets() {
* <li></li>
* </ul>
* <p>
* All of the above checks may be skipped if the the method contains a
* All of the above checks may be skipped if the method contains a
* {@link CyderInspection#WidgetInspection} suppression.
*
* @param method the method to validate
Expand Down Expand Up @@ -309,7 +305,7 @@ private static boolean validateWidget(Method method) {
}

/**
* Validates all widget classes annotated with with {@link cyder.annotations.Vanilla} annotation.
* Validates all widget classes annotated with {@link cyder.annotations.Vanilla} annotation.
*
* @return whether all vanilla annotations are valid
*/
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/cyder/ui/frame/CyderFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -1835,12 +1835,12 @@ public void repaint() {
*/
@Override
public void setSize(int width, int height) {
Preconditions.checkArgument(width >= minimumWidth);
Preconditions.checkArgument(height >= minimumHeight);

width = attemptInitialWidthCorrectionIfEnabled(width);
height = attemptInitialHeightCorrectionIfEnabled(height);

Preconditions.checkArgument(width >= minimumWidth);
Preconditions.checkArgument(height >= minimumHeight);

boolean sameSizes = this.width == width && this.height == height;
super.setSize(width, height);
this.width = width;
Expand All @@ -1854,12 +1854,12 @@ public void setSize(int width, int height) {
*/
@Override
public void setBounds(int x, int y, int width, int height) {
Preconditions.checkArgument(width >= minimumWidth);
Preconditions.checkArgument(height >= minimumHeight);

width = attemptInitialWidthCorrectionIfEnabled(width);
height = attemptInitialHeightCorrectionIfEnabled(height);

Preconditions.checkArgument(width >= minimumWidth);
Preconditions.checkArgument(height >= minimumHeight);

boolean sameSizes = this.width == width && this.height == height;
super.setBounds(x, y, width, height);
this.width = width;
Expand Down
13 changes: 2 additions & 11 deletions src/main/java/cyder/utils/OsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private OsUtil() {
}

/**
* The top-level operating system name (the operating system the JVM is currently being ran on).
* The top-level operating system name (the operating system the JVM is currently running on).
*/
public static final String OPERATING_SYSTEM_NAME = SystemPropertyKey.OS_NAME.getProperty();

Expand Down Expand Up @@ -196,15 +196,6 @@ public static boolean isWindows() {
return OperatingSystem.WINDOWS.isCurrentOperatingSystem();
}

/**
* Returns whether the operating system is OSX.
*
* @return whether the operating system is OSX
*/
public static boolean isOsx() {
return OperatingSystem.OSX.isCurrentOperatingSystem();
}

/**
* The length of the prefixes for running a system command.
* For windows this is "cmd.exe" and "/C" and for Unix systems
Expand Down Expand Up @@ -580,7 +571,7 @@ public static boolean isBinaryInExes(String filename) {
if (exes.exists()) {
File[] exeFiles = exes.listFiles();

if (exeFiles != null && exeFiles.length > 0) {
if (!ArrayUtil.nullOrEmpty(exeFiles)) {
for (File exe : exeFiles) {
if (exe.getName().equalsIgnoreCase(filename)) {
return true;
Expand Down

0 comments on commit 6e03a6b

Please sign in to comment.