From 04fa639aa136ffac9f8d78abaafff6e6a1264468 Mon Sep 17 00:00:00 2001
From: anneke02
Date: Mon, 27 May 2024 17:07:51 +0200
Subject: [PATCH 01/76] Added initial JFrame for P2T
Co-authored-by: TimU02
---
.../editor/controller/ActionFactory.java | 2 +-
.../main/java/org/woped/file/p2t/P2TUI.java | 245 ++++++++++++++++++
.../java/org/woped/starter/MainFrame.java | 1 +
.../controller/vep/GUIViewEventProcessor.java | 11 +
4 files changed, 258 insertions(+), 1 deletion(-)
create mode 100644 WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
diff --git a/WoPeD-Editor/src/main/java/org/woped/editor/controller/ActionFactory.java b/WoPeD-Editor/src/main/java/org/woped/editor/controller/ActionFactory.java
index 47332f50e..067dd0490 100644
--- a/WoPeD-Editor/src/main/java/org/woped/editor/controller/ActionFactory.java
+++ b/WoPeD-Editor/src/main/java/org/woped/editor/controller/ActionFactory.java
@@ -643,7 +643,7 @@ public static HashMap createStaticActions(ApplicationMediat
STATIC_ACTION_MAP.put(
ACTIONID_P2T,
new WoPeDAction(
- am, AbstractViewEvent.VIEWEVENTTYPE_EDIT, AbstractViewEvent.P2T, null, ACTIONID_P2T));
+ am, AbstractViewEvent.VIEWEVENTTYPE_GUI, AbstractViewEvent.P2T, null, ACTIONID_P2T));
VisualController.getInstance()
.addElement(
STATIC_ACTION_MAP.get(ACTIONID_P2T),
diff --git a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
new file mode 100644
index 000000000..03b85c7d0
--- /dev/null
+++ b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
@@ -0,0 +1,245 @@
+package org.woped.file.p2t;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Frame;
+import java.awt.HeadlessException;
+import java.awt.Insets;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import javax.swing.AbstractAction;
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.ButtonGroup;
+import javax.swing.ImageIcon;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import org.woped.core.controller.AbstractApplicationMediator;
+import org.woped.editor.controller.vc.EditorVC;
+import org.woped.file.t2p.JTextAreaWithHint;
+import org.woped.file.t2p.PlainTextFileReader;
+import org.woped.gui.lookAndFeel.WopedButton;
+import org.woped.gui.translations.Messages;
+
+public class P2TUI extends JDialog {
+ private JTextAreaWithHint textArea;
+ private JDialog loadDialog;
+ private AbstractApplicationMediator mediator;
+ private boolean requested = false;
+ private String inputText;
+
+ public P2TUI(AbstractApplicationMediator mediator) {
+ this(null, mediator);
+ }
+
+ public P2TUI(Frame owner, AbstractApplicationMediator mediator) throws HeadlessException {
+ super(owner, true);
+ this.mediator = mediator;
+ initialize();
+ }
+
+ private void initialize() {
+ this.setVisible(false);
+ this.getContentPane().setLayout(new BorderLayout());
+ this.setUndecorated(false);
+ this.setResizable(true);
+
+ textArea = new JTextAreaWithHint();
+ this.setTitle(Messages.getString("P2T.tooltip"));
+ this.getContentPane().add(wrapTextArea(initializeTextArea(textArea)), BorderLayout.CENTER);
+ this.getContentPane().add(initializeButtonsPanel(), BorderLayout.SOUTH);
+
+ this.pack();
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ this.setLocation((screenSize.width - this.getWidth()) / 3, (screenSize.height - this.getHeight()) / 3);
+ Dimension size = new Dimension(600, 440);
+ this.setSize(size);
+
+ // Set previous text if available
+ int index = 0;
+ boolean doesContain = false;
+ if (mediator.getViewControllers().containsKey("EDITOR_VC_" + index)) {
+ doesContain = true;
+ while (mediator.getViewControllers().containsKey("EDITOR_VC_" + index)) {
+ index++;
+ }
+ index--;
+ }
+
+ if (doesContain) {
+ String lastTextInput = ((EditorVC) mediator.getViewControllers().get("EDITOR_VC_" + index)).getEditorPanel().getT2PText();
+ textArea.setText(lastTextInput);
+ }
+ }
+
+ private JTextAreaWithHint initializeTextArea(JTextAreaWithHint ta) {
+ Font f = new Font("Lucia Grande", Font.PLAIN, 13);
+ String hint = Messages.getString("P2TUI.HowTo");
+ ta.setFont(f);
+ ta.changeHintText(hint);
+ ta.setLineWrap(true);
+ ta.setWrapStyleWord(true);
+ ta.requestFocus();
+ ta.requestFocusInWindow();
+ ta.setMargin(new Insets(10, 10, 10, 10));
+ return ta;
+ }
+
+ private JScrollPane wrapTextArea(JTextAreaWithHint ta) {
+ JScrollPane scrollPane = new JScrollPane(ta);
+ scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ return scrollPane;
+ }
+
+ private JPanel initializeButtonsPanel() {
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
+ buttonPanel.setBorder(BorderFactory.createEmptyBorder(20, 10, 10, 10));
+
+ String[] lang = {Messages.getString("P2TUI.Lang"), Messages.getString("P2TUI.Lang.English")};
+ JComboBox langBox = new JComboBox<>(lang);
+ langBox.setSelectedIndex(1);
+
+ // Radio buttons for "alt" and "neu"
+ JRadioButton oldRadioButton = new JRadioButton("Alt");
+ JRadioButton newRadioButton = new JRadioButton("Neu");
+ ButtonGroup group = new ButtonGroup();
+ group.add(oldRadioButton);
+ group.add(newRadioButton);
+
+ // API Key input field
+ JLabel apiKeyLabel = new JLabel("API Key:");
+ JTextField apiKeyField = new JTextField();
+ apiKeyLabel.setVisible(false);
+ apiKeyField.setVisible(false);
+
+ newRadioButton.addActionListener(e -> {
+ apiKeyLabel.setVisible(true);
+ apiKeyField.setVisible(true);
+ });
+
+ oldRadioButton.addActionListener(e -> {
+ apiKeyLabel.setVisible(false);
+ apiKeyField.setVisible(false);
+ });
+
+ // Set "alt" as default selection
+ oldRadioButton.setSelected(true);
+
+ WopedButton btnGenerate = new WopedButton(new AbstractAction() {
+ public void actionPerformed(ActionEvent arg0) {
+ request();
+ }
+ });
+
+ btnGenerate.setMnemonic(KeyEvent.VK_A);
+ btnGenerate.setText(Messages.getString("P2TUI.Button.Generate.Text"));
+ btnGenerate.setIcon(loadIcon(Messages.getString("P2TUI.Button.Generate.Icon")));
+
+ WopedButton btnErase = new WopedButton(new AbstractAction() {
+ public void actionPerformed(ActionEvent arg0) {
+ clearTextArea();
+ }
+ });
+
+ btnErase.setMnemonic(KeyEvent.VK_L);
+ btnErase.setText(Messages.getString("P2TUI.Button.Clear.Text"));
+ btnErase.setIcon(loadIcon(Messages.getString("P2TUI.Button.Clear.Icon")));
+
+ WopedButton btnUpload = new WopedButton(new AbstractAction() {
+ public void actionPerformed(ActionEvent arg0) {
+ readFile();
+ }
+ });
+
+ btnUpload.setMnemonic(KeyEvent.VK_C);
+ btnUpload.setText(Messages.getString("P2TUI.Button.Read.Text"));
+ btnUpload.setIcon(loadIcon(Messages.getString("P2TUI.Button.Read.Icon")));
+
+ buttonPanel.add(btnUpload);
+ buttonPanel.add(btnErase);
+ buttonPanel.add(langBox);
+ buttonPanel.add(Box.createHorizontalGlue());
+ buttonPanel.add(oldRadioButton);
+ buttonPanel.add(newRadioButton);
+ buttonPanel.add(apiKeyLabel);
+ buttonPanel.add(apiKeyField);
+ buttonPanel.add(btnGenerate);
+
+ return buttonPanel;
+ }
+
+ private ImageIcon loadIcon(String path) {
+ java.net.URL imgURL = getClass().getResource(path);
+ if (imgURL != null) {
+ return new ImageIcon(imgURL);
+ } else {
+ System.err.println("Couldn't find file: " + path);
+ return null; // or a default icon if you prefer
+ }
+ }
+
+ private void request() {
+ if (requested) return;
+ requested = true;
+
+ inputText = textArea.getText();
+
+ if (!inputText.isEmpty()) {
+ // Implement your request handling here
+ showLoadingBox();
+ } else {
+ showErrorPopUp("P2TUI.NoText.Title", "P2TUI.NoText.Text");
+ }
+
+ requested = false;
+ }
+
+ private void showLoadingBox() {
+ JOptionPane jop = new JOptionPane();
+ jop.setMessageType(JOptionPane.INFORMATION_MESSAGE);
+ jop.setMessage(Messages.getString("P2TUI.Loading.Text"));
+
+ loadDialog = jop.createDialog(this, Messages.getString("P2TUI.Loading.Title"));
+ jop.setOptions(new String[]{Messages.getString("P2TUI.Loading.Cancel")});
+ loadDialog.setVisible(true);
+
+ // Thread gets blocked and awaits an UI action.
+ }
+
+ private void showErrorPopUp(String titleId, String msgId) {
+ String text[] = {Messages.getString("Dialog.Ok")};
+
+ String msg = Messages.getStringReplaced(msgId, null);
+ String title = Messages.getString(titleId);
+ int optionType = JOptionPane.YES_NO_CANCEL_OPTION;
+ int messageType = JOptionPane.ERROR_MESSAGE;
+
+ JOptionPane.showOptionDialog(null, msg, title, optionType, messageType, null, text, text[0]);
+ }
+
+ private void close() {
+ this.dispose();
+ }
+
+ public void clearTextArea() {
+ if (textArea.getText() != null) {
+ textArea.setText(null);
+ }
+ }
+
+ public void readFile() {
+ PlainTextFileReader r = new PlainTextFileReader();
+ String txt = r.read();
+ if (txt != null) textArea.setText(txt);
+ }
+}
diff --git a/WoPeD-Starter/src/main/java/org/woped/starter/MainFrame.java b/WoPeD-Starter/src/main/java/org/woped/starter/MainFrame.java
index 5268c2b57..c3154020d 100644
--- a/WoPeD-Starter/src/main/java/org/woped/starter/MainFrame.java
+++ b/WoPeD-Starter/src/main/java/org/woped/starter/MainFrame.java
@@ -1196,6 +1196,7 @@ private JRibbonBand getP2TBand() {
return p2tBand;
}
+
private JRibbonBand getWindowsBand() {
if (windowsBand == null) {
diff --git a/WoPeD-Starter/src/main/java/org/woped/starter/controller/vep/GUIViewEventProcessor.java b/WoPeD-Starter/src/main/java/org/woped/starter/controller/vep/GUIViewEventProcessor.java
index 263bcdca6..d21aaacad 100644
--- a/WoPeD-Starter/src/main/java/org/woped/starter/controller/vep/GUIViewEventProcessor.java
+++ b/WoPeD-Starter/src/main/java/org/woped/starter/controller/vep/GUIViewEventProcessor.java
@@ -46,6 +46,7 @@
import org.woped.editor.controller.vc.SubprocessEditorVC;
import org.woped.editor.help.HelpBrowser;
import org.woped.editor.help.action.LaunchDefaultBrowserAction;
+import org.woped.file.p2t.P2TUI;
import org.woped.file.t2p.T2PUI;
import org.woped.gui.translations.Messages;
import org.woped.qualanalysis.service.IQualanalysisService;
@@ -82,6 +83,16 @@ && getMediator().getUi().getComponent() instanceof JFrame) {
}
t2p.setVisible(true);
break;
+ case AbstractViewEvent.P2T:
+ P2TUI p2t;
+ if (getMediator().getUi() != null
+ && getMediator().getUi().getComponent() instanceof JFrame) {
+ p2t = new P2TUI((JFrame) getMediator().getUi(), getMediator());
+ } else {
+ p2t = new P2TUI(getMediator());
+ }
+ p2t.setVisible(true);
+ break;
case AbstractViewEvent.NEW:
getMediator().createEditor(true);
break;
From bb24ad55a128c88903b09446e3f3f856aafd7a0a Mon Sep 17 00:00:00 2001
From: anneke02
Date: Tue, 28 May 2024 10:34:33 +0200
Subject: [PATCH 02/76] Edited JFrame with radio buttons and added descriptions
Co-authored-by: TimU02
---
.../main/java/org/woped/file/p2t/P2TUI.java | 144 +++++-------------
.../src/main/resources/Messages.properties | 4 +
.../src/main/resources/Messages_de.properties | 4 +
3 files changed, 44 insertions(+), 108 deletions(-)
diff --git a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
index 03b85c7d0..717c4d111 100644
--- a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
+++ b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
@@ -15,27 +15,23 @@
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
-import javax.swing.JComboBox;
+import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
-import javax.swing.JScrollPane;
import javax.swing.JTextField;
import org.woped.core.controller.AbstractApplicationMediator;
import org.woped.editor.controller.vc.EditorVC;
import org.woped.file.t2p.JTextAreaWithHint;
-import org.woped.file.t2p.PlainTextFileReader;
import org.woped.gui.lookAndFeel.WopedButton;
import org.woped.gui.translations.Messages;
public class P2TUI extends JDialog {
- private JTextAreaWithHint textArea;
private JDialog loadDialog;
private AbstractApplicationMediator mediator;
private boolean requested = false;
- private String inputText;
public P2TUI(AbstractApplicationMediator mediator) {
this(null, mediator);
@@ -52,73 +48,35 @@ private void initialize() {
this.getContentPane().setLayout(new BorderLayout());
this.setUndecorated(false);
this.setResizable(true);
+ this.setTitle(Messages.getString("P2T.openP2T.text"));
- textArea = new JTextAreaWithHint();
- this.setTitle(Messages.getString("P2T.tooltip"));
- this.getContentPane().add(wrapTextArea(initializeTextArea(textArea)), BorderLayout.CENTER);
- this.getContentPane().add(initializeButtonsPanel(), BorderLayout.SOUTH);
+ // Add switch button panel to the top left
+ this.getContentPane().add(initializeSwitchButtonPanel(), BorderLayout.NORTH);
+
+ // Add a single button to the bottom center
+ this.getContentPane().add(initializeSingleButtonPanel(), BorderLayout.SOUTH);
this.pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation((screenSize.width - this.getWidth()) / 3, (screenSize.height - this.getHeight()) / 3);
- Dimension size = new Dimension(600, 440);
+ Dimension size = new Dimension(600, 140);
this.setSize(size);
-
- // Set previous text if available
- int index = 0;
- boolean doesContain = false;
- if (mediator.getViewControllers().containsKey("EDITOR_VC_" + index)) {
- doesContain = true;
- while (mediator.getViewControllers().containsKey("EDITOR_VC_" + index)) {
- index++;
- }
- index--;
- }
-
- if (doesContain) {
- String lastTextInput = ((EditorVC) mediator.getViewControllers().get("EDITOR_VC_" + index)).getEditorPanel().getT2PText();
- textArea.setText(lastTextInput);
- }
- }
-
- private JTextAreaWithHint initializeTextArea(JTextAreaWithHint ta) {
- Font f = new Font("Lucia Grande", Font.PLAIN, 13);
- String hint = Messages.getString("P2TUI.HowTo");
- ta.setFont(f);
- ta.changeHintText(hint);
- ta.setLineWrap(true);
- ta.setWrapStyleWord(true);
- ta.requestFocus();
- ta.requestFocusInWindow();
- ta.setMargin(new Insets(10, 10, 10, 10));
- return ta;
}
- private JScrollPane wrapTextArea(JTextAreaWithHint ta) {
- JScrollPane scrollPane = new JScrollPane(ta);
- scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
- return scrollPane;
- }
-
- private JPanel initializeButtonsPanel() {
- JPanel buttonPanel = new JPanel();
- buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
- buttonPanel.setBorder(BorderFactory.createEmptyBorder(20, 10, 10, 10));
-
- String[] lang = {Messages.getString("P2TUI.Lang"), Messages.getString("P2TUI.Lang.English")};
- JComboBox langBox = new JComboBox<>(lang);
- langBox.setSelectedIndex(1);
+ private JPanel initializeSwitchButtonPanel() {
+ JPanel switchButtonPanel = new JPanel();
+ switchButtonPanel.setLayout(new BoxLayout(switchButtonPanel, BoxLayout.LINE_AXIS));
+ switchButtonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
- // Radio buttons for "alt" and "neu"
- JRadioButton oldRadioButton = new JRadioButton("Alt");
- JRadioButton newRadioButton = new JRadioButton("Neu");
+ JRadioButton oldRadioButton = new JRadioButton(Messages.getString("P2T.oldservice.title"));
+ JRadioButton newRadioButton = new JRadioButton(Messages.getString("P2T.newservice.title"));
ButtonGroup group = new ButtonGroup();
group.add(oldRadioButton);
group.add(newRadioButton);
- // API Key input field
- JLabel apiKeyLabel = new JLabel("API Key:");
+ JLabel apiKeyLabel = new JLabel(Messages.getString("P2T.apikey.title"));
JTextField apiKeyField = new JTextField();
+ apiKeyField.setPreferredSize(new Dimension(200, 25)); // Set the preferred size to make it wider
apiKeyLabel.setVisible(false);
apiKeyField.setVisible(false);
@@ -135,45 +93,33 @@ private JPanel initializeButtonsPanel() {
// Set "alt" as default selection
oldRadioButton.setSelected(true);
- WopedButton btnGenerate = new WopedButton(new AbstractAction() {
- public void actionPerformed(ActionEvent arg0) {
- request();
- }
- });
-
- btnGenerate.setMnemonic(KeyEvent.VK_A);
- btnGenerate.setText(Messages.getString("P2TUI.Button.Generate.Text"));
- btnGenerate.setIcon(loadIcon(Messages.getString("P2TUI.Button.Generate.Icon")));
+ switchButtonPanel.add(oldRadioButton);
+ switchButtonPanel.add(newRadioButton);
+ switchButtonPanel.add(apiKeyLabel);
+ switchButtonPanel.add(apiKeyField);
- WopedButton btnErase = new WopedButton(new AbstractAction() {
- public void actionPerformed(ActionEvent arg0) {
- clearTextArea();
- }
- });
+ return switchButtonPanel;
+ }
- btnErase.setMnemonic(KeyEvent.VK_L);
- btnErase.setText(Messages.getString("P2TUI.Button.Clear.Text"));
- btnErase.setIcon(loadIcon(Messages.getString("P2TUI.Button.Clear.Icon")));
+ private JPanel initializeSingleButtonPanel() {
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
+ buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
- WopedButton btnUpload = new WopedButton(new AbstractAction() {
+ JButton singleButton = new JButton(new AbstractAction() {
public void actionPerformed(ActionEvent arg0) {
- readFile();
+ // Implement your action here
+ request();
}
});
- btnUpload.setMnemonic(KeyEvent.VK_C);
- btnUpload.setText(Messages.getString("P2TUI.Button.Read.Text"));
- btnUpload.setIcon(loadIcon(Messages.getString("P2TUI.Button.Read.Icon")));
+ singleButton.setMnemonic(KeyEvent.VK_A);
+ singleButton.setText(Messages.getString("P2T.tooltip"));
+ singleButton.setIcon(loadIcon(Messages.getString("P2TUI.Button.Generate.Icon")));
- buttonPanel.add(btnUpload);
- buttonPanel.add(btnErase);
- buttonPanel.add(langBox);
buttonPanel.add(Box.createHorizontalGlue());
- buttonPanel.add(oldRadioButton);
- buttonPanel.add(newRadioButton);
- buttonPanel.add(apiKeyLabel);
- buttonPanel.add(apiKeyField);
- buttonPanel.add(btnGenerate);
+ buttonPanel.add(singleButton);
+ buttonPanel.add(Box.createHorizontalGlue());
return buttonPanel;
}
@@ -192,14 +138,8 @@ private void request() {
if (requested) return;
requested = true;
- inputText = textArea.getText();
-
- if (!inputText.isEmpty()) {
- // Implement your request handling here
- showLoadingBox();
- } else {
- showErrorPopUp("P2TUI.NoText.Title", "P2TUI.NoText.Text");
- }
+ // Implement your request handling here
+ showLoadingBox();
requested = false;
}
@@ -230,16 +170,4 @@ private void showErrorPopUp(String titleId, String msgId) {
private void close() {
this.dispose();
}
-
- public void clearTextArea() {
- if (textArea.getText() != null) {
- textArea.setText(null);
- }
- }
-
- public void readFile() {
- PlainTextFileReader r = new PlainTextFileReader();
- String txt = r.read();
- if (txt != null) textArea.setText(txt);
- }
}
diff --git a/WoPeD-GUI/src/main/resources/Messages.properties b/WoPeD-GUI/src/main/resources/Messages.properties
index b2cc69c07..537bcc8c5 100644
--- a/WoPeD-GUI/src/main/resources/Messages.properties
+++ b/WoPeD-GUI/src/main/resources/Messages.properties
@@ -873,6 +873,10 @@ P2T.SizeError = Modell has too few nodes - no text can be gene
P2T.Error.ArcWeights.title = Text generation failed
P2T.Error.ArcWeights.message = The net contains arc weights.\nArc weights are not supported by the process 2 text feature.
+P2T.oldservice.title = Old
+P2T.newservice.title = New
+P2T.apikey.title = API Key
+
#*************
! Text2Process
#*************
diff --git a/WoPeD-GUI/src/main/resources/Messages_de.properties b/WoPeD-GUI/src/main/resources/Messages_de.properties
index b3c3fe8eb..ee621fc74 100644
--- a/WoPeD-GUI/src/main/resources/Messages_de.properties
+++ b/WoPeD-GUI/src/main/resources/Messages_de.properties
@@ -478,6 +478,9 @@ P2T.SoundError =
Modell ist nicht sound - kein Text generierbar
P2T.SizeError = Modell hat zuwenige Knoten - kein Text generierbar
P2T.Error.ArcWeights.title = Textgenerierung fehlgeschlagen
P2T.Error.ArcWeights.message = Das Netz verwendet Kantengewichte. \nKantengewichte werden bei der Textgenerierung nicht unterst\u00FCtzt.
+P2T.oldservice.title = Alt
+P2T.newservice.title = Neu
+P2T.apikey.title = API Schl\u00FCssel
#*************
! Text 2 Process
#*************
@@ -487,6 +490,7 @@ T2P.openT2P.text = Text zu Prozess
T2P.tooltip = Petrinetz erzeugen
T2P.Error.ArcWeights.title = Petrinetz-Erzeugung fehlgeschlagen
T2P.Error.ArcWeights.message = Das Netz besitzt Kantengewichte.\nKantengewichte werden bei der Prozessgenerierung nicht unterst\u00FCtzt..
+
#*************
! Forms
#*************
From e41faa68c99dc0adfda9b103a72efa2640214a07 Mon Sep 17 00:00:00 2001
From: anneke02
Date: Tue, 28 May 2024 11:09:29 +0200
Subject: [PATCH 03/76] Added API key validation
---
.../main/java/org/woped/file/p2t/P2TUI.java | 45 ++++++++++++-------
.../src/main/resources/Messages.properties | 2 +
.../src/main/resources/Messages_de.properties | 2 +
3 files changed, 33 insertions(+), 16 deletions(-)
diff --git a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
index 717c4d111..7756e5c7c 100644
--- a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
+++ b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
@@ -2,13 +2,15 @@
import java.awt.BorderLayout;
import java.awt.Dimension;
-import java.awt.Font;
import java.awt.Frame;
import java.awt.HeadlessException;
-import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.Box;
@@ -23,15 +25,13 @@
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import org.woped.core.controller.AbstractApplicationMediator;
-import org.woped.editor.controller.vc.EditorVC;
-import org.woped.file.t2p.JTextAreaWithHint;
-import org.woped.gui.lookAndFeel.WopedButton;
import org.woped.gui.translations.Messages;
public class P2TUI extends JDialog {
private JDialog loadDialog;
private AbstractApplicationMediator mediator;
private boolean requested = false;
+ private JTextField apiKeyField;
public P2TUI(AbstractApplicationMediator mediator) {
this(null, mediator);
@@ -75,7 +75,7 @@ private JPanel initializeSwitchButtonPanel() {
group.add(newRadioButton);
JLabel apiKeyLabel = new JLabel(Messages.getString("P2T.apikey.title"));
- JTextField apiKeyField = new JTextField();
+ apiKeyField = new JTextField();
apiKeyField.setPreferredSize(new Dimension(200, 25)); // Set the preferred size to make it wider
apiKeyLabel.setVisible(false);
apiKeyField.setVisible(false);
@@ -108,14 +108,13 @@ private JPanel initializeSingleButtonPanel() {
JButton singleButton = new JButton(new AbstractAction() {
public void actionPerformed(ActionEvent arg0) {
- // Implement your action here
- request();
+ validateAPIKey();
}
});
singleButton.setMnemonic(KeyEvent.VK_A);
- singleButton.setText(Messages.getString("P2T.tooltip"));
- singleButton.setIcon(loadIcon(Messages.getString("P2TUI.Button.Generate.Icon")));
+ singleButton.setText(Messages.getString("P2T.text"));
+ //singleButton.setIcon(loadIcon(Messages.getString("P2TUI.Button.Validate.Icon")));
buttonPanel.add(Box.createHorizontalGlue());
buttonPanel.add(singleButton);
@@ -134,14 +133,28 @@ private ImageIcon loadIcon(String path) {
}
}
- private void request() {
- if (requested) return;
- requested = true;
+ private void validateAPIKey() {
+ String apiKey = apiKeyField.getText();
+ if (!isAPIKeyValid(apiKey)) {
+ JOptionPane.showMessageDialog(this, Messages.getString("P2T.apikey.invalid"), Messages.getString("P2T.apikey.invalid.title"), JOptionPane.ERROR_MESSAGE);
+ }
+ }
- // Implement your request handling here
- showLoadingBox();
+ public static boolean isAPIKeyValid(String apiKey) {
+ final String TEST_URL = "https://api.openai.com/v1/engines";
+ try {
+ URL url = new URL(TEST_URL);
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod("GET");
+ connection.setRequestProperty("Authorization", "Bearer " + apiKey);
- requested = false;
+ int responseCode = connection.getResponseCode();
+
+ return responseCode == 200;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
}
private void showLoadingBox() {
diff --git a/WoPeD-GUI/src/main/resources/Messages.properties b/WoPeD-GUI/src/main/resources/Messages.properties
index 537bcc8c5..61641ac4b 100644
--- a/WoPeD-GUI/src/main/resources/Messages.properties
+++ b/WoPeD-GUI/src/main/resources/Messages.properties
@@ -876,6 +876,8 @@ P2T.Error.ArcWeights.message = The net contains arc weights.\nArc wei
P2T.oldservice.title = Old
P2T.newservice.title = New
P2T.apikey.title = API Key
+P2T.apikey.invalid = API Key is not valid
+P2T.apikey.invalid.title = Validation Error
#*************
! Text2Process
diff --git a/WoPeD-GUI/src/main/resources/Messages_de.properties b/WoPeD-GUI/src/main/resources/Messages_de.properties
index ee621fc74..47cd36bcb 100644
--- a/WoPeD-GUI/src/main/resources/Messages_de.properties
+++ b/WoPeD-GUI/src/main/resources/Messages_de.properties
@@ -481,6 +481,8 @@ P2T.Error.ArcWeights.message = Das Netz verwendet Kantengewichte. \nKantengewic
P2T.oldservice.title = Alt
P2T.newservice.title = Neu
P2T.apikey.title = API Schl\u00FCssel
+P2T.apikey.invalid = API Schl\u00FCssel ist nicht valide
+P2T.apikey.invalid.title = Validierungsfehler
#*************
! Text 2 Process
#*************
From ea50494d5c000a6b8b305ed779b0a271a107ecc4 Mon Sep 17 00:00:00 2001
From: I552396
Date: Tue, 28 May 2024 11:26:08 +0200
Subject: [PATCH 04/76] Add focus in API key field
---
WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
index 7756e5c7c..5a48a3ca8 100644
--- a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
+++ b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
@@ -83,6 +83,7 @@ private JPanel initializeSwitchButtonPanel() {
newRadioButton.addActionListener(e -> {
apiKeyLabel.setVisible(true);
apiKeyField.setVisible(true);
+ apiKeyField.requestFocusInWindow();
});
oldRadioButton.addActionListener(e -> {
From 2310eefe77d914a1453d4b3b49e57ec1c8f3018a Mon Sep 17 00:00:00 2001
From: Marcel2511
Date: Tue, 4 Jun 2024 06:59:39 +0200
Subject: [PATCH 05/76] fork due to lack of write access
---
WoPeD-CommonLibs/pom.xml | 11 +-
.../main/java/org/woped/file/p2t/P2TUI.java | 132 ++++++++++++++----
WoPeD-Installer/pom.xml | 3 +-
WoPeD-Starter/pom.xml | 1 +
4 files changed, 115 insertions(+), 32 deletions(-)
diff --git a/WoPeD-CommonLibs/pom.xml b/WoPeD-CommonLibs/pom.xml
index 863931064..f234d7d5f 100644
--- a/WoPeD-CommonLibs/pom.xml
+++ b/WoPeD-CommonLibs/pom.xml
@@ -1,7 +1,7 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
@@ -21,6 +21,13 @@
+
+ de.dhbw.woped
+ jgraph
+ 5.10.2
+ system
+ ${project.basedir}/lib/jgraph-5.10.2.jar
+
de.dhbw.woped
jgraph
diff --git a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
index 5a48a3ca8..514c3cdf8 100644
--- a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
+++ b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
@@ -3,7 +3,10 @@
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
import java.awt.HeadlessException;
+import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
@@ -13,16 +16,17 @@
import java.net.URL;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
-import javax.swing.Box;
-import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
+import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
+import javax.swing.JScrollPane;
import javax.swing.JRadioButton;
+import javax.swing.JTextArea;
import javax.swing.JTextField;
import org.woped.core.controller.AbstractApplicationMediator;
import org.woped.gui.translations.Messages;
@@ -32,6 +36,9 @@ public class P2TUI extends JDialog {
private AbstractApplicationMediator mediator;
private boolean requested = false;
private JTextField apiKeyField;
+ private JTextArea promptField; // Changed to JTextArea for multiline
+ private JCheckBox enablePromptCheckBox; // New Checkbox
+ private static final String DEFAULT_PROMPT = "Create a clearly structured and comprehensible continuous text from the given BPMN that is understandable for an uninformed reader. The text should be easy to read in the summary and contain all important content; if there are subdivided points, these are integrated into the text with suitable sentence beginnings in order to obtain a well-structured and easy-to-read text. Under no circumstances should the output contain sub-items or paragraphs, but should cover all processes in one piece!";
public P2TUI(AbstractApplicationMediator mediator) {
this(null, mediator);
@@ -50,7 +57,7 @@ private void initialize() {
this.setResizable(true);
this.setTitle(Messages.getString("P2T.openP2T.text"));
- // Add switch button panel to the top left
+ // Add switch button panel to the top
this.getContentPane().add(initializeSwitchButtonPanel(), BorderLayout.NORTH);
// Add a single button to the bottom center
@@ -59,14 +66,16 @@ private void initialize() {
this.pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation((screenSize.width - this.getWidth()) / 3, (screenSize.height - this.getHeight()) / 3);
- Dimension size = new Dimension(600, 140);
+ Dimension size = new Dimension(600, 300); // Adjusted size to accommodate new text field and checkbox
this.setSize(size);
}
private JPanel initializeSwitchButtonPanel() {
- JPanel switchButtonPanel = new JPanel();
- switchButtonPanel.setLayout(new BoxLayout(switchButtonPanel, BoxLayout.LINE_AXIS));
- switchButtonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ JPanel switchButtonPanel = new JPanel(new GridBagLayout());
+ GridBagConstraints gbc = new GridBagConstraints();
+
+ JPanel radioPanel = new JPanel(new GridBagLayout());
+ GridBagConstraints gbcRadio = new GridBagConstraints();
JRadioButton oldRadioButton = new JRadioButton(Messages.getString("P2T.oldservice.title"));
JRadioButton newRadioButton = new JRadioButton(Messages.getString("P2T.newservice.title"));
@@ -74,37 +83,115 @@ private JPanel initializeSwitchButtonPanel() {
group.add(oldRadioButton);
group.add(newRadioButton);
- JLabel apiKeyLabel = new JLabel(Messages.getString("P2T.apikey.title"));
+ gbcRadio.gridx = 0;
+ gbcRadio.gridy = 0;
+ gbcRadio.insets = new Insets(5, 5, 5, 5);
+ radioPanel.add(oldRadioButton, gbcRadio);
+
+ gbcRadio.gridx = 1;
+ gbcRadio.insets = new Insets(5, 0, 5, 5);
+ radioPanel.add(newRadioButton, gbcRadio);
+
+ gbc.gridx = 0;
+ gbc.gridy = 0;
+ gbc.insets = new Insets(5, 5, 5, 5);
+ gbc.anchor = GridBagConstraints.CENTER;
+ switchButtonPanel.add(radioPanel, gbc);
+
+ JPanel fieldsPanel = new JPanel(new GridBagLayout());
+
+ JLabel apiKeyLabel = new JLabel(Messages.getString("P2T.apikey.title") + ":");
apiKeyField = new JTextField();
- apiKeyField.setPreferredSize(new Dimension(200, 25)); // Set the preferred size to make it wider
+ apiKeyField.setPreferredSize(new Dimension(200, 25));
+
+ JLabel promptLabel = new JLabel("Prompt:");
+ promptField = new JTextArea(DEFAULT_PROMPT); // Changed to JTextArea
+ promptField.setLineWrap(true);
+ promptField.setWrapStyleWord(true);
+ promptField.setRows(5); // Set initial number of rows
+ promptField.setEnabled(false); // Initially disabled
+
+ JScrollPane promptScrollPane = new JScrollPane(promptField);
+ promptScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
+ promptScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ promptScrollPane.setPreferredSize(new Dimension(200, 100));
+
+ enablePromptCheckBox = new JCheckBox("Enable editing prompt");
+ enablePromptCheckBox.setSelected(false);
+ enablePromptCheckBox.addActionListener(e -> {
+ promptField.setEnabled(enablePromptCheckBox.isSelected());
+ if (!enablePromptCheckBox.isSelected()) {
+ promptField.setText(DEFAULT_PROMPT); // Reset text when disabled
+ promptField.revalidate();
+ }
+ });
+
apiKeyLabel.setVisible(false);
apiKeyField.setVisible(false);
+ promptLabel.setVisible(false);
+ promptScrollPane.setVisible(false);
+ enablePromptCheckBox.setVisible(false);
newRadioButton.addActionListener(e -> {
apiKeyLabel.setVisible(true);
apiKeyField.setVisible(true);
+ promptLabel.setVisible(true);
+ promptScrollPane.setVisible(true);
+ enablePromptCheckBox.setVisible(true);
apiKeyField.requestFocusInWindow();
});
oldRadioButton.addActionListener(e -> {
apiKeyLabel.setVisible(false);
apiKeyField.setVisible(false);
+ promptLabel.setVisible(false);
+ promptScrollPane.setVisible(false);
+ enablePromptCheckBox.setVisible(false);
});
// Set "alt" as default selection
oldRadioButton.setSelected(true);
- switchButtonPanel.add(oldRadioButton);
- switchButtonPanel.add(newRadioButton);
- switchButtonPanel.add(apiKeyLabel);
- switchButtonPanel.add(apiKeyField);
+ gbc.gridx = 0;
+ gbc.gridy = 1;
+ gbc.anchor = GridBagConstraints.WEST;
+ gbc.insets = new Insets(5, 5, 5, 5);
+ fieldsPanel.add(apiKeyLabel, gbc);
+
+ gbc.gridx = 1;
+ gbc.weightx = 1.0;
+ gbc.fill = GridBagConstraints.HORIZONTAL;
+ fieldsPanel.add(apiKeyField, gbc);
+
+ gbc.gridx = 0;
+ gbc.gridy = 2;
+ gbc.fill = GridBagConstraints.NONE;
+ gbc.weightx = 0;
+ fieldsPanel.add(promptLabel, gbc);
+
+ gbc.gridx = 1;
+ gbc.weightx = 1.0;
+ gbc.fill = GridBagConstraints.HORIZONTAL;
+ fieldsPanel.add(promptScrollPane, gbc);
+
+ gbc.gridx = 0;
+ gbc.gridy = 3;
+ gbc.gridwidth = 2;
+ gbc.weightx = 1.0;
+ fieldsPanel.add(enablePromptCheckBox, gbc);
+
+ gbc.gridx = 0;
+ gbc.gridy = 1;
+ gbc.gridwidth = 2;
+ gbc.insets = new Insets(10, 0, 0, 0);
+ gbc.fill = GridBagConstraints.HORIZONTAL;
+ switchButtonPanel.add(fieldsPanel, gbc);
return switchButtonPanel;
}
private JPanel initializeSingleButtonPanel() {
- JPanel buttonPanel = new JPanel();
- buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
+ JPanel buttonPanel = new JPanel(new BorderLayout());
buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
JButton singleButton = new JButton(new AbstractAction() {
@@ -115,25 +202,12 @@ public void actionPerformed(ActionEvent arg0) {
singleButton.setMnemonic(KeyEvent.VK_A);
singleButton.setText(Messages.getString("P2T.text"));
- //singleButton.setIcon(loadIcon(Messages.getString("P2TUI.Button.Validate.Icon")));
- buttonPanel.add(Box.createHorizontalGlue());
- buttonPanel.add(singleButton);
- buttonPanel.add(Box.createHorizontalGlue());
+ buttonPanel.add(singleButton, BorderLayout.CENTER);
return buttonPanel;
}
- private ImageIcon loadIcon(String path) {
- java.net.URL imgURL = getClass().getResource(path);
- if (imgURL != null) {
- return new ImageIcon(imgURL);
- } else {
- System.err.println("Couldn't find file: " + path);
- return null; // or a default icon if you prefer
- }
- }
-
private void validateAPIKey() {
String apiKey = apiKeyField.getText();
if (!isAPIKeyValid(apiKey)) {
diff --git a/WoPeD-Installer/pom.xml b/WoPeD-Installer/pom.xml
index 98c449518..b418ad4e2 100644
--- a/WoPeD-Installer/pom.xml
+++ b/WoPeD-Installer/pom.xml
@@ -35,6 +35,7 @@
org.apache.maven.plugins
maven-antrun-plugin
+ 1.8
com.akathist.maven.plugins.launch4j
@@ -327,7 +328,7 @@
-
+
diff --git a/WoPeD-Starter/pom.xml b/WoPeD-Starter/pom.xml
index d4b8021cd..a2321ff39 100644
--- a/WoPeD-Starter/pom.xml
+++ b/WoPeD-Starter/pom.xml
@@ -37,6 +37,7 @@
maven-antrun-plugin
+ 1.8
sh.tak.appbundler
From d47be3c54d07fe00fb40792970e3e2738e630ebb Mon Sep 17 00:00:00 2001
From: Marcel2511
Date: Tue, 4 Jun 2024 12:24:25 +0200
Subject: [PATCH 06/76] Refactored Popup, added field for prompt
Refactored the Popup window that includes the switch button
added a field for the gpt prompt
added a lock for the prompt so that the prompt can only be edited when unlocked
---
WoPeD-CommonLibs/pom.xml | 11 +-
.../main/java/org/woped/file/p2t/P2TUI.java | 132 ++++++++++++++----
WoPeD-Installer/pom.xml | 5 +-
WoPeD-Starter/pom.xml | 5 +-
4 files changed, 118 insertions(+), 35 deletions(-)
diff --git a/WoPeD-CommonLibs/pom.xml b/WoPeD-CommonLibs/pom.xml
index 863931064..f234d7d5f 100644
--- a/WoPeD-CommonLibs/pom.xml
+++ b/WoPeD-CommonLibs/pom.xml
@@ -1,7 +1,7 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
@@ -21,6 +21,13 @@
+
+ de.dhbw.woped
+ jgraph
+ 5.10.2
+ system
+ ${project.basedir}/lib/jgraph-5.10.2.jar
+
de.dhbw.woped
jgraph
diff --git a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
index 5a48a3ca8..514c3cdf8 100644
--- a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
+++ b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
@@ -3,7 +3,10 @@
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
import java.awt.HeadlessException;
+import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
@@ -13,16 +16,17 @@
import java.net.URL;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
-import javax.swing.Box;
-import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
+import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
+import javax.swing.JScrollPane;
import javax.swing.JRadioButton;
+import javax.swing.JTextArea;
import javax.swing.JTextField;
import org.woped.core.controller.AbstractApplicationMediator;
import org.woped.gui.translations.Messages;
@@ -32,6 +36,9 @@ public class P2TUI extends JDialog {
private AbstractApplicationMediator mediator;
private boolean requested = false;
private JTextField apiKeyField;
+ private JTextArea promptField; // Changed to JTextArea for multiline
+ private JCheckBox enablePromptCheckBox; // New Checkbox
+ private static final String DEFAULT_PROMPT = "Create a clearly structured and comprehensible continuous text from the given BPMN that is understandable for an uninformed reader. The text should be easy to read in the summary and contain all important content; if there are subdivided points, these are integrated into the text with suitable sentence beginnings in order to obtain a well-structured and easy-to-read text. Under no circumstances should the output contain sub-items or paragraphs, but should cover all processes in one piece!";
public P2TUI(AbstractApplicationMediator mediator) {
this(null, mediator);
@@ -50,7 +57,7 @@ private void initialize() {
this.setResizable(true);
this.setTitle(Messages.getString("P2T.openP2T.text"));
- // Add switch button panel to the top left
+ // Add switch button panel to the top
this.getContentPane().add(initializeSwitchButtonPanel(), BorderLayout.NORTH);
// Add a single button to the bottom center
@@ -59,14 +66,16 @@ private void initialize() {
this.pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation((screenSize.width - this.getWidth()) / 3, (screenSize.height - this.getHeight()) / 3);
- Dimension size = new Dimension(600, 140);
+ Dimension size = new Dimension(600, 300); // Adjusted size to accommodate new text field and checkbox
this.setSize(size);
}
private JPanel initializeSwitchButtonPanel() {
- JPanel switchButtonPanel = new JPanel();
- switchButtonPanel.setLayout(new BoxLayout(switchButtonPanel, BoxLayout.LINE_AXIS));
- switchButtonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ JPanel switchButtonPanel = new JPanel(new GridBagLayout());
+ GridBagConstraints gbc = new GridBagConstraints();
+
+ JPanel radioPanel = new JPanel(new GridBagLayout());
+ GridBagConstraints gbcRadio = new GridBagConstraints();
JRadioButton oldRadioButton = new JRadioButton(Messages.getString("P2T.oldservice.title"));
JRadioButton newRadioButton = new JRadioButton(Messages.getString("P2T.newservice.title"));
@@ -74,37 +83,115 @@ private JPanel initializeSwitchButtonPanel() {
group.add(oldRadioButton);
group.add(newRadioButton);
- JLabel apiKeyLabel = new JLabel(Messages.getString("P2T.apikey.title"));
+ gbcRadio.gridx = 0;
+ gbcRadio.gridy = 0;
+ gbcRadio.insets = new Insets(5, 5, 5, 5);
+ radioPanel.add(oldRadioButton, gbcRadio);
+
+ gbcRadio.gridx = 1;
+ gbcRadio.insets = new Insets(5, 0, 5, 5);
+ radioPanel.add(newRadioButton, gbcRadio);
+
+ gbc.gridx = 0;
+ gbc.gridy = 0;
+ gbc.insets = new Insets(5, 5, 5, 5);
+ gbc.anchor = GridBagConstraints.CENTER;
+ switchButtonPanel.add(radioPanel, gbc);
+
+ JPanel fieldsPanel = new JPanel(new GridBagLayout());
+
+ JLabel apiKeyLabel = new JLabel(Messages.getString("P2T.apikey.title") + ":");
apiKeyField = new JTextField();
- apiKeyField.setPreferredSize(new Dimension(200, 25)); // Set the preferred size to make it wider
+ apiKeyField.setPreferredSize(new Dimension(200, 25));
+
+ JLabel promptLabel = new JLabel("Prompt:");
+ promptField = new JTextArea(DEFAULT_PROMPT); // Changed to JTextArea
+ promptField.setLineWrap(true);
+ promptField.setWrapStyleWord(true);
+ promptField.setRows(5); // Set initial number of rows
+ promptField.setEnabled(false); // Initially disabled
+
+ JScrollPane promptScrollPane = new JScrollPane(promptField);
+ promptScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
+ promptScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ promptScrollPane.setPreferredSize(new Dimension(200, 100));
+
+ enablePromptCheckBox = new JCheckBox("Enable editing prompt");
+ enablePromptCheckBox.setSelected(false);
+ enablePromptCheckBox.addActionListener(e -> {
+ promptField.setEnabled(enablePromptCheckBox.isSelected());
+ if (!enablePromptCheckBox.isSelected()) {
+ promptField.setText(DEFAULT_PROMPT); // Reset text when disabled
+ promptField.revalidate();
+ }
+ });
+
apiKeyLabel.setVisible(false);
apiKeyField.setVisible(false);
+ promptLabel.setVisible(false);
+ promptScrollPane.setVisible(false);
+ enablePromptCheckBox.setVisible(false);
newRadioButton.addActionListener(e -> {
apiKeyLabel.setVisible(true);
apiKeyField.setVisible(true);
+ promptLabel.setVisible(true);
+ promptScrollPane.setVisible(true);
+ enablePromptCheckBox.setVisible(true);
apiKeyField.requestFocusInWindow();
});
oldRadioButton.addActionListener(e -> {
apiKeyLabel.setVisible(false);
apiKeyField.setVisible(false);
+ promptLabel.setVisible(false);
+ promptScrollPane.setVisible(false);
+ enablePromptCheckBox.setVisible(false);
});
// Set "alt" as default selection
oldRadioButton.setSelected(true);
- switchButtonPanel.add(oldRadioButton);
- switchButtonPanel.add(newRadioButton);
- switchButtonPanel.add(apiKeyLabel);
- switchButtonPanel.add(apiKeyField);
+ gbc.gridx = 0;
+ gbc.gridy = 1;
+ gbc.anchor = GridBagConstraints.WEST;
+ gbc.insets = new Insets(5, 5, 5, 5);
+ fieldsPanel.add(apiKeyLabel, gbc);
+
+ gbc.gridx = 1;
+ gbc.weightx = 1.0;
+ gbc.fill = GridBagConstraints.HORIZONTAL;
+ fieldsPanel.add(apiKeyField, gbc);
+
+ gbc.gridx = 0;
+ gbc.gridy = 2;
+ gbc.fill = GridBagConstraints.NONE;
+ gbc.weightx = 0;
+ fieldsPanel.add(promptLabel, gbc);
+
+ gbc.gridx = 1;
+ gbc.weightx = 1.0;
+ gbc.fill = GridBagConstraints.HORIZONTAL;
+ fieldsPanel.add(promptScrollPane, gbc);
+
+ gbc.gridx = 0;
+ gbc.gridy = 3;
+ gbc.gridwidth = 2;
+ gbc.weightx = 1.0;
+ fieldsPanel.add(enablePromptCheckBox, gbc);
+
+ gbc.gridx = 0;
+ gbc.gridy = 1;
+ gbc.gridwidth = 2;
+ gbc.insets = new Insets(10, 0, 0, 0);
+ gbc.fill = GridBagConstraints.HORIZONTAL;
+ switchButtonPanel.add(fieldsPanel, gbc);
return switchButtonPanel;
}
private JPanel initializeSingleButtonPanel() {
- JPanel buttonPanel = new JPanel();
- buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
+ JPanel buttonPanel = new JPanel(new BorderLayout());
buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
JButton singleButton = new JButton(new AbstractAction() {
@@ -115,25 +202,12 @@ public void actionPerformed(ActionEvent arg0) {
singleButton.setMnemonic(KeyEvent.VK_A);
singleButton.setText(Messages.getString("P2T.text"));
- //singleButton.setIcon(loadIcon(Messages.getString("P2TUI.Button.Validate.Icon")));
- buttonPanel.add(Box.createHorizontalGlue());
- buttonPanel.add(singleButton);
- buttonPanel.add(Box.createHorizontalGlue());
+ buttonPanel.add(singleButton, BorderLayout.CENTER);
return buttonPanel;
}
- private ImageIcon loadIcon(String path) {
- java.net.URL imgURL = getClass().getResource(path);
- if (imgURL != null) {
- return new ImageIcon(imgURL);
- } else {
- System.err.println("Couldn't find file: " + path);
- return null; // or a default icon if you prefer
- }
- }
-
private void validateAPIKey() {
String apiKey = apiKeyField.getText();
if (!isAPIKeyValid(apiKey)) {
diff --git a/WoPeD-Installer/pom.xml b/WoPeD-Installer/pom.xml
index 98c449518..b32d704c5 100644
--- a/WoPeD-Installer/pom.xml
+++ b/WoPeD-Installer/pom.xml
@@ -35,6 +35,7 @@
org.apache.maven.plugins
maven-antrun-plugin
+ 1.8
com.akathist.maven.plugins.launch4j
@@ -107,7 +108,7 @@
-
com.akathist.maven.plugins.launch4j
@@ -327,7 +328,7 @@
-
+
diff --git a/WoPeD-Starter/pom.xml b/WoPeD-Starter/pom.xml
index d4b8021cd..7ce97a099 100644
--- a/WoPeD-Starter/pom.xml
+++ b/WoPeD-Starter/pom.xml
@@ -1,7 +1,7 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
@@ -37,6 +37,7 @@
maven-antrun-plugin
+ 1.8
sh.tak.appbundler
From 4ee2795af3a304ef4d9238a8d36e14f726a2317c Mon Sep 17 00:00:00 2001
From: Marcel2511
Date: Sun, 9 Jun 2024 23:29:30 +0200
Subject: [PATCH 07/76] added a settings option for the api key and prompt
added a settings option for the api key and prompt
---
.../woped/beanconfiguration/configuration.xsd | 74 +-
.../general/WoPeDGeneralConfiguration.java | 40 +
.../org/woped/config/general/WoPeDconfig.xml | 5 +
.../config/DefaultStaticConfiguration.java | 78 +-
.../core/config/IGeneralConfiguration.java | 53 +-
.../editor/gui/config/ConfNLPToolsPanel.java | 1311 +++++++++--------
6 files changed, 906 insertions(+), 655 deletions(-)
diff --git a/WoPeD-BeanConfiguration/src/main/java/org/woped/beanconfiguration/configuration.xsd b/WoPeD-BeanConfiguration/src/main/java/org/woped/beanconfiguration/configuration.xsd
index 69d3d29b1..c7d8adf69 100644
--- a/WoPeD-BeanConfiguration/src/main/java/org/woped/beanconfiguration/configuration.xsd
+++ b/WoPeD-BeanConfiguration/src/main/java/org/woped/beanconfiguration/configuration.xsd
@@ -3,17 +3,18 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -101,22 +102,22 @@
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -136,6 +137,15 @@
+
+
+
+
+
+
+
+
+
@@ -191,20 +201,20 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+
+
diff --git a/WoPeD-Configuration/src/main/java/org/woped/config/general/WoPeDGeneralConfiguration.java b/WoPeD-Configuration/src/main/java/org/woped/config/general/WoPeDGeneralConfiguration.java
index be4155f94..8fee47e12 100644
--- a/WoPeD-Configuration/src/main/java/org/woped/config/general/WoPeDGeneralConfiguration.java
+++ b/WoPeD-Configuration/src/main/java/org/woped/config/general/WoPeDGeneralConfiguration.java
@@ -78,6 +78,9 @@ public boolean initConfig() {
if (getConfDocument().getConfiguration().getMetrics() == null)
getConfDocument().getConfiguration().addNewMetrics();
+ if(getConfDocument().getConfiguration().getGpt() == null)
+ getConfDocument().getConfiguration().addNewGpt();
+
// Check if metrics configuration should be loaded
// and react accordingly
if (getConfDocument().getConfiguration().getMetrics().getUseMetrics()) {
@@ -1475,6 +1478,41 @@ public String getText2ProcessServerURI() {
return getConfDocument().getConfiguration().getT2P().getT2PServerURI();
} else return ConfigurationManager.getStandardConfiguration().getText2ProcessServerURI();
}
+ @Override
+ public String getGptApiKey() {
+ if(getConfDocument().getConfiguration().getGpt().isSetGptApiKey()){
+ return getConfDocument().getConfiguration().getGpt().getGptApiKey();
+ }else return ConfigurationManager.getStandardConfiguration().getGptApiKey();
+ }
+
+ @Override
+ public void setGptApiKey(String apiKey) {
+ getConfDocument().getConfiguration().getGpt().setGptApiKey(apiKey);
+ }
+
+ @Override
+ public boolean getGptShowAgain() {
+ if(getConfDocument().getConfiguration().getGpt().isSetGptShowAgain()){
+ return getConfDocument().getConfiguration().getGpt().getGptShowAgain();
+ }else return ConfigurationManager.getStandardConfiguration().getGptShowAgain();
+ }
+
+ @Override
+ public void setGptShowAgain(boolean showAgain) {
+ getConfDocument().getConfiguration().getGpt().setGptShowAgain(showAgain);
+ }
+
+ @Override
+ public String getGptPrompt() {
+ if(getConfDocument().getConfiguration().getGpt().isSetGptPrompt()){
+ return getConfDocument().getConfiguration().getGpt().getGptPrompt();
+ }else return ConfigurationManager.getStandardConfiguration().getGptPrompt();
+ }
+
+ @Override
+ public void setGptPrompt(String prompt) {
+ getConfDocument().getConfiguration().getGpt().setGptPrompt(prompt);
+ }
@Override
public void setText2ProcessServerURI(String uri) {
@@ -1605,4 +1643,6 @@ public void setYAWLExportGroups(boolean exportGroups) {
.getExporting()
.setYawlExportGroups(exportGroups);
}
+
+
}
diff --git a/WoPeD-Configuration/src/main/java/org/woped/config/general/WoPeDconfig.xml b/WoPeD-Configuration/src/main/java/org/woped/config/general/WoPeDconfig.xml
index 2665ed121..bfba43e06 100644
--- a/WoPeD-Configuration/src/main/java/org/woped/config/general/WoPeDconfig.xml
+++ b/WoPeD-Configuration/src/main/java/org/woped/config/general/WoPeDconfig.xml
@@ -116,4 +116,9 @@
8081
/t2p
+
+ test
+ test
+
+
diff --git a/WoPeD-Core/src/main/java/org/woped/core/config/DefaultStaticConfiguration.java b/WoPeD-Core/src/main/java/org/woped/core/config/DefaultStaticConfiguration.java
index 88bb24c59..f3d0b9eae 100644
--- a/WoPeD-Core/src/main/java/org/woped/core/config/DefaultStaticConfiguration.java
+++ b/WoPeD-Core/src/main/java/org/woped/core/config/DefaultStaticConfiguration.java
@@ -12,7 +12,7 @@
/**
* Class that provides fallback configuration settings for the general WoPeD configuration part
*
- * @author Philip Allgaier
+ * @autor Philip Allgaier
*/
@SuppressWarnings("JavadocReference")
public class DefaultStaticConfiguration implements IGeneralConfiguration {
@@ -190,6 +190,11 @@ public class DefaultStaticConfiguration implements IGeneralConfiguration {
private boolean yawlExportGroups = false;
+ // GPT settings
+ private String gptApiKey = "test";
+ private boolean gptShowAgain = true;
+ private String gptPrompt = "test";
+
public DefaultStaticConfiguration() {
initConfig();
}
@@ -919,29 +924,29 @@ public ApromoreServer[] getApromoreServers() {
@Override
public void addApromoreServer(
- int ID,
- String name,
- String url,
- int port,
- String path,
- String user,
- String pwd,
- boolean useProxy,
- String proxyUrl,
- int proxyPort) {}
+ int ID,
+ String name,
+ String url,
+ int port,
+ String path,
+ String user,
+ String pwd,
+ boolean useProxy,
+ String proxyUrl,
+ int proxyPort) {}
@Override
public void changeApromoreServerSettings(
- int ID,
- String name,
- String url,
- int port,
- String path,
- String user,
- String pwd,
- boolean useProxy,
- String proxyUrl,
- int proxyPort) {}
+ int ID,
+ String name,
+ String url,
+ int port,
+ String path,
+ String user,
+ String pwd,
+ boolean useProxy,
+ String proxyUrl,
+ int proxyPort) {}
@Override
public void removeApromoreServer(int index) {}
@@ -1083,4 +1088,35 @@ public boolean isYAWLExportGroups() {
public void setYAWLExportGroups(boolean exportGroups) {
this.yawlExportGroups = exportGroups;
}
+
+ // GPT settings
+ @Override
+ public String getGptApiKey() {
+ return gptApiKey;
+ }
+
+ @Override
+ public void setGptApiKey(String apiKey) {
+ this.gptApiKey = apiKey;
+ }
+
+ @Override
+ public boolean getGptShowAgain() {
+ return gptShowAgain;
+ }
+
+ @Override
+ public void setGptShowAgain(boolean showAgain) {
+ this.gptShowAgain = showAgain;
+ }
+
+ @Override
+ public String getGptPrompt() {
+ return gptPrompt;
+ }
+
+ @Override
+ public void setGptPrompt(String prompt) {
+ this.gptPrompt = prompt;
+ }
}
diff --git a/WoPeD-Core/src/main/java/org/woped/core/config/IGeneralConfiguration.java b/WoPeD-Core/src/main/java/org/woped/core/config/IGeneralConfiguration.java
index 122d25dd7..33dba995c 100644
--- a/WoPeD-Core/src/main/java/org/woped/core/config/IGeneralConfiguration.java
+++ b/WoPeD-Core/src/main/java/org/woped/core/config/IGeneralConfiguration.java
@@ -478,28 +478,28 @@ public interface IGeneralConfiguration extends IConfiguration {
public ApromoreServer[] getApromoreServers();
public void addApromoreServer(
- int ID,
- String name,
- String url,
- int port,
- String path,
- String user,
- String pwd,
- boolean useProxy,
- String proxyUrl,
- int proxyPort);
+ int ID,
+ String name,
+ String url,
+ int port,
+ String path,
+ String user,
+ String pwd,
+ boolean useProxy,
+ String proxyUrl,
+ int proxyPort);
public void changeApromoreServerSettings(
- int ID,
- String name,
- String url,
- int port,
- String path,
- String user,
- String pwd,
- boolean useProxy,
- String proxyUrl,
- int proxyPort);
+ int ID,
+ String name,
+ String url,
+ int port,
+ String path,
+ String user,
+ String pwd,
+ boolean useProxy,
+ String proxyUrl,
+ int proxyPort);
public void removeApromoreServer(int index);
@@ -560,4 +560,17 @@ public void changeApromoreServerSettings(
public boolean isYAWLExportGroups();
public void setYAWLExportGroups(boolean exportGroups);
+
+ // GPT Settings
+ public String getGptApiKey();
+
+ public void setGptApiKey(String apiKey);
+
+ public boolean getGptShowAgain();
+
+ public void setGptShowAgain(boolean showAgain);
+
+ public String getGptPrompt();
+
+ public void setGptPrompt(String prompt);
}
diff --git a/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java b/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java
index bc47190fa..ef750d3fc 100644
--- a/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java
+++ b/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java
@@ -25,6 +25,7 @@
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
+import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
@@ -38,601 +39,747 @@
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
import javax.swing.JTextField;
+
import org.woped.core.config.ConfigurationManager;
import org.woped.gui.lookAndFeel.WopedButton;
import org.woped.gui.translations.Messages;
/**
- * @author Simon Landes
- *
- * The ConfLanguagePanel
is the AbstractConfPanel
for the
- * configuration of the language.
- * Created on: 26.11.2004 Last Change on: 14.11.2005
+ * The ConfLanguagePanel
is the AbstractConfPanel
for the configuration
+ * of the language. Created on: 26.11.2004 Last Change on: 14.11.2005
*/
@SuppressWarnings("serial")
public class ConfNLPToolsPanel extends AbstractConfPanel {
- private JCheckBox useBox = null;
- private JPanel enabledPanel = null;
- private JPanel settingsPanel = null;
- private JPanel settingsPanel_T2P = null;
-
- private JTextField serverURLText = null;
- private JLabel serverURLLabel = null;
- private JLabel serverPortLabel = null;
- private JTextField serverPortText = null;
- private JTextField managerPathText = null;
- private JLabel managerPathLabel = null;
- private WopedButton testButton = null;
- private WopedButton defaultButton = null;
- private JTextField serverURLText_T2P = null;
- private JLabel serverURLLabel_T2P = null;
- private JLabel serverPortLabel_T2P = null;
- private JTextField serverPortText_T2P = null;
- private JTextField managerPathText_T2P = null;
- private JLabel managerPathLabel_T2P = null;
- private WopedButton testButton_T2P = null;
- private WopedButton defaultButton_T2P = null;
-
- /** Constructor for ConfToolsPanel. */
- public ConfNLPToolsPanel(String name) {
- super(name);
- initialize();
- }
-
- /**
- * @see AbstractConfPanel#applyConfiguration()
- */
- public boolean applyConfiguration() {
- boolean newsetting = useBox.isSelected();
- boolean oldsetting = ConfigurationManager.getConfiguration().getProcess2TextUse();
-
- if (newsetting != oldsetting) {
- ConfigurationManager.getConfiguration().setProcess2TextUse(newsetting);
- JOptionPane.showMessageDialog(
- this,
- Messages.getString("Configuration.P2T.Dialog.Restart.Message"),
- Messages.getString("Configuration.P2T.Dialog.Restart.Title"),
- JOptionPane.INFORMATION_MESSAGE);
- }
- ConfigurationManager.getConfiguration().setProcess2TextServerHost(getServerURLText().getText());
- ConfigurationManager.getConfiguration()
- .setProcess2TextServerURI(getManagerPathText().getText());
- if (getServerPortText().getText().equals("")) {
- ConfigurationManager.getConfiguration().setProcess2TextServerPort(0);
- } else
- ConfigurationManager.getConfiguration()
- .setProcess2TextServerPort(Integer.parseInt(getServerPortText().getText()));
- ConfigurationManager.getConfiguration().setProcess2TextUse(useBox.isSelected());
-
- ConfigurationManager.getConfiguration()
- .setText2ProcessServerHost(getServerURLText_T2P().getText());
-
- ConfigurationManager.getConfiguration()
- .setText2ProcessServerURI(getManagerPathText_T2P().getText());
-
- if (getServerPortText_T2P().getText().equals("")) {
- ConfigurationManager.getConfiguration().setText2ProcessServerPort(0);
- } else
- ConfigurationManager.getConfiguration()
- .setText2ProcessServerPort(Integer.parseInt(getServerPortText_T2P().getText()));
-
- return true;
- }
-
- /**
- * @see AbstractConfPanel#readConfiguration()
- */
- public void readConfiguration() {
-
- getServerURLText().setText(ConfigurationManager.getConfiguration().getProcess2TextServerHost());
- getManagerPathText()
- .setText(ConfigurationManager.getConfiguration().getProcess2TextServerURI());
- getServerPortText()
- .setText("" + ConfigurationManager.getConfiguration().getProcess2TextServerPort());
- getUseBox().setSelected(ConfigurationManager.getConfiguration().getProcess2TextUse());
-
- getServerURLText_T2P()
- .setText(ConfigurationManager.getConfiguration().getText2ProcessServerHost());
- getManagerPathText_T2P()
- .setText(ConfigurationManager.getConfiguration().getText2ProcessServerURI());
-
- getServerPortText_T2P()
- .setText("" + ConfigurationManager.getConfiguration().getText2ProcessServerPort());
- }
-
- private void initialize() {
- JPanel contentPanel = new JPanel();
- contentPanel.setLayout(new GridBagLayout());
- GridBagConstraints c = new GridBagConstraints();
- c.anchor = GridBagConstraints.NORTH;
- c.fill = GridBagConstraints.HORIZONTAL;
-
- c.weightx = 1;
- c.gridx = 0;
- c.gridy = 0;
- contentPanel.add(getEnabledPanel(), c);
-
- c.weightx = 1;
- c.gridx = 0;
- c.gridy = 1;
- contentPanel.add(getSettingsPanel(), c);
-
- c.weightx = 1;
- c.gridx = 0;
- c.gridy = 3;
- contentPanel.add(getSettingsPanel_T2P(), c);
-
- // dummy
- c.fill = GridBagConstraints.VERTICAL;
- c.weighty = 1;
- c.gridy = 4;
- contentPanel.add(new JPanel(), c);
-
- setMainPanel(contentPanel);
- }
-
- // ################## GUI COMPONENTS #################### */
-
- private JTextField getServerURLText() {
- if (serverURLText == null) {
- serverURLText = new JTextField();
- serverURLText.setColumns(40);
- serverURLText.setEnabled(true);
- serverURLText.setToolTipText(
- "" + Messages.getString("Configuration.P2T.Label.ServerHost") + "");
- }
- return serverURLText;
- }
-
- private JTextField getServerURLText_T2P() {
- if (serverURLText_T2P == null) {
- serverURLText_T2P = new JTextField();
- serverURLText_T2P.setColumns(40);
- serverURLText_T2P.setEnabled(true);
- serverURLText_T2P.setToolTipText(
- "" + Messages.getString("Configuration.T2P.Label.ServerHost") + "");
- }
- return serverURLText_T2P;
- }
-
- private JPanel getEnabledPanel() {
- if (enabledPanel == null) {
- enabledPanel = new JPanel();
- enabledPanel.setLayout(new GridBagLayout());
- GridBagConstraints c = new GridBagConstraints();
- c.anchor = GridBagConstraints.WEST;
-
- enabledPanel.setBorder(
- BorderFactory.createCompoundBorder(
- BorderFactory.createTitledBorder(
- Messages.getTitle("Configuration.P2T.Enabled.Panel")),
- BorderFactory.createEmptyBorder(10, 10, 10, 10)));
-
- c.weightx = 1;
- c.gridx = 1;
- c.gridy = 0;
- enabledPanel.add(getUseBox(), c);
- }
- return enabledPanel;
- }
-
- private JPanel getSettingsPanel() {
- if (settingsPanel == null) {
- settingsPanel = new JPanel();
- settingsPanel.setLayout(new GridBagLayout());
- GridBagConstraints c = new GridBagConstraints();
- c.anchor = GridBagConstraints.WEST;
-
- settingsPanel.setBorder(
- BorderFactory.createCompoundBorder(
- BorderFactory.createTitledBorder(
- Messages.getString("Configuration.P2T.Settings.Panel.Title")),
- BorderFactory.createEmptyBorder(10, 10, 10, 10)));
- c.weightx = 1;
- c.gridx = 0;
- c.gridy = 0;
- settingsPanel.add(getServerURLLabel(), c);
-
- c.weightx = 1;
- c.gridx = 1;
- c.gridy = 0;
- c.gridwidth = 2;
- settingsPanel.add(getServerURLText(), c);
-
- c.weightx = 1;
- c.gridx = 0;
- c.gridy = 1;
- c.gridwidth = 1;
- settingsPanel.add(getServerPortLabel(), c);
-
- c.weightx = 1;
- c.gridx = 1;
- c.gridy = 1;
- settingsPanel.add(getServerPortText(), c);
-
- c.weightx = 1;
- c.gridx = 2;
- c.gridy = 1;
- settingsPanel.add(getTestButton(), c);
-
- c.weightx = 1;
- c.gridx = 0;
- c.gridy = 2;
- settingsPanel.add(getManagerPathLabel(), c);
-
- c.weightx = 1;
- c.gridx = 1;
- c.gridy = 2;
- c.gridwidth = 2;
- settingsPanel.add(getManagerPathText(), c);
-
- c.weightx = 1;
- c.gridx = 1;
- c.gridy = 4;
- settingsPanel.add(getDefaultButton(), c);
- }
-
- settingsPanel.setVisible(getUseBox().isSelected());
- return settingsPanel;
- }
-
- private JPanel getSettingsPanel_T2P() {
- if (settingsPanel_T2P == null) {
- settingsPanel_T2P = new JPanel();
- settingsPanel_T2P.setLayout(new GridBagLayout());
- GridBagConstraints c = new GridBagConstraints();
- c.anchor = GridBagConstraints.WEST;
-
- settingsPanel_T2P.setBorder(
- BorderFactory.createCompoundBorder(
- BorderFactory.createTitledBorder(
- Messages.getString("Configuration.T2P.Settings.Panel.Title")),
- BorderFactory.createEmptyBorder(10, 10, 10, 10)));
- c.weightx = 1;
- c.gridx = 0;
- c.gridy = 0;
- settingsPanel_T2P.add(getServerURLLabel_T2P(), c);
-
- c.weightx = 1;
- c.gridx = 1;
- c.gridy = 0;
- c.gridwidth = 2;
- settingsPanel_T2P.add(getServerURLText_T2P(), c);
-
- c.weightx = 1;
- c.gridx = 0;
- c.gridy = 1;
- c.gridwidth = 1;
- settingsPanel_T2P.add(getServerPortLabel_T2P(), c);
-
- c.weightx = 1;
- c.gridx = 1;
- c.gridy = 1;
- settingsPanel_T2P.add(getServerPortText_T2P(), c);
-
- c.weightx = 1;
- c.gridx = 2;
- c.gridy = 1;
- settingsPanel_T2P.add(getTestButton_T2P(), c);
-
- c.weightx = 1;
- c.gridx = 0;
- c.gridy = 2;
- settingsPanel_T2P.add(getManagerPathLabel_T2P(), c);
-
- c.weightx = 1;
- c.gridx = 1;
- c.gridy = 2;
- c.gridwidth = 2;
- settingsPanel_T2P.add(getManagerPathText_T2P(), c);
-
- c.weightx = 1;
- c.gridx = 1;
- c.gridy = 4;
- settingsPanel_T2P.add(getDefaultButton_T2P(), c);
- }
-
- settingsPanel_T2P.setVisible(getUseBox_T2P().isSelected());
- return settingsPanel_T2P;
- }
-
- class CheckboxListener implements ItemListener {
-
- public void itemStateChanged(ItemEvent ie) {
- JCheckBox jcb = (JCheckBox) ie.getSource();
- if (jcb == useBox) {
- getSettingsPanel().setVisible(jcb.isSelected());
- getSettingsPanel_T2P().setVisible(jcb.isSelected());
- }
- }
- }
-
- private JLabel getServerURLLabel() {
- if (serverURLLabel == null) {
- serverURLLabel =
- new JLabel(
- "" + Messages.getString("Configuration.P2T.Label.ServerHost") + "");
- serverURLLabel.setHorizontalAlignment(JLabel.RIGHT);
- }
- return serverURLLabel;
- }
-
- private JLabel getServerURLLabel_T2P() {
- if (serverURLLabel_T2P == null) {
- serverURLLabel_T2P =
- new JLabel(
- "" + Messages.getString("Configuration.T2P.Label.ServerHost") + "");
- serverURLLabel_T2P.setHorizontalAlignment(JLabel.RIGHT);
- }
- return serverURLLabel_T2P;
- }
-
- private JLabel getServerPortLabel() {
- if (serverPortLabel == null) {
- serverPortLabel =
- new JLabel(
- "" + Messages.getString("Configuration.P2T.Label.ServerPort") + "");
- serverPortLabel.setHorizontalAlignment(JLabel.RIGHT);
- }
- return serverPortLabel;
- }
-
- private JLabel getServerPortLabel_T2P() {
- if (serverPortLabel_T2P == null) {
- serverPortLabel_T2P =
- new JLabel(
- "" + Messages.getString("Configuration.T2P.Label.ServerPort") + "");
- serverPortLabel_T2P.setHorizontalAlignment(JLabel.RIGHT);
- }
- return serverPortLabel_T2P;
- }
-
- private JTextField getServerPortText() {
- if (serverPortText == null) {
- serverPortText = new JTextField();
- serverPortText.setColumns(4);
- serverPortText.setEnabled(true);
- serverPortText.setToolTipText(
- "" + Messages.getString("Configuration.P2T.Label.ServerPort") + "");
- }
- return serverPortText;
- }
-
- private JTextField getServerPortText_T2P() {
- if (serverPortText_T2P == null) {
- serverPortText_T2P = new JTextField();
- serverPortText_T2P.setColumns(4);
- serverPortText_T2P.setEnabled(true);
- serverPortText_T2P.setToolTipText(
- "" + Messages.getString("Configuration.T2P.Label.ServerPort") + "");
- }
- return serverPortText_T2P;
- }
-
- private JCheckBox getUseBox() {
- if (useBox == null) {
- useBox = new JCheckBox(Messages.getString("Configuration.P2T.Label.Use"));
- useBox.setEnabled(true);
- useBox.setToolTipText(
- "" + Messages.getString("Configuration.P2T.Label.Use") + "");
- CheckboxListener cbl = new CheckboxListener();
- useBox.addItemListener(cbl);
- }
-
- return useBox;
- }
-
- private JCheckBox getUseBox_T2P() {
- if (useBox == null) {
- useBox = new JCheckBox(Messages.getString("Configuration.P2T.Label.Use"));
- useBox.setEnabled(true);
- useBox.setToolTipText(
- "" + Messages.getString("Configuration.T2P.Label.Use") + "");
- CheckboxListener cbl = new CheckboxListener();
- useBox.addItemListener(cbl);
- }
-
- return useBox;
- }
-
- private JLabel getManagerPathLabel() {
- if (managerPathLabel == null) {
- managerPathLabel =
- new JLabel(
- "" + Messages.getString("Configuration.P2T.Label.ServerURI") + "");
- managerPathLabel.setHorizontalAlignment(JLabel.RIGHT);
- }
- return managerPathLabel;
- }
-
- private JLabel getManagerPathLabel_T2P() {
- if (managerPathLabel_T2P == null) {
- managerPathLabel_T2P =
- new JLabel(
- "" + Messages.getString("Configuration.T2P.Label.ServerURI") + "");
- managerPathLabel_T2P.setHorizontalAlignment(JLabel.RIGHT);
- }
- return managerPathLabel_T2P;
- }
-
- private JTextField getManagerPathText() {
- if (managerPathText == null) {
- managerPathText = new JTextField();
- managerPathText.setColumns(40);
- managerPathText.setEnabled(true);
- managerPathText.setToolTipText(
- "" + Messages.getString("Configuration.P2T.Label.ServerURI") + "");
- }
- return managerPathText;
- }
-
- private JTextField getManagerPathText_T2P() {
- if (managerPathText_T2P == null) {
- managerPathText_T2P = new JTextField();
- managerPathText_T2P.setColumns(40);
- managerPathText_T2P.setEnabled(true);
- managerPathText_T2P.setToolTipText(
- "" + Messages.getString("Configuration.T2P.Label.ServerURI") + "");
- }
- return managerPathText_T2P;
- }
-
- private WopedButton getTestButton() {
- if (testButton == null) {
- testButton = new WopedButton();
- testButton.setText(Messages.getTitle("Button.TestConnection"));
- testButton.setIcon(Messages.getImageIcon("Button.TestConnection"));
- testButton.setMnemonic(Messages.getMnemonic("Button.TestConnection"));
- testButton.setPreferredSize(new Dimension(160, 25));
- testButton.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- testProcess2TextConnection();
- }
- });
- }
-
- return testButton;
- }
-
- private WopedButton getTestButton_T2P() {
- if (testButton_T2P == null) {
- testButton_T2P = new WopedButton();
- testButton_T2P.setText(Messages.getTitle("Button.TestConnection"));
- testButton_T2P.setIcon(Messages.getImageIcon("Button.TestConnection"));
- testButton_T2P.setMnemonic(Messages.getMnemonic("Button.TestConnection"));
- testButton_T2P.setPreferredSize(new Dimension(160, 25));
- testButton_T2P.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- testText2ProcessConnection();
+ private JCheckBox useBox = null;
+ private JPanel enabledPanel = null;
+ private JPanel settingsPanel = null;
+ private JPanel settingsPanel_T2P = null;
+ private JPanel additionalPanel = null;
+
+ private JTextField serverURLText = null;
+ private JLabel serverURLLabel = null;
+ private JLabel serverPortLabel = null;
+ private JTextField serverPortText = null;
+ private JTextField managerPathText = null;
+ private JLabel managerPathLabel = null;
+ private WopedButton testButton = null;
+ private WopedButton defaultButton = null;
+ private JTextField serverURLText_T2P = null;
+ private JLabel serverURLLabel_T2P = null;
+ private JLabel serverPortLabel_T2P = null;
+ private JTextField serverPortText_T2P = null;
+ private JTextField managerPathText_T2P = null;
+ private JLabel managerPathLabel_T2P = null;
+ private WopedButton testButton_T2P = null;
+ private WopedButton defaultButton_T2P = null;
+
+ // Components for additionalPanel
+ private JTextField apiKeyText = null;
+ private JCheckBox showAgainBox = null;
+ private WopedButton resetButton = null;
+ private JTextArea promptText = null;
+ private WopedButton checkConnectionButton = null;
+
+ /**
+ * Constructor for ConfToolsPanel.
+ */
+ public ConfNLPToolsPanel(String name) {
+ super(name);
+ initialize();
+ }
+
+ /**
+ * @see AbstractConfPanel#applyConfiguration()
+ */
+ public boolean applyConfiguration() {
+ boolean newsetting = useBox.isSelected();
+ boolean oldsetting = ConfigurationManager.getConfiguration().getProcess2TextUse();
+
+ if (newsetting != oldsetting) {
+ ConfigurationManager.getConfiguration().setProcess2TextUse(newsetting);
+ JOptionPane.showMessageDialog(
+ this,
+ Messages.getString("Configuration.P2T.Dialog.Restart.Message"),
+ Messages.getString("Configuration.P2T.Dialog.Restart.Title"),
+ JOptionPane.INFORMATION_MESSAGE);
+ }
+ ConfigurationManager.getConfiguration().setProcess2TextServerHost(getServerURLText().getText());
+ ConfigurationManager.getConfiguration().setProcess2TextServerURI(getManagerPathText().getText());
+ if (getServerPortText().getText().equals("")) {
+ ConfigurationManager.getConfiguration().setProcess2TextServerPort(0);
+ } else
+ ConfigurationManager.getConfiguration()
+ .setProcess2TextServerPort(Integer.parseInt(getServerPortText().getText()));
+ ConfigurationManager.getConfiguration().setProcess2TextUse(useBox.isSelected());
+
+ ConfigurationManager.getConfiguration().setText2ProcessServerHost(getServerURLText_T2P().getText());
+
+ ConfigurationManager.getConfiguration().setText2ProcessServerURI(getManagerPathText_T2P().getText());
+
+ if (getServerPortText_T2P().getText().equals("")) {
+ ConfigurationManager.getConfiguration().setText2ProcessServerPort(0);
+ } else
+ ConfigurationManager.getConfiguration()
+ .setText2ProcessServerPort(Integer.parseInt(getServerPortText_T2P().getText()));
+
+ // Save additional panel configurations
+ ConfigurationManager.getConfiguration().setGptApiKey(getApiKeyText().getText());
+ ConfigurationManager.getConfiguration().setGptShowAgain(getShowAgainBox().isSelected());
+ ConfigurationManager.getConfiguration().setGptPrompt(getPromptText().getText());
+
+ return true;
+ }
+
+ /**
+ * @see AbstractConfPanel#readConfiguration()
+ */
+ public void readConfiguration() {
+
+ getServerURLText().setText(ConfigurationManager.getConfiguration().getProcess2TextServerHost());
+ getManagerPathText().setText(ConfigurationManager.getConfiguration().getProcess2TextServerURI());
+ getServerPortText().setText("" + ConfigurationManager.getConfiguration().getProcess2TextServerPort());
+ getUseBox().setSelected(ConfigurationManager.getConfiguration().getProcess2TextUse());
+
+ getServerURLText_T2P().setText(ConfigurationManager.getConfiguration().getText2ProcessServerHost());
+ getManagerPathText_T2P().setText(ConfigurationManager.getConfiguration().getText2ProcessServerURI());
+
+ getServerPortText_T2P().setText("" + ConfigurationManager.getConfiguration().getText2ProcessServerPort());
+
+ // Load additional panel configurations
+ getApiKeyText().setText(ConfigurationManager.getConfiguration().getGptApiKey());
+ getShowAgainBox().setSelected(ConfigurationManager.getConfiguration().getGptShowAgain());
+ getPromptText().setText(ConfigurationManager.getConfiguration().getGptPrompt());
+ }
+
+ private void initialize() {
+ JPanel contentPanel = new JPanel();
+ contentPanel.setLayout(new GridBagLayout());
+ GridBagConstraints c = new GridBagConstraints();
+ c.anchor = GridBagConstraints.NORTH;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.insets = new Insets(2, 0, 2, 0); // Small vertical gap between elements
+
+ c.weightx = 1;
+ c.gridx = 0;
+ c.gridy = 0;
+ contentPanel.add(getEnabledPanel(), c);
+
+ c.weightx = 1;
+ c.gridx = 0;
+ c.gridy = 1;
+ contentPanel.add(getSettingsPanel(), c);
+
+ c.weightx = 1;
+ c.gridx = 0;
+ c.gridy = 2;
+ contentPanel.add(getSettingsPanel_T2P(), c);
+
+ c.weightx = 1;
+ c.gridx = 0;
+ c.gridy = 3;
+ contentPanel.add(getAdditionalPanel(), c);
+
+ // dummy
+ c.fill = GridBagConstraints.VERTICAL;
+ c.weighty = 1;
+ c.gridy = 4;
+ contentPanel.add(new JPanel(), c);
+
+ setMainPanel(contentPanel);
+ }
+
+ // ################## GUI COMPONENTS #################### */
+
+ private JTextField getServerURLText() {
+ if (serverURLText == null) {
+ serverURLText = new JTextField();
+ serverURLText.setColumns(40);
+ serverURLText.setEnabled(true);
+ serverURLText.setToolTipText(
+ "" + Messages.getString("Configuration.P2T.Label.ServerHost") + "");
+ }
+ return serverURLText;
+ }
+
+ private JTextField getServerURLText_T2P() {
+ if (serverURLText_T2P == null) {
+ serverURLText_T2P = new JTextField();
+ serverURLText_T2P.setColumns(40);
+ serverURLText_T2P.setEnabled(true);
+ serverURLText_T2P.setToolTipText(
+ "" + Messages.getString("Configuration.T2P.Label.ServerHost") + "");
+ }
+ return serverURLText_T2P;
+ }
+
+ private JPanel getEnabledPanel() {
+ if (enabledPanel == null) {
+ enabledPanel = new JPanel();
+ enabledPanel.setLayout(new GridBagLayout());
+ GridBagConstraints c = new GridBagConstraints();
+ c.anchor = GridBagConstraints.WEST;
+ c.insets = new Insets(2, 0, 2, 0); // Small vertical gap between elements
+
+ enabledPanel.setBorder(
+ BorderFactory.createCompoundBorder(
+ BorderFactory.createTitledBorder(Messages.getTitle("Configuration.P2T.Enabled.Panel")),
+ BorderFactory.createEmptyBorder(10, 10, 10, 10)));
+
+ c.weightx = 1;
+ c.gridx = 1;
+ c.gridy = 0;
+ enabledPanel.add(getUseBox(), c);
+ }
+ return enabledPanel;
+ }
+
+ private JPanel getSettingsPanel() {
+ if (settingsPanel == null) {
+ settingsPanel = new JPanel();
+ settingsPanel.setLayout(new GridBagLayout());
+ GridBagConstraints c = new GridBagConstraints();
+ c.anchor = GridBagConstraints.WEST;
+ c.insets = new Insets(2, 0, 2, 0); // Small vertical gap between elements
+
+ settingsPanel.setBorder(
+ BorderFactory.createCompoundBorder(
+ BorderFactory.createTitledBorder(Messages.getString("Configuration.P2T.Settings.Panel.Title")),
+ BorderFactory.createEmptyBorder(10, 10, 10, 10)));
+ c.weightx = 1;
+ c.gridx = 0;
+ c.gridy = 0;
+ settingsPanel.add(getServerURLLabel(), c);
+
+ c.weightx = 1;
+ c.gridx = 1;
+ c.gridy = 0;
+ c.gridwidth = 2;
+ settingsPanel.add(getServerURLText(), c);
+
+ c.weightx = 1;
+ c.gridx = 0;
+ c.gridy = 1;
+ c.gridwidth = 1;
+ settingsPanel.add(getServerPortLabel(), c);
+
+ c.weightx = 1;
+ c.gridx = 1;
+ c.gridy = 1;
+ settingsPanel.add(getServerPortText(), c);
+
+ c.weightx = 1;
+ c.gridx = 2;
+ c.gridy = 1;
+ settingsPanel.add(getTestButton(), c);
+
+ c.weightx = 1;
+ c.gridx = 0;
+ c.gridy = 2;
+ settingsPanel.add(getManagerPathLabel(), c);
+
+ c.weightx = 1;
+ c.gridx = 1;
+ c.gridy = 2;
+ c.gridwidth = 2;
+ settingsPanel.add(getManagerPathText(), c);
+
+ c.weightx = 1;
+ c.gridx = 1;
+ c.gridy = 4;
+ settingsPanel.add(getDefaultButton(), c);
+ }
+
+ settingsPanel.setVisible(getUseBox().isSelected());
+ return settingsPanel;
+ }
+
+ private JPanel getSettingsPanel_T2P() {
+ if (settingsPanel_T2P == null) {
+ settingsPanel_T2P = new JPanel();
+ settingsPanel_T2P.setLayout(new GridBagLayout());
+ GridBagConstraints c = new GridBagConstraints();
+ c.anchor = GridBagConstraints.WEST;
+ c.insets = new Insets(2, 0, 2, 0); // Small vertical gap between elements
+
+ settingsPanel_T2P.setBorder(
+ BorderFactory.createCompoundBorder(
+ BorderFactory.createTitledBorder(Messages.getString("Configuration.T2P.Settings.Panel.Title")),
+ BorderFactory.createEmptyBorder(10, 10, 10, 10)));
+ c.weightx = 1;
+ c.gridx = 0;
+ c.gridy = 0;
+ settingsPanel_T2P.add(getServerURLLabel_T2P(), c);
+
+ c.weightx = 1;
+ c.gridx = 1;
+ c.gridy = 0;
+ c.gridwidth = 2;
+ settingsPanel_T2P.add(getServerURLText_T2P(), c);
+
+ c.weightx = 1;
+ c.gridx = 0;
+ c.gridy = 1;
+ c.gridwidth = 1;
+ settingsPanel_T2P.add(getServerPortLabel_T2P(), c);
+
+ c.weightx = 1;
+ c.gridx = 1;
+ c.gridy = 1;
+ settingsPanel_T2P.add(getServerPortText_T2P(), c);
+
+ c.weightx = 1;
+ c.gridx = 2;
+ c.gridy = 1;
+ settingsPanel_T2P.add(getTestButton_T2P(), c);
+
+ c.weightx = 1;
+ c.gridx = 0;
+ c.gridy = 2;
+ settingsPanel_T2P.add(getManagerPathLabel_T2P(), c);
+
+ c.weightx = 1;
+ c.gridx = 1;
+ c.gridy = 2;
+ c.gridwidth = 2;
+ settingsPanel_T2P.add(getManagerPathText_T2P(), c);
+
+ c.weightx = 1;
+ c.gridx = 1;
+ c.gridy = 4;
+ settingsPanel_T2P.add(getDefaultButton_T2P(), c);
+ }
+
+ settingsPanel_T2P.setVisible(getUseBox_T2P().isSelected());
+ return settingsPanel_T2P;
+ }
+
+ private JPanel getAdditionalPanel() {
+ if (additionalPanel == null) {
+ additionalPanel = new JPanel();
+ additionalPanel.setLayout(new GridBagLayout());
+ GridBagConstraints c = new GridBagConstraints();
+ c.anchor = GridBagConstraints.WEST;
+ c.insets = new Insets(2, 0, 2, 0); // Small vertical gap between elements
+
+ additionalPanel.setBorder(
+ BorderFactory.createCompoundBorder(
+ BorderFactory.createTitledBorder("GPT Settings"),
+ BorderFactory.createEmptyBorder(10, 10, 10, 10)));
+
+ c.weightx = 1;
+ c.gridx = 0;
+ c.gridy = 0;
+ additionalPanel.add(new JLabel("API-Key:"), c);
+
+ c.weightx = 1;
+ c.gridx = 1;
+ c.gridy = 0;
+ additionalPanel.add(getApiKeyText(), c);
+
+ c.weightx = 1;
+ c.gridx = 0;
+ c.gridy = 1;
+ additionalPanel.add(new JLabel("Prompt:"), c);
+
+ c.weightx = 1;
+ c.gridx = 1;
+ c.gridy = 1;
+ c.gridwidth = 2;
+ additionalPanel.add(getPromptTextScrollPane(), c);
+
+ c.weightx = 1;
+ c.gridx = 0;
+ c.gridy = 2;
+ additionalPanel.add(getShowAgainBox(), c);
+
+ c.weightx = 1;
+ c.gridx = 1;
+ c.gridy = 2;
+ additionalPanel.add(getResetButton(), c);
+
+ c.weightx = 1;
+ c.gridx = 2;
+ c.gridy = 2;
+ additionalPanel.add(getCheckConnectionButton(), c);
+
+ }
+ return additionalPanel;
+ }
+
+ private JScrollPane getPromptTextScrollPane() {
+ JScrollPane scrollPane = new JScrollPane(getPromptText());
+ scrollPane.setPreferredSize(new Dimension(getApiKeyText().getPreferredSize().width, 100));
+ return scrollPane;
+ }
+
+ private JTextField getApiKeyText() {
+ if (apiKeyText == null) {
+ apiKeyText = new JTextField();
+ apiKeyText.setColumns(40);
+ apiKeyText.setEnabled(true);
+ }
+ return apiKeyText;
+ }
+
+ private JTextArea getPromptText() {
+ if (promptText == null) {
+ promptText = new JTextArea();
+ promptText.setColumns(40);
+ promptText.setRows(5);
+ promptText.setLineWrap(true);
+ promptText.setWrapStyleWord(true);
+ promptText.setEnabled(true);
+ promptText.setText(
+ "Create a clearly structured and comprehensible continuous text from the given BPMN that is understandable for an uninformed reader. The text should be easy to read in the summary and contain all important content; if there are subdivided points, these are integrated into the text with suitable sentence beginnings in order to obtain a well-structured and easy-to-read text. Under no circumstances should the output contain sub-items or paragraphs, but should cover all processes in one piece!");
+ }
+ return promptText;
+ }
+
+ private JCheckBox getShowAgainBox() {
+ if (showAgainBox == null) {
+ showAgainBox = new JCheckBox("Show Again");
+ showAgainBox.setEnabled(true);
+ showAgainBox.setToolTipText("Test");
+ }
+ return showAgainBox;
+ }
+
+ private WopedButton getResetButton() {
+ if (resetButton == null) {
+ resetButton = new WopedButton();
+ resetButton.setText("Auf Standard zurücksetzen");
+ resetButton.setPreferredSize(new Dimension(200, 25));
+ resetButton.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ setDefaultValuesGPT();
+ System.out.println(ConfigurationManager.getConfiguration().getGptShowAgain());
+ System.out.println(ConfigurationManager.getConfiguration().getGptPrompt());
+ }
+ });
+ }
+ return resetButton;
+ }
+
+ private WopedButton getCheckConnectionButton() {
+ if (checkConnectionButton == null) {
+ checkConnectionButton = new WopedButton();
+ checkConnectionButton.setText("Verbindung überprüfen");
+ checkConnectionButton.setIcon(Messages.getImageIcon("Button.TestConnection"));
+ checkConnectionButton.setMnemonic(Messages.getMnemonic("Button.TestConnection"));
+ checkConnectionButton.setPreferredSize(new Dimension(200, 25));
+ checkConnectionButton.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ testGPTConnection();
+ }
+ });
+ }
+ return checkConnectionButton;
+ }
+
+ private void testGPTConnection() {
+ // Implement connection test logic for GPT here
+ JOptionPane.showMessageDialog(
+ this.getAdditionalPanel(),
+ "GPT connection test not implemented.",
+ "Connection Test",
+ JOptionPane.INFORMATION_MESSAGE);
+ }
+
+ private void setDefaultValuesGPT() {
+ getApiKeyText().setText(ConfigurationManager.getStandardConfiguration().getGptApiKey());
+ getShowAgainBox().setSelected(ConfigurationManager.getStandardConfiguration().getGptShowAgain());
+ getPromptText().setText(ConfigurationManager.getStandardConfiguration().getGptPrompt());
+ }
+
+ class CheckboxListener implements ItemListener {
+
+ public void itemStateChanged(ItemEvent ie) {
+ JCheckBox jcb = (JCheckBox) ie.getSource();
+ if (jcb == useBox) {
+ getSettingsPanel().setVisible(jcb.isSelected());
+ getSettingsPanel_T2P().setVisible(jcb.isSelected());
}
- });
+ }
+ }
+
+ private JLabel getServerURLLabel() {
+ if (serverURLLabel == null) {
+ serverURLLabel =
+ new JLabel("" + Messages.getString("Configuration.P2T.Label.ServerHost") + "");
+ serverURLLabel.setHorizontalAlignment(JLabel.RIGHT);
+ }
+ return serverURLLabel;
+ }
+
+ private JLabel getServerURLLabel_T2P() {
+ if (serverURLLabel_T2P == null) {
+ serverURLLabel_T2P =
+ new JLabel("" + Messages.getString("Configuration.T2P.Label.ServerHost") + "");
+ serverURLLabel_T2P.setHorizontalAlignment(JLabel.RIGHT);
+ }
+ return serverURLLabel_T2P;
+ }
+
+ private JLabel getServerPortLabel() {
+ if (serverPortLabel == null) {
+ serverPortLabel =
+ new JLabel("" + Messages.getString("Configuration.P2T.Label.ServerPort") + "");
+ serverPortLabel.setHorizontalAlignment(JLabel.RIGHT);
+ }
+ return serverPortLabel;
+ }
+
+ private JLabel getServerPortLabel_T2P() {
+ if (serverPortLabel_T2P == null) {
+ serverPortLabel_T2P =
+ new JLabel("" + Messages.getString("Configuration.T2P.Label.ServerPort") + "");
+ serverPortLabel_T2P.setHorizontalAlignment(JLabel.RIGHT);
+ }
+ return serverPortLabel_T2P;
+ }
+
+ private JTextField getServerPortText() {
+ if (serverPortText == null) {
+ serverPortText = new JTextField();
+ serverPortText.setColumns(4);
+ serverPortText.setEnabled(true);
+ serverPortText.setToolTipText("" + Messages.getString("Configuration.P2T.Label.ServerPort") + "");
+ }
+ return serverPortText;
}
- return testButton_T2P;
- }
+ private JTextField getServerPortText_T2P() {
+ if (serverPortText_T2P == null) {
+ serverPortText_T2P = new JTextField();
+ serverPortText_T2P.setColumns(4);
+ serverPortText_T2P.setEnabled(true);
+ serverPortText_T2P.setToolTipText("" + Messages.getString("Configuration.T2P.Label.ServerPort") + "");
+ }
+ return serverPortText_T2P;
+ }
+
+ private JCheckBox getUseBox() {
+ if (useBox == null) {
+ useBox = new JCheckBox(Messages.getString("Configuration.P2T.Label.Use"));
+ useBox.setEnabled(true);
+ useBox.setToolTipText("" + Messages.getString("Configuration.P2T.Label.Use") + "");
+ CheckboxListener cbl = new CheckboxListener();
+ useBox.addItemListener(cbl);
+ }
+
+ return useBox;
+ }
+
+ private JCheckBox getUseBox_T2P() {
+ if (useBox == null) {
+ useBox = new JCheckBox(Messages.getString("Configuration.P2T.Label.Use"));
+ useBox.setEnabled(true);
+ useBox.setToolTipText("" + Messages.getString("Configuration.T2P.Label.Use") + "");
+ CheckboxListener cbl = new CheckboxListener();
+ useBox.addItemListener(cbl);
+ }
+
+ return useBox;
+ }
+
+ private JLabel getManagerPathLabel() {
+ if (managerPathLabel == null) {
+ managerPathLabel =
+ new JLabel("" + Messages.getString("Configuration.P2T.Label.ServerURI") + "");
+ managerPathLabel.setHorizontalAlignment(JLabel.RIGHT);
+ }
+ return managerPathLabel;
+ }
+
+ private JLabel getManagerPathLabel_T2P() {
+ if (managerPathLabel_T2P == null) {
+ managerPathLabel_T2P =
+ new JLabel("" + Messages.getString("Configuration.T2P.Label.ServerURI") + "");
+ managerPathLabel_T2P.setHorizontalAlignment(JLabel.RIGHT);
+ }
+ return managerPathLabel_T2P;
+ }
- private WopedButton getDefaultButton() {
- if (defaultButton == null) {
- defaultButton = new WopedButton();
- defaultButton.setText(Messages.getTitle("Button.SetToDefault"));
- defaultButton.setPreferredSize(new Dimension(200, 25));
- defaultButton.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- setDefaultValues();
+ private JTextField getManagerPathText() {
+ if (managerPathText == null) {
+ managerPathText = new JTextField();
+ managerPathText.setColumns(40);
+ managerPathText.setEnabled(true);
+ managerPathText.setToolTipText("" + Messages.getString("Configuration.P2T.Label.ServerURI") + "");
+ }
+ return managerPathText;
+ }
+
+ private JTextField getManagerPathText_T2P() {
+ if (managerPathText_T2P == null) {
+ managerPathText_T2P = new JTextField();
+ managerPathText_T2P.setColumns(40);
+ managerPathText_T2P.setEnabled(true);
+ managerPathText_T2P.setToolTipText("" + Messages.getString("Configuration.T2P.Label.ServerURI") + "");
+ }
+ return managerPathText_T2P;
+ }
+
+ private WopedButton getTestButton() {
+ if (testButton == null) {
+ testButton = new WopedButton();
+ testButton.setText(Messages.getTitle("Button.TestConnection"));
+ testButton.setIcon(Messages.getImageIcon("Button.TestConnection"));
+ testButton.setMnemonic(Messages.getMnemonic("Button.TestConnection"));
+ testButton.setPreferredSize(new Dimension(160, 25));
+ testButton.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ testProcess2TextConnection();
+ }
+ });
+ }
+
+ return testButton;
+ }
+
+ private WopedButton getTestButton_T2P() {
+ if (testButton_T2P == null) {
+ testButton_T2P = new WopedButton();
+ testButton_T2P.setText(Messages.getTitle("Button.TestConnection"));
+ testButton_T2P.setIcon(Messages.getImageIcon("Button.TestConnection"));
+ testButton_T2P.setMnemonic(Messages.getMnemonic("Button.TestConnection"));
+ testButton_T2P.setPreferredSize(new Dimension(160, 25));
+ testButton_T2P.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ testText2ProcessConnection();
+ }
+ });
+ }
+
+ return testButton_T2P;
+ }
+
+ private WopedButton getDefaultButton() {
+ if (defaultButton == null) {
+ defaultButton = new WopedButton();
+ defaultButton.setText(Messages.getTitle("Button.SetToDefault"));
+ defaultButton.setPreferredSize(new Dimension(200, 25));
+ defaultButton.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ setDefaultValues();
+ }
+ });
+ }
+ return defaultButton;
+ }
+
+ private WopedButton getDefaultButton_T2P() {
+ if (defaultButton_T2P == null) {
+ defaultButton_T2P = new WopedButton();
+ defaultButton_T2P.setText(Messages.getTitle("Button.SetToDefault"));
+ defaultButton_T2P.setPreferredSize(new Dimension(200, 25));
+ defaultButton_T2P.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ setDefaultValues_T2P();
+ }
+ });
+ }
+ return defaultButton_T2P;
+ }
+
+ private void testProcess2TextConnection() {
+ URL url = null;
+ String connection =
+ "http://"
+ + getServerURLText().getText()
+ + ":"
+ + getServerPortText().getText()
+ + getManagerPathText().getText();
+ String arg[] = {connection, ""};
+
+ try {
+ url = new URL(connection);
+ URLConnection urlConnection = url.openConnection();
+
+ if (urlConnection.getContent() != null) {
+ arg[1] = "P2T";
+ JOptionPane.showMessageDialog(
+ this.getSettingsPanel(),
+ Messages.getString("Paraphrasing.Webservice.Success.Message", arg),
+ Messages.getString("Paraphrasing.Webservice.Success.Title"),
+ JOptionPane.INFORMATION_MESSAGE);
}
- });
- }
- return defaultButton;
- }
-
- private WopedButton getDefaultButton_T2P() {
- if (defaultButton_T2P == null) {
- defaultButton_T2P = new WopedButton();
- defaultButton_T2P.setText(Messages.getTitle("Button.SetToDefault"));
- defaultButton_T2P.setPreferredSize(new Dimension(200, 25));
- defaultButton_T2P.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- setDefaultValues_T2P();
+ } catch (MalformedURLException mue) {
+ JOptionPane.showMessageDialog(
+ this.getSettingsPanel(),
+ Messages.getString("Paraphrasing.Webservice.Error.WebserviceException.Message", arg),
+ Messages.getString("Paraphrasing.Webservice.Error.Title"),
+ JOptionPane.ERROR_MESSAGE);
+ } catch (IOException ex) {
+ JOptionPane.showMessageDialog(
+ this.getSettingsPanel(),
+ Messages.getString("Paraphrasing.Webservice.Error.WebserviceException.Message", arg),
+ Messages.getString("Paraphrasing.Webservice.Error.Title"),
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
+ private void testText2ProcessConnection() {
+ URL url = null;
+ String connection =
+ "http://"
+ + getServerURLText_T2P().getText()
+ + ":"
+ + getServerPortText_T2P().getText()
+ + getManagerPathText_T2P().getText()
+ + "";
+ String arg[] = {connection, ""};
+
+ try {
+ url = new URL(connection);
+ URLConnection urlConnection = url.openConnection();
+ if (urlConnection.getContent() != null) {
+ arg[1] = "T2P";
+ JOptionPane.showMessageDialog(
+ this.getSettingsPanel_T2P(),
+ Messages.getString("Paraphrasing.Webservice.Success.Message", arg),
+ Messages.getString("Paraphrasing.Webservice.Success.Title"),
+ JOptionPane.INFORMATION_MESSAGE);
}
- });
- }
- return defaultButton_T2P;
- }
-
- private void testProcess2TextConnection() {
- URL url = null;
- String connection =
- "http://"
- + getServerURLText().getText()
- + ":"
- + getServerPortText().getText()
- + getManagerPathText().getText();
- String arg[] = {connection, ""};
-
- try {
- url = new URL(connection);
- URLConnection urlConnection = url.openConnection();
-
- if (urlConnection.getContent() != null) {
- arg[1] = "P2T";
- JOptionPane.showMessageDialog(
- this.getSettingsPanel(),
- Messages.getString("Paraphrasing.Webservice.Success.Message", arg),
- Messages.getString("Paraphrasing.Webservice.Success.Title"),
- JOptionPane.INFORMATION_MESSAGE);
- }
- } catch (MalformedURLException mue) {
- JOptionPane.showMessageDialog(
- this.getSettingsPanel(),
- Messages.getString("Paraphrasing.Webservice.Error.WebserviceException.Message", arg),
- Messages.getString("Paraphrasing.Webservice.Error.Title"),
- JOptionPane.ERROR_MESSAGE);
- } catch (IOException ex) {
- JOptionPane.showMessageDialog(
- this.getSettingsPanel(),
- Messages.getString("Paraphrasing.Webservice.Error.WebserviceException.Message", arg),
- Messages.getString("Paraphrasing.Webservice.Error.Title"),
- JOptionPane.ERROR_MESSAGE);
- }
- }
-
- private void testText2ProcessConnection() {
- URL url = null;
- String connection =
- "http://"
- + getServerURLText_T2P().getText()
- + ":"
- + getServerPortText_T2P().getText()
- + getManagerPathText_T2P().getText()
- + "";
- String arg[] = {connection, ""};
-
- try {
- url = new URL(connection);
- URLConnection urlConnection = url.openConnection();
- if (urlConnection.getContent() != null) {
- arg[1] = "T2P";
- JOptionPane.showMessageDialog(
- this.getSettingsPanel_T2P(),
- Messages.getString("Paraphrasing.Webservice.Success.Message", arg),
- Messages.getString("Paraphrasing.Webservice.Success.Title"),
- JOptionPane.INFORMATION_MESSAGE);
- }
- } catch (MalformedURLException mue) {
- JOptionPane.showMessageDialog(
- this.getSettingsPanel_T2P(),
- Messages.getString("Paraphrasing.Webservice.Error.WebserviceException.Message", arg),
- Messages.getString("Paraphrasing.Webservice.Error.Title"),
- JOptionPane.ERROR_MESSAGE);
- } catch (IOException ex) {
- JOptionPane.showMessageDialog(
- this.getSettingsPanel_T2P(),
- Messages.getString("Paraphrasing.Webservice.Error.WebserviceException.Message", arg),
- Messages.getString("Paraphrasing.Webservice.Error.Title"),
- JOptionPane.ERROR_MESSAGE);
- }
- }
-
- private void setDefaultValues() {
- getServerURLText()
- .setText(ConfigurationManager.getStandardConfiguration().getProcess2TextServerHost());
- getManagerPathText()
- .setText(ConfigurationManager.getStandardConfiguration().getProcess2TextServerURI());
- getServerPortText()
- .setText("" + ConfigurationManager.getStandardConfiguration().getProcess2TextServerPort());
- }
-
- private void setDefaultValues_T2P() {
- getServerURLText_T2P()
- .setText(ConfigurationManager.getStandardConfiguration().getText2ProcessServerHost());
- getManagerPathText_T2P()
- .setText(ConfigurationManager.getStandardConfiguration().getText2ProcessServerURI());
- getServerPortText_T2P()
- .setText("" + ConfigurationManager.getStandardConfiguration().getText2ProcessServerPort());
- }
+ } catch (MalformedURLException mue) {
+ JOptionPane.showMessageDialog(
+ this.getSettingsPanel_T2P(),
+ Messages.getString("Paraphrasing.Webservice.Error.WebserviceException.Message", arg),
+ Messages.getString("Paraphrasing.Webservice.Error.Title"),
+ JOptionPane.ERROR_MESSAGE);
+ } catch (IOException ex) {
+ JOptionPane.showMessageDialog(
+ this.getSettingsPanel_T2P(),
+ Messages.getString("Paraphrasing.Webservice.Error.WebserviceException.Message", arg),
+ Messages.getString("Paraphrasing.Webservice.Error.Title"),
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
+ private void setDefaultValues() {
+ getServerURLText()
+ .setText(ConfigurationManager.getStandardConfiguration().getProcess2TextServerHost());
+ getManagerPathText()
+ .setText(ConfigurationManager.getStandardConfiguration().getProcess2TextServerURI());
+ getServerPortText()
+ .setText("" + ConfigurationManager.getStandardConfiguration().getProcess2TextServerPort());
+ }
+
+ private void setDefaultValues_T2P() {
+ getServerURLText_T2P()
+ .setText(ConfigurationManager.getStandardConfiguration().getText2ProcessServerHost());
+ getManagerPathText_T2P()
+ .setText(ConfigurationManager.getStandardConfiguration().getText2ProcessServerURI());
+ getServerPortText_T2P()
+ .setText("" + ConfigurationManager.getStandardConfiguration().getText2ProcessServerPort());
+ }
}
From 4006920123af577a6bbdc6726610b04fbd84a093 Mon Sep 17 00:00:00 2001
From: Marcel2511
Date: Mon, 10 Jun 2024 00:25:58 +0200
Subject: [PATCH 08/76] added api key validation
---
.../editor/gui/config/ConfNLPToolsPanel.java | 39 ++++++++++++++++---
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git a/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java b/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java
index ef750d3fc..7eca86a10 100644
--- a/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java
+++ b/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java
@@ -31,6 +31,7 @@
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.IOException;
+import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
@@ -482,12 +483,38 @@ public void actionPerformed(ActionEvent e) {
}
private void testGPTConnection() {
- // Implement connection test logic for GPT here
- JOptionPane.showMessageDialog(
- this.getAdditionalPanel(),
- "GPT connection test not implemented.",
- "Connection Test",
- JOptionPane.INFORMATION_MESSAGE);
+ String apiKey = apiKeyText.getText(); // Annahme: Methode zum Abrufen des API-Schlüssels ist vorhanden
+ String urlString = "https://api.openai.com/v1/engines";
+
+ try {
+ URL url = new URL(urlString);
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod("GET");
+ connection.setRequestProperty("Authorization", "Bearer " + apiKey);
+ connection.connect();
+
+ int responseCode = connection.getResponseCode();
+ String message;
+
+ if (responseCode == 200) {
+ message = "GPT connection successful. Response Code: " + responseCode;
+ } else {
+ message = "GPT connection failed. Response Code: " + responseCode;
+ }
+
+ JOptionPane.showMessageDialog(
+ this.getAdditionalPanel(),
+ message,
+ "Connection Test",
+ JOptionPane.INFORMATION_MESSAGE);
+
+ } catch (IOException e) {
+ JOptionPane.showMessageDialog(
+ this.getAdditionalPanel(),
+ "GPT connection test failed: " + e.getMessage(),
+ "Connection Test",
+ JOptionPane.ERROR_MESSAGE);
+ }
}
private void setDefaultValuesGPT() {
From 9ae6edf499f67f2edda503e2bb24356915d7f5bc Mon Sep 17 00:00:00 2001
From: Marcel2511
Date: Mon, 10 Jun 2024 00:30:21 +0200
Subject: [PATCH 09/76] added default prompt in settings
---
.../org/woped/core/config/DefaultStaticConfiguration.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/WoPeD-Core/src/main/java/org/woped/core/config/DefaultStaticConfiguration.java b/WoPeD-Core/src/main/java/org/woped/core/config/DefaultStaticConfiguration.java
index f3d0b9eae..157fd6155 100644
--- a/WoPeD-Core/src/main/java/org/woped/core/config/DefaultStaticConfiguration.java
+++ b/WoPeD-Core/src/main/java/org/woped/core/config/DefaultStaticConfiguration.java
@@ -191,9 +191,9 @@ public class DefaultStaticConfiguration implements IGeneralConfiguration {
private boolean yawlExportGroups = false;
// GPT settings
- private String gptApiKey = "test";
+ private String gptApiKey = "";
private boolean gptShowAgain = true;
- private String gptPrompt = "test";
+ private String gptPrompt = "Create a clearly structured and comprehensible continuous text from the given BPMN that is understandable for an uninformed reader. The text should be easy to read in the summary and contain all important content; if there are subdivided points, these are integrated into the text with suitable sentence beginnings in order to obtain a well-structured and easy-to-read text. Under no circumstances should the output contain sub-items or paragraphs, but should cover all processes in one piece!";
public DefaultStaticConfiguration() {
initConfig();
From c4b02fe27842d77d7cfb834c19375801f78b7c07 Mon Sep 17 00:00:00 2001
From: Marcel2511
Date: Mon, 10 Jun 2024 00:40:06 +0200
Subject: [PATCH 10/76] added clause so that old/new UI doesn't show if
checkAgain == false
added a clause that makes sure, that the UI to choose between the old / new option doesn't show if it's not enabled in the settings
---
.../starter/controller/vep/GUIViewEventProcessor.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/WoPeD-Starter/src/main/java/org/woped/starter/controller/vep/GUIViewEventProcessor.java b/WoPeD-Starter/src/main/java/org/woped/starter/controller/vep/GUIViewEventProcessor.java
index d21aaacad..338d9bbf3 100644
--- a/WoPeD-Starter/src/main/java/org/woped/starter/controller/vep/GUIViewEventProcessor.java
+++ b/WoPeD-Starter/src/main/java/org/woped/starter/controller/vep/GUIViewEventProcessor.java
@@ -87,11 +87,14 @@ && getMediator().getUi().getComponent() instanceof JFrame) {
P2TUI p2t;
if (getMediator().getUi() != null
&& getMediator().getUi().getComponent() instanceof JFrame) {
- p2t = new P2TUI((JFrame) getMediator().getUi(), getMediator());
+ {
+ p2t = new P2TUI((JFrame) getMediator().getUi(), getMediator());}
} else {
p2t = new P2TUI(getMediator());
}
- p2t.setVisible(true);
+ if(ConfigurationManager.getConfiguration().getGptShowAgain()){
+ p2t.setVisible(true);
+ }
break;
case AbstractViewEvent.NEW:
getMediator().createEditor(true);
From 1d705eb7baa5da2253337875597e82f6e93c4130 Mon Sep 17 00:00:00 2001
From: Marcel2511
Date: Mon, 10 Jun 2024 00:50:58 +0200
Subject: [PATCH 11/76] added checkbox in p2tUI "don't show again"
Added a checkbox that allows the user to hide the new/old option upon using p2t nlp tools
---
.../src/main/java/org/woped/file/p2t/P2TUI.java | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
index 514c3cdf8..da61b87c4 100644
--- a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
+++ b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
@@ -38,6 +38,7 @@ public class P2TUI extends JDialog {
private JTextField apiKeyField;
private JTextArea promptField; // Changed to JTextArea for multiline
private JCheckBox enablePromptCheckBox; // New Checkbox
+ private JCheckBox showAgainCheckBox; // New Checkbox
private static final String DEFAULT_PROMPT = "Create a clearly structured and comprehensible continuous text from the given BPMN that is understandable for an uninformed reader. The text should be easy to read in the summary and contain all important content; if there are subdivided points, these are integrated into the text with suitable sentence beginnings in order to obtain a well-structured and easy-to-read text. Under no circumstances should the output contain sub-items or paragraphs, but should cover all processes in one piece!";
public P2TUI(AbstractApplicationMediator mediator) {
@@ -66,7 +67,7 @@ private void initialize() {
this.pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation((screenSize.width - this.getWidth()) / 3, (screenSize.height - this.getHeight()) / 3);
- Dimension size = new Dimension(600, 300); // Adjusted size to accommodate new text field and checkbox
+ Dimension size = new Dimension(600, 350); // Adjusted size to accommodate new text field and checkbox
this.setSize(size);
}
@@ -126,11 +127,16 @@ private JPanel initializeSwitchButtonPanel() {
}
});
+ showAgainCheckBox = new JCheckBox("Don't show Again");
+ showAgainCheckBox.setSelected(true);
+ showAgainCheckBox.setToolTipText("Placeholder");
+
apiKeyLabel.setVisible(false);
apiKeyField.setVisible(false);
promptLabel.setVisible(false);
promptScrollPane.setVisible(false);
enablePromptCheckBox.setVisible(false);
+ showAgainCheckBox.setVisible(false); // Initially hidden
newRadioButton.addActionListener(e -> {
apiKeyLabel.setVisible(true);
@@ -138,6 +144,7 @@ private JPanel initializeSwitchButtonPanel() {
promptLabel.setVisible(true);
promptScrollPane.setVisible(true);
enablePromptCheckBox.setVisible(true);
+ showAgainCheckBox.setVisible(true); // Show when new service is selected
apiKeyField.requestFocusInWindow();
});
@@ -147,6 +154,7 @@ private JPanel initializeSwitchButtonPanel() {
promptLabel.setVisible(false);
promptScrollPane.setVisible(false);
enablePromptCheckBox.setVisible(false);
+ showAgainCheckBox.setVisible(false); // Hide when old service is selected
});
// Set "alt" as default selection
@@ -180,6 +188,12 @@ private JPanel initializeSwitchButtonPanel() {
gbc.weightx = 1.0;
fieldsPanel.add(enablePromptCheckBox, gbc);
+ gbc.gridx = 0;
+ gbc.gridy = 4;
+ gbc.gridwidth = 2;
+ gbc.weightx = 1.0;
+ fieldsPanel.add(showAgainCheckBox, gbc); // Add "Show Again" checkbox
+
gbc.gridx = 0;
gbc.gridy = 1;
gbc.gridwidth = 2;
From 0f0c449fd325323437fe7caee7cd508d377ed4fa Mon Sep 17 00:00:00 2001
From: Marcel2511
Date: Mon, 10 Jun 2024 00:57:12 +0200
Subject: [PATCH 12/76] refactored apikey validation
refactored the apiKey validation so that it only checks validity, if the "new" option is actually selected via the radio button
---
.../src/main/java/org/woped/file/p2t/P2TUI.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
index da61b87c4..0fdae44c5 100644
--- a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
+++ b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
@@ -39,6 +39,8 @@ public class P2TUI extends JDialog {
private JTextArea promptField; // Changed to JTextArea for multiline
private JCheckBox enablePromptCheckBox; // New Checkbox
private JCheckBox showAgainCheckBox; // New Checkbox
+ private JRadioButton newRadioButton = null;
+ private JRadioButton oldRadioButton = null;
private static final String DEFAULT_PROMPT = "Create a clearly structured and comprehensible continuous text from the given BPMN that is understandable for an uninformed reader. The text should be easy to read in the summary and contain all important content; if there are subdivided points, these are integrated into the text with suitable sentence beginnings in order to obtain a well-structured and easy-to-read text. Under no circumstances should the output contain sub-items or paragraphs, but should cover all processes in one piece!";
public P2TUI(AbstractApplicationMediator mediator) {
@@ -78,8 +80,8 @@ private JPanel initializeSwitchButtonPanel() {
JPanel radioPanel = new JPanel(new GridBagLayout());
GridBagConstraints gbcRadio = new GridBagConstraints();
- JRadioButton oldRadioButton = new JRadioButton(Messages.getString("P2T.oldservice.title"));
- JRadioButton newRadioButton = new JRadioButton(Messages.getString("P2T.newservice.title"));
+ oldRadioButton = new JRadioButton(Messages.getString("P2T.oldservice.title"));
+ newRadioButton = new JRadioButton(Messages.getString("P2T.newservice.title"));
ButtonGroup group = new ButtonGroup();
group.add(oldRadioButton);
group.add(newRadioButton);
@@ -210,7 +212,14 @@ private JPanel initializeSingleButtonPanel() {
JButton singleButton = new JButton(new AbstractAction() {
public void actionPerformed(ActionEvent arg0) {
- validateAPIKey();
+ if (newRadioButton.isSelected()) {
+ validateAPIKey();
+ //GPT Aufrufen
+ }
+ else {
+ //GPT Aufrufen
+ }
+
}
});
From 72cda0ef3bacf86c70e9fe528fc39ef9e5d25ddb Mon Sep 17 00:00:00 2001
From: Marcel2511
Date: Mon, 10 Jun 2024 01:41:38 +0200
Subject: [PATCH 13/76] added logic to show again button in old/new UI, added
config changes based on apikey / prompt
added logic to show again button in old/new UI, added config changes based on apikey / prompt
---
.../woped/beanconfiguration/configuration.xsd | 2 +-
.../editor/gui/config/ConfNLPToolsPanel.java | 2 +-
.../main/java/org/woped/file/p2t/P2TUI.java | 53 +++++++++++--------
3 files changed, 32 insertions(+), 25 deletions(-)
diff --git a/WoPeD-BeanConfiguration/src/main/java/org/woped/beanconfiguration/configuration.xsd b/WoPeD-BeanConfiguration/src/main/java/org/woped/beanconfiguration/configuration.xsd
index c7d8adf69..e03fccdf6 100644
--- a/WoPeD-BeanConfiguration/src/main/java/org/woped/beanconfiguration/configuration.xsd
+++ b/WoPeD-BeanConfiguration/src/main/java/org/woped/beanconfiguration/configuration.xsd
@@ -141,7 +141,7 @@
-
+
diff --git a/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java b/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java
index 7eca86a10..9d333a3af 100644
--- a/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java
+++ b/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java
@@ -128,7 +128,7 @@ public boolean applyConfiguration() {
// Save additional panel configurations
ConfigurationManager.getConfiguration().setGptApiKey(getApiKeyText().getText());
- ConfigurationManager.getConfiguration().setGptShowAgain(getShowAgainBox().isSelected());
+ ConfigurationManager.getConfiguration().setGptShowAgain(true);
ConfigurationManager.getConfiguration().setGptPrompt(getPromptText().getText());
return true;
diff --git a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
index 0fdae44c5..0a44968e3 100644
--- a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
+++ b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
@@ -9,15 +9,13 @@
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
-import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
@@ -28,6 +26,9 @@
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;
+
+import org.woped.core.config.ConfigurationManager;
+import org.woped.core.config.IConfiguration;
import org.woped.core.controller.AbstractApplicationMediator;
import org.woped.gui.translations.Messages;
@@ -38,7 +39,7 @@ public class P2TUI extends JDialog {
private JTextField apiKeyField;
private JTextArea promptField; // Changed to JTextArea for multiline
private JCheckBox enablePromptCheckBox; // New Checkbox
- private JCheckBox showAgainCheckBox; // New Checkbox
+ private JCheckBox dontshowAgainCheckBox; // New Checkbox
private JRadioButton newRadioButton = null;
private JRadioButton oldRadioButton = null;
private static final String DEFAULT_PROMPT = "Create a clearly structured and comprehensible continuous text from the given BPMN that is understandable for an uninformed reader. The text should be easy to read in the summary and contain all important content; if there are subdivided points, these are integrated into the text with suitable sentence beginnings in order to obtain a well-structured and easy-to-read text. Under no circumstances should the output contain sub-items or paragraphs, but should cover all processes in one piece!";
@@ -129,16 +130,17 @@ private JPanel initializeSwitchButtonPanel() {
}
});
- showAgainCheckBox = new JCheckBox("Don't show Again");
- showAgainCheckBox.setSelected(true);
- showAgainCheckBox.setToolTipText("Placeholder");
+ dontshowAgainCheckBox = new JCheckBox("Show Again");
+ dontshowAgainCheckBox.setSelected(ConfigurationManager.getConfiguration().getGptShowAgain());
+ dontshowAgainCheckBox.setToolTipText("Placeholder");
apiKeyLabel.setVisible(false);
+ apiKeyField.setText(ConfigurationManager.getConfiguration().getGptApiKey());
apiKeyField.setVisible(false);
promptLabel.setVisible(false);
promptScrollPane.setVisible(false);
enablePromptCheckBox.setVisible(false);
- showAgainCheckBox.setVisible(false); // Initially hidden
+ dontshowAgainCheckBox.setVisible(false); // Initially hidden
newRadioButton.addActionListener(e -> {
apiKeyLabel.setVisible(true);
@@ -146,7 +148,7 @@ private JPanel initializeSwitchButtonPanel() {
promptLabel.setVisible(true);
promptScrollPane.setVisible(true);
enablePromptCheckBox.setVisible(true);
- showAgainCheckBox.setVisible(true); // Show when new service is selected
+ dontshowAgainCheckBox.setVisible(true); // Show when new service is selected
apiKeyField.requestFocusInWindow();
});
@@ -156,7 +158,7 @@ private JPanel initializeSwitchButtonPanel() {
promptLabel.setVisible(false);
promptScrollPane.setVisible(false);
enablePromptCheckBox.setVisible(false);
- showAgainCheckBox.setVisible(false); // Hide when old service is selected
+ dontshowAgainCheckBox.setVisible(false); // Hide when old service is selected
});
// Set "alt" as default selection
@@ -194,7 +196,7 @@ private JPanel initializeSwitchButtonPanel() {
gbc.gridy = 4;
gbc.gridwidth = 2;
gbc.weightx = 1.0;
- fieldsPanel.add(showAgainCheckBox, gbc); // Add "Show Again" checkbox
+ fieldsPanel.add(dontshowAgainCheckBox, gbc); // Add "Show Again" checkbox
gbc.gridx = 0;
gbc.gridy = 1;
@@ -210,24 +212,29 @@ private JPanel initializeSingleButtonPanel() {
JPanel buttonPanel = new JPanel(new BorderLayout());
buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
- JButton singleButton = new JButton(new AbstractAction() {
- public void actionPerformed(ActionEvent arg0) {
- if (newRadioButton.isSelected()) {
- validateAPIKey();
- //GPT Aufrufen
- }
- else {
- //GPT Aufrufen
- }
-
- }
- });
+ JButton singleButton = new JButton();
singleButton.setMnemonic(KeyEvent.VK_A);
singleButton.setText(Messages.getString("P2T.text"));
buttonPanel.add(singleButton, BorderLayout.CENTER);
+ singleButton.addActionListener(e -> {
+ if (newRadioButton.isSelected()) {
+ validateAPIKey();
+ ConfigurationManager.getConfiguration().setGptApiKey(apiKeyField.getText());
+ ConfigurationManager.getConfiguration().setGptPrompt(promptField.getText());
+
+ if(!dontshowAgainCheckBox.isSelected()){
+ ConfigurationManager.getConfiguration().setGptShowAgain(false);
+ }
+ //GPT Aufrufen
+ }
+ else {
+ //GPT Aufrufen
+ }
+
+ });
return buttonPanel;
}
From 444322d7e795c6b099f5f98982574cfe650eaa44 Mon Sep 17 00:00:00 2001
From: Marcel2511
Date: Mon, 10 Jun 2024 09:26:33 +0200
Subject: [PATCH 14/76] bixfix where prompt didnt update when changed in
settings
bixfix where prompt didnt update when changed in settings
---
WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
index 0a44968e3..e7c57ee98 100644
--- a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
+++ b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
@@ -114,6 +114,7 @@ private JPanel initializeSwitchButtonPanel() {
promptField.setWrapStyleWord(true);
promptField.setRows(5); // Set initial number of rows
promptField.setEnabled(false); // Initially disabled
+ promptField.setText(ConfigurationManager.getConfiguration().getGptPrompt());
JScrollPane promptScrollPane = new JScrollPane(promptField);
promptScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
From 24207970991479669a4a6ef41ab1e9a8a3bafee0 Mon Sep 17 00:00:00 2001
From: anneke02
Date: Mon, 10 Jun 2024 11:26:25 +0200
Subject: [PATCH 15/76] Refactor strings of P2TUI
---
.../editor/gui/config/ConfNLPToolsPanel.java | 10 ++---
.../main/java/org/woped/file/p2t/P2TUI.java | 6 +--
.../src/main/resources/Messages.properties | 13 ++++--
.../src/main/resources/Messages_de.properties | 42 ++++++++++++-------
4 files changed, 44 insertions(+), 27 deletions(-)
diff --git a/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java b/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java
index 9d333a3af..945f09e93 100644
--- a/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java
+++ b/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java
@@ -373,7 +373,7 @@ private JPanel getAdditionalPanel() {
c.weightx = 1;
c.gridx = 0;
c.gridy = 0;
- additionalPanel.add(new JLabel("API-Key:"), c);
+ additionalPanel.add(new JLabel(Messages.getString("Configuration.GPT.apikey.Title")), c);
c.weightx = 1;
c.gridx = 1;
@@ -383,7 +383,7 @@ private JPanel getAdditionalPanel() {
c.weightx = 1;
c.gridx = 0;
c.gridy = 1;
- additionalPanel.add(new JLabel("Prompt:"), c);
+ additionalPanel.add(new JLabel(Messages.getString("Configuration.GPT.prompt.Title")), c);
c.weightx = 1;
c.gridx = 1;
@@ -441,7 +441,7 @@ private JTextArea getPromptText() {
private JCheckBox getShowAgainBox() {
if (showAgainBox == null) {
- showAgainBox = new JCheckBox("Show Again");
+ showAgainBox = new JCheckBox(Messages.getString("Configuration.GPT.show.again.Title"));
showAgainBox.setEnabled(true);
showAgainBox.setToolTipText("Test");
}
@@ -451,7 +451,7 @@ private JCheckBox getShowAgainBox() {
private WopedButton getResetButton() {
if (resetButton == null) {
resetButton = new WopedButton();
- resetButton.setText("Auf Standard zurücksetzen");
+ resetButton.setText(Messages.getString("Configuration.GPT.standard.Title"));
resetButton.setPreferredSize(new Dimension(200, 25));
resetButton.addActionListener(
new ActionListener() {
@@ -468,7 +468,7 @@ public void actionPerformed(ActionEvent e) {
private WopedButton getCheckConnectionButton() {
if (checkConnectionButton == null) {
checkConnectionButton = new WopedButton();
- checkConnectionButton.setText("Verbindung überprüfen");
+ checkConnectionButton.setText(Messages.getString("Configuration.GPT.connection.Title"));
checkConnectionButton.setIcon(Messages.getImageIcon("Button.TestConnection"));
checkConnectionButton.setMnemonic(Messages.getMnemonic("Button.TestConnection"));
checkConnectionButton.setPreferredSize(new Dimension(200, 25));
diff --git a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
index a9e0c570e..553a08d0e 100644
--- a/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
+++ b/WoPeD-FileInterface/src/main/java/org/woped/file/p2t/P2TUI.java
@@ -111,7 +111,7 @@ private JPanel initializeSwitchButtonPanel() {
apiKeyField = new JTextField();
apiKeyField.setPreferredSize(new Dimension(200, 25));
- JLabel promptLabel = new JLabel("Prompt:");
+ JLabel promptLabel = new JLabel(Messages.getString("P2T.prompt.title") + ":");
promptField = new JTextArea(DEFAULT_PROMPT); // Changed to JTextArea
promptField.setLineWrap(true);
promptField.setWrapStyleWord(true);
@@ -126,7 +126,7 @@ private JPanel initializeSwitchButtonPanel() {
promptScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
promptScrollPane.setPreferredSize(new Dimension(200, 100));
- enablePromptCheckBox = new JCheckBox("Enable editing prompt");
+ enablePromptCheckBox = new JCheckBox(Messages.getString("P2T.prompt.checkbox.enable.title"));
enablePromptCheckBox.setSelected(false);
enablePromptCheckBox.addActionListener(e -> {
promptField.setEnabled(enablePromptCheckBox.isSelected());
@@ -137,7 +137,7 @@ private JPanel initializeSwitchButtonPanel() {
});
- dontshowAgainCheckBox = new JCheckBox("Show Again");
+ dontshowAgainCheckBox = new JCheckBox(Messages.getString("P2T.popup.show.again.title"));
dontshowAgainCheckBox.setSelected(ConfigurationManager.getConfiguration().getGptShowAgain());
dontshowAgainCheckBox.setToolTipText("Placeholder");
apiKeyLabel.setVisible(false);
diff --git a/WoPeD-GUI/src/main/resources/Messages.properties b/WoPeD-GUI/src/main/resources/Messages.properties
index 61641ac4b..65acb5854 100644
--- a/WoPeD-GUI/src/main/resources/Messages.properties
+++ b/WoPeD-GUI/src/main/resources/Messages.properties
@@ -870,14 +870,16 @@ P2T.loading = Generating text...
P2T.ArcError = <>Model has arc weights - no text can be generated
P2T.SoundError = Modell is not sound - no text can be generated
P2T.SizeError = Modell has too few nodes - no text can be generated
-
P2T.Error.ArcWeights.title = Text generation failed
P2T.Error.ArcWeights.message = The net contains arc weights.\nArc weights are not supported by the process 2 text feature.
-P2T.oldservice.title = Old
-P2T.newservice.title = New
+P2T.oldservice.title = Algorithm
+P2T.newservice.title = LLM
P2T.apikey.title = API Key
P2T.apikey.invalid = API Key is not valid
P2T.apikey.invalid.title = Validation Error
+P2T.prompt.title = Prompt
+P2T.prompt.checkbox.enable.title = Enable editing
+P2T.popup.show.again.title = Show again
#*************
! Text2Process
@@ -1277,6 +1279,11 @@ Configuration.P2T.Label.ServerPort = Port
Configuration.P2T.Label.ServerURI = URI
Configuration.P2T.Label.Use = Enable NLP Tools
Configuration.P2T.Settings.Panel.Title = Process2Text server settings
+Configuration.GPT.apikey.Title = API Key
+Configuration.GPT.prompt.Title = Prompt
+Configuration.GPT.show.again.Title = Show again
+Configuration.GPT.standard.Title = Reset to standard
+Configuration.GPT.connection.Title = Test connection
Configuration.T2P.Settings.Panel.Title = Text2Process server settings
Configuration.T2P.Dialog.Restart.Title = Restart
Configuration.T2P.Label.ServerHost = Server Host
diff --git a/WoPeD-GUI/src/main/resources/Messages_de.properties b/WoPeD-GUI/src/main/resources/Messages_de.properties
index 47cd36bcb..1edc29258 100644
--- a/WoPeD-GUI/src/main/resources/Messages_de.properties
+++ b/WoPeD-GUI/src/main/resources/Messages_de.properties
@@ -467,22 +467,26 @@ DataOutput.textBandTitle = Ausgabe
#*************
! Process 2 Text
#*************
-P2T.textBandTitle = NLP Tools
-P2T.text = In Text umwandeln
-P2T.openP2T.text = Process zu Text
-P2T.openP2T.header = Eingabetext
-P2T.tooltip = Textuelle Beschreibung erzeugen
-P2T.loading = Erzeuge Text...
-P2T.ArcError = Modell hat Kantengewichte - kein Text generierbar
-P2T.SoundError = Modell ist nicht sound - kein Text generierbar
-P2T.SizeError = Modell hat zuwenige Knoten - kein Text generierbar
-P2T.Error.ArcWeights.title = Textgenerierung fehlgeschlagen
-P2T.Error.ArcWeights.message = Das Netz verwendet Kantengewichte. \nKantengewichte werden bei der Textgenerierung nicht unterst\u00FCtzt.
-P2T.oldservice.title = Alt
-P2T.newservice.title = Neu
-P2T.apikey.title = API Schl\u00FCssel
-P2T.apikey.invalid = API Schl\u00FCssel ist nicht valide
-P2T.apikey.invalid.title = Validierungsfehler
+P2T.textBandTitle = NLP Tools
+P2T.text = In Text umwandeln
+P2T.openP2T.text = Process zu Text
+P2T.openP2T.header = Eingabetext
+P2T.tooltip = Textuelle Beschreibung erzeugen
+P2T.loading = Erzeuge Text...
+P2T.ArcError = Modell hat Kantengewichte - kein Text generierbar
+P2T.SoundError = Modell ist nicht sound - kein Text generierbar
+P2T.SizeError = Modell hat zuwenige Knoten - kein Text generierbar
+P2T.Error.ArcWeights.title = Textgenerierung fehlgeschlagen
+P2T.Error.ArcWeights.message = Das Netz verwendet Kantengewichte. \nKantengewichte werden bei der Textgenerierung nicht unterst\u00FCtzt.
+P2T.oldservice.title = Algorithmus
+P2T.newservice.title = LLM
+P2T.apikey.title = API Schl\u00FCssel
+P2T.apikey.invalid = API Schl\u00FCssel ist nicht valide
+P2T.apikey.invalid.title = Validierungsfehler
+P2T.prompt.title = Prompt
+P2T.prompt.checkbox.enable.title = Bearbeitung aktivieren
+P2T.popup.show.again.title = Erneut anzeigen
+
#*************
! Text 2 Process
#*************
@@ -814,6 +818,11 @@ Configuration.P2T.Label.Use = NLP Tools aktivieren
Configuration.P2T.Settings.Panel.Title = Process2Text Servereinstellungen
Configuration.T2P.Settings.Panel.Title = Text2Process Servereinstellungen
Configuration.P2T.Title = NLP Tools
+Configuration.GPT.apikey.Title = API Schl\u00FCssel
+Configuration.GPT.prompt.Title = Prompt
+Configuration.GPT.show.again.Title = Erneut anzeigen
+Configuration.GPT.standard.Title = Auf Standard zur\u00FCcksetzen
+Configuration.GPT.connection.Title = Verbindung \u00FCberpr\u00FCfen
Configuration.T2P.Dialog.Restart.Title = Neustart
Configuration.T2P.Label.ServerHost = Server Host
Configuration.T2P.Label.ServerPort = Port
@@ -836,6 +845,7 @@ Configuration.YAWL.Panel.Export.ExplicitPlaces = *.yawl Dat
Configuration.YAWL.Panel.Export.ExplicitPlaces.ToolTip = Alle Stellen im Petrinetz werden zu Conditions in YAWL exportiert
Configuration.YAWL.Panel.Export.Groups = *.ybkp Dateien mit Gruppen exportieren
Configuration.YAWL.Panel.Export.Groups.ToolTip = Alle Gruppen im Ressourcen Editor werden zu OrgGroups in YAWL exportiert
+
#*************
! Exit-Config
#*************
From 1c01d29d65f2776de281b3e25cc192ad1fa378a1 Mon Sep 17 00:00:00 2001
From: I552396
Date: Mon, 10 Jun 2024 11:29:43 +0200
Subject: [PATCH 16/76] Make visibility of GPT settings selectable
---
.../java/org/woped/editor/gui/config/ConfNLPToolsPanel.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java b/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java
index 9d333a3af..b698e187e 100644
--- a/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java
+++ b/WoPeD-Editor/src/main/java/org/woped/editor/gui/config/ConfNLPToolsPanel.java
@@ -407,6 +407,8 @@ private JPanel getAdditionalPanel() {
additionalPanel.add(getCheckConnectionButton(), c);
}
+
+ additionalPanel.setVisible(getUseBox().isSelected());
return additionalPanel;
}
@@ -530,6 +532,7 @@ public void itemStateChanged(ItemEvent ie) {
if (jcb == useBox) {
getSettingsPanel().setVisible(jcb.isSelected());
getSettingsPanel_T2P().setVisible(jcb.isSelected());
+ getAdditionalPanel().setVisible(jcb.isSelected());
}
}
}
@@ -594,7 +597,7 @@ private JCheckBox getUseBox() {
if (useBox == null) {
useBox = new JCheckBox(Messages.getString("Configuration.P2T.Label.Use"));
useBox.setEnabled(true);
- useBox.setToolTipText("" + Messages.getString("Configuration.P2T.Label.Use") + "");
+ useBox.setToolTipText("" + Messages.getString("Configuration.P2T.Label.Use") + "