You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SIPRP/trunk/siprp/clientes/NoticiasDialog.java

102 lines
2.1 KiB

/*
* NoticiasPanel.java
*
* Created on 24 de Maio de 2005, 15:12
*/
package siprp.clientes;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.panel.*;
/**
*
* @author fpalma
*/
public class NoticiasDialog extends CustomJDialog
implements ActionListener
{
protected HTMLEditorPanel textText;
protected JButton okButton;
protected JButton cancelButton;
protected NoticiasDataProvider provider;
/** Creates a new instance of NoticiasPanel */
public NoticiasDialog( JFrame owner )
throws Exception
{
super( owner, true );
provider = (NoticiasDataProvider)NoticiasDataProvider.getProvider();
setupComponents();
if( owner != null )
{
centerSuper();
}
else
{
center();
}
textText.fill( provider.getNoticias() );
}
private void setupComponents()
{
setTitle( "Editar Texto das Not\u00edcias" );
setSize( 300, 200 );
textText = new HTMLEditorPanel( true );
// textText.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(),
// "Texto" ) );
okButton = new JButton( "OK" );
okButton.addActionListener( this );
cancelButton = new JButton( "Cancelar" );
cancelButton.addActionListener( this );
getContentPane().setLayout( new BorderLayout() );
getContentPane().add( textText, BorderLayout.CENTER );
JPanel buttonPanel = new JPanel();
getContentPane().add( buttonPanel, BorderLayout.SOUTH );
buttonPanel.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
buttonPanel.add( okButton );
buttonPanel.add( cancelButton );
}
public void actionPerformed( ActionEvent e )
{
Object source = e.getSource();
if( source.equals( okButton ) )
{
try
{
provider.saveNoticias( (String) textText.save() );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a gravar not\u00edcias", true );
return;
}
close();
}
else if( source.equals( cancelButton ) )
{
close();
}
}
public void close()
{
SwingUtilities.invokeLater( new Thread(){
public void run()
{
setVisible( false );
dispose();
}
} );
}
}