Skip to content

Commit

Permalink
showing case context or document context attached to a message
Browse files Browse the repository at this point in the history
navigating to a case from a message
navigating to a document from a message
tabbed representation in message center, if case context is available
issue #2018
  • Loading branch information
j-dimension committed Sep 25, 2023
1 parent b5eec8f commit cd5b3dc
Show file tree
Hide file tree
Showing 7 changed files with 459 additions and 299 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,33 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="calloutPanelComponent1" pref="229" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="calloutPanelComponent1" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="lblCaseContext" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="lblDocumentContext" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="154" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblUser" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="lblUser" alignment="1" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="calloutPanelComponent1" pref="17" max="32767" attributes="0"/>
<Component id="calloutPanelComponent1" pref="63" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblCaseContext" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblDocumentContext" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
</Group>
<Component id="lblUser" alignment="1" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
Expand All @@ -44,12 +57,12 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="229" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="17" max="32767" attributes="0"/>
<EmptySpace min="0" pref="63" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
Expand All @@ -59,5 +72,43 @@
<Property name="text" type="java.lang.String" value="jLabel1"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblCaseContext">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font component="lblCaseContext" property="font" relativeSize="true" size="-2"/>
</FontInfo>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="jLabel1"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Handcursor"/>
</Property>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCaseContextMouseClicked"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblDocumentContext">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font component="lblDocumentContext" property="font" relativeSize="true" size="-2"/>
</FontInfo>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="jLabel2"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Handcursor"/>
</Property>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblDocumentContextMouseClicked"/>
</Events>
</Component>
</SubComponents>
</Form>
Original file line number Diff line number Diff line change
Expand Up @@ -663,14 +663,31 @@ You should also get your employer (if you work as a programmer) or school,
*/
package com.jdimension.jlawyer.client.messenger;

import com.jdimension.jlawyer.client.configuration.PopulateOptionsEditor;
import com.jdimension.jlawyer.client.editors.EditorsRegistry;
import com.jdimension.jlawyer.client.editors.ThemeableEditor;
import com.jdimension.jlawyer.client.editors.files.ArchiveFilePanel;
import com.jdimension.jlawyer.client.editors.files.EditArchiveFileDetailsPanel;
import com.jdimension.jlawyer.client.editors.files.ViewArchiveFileDetailsPanel;
import com.jdimension.jlawyer.client.settings.ClientSettings;
import com.jdimension.jlawyer.client.settings.UserSettings;
import com.jdimension.jlawyer.client.utils.FileUtils;
import com.jdimension.jlawyer.client.utils.StringUtils;
import com.jdimension.jlawyer.persistence.AppUserBean;
import com.jdimension.jlawyer.persistence.ArchiveFileBean;
import com.jdimension.jlawyer.persistence.InstantMessage;
import com.jdimension.jlawyer.services.ArchiveFileServiceRemote;
import com.jdimension.jlawyer.services.JLawyerServiceLocator;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Image;
import java.util.List;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import org.apache.log4j.Logger;
import themes.colors.DefaultColorTheme;

/**
Expand All @@ -679,6 +696,11 @@ You should also get your employer (if you work as a programmer) or school,
*/
public class MessagePanel extends javax.swing.JPanel {

private static final Logger log=Logger.getLogger(MessagePanel.class.getName());

private ImageIcon caseIcon= new javax.swing.ImageIcon(getClass().getResource("/icons/folder.png"));
private InstantMessage im=null;

/**
* Creates new form MessagePanel
*/
Expand All @@ -691,6 +713,8 @@ public MessagePanel() {
public MessagePanel(List<AppUserBean> principals, String ownPrincipal, boolean ownMessage, InstantMessage im) {
initComponents();

this.im=im;

String sender=im.getSender();
if(StringUtils.isEmpty(sender))
sender="?";
Expand All @@ -717,6 +741,28 @@ public MessagePanel(List<AppUserBean> principals, String ownPrincipal, boolean o
this.calloutPanelComponent1.setOwnMessage(ownMessage);
this.calloutPanelComponent1.setPrincipals(principals);
this.calloutPanelComponent1.setOwnPrincipal(ownPrincipal);

if(im.getCaseContext()!=null) {
this.lblCaseContext.setText(im.getCaseContext().getFileNumber());
this.lblCaseContext.setToolTipText(im.getCaseContext().getFileNumber() + System.lineSeparator() + im.getCaseContext().getName() + System.lineSeparator() + im.getCaseContext().getReason());
this.lblCaseContext.setIcon(this.caseIcon);
} else {
this.lblCaseContext.setText("");
this.lblCaseContext.setToolTipText("");
this.lblCaseContext.setIcon(null);
}
if(im.getDocumentContext()!=null) {
this.lblDocumentContext.setText(im.getDocumentContext().getName());
FileUtils fu = FileUtils.getInstance();
Icon icon = fu.getFileTypeIcon(im.getDocumentContext().getName());
this.lblDocumentContext.setIcon(icon);
this.lblDocumentContext.setToolTipText(im.getDocumentContext().getName());
} else {
this.lblDocumentContext.setText("");
this.lblDocumentContext.setToolTipText("");
this.lblDocumentContext.setIcon(null);

}
}

public InstantMessage getMessage() {
Expand All @@ -731,12 +777,18 @@ public int getCalloutWidth() {

@Override
public Dimension getMaximumSize() {
return this.calloutPanelComponent1.getPreferredSize(); //To change body of generated methods, choose Tools | Templates.
//return this.calloutPanelComponent1.getPreferredSize(); //To change body of generated methods, choose Tools | Templates.
Dimension calloutPreferred= this.calloutPanelComponent1.getPreferredSize(); //To change body of generated methods, choose Tools | Templates.
calloutPreferred.setSize(calloutPreferred.getWidth(), calloutPreferred.getHeight() + 8 + 18 + this.lblCaseContext.getPreferredSize().getHeight());
return calloutPreferred;
}

@Override
public Dimension getPreferredSize() {
return this.calloutPanelComponent1.getPreferredSize(); //To change body of generated methods, choose Tools | Templates.
//return this.calloutPanelComponent1.getPreferredSize();
Dimension calloutPreferred= this.calloutPanelComponent1.getPreferredSize(); //To change body of generated methods, choose Tools | Templates.
calloutPreferred.setSize(calloutPreferred.getWidth(), calloutPreferred.getHeight() + 8 + 18 + this.lblCaseContext.getPreferredSize().getHeight());
return calloutPreferred;
}


Expand All @@ -752,45 +804,134 @@ private void initComponents() {

calloutPanelComponent1 = new com.jdimension.jlawyer.client.messenger.CalloutPanelComponent();
lblUser = new javax.swing.JLabel();
lblCaseContext = new javax.swing.JLabel();
lblDocumentContext = new javax.swing.JLabel();

setOpaque(false);

javax.swing.GroupLayout calloutPanelComponent1Layout = new javax.swing.GroupLayout(calloutPanelComponent1);
calloutPanelComponent1.setLayout(calloutPanelComponent1Layout);
calloutPanelComponent1Layout.setHorizontalGroup(
calloutPanelComponent1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 229, Short.MAX_VALUE)
.addGap(0, 0, Short.MAX_VALUE)
);
calloutPanelComponent1Layout.setVerticalGroup(
calloutPanelComponent1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 17, Short.MAX_VALUE)
.addGap(0, 63, Short.MAX_VALUE)
);

lblUser.setText("jLabel1");

lblCaseContext.setFont(lblCaseContext.getFont().deriveFont(lblCaseContext.getFont().getSize()-2f));
lblCaseContext.setForeground(new java.awt.Color(255, 255, 255));
lblCaseContext.setText("jLabel1");
lblCaseContext.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
lblCaseContext.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lblCaseContextMouseClicked(evt);
}
});

lblDocumentContext.setFont(lblDocumentContext.getFont().deriveFont(lblDocumentContext.getFont().getSize()-2f));
lblDocumentContext.setForeground(new java.awt.Color(255, 255, 255));
lblDocumentContext.setText("jLabel2");
lblDocumentContext.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
lblDocumentContext.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lblDocumentContextMouseClicked(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(calloutPanelComponent1, javax.swing.GroupLayout.DEFAULT_SIZE, 229, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(calloutPanelComponent1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(lblCaseContext)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lblDocumentContext)
.addGap(0, 154, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblUser))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblUser, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(calloutPanelComponent1, javax.swing.GroupLayout.DEFAULT_SIZE, 17, Short.MAX_VALUE)
.addContainerGap())
.addComponent(lblUser, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(calloutPanelComponent1, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblCaseContext)
.addComponent(lblDocumentContext))
.addGap(6, 6, 6))
);
}// </editor-fold>//GEN-END:initComponents

private void lblCaseContextMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCaseContextMouseClicked
this.contextClicked(false);
}//GEN-LAST:event_lblCaseContextMouseClicked

private void lblDocumentContextMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblDocumentContextMouseClicked
this.contextClicked(true);
}//GEN-LAST:event_lblDocumentContextMouseClicked

private void contextClicked(boolean toDocument) {
try {
Object editor = null;
if (UserSettings.getInstance().isCurrentUserInRole(UserSettings.ROLE_WRITECASE)) {
editor = EditorsRegistry.getInstance().getEditor(EditArchiveFileDetailsPanel.class.getName());
} else {
editor = EditorsRegistry.getInstance().getEditor(ViewArchiveFileDetailsPanel.class.getName());
}
Object desktop = EditorsRegistry.getInstance().getEditor(MessagingCenterPanel.class.getName());
Image bgi = ((MessagingCenterPanel) desktop).getBackgroundImage();

if (editor instanceof ThemeableEditor) {
// inherit the background to newly created child editors
((ThemeableEditor) editor).setBackgroundImage(bgi);
}

if (editor instanceof PopulateOptionsEditor) {
((PopulateOptionsEditor) editor).populateOptions();
}

ArchiveFileBean aFile = null;
try {
JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(ClientSettings.getInstance().getLookupProperties());
ArchiveFileServiceRemote fileService = locator.lookupArchiveFileServiceRemote();

aFile = fileService.getArchiveFile(this.im.getCaseContext().getId());
} catch (Exception ex) {
log.error("Error loading archive file from server", ex);
JOptionPane.showMessageDialog(this, java.text.MessageFormat.format(java.util.ResourceBundle.getBundle("com/jdimension/jlawyer/client/desktop/TaggedEntryPanel").getString("error.loadingcase"), new Object[]{ex.getMessage()}), java.util.ResourceBundle.getBundle("com/jdimension/jlawyer/client/desktop/TaggedEntryPanel").getString("dialog.error"), JOptionPane.ERROR_MESSAGE);
}

if (aFile == null) {
return;
}

if (this.lblDocumentContext.getText() != null && !"".equals(this.lblDocumentContext.getText()) && toDocument) {
((ArchiveFilePanel) editor).setArchiveFileDTO(aFile, this.lblDocumentContext.getText());
} else {
((ArchiveFilePanel) editor).setArchiveFileDTO(aFile);
}
((ArchiveFilePanel) editor).setOpenedFromEditorClass(MessagingCenterPanel.class.getName());
EditorsRegistry.getInstance().setMainEditorsPaneView((Component) editor);
} catch (Exception ex) {
log.error("Error creating editor from class " + this.getClass().getName(), ex);
JOptionPane.showMessageDialog(this, java.text.MessageFormat.format(java.util.ResourceBundle.getBundle("com/jdimension/jlawyer/client/desktop/TaggedEntryPanel").getString("error.loadingeditor"), new Object[]{ex.getMessage()}), java.util.ResourceBundle.getBundle("com/jdimension/jlawyer/client/desktop/TaggedEntryPanel").getString("dialog.error"), JOptionPane.ERROR_MESSAGE);
}
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private com.jdimension.jlawyer.client.messenger.CalloutPanelComponent calloutPanelComponent1;
private javax.swing.JLabel lblCaseContext;
private javax.swing.JLabel lblDocumentContext;
private javax.swing.JLabel lblUser;
// End of variables declaration//GEN-END:variables
}
Original file line number Diff line number Diff line change
Expand Up @@ -712,10 +712,8 @@ public void run() {
if(!newMessages.isEmpty()) {
this.lastMessageTimestamp=newMessages.get(newMessages.size()-1).getSent().getTime();
}
for(InstantMessage newMsg: newMessages) {
EventBroker eb = EventBroker.getInstance();
eb.publishEvent(new NewInstantMessagesEvent(newMessages));
}
EventBroker eb = EventBroker.getInstance();
eb.publishEvent(new NewInstantMessagesEvent(newMessages));
}

} catch (Throwable ex) {
Expand Down
Loading

0 comments on commit cd5b3dc

Please sign in to comment.