Package ClipboardSample

Source Code of ClipboardSample.ClipboardWindow

package ClipboardSample;

import DisplayProject.ClipboardUtils;
import DisplayProject.CloseHideAdaptor;
import DisplayProject.Constants;
import DisplayProject.CursorMgr;
import DisplayProject.LayoutManagerHelper;
import DisplayProject.UDSWindow;
import DisplayProject.UIutils;
import DisplayProject.WindowManager;
import DisplayProject.WindowSystem;
import DisplayProject.WindowUsageMap;
import DisplayProject.actions.AppletConnectionInfo;
import DisplayProject.actions.HeightPolicy;
import DisplayProject.actions.PictureButtonImageValue;
import DisplayProject.actions.UserWindow;
import DisplayProject.actions.WidgetState;
import DisplayProject.actions.WidthPolicy;
import DisplayProject.binding.BindingManager;
import DisplayProject.binding.beans.ExtendedPropertyChangeSupport;
import DisplayProject.binding.beans.Observable;
import DisplayProject.controls.MultiLineTextField;
import DisplayProject.events.ClientEventManager;
import DisplayProject.factory.CompoundFieldFactory;
import DisplayProject.factory.PushButtonFactory;
import DisplayProject.factory.TextEditFactory;
import DisplayProject.plaf.Win32LookAndFeel;
import Framework.ErrorMgr;
import Framework.EventHandle;
import Framework.EventManager;
import Framework.EventRegistration;
import Framework.File;
import Framework.ForteKeyboardFocusManager;
import Framework.FrameworkUtils;
import Framework.ImageData;
import Framework.ParameterHolder;
import Framework.RuntimeProperties;
import Framework.TextData;
import Framework.UsageException;
import java.awt.Dimension;
import java.awt.KeyboardFocusManager;
import java.awt.Window;
import java.awt.event.ComponentListener;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.lang.Object;
import java.lang.String;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.UIManager;
import org.apache.log4j.Logger;

/**
* ClipboardWindow<p>
* <p>
* @author Generated from Forte
* @since  19-Nov-2008
*/
@RuntimeProperties(isDistributed=false, isAnchored=false, isShared=false, isTransactional=false)
@UDSWindow()
@SuppressWarnings("serial")
public class ClipboardWindow
        extends JFrame
        implements Serializable, Observable
{

    // ----------
    // Attributes
    // ----------
    protected File DefaultHelpFile;
    protected BindingManager bindingManager = null;
    public PropertyChangeSupport qq_Listeners = new ExtendedPropertyChangeSupport(this, true);
    private TextData text_field;

    // ------------
    // Constructors
    // ------------
    public ClipboardWindow() {
        // Explicitly call the superclass constructor to prevent the implicit call
        super();
        this.initialize();
        this.setText_field(new TextData());
        this.getText_field().setValue( "Starting value." );

    }

    // ----------------------
    // Accessors and Mutators
    // ----------------------
    public File getDefaultHelpFile() {
        return DefaultHelpFile;
    }

    public void setDefaultHelpFile(File defaultHelpFile) {
        DefaultHelpFile = defaultHelpFile;
        UserWindow.createHelp(this, defaultHelpFile);
    }

    public void setHelpURL(String urlString) {
        try {
            URL url = new URL(urlString);
            UserWindow.createHelp(this, url);
        } catch (MalformedURLException e) {
            UsageException err = new UsageException("Cannot create help URL", e);
            ErrorMgr.addError(err);
            throw err;
        }
    }

    protected BindingManager getBindingManager() {
        if (this.bindingManager == null) {
            this.bindingManager = new BindingManager(this);
        }
        return bindingManager;
    }

    public void setText_field(TextData text_field) {
        TextData oldValue = this.text_field;
        this.text_field = text_field;
        this.qq_Listeners.firePropertyChange("text_field", oldValue, this.text_field);
    }

    public TextData getText_field() {
        return this.text_field;
    }

    // -------
    // Methods
    // -------
    public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
        qq_Listeners.addPropertyChangeListener(property, listener);
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        qq_Listeners.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(String property, PropertyChangeListener listener) {
        qq_Listeners.removePropertyChangeListener(property, listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        qq_Listeners.removePropertyChangeListener(listener);
    }

    /**
     * display<p>
     * This sample application demonstrates the use of Forte<br>
     * with the system clipboard.  It shows an image_field<br>
     * (PictureButton) with an image, and a text_field<br>
     * (TextField) which contains some initial data.<br>
     * <p>
     * The system displays buttons allowing the image or text<br>
     * to be moved to the system clipboard.  It also contains<br>
     * a button that will allow to move whatever is in the<br>
     * system clipboard to the window.  If text is in the<br>
     * clipboard, it will be moved to text_field.  If an image<br>
     * is in the clipboard, it is moved to the image_field.<br>
     * If neither is there, an error is displayed.<br>
     * <p>
     */
    public void display() {
        UserWindow.open(this);

        // First, see if anything is in the clipboard, and set
        // the button appropriately.
        boolean d_in_clipboard = false;
        switch (ClipboardUtils.getClipboardDataType()) {
            case Constants.SD_TEXT: {
                d_in_clipboard = true;
                break;
            }
            case Constants.SD_IMAGE: {
                d_in_clipboard = true;
                break;
            }

            default: {
                d_in_clipboard = false;
                break;
            }
        }
        if (d_in_clipboard) {
            WidgetState.set(this.getqq_clipboard_to_window(), Constants.FS_UPDATE);
        }
        else {
            WidgetState.set(this.getqq_clipboard_to_window(), Constants.FS_DISABLED);
        }

        // Standard shutdown.
        // ----------
        // Event Loop
        // ----------
        EventManager.startEventLoop();
        try {
            EventRegistration TaskHandle_Shutdown_langThreadcurrentThread = ClientEventManager.register( Thread.currentThread(), "Shutdown" );
            EventRegistration windowSystem_AfterClipboardChange = ClientEventManager.register( WindowSystem.class, "AfterClipboardChange" );
            EventRegistration PushButton_Click_getqq_clipboard_to_window = ClientEventManager.register( this.getqq_clipboard_to_window(), "Click" );
            EventRegistration PushButton_Click_getqq_image_to_clipboard = ClientEventManager.register( this.getqq_image_to_clipboard(), "Click" );
            EventRegistration PushButton_Click_getqq_text_to_clipboard = ClientEventManager.register( this.getqq_text_to_clipboard(), "Click" );
            EventRegistration windowSystem_TextMenuStatusChange = ClientEventManager.register( WindowSystem.class, "TextMenuStatusChange" );

            while (true) {

                UIutils.processGUIActions();
                EventHandle qq_currentEvent = EventManager.waitForEvent();
                if (qq_currentEvent == null)
                    break;

                // -------------
                // task.Shutdown
                // -------------
                if (qq_currentEvent.isEvent(TaskHandle_Shutdown_langThreadcurrentThread)) {
                    try {
                        CursorMgr.startEvent();
                        // ================ Begin Forte Event Handler Translation ================
                        break;

                        // When clipboard data changes.
                        // ================ End Forte Event Handler Translation ================
                    }
                    finally {
                        CursorMgr.endEvent();
                    }
                }

                // ---------------------------------------------
                // self.Window.WindowSystem.AfterClipboardChange
                // ---------------------------------------------
                else if (qq_currentEvent.isEvent(windowSystem_AfterClipboardChange)) {
                    try {
                        CursorMgr.startEvent();
                        // ================ Begin Forte Event Handler Translation ================
                        // First, see if anything is in the clipboard, and
                        // set the button appropriately.
                        boolean d_in_clipboard1 = false;
                        switch (ClipboardUtils.getClipboardDataType()) {

                            case Constants.SD_TEXT: {
                                d_in_clipboard1 = true;
                                break;
                            }
                            case Constants.SD_IMAGE: {
                                d_in_clipboard1 = true;
                                break;
                            }

                            default: {
                                d_in_clipboard1 = false;
                                break;
                            }
                        }
                        if (d_in_clipboard1) {
                            WidgetState.set(this.getqq_clipboard_to_window(), Constants.FS_UPDATE);
                        }
                        else {
                            WidgetState.set(this.getqq_clipboard_to_window(), Constants.FS_DISABLED);
                        }

                        // ================ End Forte Event Handler Translation ================
                    }
                    finally {
                        CursorMgr.endEvent();
                    }
                }

                // ---------------------------
                // <clipboard_to_window>.Click
                // ---------------------------
                else if (qq_currentEvent.isEvent(PushButton_Click_getqq_clipboard_to_window)) {
                    try {
                        CursorMgr.startEvent();
                        // ================ Begin Forte Event Handler Translation ================
                        // Copy the appropriate type of data.
                        switch (ClipboardUtils.getClipboardDataType()) {
                            case Constants.SD_TEXT: {
                                // Data is text.  Move to text_field.
                                Object o = null;
                                // to hold clipboard object
                                o = ClipboardUtils.copyFromClipboard(Constants.SD_TEXT);
                                // Since it is a generic object, cast it.
                                this.getText_field().setValue( (TextData)o );

                                break;
                            }
                            case Constants.SD_IMAGE: {
                                // Data is image.  Move to image_field.
                                Object o = null;
                                // to hold clipboard object
                                o = ClipboardUtils.copyFromClipboard(Constants.SD_IMAGE);
                                // Since it is a generic object, cast it.
                                PictureButtonImageValue.set(this.getqq_image_field(), ((ImageData)o));
                                break;
                            }
                        }

                        // Copy this image_field data to the clipboard.
                        // ================ End Forte Event Handler Translation ================
                    }
                    finally {
                        CursorMgr.endEvent();
                    }
                }

                // --------------------------
                // <image_to_clipboard>.Click
                // --------------------------
                else if (qq_currentEvent.isEvent(PushButton_Click_getqq_image_to_clipboard)) {
                    try {
                        CursorMgr.startEvent();
                        // ================ Begin Forte Event Handler Translation ================
                        ClipboardUtils.copyToClipboard(PictureButtonImageValue.get(this.getqq_image_field()));

                        // Copy this text to the clipboard.
                        // ================ End Forte Event Handler Translation ================
                    }
                    finally {
                        CursorMgr.endEvent();
                    }
                }

                // -------------------------
                // <text_to_clipboard>.Click
                // -------------------------
                else if (qq_currentEvent.isEvent(PushButton_Click_getqq_text_to_clipboard)) {
                    try {
                        CursorMgr.startEvent();
                        // ================ Begin Forte Event Handler Translation ================
                        ClipboardUtils.copyToClipboard(this.getText_field());

                        // ================ End Forte Event Handler Translation ================
                    }
                    finally {
                        CursorMgr.endEvent();
                    }
                }

                // ---------------------------
                // Window.TextMenuStatusChange
                // ---------------------------
                else if (qq_currentEvent.isEvent(windowSystem_TextMenuStatusChange)) {
                    try {
                        CursorMgr.startEvent();
                        // ================ Begin Forte Event Handler Translation ================
                        int cutState = ((ParameterHolder)qq_currentEvent.getParameter("CutState")).getInt();
                        int copyState = ((ParameterHolder)qq_currentEvent.getParameter("CopyState")).getInt();
                        int pasteState = ((ParameterHolder)qq_currentEvent.getParameter("PasteState")).getInt();
                        int deleteState = ((ParameterHolder)qq_currentEvent.getParameter("DeleteState")).getInt();
                        int selectAllState = ((ParameterHolder)qq_currentEvent.getParameter("SelectAllState")).getInt();
                        int undoState = ((ParameterHolder)qq_currentEvent.getParameter("UndoState")).getInt();
                        int redoState = ((ParameterHolder)qq_currentEvent.getParameter("RedoState")).getInt();
                        Logger.getLogger("task.part.logmgr").info(">>>>>>>");
                        Logger.getLogger("task.part.logmgr").info( Integer.toString(cutState));
                        Logger.getLogger("task.part.logmgr").info( Integer.toString(copyState));
                        Logger.getLogger("task.part.logmgr").info( Integer.toString(pasteState));
                        Logger.getLogger("task.part.logmgr").info( Integer.toString(deleteState));
                        Logger.getLogger("task.part.logmgr").info( Integer.toString(selectAllState));
                        Logger.getLogger("task.part.logmgr").info( Integer.toString(undoState));
                        Logger.getLogger("task.part.logmgr").info( Integer.toString(redoState));

                        // ================ End Forte Event Handler Translation ================
                    }
                    finally {
                        CursorMgr.endEvent();
                    }
                }
            }
            EventManager.deregister( TaskHandle_Shutdown_langThreadcurrentThread );
            EventManager.deregister( windowSystem_AfterClipboardChange );
            EventManager.deregister( PushButton_Click_getqq_clipboard_to_window );
            EventManager.deregister( PushButton_Click_getqq_image_to_clipboard );
            EventManager.deregister( PushButton_Click_getqq_text_to_clipboard );
            EventManager.deregister( windowSystem_TextMenuStatusChange );
        }
        //catch (Exception qq_error) {
            //Logger.getLogger("task.part.Event").error("Event loop terminated by unhandled exception: " + qq_error.getMessage(), qq_error );
            //throw qq_error;
        //}
        finally {
            EventManager.endEventLoop();
            UserWindow.close(this);
        }
    }

    // ------------------
    // Window Definitions
    // ------------------
    // <editor-fold defaultstate="collapsed" desc="Window Definitions">
    private int qq_defaultSet = 1;
    private int qq_msgNumber = 0;
    private int qq_msgSet = 0;
    protected Window primaryWindow = null;
    protected int initialX;
    protected int initialY;
    protected int qq_SystemClosePolicy = Constants.SC_ENABLEDSHUTDOWN;
    protected int qq_initialPositionPolicy = Constants.PP_SYSTEMDEFAULT;
    public JButton qq_clipboard_to_window;
    public JButton qq_image_field;
    public JButton qq_image_to_clipboard;
    public JButton qq_text_to_clipboard;
    public JPanel Form;
    public JScrollPane qq_text_field_sp;
    public MultiLineTextField qq_text_field;

    /**
     * qq_text_field_sp: transformed from: qqds_TextField
     * TagId=12
     * isInherited=FALSE
     */
    public JScrollPane getqq_text_field_sp() {
        if (qq_text_field_sp == null) {
            qq_text_field_sp = CompoundFieldFactory.newScrollPane();
            qq_text_field_sp.setName("text_field");
            qq_text_field_sp.setViewportView(getqq_text_field());
            qq_text_field_sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            qq_text_field_sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            WidthPolicy.set(qq_text_field_sp, Constants.SP_EXPLICIT);
            HeightPolicy.set(qq_text_field_sp, Constants.SP_EXPLICIT);
            qq_text_field_sp.setSize(new Dimension(443, 91));
            qq_text_field_sp.setMinimumSize(new Dimension(443, 91));
            qq_text_field_sp.setPreferredSize(new Dimension(443, 91));
            qq_text_field_sp.setLocation(0, 163);
        }
        return qq_text_field_sp;
    }

    public void setqq_text_field_sp(JScrollPane value) {
        JScrollPane oldValue = qq_text_field_sp;
        qq_text_field_sp = value;
        this.qq_Listeners.firePropertyChange("qq_text_field_sp", oldValue, value);
    }

    /**
     * qq_text_field: transformed from: qqds_TextField
     * TagId=12
     * isInherited=FALSE
     */
    public MultiLineTextField getqq_text_field() {
        if (qq_text_field == null) {
            qq_text_field = TextEditFactory.newTextField("text_field", 3, 41);
            getBindingManager().bindComponent(qq_text_field, "text_field");
            WidthPolicy.set(qq_text_field, Constants.SP_EXPLICIT);
            HeightPolicy.set(qq_text_field, Constants.SP_EXPLICIT);
            qq_text_field.setLocation(0, 163);
        }
        return qq_text_field;
    }

    public void setqq_text_field(MultiLineTextField value) {
        MultiLineTextField oldValue = qq_text_field;
        qq_text_field = value;
        this.qq_Listeners.firePropertyChange("qq_text_field", oldValue, value);
    }

    /**
     * qq_image_field: transformed from: qqds_PictureButton
     * TagId=13
     * isInherited=FALSE
     */
    public JButton getqq_image_field() {
        if (qq_image_field == null) {
            qq_image_field = PushButtonFactory.newInstance("image_field");
            qq_image_field.setIcon(new ImageIcon(ClipboardWindow.class.getResource("ClipboardWindow.qq_image_field.png")));
            qq_image_field.setVerifyInputWhenFocusTarget(true);
            WidthPolicy.set(qq_image_field, Constants.SP_NATURAL);
            HeightPolicy.set(qq_image_field, Constants.SP_NATURAL);
            qq_image_field.setSize(new Dimension(88, 57));
            qq_image_field.setMinimumSize(new Dimension(88, 57));
            qq_image_field.setPreferredSize(new Dimension(88, 57));
            qq_image_field.setLocation(7, 4);
        }
        return qq_image_field;
    }

    public void setqq_image_field(JButton value) {
        JButton oldValue = qq_image_field;
        qq_image_field = value;
        this.qq_Listeners.firePropertyChange("qq_image_field", oldValue, value);
    }

    /**
     * qq_image_to_clipboard: transformed from: qqds_PushButton
     * TagId=14
     * isInherited=FALSE
     */
    public JButton getqq_image_to_clipboard() {
        if (qq_image_to_clipboard == null) {
            qq_image_to_clipboard = PushButtonFactory.newInstance("image_to_clipboard", "Move Image");
            qq_image_to_clipboard.setVerifyInputWhenFocusTarget(true);
            WidthPolicy.set(qq_image_to_clipboard, Constants.SP_TO_PARTNER);
            HeightPolicy.set(qq_image_to_clipboard, Constants.SP_TO_PARTNER);
            LayoutManagerHelper.setHeightPartner(qq_image_to_clipboard, getqq_text_to_clipboard());
            LayoutManagerHelper.setWidthPartner(qq_image_to_clipboard, getqq_clipboard_to_window());
            qq_image_to_clipboard.setMinimumSize(new Dimension(0, 0));
            qq_image_to_clipboard.setLocation(240, 14);
        }
        return qq_image_to_clipboard;
    }

    public void setqq_image_to_clipboard(JButton value) {
        JButton oldValue = qq_image_to_clipboard;
        qq_image_to_clipboard = value;
        this.qq_Listeners.firePropertyChange("qq_image_to_clipboard", oldValue, value);
    }

    /**
     * qq_text_to_clipboard: transformed from: qqds_PushButton
     * TagId=15
     * isInherited=FALSE
     */
    public JButton getqq_text_to_clipboard() {
        if (qq_text_to_clipboard == null) {
            qq_text_to_clipboard = PushButtonFactory.newInstance("text_to_clipboard", "Move Text");
            qq_text_to_clipboard.setVerifyInputWhenFocusTarget(true);
            WidthPolicy.set(qq_text_to_clipboard, Constants.SP_TO_PARTNER);
            HeightPolicy.set(qq_text_to_clipboard, Constants.SP_TO_PARTNER);
            LayoutManagerHelper.setHeightPartner(qq_text_to_clipboard, getqq_clipboard_to_window());
            LayoutManagerHelper.setWidthPartner(qq_text_to_clipboard, getqq_image_to_clipboard());
            qq_text_to_clipboard.setMinimumSize(new Dimension(0, 0));
            qq_text_to_clipboard.setLocation(242, 67);
        }
        return qq_text_to_clipboard;
    }

    public void setqq_text_to_clipboard(JButton value) {
        JButton oldValue = qq_text_to_clipboard;
        qq_text_to_clipboard = value;
        this.qq_Listeners.firePropertyChange("qq_text_to_clipboard", oldValue, value);
    }

    /**
     * qq_clipboard_to_window: transformed from: qqds_PushButton
     * TagId=16
     * isInherited=FALSE
     */
    public JButton getqq_clipboard_to_window() {
        if (qq_clipboard_to_window == null) {
            qq_clipboard_to_window = PushButtonFactory.newInstance("clipboard_to_window", "Copy From Clipboard");
            qq_clipboard_to_window.setVerifyInputWhenFocusTarget(true);
            WidthPolicy.set(qq_clipboard_to_window, Constants.SP_TO_PARTNER);
            HeightPolicy.set(qq_clipboard_to_window, Constants.SP_TO_PARTNER);
            LayoutManagerHelper.setHeightPartner(qq_clipboard_to_window, getqq_image_to_clipboard());
            LayoutManagerHelper.setWidthPartner(qq_clipboard_to_window, getqq_text_to_clipboard());
            qq_clipboard_to_window.setMinimumSize(new Dimension(0, 0));
            qq_clipboard_to_window.setLocation(240, 114);
        }
        return qq_clipboard_to_window;
    }

    public void setqq_clipboard_to_window(JButton value) {
        JButton oldValue = qq_clipboard_to_window;
        qq_clipboard_to_window = value;
        this.qq_Listeners.firePropertyChange("qq_clipboard_to_window", oldValue, value);
    }

    /**
     * Form: transformed from: qqds_Panel
     * TagId=1
     * isInherited=FALSE
     */
    protected void setFormProperties() {
        Form.setOpaque( true );
    }

    public JPanel getForm() {
        if (Form == null) {
            Form = CompoundFieldFactory.newForm();
            this.setFormProperties();
            Form.add( getqq_clipboard_to_window() );
            Form.add( getqq_text_to_clipboard() );
            Form.add( getqq_image_to_clipboard() );
            Form.add( getqq_image_field() );
            Form.add( getqq_text_field_sp() );
        }
        return Form;
    }

    public void setForm(JPanel value) {
        JPanel oldValue = Form;
        Form = value;
        this.qq_Listeners.firePropertyChange("Form", oldValue, value);
    }

    /**
     * Gets the system close policy
     *
     * The SystemClosePolicy property determines how a window responds to user attempts to close it by using the native window system through the window close box or a window system menu command.
     * SystemClosePolicy responds to window closure attempts according to the following parameters:
     * <li>Constants.SC_DISABLED  Does not allow window closure through window system.</li>
     * <li>Constants.SC_ENABLEDNOFINALIZE  Window can be closed, but the contents are not verified, guaranteeing that the window will close (for example, the user clicks the Cancel button).</li>
     * <li>Constants.SC_ENABLEDFINALIZE  Posts the RequestFinalize method on the window, with a reason code of zero.</li>
     * <li>Constants.SC_ENABLEDSHUTDOWN  Posts Shutdown event to window�s task and to all tasks started by that task. This is the default value.</li>
     */
    public int getSystemClosePolicy() {
        return qq_SystemClosePolicy;
    }

    /**
     * Sets the system close policy
     *
     * The SystemClosePolicy property determines how a window responds to user attempts to close it by using the native window system through the window close box or a window system menu command.
     * SystemClosePolicy responds to window closure attempts according to the following parameters:
     * <li>Constants.SC_DISABLED  Does not allow window closure through window system.</li>
     * <li>Constants.SC_ENABLEDNOFINALIZE  Window can be closed, but the contents are not verified, guaranteeing that the window will close (for example, the user clicks the Cancel button).</li>
     * <li>Constants.SC_ENABLEDFINALIZE  Posts the RequestFinalize method on the window, with a reason code of zero.</li>
     * <li>Constants.SC_ENABLEDSHUTDOWN  Posts Shutdown event to window�s task and to all tasks started by that task. This is the default value.</li>
     */
    public void setSystemClosePolicy(int policy) {
        this.qq_SystemClosePolicy = policy;
        if (policy == Constants.SC_DISABLED) {
            this.addComponentListener(new CloseHideAdaptor(this));
        } else {
            for (ComponentListener cl : this.getComponentListeners()) {
                if (cl instanceof CloseHideAdaptor) {
                    this.removeComponentListener(cl);
                    break;
                }
            }
        }
    }

    /**
     * Gets the initial position policy
     *
     * The InitialPositionPolicy property sets the position of a main window when it is first displayed, relative to a primary window or the screen.
     * You use the InitialPositionPolicy property in conjunction with the InitialX, InitialY properties.
     * InitialPositionPolicy sets the position of a window according to the following values:
     * <li>Constants.PP_SYSTEMDEFAULT    Accepts the default window system placement specification.</li>
     * <li>Constants.PP_PRIMARYCENTERED  Centers the window relative to the window specified as the PrimaryWindow property.</li>
     * <li>Constants.PP_PRIMARYRELATIVE  Positions the window relative to the primary window, using the PrimaryWindow, InitialX and InitialY attributes.</li>
     * <li>Constants.PP_SCREENCENTERED  Centers the window relative to the screen.</li>
     * <li>Constants.PP_SCREENRELATIVE  Positions the window relative to the screen, using the InitialX and InitialY properties.</li>
     */
    public int getInitialPositionPolicy() {
        return qq_initialPositionPolicy;
    }

    /**
     * Sets the initial position policy
     *
     * The InitialPositionPolicy property sets the position of a main window when it is first displayed, relative to a primary window or the screen.
     * You use the InitialPositionPolicy property in conjunction with the InitialX, InitialY properties.
     * InitialPositionPolicy sets the position of a window according to the following values:
     * <li>Constants.PP_SYSTEMDEFAULT    Accepts the default window system placement specification.</li>
     * <li>Constants.PP_PRIMARYCENTERED  Centers the window relative to the window specified as the PrimaryWindow property.</li>
     * <li>Constants.PP_PRIMARYRELATIVE  Positions the window relative to the primary window, using the PrimaryWindow, InitialX and InitialY attributes.</li>
     * <li>Constants.PP_SCREENCENTERED  Centers the window relative to the screen.</li>
     * <li>Constants.PP_SCREENRELATIVE  Positions the window relative to the screen, using the InitialX and InitialY properties.</li>
     */
    public void setInitialPositionPolicy(int policy) {
        this.qq_initialPositionPolicy = policy;
    }

    /**
     * Gets the primary window
     *
     * The primary window property designates a window, known as a primary window, to serve as an initial position reference for the current window.
     * When a main window first realizes itself through the Open method on the UserWindow, it assumes a position according to the InitialPositionPolicy attribute.
     * When the InitialPositionPolicy property is set to PP_PRIMARYRELATIVE (relative to the primary window) or PP_PRIMARYCENTERED (centered on the primary window),
     * the window realizes itself in a position relative to the designated primary window.<p>
     * <p>
     * To take a position relative to the primary window, a window uses the PrimaryWindow attribute in conjunction with the InitialX and InitialY properties, which specify the window�s horizontal and vertical coordinates.
     */
    public Window getPrimaryWindow() {
        return this.primaryWindow;
    }

    /**
     * Sets the primary window
     *
     * The primary window property designates a window, known as a primary window, to serve as an initial position reference for the current window.
     * When a main window first realizes itself through the Open method on the UserWindow, it assumes a position according to the InitialPositionPolicy attribute.
     * When the InitialPositionPolicy property is set to PP_PRIMARYRELATIVE (relative to the primary window) or PP_PRIMARYCENTERED (centered on the primary window),
     * the window realizes itself in a position relative to the designated primary window.<p>
     * <p>
     * To take a position relative to the primary window, a window uses the PrimaryWindow attribute in conjunction with the InitialX and InitialY properties, which specify the window�s horizontal and vertical coordinates.
     */
    public void setPrimaryWindow(Window value) {
        this.primaryWindow = value;
    }

    /**
     * Gets the InitialX value
     *
     * The InitialX property (integer) is the window�s initial horizontal screen position, relative to a primary window or the screen. It is specified in mils.
     * InitialX applies only to main windows and only when a window�s InitialPositionPolicy attribute is set to PP_PRIMARYRELATIVE (relative to the primary window) or PP_SCREENRELATIVE (relative to the screen).
     * InitialX, and its corollary, InitialY, work in conjunction with the PrimaryWindow and InitialPositionPolicy attributes to determine the position of a main window when it is first realized.
     */
    public int getInitialX() {
        return initialX;
    }

    /**
     * Sets the InitialX value
     *
     * The InitialX property (integer) is the window�s initial horizontal screen position, relative to a primary window or the screen. It is specified in mils.
     * InitialX applies only to main windows and only when a window�s InitialPositionPolicy attribute is set to PP_PRIMARYRELATIVE (relative to the primary window) or PP_SCREENRELATIVE (relative to the screen).
     * InitialX, and its corollary, InitialY, work in conjunction with the PrimaryWindow and InitialPositionPolicy attributes to determine the position of a main window when it is first realized.
     */
    public void setInitialX(int value) {
        this.initialX = value;
    }

    /**
     * Gets the InitialY value
     *
     * The InitialY property (integer) is the window�s initial vertical screen position, relative to a primary window or the screen. It is specified in mils.
     * InitialY applies only to main windows and only when a window�s InitialPositionPolicy attribute is set to PP_PRIMARYRELATIVE (relative to the primary window) or PP_SCREENRELATIVE (relative to the screen).
     * InitialY, and its corollary, InitialX, work in conjunction with the PrimaryWindow and InitialPositionPolicy attributes to determine the position of a main window when it is first realized.
     */
    public int getInitialY() {
        return initialY;
    }

    /**
     * Sets the InitialY value
     *
     * The InitialY property (integer) is the window�s initial vertical screen position, relative to a primary window or the screen. It is specified in mils.
     * InitialY applies only to main windows and only when a window�s InitialPositionPolicy attribute is set to PP_PRIMARYRELATIVE (relative to the primary window) or PP_SCREENRELATIVE (relative to the screen).
     * InitialY, and its corollary, InitialX, work in conjunction with the PrimaryWindow and InitialPositionPolicy attributes to determine the position of a main window when it is first realized.
     */
    public void setInitialY(int value) {
        this.initialY = value;
    }

    /**
     * Gets the default message set number for the window and its widgets.
     */
    public int getSetNum() {
        return this.qq_defaultSet;
    }

    /**
     * Sets the default message set number for the window and its widgets.
     */
    public void setSetNum(int value) {
        this.qq_defaultSet = value;
    }

    /**
     * Gets the message set number for the message number of the window's title.
     */
    public int getTitleSetNum() {
        return this.qq_msgSet;
    }

    /**
     * Sets the message set number for the message number of the window's title.
     */
    public void setTitleSetNum(int value) {
        this.qq_msgSet = value;
    }

    /**
     * Gets the message number for the message number of the window's title.
     */
    public int getTitleMsgNum() {
        return this.qq_msgNumber;
    }

    /**
     * Sets the message number for the message number of the window's title.
     */
    public void setTitleMsgNum(int value) {
        this.qq_msgNumber = value;
    }



    /**
     * Initialise the window and all its children.
     */
    protected void initialize() {
        if (this.Form == null) {
            this.setName( "ClipboardWindow" );
            this.setTitle( "" );
            this.setSystemClosePolicy(Constants.SC_ENABLEDSHUTDOWN);
            if (this.getContentPane() != this.getForm()) {
                this.setContentPane(getForm());
            }
            this.qq_setupWindowUsage();
            this.setResizable( false );
            this.setAlwaysOnTop(false);
            UserWindow.setIconizeEnabled(this, true);
            WindowManager.addWindowListener(this);
            this.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
            this.setUsage(DisplayProject.Constants.WU_UPDATE);
            UIutils.processGUIActions();
            this.pack();
            this.setInitialX(0);
            this.setInitialY(0);
            this.setInitialPositionPolicy(Constants.PP_SYSTEMDEFAULT);
        }
    }


    // ----------------
    //  Window usage
    //-----------------
    protected WindowUsageMap usage = new WindowUsageMap();
    public int getUsage() {
        return this.usage.getUsage();
    }
    public WindowUsageMap getUsageMap() {
        return this.usage;
    }
    /**
     * Sets the window usage
     *
     * The Usage property sets the state for all a window�s child widgets at once, providing collective widget state changes on a predefined basis. A widget�s state determines how the widget reacts to mouse actions and how it displays itself. A window�s Usage property provides a convenient way to control the states of a group of widgets in the context of their parent window. With the Usage attribute, you can synchronize widget states to conform to a pattern you establish for the window.
     * The Usage attribute accepts the following values:
     * <li>Constants.WU_EDIT  Edit usage: widgets themselves are editable, but not underlying data.</li>
     * <li>Constants.WU_QUERY  Query only usage: widget data is editable, but not widgets themselves.</li>
     * <li>Constants.WU_UPDATE  Update usage: mouse actions and keyboard input accepted. Widgets themselves are changeable. This is the default.</li>
     * <li>Constants.WU_USER1  A user-defined usage. Default values same as WU_UPDATE.</li>
     * <li>Constants.WU_USER2  A user-defined usage. Default values same as WU_UPDATE.</li>
     * <li>Constants.WU_USER3  A user-defined usage. Default values same as WU_UPDATE.</li>
     * <li>Constants.WU_VIEW  View-only usage: no keyboard input is accepted. Widget posts Click events for mouse clicks.</li>
     */
    public void setUsage(int usage) {
        this.usage.setUsage(usage);
    }
    public void qq_setupWindowUsage() {
        this.usage = new WindowUsageMap();
        this.usage.add(getqq_text_field(), Constants.FS_UPDATE, Constants.FS_VIEWONLY, Constants.FS_UPDATE, Constants.FS_UPDATE, Constants.FS_UPDATE, Constants.FS_UPDATE);
        this.usage.add(getqq_image_field(), Constants.FS_UPDATE, Constants.FS_VIEWONLY, Constants.FS_UPDATE, Constants.FS_INACTIVE, Constants.FS_INACTIVE, Constants.FS_INACTIVE);
        this.usage.add(getqq_image_to_clipboard(), Constants.FS_UPDATE, Constants.FS_VIEWONLY, Constants.FS_UPDATE, Constants.FS_INACTIVE, Constants.FS_INACTIVE, Constants.FS_INACTIVE);
        this.usage.add(getqq_text_to_clipboard(), Constants.FS_UPDATE, Constants.FS_VIEWONLY, Constants.FS_UPDATE, Constants.FS_INACTIVE, Constants.FS_INACTIVE, Constants.FS_INACTIVE);
        this.usage.add(getqq_clipboard_to_window(), Constants.FS_UPDATE, Constants.FS_VIEWONLY, Constants.FS_UPDATE, Constants.FS_INACTIVE, Constants.FS_INACTIVE, Constants.FS_INACTIVE);
    }
    // </editor-fold>

    // -----------
    // Main method
    // -----------
        public static void main( String[] args ) {
            FrameworkUtils.setCmdLineArgs(args);
            AppletConnectionInfo client = null;
            try {
                // Install our own focus manager. MUST be done prior to setting the
                // UIManager, otherwise you'll run into issues like things have the wrong focus.
                KeyboardFocusManager.setCurrentKeyboardFocusManager(new ForteKeyboardFocusManager());

                UIManager.setLookAndFeel(new Win32LookAndFeel());

                client = UserWindow.postAPPLETStarted();
                ClipboardWindow clipboardWindow_start = new ClipboardWindow();
                clipboardWindow_start.display();
                UserWindow.postAPPLETStopped(client);
                System.exit(0);
            } catch (Throwable e) {
                ErrorMgr.showErrors(null, "Unhandled exception", e);
                UserWindow.postAPPLETStopped(client);
                System.exit(0);
            }
        }
// end class ClipboardWindow
// c Pass 2 Conversion Time: 531 milliseconds
TOP

Related Classes of ClipboardSample.ClipboardWindow

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.