git-svn-id: https://svn.coded.pt/svn/SIPRP@599 bb69d46d-e84e-40c8-a05a-06db0d633741

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Frederico Palma 18 years ago
parent 187bceb34c
commit d2af71acb9

@ -0,0 +1,94 @@
package siprp.medicina.processo.mail;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.colorchooser.AbstractColorChooserPanel;
import com.evolute.utils.ui.CustomJDialog;
public class ColorChooserDialog extends CustomJDialog
implements ActionListener
{
/**
*
*/
private static final long serialVersionUID = 1L;
protected JColorChooser colorChooser;
protected JButton okButton;
protected JButton cancelButton;
protected Color initialColor;
protected Color selectedColor;
public ColorChooserDialog( JFrame owner, Color color )
{
super( owner, true );
initialColor = color;
setupComponents();
}
private void setupComponents()
{
setTitle( "Escolha a cor" );
colorChooser = new JColorChooser( initialColor );
colorChooser.setChooserPanels( new AbstractColorChooserPanel[]{ colorChooser.getChooserPanels()[ 0 ] } );
colorChooser.setPreviewPanel( new JPanel() );
okButton = new JButton( "OK" );
cancelButton = new JButton( "Cancelar" );
setLayout( new BorderLayout() );
add( colorChooser, BorderLayout.CENTER );
JPanel buttonPanel = new JPanel();
add( buttonPanel, BorderLayout.SOUTH );
buttonPanel.setLayout( new FlowLayout( FlowLayout.CENTER ) );
buttonPanel.add( okButton );
buttonPanel.add( cancelButton );
okButton.addActionListener( this );
cancelButton.addActionListener( this );
pack();
}
@Override
public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();
if( source.equals( okButton ) )
{
selectedColor = colorChooser.getColor();
close();
}
else
{
close();
}
}
public void close()
{
SwingUtilities.invokeLater( new Runnable(){
public void run()
{
setVisible( false );
dispose();
}
} );
}
public Color getColor()
{
return selectedColor;
}
}

@ -1,21 +1,32 @@
package siprp.medicina.processo.mail;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Vector;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.text.AttributeSet;
import javax.swing.text.DefaultEditorKit;
@ -24,12 +35,19 @@ import javax.swing.text.StyledEditorKit;
import javax.swing.text.html.HTMLEditorKit;
import com.evolute.utils.images.ImageIconLoader;
import com.evolute.utils.tables.BaseTable;
import com.evolute.utils.tables.VectorTableModel;
public class MailPanel extends JPanel
{
protected StyledEditorKit.FontSizeAction FONT_SIZE_ACTIONS[];
protected int FONT_SIZES[];
protected JTextField toText;
protected JTextField bccText;
protected JTextField subjectText;
protected BaseTable attachmentsTable;
protected VectorTableModel attachmentsModel;
protected JTextPane bodyPane;
public static void main( String args[] )
@ -56,6 +74,96 @@ public class MailPanel extends JPanel
private void setupComponents()
throws Exception
{
setLayout( new BorderLayout() );
JPanel headerPanel = new JPanel();
setupHeaderComponents( headerPanel );
add( headerPanel, BorderLayout.NORTH );
JPanel htmlPanel = new JPanel();
setupHTMLComponents( htmlPanel );
add( htmlPanel, BorderLayout.CENTER );
}
private void setupHeaderComponents( JPanel headerPanel )
throws Exception
{
Action sendAction = new AbstractAction( "send" ){
/**
*
*/
private static final long serialVersionUID = 1L;
public void actionPerformed( ActionEvent e )
{
}
};
JButton sendButton = createButton( sendAction, "siprp/medicina/processo/mail/icons/mail2.png" );
Action attachAction = new AbstractAction( "attach" ){
/**
*
*/
private static final long serialVersionUID = 1L;
public void actionPerformed( ActionEvent e )
{
}
};
JButton attachButton = createButton( attachAction, "siprp/medicina/processo/mail/icons/mail_attachment.png" );
Action removeAttachmentAction = new AbstractAction( "remove-attachment" ){
/**
*
*/
private static final long serialVersionUID = 1L;
public void actionPerformed( ActionEvent e )
{
}
};
JButton removeAttachmentButton = createButton( removeAttachmentAction, "siprp/medicina/processo/mail/icons/delete2.png" );
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout( new FlowLayout( FlowLayout.LEFT ) );
buttonPanel.add( sendButton );
buttonPanel.add( attachButton );
buttonPanel.add( removeAttachmentButton );
JLabel toLabel = new JLabel( "Para:" );
toText = new JTextField();
toText.setEditable( false );
JLabel bccLabel = new JLabel( "C\u00f3pia:" );
bccText = new JTextField();
bccText.setEditable( false );
JLabel assuntoLabel = new JLabel( "Assunto:" );
subjectText = new JTextField();
attachmentsModel = new VectorTableModel( new String[]{ "" } );
attachmentsTable = new BaseTable( attachmentsModel );
JScrollPane attachmentsScroll = new JScrollPane( attachmentsTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
TableLayout layout =
new TableLayout(
new double[]{ TableLayoutConstraints.MINIMUM, TableLayoutConstraints.FILL, TableLayoutConstraints.FILL },
new double[]{ TableLayoutConstraints.PREFERRED, TableLayoutConstraints.MINIMUM, TableLayoutConstraints.MINIMUM,
TableLayoutConstraints.MINIMUM } );
layout.setHGap( 2 );
layout.setVGap( 2 );
headerPanel.setLayout( layout );
headerPanel.add( buttonPanel, new TableLayoutConstraints( 0, 0, 2, 0 ) );
headerPanel.add( toLabel, new TableLayoutConstraints( 0, 1 ) );
headerPanel.add( toText, new TableLayoutConstraints( 1, 1 ) );
headerPanel.add( attachmentsScroll, new TableLayoutConstraints( 2, 1, 2, 3 ) );
headerPanel.add( bccLabel, new TableLayoutConstraints( 0, 2 ) );
headerPanel.add( bccText, new TableLayoutConstraints( 1, 2 ) );
headerPanel.add( assuntoLabel, new TableLayoutConstraints( 0, 3 ) );
headerPanel.add( subjectText, new TableLayoutConstraints( 1, 3 ) );
}
private void setupHTMLComponents( JPanel htmlPanel )
throws Exception
{
HTMLEditorKit kit = new HTMLEditorKit();
Action actions[] = kit.getActions();
@ -73,6 +181,10 @@ public class MailPanel extends JPanel
}
fontSizeActions.add( ( StyledEditorKit.FontSizeAction ) actions[ n ] );
}
else if( str.toLowerCase().indexOf( "font" ) != -1 )
{
System.out.println( str );
}
}
FONT_SIZE_ACTIONS = fontSizeActions.toArray( new StyledEditorKit.FontSizeAction[ fontSizeActions.size() ] );
@ -111,7 +223,7 @@ public class MailPanel extends JPanel
public void actionPerformed( ActionEvent e )
{
bodyPane.requestFocusInWindow();
int start = bodyPane.getSelectionStart();
AttributeSet set = bodyPane.getStyledDocument().getCharacterElement( start ).getAttributes();
int size = StyleConstants.getFontSize( set );
@ -123,6 +235,7 @@ public class MailPanel extends JPanel
break;
}
}
bodyPane.requestFocusInWindow();
}
};
Action fontSmallerAction =
@ -134,7 +247,7 @@ public class MailPanel extends JPanel
public void actionPerformed( ActionEvent e )
{
bodyPane.requestFocusInWindow();
int start = bodyPane.getSelectionStart();
AttributeSet set = bodyPane.getStyledDocument().getCharacterElement( start ).getAttributes();
int size = StyleConstants.getFontSize( set );
@ -146,8 +259,51 @@ public class MailPanel extends JPanel
break;
}
}
bodyPane.requestFocusInWindow();
}
};
};
Action colorAction =
new StyledEditorKit.ForegroundAction( "color", Color.black ){
/**
*
*/
private static final long serialVersionUID = 1L;
public void actionPerformed( ActionEvent e )
{
ColorChooserDialog dialog = new ColorChooserDialog( null, Color.black );
dialog.setVisible( true );
Color color = dialog.getColor();
if( color != null )
{
bodyPane.requestFocusInWindow();
Action colorTempAction = new StyledEditorKit.ForegroundAction( "color-temp", color );
bodyPane.getActionMap().put( "color-temp", colorTempAction );
colorTempAction.actionPerformed( e );
}
bodyPane.requestFocusInWindow();
}
};
String fontFamilies[] = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
JComboBox fontCombo = new JComboBox();
for( int n = 0; n < fontFamilies.length; n++ )
{
fontCombo.addItem( fontFamilies[ n ] );
}
fontCombo.addItemListener( new ItemListener(){
@Override
public void itemStateChanged(ItemEvent e)
{
String selected = ( String ) e.getItem();
Action fontFamilyAction =
new StyledEditorKit.FontFamilyAction( "font-family-action" , selected );
bodyPane.getActionMap().put( "font-family-action", fontFamilyAction );
fontFamilyAction.actionPerformed(
new ActionEvent( e.getSource(), e.getID(), "" ) );
bodyPane.requestFocusInWindow();
}
} );
Action alignLeftAction = actionMap.get( "left-justify" );
Action alignCenterAction = actionMap.get( "center-justify" );
@ -171,20 +327,25 @@ public class MailPanel extends JPanel
upperPanel.add( createButton( cutAction, "siprp/medicina/processo/mail/icons/cut.png" ) );
upperPanel.add( createButton( copyAction, "siprp/medicina/processo/mail/icons/copy.png" ) );
upperPanel.add( createButton( pasteAction, "siprp/medicina/processo/mail/icons/paste.png" ) );
upperPanel.add( new JLabel( " " ) );
upperPanel.add( createButton( boldAction, "siprp/medicina/processo/mail/icons/text_bold.png" ) );
upperPanel.add( createButton( italicAction, "siprp/medicina/processo/mail/icons/text_italics.png" ) );
upperPanel.add( createButton( underlineAction, "siprp/medicina/processo/mail/icons/text_underlined.png" ) );
upperPanel.add( createButton( fontBiggerAction, "siprp/medicina/processo/mail/icons/font_bigger.png" ) );
upperPanel.add( createButton( fontSmallerAction, "siprp/medicina/processo/mail/icons/font_smaller.png" ) );
upperPanel.add( createButton( colorAction, "siprp/medicina/processo/mail/icons/colorwheel.png" ) );
upperPanel.add( fontCombo );
upperPanel.add( new JLabel( " " ) );
upperPanel.add( createButton( alignLeftAction, "siprp/medicina/processo/mail/icons/text_align_left.png" ) );
upperPanel.add( createButton( alignCenterAction, "siprp/medicina/processo/mail/icons/text_align_center.png" ) );
upperPanel.add( createButton( alignRightAction, "siprp/medicina/processo/mail/icons/text_align_right.png" ) );
upperPanel.add( createButton( alignJustifyAction, "siprp/medicina/processo/mail/icons/text_align_justified.png" ) );
setLayout( new BorderLayout() );
htmlPanel.setLayout( new BorderLayout() );
add( upperPanel, BorderLayout.NORTH );
add( bodyPane, BorderLayout.CENTER );
htmlPanel.add( upperPanel, BorderLayout.NORTH );
htmlPanel.add( new JScrollPane( bodyPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ), BorderLayout.CENTER );
}
private JButton createButton( Action action, String iconPath )

Binary file not shown.

Before

Width:  |  Height:  |  Size: 614 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 627 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 791 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 828 B

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 849 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 860 B

Loading…
Cancel
Save