Update scripts and plugins to 2.0
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
|
||||
import ch.psi.pshell.core.Configuration.NotificationLevel;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.utils.State;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import ch.psi.utils.swing.SwingUtils.OptionResult;
|
||||
import ch.psi.utils.swing.SwingUtils.OptionType;
|
||||
import ch.psi.pshell.console.App;
|
||||
import ch.psi.pshell.framework.Context;
|
||||
import ch.psi.pshell.framework.Setup;
|
||||
import ch.psi.pshell.framework.Panel;
|
||||
import ch.psi.pshell.notification.NotificationManager.NotificationLevel;
|
||||
import ch.psi.pshell.utils.State;
|
||||
import ch.psi.pshell.swing.SwingUtils;
|
||||
import ch.psi.pshell.swing.SwingUtils.OptionResult;
|
||||
import ch.psi.pshell.swing.SwingUtils.OptionType;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -30,7 +33,7 @@ public class Settings extends Panel {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
undo();
|
||||
});
|
||||
textNamePattern.setText(getContext().getConfig().dataPath);
|
||||
textNamePattern.setText(App.getInstance().getConfig().dataPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,12 +53,12 @@ public class Settings extends Panel {
|
||||
|
||||
void undo() {
|
||||
try {
|
||||
textDataPath.setText(getContext().getSetup().expandPath(getContext().getConfig().dataPath));
|
||||
textPGroup.setText(getContext().getSetting("pgroup") == null ? "" : getContext().getSetting("pgroup"));
|
||||
textProposal.setText(getContext().getSetting("proposal") == null ? "" : getContext().getSetting("proposal"));
|
||||
textProposer.setText(getContext().getSetting("proposer") == null ? "" : getContext().getSetting("proposer"));
|
||||
textSamples.setText(getContext().getSetting("sample") == null ? "" : getContext().getSetting("sample"));
|
||||
textAuthors.setText(getContext().getSetting("authors") == null ? "" : getContext().getSetting("authors").replace("|", "\n"));
|
||||
textDataPath.setText(Setup.expandPath(App.getInstance().getConfig().dataPath));
|
||||
textPGroup.setText(Context.getSetting("pgroup") == null ? "" : Context.getSetting("pgroup"));
|
||||
textProposal.setText(Context.getSetting("proposal") == null ? "" : Context.getSetting("proposal"));
|
||||
textProposer.setText(Context.getSetting("proposer") == null ? "" : Context.getSetting("proposer"));
|
||||
textSamples.setText(Context.getSetting("sample") == null ? "" : Context.getSetting("sample"));
|
||||
textAuthors.setText(Context.getSetting("authors") == null ? "" : Context.getSetting("authors").replace("|", "\n"));
|
||||
} catch (Exception ex) {
|
||||
getLogger().log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@@ -71,11 +74,11 @@ public class Settings extends Panel {
|
||||
String samples = textSamples.getText().trim();
|
||||
String authors = textAuthors.getText().trim().replace("\n", "|");
|
||||
|
||||
getContext().setSetting("pgroup", pgroup);
|
||||
getContext().setSetting("proposal", proposal);
|
||||
getContext().setSetting("proposer", proposer);
|
||||
getContext().setSetting("sample", samples);
|
||||
getContext().setSetting("authors", authors);
|
||||
Context.setSetting("pgroup", pgroup);
|
||||
Context.setSetting("proposal", proposal);
|
||||
Context.setSetting("proposer", proposer);
|
||||
Context.setSetting("sample", samples);
|
||||
Context.setSetting("authors", authors);
|
||||
|
||||
} catch (Exception ex) {
|
||||
getLogger().log(Level.SEVERE, null, ex);
|
||||
@@ -134,8 +137,8 @@ public class Settings extends Panel {
|
||||
void updateNotify() {
|
||||
try {
|
||||
updatingControls = true;
|
||||
comboNotification.setSelectedItem(getContext().getConfig().notificationLevel);
|
||||
textRecipients.setText(getContext().getNotificationManager().getConfig().to);
|
||||
comboNotification.setSelectedItem(App.getInstance().getConfig().notificationLevel);
|
||||
textRecipients.setText(Context.getNotificationManager().getConfig().to);
|
||||
} finally {
|
||||
updatingControls = false;
|
||||
}
|
||||
@@ -148,14 +151,14 @@ public class Settings extends Panel {
|
||||
textNamePattern.setEnabled(editable);
|
||||
spinnerSeq.setEnabled(editable);
|
||||
buttonDefaultPath.setEnabled(editable && !textNamePattern.getText().equals(DEFAULT_PATH));
|
||||
buttonSetPath.setEnabled(editable && !textNamePattern.getText().equals(getContext().getConfig().dataPath));
|
||||
buttonUndoPath.setEnabled(editable && !textNamePattern.getText().equals(getContext().getConfig().dataPath));
|
||||
buttonSetSeq.setEnabled(editable && !spinnerSeq.getValue().equals(getContext().getFileSequentialNumber()));
|
||||
buttonUndoSeq.setEnabled(editable && !spinnerSeq.getValue().equals(getContext().getFileSequentialNumber()));
|
||||
buttonSetPath.setEnabled(editable && !textNamePattern.getText().equals(App.getInstance().getConfig().dataPath));
|
||||
buttonUndoPath.setEnabled(editable && !textNamePattern.getText().equals(App.getInstance().getConfig().dataPath));
|
||||
buttonSetSeq.setEnabled(editable && !spinnerSeq.getValue().equals(Context.getFileSequentialNumber()));
|
||||
buttonUndoSeq.setEnabled(editable && !spinnerSeq.getValue().equals(Context.getFileSequentialNumber()));
|
||||
buttonApply.setEnabled(editable);
|
||||
|
||||
spinnerSeq.setValue(getContext().getFileSequentialNumber());
|
||||
textDataPath.setText(getContext().getSetup().expandPath(getContext().getConfig().dataPath));
|
||||
spinnerSeq.setValue(Context.getFileSequentialNumber());
|
||||
textDataPath.setText(Setup.expandPath(App.getInstance().getConfig().dataPath));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -673,7 +676,7 @@ public class Settings extends Panel {
|
||||
|
||||
private void buttonSetSeqActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetSeqActionPerformed
|
||||
try {
|
||||
getContext().setFileSequentialNumber(((Number) spinnerSeq.getValue()).intValue());
|
||||
Context.setFileSequentialNumber(((Number) spinnerSeq.getValue()).intValue());
|
||||
updateControls();
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
@@ -682,7 +685,7 @@ public class Settings extends Panel {
|
||||
|
||||
private void buttonUndoSeqActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUndoSeqActionPerformed
|
||||
try {
|
||||
spinnerSeq.setValue(getContext().getFileSequentialNumber());
|
||||
spinnerSeq.setValue(Context.getFileSequentialNumber());
|
||||
updateControls();
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
@@ -696,8 +699,8 @@ public class Settings extends Panel {
|
||||
|
||||
private void buttonSetPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetPathActionPerformed
|
||||
try {
|
||||
getContext().getConfig().dataPath = textNamePattern.getText();
|
||||
getContext().getConfig().save();
|
||||
App.getInstance().getConfig().dataPath = textNamePattern.getText();
|
||||
App.getInstance().getConfig().save();
|
||||
updateControls();
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
@@ -706,7 +709,7 @@ public class Settings extends Panel {
|
||||
|
||||
private void buttonUndoPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUndoPathActionPerformed
|
||||
try {
|
||||
textNamePattern.setText(getContext().getConfig().dataPath);
|
||||
textNamePattern.setText(App.getInstance().getConfig().dataPath);
|
||||
updateControls();
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
@@ -830,9 +833,9 @@ public class Settings extends Panel {
|
||||
throw new Exception("To enable notifications please set the recepient list.");
|
||||
}
|
||||
}
|
||||
getContext().getConfig().notificationLevel =level;
|
||||
getContext().getNotificationManager().setRecipients(to.split(";"));
|
||||
getContext().getNotificationManager().initialize(); //Remove this when fix setRecipients
|
||||
App.getInstance().getConfig().notificationLevel =level;
|
||||
Context.getNotificationManager().setRecipients(to.split(";"));
|
||||
Context.getNotificationManager().initialize(); //Remove this when fix setRecipients
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user