OpAction.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright (c) 2000 by Sun Microsystems, Inc.
* All rights reserved.
*/
/*
* Copyright (C) 1996 Active Software, Inc.
* All rights reserved.
*
* @(#) OpAction.java 1.17 - last change made 07/25/97
*/
/**
* Stores the action that should be triggered in an operation whose
* filter has matched an event or message. This class
* also simultaneously
* acts as its own converter.
*
* @see Op
* @version 1.17, 07/25/97
*/
// Register the converter
static {
"sunsoft.jws.visual.rt.type.OpAction",
/* NOI18N */"sunsoft.jws.visual.rt.type.OpAction");
}
/**
* Action is to set an attribute.
*/
public static final int ATTRIBUTE = 0;
/**
* Action is to send a message.
*/
public static final int MESSAGE = 1;
/**
* Action is to execute some code.
*/
public static final int CODE = 2;
// Action Details
public static final int SHOW = 1;
public static final int HIDE = 2;
public static final int EXIT = 3;
/* BEGIN JSTYLED */
/**
* Used when setting the action target, specifies
* that the target is
* permanently set (i.e. always use what is stored in this objects
* target memeber.
*
* @see #target
*/
/* END JSTYLED */
public static final int CONSTANT = 10;
/**
* Used when setting the action target, specifies that
* the target should
* be the same as the target of the event
* or message that triggered this
* operation.
*/
public static final int TARGET = 11;
/**
* Used when setting the action target, specifies
* that the target should
* be whatever is in the arg variable of the message or event.
*/
public static final int ARG = 12;
/**
* Action type, ATTRIBUTE, MESSAGE, or CODE.
*/
public int actionType;
/**
* Action detail, used by the action editor to
* keep track of simple actions.
*/
public int actionDetail;
/**
* Action target, used when targetSource == CONSTANT.
*/
/**
* Specifies how the target or the action is determined, is either
* CONSTANT, TARGET, or ARG.
*/
public int targetSource;
/**
* Message or Attribute name.
*/
/* BEGIN JSTYLED */
/**
* Message arg or Attribute value, used when valueSource == CONSTANT.
*/
/* END JSTYLED */
/**
* is either CONSTANT, TARGET, or ARG.
*/
public int valueSource;
/**
* Message type, used when the action is to send a message.
*/
/**
* Message target name, used when the action is to send a message.
*/
public String targetName;
/**
* The code associate with the action, in string form.
*/
/**
* Constructs an instance where targetSource and
* valueSource are CONSTANT.
*/
public OpAction() {
this.targetSource = CONSTANT;
this.valueSource = CONSTANT;
}
/**
* Constructs an instance where targetSource and
* valueSource are CONSTANT.
*/
this.actionType = actionType;
this.targetSource = CONSTANT;
this.valueSource = CONSTANT;
}
/**
* Performs the action.
*
* @param target the target of the action if targetSource == TARGET
* @param arg the argument of the message or event
* and the target of the action if targetSource == ARG
* @param scope the root tree in which to search for the target
*/
return;
// Lookup the target
return;
// Lookup the value
// Perform the action
}
switch (targetSource) {
case CONSTANT:
break;
case TARGET:
break;
case ARG:
break;
}
return mgr;
}
switch (valueSource) {
case CONSTANT:
break;
case TARGET:
break;
case ARG:
break;
}
return value;
}
switch (actionType) {
case ATTRIBUTE:
break;
case MESSAGE:
break;
case CODE:
break;
}
}
/**
* Returns a new copy of this action.
*/
try {
return super.clone();
} catch (CloneNotSupportedException e) {
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}
}
//
// Code generation
//
/**
* Appends the initialization code for this operation filter into
* the buffer given.
*
* @param varname variable name of the operation filter
* @param buf buffer onto which the code should be appended
*/
// Action type
// Target
}
// Target source
if (targetSource != CONSTANT) {
}
// Name
}
// Value source
if (valueSource != CONSTANT) {
}
// Value
// Lookup converter for value
}
}
// Message type
}
// Message target name
if (targetName != null) {
}
}
//
// String converters
//
private String constantToString(int c) {
switch (c) {
// Action consts
case ATTRIBUTE:
return /* NOI18N */"ATTRIBUTE";
case MESSAGE:
return /* NOI18N */"MESSAGE";
case CODE:
return /* NOI18N */"CODE";
// Source consts
case CONSTANT:
return /* NOI18N */"CONSTANT";
case TARGET:
return /* NOI18N */"TARGET";
case ARG:
return /* NOI18N */"ARG";
default:
return null;
}
}
private int stringToConstant(String s) {
// Action consts
return ATTRIBUTE;
return MESSAGE;
return CODE;
// Source consts
return CONSTANT;
return TARGET;
return ARG;
else
return -1;
}
// Open brace
incrIndent();
// Action type
// Action detail
if (a.actionDetail != 0) {
}
// Action target
}
// Target source
if (a.targetSource != CONSTANT) {
}
// Name
}
// Value
// Lookup converter for value
} else {
}
}
// Value source
if (a.valueSource != CONSTANT) {
}
// Message type
}
// Message target name
if (a.targetName != null) {
}
// Code
}
// Close brace
decrIndent();
}
convertFromString(s, action);
return action;
}
// Action type
// Action detail
try {
}
catch (NumberFormatException ex) {
/* JSTYLED */
throw new ParseException(Global.fmtMsg("sunsoft.jws.visual.rt.type.OpAction.NumberFormatException", val));
}
}
// Action target
// Target source
// Name
// Value
} else {
"valueType");
}
"sunsoft.jws.visual.rt.type.OpAction.NoConverter",
valueType));
}
/* JSTYLED */
}
}
// Value source
// Message type
// Message target name
// Code
}
/**
* Returns true if this type should be displayed in an editor.
*
* For the attribute editor, a return value of false means that the
* the textfield will be hidden.
*
* @return false
*/
public boolean viewableAsString() {
return (false);
}
}