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.common.JUMPIsolate;
031: import com.sun.jump.message.JUMPMessage;
032: import com.sun.jump.message.JUMPMessageReader;
033: import com.sun.jump.message.JUMPOutgoingMessage;
034:
035: /**
036: * <code>JUMPIsolateWindowRequest</code> defines all the windowing
037: * related requests that originate from the <Code>JUMPIsolate</code>
038: */
039: public class JUMPIsolateWindowRequest extends JUMPRequest {
040: private int windowId;
041: private int isolateId;
042:
043: /**
044: * Type of <code>JUMPMessage</code> corresponding
045: * to <code>JUMPIsolateWindowRequest</code> request.
046: */
047: public static final String MESSAGE_TYPE = "isolate/window";
048:
049: /**
050: * Isolate notifying the executive that the window is raised to the
051: * foreground.
052: * <ol>
053: * <li>args[0] - Isolate Id</li>
054: * <li>args[1] - Window Id</li>
055: * </ol>
056: * Asynchronous request. No <code>JUMPResponse</code> required.
057: */
058: public static final String ID_NOTIFY_WINDOW_FOREGROUND = "NotifyFg";
059:
060: /**
061: * Isolate notifying the executive that the window is lowered to the
062: * background.
063: * <ol>
064: * <li>args[0] - Isolate Id</li>
065: * <li>args[1] - Window Id</li>
066: * </ol>
067: * Asynchronous request. No <code>JUMPResponse</code> required.
068: */
069: public static final String ID_NOTIFY_WINDOW_BACKGROUND = "NotifyBg";
070:
071: private JUMPIsolateWindowRequest(String id, String[] args) {
072: super (MESSAGE_TYPE, id, args);
073: }
074:
075: JUMPIsolateWindowRequest() {
076: super (MESSAGE_TYPE, null, null);
077: }
078:
079: public JUMPIsolateWindowRequest(String id, int windowId,
080: int isolateId) {
081: this (id, null);
082: this .windowId = windowId;
083: this .isolateId = isolateId;
084: }
085:
086: public int getWindowId() {
087: return windowId;
088: }
089:
090: public int getIsolateId() {
091: return isolateId;
092: }
093:
094: /**
095: * For subclasses to use to initialize any fields
096: * using <code>JUMPMessage.get*</code> methods.
097: */
098: protected void deserializeFrom(JUMPMessageReader message) {
099: // First deserialize any shared fields
100: super .deserializeFrom(message);
101: // And now window request specific fields
102: this .windowId = message.getInt();
103: this .isolateId = message.getInt();
104: }
105:
106: /**
107: * For subclasses to use to put data in a message
108: * using <code>JUMPOutgoingMessage.add*</code> methods.
109: */
110: protected void serializeInto(JUMPOutgoingMessage message) {
111: super .serializeInto(message);
112: // And now window request specific fields
113: message.addInt(this .windowId);
114: message.addInt(this .isolateId);
115: }
116:
117: public static JUMPCommand fromMessage(JUMPMessage message) {
118: return JUMPCommand.fromMessage(message,
119: JUMPIsolateWindowRequest.class);
120: }
121: }
|