package com.realobjects.customdialog.insertlink; import java.awt.*; import java.awt.event.*; import java.util.Hashtable; import javax.swing.AbstractAction; // This package must be included, edit-on-pro4.jar must be in the class path build the custom class import com.realobjects.eop.japplet.SwingEditorApplet; // This package is imported in order to be able to use centerOnComponent import com.realobjects.eop.bean.custom.CustomDialogUtil; // Sample custom class implementation public class InsertLinkDialog extends AbstractAction { // This method will be called when the "LINK" action is fired public void actionPerformed(ActionEvent arg0) { Object keys[] = getKeys(); System.out.println("custom action, keys: "); for(int i = 0; i < keys.length; i++) { System.out.print("Key #" + (i + 1) + ": " + keys[i] + ", value: "); System.out.println(getValue(keys[i].toString())); } Hashtable h = (Hashtable)getValue("EOPDATA"); Frame f = (Frame)getValue("frame"); System.out.println("custom action, EOPDATA: " +h); SwingEditorApplet applet = (SwingEditorApplet)getValue("apiobject"); Hashtable t = (Hashtable)h.get("attributes"); System.out.println("Attributes Hashtable:" + t); System.out.println("Attributes Hashtable put to edit-on Pro: " + t); applet = (SwingEditorApplet)getValue("apiobject"); LinkDlg dlg = new LinkDlg(f, "Custom Insert Hyperlink Dialog", true); dlg.setVisible(true); if(dlg.retVal) { putValue("cancelaction",Boolean.FALSE); t.put("href", dlg.list.getSelectedItem()); } else { putValue("cancelaction",Boolean.TRUE); } } protected class LinkDlg extends Dialog implements ActionListener { public LinkDlg(Frame frame, String title, boolean modal) { super(frame, title, modal); setLayout( new BorderLayout() ); list = new List(); list.add( "http://www.yahoo.com" ); list.add( "http://www.google.com" ); list.add( "http://www.altavista.com" ); list.add( "http://www.infoseek.com" ); list.add( "http://www.msn.com" ); add( list, BorderLayout.CENTER ); Panel panel = new Panel( new FlowLayout( FlowLayout.CENTER ) ); Button btn = new Button( "Ok" ); btn.addActionListener( this ); panel.add( btn ); btn = new Button( "Cancel" ); btn.addActionListener( this ); panel.add( btn ); add( panel, BorderLayout.SOUTH ); setSize( 400, 200 ); // Centers the dialog on the editor CustomDialogUtil.centerOnComponent(frame,this); } public void actionPerformed( ActionEvent e ) { if (e.getActionCommand().equalsIgnoreCase("Ok")) { retVal = true; dispose(); } else { dispose(); } } protected List list = null; protected boolean retVal = false; } }