001: /*
002: * %W% %E%
003: *
004: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package com.sun.jump.command;
028:
029: import com.sun.jump.common.JUMPWindow;
030: import com.sun.jump.module.windowing.JUMPWindowingModuleFactory;
031: import com.sun.jump.module.windowing.JUMPWindowingModule;
032: import com.sun.jump.message.JUMPMessage;
033: import com.sun.jump.message.JUMPMessageReader;
034: import com.sun.jump.message.JUMPOutgoingMessage;
035:
036: /**
037: * <code>JUMPExecutiveWindowRequest</code> defines all the windowing
038: * related requests that originate from the <Code>JUMPExecutive</code>
039: */
040: public class JUMPExecutiveWindowRequest extends JUMPRequest {
041: private int windowId;
042:
043: /**
044: * Type of <code>JUMPMessage</code> corresponding
045: * to <code>JUMPExecutiveWindowRequest</code> request.
046: */
047: public static final String MESSAGE_TYPE = "executive/window";
048:
049: /**
050: * Command to bring the Isolate's window to the foreground.
051: * <ol>
052: * <li>args[0] - Window Id</li>
053: * </ol>
054: * Synchronous request. expects a
055: * {@link com.sun.jump.command.JUMPResponse#ID_SUCCESS} or
056: * {@link com.sun.jump.command.JUMPResponse#ID_FAILURE}
057: */
058: public static final String ID_FOREGROUND = "Foreground";
059:
060: /**
061: * Command to bring the Isolate's window to the background.
062: * <ol>
063: * <li>args[0] - Window Id</li>
064: * </ol>
065: * Synchronous request. expects a
066: * {@link com.sun.jump.command.JUMPResponse#ID_SUCCESS} or
067: * {@link com.sun.jump.command.JUMPResponse#ID_FAILURE}
068: */
069: public static final String ID_BACKGROUND = "Background";
070:
071: private JUMPExecutiveWindowRequest(String id, String[] args) {
072: super (MESSAGE_TYPE, id, args);
073: }
074:
075: private JUMPExecutiveWindowRequest(String id) {
076: super (MESSAGE_TYPE, id, null);
077: }
078:
079: JUMPExecutiveWindowRequest() {
080: super (MESSAGE_TYPE, null, null);
081: }
082:
083: public JUMPExecutiveWindowRequest(String id, JUMPWindow w) {
084: this (id);
085: this .windowId = w.getId();
086: }
087:
088: /**
089: * For subclasses to use to initialize any fields
090: * using <code>JUMPMessage.get*</code> methods.
091: */
092: protected void deserializeFrom(JUMPMessageReader message) {
093: // First deserialize any shared fields
094: super .deserializeFrom(message);
095: // And now window specific fields
096: this .windowId = message.getInt();
097: }
098:
099: /**
100: * For subclasses to use to put data in a message
101: * using <code>JUMPOutgoingMessage.add*</code> methods.
102: */
103: protected void serializeInto(JUMPOutgoingMessage message) {
104: super .serializeInto(message);
105: // And now window specific fields
106: message.addInt(this .windowId);
107: }
108:
109: public static JUMPCommand fromMessage(JUMPMessage message) {
110: return JUMPCommand.fromMessage(message,
111: JUMPExecutiveWindowRequest.class);
112: }
113:
114: public int getWindowId() {
115: return windowId;
116: }
117: }
|