Skip to content

Commit

Permalink
save notes automatically. close #783
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Dec 9, 2023
1 parent 85700c0 commit fd03921
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" pref="369" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Component id="cmdSave" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="lblFileName" max="32767" attributes="0"/>
</Group>
Expand All @@ -27,10 +26,7 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="cmdSave" max="32767" attributes="0"/>
<Component id="lblFileName" max="32767" attributes="0"/>
</Group>
<Component id="lblFileName" min="-2" pref="28" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" max="32767" attributes="0"/>
</Group>
Expand All @@ -49,16 +45,6 @@
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="cmdSave">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons/filesave.png"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdSaveActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblFileName">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,15 +682,14 @@ public class HtmlPanel extends javax.swing.JPanel implements PreviewPanel {

/**
* Creates new form PlaintextPanel
* @param docId
* @param readOnly
*/
public HtmlPanel(String docId, boolean readOnly) {
initComponents();
this.id = docId;
this.readOnly=readOnly;
this.cmdSave.setEnabled(!readOnly);
//ThreadUtils.updateEditorPane(this.edtContent, "");
ThreadUtils.updateHtmlEditor(this.html, "");
ThreadUtils.enableComponent(cmdSave, !readOnly);

ThreadUtils.enableComponent(this, !readOnly);
ThreadUtils.enableComponent(this.html, !readOnly);
Expand All @@ -713,19 +712,11 @@ private void initComponents() {

jScrollPane1 = new javax.swing.JScrollPane();
html = new com.jdimension.jlawyer.client.mail.HtmlEditorPanel();
cmdSave = new javax.swing.JButton();
lblFileName = new javax.swing.JLabel();

html.setFocusable(false);
jScrollPane1.setViewportView(html);

cmdSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/filesave.png"))); // NOI18N
cmdSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdSaveActionPerformed(evt);
}
});

lblFileName.setFont(lblFileName.getFont().deriveFont(lblFileName.getFont().getStyle() | java.awt.Font.BOLD));
lblFileName.setText("Notizdatei.html");

Expand All @@ -734,41 +725,21 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 369, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(cmdSave)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(lblFileName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(cmdSave, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblFileName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(lblFileName, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1))
);
}// </editor-fold>//GEN-END:initComponents

private void cmdSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdSaveActionPerformed
if (this.id != null) {
ThreadUtils.enableComponent(cmdSave, false);
try {
ClientSettings settings = ClientSettings.getInstance();
JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties());
locator.lookupArchiveFileServiceRemote().setDocumentContent(this.id, this.html.getText().getBytes());
} catch (Throwable t) {
log.error("Error saving document with id " + this.id, t);
ThreadUtils.showErrorDialog(EditorsRegistry.getInstance().getMainWindow(), "Fehler beim Speichern: " + t.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR);

}
ThreadUtils.enableComponent(cmdSave, true);
}
}//GEN-LAST:event_cmdSaveActionPerformed


// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cmdSave;
private com.jdimension.jlawyer.client.mail.HtmlEditorPanel html;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lblFileName;
Expand All @@ -785,5 +756,20 @@ public void showContent(byte[] content) {
//ThreadUtils.updateEditorPane(this.edtContent, new String(content));
ThreadUtils.updateHtmlEditor(html, new String(content));
}

@Override
public void removeNotify() {
if (this.id != null && !this.readOnly) {
try {
ClientSettings settings = ClientSettings.getInstance();
JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties());
locator.lookupArchiveFileServiceRemote().setDocumentContent(this.id, this.html.getText().getBytes());
} catch (Throwable t) {
log.error("Error saving document with id " + this.id, t);
ThreadUtils.showErrorDialog(EditorsRegistry.getInstance().getMainWindow(), "Fehler beim Speichern: " + t.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR);

}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6357,7 +6357,7 @@ public void drop(DropTargetDropEvent dtde) {
try {

List transferData = (List) transferable.getTransferData(DataFlavor.javaFileListFlavor);
if (transferData != null && transferData.size() > 0) {
if (transferData != null && !transferData.isEmpty()) {

ThreadUtils.setWaitCursor(p);

Expand Down

0 comments on commit fd03921

Please sign in to comment.