Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds endpoint for retrieving email-templates incl. placeholders #2623

Merged
merged 9 commits into from
Oct 27, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -666,25 +666,35 @@
import com.jdimension.jlawyer.server.utils.ContentTypes;
import java.awt.Component;
import java.awt.Container;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.KeyStroke;
import org.apache.log4j.Logger;
import javax.swing.undo.UndoManager;

/**
*
* @author Kutschke
*/
public class HtmlEditorPanel extends javax.swing.JPanel implements EditorImplementation {

private final UndoManager undoManager;
private static final Logger log=Logger.getLogger(HtmlEditorPanel.class.getName());

/**
* Creates new form HtmlEditorPanel
*/
public HtmlEditorPanel() {
initComponents();
}

undoManager = new UndoManager();
setupUndoRedoForEditorPane(htmlPane); }

/**
* This method is called from within the constructor to initialize the form.
Expand Down Expand Up @@ -822,5 +832,54 @@ private boolean insertToEditorPane(Container c, String t, int pos) {
}
return false;
}

private void setupUndoRedoForEditorPane(Container container) {
for (Component comp : container.getComponents()) {
if (comp instanceof JEditorPane) {
JEditorPane editorPane = (JEditorPane) comp;
editorPane.getDocument().addUndoableEditListener(e -> undoManager.addEdit(e.getEdit()));

// Setup key bindings for undo
KeyStroke undoKeystroke = KeyStroke.getKeyStroke(
KeyEvent.VK_Z,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()
);

// Setup key bindings for redo
KeyStroke redoKeystroke = KeyStroke.getKeyStroke(
KeyEvent.VK_Y,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()
);

editorPane.getInputMap(JComponent.WHEN_FOCUSED).put(undoKeystroke, "Undo");
editorPane.getActionMap().put("Undo", new AbstractAction("Undo") {
@Override
public void actionPerformed(ActionEvent evt) {
if (undoManager.canUndo()) {
undoManager.undo();
}
}
});

editorPane.getInputMap(JComponent.WHEN_FOCUSED).put(redoKeystroke, "Redo");
editorPane.getActionMap().put("Redo", new AbstractAction("Redo") {
@Override
public void actionPerformed(ActionEvent evt) {
if (undoManager.canRedo()) {
undoManager.redo();
}
}
});

break; // Found the editor pane, no need to continue
} else if (comp instanceof Container) {
setupUndoRedoForEditorPane((Container) comp);
}
}
}

public UndoManager getUndoManager() {
return undoManager;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -664,20 +664,64 @@
package com.jdimension.jlawyer.client.mail;

import com.jdimension.jlawyer.server.utils.ContentTypes;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.JComponent;
import javax.swing.KeyStroke;
import javax.swing.undo.UndoManager;

/**
*
* @author Kutschke
*/
public class TextEditorPanel extends javax.swing.JPanel implements EditorImplementation {


private final UndoManager undoManager;

/**
* Creates new form TextEditorPanel
*/
public TextEditorPanel() {
initComponents();

// Initialize UndoManager
undoManager = new UndoManager();
taText.getDocument().addUndoableEditListener(e -> undoManager.addEdit(e.getEdit()));

// Setup key bindings for undo
KeyStroke undoKeystroke = KeyStroke.getKeyStroke(
KeyEvent.VK_Z,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()
);

// Setup key bindings for redo
KeyStroke redoKeystroke = KeyStroke.getKeyStroke(
KeyEvent.VK_Y,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()
);

taText.getInputMap(JComponent.WHEN_FOCUSED).put(undoKeystroke, "Undo");
taText.getActionMap().put("Undo", new AbstractAction("Undo") {
@Override
public void actionPerformed(ActionEvent evt) {
if (undoManager.canUndo()) {
undoManager.undo();
}
}
});

taText.getInputMap(JComponent.WHEN_FOCUSED).put(redoKeystroke, "Redo");
taText.getActionMap().put("Redo", new AbstractAction("Redo") {
@Override
public void actionPerformed(ActionEvent evt) {
if (undoManager.canRedo()) {
undoManager.redo();
}
}
});

// this is required because the scroll pane was stealing those key strokes from its jtextarea, making it impossible to scroll using the keys
this.jScrollPane2.getInputMap().put(KeyStroke.getKeyStroke("UP"), "none");
this.jScrollPane2.getInputMap().put(KeyStroke.getKeyStroke("DOWN"), "none");
Expand Down Expand Up @@ -764,4 +808,9 @@ public String getSelectedText() {
public void insert(String t, int pos) {
this.taText.insert(t, pos);
}


public UndoManager getUndoManager() {
return undoManager;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -682,5 +682,8 @@ public interface TemplatesEndpointLocalV6 {
Response getPlaceHoldersForTemplate(String folder, String template, String caseId);

Response addDocumentFromTemplate(String caseId, String fileName, String templateFolder, String template, List<RestfulPlaceholderV6> placeHolderValues) throws Exception;

Response listEmailTemplates();

Response getEmailFromTemplate(String templateName, String caseId);
}
Loading