Removed the 'Command' feature
This commit is contained in:
parent
98906d6922
commit
26da0ec8b9
@ -1,86 +0,0 @@
|
||||
package org.nanoboot.utils.timecalc.app;
|
||||
|
||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||
import org.nanoboot.utils.timecalc.swing.common.Toaster;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* @author Robert Vokac
|
||||
* @since 26.02.2024
|
||||
*/
|
||||
public class CommandActionListener
|
||||
implements ActionListener {
|
||||
|
||||
private final TimeCalcApp timeCalcApp;
|
||||
private final TimeCalcConfiguration timeCalcConfiguration;
|
||||
|
||||
public CommandActionListener(TimeCalcApp timeCalcApp,
|
||||
TimeCalcConfiguration timeCalcConfiguration) {
|
||||
this.timeCalcApp = timeCalcApp;
|
||||
this.timeCalcConfiguration = timeCalcConfiguration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String commands = (String) JOptionPane.showInputDialog(
|
||||
null,
|
||||
"Run a command:",
|
||||
"Command launching",
|
||||
JOptionPane.PLAIN_MESSAGE,
|
||||
null,
|
||||
null,
|
||||
"test"
|
||||
);
|
||||
String[] commandsAsArray = commands.split(" ");
|
||||
switch (commandsAsArray[0]) {
|
||||
case "test":
|
||||
JOptionPane.showMessageDialog(null, "Test");
|
||||
break;
|
||||
case "color":
|
||||
timeCalcApp.visibilityProperty.setValue(
|
||||
commandsAsArray[1].equals("1")
|
||||
? Visibility.STRONGLY_COLORED.name()
|
||||
: Visibility.WEAKLY_COLORED.name());
|
||||
break;
|
||||
case "gray":
|
||||
timeCalcApp.visibilityProperty.setValue(
|
||||
commandsAsArray[1].equals("1")
|
||||
? Visibility.GRAY.name()
|
||||
: Visibility.WEAKLY_COLORED.name());
|
||||
break;
|
||||
case "waves":
|
||||
timeCalcConfiguration.batteryWavesVisibleProperty
|
||||
.setValue(commandsAsArray[1].equals("1"));
|
||||
break;
|
||||
case "uptime":
|
||||
JOptionPane.showMessageDialog(null,
|
||||
timeCalcApp
|
||||
.getCountOfMinutesSinceAppStarted()
|
||||
+ " minutes");
|
||||
break;
|
||||
case "toast":
|
||||
Toaster t = new Toaster();
|
||||
t.setToasterWidth(800);
|
||||
t.setToasterHeight(800);
|
||||
t.setDisplayTime(60000 * 5);
|
||||
t.setToasterColor(Color.GRAY);
|
||||
Font font = new Font("sans", Font.PLAIN, 12);
|
||||
t.setToasterMessageFont(font);
|
||||
t.setDisplayTime(5000);
|
||||
t.showToaster(commands.substring(6));
|
||||
break;
|
||||
case "toasts":
|
||||
timeCalcConfiguration.notificationsVisibleProperty
|
||||
.setValue(commandsAsArray[1].equals("1"));
|
||||
break;
|
||||
default:
|
||||
JOptionPane.showMessageDialog(null,
|
||||
"Unknown command: " + commandsAsArray[0]);
|
||||
}
|
||||
}
|
||||
}
|
@ -548,10 +548,6 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KeyEvent.VK_F2: {
|
||||
mainWindow.doCommand();
|
||||
break;
|
||||
}
|
||||
case KeyEvent.VK_R: {
|
||||
mainWindow.doRestart();
|
||||
break;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.nanoboot.utils.timecalc.swing.windows;
|
||||
|
||||
import org.nanoboot.utils.timecalc.app.CommandActionListener;
|
||||
import org.nanoboot.utils.timecalc.app.GetProperty;
|
||||
import org.nanoboot.utils.timecalc.app.TimeCalcApp;
|
||||
import org.nanoboot.utils.timecalc.app.TimeCalcConfiguration;
|
||||
@ -113,8 +112,6 @@ public class MainWindow extends TWindow {
|
||||
private final TButton focusButton;
|
||||
private final TButton helpButton;
|
||||
private final TButton weatherButton;
|
||||
private final TButton commandButton;
|
||||
private final TButton jokeButton;
|
||||
private final AboutButton aboutButton;
|
||||
private final TimeCalcConfiguration timeCalcConfiguration
|
||||
= new TimeCalcConfiguration();
|
||||
@ -285,8 +282,6 @@ public class MainWindow extends TWindow {
|
||||
this.focusButton = new TButton(allowOnlyBasicFeaturesProperty.getValue() ? " " : "Focus", 70);
|
||||
this.helpButton = new TButton("Help", 60);
|
||||
this.weatherButton = new TButton("Weather");
|
||||
this.commandButton = new TButton("Run", 40);
|
||||
this.jokeButton = new TButton("Joke", 60);
|
||||
this.aboutButton = new AboutButton();
|
||||
|
||||
Function<String, ImageIcon> loadImageIcon = (p) ->
|
||||
@ -316,7 +311,7 @@ public class MainWindow extends TWindow {
|
||||
//window.add(weatherButton);
|
||||
addAll(workDaysButton, activitiesButton, restartButton,focusButton);
|
||||
if(!allowOnlyBasicFeaturesProperty.getValue()) {
|
||||
addAll(configButton, commandButton,jokeButton,helpButton,
|
||||
addAll(configButton, helpButton,
|
||||
exitButton,
|
||||
hideShowFormsCheckBox);
|
||||
}
|
||||
@ -796,12 +791,10 @@ public class MainWindow extends TWindow {
|
||||
//
|
||||
helpButton.setBoundsFromLeft(configButton);
|
||||
focusButton.setBoundsFromLeft(helpButton);
|
||||
commandButton.setBoundsFromLeft(focusButton);
|
||||
jokeButton.setBoundsFromLeft(commandButton);
|
||||
hideShowFormsCheckBox.setSelected(true);
|
||||
hideShowFormsCheckBox.setBounds(
|
||||
jokeButton.getX() + jokeButton.getWidth() + SwingUtils.MARGIN,
|
||||
jokeButton.getY(), 20, 20);
|
||||
focusButton.getX() + focusButton.getWidth() + SwingUtils.MARGIN,
|
||||
focusButton.getY(), 20, 20);
|
||||
//
|
||||
restartButton.setBoundsFromLeft(hideShowFormsCheckBox);
|
||||
exitButton.setBoundsFromLeft(restartButton);
|
||||
@ -815,14 +808,7 @@ public class MainWindow extends TWindow {
|
||||
|
||||
weatherButton
|
||||
.addActionListener(e -> new WeatherWindow().setVisible(true));
|
||||
commandButton.addActionListener(
|
||||
new CommandActionListener(timeCalcApp, timeCalcConfiguration));
|
||||
|
||||
jokeButton.addActionListener(e -> {
|
||||
for (int i = 1; i <= 1; i++) {
|
||||
Jokes.showRandom();
|
||||
}
|
||||
});
|
||||
hideShowFormsCheckBox.addItemListener(e -> this.requestFocus());
|
||||
exitButton.addActionListener(e
|
||||
-> {
|
||||
@ -1424,12 +1410,6 @@ public class MainWindow extends TWindow {
|
||||
.isEnabled()) /*|| (c instanceof TButton ? ((Widget)c).visibleProperty.isEnabled()
|
||||
: true)*/, currentVisibility.isNotNone());
|
||||
|
||||
jokeButton.setVisible(
|
||||
TimeCalcProperties.getInstance().getBooleanProperty(
|
||||
TimeCalcProperty.JOKES_VISIBLE)
|
||||
&& !currentVisibility.isNone()
|
||||
&& MainWindow.hideShowFormsCheckBox.isSelected());
|
||||
|
||||
setTitle(currentVisibility.isNone() ? "" : getWindowTitle());
|
||||
|
||||
int secondNow = clock.secondProperty.getValue();
|
||||
@ -1721,10 +1701,6 @@ public class MainWindow extends TWindow {
|
||||
restartButton.doClick();
|
||||
}
|
||||
|
||||
public void doCommand() {
|
||||
commandButton.doClick();
|
||||
}
|
||||
|
||||
public void openHelpWindow() {
|
||||
helpButton.doClick();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user