Improve the pause button screen workflow (#216)
This commit is contained in:
@@ -138,6 +138,9 @@ public class Client {
|
|||||||
while (this.running == true) {
|
while (this.running == true) {
|
||||||
this.renderingJob = null;
|
this.renderingJob = null;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
if (this.suspended) {
|
||||||
|
this.gui.status("Client paused", true);
|
||||||
|
}
|
||||||
while (this.suspended) {
|
while (this.suspended) {
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
@@ -431,6 +434,7 @@ public class Client {
|
|||||||
|
|
||||||
public void suspend() {
|
public void suspend() {
|
||||||
suspended = true;
|
suspended = true;
|
||||||
|
this.gui.status("Client will pause when the current job finishes", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void resume() {
|
public synchronized void resume() {
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ public interface Gui {
|
|||||||
|
|
||||||
public void status(String msg_);
|
public void status(String msg_);
|
||||||
|
|
||||||
|
public void status(String msg_, boolean overwriteSuspendedMsg);
|
||||||
|
|
||||||
public void updateTrayIcon(Integer percentage_);
|
public void updateTrayIcon(Integer percentage_);
|
||||||
|
|
||||||
public void setRenderingProjectName(String name_);
|
public void setRenderingProjectName(String name_);
|
||||||
|
|||||||
@@ -187,8 +187,13 @@ public class GuiSwing extends JFrame implements Gui {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void status(String msg_) {
|
public void status(String msg_) {
|
||||||
|
status(msg_, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void status(String msg_, boolean overwriteSuspendedMsg) {
|
||||||
if (activityWorking != null) {
|
if (activityWorking != null) {
|
||||||
this.activityWorking.setStatus(msg_);
|
this.activityWorking.setStatus(msg_, overwriteSuspendedMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,8 +95,21 @@ public class GuiText implements Gui {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void status(String msg_) {
|
public void status(String msg_) {
|
||||||
System.out.println(msg_);
|
status(msg_, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void status(String msg_, boolean overwriteSuspendedMsg) {
|
||||||
log.debug("GUI " + msg_);
|
log.debug("GUI " + msg_);
|
||||||
|
|
||||||
|
if (client != null && client.isSuspended()) {
|
||||||
|
if (overwriteSuspendedMsg) {
|
||||||
|
System.out.println(msg_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println(msg_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -106,8 +106,21 @@ public class GuiTextOneLine implements Gui {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void status(String msg_) {
|
public void status(String msg_) {
|
||||||
status = msg_;
|
status(msg_, false);
|
||||||
updateLine();
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void status(String msg_, boolean overwriteSuspendedMsg) {
|
||||||
|
if (client != null && client.isSuspended()) {
|
||||||
|
if (overwriteSuspendedMsg) {
|
||||||
|
status = msg_;
|
||||||
|
updateLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
status = msg_;
|
||||||
|
updateLine();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ public class Working implements Activity {
|
|||||||
private GuiSwing parent;
|
private GuiSwing parent;
|
||||||
|
|
||||||
private JLabel statusContent;
|
private JLabel statusContent;
|
||||||
|
private String previousStatus;
|
||||||
private JLabel renderedFrameContent;
|
private JLabel renderedFrameContent;
|
||||||
private JLabel remainingFrameContent;
|
private JLabel remainingFrameContent;
|
||||||
private JLabel lastRenderTime;
|
private JLabel lastRenderTime;
|
||||||
@@ -94,6 +95,7 @@ public class Working implements Activity {
|
|||||||
lastRender = new JLabel("");
|
lastRender = new JLabel("");
|
||||||
userInfoQueuedUploadsAndSizeValue = new JLabel("0");
|
userInfoQueuedUploadsAndSizeValue = new JLabel("0");
|
||||||
currentTheme = UIManager.getLookAndFeel().getName(); // Capture the theme on component instantiation
|
currentTheme = UIManager.getLookAndFeel().getName(); // Capture the theme on component instantiation
|
||||||
|
previousStatus = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -217,10 +219,10 @@ public class Working implements Activity {
|
|||||||
JButton settingsButton = new JButton("Settings");
|
JButton settingsButton = new JButton("Settings");
|
||||||
settingsButton.addActionListener(new SettingsAction());
|
settingsButton.addActionListener(new SettingsAction());
|
||||||
|
|
||||||
pauseButton = new JButton("Pause");
|
pauseButton = new JButton("Pause getting new jobs");
|
||||||
Client client = parent.getClient();
|
Client client = parent.getClient();
|
||||||
if (client != null && client.isSuspended()) {
|
if (client != null && client.isSuspended()) {
|
||||||
pauseButton.setText("Resume");
|
pauseButton.setText("Resume getting jobs");
|
||||||
}
|
}
|
||||||
|
|
||||||
pauseButton.addActionListener(new PauseAction());
|
pauseButton.addActionListener(new PauseAction());
|
||||||
@@ -259,7 +261,24 @@ public class Working implements Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(String msg_) {
|
public void setStatus(String msg_) {
|
||||||
statusContent.setText("<html>" + msg_ + "</html>");
|
setStatus(msg_, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String msg_, boolean overwriteSuspendedMsg) {
|
||||||
|
Client client = parent.getClient();
|
||||||
|
|
||||||
|
if (!msg_.equals("")) {
|
||||||
|
this.previousStatus = msg_;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (client != null && client.isSuspended()) {
|
||||||
|
if (overwriteSuspendedMsg) {
|
||||||
|
statusContent.setText("<html>" + msg_ + "</html>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
statusContent.setText("<html>" + msg_ + "</html>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRenderingProjectName(String msg_) {
|
public void setRenderingProjectName(String msg_) {
|
||||||
@@ -343,7 +362,7 @@ public class Working implements Activity {
|
|||||||
if (width * factor > 200) {
|
if (width * factor > 200) {
|
||||||
factor = Math.min(factor, 200f / width);
|
factor = Math.min(factor, 200f / width);
|
||||||
}
|
}
|
||||||
icon = new ImageIcon(img.getScaledInstance((int)(width * factor), (int)(height * factor), Image.SCALE_FAST));
|
icon = new ImageIcon(img.getScaledInstance((int) (width * factor), (int) (height * factor), Image.SCALE_FAST));
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
System.out.println("Working::showLastRender() exception " + e);
|
System.out.println("Working::showLastRender() exception " + e);
|
||||||
@@ -428,12 +447,14 @@ public class Working implements Activity {
|
|||||||
Client client = parent.getClient();
|
Client client = parent.getClient();
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
if (client.isSuspended()) {
|
if (client.isSuspended()) {
|
||||||
pauseButton.setText("Pause");
|
pauseButton.setText("Pause getting new jobs");
|
||||||
client.resume();
|
client.resume();
|
||||||
|
setStatus(previousStatus);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pauseButton.setText("Resume");
|
pauseButton.setText("Resume getting jobs");
|
||||||
client.suspend();
|
client.suspend();
|
||||||
|
setStatus("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user