OpFilter.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.
*
* @(#) OpFilter.java 1.16 - last change made 07/25/97
*/
/**
* Stores the conditions under which an operation
* should be activated. The
* parameters stored here are compared with the fields
* in events and messages
* to determine a match. This class also simultaneously
* acts as its own
* converter.
*
* @see Op
* @see Message
* @see Event
* @version 1.16, 07/25/97
*/
/**
* The operation should match against an event.
*/
public static final int EVENT = 0;
/**
* The operation should match against a message.
*/
public static final int MESSAGE = 1;
public static final int LEFT_MOUSE = 0;
public static final int MIDDLE_MOUSE = 8;
public static final int RIGHT_MOUSE = 4;
// Converter
static {
"sunsoft.jws.visual.rt.type.OpFilter",
/* NOI18N */"sunsoft.jws.visual.rt.type.OpFilter");
}
/**
* Filter type, either EVENT or MESSAGE.
*/
public int filterType;
/**
* AttributeManager object that should be the target of a matching
* event or message.
*/
public AttributeManager target;
/**
* Target reference (left in for compatibility reasons.)
*/
/**
* Message filter on name.
*
* @see Message#name
*/
/**
* Message filter on type.
*
* @see Message#type
*/
/**
* Message filter on target name.
*
* @see Message#targetName
*/
public String targetName;
/**
* Event filter on id.
*
* @see Event#id
*/
public int id;
/**
* Event filter on key.
*
* @see Event#key
*/
public int key = -1;
/**
* Event filter on modifiers.
*
* @see Event#modifiers
*/
public int modifiers = -1;
/**
* Event filter on clickCount.
*
* @see Event#clickCount
*/
public int clickCount = 0;
/**
* Constructs a new instance.
*/
public OpFilter() {
}
/**
* Constructs a new instance that filters on a message.
*/
}
/**
* Constructs a new instance that filters on a message.
*/
this.targetName = targetName;
}
/**
* Constructs a new instance that filters on an event.
*/
filterType = EVENT;
}
/**
* Constructs a new instance that filters on an event.
*/
this.clickCount = clickCount;
}
/**
* Returns true if this filter matches with the message given.
*/
if (filterType != MESSAGE)
return false;
}
/**
* Returns true if this filter matches with the event given.
*/
if (filterType != EVENT)
return false;
(modifiers == -1 ||
}
/**
* Returns a new copy of this filter.
*/
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
*/
// The targetRef is used for code generation so that QuickGen can work.
}
}
}
if (targetName != null) {
}
if (key != -1) {
}
if (modifiers != -1) {
}
if (clickCount != 0) {
}
}
//
// String converters
//
private String constantToString(int c) {
switch (c) {
case EVENT:
return /* NOI18N */"EVENT";
case MESSAGE:
return /* NOI18N */"MESSAGE";
default:
return null;
}
}
private int stringToConstant(String s) {
return EVENT;
return MESSAGE;
else
return -1;
}
// Open brace
incrIndent();
// Filter type
// Don't save the target. The target is determined during code
// generation by figuring out which shadow has the operation
// as its attribute.
//
// if (f.targetRef != null) {
// indent(buf);
// buf.append("target ");
// buf.append(f.targetRef.getName());
// newline(buf);
// }
// Message filters
}
}
if (f.targetName != null) {
}
// Event filters
if (f.key != -1) {
}
if (f.modifiers != -1) {
}
if (f.clickCount != 0) {
}
// Close brace
decrIndent();
}
convertFromString(s, filter);
return filter;
}
//
// Filter type
//
throw new ParseException(/* NOI18N */
"filterType not found: " + s);
}
//
// Message or event target to match against.
// Left in for compatibility reasons.
//
//
// Message filters
//
//
// Event filters
//
}
/**
* 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);
}
}