ILOG logo
KSTEC ȸ¿øÀ¸·Î °¡ÀÔÇϼ¼¿ä¤Ó»õ¼Ò½Ä | ·Î±×ÀÎ
 
title element1
License
- ¶óÀ̼¾½º
- ¶óÀ̼¾½º °ü¸®
Maintenance
Training
FAQ
Q&A

Q & A ... °Ô½ÃÆÇ  (Business Rules)


¡Ø ¾È³çÇϽʴϱî..?
    ÀúÈñ KSTECÀÇ Á¦Ç°À̳ª ¼­ºñ½º¿¡ ´ëÇØ ±Ã±ÝÇϽŠÁ¡À̳ª ±â¼úÁö¿øÀ» ¿øÇϽô °í°´´ÔÀº ȸ»ç¸í,
    ºÎ¼­¸í, ¼º¸í, »ç¿ëÁ¦Ç°¸í, Á¦Ç° VERSIONÀ» ¸í½ÃÇÏ¿© Áֽñ⠹ٶø´Ï´Ù.

¡Ø °Ô½ÃÇϽг»¿ë¿¡ ´ëÇØ¼­´Â ½Å¼ÓÇÏ°Ô ´äº¯ÇØ µå¸®°Ú½À´Ï´Ù.
¡Ø ÇØ´çµÇ´Â Á¦Ç°±ºÀ» ¼±ÅÃÇϽŠÈÄ ÇÏ°í ½ÍÀ¸½Å ¸»¾¸À» Àû¾î ÁֽʽÿÀ.

Á¦ ¸ñ
search condition 2
ÀÛ¼ºÀÚ
±èÁ¤È£
ÀÛ¼ºÀÏ
2006-06-13
Á¶È¸¼ö 2346 È¸
÷ºÎÆÄÀÏ Ã·ºÎµÈ ÆÄÀϾøÀ½.
// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)

package ilog.rules.ui.editor.chooser;

import ilog.rules.brl.*;
import ilog.rules.ui.editor.*;
import ilog.rules.ui.editor.chooser.tree.IlrObjectTokenTreeChooser;
import java.awt.*;
import javax.swing.*;
import javax.swing.text.JTextComponent;

// Referenced classes of package ilog.rules.ui.editor.chooser:
// IlrObjectTokenChooser

public class IlrObjectTokenActionManager extends IlrTokenActionManager
{

public IlrObjectTokenActionManager(ilog.rules.brl.IlrToken.TextToken texttoken)
{
super(texttoken);
popupMenu = null;
}

protected void doAction(IlrTokenEditor ilrtokeneditor, boolean flag)
{

//System.out.println("IlrObjectTokenActionManager.doAction +++++++++++++++++++++++++++++++++");
IlrSyntacticEditorPane ilrsyntacticeditorpane = (IlrSyntacticEditorPane)ilrtokeneditor;
ilog.rules.brl.IlrFormatToken.ObjectToken objecttoken = (ilog.rules.brl.IlrFormatToken.ObjectToken)super.token;
if(popupMenu != null && popupMenu.isVisible())
return;
popupMenu = makeMenu(ilrsyntacticeditorpane, currentChooser.getJComponent());
popupMenu.setPreferredSize(new Dimension(400, 200));
if(getChooser().isEmpty())
return;
if(objecttoken.getChoicesProvider().getChoiceObject() != null){
currentChooser.setSelectedObject(objecttoken.getChoicesProvider().getChoiceObject());
}
try
{
IlrStyledTokenDocument ilrstyledtokendocument = (IlrStyledTokenDocument)super.token.getDocument();
int i = ilrstyledtokendocument.getStartOffset(super.token, false);
Rectangle rectangle = ilrsyntacticeditorpane.modelToView(i);
popupMenu.show(ilrsyntacticeditorpane, rectangle.x, rectangle.y + rectangle.height);
popupMenu.requestFocus();
}
catch(Exception exception) { }
}

protected void doMenuAction(IlrTokenEditor ilrtokeneditor, String s)
{
//¹ÚÇ×¼® Ãß°¡ - ¸Þ´º ¼±Åýà ¸Þ´º action
IlrSyntacticEditorPane ilrsyntacticeditorpane = (IlrSyntacticEditorPane)ilrtokeneditor;
IlrToken.doTokenMenuAction(super.token,ilrsyntacticeditorpane,s);
}

protected void doSelect(IlrTokenEditor ilrtokeneditor)
{
doAction(ilrtokeneditor, false);
}

public boolean isEnabled()
{
getChooser().reset();
return getChooser().isEnabled();
}

private IlrObjectTokenChooser getChooser()
{
ilog.rules.brl.IlrFormatToken.ObjectToken objecttoken = (ilog.rules.brl.IlrFormatToken.ObjectToken)super.token;
if(currentChooser == null)
{
currentChooser = makeChooserInstance();
currentChooser.setObjectToken(objecttoken);
currentChooser.setObjectTokenActionManager(this);
}
return currentChooser;
}

protected IlrObjectTokenChooser makeChooserInstance()
{
return new IlrObjectTokenTreeChooser();
}

protected JPopupMenu makeMenu(Component component, JComponent jcomponent)
{
JPopupMenu jpopupmenu = new JPopupMenu();
jpopupmenu.add(jcomponent);
jpopupmenu.setLayout(new BoxLayout(jpopupmenu, 1));
jpopupmenu.setBorderPainted(true);
javax.swing.border.Border border = BorderFactory.createLineBorder(Color.lightGray);
javax.swing.border.Border border1 = BorderFactory.createRaisedBevelBorder();
javax.swing.border.Border border2 = BorderFactory.createEtchedBorder();
javax.swing.border.CompoundBorder compoundborder = BorderFactory.createCompoundBorder(border, border1);
jpopupmenu.setBorder(BorderFactory.createCompoundBorder(compoundborder, border2));
jpopupmenu.setOpaque(false);
jpopupmenu.setDoubleBuffered(true);
jpopupmenu.setRequestFocusEnabled(false);
return jpopupmenu;
}

public JPopupMenu getPopupMenu()
{
return popupMenu;
}

private static boolean isJDK14()
{
String s = System.getProperty("java.version", "");
return s.compareTo("1.4.0") >= 0;
}

public void chooserValidated(IlrObjectTokenChooser ilrobjecttokenchooser)
{
ilog.rules.brl.IlrFormatToken.ObjectToken objecttoken = (ilog.rules.brl.IlrFormatToken.ObjectToken)super.token;
int i = ilrobjecttokenchooser.getSelectedIndex();
if(i != -1)
objecttoken.setChoice(i);
popupMenu.setVisible(false);
}

private JPopupMenu popupMenu;
private IlrObjectTokenChooser currentChooser;
}




















// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)

package ilog.rules.ui.editor.chooser;

import ilog.rules.brl.IlrFormatToken;
import javax.swing.JComponent;

// Referenced classes of package ilog.rules.ui.editor.chooser:
// IlrObjectTokenActionManager

public interface IlrObjectTokenChooser
{

public abstract ilog.rules.brl.IlrFormatToken.ObjectToken getObjectToken();

public abstract void setObjectToken(ilog.rules.brl.IlrFormatToken.ObjectToken objecttoken);

public abstract JComponent getJComponent();

public abstract void setSelectedObject(Object obj);

public abstract Object getSelectedObject();

public abstract int getSelectedIndex();

public abstract void setObjectTokenActionManager(IlrObjectTokenActionManager ilrobjecttokenactionmanager);

public abstract boolean isEmpty();

public abstract boolean isEnabled();

public abstract void reset();
}




















// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)

package ilog.rules.ui.editor.chooser.tree;

import ilog.rules.bom.IlrAttribute;
import ilog.rules.bom.IlrClass;
import ilog.rules.bom.IlrMember;
import ilog.rules.bom.IlrMethod;
import ilog.rules.brl.IlrBOMChoicesProvider;
import ilog.rules.brl.IlrBOMTokenObjectModel;
import ilog.rules.brl.IlrChoicesProvider;
import ilog.rules.brl.IlrFormatToken;
import ilog.rules.brl.IlrGrammarChoices;
import ilog.rules.brl.IlrGrammarTokenModel;
import ilog.rules.brl.IlrMergedChoices;
import ilog.rules.brl.IlrToken;
import ilog.rules.brl.IlrTokenModel;
import ilog.rules.brl.IlrVariable;
import ilog.rules.repository.model.IlrElement;
import ilog.rules.ui.editor.IlrStyledTokenDocument;
import ilog.rules.ui.editor.chooser.IlrObjectTokenActionManager;
import ilog.rules.ui.editor.chooser.IlrObjectTokenChooser;
import ilog.rules.ui.util.IlrScrollPane;
import ilog.rules.ui.util.IlrUIPreferences;
import ilog.rules.ui.util.IlrUtils;
import ilog.rules.util.prefs.IlrPreferences;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.ToolTipManager;
import javax.swing.text.DefaultStyledDocument;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.MutableTreeNode;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;

public class IlrObjectTokenTreeChooser
implements IlrObjectTokenChooser
{
private class TreeNodeComparator
implements Comparator
{

public int compare(Object obj, Object obj1)
{

//System.out.println("@@@@@@@@@@@@@@@obj="+ obj);
//System.out.println("@@@@@@@@@@@@@@@obj1="+ obj1);
DefaultMutableTreeNode defaultmutabletreenode = (DefaultMutableTreeNode)obj;
DefaultMutableTreeNode defaultmutabletreenode1 = (DefaultMutableTreeNode)obj1;
Object obj2 = defaultmutabletreenode.getUserObject();
Object obj3 = defaultmutabletreenode1.getUserObject();
//System.out.println("@@@@@@@@@@@@@@@obj2="+ obj2);
//System.out.println("@@@@@@@@@@@@@@@obj3="+ obj3);
int i = choiceIndexes.indexOf(obj2);
int j = choiceIndexes.indexOf(obj3);
String s = i == -1 ? getDefaultAlternate(obj2) : getMessage(choicesProvider.getChoicesText()[i]);
String s1 = j == -1 ? getDefaultAlternate(obj3) : getMessage(choicesProvider.getChoicesText()[j]);
return Collator.getInstance().compare(s, s1);
}

private IlrChoicesProvider choicesProvider;

public TreeNodeComparator(IlrChoicesProvider ilrchoicesprovider)
{
choicesProvider = ilrchoicesprovider;
}
}

private class TreeMouseMotionHandler extends java.awt.event.MouseMotionAdapter
{

public void mouseMoved(java.awt.event.MouseEvent mouseevent)
{
int i = tree.getRowForLocation(mouseevent.getX(), mouseevent.getY());
tree.setSelectionRow(i);
}

private TreeMouseMotionHandler()
{
}

}

private class ChoiceTree extends JTree
{

public String getToolTipText(java.awt.event.MouseEvent mouseevent)
{
if(getRowForLocation(mouseevent.getX(), mouseevent.getY()) == -1)
return null;
TreePath treepath = getPathForLocation(mouseevent.getX(), mouseevent.getY());
Object obj = ((DefaultMutableTreeNode)treepath.getPathComponent(treepath.getPathCount() - 1)).getUserObject();
String s = getAnnotation(obj);
if(s != null)
return "" + s + "";
else
return null;
}

public ChoiceTree(TreeModel treemodel)
{
super(treemodel);
ToolTipManager.sharedInstance().registerComponent(this);
}
}

private class TreeCellRenderer extends DefaultTreeCellRenderer
{

public java.awt.Component getTreeCellRendererComponent(JTree jtree, Object obj, boolean flag, boolean flag1, boolean flag2, int i, boolean flag3)
{
DefaultMutableTreeNode defaultmutabletreenode = (DefaultMutableTreeNode)obj;
Object obj1 = defaultmutabletreenode.getUserObject();
int j = choiceIndexes.indexOf(obj1);
boolean flag4 = j != -1 && flag;
super.getTreeCellRendererComponent(jtree, obj, flag4, flag1, flag2, i, flag3);
IlrStyledTokenDocument ilrstyledtokendocument = (IlrStyledTokenDocument)getObjectToken().getDocument();
javax.swing.text.AttributeSet attributeset = ilrstyledtokendocument.getTokenAttributes(getObjectToken());
java.awt.Font font = ilrstyledtokendocument.getFont(attributeset);
IlrChoicesProvider ilrchoicesprovider = getObjectToken().getChoicesProvider();

//System.out.println(ilrchoicesprovider.getChoiceObject());

if(j != -1)
{
//System.out.println("ilrchoicesprovider.getChoicesText()[j])="+ilrchoicesprovider.getChoicesText()[j]);
setText(getMessage(ilrchoicesprovider.getChoicesText()[j]));
} else
{
//System.out.println("getDefaultAlternate(obj1)="+getDefaultAlternate(obj1));
setText(getDefaultAlternate(obj1));
setForeground(java.awt.Color.lightGray);
}
setFont(font);
setIcon(getIcon(obj1));
return this;
}

private Icon getIcon(Object obj)
{
boolean flag = choiceIndexes.contains(obj);
ImageIcon imageicon = null;
if(obj instanceof IlrClass)
imageicon = (ImageIcon)IlrUIPreferences.getIcon("ui.DefaultBusinessModel.Class.icon");
else
if(obj instanceof IlrAttribute)
imageicon = (ImageIcon)IlrUIPreferences.getIcon("ui.DefaultBusinessModel.Field.icon");
else
if(obj instanceof IlrMethod)
imageicon = (ImageIcon)IlrUIPreferences.getIcon("ui.DefaultBusinessModel.Method.icon");
else
imageicon = (ImageIcon)IlrUIPreferences.getIcon("ui.Default.icon");
if(imageicon != null && !flag)
{
java.awt.image.FilteredImageSource filteredimagesource = new java.awt.image.FilteredImageSource(imageicon.getImage().getSource(), IlrObjectTokenTreeChooser.TRANSP_FILTER);
java.awt.Image image = java.awt.Toolkit.getDefaultToolkit().createImage(filteredimagesource);
imageicon = new ImageIcon(image);
}
return imageicon;
}

private TreeCellRenderer()
{
}

}


public IlrObjectTokenTreeChooser()
{
needReset = false;
sortEnabled = true;
init();
}

protected void init()
{
classNodes = new ArrayList();
variableNodes = new ArrayList();
memberNodes = new HashMap();
choiceIndexes = new ArrayList();
nodes = new HashMap();
sortEnabled = IlrPreferences.getBoolean("ui.editor.SyntacticEditor.tokenActionManager.Member.sortEnabled", true);
}

protected void clear()
{
classNodes.clear();
variableNodes.clear();
memberNodes.clear();
choiceIndexes.clear();
nodes.clear();
}

public JComponent getJComponent()
{
JTree jtree = getJTree();
registerActions();
IlrScrollPane ilrscrollpane = new IlrScrollPane(jtree);
ilrscrollpane.setRequestFocusEnabled(false);
ilrscrollpane.getVerticalScrollBar().setRequestFocusEnabled(false);
ilrscrollpane.getHorizontalScrollBar().setRequestFocusEnabled(false);
return ilrscrollpane;
}


public void setSelectedObject(Object obj)
{
//System.out.println("treepath obj="+obj);
DefaultMutableTreeNode defaultmutabletreenode = (DefaultMutableTreeNode)nodes.get(obj);
if(defaultmutabletreenode != null)
{
TreePath treepath = new TreePath(defaultmutabletreenode.getPath());
getJTree().expandPath(treepath);
getJTree().setSelectionPath(treepath);
}
}

public Object getSelectedObject()
{
TreePath treepath = tree.getSelectionPath();
if(treepath == null)
return null;
DefaultMutableTreeNode defaultmutabletreenode = (DefaultMutableTreeNode)treepath.getLastPathComponent();
Object obj = defaultmutabletreenode.getUserObject();
if(choiceIndexes.indexOf(obj) != -1)
return obj;
else
return null;
}

public int getSelectedIndex()
{
Object obj = getSelectedObject();
if(obj != null)
return choiceIndexes.indexOf(obj);
else
return -1;
}

public void setObjectTokenActionManager(IlrObjectTokenActionManager ilrobjecttokenactionmanager)
{
actionManager = ilrobjecttokenactionmanager;
}

public boolean isEmpty()
{
return nodes.size() == 0;
}

public boolean isEnabled()
{
IlrChoicesProvider ilrchoicesprovider = getObjectToken().getChoicesProvider();
if(ilrchoicesprovider instanceof IlrBOMChoicesProvider)
return true;
if(ilrchoicesprovider instanceof IlrMergedChoices)
return !isStaticChoices(ilrchoicesprovider);
else
return false;
}

public ilog.rules.brl.IlrFormatToken.ObjectToken getObjectToken()
{
return objectToken;
}

public void setObjectToken(ilog.rules.brl.IlrFormatToken.ObjectToken objecttoken)
{
ilog.rules.brl.IlrFormatToken.ObjectToken objecttoken1 = objectToken;
objectToken = objecttoken;
if(objecttoken1 != objecttoken)
needReset = true;
}


//¹ÚÇ×¼® Ãß°¡
public void setObjectToken(ilog.rules.brl.IlrFormatToken.ObjectToken objecttoken, String as[])
{
ilog.rules.brl.IlrFormatToken.ObjectToken objecttoken1 = objectToken;
objectToken = objecttoken;
searchconditon= as;
if(objecttoken1 != objecttoken)
needReset = true;
}

public void reset()
{
if(needReset)
{
clear();
makeTreeModel();
needReset = false;
}
}

private boolean isStaticChoices(IlrChoicesProvider ilrchoicesprovider)
{
if(ilrchoicesprovider instanceof IlrGrammarChoices)
{
IlrGrammarChoices ilrgrammarchoices = (IlrGrammarChoices)ilrchoicesprovider;
if(ilrgrammarchoices.getSubChoicesCount() == 0)
return true;
boolean flag = true;
for(int i = 0; i < ilrgrammarchoices.getSubChoicesCount(); i++)
flag &= isStaticChoices(ilrgrammarchoices.getSubChoices(i));

return flag;
} else
{
return false;
}
}

private void registerActions()
{
getJTree().addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent mouseevent)
{
boolean flag = (mouseevent.getModifiers() & 0x10) != 0;
boolean flag1 = (mouseevent.getModifiers() & 8) != 0;
boolean flag2 = (mouseevent.getModifiers() & 4) != 0;
if(flag && !flag1 && !flag2 && getSelectedIndex() != -1)
chooserValidated();
}

});
}

private JTree getJTree()
{
if(tree == null)
tree = makeJTree();
return tree;
}


protected JTree makeJTree()
{
//System.out.println("makeJTree++++++++++++++++++++++++++++++++++++");
ChoiceTree choicetree = new ChoiceTree(treeModel);
choicetree.setCellRenderer(new TreeCellRenderer());
choicetree.getSelectionModel().setSelectionMode(1);
choicetree.setRootVisible(false);
choicetree.putClientProperty("JTree.lineStyle", "None");
choicetree.setShowsRootHandles(true);
choicetree.setScrollsOnExpand(true);
choicetree.addMouseMotionListener(new TreeMouseMotionHandler());
choicetree.setScrollsOnExpand(true);
choicetree.setAutoscrolls(true);
return choicetree;
}

private void makeTreeModel()
{
treeModel = new DefaultTreeModel(makeTopNode());
populate();
if(tree != null)
tree.setModel(treeModel);
}

private IlrGrammarTokenModel getTokenModel()
{
return (IlrGrammarTokenModel)getObjectToken().getTokenModel();
}

private void populate()
{
clear();
IlrChoicesProvider ilrchoicesprovider = getObjectToken().getChoicesProvider();
String as[] = ilrchoicesprovider.getChoicesText();
int i = as == null ? 0 : as.length;
ilrchoicesprovider.updateChoices();
Collection collection = ilrchoicesprovider.getChoiceObjects();
/*
Collection collection2=null;
if(searchconditon!=null){
for(Iterator iterator2 = collection.iterator(); iterator2.hasNext();){
Object obj2 = iterator2.next();
for(int ii=0; ii String objstring = obj2.toString();
System.out.println("objstring=["+objstring+"]");
if(objstring.indexOf(searchconditon[ii])!=-1){
collection2.add(obj2);
break;
}
}
}
}
*/

int j = 0;
for(Iterator iterator = collection.iterator(); iterator.hasNext();)
{
Object obj = iterator.next();
TreeNode treenode = null;
if(obj instanceof IlrClass)
treenode = addClassChoiceNode(j, (IlrClass)obj, ilrchoicesprovider);
else
if(obj instanceof IlrMember)
treenode = addMemberChoiceNode(j, (IlrMember)obj, ilrchoicesprovider);
else
if(obj instanceof IlrVariable)
treenode = addVariableChoiceNode(j, (IlrVariable)obj, ilrchoicesprovider);
else
if(obj instanceof IlrGrammarChoices)
treenode = addGrammarChoiceNode(j, (IlrGrammarChoices)obj, ilrchoicesprovider);
if(treenode != null)
choiceIndexes.add(j, obj);
else
choiceIndexes.add(j, null);
j++;
}

TreeNodeComparator treenodecomparator = new TreeNodeComparator(ilrchoicesprovider);
if(sortEnabled)
Collections.sort(variableNodes, treenodecomparator);
for(int k = 0; k < variableNodes.size(); k++)
{
MutableTreeNode mutabletreenode = (MutableTreeNode)variableNodes.get(k);
((DefaultMutableTreeNode)treeModel.getRoot()).add(mutabletreenode);
}

if(sortEnabled)
Collections.sort(classNodes, treenodecomparator);
for(int l = 0; l < classNodes.size(); l++)
{
DefaultMutableTreeNode defaultmutabletreenode = (DefaultMutableTreeNode)classNodes.get(l);
((DefaultMutableTreeNode)treeModel.getRoot()).add(defaultmutabletreenode);
List list = (List)memberNodes.get(defaultmutabletreenode);
if(list != null)
{
if(sortEnabled)
Collections.sort(list, treenodecomparator);
for(int i1 = 0; i1 < list.size(); i1++)
{
MutableTreeNode mutabletreenode1 = (MutableTreeNode)list.get(i1);
defaultmutabletreenode.add(mutabletreenode1);
}

}
}


}

protected void chooserValidated()
{
actionManager.chooserValidated(this);
}

protected TreeNode addClassChoiceNode(int i, IlrClass ilrclass, IlrChoicesProvider ilrchoicesprovider)
{
DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode(ilrclass);
classNodes.add(defaultmutabletreenode);
nodes.put(ilrclass, defaultmutabletreenode);
return defaultmutabletreenode;
}

protected TreeNode addMemberChoiceNode(int i, IlrMember ilrmember, IlrChoicesProvider ilrchoicesprovider)
{
DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode(ilrmember);
IlrClass ilrclass = ilrmember.getDeclaringClass();
DefaultMutableTreeNode defaultmutabletreenode1 = getClassNode(ilrclass);
Object obj = (List)memberNodes.get(defaultmutabletreenode1);
if(obj == null)
{
obj = new ArrayList();
memberNodes.put(defaultmutabletreenode1, obj);
}
((List) (obj)).add(defaultmutabletreenode);
nodes.put(ilrmember, defaultmutabletreenode);
return defaultmutabletreenode;
}

protected TreeNode addVariableChoiceNode(int i, IlrVariable ilrvariable, IlrChoicesProvider ilrchoicesprovider)
{
DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode(ilrvariable);
variableNodes.add(defaultmutabletreenode);
nodes.put(ilrvariable, defaultmutabletreenode);
return defaultmutabletreenode;
}

protected TreeNode addGrammarChoiceNode(int i, IlrGrammarChoices ilrgrammarchoices, IlrChoicesProvider ilrchoicesprovider)
{
boolean flag = true;
String s = getTokenModel().getMessage(ilrgrammarchoices.makeMenuText());
//System.out.println("getTokenModel().getMessage(ilrgrammarchoices.makeMenuText())="+s);
String as[] = objectToken.getDisplayChoices();

for(int j = 0; j < as.length; j++)
{
if(!as[j].equals(s))
continue;
flag = false;
break;
}

if(flag)
{
return null;
} else
{
DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode(ilrgrammarchoices);
DefaultMutableTreeNode defaultmutabletreenode1 = (DefaultMutableTreeNode)treeModel.getRoot();
defaultmutabletreenode1.add(defaultmutabletreenode);
nodes.put(ilrgrammarchoices, defaultmutabletreenode);
return defaultmutabletreenode;
}
}

private DefaultMutableTreeNode getClassNode(IlrClass ilrclass)
{
DefaultMutableTreeNode defaultmutabletreenode = (DefaultMutableTreeNode)nodes.get(ilrclass);
if(defaultmutabletreenode != null)
return defaultmutabletreenode;
for(int i = 0; i < classNodes.size(); i++)
{
defaultmutabletreenode = (DefaultMutableTreeNode)classNodes.get(i);
Object obj = defaultmutabletreenode.getUserObject();
if(obj != null && obj.equals(ilrclass))
{
nodes.put(ilrclass, defaultmutabletreenode);
return defaultmutabletreenode;
}
}

defaultmutabletreenode = new DefaultMutableTreeNode(ilrclass);
classNodes.add(defaultmutabletreenode);
nodes.put(ilrclass, defaultmutabletreenode);
return defaultmutabletreenode;
}

private TreeNode makeTopNode()
{
String s = getObjectToken().getText();
if(s == null){
s = getObjectToken().getEmptyText();
// if(s!=null){
// System.out.println("getObjectToken().getEmptyText()="+s);
//}
}
return new DefaultMutableTreeNode(getTokenModel().getMessage(s));
}

private String getMessage(String s)
{
return getTokenModel().getMessage(s);
}

private String getDefaultAlternate(Object obj)
{
IlrBOMTokenObjectModel ilrbomtokenobjectmodel = getTokenModel().getTokenObjectModel();
if(obj instanceof IlrClass)
{
IlrClass ilrclass = (IlrClass)obj;
return getMessage(ilrbomtokenobjectmodel.getClassLabel(ilrclass));
}
if(obj instanceof IlrMember)
{
IlrMember ilrmember = (IlrMember)obj;
return getMessage(ilrbomtokenobjectmodel.getMemberFormat(ilrmember));
}
if(obj instanceof IlrVariable)
{
IlrVariable ilrvariable = (IlrVariable)obj;
String s = ilrvariable.getVariableAlternate();
if(s == null)
s = ilrvariable.getVariableName();
return getMessage(s);
}
if(obj instanceof IlrGrammarChoices)
{
IlrGrammarChoices ilrgrammarchoices = (IlrGrammarChoices)obj;
return getMessage(ilrgrammarchoices.makeMenuText());
} else
{
return obj.toString();
}
}

private Object getChoiceAt(int i)
{
return getObjectToken().getChoicesProvider().getChoiceObject(i);
}

private String getAnnotation(Object obj)
{
if(choiceIndexes.contains(obj) && (obj instanceof IlrElement))
{
IlrElement ilrelement = (IlrElement)obj;
ilog.rules.repository.model.IlrProperty ilrproperty = ilrelement.getProperty("annotation");
return getTokenModel().getMessage((String)ilrelement.getValue(ilrproperty));
} else
{
return null;
}
}

//¹ÚÇ×¼® Ãß°¡
private String searchconditon[];
private JTree tree;
private ilog.rules.brl.IlrFormatToken.ObjectToken objectToken;
private IlrObjectTokenActionManager actionManager;
private HashMap nodes;
private TreeModel treeModel;
private ArrayList choiceIndexes;
private boolean needReset;
private List classNodes;
private List variableNodes;
private Map memberNodes;
private boolean sortEnabled;
private static final java.awt.image.ImageFilter TRANSP_FILTER = new ilog.rules.ui.util.IlrUtils.TranspFilter();
private static final String SORT_ENABLED_PREF = "ui.editor.SyntacticEditor.tokenActionManager.Member.sortEnabled";







}




















// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)

package ilog.rules.ui.editor;

import ilog.rules.brl.*;
import ilog.rules.ui.util.IlrUIPreferences;
import ilog.rules.util.prefs.IlrMessages;
import ilog.rules.util.prefs.IlrPreferences;
import java.awt.*;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.lang.reflect.Constructor;
import java.util.*;
import javax.swing.Icon;
import javax.swing.OverlayLayout;
import javax.swing.event.DocumentEvent;
import javax.swing.text.*;

// Referenced classes of package ilog.rules.ui.editor:
// IlrTokenActionManager, IlrTokenComponent

public class IlrStyledTokenDocument extends DefaultStyledDocument implements
IlrTokenDocument {
private static class IlrTokenAttribute {

public String toString() {
return "token";
}

private IlrTokenAttribute() {
}

}

public IlrStyledTokenDocument(StyleContext stylecontext) {
super(stylecontext);
defaultTokenSeparator = " ";
defaultTokenTextBefore = "";
defaultTokenTextAfter = "";
defaultTabSize = 25;
defaultMinTextLength = 5;
tokenSeparator = defaultTokenSeparator;
tokenTextBefore = defaultTokenTextBefore;
tokenTextAfter = defaultTokenTextAfter;
tabSize = defaultTabSize;
minTextLength = defaultMinTextLength;
indentString = " ";
indentLength = indentString.length();
defaultStyle = null;
editableStyle = null;
editionStyle = null;
emptyStyle = null;
frozenStyle = null;
tokenElements = new Hashtable();
tokenNewlineElements = new Hashtable();
tokenComponentClassNames = new Hashtable();
tokenComponents = new Hashtable();
tokenActionManagerClassNames = new Hashtable();
tokenActionManagers = new Hashtable();
modificationEvent = true;
styleTable = new Hashtable();
resourcePrefix = "ui.editor.SyntacticEditor";
initialize();
}

public IlrStyledTokenDocument() {
defaultTokenSeparator = " ";
defaultTokenTextBefore = "";
defaultTokenTextAfter = "";
defaultTabSize = 25;
defaultMinTextLength = 5;
tokenSeparator = defaultTokenSeparator;
tokenTextBefore = defaultTokenTextBefore;
tokenTextAfter = defaultTokenTextAfter;
tabSize = defaultTabSize;
minTextLength = defaultMinTextLength;
indentString = " ";
indentLength = indentString.length();
defaultStyle = null;
editableStyle = null;
editionStyle = null;
emptyStyle = null;
frozenStyle = null;
tokenElements = new Hashtable();
tokenNewlineElements = new Hashtable();
tokenComponentClassNames = new Hashtable();
tokenComponents = new Hashtable();
tokenActionManagerClassNames = new Hashtable();
tokenActionManagers = new Hashtable();
modificationEvent = true;
styleTable = new Hashtable();
resourcePrefix = "ui.editor.SyntacticEditor";
initialize();
}

protected void initialize() {
initializeStyles();
registerTokenComponentClass("Icon",
"ilog.rules.ui.editor.IlrIconTokenComponent");
registerTokenComponentClass("Date",
"ilog.rules.ui.editor.IlrDateTokenComponent");
registerTokenActionManagerClass("Date",
"ilog.rules.ui.editor.IlrDateTokenActionManager");
registerTokenActionManagerClass("LibraryClass",
"ilog.rules.ui.editor.IlrLibraryClassTokenActionManager");
registerTokenActionManagerClass("LibraryClassMbr",
"ilog.rules.ui.editor.IlrLibraryClassMbrTokenActionManager");
registerTokenActionManagerClass("Day",
"ilog.rules.ui.editor.IlrDayTokenActionManager");
registerTokenActionManagerClass("Month",
"ilog.rules.ui.editor.IlrMonthTokenActionManager");
registerTokenActionManagerClass("SimpleDate",
"ilog.rules.ui.editor.IlrSimpleDateTokenActionManager");
String as[] = IlrPreferences.getStringArray(addPrefix(resourcePrefix,
"tokenActionManagerNames"));
if (as != null) {
for (int i = 0; i < as.length; i++) {
String s = as[i];
String s1 = IlrPreferences.getString(addPrefix(resourcePrefix,
"tokenActionManager." + s + ".class"));
if (s1 != null
&& IlrPreferences
.getBoolean(addPrefix(resourcePrefix,
"tokenActionManager." + s
+ ".activated"), true))
registerTokenActionManagerClass(s, s1);
}

}
if (tabs == null) {
tabs = new SimpleAttributeSet();
byte byte0 = 10;
TabStop atabstop[] = new TabStop[byte0];
for (int j = 0; j < byte0; j++)
atabstop[j] = new TabStop((j + 1) * tabSize);

TabSet tabset = new TabSet(atabstop);
StyleConstants.setTabSet(tabs, tabset);
}
if (isJdk13())
StyleConstants.setLineSpacing(tabs, 1.1F);
setParagraphAttributes(0, getLength(), tabs, false);
setLogicalStyle(0, defaultStyle);
}

public void updateResources() {
updateResourceStyles();
setTokenModelResources();
}

public void setResourcePrefix(String s) {
resourcePrefix = s;
}

private void setTokenModelResources() {
IlrTokenModel ilrtokenmodel = getTokenModel();
if (ilrtokenmodel != null)
ilrtokenmodel.updateResources();
}

private String readResourceString(String s, String s1) {
String s2 = IlrPreferences.getString(s);
if (s2 == null)
return s1;
else
return IlrMessages.unquote(s2);
}

private String addPrefix(String s, String s1) {
return s != null ? s + ''.'' + s1 : s1;
}

private Style resetStyle(String s) {
Style style = getStyle(s);
if (style != null) {
style.removeAttributes(style);
if (style instanceof javax.swing.text.StyleContext.NamedStyle)
((javax.swing.text.StyleContext.NamedStyle) style).setName(s);
} else {
style = addStyle(s, null);
}
return style;
}

protected void initializeStyles() {
defaultStyle = resetStyle("default");
editableStyle = resetStyle("editable");
editionStyle = resetStyle("edition");
emptyStyle = resetStyle("empty");
frozenStyle = resetStyle("frozen");
StyleConstants.setFontFamily(defaultStyle, "SansSerif");
StyleConstants.setFontSize(defaultStyle, fontSize);
StyleConstants.setUnderline(editableStyle, true);
StyleConstants.setForeground(editableStyle, Color.blue);
StyleConstants.setItalic(emptyStyle, true);
StyleConstants.setBackground(editionStyle, EditableBackground);
StyleConstants.setForeground(frozenStyle, FrozenTextForeground);
}

public void updateResources(String s) {
tokenSeparator = readResourceString(addPrefix(s, "tokenSeparator"),
defaultTokenSeparator);
tokenTextBefore = readResourceString(addPrefix(s, "tokenTextBefore"),
defaultTokenTextBefore);
tokenTextAfter = readResourceString(addPrefix(s, "tokenTextAfter"),
defaultTokenTextAfter);
minTextLength = IlrPreferences.getInt(addPrefix(s, "minTextLength"),
defaultMinTextLength);
tabSize = IlrPreferences
.getInt(addPrefix(s, "tabSize"), defaultTabSize);
}

public void updateResourceStyles() {
initializeStyles();
updateResourceStyles(resourcePrefix);
if (tokenModel != null && tokenModel.getName() != null)
updateResourceStyles(addPrefix(resourcePrefix, tokenModel.getName()));
}

protected void updateResourceStyles(String s) {
updateResources(s);
String as[] = IlrPreferences.getStringArray(addPrefix(s, "styles"));
if (as != null) {
for (int i = 0; i < as.length; i++) {
Style style = getStyle(as[i]);
if (style == null)
style = addStyle(as[i], getDefaultStyle());
if (s == null)
IlrUIPreferences.updateStyle(style);
else
IlrUIPreferences.updateStyle(s, style);
}

}
}

public void setTokenModel(IlrTokenModel ilrtokenmodel) {
if (tokenModel != ilrtokenmodel) {
tokenModel = ilrtokenmodel;
updateResourceStyles();
if (ilrtokenmodel != null)
setTokenModelResources();
}
}

public IlrTokenModel getTokenModel() {
return tokenModel;
}

public ilog.rules.brl.IlrToken.Token getRootToken() {
return tokenModel != null ? tokenModel.getRootToken() : null;
}

public IlrTokenActionManager getTokenActionManager(
ilog.rules.brl.IlrToken.Token token) {
if (token == null)
return null;
IlrTokenActionManager ilrtokenactionmanager = (IlrTokenActionManager) tokenActionManagers
.get(token);
if (ilrtokenactionmanager == null)
ilrtokenactionmanager = makeTokenActionManager(token);
return ilrtokenactionmanager;
}

protected IlrTokenActionManager makeTokenActionManager(
ilog.rules.brl.IlrToken.Token token) {
if (token instanceof ilog.rules.brl.IlrToken.TextToken) {
ilog.rules.brl.IlrToken.TextToken texttoken = (ilog.rules.brl.IlrToken.TextToken) token;
String s = null;
IlrTokenModel ilrtokenmodel = getTokenModel();
if (ilrtokenmodel == null)
return null;
String as[] = (String[]) ilrtokenmodel
.getTokenActionManagerProperty(texttoken);
if (as != null)
s = as[0];
if (s == null)
return null;
Class class1 = null;
String s1 = (String) tokenActionManagerClassNames.get(s);
try {
if (s1 != null)
class1 = Class.forName(s1);
} catch (ClassNotFoundException classnotfoundexception) {
Object aobj1[] = { s1 };
String s2 = IlrMessages.getMessage(
"ui.TokenActionManagerClassNotFound.text", aobj1);
System.err.println(s2);
return null;
}
if (class1 == null)
return null;
Object aobj[] = { texttoken };
Class aclass[] = { ilog.rules.brl.IlrToken.TextToken.class };
Object obj;
try {
Constructor constructor = class1.getConstructor(aclass);
obj = constructor.newInstance(aobj);
} catch (NoSuchMethodException nosuchmethodexception) {
Object aobj2[] = { class1.getName() };
String s3 = IlrMessages.getMessage(
"ui.TokenActionManagerBadCtor.text", aobj2);
System.err.println(s3);
return null;
} catch (Exception exception) {
PrintWriter printwriter = new PrintWriter(System.out, true);
exception.printStackTrace(printwriter);
return null;
}
IlrTokenActionManager ilrtokenactionmanager = (IlrTokenActionManager) obj;
tokenActionManagers.put(texttoken, ilrtokenactionmanager);
return ilrtokenactionmanager;
} else {
return null;
}
}

public IlrTokenComponent getTokenComponent(
ilog.rules.brl.IlrToken.Token token) {
if (token == null)
return null;
IlrTokenComponent ilrtokencomponent = (IlrTokenComponent) tokenComponents
.get(token);
if (ilrtokencomponent == null)
ilrtokencomponent = makeTokenComponent(token);
return ilrtokencomponent;
}

protected IlrTokenComponent makeTokenComponent(
ilog.rules.brl.IlrToken.Token token) {
if (token instanceof ilog.rules.brl.IlrToken.TextToken) {
ilog.rules.brl.IlrToken.TextToken texttoken = (ilog.rules.brl.IlrToken.TextToken) token;
String s = null;
String s1 = null;
IlrTokenModel ilrtokenmodel = getTokenModel();
if (ilrtokenmodel == null)
return null;
String as[] = (String[]) ilrtokenmodel
.getTokenComponentProperty(texttoken);
if (as != null) {
s = as[0];
s1 = as[1];
}
if (s == null)
return null;
Class class1 = null;
String s2 = (String) tokenComponentClassNames.get(s);
try {
if (s2 != null)
class1 = Class.forName(s2);
} catch (ClassNotFoundException classnotfoundexception) {
Object aobj1[] = { s2 };
String s3 = IlrMessages.getMessage(
"ui.TokenComponentClassNotFound.text", aobj1);
System.err.println(s3);
return null;
}
if (class1 == null)
return null;
Object aobj[] = { texttoken };
Class aclass[] = { ilog.rules.brl.IlrToken.TextToken.class };
Object obj;
try {
Constructor constructor = class1.getConstructor(aclass);
obj = constructor.newInstance(aobj);
} catch (NoSuchMethodException nosuchmethodexception) {
Object aobj2[] = { class1.getName() };
String s4 = IlrMessages.getMessage(
"ui.TokenComponentBadCtor.text", aobj2);
System.err.println(s4);
return null;
} catch (Exception exception) {
PrintWriter printwriter = new PrintWriter(System.err, true);
exception.printStackTrace(printwriter);
return null;
}
IlrTokenComponent ilrtokencomponent = (IlrTokenComponent) obj;
boolean flag = ilrtokencomponent.initTokenComponent(resourcePrefix,
s1);
if (!flag) {
return null;
} else {
tokenComponents.put(texttoken, ilrtokencomponent);
return (IlrTokenComponent) obj;
}
} else {
return null;
}
}

public void registerTokenComponentClass(String s, String s1) {
if (s == null) {
return;
} else {
tokenComponentClassNames.put(s, s1);
return;
}
}

public void registerTokenActionManagerClass(String s, String s1) {
if (s == null) {
return;
} else {
tokenActionManagerClassNames.put(s, s1);
return;
}
}

public void clear() {
tokenElements = new Hashtable();
tokenNewlineElements = new Hashtable();
tokenComponents = new Hashtable();
styleTable = new Hashtable();
try {
remove(0, getLength());
} catch (BadLocationException badlocationexception) {
}
}

public void refresh() {
setModificationEvent(false);
clear();
if (getRootToken() != null)
IlrToken.insertTokenInDocument(getRootToken(), this);
setModificationEvent(true);
}

public int getMinimumTextLength() {
return minTextLength;
}

public void setMinimumTextLength(int i) {
minTextLength = i;
}

public void setIndentString(String s) {
indentString = s;
indentLength = s.length();
}

public void setTokenSeparator(String s) {
tokenSeparator = s;
}

public void setTokenTextBefore(String s) {
tokenTextBefore = s;
}

public void setTokenTextAfter(String s) {
tokenTextAfter = s;
}

public Style getDefaultStyle() {
return defaultStyle;
}

public void setDefaultStyle(Style style) {
defaultStyle = style;
}

public Style getEditableStyle() {
return editableStyle;
}

public void setEditableStyle(Style style) {
editableStyle = style;
}

public Style getEditionStyle() {
return editionStyle;
}

public void setEditionStyle(Style style) {
editionStyle = style;
}

public Style getEmptyStyle() {
return emptyStyle;
}

public void setEmptyStyle(Style style) {
emptyStyle = style;
}

public Style getFrozenStyle() {
return frozenStyle;
}

public void setFrozenStyle(Style style) {
frozenStyle = style;
}

public StyleContext getStyleContext() {
javax.swing.text.AbstractDocument.AttributeContext attributecontext = getAttributeContext();
return (StyleContext) attributecontext;
}

public char getCharAt(int i) {
try {
String s = getText(i, 1);
return s.charAt(0);
} catch (BadLocationException badlocationexception) {
return ''\0'';
}
}

public char getNextCharAt(int i) {
try {
String s;
while ((s = getText(i, 1)).charAt(0) == '' '')
i++;
return s.charAt(0);
} catch (BadLocationException badlocationexception) {
return ''\0'';
}
}

public int getValidPosition(ilog.rules.brl.IlrToken.Token token, int i) {
int j = getEndOffset(token, false);
for (int k = i; k < j; k++) {
char c = getCharAt(k);
if (c != '' '')
return i;
}

int l = getStartOffset(token, false);
for (int i1 = i - 1; i1 >= l; i1--) {
char c1 = getCharAt(i1);
if (c1 != '' '')
return i1 + 1;
}

return l;
}

public int getFirstPosition(ilog.rules.brl.IlrToken.Token token) {
return getStartOffset(token, false);
}

public int getLastPosition(ilog.rules.brl.IlrToken.Token token) {
int i = getEndOffset(token, false);
int j = getStartOffset(token, false);
for (int k = i - 1; k >= j; k--) {
char c = getCharAt(k);
if (c != '' '')
return k + 1;
}

return j;
}

public void removeBlankChars(ilog.rules.brl.IlrToken.Token token) {
String s = getTokenElementText(token);
if (s != null) {
int i = s.length();
int j;
for (j = i - 1; j >= 0 && s.charAt(j) == '' ''; j--)
;
if (j < 0)
j = minTextLength - 1;
int k = j + 1;
int l = i - k;
if (l > 0)
try {
int i1 = getStartOffset(token, false);
remove(i1 + k, l);
} catch (BadLocationException badlocationexception) {
}
}
}

public String trimEnd(String s) {
if (s == null)
return null;
int i = s.length();
int j;
for (j = i; j > 0 && s.charAt(j - 1) == '' ''; j--)
;
return j != i ? j != 0 ? s.substring(0, j) : null : s;
}

public boolean isSeparator(char c) {
return !Character.isJavaIdentifierPart(c) && c != ''?'';
}

public int getWordStart(int i) {
int j;
for (j = i; j > 0 && !isSeparator(getCharAt(j - 1)); j--)
;
return j;
}

public int getWordEnd(int i) {
int j;
for (j = i; j < getLength() && !isSeparator(getCharAt(j)); j++)
;
return j;
}

public int getPreviousWordStart(int i) {
int j;
for (j = i; j > 0 && isSeparator(getCharAt(j - 1)); j--)
;
for (; j > 0 && !isSeparator(getCharAt(j - 1)); j--)
;
return j;
}

public int getNextWordStart(int i) {
int j;
for (j = i; j < getLength() && isSeparator(getCharAt(j)); j++)
;
for (; j < getLength() && !isSeparator(getCharAt(j)); j++)
;
for (; j < getLength() && isSeparator(getCharAt(j)); j++)
;
return j;
}

public int getNextWordEnd(int i) {
int j;
for (j = i; j < getLength() && isSeparator(getCharAt(j)); j++)
;
for (; j < getLength() && !isSeparator(getCharAt(j)); j++)
;
return j;
}

public String getTokenText(ilog.rules.brl.IlrToken.Token token) {
return trimEnd(getTokenElementText(token));
}

public void setTokenText(ilog.rules.brl.IlrToken.Token token, String s) {
IlrTokenComponent ilrtokencomponent = getTokenComponent(token);
if (ilrtokencomponent != null) {
if (s == null)
s = IlrToken.getTokenEmptyText(token);
ilrtokencomponent.setText(s);
} else {
if (s == null)
s = IlrToken.getTokenEmptyText(token);
setTokenElementText(token, s);
}
}

public String getTokenElementText(ilog.rules.brl.IlrToken.Token token) {
Element element = getTokenElement(token);
return element != null ? getElementText(element, token) : null;
}

public Icon getTokenElementIcon(ilog.rules.brl.IlrToken.Token token) {
Element element = getTokenElement(token);
return element != null ? getElementIcon(element, token) : null;
}

public void setTokenElementText(ilog.rules.brl.IlrToken.Token token,
String s) {
Element element = getTokenElement(token);
if (element != null)
setElementText(element, token, s);
}

public void updateTokenText(ilog.rules.brl.IlrToken.Token token) {
if ((token instanceof ilog.rules.brl.IlrToken.TextToken)
&& IlrToken.isAnEditableToken(token)) {
String s = getTokenText(token);
if (s != null) {
String s1 = IlrToken.getTokenEmptyText(token);
if (s1 != null && s1.equals(s))
s = null;
}
if (s != null && (token instanceof IlrLocalizedToken)) {
String s2 = ((IlrLocalizedToken) token).getPersistentString(s);
Object obj = ((IlrLocalizedToken) token).getLocalizedObject(s2);
if (obj != null) {
String s3 = obj.toString();
((ilog.rules.brl.IlrToken.TextToken) token).setText(s3);
if (!s.equals(s3))
setTokenText(token, s3);
} else {
((ilog.rules.brl.IlrToken.TextToken) token).setText(s);
}
} else {
((ilog.rules.brl.IlrToken.TextToken) token).setText(s);
}
}
}

protected boolean hasTokenSurroundingText(
ilog.rules.brl.IlrToken.Token token) {
return !IlrToken.isAnEditableToken(token)
&& IlrToken.getTokenIcon(token) == null;
}

protected String getElementText(Element element,
ilog.rules.brl.IlrToken.Token token) {
String s = null;
try {
int i = element.getStartOffset();
int j = element.getEndOffset();
if (hasTokenSurroundingText(token)) {
i += tokenTextBefore.length();
j -= tokenTextAfter.length();
}
s = getText(i, j - i);
} catch (BadLocationException badlocationexception) {
}
return s;
}

protected Icon getElementIcon(Element element,
ilog.rules.brl.IlrToken.Token token) {
AttributeSet attributeset = element.getAttributes();
return StyleConstants.getIcon(attributeset);
}

protected String setElementText(Element element,
ilog.rules.brl.IlrToken.Token token, String s) {
if (s == null)
s = "";
try {
int i = element.getStartOffset();
int j = element.getEndOffset();
if (hasTokenSurroundingText(token)) {
i += tokenTextBefore.length();
j -= tokenTextAfter.length();
}
insertString(j, s, element.getAttributes());
remove(i, j - i);
} catch (BadLocationException badlocationexception) {
}
return s;
}

protected Element getTokenElement(ilog.rules.brl.IlrToken.Token token) {
return (Element) tokenElements.get(token);
}

protected Element getTokenNewlineElement(ilog.rules.brl.IlrToken.Token token) {
return (Element) tokenNewlineElements.get(token);
}

public boolean contains(ilog.rules.brl.IlrToken.Token token) {
return getTokenElement(token) != null
|| getTokenNewlineElement(token) != null;
}

public ilog.rules.brl.IlrToken.Token getToken(int i) {
if (i >= 0 && i < getLength())
return getToken(getCharacterElement(i));
else
return null;
}

protected ilog.rules.brl.IlrToken.Token getToken(Element element) {
ilog.rules.brl.IlrToken.Token token = (ilog.rules.brl.IlrToken.Token) element
.getAttributes().getAttribute(TokenAttribute);
if (token == null)
token = (ilog.rules.brl.IlrToken.Token) element.getAttributes()
.getAttribute(TokenSeparatorAttribute);
return token;
}

public Vector getTokens(int i, int j) {
int k = Math.max(0, i);
int l = Math.min(getLength(), i + j);
Vector vector = new Vector();
Element element;
for (; k <= l; k = element.getEndOffset() + 1) {
element = getCharacterElement(k);
ilog.rules.brl.IlrToken.Token token = getToken(element);
if (token != null)
vector.addElement(token);
}

return vector;
}

public int getStartOffset(ilog.rules.brl.IlrToken.Token token, boolean flag) {
Element element = null;
if (flag) {
element = getTokenNewlineElement(token);
if (element != null)
return element.getStartOffset();
}
element = getTokenElement(token);
if (element != null)
return element.getStartOffset();
if (token instanceof ilog.rules.brl.IlrToken.ListToken) {
ilog.rules.brl.IlrToken.ListToken listtoken = (ilog.rules.brl.IlrToken.ListToken) token;
int i = listtoken.subTokensCount();
for (int j = 0; j < i; j++) {
int k = getStartOffset(listtoken.getSubToken(j), flag);
if (k >= 0)
return k;
}

}
return -1;
}

public int getEndOffset(ilog.rules.brl.IlrToken.Token token, boolean flag) {
if (token instanceof ilog.rules.brl.IlrToken.ListToken) {
ilog.rules.brl.IlrToken.ListToken listtoken = (ilog.rules.brl.IlrToken.ListToken) token;
int i = listtoken.subTokensCount();
for (int k = i - 1; k >= 0; k--) {
int l = getEndOffset(listtoken.getSubToken(k), flag);
if (l >= 0)
return l;
}

}
Element element = getTokenElement(token);
if (element != null) {
int j = element.getEndOffset();
return j;
}
if (flag) {
Element element1 = getTokenNewlineElement(token);
if (element1 != null)
return element1.getEndOffset() + token.getIndentCount()
* indentLength;
}
return -1;
}

public int getNextPosition(ilog.rules.brl.IlrToken.Token token) {
Element element = getTokenElement(token);
if (element != null)
return element.getEndOffset() + tokenSeparator.length();
element = getTokenNewlineElement(token);
if (element != null)
return element.getEndOffset() + token.getIndentCount()
* indentLength;
if (token instanceof ilog.rules.brl.IlrToken.ListToken) {
ilog.rules.brl.IlrToken.ListToken listtoken = (ilog.rules.brl.IlrToken.ListToken) token;
int i = listtoken.subTokensCount();
for (int j = i - 1; j >= 0; j--) {
int k = getEndOffset(listtoken.getSubToken(j), false);
if (k >= 0)
return k;
}

}
return -1;
}

public int getStartPosition(ilog.rules.brl.IlrToken.Token token) {
return getStartOffset(token, false);
}

public int getEndPosition(ilog.rules.brl.IlrToken.Token token) {
return getEndOffset(token, false);
}

public boolean isStartOfParagraph(int i) {
Element element = getParagraphElement(i);
return i == element.getStartOffset();
}

public boolean isEndOfParagraph(int i) {
Element element = getParagraphElement(i);
int j = element.getEndOffset();
return i == j || i == j - 1;
}

public void setEditionMode(boolean flag) {
if (tokenModel != null) {
setModificationEvent(false);
tokenModel.setEditable(flag);
setModificationEvent(true);
}
}

public void toggleEditionMode() {
if (tokenModel != null) {
setModificationEvent(false);
tokenModel.setEditable(!tokenModel.isEditable());
setModificationEvent(true);
}
}

public boolean isEditionMode() {
if (tokenModel != null)
return tokenModel.isEditable();
else
return false;
}

public void setTokenAttributes(ilog.rules.brl.IlrToken.Token token,
AttributeSet attributeset, boolean flag) {
setTokenAttributes(token, attributeset, flag, false);
}

private void setTokenAttributes(ilog.rules.brl.IlrToken.Token token,
AttributeSet attributeset, boolean flag, boolean flag1) {
if (IlrToken.hasComponent(token))
return;
Element element = getTokenElement(token);
if (element != null) {
int i = element.getStartOffset();
int k = element.getEndOffset();
if (i >= 0 && k >= 0) {
AttributeSet attributeset1 = attributeset;
if (flag)
attributeset1 = makeTokenAttributes(token, attributeset);
setCharacterAttributes(i, k - i, attributeset1, flag);
}
if (flag1) {
int j = k;
k += tokenSeparator.length();
if (j >= 0 && k >= 0) {
AttributeSet attributeset2 = attributeset;
if (flag)
attributeset2 = makeTokenSeparatorAttributes(token,
attributeset);
setCharacterAttributes(j, k - j, attributeset2, flag);
}
}
}
}

public AttributeSet getTokenAttributes(ilog.rules.brl.IlrToken.Token token) {
Element element = getTokenElement(token);
return element != null ? element.getAttributes() : null;
}

public Style getTokenStyle(ilog.rules.brl.IlrToken.Token token) {
String s = IlrToken.getTokenStyleName(token);
if (s != null) {
Style style = getStyle(s);
if (style != null)
return style;
}
return getDefaultStyle();
}

public void setTokenStyle(ilog.rules.brl.IlrToken.Token token, String s,
boolean flag) {
setTokenStyle(token, s, flag, false);
}

public void setTokenStyle(ilog.rules.brl.IlrToken.Token token, String s,
boolean flag, boolean flag1) {
Style style = getStyle(s);
if (style != null)
setTokenAttributes(token, style, flag, flag1);
}

public void resetTokenStyle(ilog.rules.brl.IlrToken.Token token) {
resetTokenStyle(token, false);
}

public void resetTokenStyle(ilog.rules.brl.IlrToken.Token token,
boolean flag) {
Style style = getTokenStyle(token);
if (style != null)
setTokenAttributes(token, style, true, flag);
updateTokenStyle(token, true, flag);
}

public void removeEmptyStyle(ilog.rules.brl.IlrToken.Token token) {
Style style = getTokenStyle(token);
if (style != null)
setTokenAttributes(token, style, true);
updateTokenStyle(token, false, false);
}

public void updateTokenStyle(ilog.rules.brl.IlrToken.Token token) {
updateTokenStyle(token, true, false);
}

private void updateTokenStyle(ilog.rules.brl.IlrToken.Token token,
boolean flag, boolean flag1) {
if (IlrToken.hasComponent(token))
return;
Element element = getTokenElement(token);
if (element != null) {
int i = element.getStartOffset();
int j = element.getEndOffset();
if (i >= 0 && j >= 0) {
if (token instanceof ilog.rules.brl.IlrToken.TextToken) {
ilog.rules.brl.IlrToken.TextToken texttoken = (ilog.rules.brl.IlrToken.TextToken) token;
if (IlrToken.isAnEditableToken(token)) {
if (editableStyle != null
&& IlrToken.isTokenEditable(texttoken))
setCharacterAttributes(i, j - i, editableStyle,
false);
} else if (frozenStyle != null && texttoken.isMetaToken()
&& texttoken.isFrozen())
setCharacterAttributes(i, j - i, frozenStyle, false);
if (flag && emptyStyle != null
&& texttoken.getIcon() == null
&& IlrToken.isTokenTextEmpty(token))
setCharacterAttributes(i, j - i, emptyStyle, false);
}
reapplyStyles(token, flag1);
}
}
}

public void addTokenStyle(Vector vector, String s) {
Style style = getStyle(s);
if (style == null)
return;
int i = vector.size();
if (i > 0) {
Vector vector1 = (Vector) styleTable.get(style);
if (vector1 == null) {
vector1 = new Vector(i);
styleTable.put(style, vector1);
}
for (int j = 0; j < i; j++) {
ilog.rules.brl.IlrToken.Token token = (ilog.rules.brl.IlrToken.Token) vector
.elementAt(j);
doAddTokenStyle(token, s, vector1, true, j == i - 1);
}

}
}

public void addTokenStyle(ilog.rules.brl.IlrToken.Token token, String s) {
Style style = getStyle(s);
if (style == null)
return;
Vector vector = (Vector) styleTable.get(style);
if (vector == null) {
vector = new Vector();
styleTable.put(style, vector);
}
doAddTokenStyle(token, s, vector, false, false);
}

public void clearStyle(String s) {
Style style = getStyle(s);
if (style == null)
return;
Vector vector = (Vector) styleTable.get(style);
if (vector != null) {
styleTable.remove(style);
for (int i = 0; i < vector.size(); i++) {
ilog.rules.brl.IlrToken.Token token = (ilog.rules.brl.IlrToken.Token) vector
.elementAt(i);
resetTokenStyle(token, true);
}

}
}

public void clearTokenStyle(Vector vector, String s) {
Style style = getStyle(s);
if (style == null)
return;
Vector vector1 = (Vector) styleTable.get(style);
if (vector1 != null) {
int i = vector.size();
for (int j = 0; j < i; j++) {
ilog.rules.brl.IlrToken.Token token = (ilog.rules.brl.IlrToken.Token) vector
.elementAt(j);
doClearTokenStyle(token, s, vector1, true, j == i - 1);
}

}
}

public void clearTokenStyle(ilog.rules.brl.IlrToken.Token token, String s) {
Style style = getStyle(s);
if (style == null)
return;
Vector vector = (Vector) styleTable.get(style);
if (vector != null)
doClearTokenStyle(token, s, vector, false, false);
}

private void doAddTokenStyle(ilog.rules.brl.IlrToken.Token token, String s,
Vector vector, boolean flag, boolean flag1) {
if (token instanceof ilog.rules.brl.IlrToken.TextToken) {
if (!vector.contains(token)) {
setTokenStyle(token, s, false, flag && !flag1);
vector.addElement(token);
}
} else if (token instanceof ilog.rules.brl.IlrToken.ListToken) {
ilog.rules.brl.IlrToken.ListToken listtoken = (ilog.rules.brl.IlrToken.ListToken) token;
int i = listtoken.subTokensCount();
for (int j = 0; j < i; j++)
doAddTokenStyle(listtoken.getSubToken(j), s, vector, flag,
flag1 && j == i - 1);

}
}

private void doClearTokenStyle(ilog.rules.brl.IlrToken.Token token,
String s, Vector vector, boolean flag, boolean flag1) {
if (token instanceof ilog.rules.brl.IlrToken.TextToken) {
if (vector.contains(token)) {
vector.removeElement(token);
resetTokenStyle(token, flag && !flag1);
}
} else if (token instanceof ilog.rules.brl.IlrToken.ListToken) {
ilog.rules.brl.IlrToken.ListToken listtoken = (ilog.rules.brl.IlrToken.ListToken) token;
int i = listtoken.subTokensCount();
for (int j = 0; j < i; j++)
doClearTokenStyle(listtoken.getSubToken(j), s, vector, flag,
flag1 && j == i - 1);

}
}

private void reapplyStyles(ilog.rules.brl.IlrToken.Token token, boolean flag) {
for (Enumeration enumeration = getStyleNames(); enumeration
.hasMoreElements();) {
String s = (String) enumeration.nextElement();
Style style = getStyle(s);
Vector vector = (Vector) styleTable.get(style);
if (vector != null && vector.contains(token))
setTokenStyle(token, s, false, flag);
}

}

public void updateEditable(ilog.rules.brl.IlrToken.Token token) {
resetTokenStyle(token, false);
}

public void updateEmpty(ilog.rules.brl.IlrToken.Token token) {
resetTokenStyle(token, false);
}

public void updateFrozen(ilog.rules.brl.IlrToken.Token token) {
resetTokenStyle(token, false);
}

protected Element createLeafElement(Element element,
AttributeSet attributeset, int i, int j) {
Element element1 = super.createLeafElement(element, attributeset, i, j);
ilog.rules.brl.IlrToken.Token token = (ilog.rules.brl.IlrToken.Token) attributeset
.getAttribute(TokenAttribute);
if (token != null)
tokenElements.put(token, element1);
token = (ilog.rules.brl.IlrToken.Token) attributeset
.getAttribute(TokenNewlineAttribute);
if (token != null)
tokenNewlineElements.put(token, element1);
return element1;
}

public void removeToken(ilog.rules.brl.IlrToken.Token token) {
Element element = getTokenElement(token);
if (element != null) {
tokenElements.remove(token);
int i = element.getStartOffset();
int j = element.getEndOffset() + tokenSeparator.length();
try {
remove(i, j - i);
} catch (BadLocationException badlocationexception) {
}
}
if (token.isNewline())
removeNewline(token);
}

public void removeTokenNewline(ilog.rules.brl.IlrToken.Token token) {
if (token.isNewline())
removeNewline(token);
}

public void addToken(ilog.rules.brl.IlrToken.Token token) {
insertToken(getLength(), token);
}

public int insertToken(int i, ilog.rules.brl.IlrToken.Token token) {
if (token.isNewline()) {
Style style = getTokenStyle(token);
i = insertNewline(i, token, style);
i = indent(i, token.getIndentCount(), style);
}
if (token instanceof ilog.rules.brl.IlrToken.TextToken)
i = insertTextToken(i, (ilog.rules.brl.IlrToken.TextToken) token);
return i;
}

private int insertTextToken(int i,
ilog.rules.brl.IlrToken.TextToken texttoken) {
Style style = getTokenStyle(texttoken);
IlrTokenComponent ilrtokencomponent = getTokenComponent(texttoken);
if (ilrtokencomponent != null
&& ilrtokencomponent.isPersistentComponent()) {
IlrTokenComponent ilrtokencomponent1 = ilrtokencomponent;
i = insertTokenComponent(i, texttoken, ilrtokencomponent1, style);
i = insertTokenSeparator(i, texttoken, defaultStyle);
updateTokenStyle(texttoken);
} else {
String s = texttoken.getDisplayText();
if (s == null)
s = texttoken.getDisplayEmptyText();
if (s != null) {
if (!texttoken.isEditableToken())
s = tokenTextBefore + s + tokenTextAfter;
i = insertTokenText(i, texttoken, s, style);
i = insertTokenSeparator(i, texttoken, defaultStyle);
updateTokenStyle(texttoken);
}
}
return i;
}

public int insertTokenNewline(int i, ilog.rules.brl.IlrToken.Token token) {
if (token.isNewline()) {
Style style = getTokenStyle(token);
i = insertNewline(i, token, style);
i = indent(i, token.getIndentCount(), style);
}
return i;
}

protected int insertNewline(int i, ilog.rules.brl.IlrToken.Token token,
AttributeSet attributeset) {
SimpleAttributeSet simpleattributeset = new SimpleAttributeSet(
attributeset);
simpleattributeset.addAttribute(TokenNewlineAttribute, token);
try {
insertString(i, "\n", simpleattributeset);
} catch (BadLocationException badlocationexception) {
}
return i + 1;
}

protected void removeNewline(ilog.rules.brl.IlrToken.Token token) {
Element element = (Element) tokenNewlineElements.get(token);
if (element != null) {
int i = element.getStartOffset();
int j = token.getIndentCount() * indentLength + 1;
try {
remove(i, j);
} catch (BadLocationException badlocationexception) {
}
tokenNewlineElements.remove(token);
}
}

public void updateIndentation(ilog.rules.brl.IlrToken.Token token) {
Element element = getTokenNewlineElement(token);
if (element != null) {
int i = token.getIndentCount();
int j = element.getEndOffset();
int k;
for (k = 0; getCharAt(j + k) == '' ''; k++)
;
k /= indentLength;
try {
if (k > i) {
int l = (k - i) * indentLength;
remove(j, l);
} else if (k < i) {
int i1 = (i - k) * indentLength;
insertString(j, IlrBRLUtil.makeString(i1, '' ''), null);
}
} catch (BadLocationException badlocationexception) {
}
}
}

protected int indent(int i, int j, AttributeSet attributeset) {
int k = j * indentLength;
StringBuffer stringbuffer = new StringBuffer(k);
for (int l = 0; l < k; l++)
stringbuffer.append('' '');

try {
insertString(i, stringbuffer.toString(), attributeset);
i += k;
} catch (BadLocationException badlocationexception) {
}
return i;
}

protected int newline(int i, AttributeSet attributeset) {
try {
insertString(i, "\n", attributeset);
i++;
} catch (BadLocationException badlocationexception) {
}
return i;
}

protected AttributeSet makeTokenAttributes(
ilog.rules.brl.IlrToken.Token token, AttributeSet attributeset) {
SimpleAttributeSet simpleattributeset = new SimpleAttributeSet(
attributeset);
simpleattributeset.addAttribute("$ename", "token");
simpleattributeset.addAttribute(TokenAttribute, token);
return simpleattributeset;
}

protected int insertTokenText(int i, ilog.rules.brl.IlrToken.Token token,
String s, AttributeSet attributeset) {
try {
AttributeSet attributeset1 = makeTokenAttributes(token,
attributeset);
insertString(i, s, attributeset1);
i += s.length();
} catch (BadLocationException badlocationexception) {
}
return i;
}

protected AttributeSet makeTokenSeparatorAttributes(
ilog.rules.brl.IlrToken.Token token, AttributeSet attributeset) {
SimpleAttributeSet simpleattributeset = new SimpleAttributeSet(
attributeset);
simpleattributeset.addAttribute(TokenSeparatorAttribute, token);
return simpleattributeset;
}

protected int insertTokenSeparator(int i,
ilog.rules.brl.IlrToken.Token token, AttributeSet attributeset) {
try {
AttributeSet attributeset1 = makeTokenSeparatorAttributes(token,
attributeset);
insertString(i, tokenSeparator, attributeset1);
i += tokenSeparator.length();
} catch (BadLocationException badlocationexception) {
}
return i;
}

protected int insertTokenComponent(int i,
ilog.rules.brl.IlrToken.Token token,
IlrTokenComponent ilrtokencomponent, AttributeSet attributeset) {
try {
SimpleAttributeSet simpleattributeset = new SimpleAttributeSet(
attributeset);
simpleattributeset.addAttribute("$ename", "token");
simpleattributeset.addAttribute(TokenAttribute, token);
if (!ilrtokencomponent.isIconComponent())
insertComponent(i, ilrtokencomponent.getComponent(),
simpleattributeset);
else
insertIcon(i, ilrtokencomponent.getIcon(), simpleattributeset);
i++;
} catch (BadLocationException badlocationexception) {
}
return i;
}

protected int insertTokenIcon(int i, ilog.rules.brl.IlrToken.Token token,
Icon icon, AttributeSet attributeset) {
try {
SimpleAttributeSet simpleattributeset = new SimpleAttributeSet(
attributeset);
simpleattributeset.addAttribute("$ename", "token");
simpleattributeset.addAttribute(TokenAttribute, token);
insertIcon(i, icon, simpleattributeset);
i++;
} catch (BadLocationException badlocationexception) {
}
return i;
}

public void insertIcon(int i, Icon icon, AttributeSet attributeset)
throws BadLocationException {
SimpleAttributeSet simpleattributeset = new SimpleAttributeSet(
attributeset);
StyleConstants.setIcon(simpleattributeset, icon);
insertString(i, " ", simpleattributeset);
}

private boolean isJdk13() {
String s = System.getProperty("java.version", "");
return s.compareTo("1.3.0") >= 0 && s.compareTo("1.4.0") < 0;
}

private boolean isJdk14() {
String s = System.getProperty("java.version", "");
return s.compareTo("1.4.0") >= 0;
}

private void invalidateComponentLayout(Component component) {
java.awt.LayoutManager layoutmanager = component.getParent()
.getLayout();
if (layoutmanager instanceof OverlayLayout) {
OverlayLayout overlaylayout = (OverlayLayout) layoutmanager;
overlaylayout.invalidateLayout(component.getParent());
}
}

public void insertComponent(int i, Component component,
AttributeSet attributeset) throws BadLocationException {
SimpleAttributeSet simpleattributeset = new SimpleAttributeSet(
attributeset);
StyleConstants.setComponent(simpleattributeset, component);
insertString(i, " ", simpleattributeset);
invalidateComponentLayout(component);
}

public void removeComponent(int i) throws BadLocationException {
remove(i, 1);
}

public Color getBackground(AttributeSet attributeset) {
Color color = (Color) attributeset
.getAttribute(StyleConstants.Background);
if (color == null)
color = Color.white;
return color;
}

public boolean deleteTokens(Vector vector) {
return applyToTokens(vector, 0, null);
}

public boolean removeTokens(Vector vector) {
return applyToTokens(IlrToken.findRemovableTokens(vector), 1, null);
}

public boolean cutTokens(Vector vector, Vector vector1) {
return applyToTokens(IlrToken.findRemovableTokens(vector), 2, vector1);
}

public boolean copyTokens(Vector vector, Vector vector1) {
return applyToTokens(IlrToken.findRemovableTokens(vector), 3, vector1);
}

private boolean applyToTokens(Vector vector, int i, Vector vector1) {
boolean flag = false;
if (vector != null) {
for (int j = 0; j < vector.size(); j++) {
ilog.rules.brl.IlrToken.Token token = (ilog.rules.brl.IlrToken.Token) vector
.elementAt(j);
if (vector1 != null)
vector1.addElement(IlrToken.copyToken(token));
flag = true;
}

if (i == 0 || i == 1 || i == 2)
if (IlrToken.canRemoveTokens(vector))
IlrToken.removeTokens(vector);
else
flag = false;
}
return flag;
}

public boolean canCopyTokens(Vector vector, Vector vector1) {
vector = IlrToken.findRemovableTokens(vector);
if (vector != null && vector.size() > 0) {
for (int i = 0; i < vector.size(); i++)
vector1.addElement(vector.elementAt(i));

return true;
} else {
return false;
}
}

public boolean canRemoveTokens(Vector vector) {
return IlrToken.canRemoveTokens(vector);
}

public boolean pasteTokens(int i, Vector vector) {
ilog.rules.brl.IlrToken.Token token = getToken(i);
if (token != null)
return IlrToken.pasteTokens(vector, token);
else
return false;
}

public boolean canPasteTokens(int i, Vector vector) {
ilog.rules.brl.IlrToken.Token token = getToken(i);
if (token != null)
return IlrToken.canPasteTokens(vector, token);
else
return false;
}

public boolean canInsertTokens(Vector vector) {
ilog.rules.brl.IlrToken.AbstractMultipleToken abstractmultipletoken = IlrToken
.findMultipleToken(vector);
if (abstractmultipletoken == null)
return false;
else
return canInsertInMultiple(abstractmultipletoken);
}

public boolean canInsertInMultiple(
ilog.rules.brl.IlrToken.AbstractMultipleToken abstractmultipletoken) {
return IlrToken.canGenerateTokens(abstractmultipletoken);
}

public void setModificationEvent(boolean flag) {
modificationEvent = flag;
}

public boolean isModificationEvent() {
return modificationEvent;
}

public static boolean isModificationEvent(DocumentEvent documentevent) {
javax.swing.text.Document document = documentevent.getDocument();
if (document instanceof IlrStyledTokenDocument)
return ((IlrStyledTokenDocument) document).isModificationEvent();
else
return true;
}

public static Color EditableBackground = new Color(230, 230, 230);

public static Color FrozenTextForeground = new Color(130, 130, 130);

private static MutableAttributeSet tabs;

private static final IlrTokenAttribute TokenAttribute = new IlrTokenAttribute();

private static final IlrTokenAttribute TokenSeparatorAttribute = new IlrTokenAttribute();

private static final IlrTokenAttribute TokenNewlineAttribute = new IlrTokenAttribute();

private static final String TokenElementName = "token";

private String defaultTokenSeparator;

private String defaultTokenTextBefore;

private String defaultTokenTextAfter;

private int defaultTabSize;

private int defaultMinTextLength;

private String tokenSeparator;

private String tokenTextBefore;

private String tokenTextAfter;

private int tabSize;

private int minTextLength;

private String indentString;

private int indentLength;

private Style defaultStyle;

private Style editableStyle;

private Style editionStyle;

private Style emptyStyle;

private Style frozenStyle;

private Hashtable tokenElements;

private Hashtable tokenNewlineElements;

private Hashtable tokenComponentClassNames;

private Hashtable tokenComponents;

private Hashtable tokenActionManagerClassNames;

private Hashtable tokenActionManagers;

private IlrTokenModel tokenModel;

private boolean modificationEvent;

private static int fontSize = 12;

private Hashtable styleTable;

private String resourcePrefix;

private static final int DELETE = 0;

private static final int REMOVE = 1;

private static final int CUT = 2;

private static final int COPY = 3;

}




















// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)

package ilog.rules.ui.editor;

import ilog.rules.brl.IlrChoicesProvider;
import ilog.rules.brl.IlrToken;
import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.MouseEvent;
import java.awt.im.InputContext;
import java.io.PrintStream;
import java.util.Collection;
import java.util.Iterator;
import java.util.Vector;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.plaf.TextUI;
import javax.swing.text.*;

// Referenced classes of package ilog.rules.ui.editor:
// IlrSyntacticEditorPane, IlrStyledTokenDocument, IlrTokenComponent

public class IlrSyntacticEditorCaret extends DefaultCaret
{
private class ComponentHighlighter extends DefaultHighlighter
{

private void select(int i, int j)
{
if(j <= i)
return;
Rectangle rectangle = null;
Vector vector = pane.getTokenDocument().getTokens(i, j - i);
if(vector != null)
{
for(int k = 0; k < vector.size(); k++)
{
ilog.rules.brl.IlrToken.Token token = (ilog.rules.brl.IlrToken.Token)vector.elementAt(k);
if(IlrToken.hasComponent(token))
{
IlrTokenComponent ilrtokencomponent = pane.getTokenDocument().getTokenComponent(token);
if(ilrtokencomponent != null && ilrtokencomponent.isPersistentComponent())
{
if(rectangle == null)
{
rectangle = pane.getTokenRect(token);
} else
{
Rectangle rectangle1 = pane.getTokenRect(token);
if(rectangle1 != null)
rectangle = rectangle.union(rectangle1);
}
ilrtokencomponent.setSelected(pane.getTokenRect(token), pane.getSelectionColor());
selectedComponents.add(ilrtokencomponent);
}
}
}

}
pane.repaint();
}

private void unSelect()
{
for(int i = 0; i < selectedComponents.size(); i++)
{
IlrTokenComponent ilrtokencomponent = (IlrTokenComponent)selectedComponents.elementAt(i);
ilrtokencomponent.unSelect();
}

selectedComponents.removeAllElements();
}

public Object addHighlight(int i, int j, javax.swing.text.Highlighter.HighlightPainter highlightpainter)
throws BadLocationException
{
select(i, j);
return super.addHighlight(i, j, highlightpainter);
}

public void changeHighlight(Object obj, int i, int j)
throws BadLocationException
{
select(i, j);
super.changeHighlight(obj, i, j);
}

public void removeHighlight(Object obj)
{
unSelect();
super.removeHighlight(obj);
}

public void removeAllHighlights()
{
unSelect();
super.removeAllHighlights();
}

private Vector selectedComponents;

public ComponentHighlighter()
{
selectedComponents = new Vector();
}
}

private class DoSetCaretPosition
implements Runnable
{

public void run()
{
setPosition(newPos.getOffset(), false);
selectionStart = getDot();
setMagicCaretPosition(null);
}

JTextComponent pane;
Position newPos;

DoSetCaretPosition(JTextComponent jtextcomponent, Position position)
{
pane = jtextcomponent;
newPos = position;
}
}


public IlrSyntacticEditorCaret()
{
selectionEnabled = true;
mousePressed = false;
mouseDragged = false;
composing = false;
setBlinkRate(500);
setVisible(false);
}

public void install(JTextComponent jtextcomponent)
{
super.install(jtextcomponent);
setSelectionVisible(true);
pane = (IlrSyntacticEditorPane)jtextcomponent;
pane.setHighlighter(new ComponentHighlighter());
}

public void enableSelection()
{
selectionEnabled = true;
}

public void disableSelection()
{
selectionEnabled = false;
caretToken = null;
hideSelection();
}

public void hideSelection()
{
setDot(getDot());
}

public boolean inSelection(int i)
{
int j = Math.min(getDot(), getMark());
int k = Math.max(getDot(), getMark());
return i >= j && i < k;
}

public boolean hasSelectedTokens()
{
return selection != null && selection.size() != 0;
}

public Vector getSelectedTokens()
{
return selection;
}

public ilog.rules.brl.IlrToken.Token getToken(MouseEvent mouseevent)
{
Point point = new Point(mouseevent.getX(), mouseevent.getY());
int i = pane.getUI().viewToModel(pane, point);
return pane.getToken(i);
}

static Cursor getDefaultCursor()
{
return Cursor.getDefaultCursor();
}

static Cursor getTextCursor()
{
return textCursor;
}

public void updateCursor()
{
if(mouseToken != null && pane.isEditedToken(mouseToken)){
pane.setCursor(getTextCursor());
}else{
pane.setCursor(getDefaultCursor());
}
}

public void updatePosition(boolean flag)
{
setPosition(getDot(), flag);
}

public void setPosition(int i, boolean flag)
{
if(hasSelectedTokens())
{
selection = null;
pane.setCurrentToken(null, false);
}
ilog.rules.brl.IlrToken.Token token = pane.getEditedToken();
if(selectionEnabled)
{
caretToken = pane.getToken(i);
if(caretToken == null || caretToken != pane.getCurrentToken()){
setDot(i);
}
pane.setCurrentToken(caretToken, flag);
if(caretToken != null && caretToken == token)
{
IlrStyledTokenDocument ilrstyledtokendocument = pane.getTokenDocument();
setDot(ilrstyledtokendocument.getValidPosition(caretToken, i));
}
updateCursor();
}
}

public boolean isComposing()
{
return composing;
}

public void isComposing(boolean flag)
{
composing = flag;
}

protected void positionCaret(MouseEvent mouseevent)
{

Point point = new Point(mouseevent.getX(), mouseevent.getY());
int i = pane.getUI().viewToModel(pane, point);
if(i >= 0)
if(isComposing() && !pane.isInCompositionArea(i))
{
isComposing(false);
try
{
Position position = pane.getDocument().createPosition(i);
pane.getInputContext().endComposition();
EventQueue.invokeLater(new DoSetCaretPosition(pane, position));
}
catch(BadLocationException badlocationexception)
{
System.err.println(badlocationexception);
}
} else
{
setPosition(i, false);
selectionStart = getDot();
setMagicCaretPosition(null);
}
}

protected void moveCaret(MouseEvent mouseevent)
{

if(!selectionEnabled)
return;
Point point = new Point(mouseevent.getX(), mouseevent.getY());
int i = pane.getUI().viewToModel(pane, point);
if(i >= 0)
{
int j = Math.min(selectionStart, i);
int k = Math.max(selectionStart, i);
int l = k - j;
if(pane.isEditing())
{
if(i < selectionStart)
i = Math.max(i, pane.getEditionStartOffset());
else
if(i > selectionStart)
i = Math.min(i, pane.getEditionEndOffset());
setDot(selectionStart);
moveDot(i);
setVisible(true);
selection = null;
} else
{
Vector vector = pane.getTokenDocument().getTokens(j, l);
if(vector.size() == 1 && vector.firstElement() == caretToken && inSelection(i))
{
pane.setCurrentToken(caretToken, false);
} else
{
pane.setCurrentToken(null, false);
vector = IlrToken.findSelectableTokens(vector);
if(vector != null && vector.size() > 0)
{
selection = vector;
pane.selectTokens(selection);
}
}
}
}
}

public void focusGained(FocusEvent focusevent)
{

pane.setFocus(true);
}

public void focusLost(FocusEvent focusevent)
{

if(!focusevent.isTemporary())
pane.setFocus(false);
}

public void mousePressed(MouseEvent mouseevent)
{
//¹ÚÇ×¼® Ãß°¡ - search a condition ¼±Åýà ¸Þ´º ¼±ÅÃÀ» ÇÏÁö ¾Ê°í ´Ù¸¥ ¸¶¿ì½º Æ÷ÀÎÆ®¸¦ Âï¾úÀ» ¶§¸¦ À§ÇØ
// ¹Ù·ÎÀü token °ªÀ» ÀúÀå
temptoken=null;
if(getsearchconditioncheck(pane.getCurrentToken())){
temptoken=pane.getCurrentToken();
}
mousePressed = true;
mouseDragged = false;
Point point = new Point(mouseevent.getX(), mouseevent.getY());
int i = pane.getUI().viewToModel(pane, point);
if(i >= 0)
{
if(getComponent() != null && getComponent().isEnabled()){
getComponent().requestFocus();
}
if(SwingUtilities.isLeftMouseButton(mouseevent)){
positionCaret(mouseevent);
}else{
if(SwingUtilities.isRightMouseButton(mouseevent) && !inSelection(i)){
positionCaret(mouseevent);
}
}
}
}

public void mouseReleased(MouseEvent mouseevent)
{
if(!mousePressed)
return;
if(SwingUtilities.isLeftMouseButton(mouseevent))
{
if(mouseevent.getClickCount() == 1)
{
boolean flag = false;
if(!mouseDragged)
{
flag = caretToken != null;
} else
{
if(temptoken!=null){
}
ilog.rules.brl.IlrToken.Token token = getToken(mouseevent);
flag = caretToken != null && token == caretToken;
}
if(flag){
String checksearch = pane.getTokenDocument().getTokenText(caretToken);
if(checksearch!=null && checksearch.equals("")){
pane.startEditing();
}else{
if(IlrToken.isTokenEditable(caretToken) && !pane.isEditedToken(caretToken)){
pane.startEditing();
}else{
pane.doTokenAction(caretToken, true);
}
}
updateCursor();
}else{
if(getsearchconditioncheck2(temptoken)){
if(pane != null && pane.isEditable() && pane.isEnabled()){
if(pane.isEditing()){
pane.undoTextAction();
}else{
pane.getTokenModel().undo();
}
}
temptoken=null;
}
}

}
} else
if(SwingUtilities.isRightMouseButton(mouseevent))
{
Point point = new Point(mouseevent.getX(), mouseevent.getY());
pane.showContextualMenu(point);
}
}



/*
* ¹ÚÇ×¼® »ý¼º
* Search a condition check
*/
public boolean getsearchconditioncheck(ilog.rules.brl.IlrToken.Token temptoken){
boolean checksearch = false;

if(temptoken instanceof ilog.rules.brl.IlrFormatToken.ObjectToken){
ilog.rules.brl.IlrFormatToken.ObjectToken objecttoken = (ilog.rules.brl.IlrFormatToken.ObjectToken)temptoken;
IlrChoicesProvider ilrchoicesprovider = objecttoken.getChoicesProvider();
String emptytext = objecttoken.getDisplayEmptyText();
Object obj = ilrchoicesprovider.getDefaultChoice();
if (emptytext!=null && emptytext.equals("") && obj==null && displaytext!=null && displaytext.equals("")){
checksearch=true;
}
}
return checksearch;
}


public void mouseClicked(MouseEvent mouseevent)
{
if(!mousePressed){
return;
}
mousePressed = false;
if(SwingUtilities.isLeftMouseButton(mouseevent)){
if(mouseevent.getClickCount() == 2)
{
if(caretToken != null && pane.isEditedToken(caretToken))
{
pane.selectWord(getDot());
pane.showPopupMenu(caretToken);
}
} else
if(mouseevent.getClickCount() == 3 && caretToken != null && pane.isEditedToken(caretToken)){
pane.selectTokenText(caretToken, true);
}
}
}

public void mouseDragged(MouseEvent mouseevent)
{
if(!mousePressed)
{
return;
} else
{
super.mouseDragged(mouseevent);
mouseDragged = true;
return;
}
}

public void mouseMoved(MouseEvent mouseevent)
{
if(!pane.hasFocus())
return;
pane.hideToolTip();
ilog.rules.brl.IlrToken.Token token = getToken(mouseevent);
if(token != mouseToken)
{
mouseToken = token;
if(mouseToken != null && IlrToken.isTokenActive(mouseToken)){
pane.setGhostToken(mouseToken);

}else{
pane.setGhostToken(null);

}
updateCursor();
}
}

public void mouseExited(MouseEvent mouseevent)
{
pane.setGhostToken(null);
super.mouseExited(mouseevent);
}


private ilog.rules.brl.IlrToken.Token temptoken; // ¹ÚÇ×¼® Ãß°¡ mouse event ¸¦ ¹Þ¾Æ¼­ search a condition ÀÏ °æ¿ì Àü tokenÀ» ÀúÀåÇϱâ À§ÇØ


private static Cursor textCursor = Cursor.getPredefinedCursor(2);
private IlrSyntacticEditorPane pane;
private boolean selectionEnabled;
private Vector selection;
private int selectionStart;
private boolean mousePressed;
private boolean mouseDragged;
private ilog.rules.brl.IlrToken.Token caretToken;
private ilog.rules.brl.IlrToken.Token mouseToken;
private boolean composing;



}




















// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)

package ilog.rules.ui.editor;



import ilog.rules.brl.IlrChoicesProvider;

import java.awt.*;
import java.awt.event.*;
import java.awt.font.TextHitInfo;
import java.awt.im.InputMethodRequests;
import java.text.*;
import javax.swing.KeyStroke;
import javax.swing.text.*;

// Referenced classes of package ilog.rules.ui.editor:
// IlrSyntacticEditorPane, IlrSyntacticEditorCaret

public class IlrSyntacticEditorInputMethod
implements InputMethodListener, InputMethodRequests
{

public IlrSyntacticEditorInputMethod(IlrSyntacticEditorPane ilrsyntacticeditorpane)
{
pane = null;
pane = ilrsyntacticeditorpane;


}

public boolean isInCompositionArea(int i)
{
return composedTextStart != null && i >= composedTextStart.getOffset() && i <= composedTextEnd.getOffset();
}

public void inputMethodTextChanged(InputMethodEvent inputmethodevent)
{
// ¹ÚÇ×¼® Ãß°¡ - ÇѱÛÀÇ °æ¿ì ÇѱÛÀÚ°¡ ¿Ï¼ºµÇ¾úÀ» ¶§ À̺¥Æ®¸¦ ¹ß»ý ½Ã۰í Àֱ⠶§¹®¿¡ Űº¸µå À̺¥Æ® ¹ß»ý½Ã À̺¥Æ®¸¦ ¹Ù·Î ¹Ù·Î ÁÖ°¡ À§ÇØ Ãß°¡
commitstate = false; //ÇÑ±Û ÇѱÛÀÚ°¡ ¿ÏÀüÀÌ ÀÔ·Â µÇ¾úÀ» ¶§¿Í ¾Æ´Ò¶§¸¦ ±¸º°ÇØ ÁÖ±â À§ÇØ

int i = inputmethodevent.getCommittedCharacterCount();
AttributedCharacterIterator attributedcharacteriterator = inputmethodevent.getText();
Document document = pane.getDocument();
if(composedTextStart != null)
{
try
{
int k = composedTextStart.getOffset();
document.remove(k, composedTextEnd.getOffset() - k);
}
catch(BadLocationException badlocationexception) { }
composedTextStart = composedTextEnd = null;
composedText = null;
composedTextContent = null;
}
if(attributedcharacteriterator != null)
{
attributedcharacteriterator.first();
if(i > 0)
{
setcharacterscommitted(true); //¹ÚÇ×¼® Ãß°¡ - ¿Ï¼ºÇü À̺¥Æ®½Ã true
StringBuffer stringbuffer = new StringBuffer();
char c = attributedcharacteriterator.current();
for(; i > 0; i--)
{
stringbuffer.append(c);
c = attributedcharacteriterator.next();
}
mapCommittedTextToAction(new String(stringbuffer));
}
int j = attributedcharacteriterator.getIndex();
if(j < attributedcharacteriterator.getEndIndex())
{
createComposedString(j, attributedcharacteriterator);
javax.swing.text.MutableAttributeSet mutableattributeset = pane.getInputAttributes();
try
{
pane.replaceSelection(null);
IlrSyntacticEditorCaret ilrsyntacticeditorcaret = pane.getSyntacticCaret();
ilrsyntacticeditorcaret.isComposing(true);
document.insertString(ilrsyntacticeditorcaret.getDot(), composedTextContent, mutableattributeset);
composedTextStart = document.createPosition(ilrsyntacticeditorcaret.getDot() - composedTextContent.length());
composedTextEnd = document.createPosition(ilrsyntacticeditorcaret.getDot());
}
catch(BadLocationException badlocationexception1)
{
composedTextStart = composedTextEnd = null;
composedText = null;
composedTextContent = null;
}
}
}

// ¹ÚÇ×¼® Ãß°¡ - Űº¸µå À̺¥Æ® ¹ß»ý½Ã ¹Ù·Î ¹Ù·Î À̺¥Æ®¸¦ Àü´ÞÇϱâ À§ÇØ Ãß°¡

if(getsearchconditioncheck(pane.getCurrentToken())){
String tempevent = inputmethodevent.paramString();
String tempeventchar = null;
if (tempevent!=null){
if(i==0){
String inputkeychar[] = tempevent.split(",");
String inputkeychar2 = inputkeychar[1];
String inputkeychar3 = null;
int k = inputkeychar2.indexOf("\"\" + \"");
if(k>0)
inputkeychar3= inputkeychar2.substring(7,8);
if(inputkeychar3!=null){
setcharacterscommitted(false);
mapCommittedTextToAction(inputkeychar3);
}
}
}
}
inputmethodevent.consume();
pane.repaint();
}


/*
*¹ÚÇ×¼® Ãß°¡ - bal46 textÀԷ½à select a condition ÀÏ °æ¿ì¸¦ üũ¸¦ ÇØÁØ´Ù.
*
* */
public boolean getCheckbal46(String s){
boolean checkbal46 = false;
if (s.equals("&ilog.rules.brl.bal46.T-test-choice.emptyText") || s.equals("&ilog.rules.brl.bal46.T-boolean-member.emptyText")){
checkbal46=true;
}
return checkbal46;
}

/*
* ¹ÚÇ×¼® »ý¼º
* Search a condition À» ¼±Åà ÇÒ ¼ö ÀÖ´Â popup menue°¡ ³ª¿Ã¼ö ÀÖ´ÂÁö check
*/
public boolean getsearchconditioncheck(ilog.rules.brl.IlrToken.Token token){
boolean checksearch = false;
if(token instanceof ilog.rules.brl.IlrFormatToken.ObjectToken){
ilog.rules.brl.IlrFormatToken.ObjectToken objecttoken = (ilog.rules.brl.IlrFormatToken.ObjectToken)token;
IlrChoicesProvider ilrchoicesprovider = objecttoken.getChoicesProvider();
String emptytext = objecttoken.getDisplayEmptyText();
Object obj = ilrchoicesprovider.getDefaultChoice();
if (emptytext!=null && emptytext.equals("") && obj==null){
checksearch=true;
}
}
return checksearch;
}

public DefaultKeyTypedAction(String s)
{
super(s);
}
}



public IlrSyntacticEditorKit()
{
defaultAction = new DefaultKeyTypedAction("default-typed");
defaultActions = (new Action[] {
defaultAction, new NewlineAction("newlineAction"), new DeleteAction("delete-next", false, false), new DeleteAction("delete-previous", true, false), new DeleteAction("deleteNextWordAction", false, true), new DeleteAction("deletePrevWordAction", true, true), new NextVisualPositionAction("caret-forward", 3, false, false), new NextVisualPositionAction("caret-backward", 7, false, false), new NextVisualPositionAction("caret-up", 1, false, false), new NextVisualPositionAction("caret-down", 5, false, false),
new NextVisualPositionAction("selection-forward", 3, true, false), new NextVisualPositionAction("selection-backward", 7, true, false), new NextVisualPositionAction("selection-up", 1, true, false), new NextVisualPositionAction("selection-down", 5, true, false), new NextVisualPositionAction("caret-end-word", 3, false, true), new NextVisualPositionAction("caret-begin-word", 7, false, true), new NextVisualPositionAction("selection-end-word", 3, true, true), new NextVisualPositionAction("selection-begin-word", 7, true, true), new NextVisualPositionAction("caret-begin", 2, false, false), new NextVisualPositionAction("caret-end", 4, false, false),
new NextVisualPositionAction("selection-begin", 2, true, false), new NextVisualPositionAction("selection-end", 4, true, false), new NextVisualPositionAction("nextTokenAction", 3, true), new NextVisualPositionAction("prevTokenAction", 7, true), new CutAction("cut-to-clipboard"), new CopyAction("copy-to-clipboard"), new PasteAction("paste-from-clipboard"), new CancelAction("cancelAction"), new SelectAllAction("select-all"), new UndoAction("undoAction"),
new RedoAction("redoAction")
});
}

public Action getDefaultAction()
{
return defaultAction;
}

public void install(JEditorPane jeditorpane)
{
super.install(jeditorpane);
if(jeditorpane instanceof IlrSyntacticEditorPane)
pane = (IlrSyntacticEditorPane)jeditorpane;
}

public void deinstall(JEditorPane jeditorpane)
{
super.deinstall(jeditorpane);
pane = null;
}

public MutableAttributeSet getInputAttributes()
{
if(pane != null)
{
MutableAttributeSet mutableattributeset = pane.getInputAttributes();
if(mutableattributeset != null)
return mutableattributeset;
}
return super.getInputAttributes();
}

public static boolean moveCaret(IlrSyntacticEditorPane ilrsyntacticeditorpane, int i, boolean flag, boolean flag1)
{
boolean flag2 = false;
ilog.rules.brl.IlrToken.Token token = ilrsyntacticeditorpane.getCurrentToken();
IlrStyledTokenDocument ilrstyledtokendocument = ilrsyntacticeditorpane.getTokenDocument();
int j = ilrstyledtokendocument.getFirstPosition(token);
int k = ilrstyledtokendocument.getLastPosition(token);
if(j >= 0 && k >= 0)
{
int l = ilrsyntacticeditorpane.getCaret().getDot();
int i1 = l;
switch(i)
{
case 1: // ''\001''
case 5: // ''\005''
case 6: // ''\006''
default:
break;

case 3: // ''\003''
if(flag1)
{
i1 = ilrstyledtokendocument.getNextWordStart(l);
i1 = Math.min(i1, k);
} else
if(l < k)
i1 = l + 1;
flag2 = i1 != l;
break;

case 7: // ''\007''
if(flag1)
{
i1 = ilrstyledtokendocument.getPreviousWordStart(l);
i1 = Math.max(i1, j);
} else
if(l > j)
i1 = l - 1;
flag2 = i1 != l;
break;

case 2: // ''\002''
i1 = j;
flag2 = true;
break;

case 4: // ''\004''
i1 = k;
flag2 = true;
break;
}
Caret caret = ilrsyntacticeditorpane.getCaret();
if(flag)
caret.moveDot(i1);
else
caret.setDot(i1);
}
return flag2;
}

public static void selectAll(IlrSyntacticEditorPane ilrsyntacticeditorpane)
{
ilog.rules.brl.IlrToken.Token token = ilrsyntacticeditorpane.getCurrentToken();
IlrStyledTokenDocument ilrstyledtokendocument = ilrsyntacticeditorpane.getTokenDocument();
int i = ilrstyledtokendocument.getFirstPosition(token);
int j = ilrstyledtokendocument.getLastPosition(token);
if(i >= 0 && j >= 0)
{
Caret caret = ilrsyntacticeditorpane.getCaret();
caret.setDot(i);
caret.moveDot(j);
}
}

public static void moveToken(IlrSyntacticEditorPane ilrsyntacticeditorpane, int i, boolean flag)
{
ilog.rules.brl.IlrToken.Token token = ilrsyntacticeditorpane.getCurrentToken();
if(token != null)
{
ilog.rules.brl.IlrToken.Token token1 = null;
if(i == 1 || i == 5 || i == 3 || i == 7)
token1 = findNextToken(ilrsyntacticeditorpane, i);
if(token1 != null)
ilrsyntacticeditorpane.setCurrentToken(token1, true);
}
}

private static ilog.rules.brl.IlrToken.Token findNextToken(IlrSyntacticEditorPane ilrsyntacticeditorpane, int i)
{
ilog.rules.brl.IlrToken.Token token = null;
boolean flag = false;
Caret caret = ilrsyntacticeditorpane.getCaret();
int j = caret.getDot();
javax.swing.text.Position.Bias abias[] = new javax.swing.text.Position.Bias[1];
try
{
if(i == 1 || i == 5)
{
Point point = caret.getMagicCaretPosition();
if(point == null)
{
Rectangle rectangle = ilrsyntacticeditorpane.modelToView(j);
Point point1 = new Point(rectangle.x, rectangle.y);
caret.setMagicCaretPosition(point1);
}
}
ilog.rules.brl.IlrToken.Token token1 = ilrsyntacticeditorpane.getCurrentToken();
int k = j;
Object obj = null;
while(!flag)
{
int l = ilrsyntacticeditorpane.getUI().getNextVisualPositionFrom(ilrsyntacticeditorpane, k, javax.swing.text.Position.Bias.Forward, i, abias);
if(l == k)
break;
k = l;
token = ilrsyntacticeditorpane.getToken(k);
if(token != null && token1 != token && IlrToken.isTokenActive(token))
flag = true;
}
if(i == 3 || i == 7)
caret.setMagicCaretPosition(null);
}
catch(BadLocationException badlocationexception) { }
return flag ? token : null;
}

public Action[] getActions()
{
return defaultActions;
}

public static final String deleteNextWordAction = "deleteNextWordAction";
public static final String deletePrevWordAction = "deletePrevWordAction";
public static final String nextTokenAction = "nextTokenAction";
public static final String prevTokenAction = "prevTokenAction";
public static final String newlineAction = "newlineAction";
public static final String cancelAction = "cancelAction";
public static final String undoAction = "undoAction";
public static final String redoAction = "redoAction";
private static final int CTRL_SHIFT_MASK = 3;
private Action defaultAction;
private IlrSyntacticEditorPane pane;
public static final javax.swing.text.JTextComponent.KeyBinding keyBindings[] = {
new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(9, 0), "nextTokenAction"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(9, 1), "prevTokenAction"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(10, 0), "newlineAction"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(''\033''), "cancelAction"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(''\b''), "delete-previous"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(127, 0), "delete-next"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(8, 2), "deletePrevWordAction"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(127, 2), "deleteNextWordAction"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(39, 0), "caret-forward"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(37, 0), "caret-backward"),
new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(38, 0), "caret-up"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(40, 0), "caret-down"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(39, 1), "selection-forward"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(37, 1), "selection-backward"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(38, 1), "selection-up"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(40, 1), "selection-down"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(39, 2), "caret-end-word"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(37, 2), "caret-begin-word"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(39, 3), "selection-end-word"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(37, 3), "selection-begin-word"),
new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(36, 0), "caret-begin"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(36, 1), "selection-begin"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(35, 0), "caret-end"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(35, 1), "selection-end"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(67, 2), "copy-to-clipboard"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(86, 2), "paste-from-clipboard"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(88, 2), "cut-to-clipboard"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(65, 2), "select-all"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(90, 2), "undoAction"), new javax.swing.text.JTextComponent.KeyBinding(KeyStroke.getKeyStroke(89, 2), "redoAction")
};
private Action defaultActions[];

}




















// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)

package ilog.rules.ui.editor;

import ilog.rules.bom.IlrClass;
import ilog.rules.bom.IlrMember;
import ilog.rules.brl.*;
import ilog.rules.brl.IlrToken.TextToken;
import ilog.rules.builder.base.IlrBrManager;
import ilog.rules.ui.editor.chooser.IlrObjectTokenActionManager;
import ilog.rules.ui.editor.chooser.IlrObjectTokenChooser;
import ilog.rules.ui.editor.chooser.tree.IlrObjectTokenTreeChooser;
import ilog.rules.ui.util.IlrPopupMenu;
import ilog.rules.ui.util.IlrUIPreferences;
import ilog.rules.util.prefs.IlrMessages;
import ilog.rules.util.prefs.IlrPreferences;
import ilog.rules.util.undo.*;
import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.event.*;
import java.awt.im.InputMethodRequests;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Vector;
import javax.swing.*;
import javax.swing.border.LineBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.plaf.TextUI;
import javax.swing.text.*;
import javax.swing.tree.TreeNode;

// Referenced classes of package ilog.rules.ui.editor:
// IlrSyntacticEditorKit, IlrSyntacticEditorCaret, IlrSyntacticEditorInputMethod, IlrStyledTokenDocument,
// IlrSyntacticEditorPopupMenu, IlrSyntacticEditorUEditProvider, IlrTokenComponent, IlrTokenActionManager

public class IlrSyntacticEditorPane extends JTextPane
implements IlrTokenEditor
{
private static class ClipboardObserver
implements ClipboardOwner
{

public void lostOwnership(Clipboard clipboard1, Transferable transferable)
{
}

private ClipboardObserver()
{
}

}

private class MultipleAction
implements ActionListener
{

public void actionPerformed(ActionEvent actionevent)
{
insertInMultiple(type);
}

private int type;

MultipleAction(int i)
{
type = i;
}
}

private class Ghost extends JComponent
{

public synchronized void addMouseListener(MouseListener mouselistener)
{
}

public synchronized void addMouseMotionListener(MouseMotionListener mousemotionlistener)
{
}

public Ghost()
{
setBorder(new LineBorder(Color.black));
setOpaque(false);
}
}

private class SelectionRemover
implements DocumentListener
{

public void insertUpdate(DocumentEvent documentevent)
{
hideSelection();
}

public void removeUpdate(DocumentEvent documentevent)
{
hideSelection();
}

public void changedUpdate(DocumentEvent documentevent)
{
hideSelection();
}

private SelectionRemover()
{
}

}


public IlrSyntacticEditorPane()
{
resourcePrefix = "ui.editor.SyntacticEditor";
editing = false;
ghostEnabled = true;
ghostAdded = false;
editionModeAction = new ActionListener() {

public void actionPerformed(ActionEvent actionevent)
{
toggleEditionMode();
}

};
removeSelectionAction = new ActionListener() {

public void actionPerformed(ActionEvent actionevent)
{
removeSelection();
}

};
cutSelectionAction = new ActionListener() {

public void actionPerformed(ActionEvent actionevent)
{
cutSelection();
}

};
copySelectionAction = new ActionListener() {

public void actionPerformed(ActionEvent actionevent)
{
copySelection();
}

};
pasteSelectionAction = new ActionListener() {

public void actionPerformed(ActionEvent actionevent)
{
pasteClipboard();
}

};
freezeTokensAction = new ActionListener() {

public void actionPerformed(ActionEvent actionevent)
{
freezeSelectedTokens();
}

};
unfreezeTokensAction = new ActionListener() {

public void actionPerformed(ActionEvent actionevent)
{
unfreezeSelectedTokens();
}

};
freezeAllAction = new ActionListener() {

public void actionPerformed(ActionEvent actionevent)
{
freezeAllTokens();
}

};
unfreezeAllAction = new ActionListener() {

public void actionPerformed(ActionEvent actionevent)
{
unfreezeAllTokens();
}

};
reloadBRLDefinitionAction = new ActionListener() {

public void actionPerformed(ActionEvent actionevent)
{
reloadBRLDefinition();
}

};
startParenthesisAction = new MultipleAction(0);
endParenthesisAction = new MultipleAction(1);
bothParenthesisAction = new MultipleAction(2);
insertTermAction = new MultipleAction(3);
insertUnaryOperatorBeforeAction = new MultipleAction(4);
insertUnaryOperatorAfterAction = new MultipleAction(5);
setSelectedTextColor(SelectedForegroundColor);
setSelectionColor(getSelectedBackgroundColor());
setDisabledTextColor(NoFocusSelectedBackgroundColor);
IlrSyntacticEditorKit ilrsyntacticeditorkit = new IlrSyntacticEditorKit();
setEditorKit(ilrsyntacticeditorkit);
Keymap keymap = JTextComponent.addKeymap("tokenKeymap", null);
JTextComponent.loadKeymap(keymap, IlrSyntacticEditorKit.keyBindings, ilrsyntacticeditorkit.getActions());
keymap.setDefaultAction(ilrsyntacticeditorkit.getDefaultAction());
setKeymap(keymap);
IlrSyntacticEditorCaret ilrsyntacticeditorcaret = new IlrSyntacticEditorCaret();
setCaret(ilrsyntacticeditorcaret);
ToolTipManager.sharedInstance().registerComponent(this);
setMinimumSize(new Dimension(200, 200));
inputMethod = new IlrSyntacticEditorInputMethod(this);
addInputMethodListener(inputMethod);
enableInputMethods(true);

//¹ÚÇ×¼® Ãß°¡ - search ½Ã classnameÀ» ã±â À§ÇØ ¹Ì¸® ¼±ÅÃµÈ tokenÀÇ ¸ðµç ¸Þ´º¸¦ ÀúÀå
choiceIndexes = new ArrayList();
}

public static void testJdk()
{


if(!isJdkTested)
{
String s = System.getProperty("java.version", "");
isJdk13 = s.compareTo("1.3.0") >= 0;
isJdk14 = s.compareTo("1.4.0") >= 0;
isWindowsLook = UIManager.getLookAndFeel().getName().equals("Windows");
isJdkTested = true;
}
}

public static boolean isJdk13()
{
testJdk();
return isJdk13;
}

public static boolean isJdk14()
{
testJdk();
return isJdk14;
}

public static boolean isWindowsLook()
{

testJdk();
return isWindowsLook;
}

private boolean french_insert(char c)
{

switch(c)
{
case 35: // ''#''
case 64: // ''@''
case 91: // ''[''
case 92: // ''\\''
case 93: // '']''
case 94: // ''^''
case 96: // ''`''
case 123: // ''{''
case 124: // ''|''
case 125: // ''}''
case 126: // ''~''
case 164:
insert("" + c, getCaretPosition());
return true;
}
return false;
}

protected void processKeyEvent(KeyEvent keyevent)
{

int i = keyevent.getID();
if(french_flag && keyevent.getID() == 400 && french_insert(keyevent.getKeyChar()))
{
return;
} else
{
super.processKeyEvent(keyevent);
return;
}
}

public void insert(String s, int i)
{

javax.swing.text.StyledDocument styleddocument = getStyledDocument();
if(styleddocument != null)
try
{
styleddocument.insertString(i, s, getInputAttributes());
}
catch(BadLocationException badlocationexception)
{
throw new IllegalArgumentException(badlocationexception.getMessage());
}
}

private Color getSelectedBackgroundColor()
{

Color color = IlrUIPreferences.getColor("Editor.textHighlight");
if(color != null)
return color;
if(!isJdk13() && isWindowsLook())
return Jdk12SelectedBackgroundColor;
else
return SelectedBackgroundColor;
}

public IlrUndoSupportManager getTextUndoManager()
{

return textUndoManager;
}

public void setTextUndoManager(IlrUndoSupportManager ilrundosupportmanager)
{

textUndoManager = ilrundosupportmanager;
}

public void undoTextAction()
{

try
{
if(textUndoManager != null)
textUndoManager.undo();
}
catch(IlrCannotUndoException ilrcannotundoexception) { }
}

public void redoTextAction()
{

try
{
if(textUndoManager != null)
textUndoManager.redo();
}
catch(IlrCannotRedoException ilrcannotredoexception) { }
}

public void handleError(RuntimeException runtimeexception)
{

throw runtimeexception;
}

public String getMessage(String s)
{

if(resourcePrefix != null)
s = resourcePrefix + "." + s;
return IlrMessages.getMessage(s);
}

public void updateResources()
{

IlrStyledTokenDocument ilrstyledtokendocument = getTokenDocument();
if(ilrstyledtokendocument != null)
ilrstyledtokendocument.updateResources();
}

public void setResourcePrefix(String s)
{

resourcePrefix = s;
}

public String getResourcePrefix()
{

return resourcePrefix;
}

public void setTokenModel(IlrTokenModel ilrtokenmodel)
{


if(ilrtokenmodel != getTokenModel())
{
ilog.rules.brl.IlrTokenDocument ilrtokendocument = ilrtokenmodel.getTokenDocument();
if(ilrtokendocument instanceof IlrStyledTokenDocument)
{
setTokenDocument((IlrStyledTokenDocument)ilrtokendocument);
} else
{
IlrStyledTokenDocument ilrstyledtokendocument = makeTokenDocument();
ilrtokenmodel.setTokenDocument(ilrstyledtokendocument);
setTokenDocument(ilrstyledtokendocument);
}
}
}

public IlrTokenModel getTokenModel()
{

return document != null ? document.getTokenModel() : null;
}

public IlrStyledTokenDocument getTokenDocument()
{

return document;
}

public IlrStyledTokenDocument makeTokenDocument()
{

return makeTokenDocument(null);
}

public IlrStyledTokenDocument makeTokenDocument(StyleContext stylecontext)
{


IlrStyledTokenDocument ilrstyledtokendocument;
if(stylecontext == null)
ilrstyledtokendocument = new IlrStyledTokenDocument();
else
ilrstyledtokendocument = new IlrStyledTokenDocument(stylecontext);
ilrstyledtokendocument.setResourcePrefix(resourcePrefix);
return ilrstyledtokendocument;
}

public void setTokenDocument(IlrStyledTokenDocument ilrstyledtokendocument)
{
if(document != ilrstyledtokendocument)
{
if(isJdk14())
{
if(document != null && selectionRemover != null)
document.removeDocumentListener(selectionRemover);
if(selectionRemover == null)
selectionRemover = new SelectionRemover();
ilrstyledtokendocument.addDocumentListener(selectionRemover);
}
document = ilrstyledtokendocument;
super.setDocument(ilrstyledtokendocument);
ilrstyledtokendocument.updateResources();
ilrstyledtokendocument.setEditionMode(isEditable());
IlrSyntacticEditorCaret ilrsyntacticeditorcaret = getSyntacticCaret();
if(ilrsyntacticeditorcaret != null)
ilrsyntacticeditorcaret.updatePosition(false);
}
}

public void setDocument(Document document1)
{
if(document1 instanceof IlrStyledTokenDocument)
setTokenDocument((IlrStyledTokenDocument)document1);
else
super.setDocument(document1);
}

public void refresh()
{
setCurrentToken(null, false);
if(document != null)
document.refresh();
}

public void setFocus(boolean flag)
{
Caret caret = getCaret();
if(flag)
{
setSelectedTextColor(SelectedForegroundColor);
setSelectionColor(getSelectedBackgroundColor());
if(isEditing())
caret.setVisible(true);
} else
{
stopEditing();
setGhostToken(null);
setSelectedTextColor(NoFocusSelectedForegroundColor);
setSelectionColor(NoFocusSelectedBackgroundColor);
}
redrawSelection();
}

public void setEditable(boolean flag)
{
if(document != null)
document.setEditionMode(flag);
super.setEditable(flag);
}

public void toggleEditionMode()
{

if(document != null)
document.toggleEditionMode();
}

public boolean isEditionMode()
{
return document != null && document.isEditionMode();
}

public String getToolTipText(MouseEvent mouseevent)
{
IlrSyntacticEditorCaret ilrsyntacticeditorcaret = getSyntacticCaret();
if(ilrsyntacticeditorcaret == null)
return null;
ilog.rules.brl.IlrToken.Token token = ilrsyntacticeditorcaret.getToken(mouseevent);
if(token != null)
return getTokenModel().getMessage(IlrToken.getTokenToolTipText(token));
else
return null;
}

public void hideToolTip()
{
ToolTipManager.sharedInstance().setEnabled(false);
ToolTipManager.sharedInstance().setEnabled(true);
}

public ilog.rules.brl.IlrToken.Token getToken(int i)
{
return document != null ? document.getToken(i) : null;
}

public IlrSyntacticEditorCaret getSyntacticCaret()
{
Caret caret = getCaret();
if(caret instanceof IlrSyntacticEditorCaret)
return (IlrSyntacticEditorCaret)caret;
else
return null;
}

public void redrawSelection()
{
Caret caret = getCaret();
if(caret.isSelectionVisible())
{
caret.setSelectionVisible(false);
caret.setSelectionVisible(true);
}
}

public void enableSelection()
{
IlrSyntacticEditorCaret ilrsyntacticeditorcaret = getSyntacticCaret();
if(ilrsyntacticeditorcaret != null)
ilrsyntacticeditorcaret.enableSelection();
}

public void disableSelection()
{
IlrSyntacticEditorCaret ilrsyntacticeditorcaret = getSyntacticCaret();
if(ilrsyntacticeditorcaret != null)
ilrsyntacticeditorcaret.disableSelection();
}

public void hideSelection()
{
IlrSyntacticEditorCaret ilrsyntacticeditorcaret = getSyntacticCaret();
if(ilrsyntacticeditorcaret != null)
ilrsyntacticeditorcaret.hideSelection();
}

public void removeHighlight()
{
IlrSyntacticEditorCaret ilrsyntacticeditorcaret = getSyntacticCaret();
if(ilrsyntacticeditorcaret != null && !ilrsyntacticeditorcaret.hasSelectedTokens())
ilrsyntacticeditorcaret.hideSelection();
}

public void selectTokens(Vector vector)
{
if(document == null)
return;
int i = -1;
int j = -1;
for(int k = 0; k < vector.size(); k++)
{
ilog.rules.brl.IlrToken.Token token = (ilog.rules.brl.IlrToken.Token)vector.elementAt(k);
int l = document.getStartPosition(token);
int i1 = document.getEndPosition(token);
if(i == -1)
i = l;
else
i = Math.min(i, l);
if(j == -1)
j = i1;
else
j = Math.max(j, i1);
}

select(i, j);
}

public void selectToken(ilog.rules.brl.IlrToken.Token token, boolean flag)
{
if(document == null)
return;
if(token != null)
{
int i = document.getStartPosition(token);
int j = document.getEndPosition(token);
if(i >= 0 && j >= 0)
{
select(i, j);
if(flag)
showPopupMenu(token);
return;
}
}
hideSelection();
}

public void selectTokenText(ilog.rules.brl.IlrToken.Token token, boolean flag)
{

if(document == null)
return;
int i = document.getFirstPosition(token);
int j = document.getLastPosition(token);
if(i >= 0 && j >= 0)
{
select(i, j);
if(flag)
showPopupMenu(token);
}
}

public void selectWord(int i)
{
if(document == null)
{
return;
} else
{
int j = document.getWordStart(i);
int k = document.getWordEnd(i);
select(j, k);
return;
}
}

public Vector getSelectedTokens()
{
IlrSyntacticEditorCaret ilrsyntacticeditorcaret = getSyntacticCaret();
if(ilrsyntacticeditorcaret == null)
return null;
Vector vector = ilrsyntacticeditorcaret.getSelectedTokens();
if(vector == null && currentToken != null)
{
vector = new Vector();
vector.addElement(currentToken);
}
return vector;
}

public boolean hasSelectedTokens()
{
IlrSyntacticEditorCaret ilrsyntacticeditorcaret = getSyntacticCaret();
if(ilrsyntacticeditorcaret != null && ilrsyntacticeditorcaret.hasSelectedTokens())
return true;
else
return currentToken != null;
}

public InputMethodRequests getInputMethodRequests()
{
return inputMethod;
}

public boolean isInCompositionArea(int i)
{
return inputMethod.isInCompositionArea(i);
}

public boolean isSelectionEditable()
{
Caret caret = getCaret();
int i = caret.getDot();
int j = caret.getMark();
ilog.rules.brl.IlrToken.Token token = getToken(i);
ilog.rules.brl.IlrToken.Token token1 = i != j ? getToken(j) : token;
return token != null && token == token1 && isEditedToken(token);
}

public boolean isAreaEditable(int i, int j)
{
ilog.rules.brl.IlrToken.Token token = getToken(i);
ilog.rules.brl.IlrToken.Token token1 = getToken(i + j);
return token != null && token == token1 && isEditedToken(token);
}

public MutableAttributeSet getInputAttributes()
{
if(currentToken != null)
{
inputAttributes = document.getTokenAttributes(currentToken);
if(inputAttributes != null)
return new SimpleAttributeSet(inputAttributes);
} else
if(document != null)
return new SimpleAttributeSet(document.getDefaultStyle());
return null;
}

public void replaceWord(String s)
{
int i = getSelectionStart();
int j = getSelectionEnd();
if(i == j)
{
int k = document.getWordStart(i);
int l = document.getWordEnd(i);
if(k != l)
try
{
String s1 = document.getText(k, l - k);
int i1 = s.indexOf(''('');
if(i1 != -1)
{
char c = document.getNextCharAt(l);
if(c == ''('')
s = s.substring(0, i1);
}
select(k, l);
replaceSelection(s);
return;
}
catch(BadLocationException badlocationexception) { }
}
replaceSelection(i, j - i, s);
}

public void replaceSelection(String s)
{
int i = getSelectionStart();
int j = getSelectionEnd();
replaceSelection(i, j - i, s);
}

public void replaceSelection(int i, int j, String s)
{
if(!isEditable())
{
getToolkit().beep();
return;
}
if(document == null)
return;
try
{
ilog.rules.brl.IlrToken.Token token = getToken(i);
if(token == null)
return;
int k = document.getStartOffset(token, false);
int l = document.getEndOffset(token, false);
if(i + j >= l)
j = l - i - 1;
if(j < 0)
return;
if(valueEditor != null && !checkInput(token, i - k, j, s))
{
getToolkit().beep();
return;
}
int i1 = j;
int j1 = s != null ? s.length() : 0;
if(i1 > j1)
{
int k1 = document.getMinimumTextLength();
int i2 = ((l - k) + j1) - i1;
if(i2 < k1)
{
int k2 = Math.min(i1, k1 - i2);
if(k2 > 0)
{
String s1 = IlrBRLUtil.makeBlankString(k2);
document.insertString(l, s1, getInputAttributes());
}
}
} else
if(i1 < j1)
{
int l1 = j1 - i1;
int j2 = 0;
for(int l2 = l - 2; l2 >= i; l2--)
{
if(document.getCharAt(l2) != '' '')
break;
j2++;
}

j2 = Math.min(j2, l1);
document.remove(l - j2, j2);
}
registerEdit(i, j, s);
if(i1 > 0)
document.remove(i, i1);
if(j1 > 0)
document.insertString(i, s, getInputAttributes());
if(isPopupMenuVisible())
popupMenu.searchMenuItem(i);
}
catch(BadLocationException badlocationexception)
{
getToolkit().beep();
}
}

private void registerEdit(int i, int j, String s)
{
if(textUndoManager == null)
return;
String s1 = null;
if(j > 0)
try
{
s1 = document.getText(i, j);
}
catch(BadLocationException badlocationexception)
{
return;
}
if(s == null && s1 == null)
{
IlrSyntacticEditorUEditProvider.RemoveTextEdit removetextedit = new IlrSyntacticEditorUEditProvider.RemoveTextEdit(s1, i, this, true);
textUndoManager.postEdit(removetextedit);
} else
if(s == null && s1 != null)
{
IlrSyntacticEditorUEditProvider.RemoveTextEdit removetextedit1;
if(s1.equals("\t") || s1.equals("\r") || s1.equals(" "))
removetextedit1 = new IlrSyntacticEditorUEditProvider.RemoveTextEdit(s1, i, this, false);
else
removetextedit1 = new IlrSyntacticEditorUEditProvider.RemoveTextEdit(s1, i, this, true);
textUndoManager.postEdit(removetextedit1);
} else
if(s.equals("\t") || s.equals("\r") || s.equals(" "))
{
if(s1 != null)
{
IlrSyntacticEditorUEditProvider.RemoveTextEdit removetextedit2 = new IlrSyntacticEditorUEditProvider.RemoveTextEdit(s1, i, this, false);
textUndoManager.postEdit(removetextedit2);
}
IlrSyntacticEditorUEditProvider.AddTextEdit addtextedit = new IlrSyntacticEditorUEditProvider.AddTextEdit(s, i, this, false);
textUndoManager.postEdit(addtextedit);
} else
{
if(s1 != null)
{
IlrSyntacticEditorUEditProvider.RemoveTextEdit removetextedit3 = new IlrSyntacticEditorUEditProvider.RemoveTextEdit(s1, i, this, false);
textUndoManager.postEdit(removetextedit3);
}
IlrSyntacticEditorUEditProvider.AddTextEdit addtextedit1 = new IlrSyntacticEditorUEditProvider.AddTextEdit(s, i, this, true);
textUndoManager.postEdit(addtextedit1);
}
}

private boolean checkInput(ilog.rules.brl.IlrToken.Token token, int i, int j, String s)
{
String s1 = document.getTokenElementText(token);
int k = s1.length();
char ac[] = s1.toCharArray();
StringBuffer stringbuffer = new StringBuffer(k + j);
stringbuffer.append(ac, 0, i);
if(s != null)
stringbuffer.append(s);
stringbuffer.append(ac, i + j, k - i - j);
String s2 = stringbuffer.toString().trim();
if(s2.length() == 0)
return true;
else
return valueEditor.checkInput(token, s2);
}

public int getEditionStartOffset()
{
return document.getFirstPosition(currentToken);
}

public int getEditionEndOffset()
{
return document.getLastPosition(currentToken);
}

private String makeEmptyString(ilog.rules.brl.IlrToken.Token token, String s)
{
int i = s.length();
AttributeSet attributeset = document.getTokenAttributes(token);
StyleContext stylecontext = document.getStyleContext();
java.awt.Font font = stylecontext.getFont(attributeset);
FontMetrics fontmetrics = stylecontext.getFontMetrics(font);
int j = fontmetrics.charWidth('' '');
int k = fontmetrics.stringWidth(s);
i = k / j;
if(k % j != 0)
i++;
return IlrBRLUtil.makeBlankString(i);
}

protected void startEditing(ilog.rules.brl.IlrToken.Token token)
{
setGhostToken(null);
document.setModificationEvent(false);
editedTokenComponent = document.getTokenComponent(token);
editedTokenText = document.getTokenElementText(token);
int i = document.getStartOffset(token, false);
javax.swing.text.Style style = document.getTokenStyle(token);
javax.swing.text.Style style1 = document.getDefaultStyle();
if(editedTokenComponent != null && !editedTokenComponent.isPersistentComponent())
{
int j = document.getEndOffset(token, false);
try
{
document.remove(i, j - i);
}
catch(BadLocationException badlocationexception)
{
badlocationexception.printStackTrace();
}
i = document.insertTokenComponent(i, token, editedTokenComponent, style);
i = document.insertTokenSeparator(i, token, style1);
document.updateTokenStyle(token);
} else{
if(IlrToken.isTokenTextEmpty(token) || (editedTokenText!=null && editedTokenText.equals("")) )
{
//¹ÚÇ×¼® Ãß°¡ - search a condition ¼±Åýà ±ÛÀÚ¸¦ ÀÔ·Â ÇÒ¼ö ÀÖ´Â textarea ¸¦ ¸¸µç´Ù.
document.removeEmptyStyle(token);
String s = IlrToken.getTokenEmptyText(token);
if((s != null && editedTokenText != null && editedTokenText.equals(s)) || (editedTokenText!=null && editedTokenText.equals("")) ){
document.setTokenElementText(token, makeEmptyString(token, s));
}
} else
{
int k = document.getEndOffset(token, false);
try
{
document.insertString(k, " ", getInputAttributes());
}
catch(BadLocationException badlocationexception1) { }
}
}
document.addTokenStyle(token, "edition");
document.setModificationEvent(true);
selectTokenText(token, false);
Caret caret = getCaret();
caret.setVisible(true);
}

protected void stopEditing(ilog.rules.brl.IlrToken.Token token, boolean flag)
{
setGhostToken(null);
Caret caret = getCaret();
caret.setVisible(false);
document.setModificationEvent(false);
document.clearTokenStyle(token, "edition");
if(editedTokenComponent != null && !editedTokenComponent.isPersistentComponent())
{
int i = document.getStartOffset(token, false);
try
{
document.removeComponent(i);
}
catch(BadLocationException badlocationexception)
{
badlocationexception.printStackTrace();
}
}

if(flag)
document.setTokenElementText(token, editedTokenText);
else
document.updateTokenText(token);

String s = IlrToken.getTokenEmptyText(token);
boolean flag1 = false;
if(s != null)
{
String s1 = document.getTokenElementText(token);
if(IlrBRLUtil.isEmptyString(s1))
{
document.setTokenElementText(token, s);
flag1 = true;
}
}
if(!flag1)
document.removeBlankChars(token);
document.setModificationEvent(true);
}



public boolean isEditing()
{
return editing;
}


public ilog.rules.brl.IlrToken.Token getEditedToken()
{
return editing ? currentToken : null;
}

public boolean isEditedToken(ilog.rules.brl.IlrToken.Token token)
{
return editing && token == currentToken;
}

public void startEditing()
{
//¹ÚÇ×¼® Ãß°¡ - ¸¶¿ì½º Ŭ¸¯½Ã search a condition ¼±Åýà textarea ¸¸µå´Â ½ÃÀÛÁ¡ startEditing(currentToken)È£Ãâ
String searchtext = getTokenDocument().getTokenText(currentToken);
if(searchtext!=null && searchtext.equals("")){
editing = true;
inputAttributes = document.getTokenAttributes(currentToken);
valueEditor = IlrBOMToken.findValueEditor(currentToken);
startEditing(currentToken);
}
if(editing){
return;
}
if(currentToken != null && IlrToken.isTokenEditable(currentToken))
{
editing = true;
inputAttributes = document.getTokenAttributes(currentToken);
valueEditor = IlrBOMToken.findValueEditor(currentToken);
startEditing(currentToken);
showPopupMenu(currentToken);
}

}


private void stopEditing(boolean flag)
{
if(!editing)
return;
if(currentToken != null)
{
editing = false;
hidePopupMenu();
stopEditing(currentToken, flag);
selectToken(currentToken, false);
inputAttributes = null;
valueEditor = null;
if(textUndoManager != null)
textUndoManager.discardAllEdits();
}
}

public void cancelEditing()
{
stopEditing(true);
}

public void stopEditing()
{
stopEditing(false);
}

public ilog.rules.brl.IlrToken.Token getCurrentToken()
{
return currentToken;
}

public boolean isCurrentToken(ilog.rules.brl.IlrToken.Token token)
{
return token == currentToken;
}

public void setCurrentToken(ilog.rules.brl.IlrToken.Token token, boolean flag)
{

if(currentToken == token){

return;
}
if(currentToken != null)
{

if(editing){

stopEditing();
}
IlrTokenComponent ilrtokencomponent = document.getTokenComponent(currentToken);
if(ilrtokencomponent != null)
{

ilrtokencomponent.setFocus(false);
repaint();
}
hidePopupMenu();
}
currentToken = token;
if(token == null || !IlrToken.isTokenActive(token))
{

setGhostToken(null);
removeHighlight();
} else
{

if(ghostToken == token){
setGhostToken(null);
}
if(flag && IlrToken.isTokenEditable(token))
{

startEditing();
} else
{

IlrTokenComponent ilrtokencomponent1 = document.getTokenComponent(token);
if(ilrtokencomponent1 != null)
{

ilrtokencomponent1.setFocus(true);
repaint();
}
selectToken(token, flag);
}
}
}




public void doTokenAction(ilog.rules.brl.IlrToken.Token token, boolean flag)
{
//System.out.println("#######################IlrSyntacticEditorPane.doTokenAction##########################");
IlrTokenActionManager ilrtokenactionmanager = getTokenDocument().getTokenActionManager(token);
//¹ÚÇ×¼® Ãß°¡ select a condition ¼±Åýà ilrtokenactionmanagerÀÇ actionÀ» ÇÏÁö ¾Ê°í popup menu ¸¦ ¸¸µé¾î¼­ »ç¿ëÀÚ°¡ ¼±ÅÃÇÒ ¼ö ÀÖµµ·Ï ÇÑ´Ù.
if (getsearchconditioncheck(token)){
//System.out.println("#######################IlrSyntacticEditorPane.doTokenAction.IlrToken.doTokenAction##########################");
IlrToken.doTokenAction(token, this, flag);
}else{
if(IlrToken.isTokenActive(token) && ilrtokenactionmanager != null && ilrtokenactionmanager.isEnabled() )
{
if(token.isEditionMode() && !token.isFrozen()){
//System.out.println("#######################IlrSyntacticEditorPane.doTokenAction.ilrtokenactionmanager.doAction##########################");
ilrtokenactionmanager.doAction(this, flag);
}
} else
{
//System.out.println("#######################IlrSyntacticEditorPane.doTokenAction.IlrToken.doTokenAction##########################");
IlrToken.doTokenAction(token, this, flag);
}
}
}

/*
* popup menu °¡ ³ªÅ¸³ª°í ³ª¼­ select a condition À» ¼±Åà ÇßÀ» ¶§ IlrTokenActionManager¿¡ ÀÇÇÑ doactionÀ» ¹Ù·Î ÇÒ ¼ö ÀÖµµ·Ï
* method Ãß°¡
*/
public void doTokenAction2(ilog.rules.brl.IlrToken.Token token, boolean flag)
{
//System.out.println("+++++++++++++++++++++++++++++IlrSyntacticEditorPane.doTokenAction2++++++++++++++"+flag);
IlrTokenActionManager ilrtokenactionmanager = getTokenDocument().getTokenActionManager(token);
if(IlrToken.isTokenActive(token) && ilrtokenactionmanager != null && ilrtokenactionmanager.isEnabled())
{

if(token.isEditionMode() && !token.isFrozen()){
ilrtokenactionmanager.doAction(this, flag);
}
} else
{
//System.out.println("+++++++++++++++++++++++++++++IlrSyntacticEditorPane.doTokenAction2.else++++++++++++++"+flag);
IlrToken.doTokenAction(token, this, flag);
}
}


public void setGhostToken(ilog.rules.brl.IlrToken.Token token)
{
if(token != null)
token = getEnglobingToken(token);
if(!ghostEnabled || ghostToken == token)
return;
IlrTokenComponent ilrtokencomponent = document.getTokenComponent(ghostToken);
IlrTokenComponent ilrtokencomponent1 = document.getTokenComponent(token);
if(ghostToken != null)
{
if(ilrtokencomponent != null)
{
ilrtokencomponent.setFocus(false);
repaint(getTokenRect(ghostToken));
}
eraseGhost();
}
if(token != null)
if(ilrtokencomponent1 != null && ilrtokencomponent1.isPersistentComponent())
{
ilrtokencomponent1.setFocus(true);
repaint(getTokenRect(token));
} else
if(!isEditedToken(token))
drawGhost(token);
ghostToken = token;
}

public JComponent getGhost()
{
if(ghost == null)
ghost = new Ghost();
return ghost;
}

protected Rectangle getTokenRect(ilog.rules.brl.IlrToken.Token token)
{
int i = document.getStartPosition(token);
int j = document.getEndPosition(token);
if(i >= 0 && j >= 0)
try
{
Rectangle rectangle = getUI().modelToView(this, i);
Rectangle rectangle1 = getUI().modelToView(this, j);
if(rectangle == null || rectangle1 == null)
return null;
rectangle = rectangle.union(rectangle1);
if(rectangle.y != rectangle1.y)
{
rectangle.x = 0;
rectangle.width = getWidth();
} else
{
byte byte0 = 0;
byte byte1 = 0;
if(!IlrToken.hasComponent(token))
{
byte0 = 2;
byte1 = -1;
}
rectangle.width = Math.min(getWidth(), rectangle.width + byte0);
rectangle.x = Math.max(0, rectangle.x + byte1);
}
return rectangle;
}
catch(BadLocationException badlocationexception) { }
return null;
}

public void drawGhost(ilog.rules.brl.IlrToken.Token token)
{
if(!qfTestActivation)
{
if(document == null)
return;
if(!ghostEnabled || ghostAdded && ghostObject == token)
return;
removeGhost();
Rectangle rectangle = getTokenRect(token);
getGhost().setBounds(rectangle);
addGhost();
ghostObject = token;
}
}

public void eraseGhost()
{
if(!qfTestActivation)
removeGhost();
}

protected void addGhost()
{
if(!ghostAdded)
{
add(getGhost());
repaint();
ghostAdded = true;
}
}

protected void removeGhost()
{
if(ghostAdded)
{
remove(getGhost());
repaint();
ghostAdded = false;
}
}

public void enableGhost()
{
ghostEnabled = true;
}

public void disableGhost()
{
ghostEnabled = false;
setGhostToken(null);
}

public ilog.rules.brl.IlrToken.Token getEnglobingToken(ilog.rules.brl.IlrToken.Token token)
{
if((token.getSuperToken() instanceof ilog.rules.brl.IlrToken.SwitchToken) && token.getSuperToken().indexOf(token) == 0)
return token.getSuperToken();
if((token.getSuperToken() instanceof ilog.rules.brl.IlrBOMToken.MemberFormatToken) && ((ilog.rules.brl.IlrBOMToken.MemberFormatToken)token.getSuperToken()).isChoiceToken(token))
return token.getSuperToken();
else
return token;
}

protected IlrSyntacticEditorPopupMenu buildPopupMenu(ilog.rules.brl.IlrToken.Token token)
{
//System.out.println("+++++++++++++++++++++++++++++IlrSyntacticEditorPane.buildPopupMenu++++++++++++++");
try
{
//¹ÚÇ×¼® Ãß°¡ - select a condition ÃÖÃÊ ¼±Åà ÈÄ select a condition °ú search a conditionÀ» ´Ù½Ã ¼±Åà ÇÏ°Ô ¸¸µå´Â popup menu ¸¸µé±â
if(getsearchconditioncheck(token)){
String as[] = {"") && obj==null && balcheck!=null && balcheck.indexOf("bal46")!=-1){
checksearch=true;
}
}
return checksearch;
}
public void hidePopupMenu()
{
if(isPopupMenuVisible())
popupMenu.setVisible(false);
popupToken = null;
}

public void togglePopupMenu(ilog.rules.brl.IlrToken.ChoiceToken choicetoken)
{
if(IlrToken.hasComponent(choicetoken))
return;
if(choicetoken == popupToken)
hidePopupMenu();
else
showPopupMenu(choicetoken);
}

public boolean isPopupMenuVisible()
{
return popupMenu != null && popupMenu.isVisible();
}

public IlrSyntacticEditorPopupMenu getPopupMenu()
{
return popupMenu;
}

public void setMenuChoice(ilog.rules.brl.IlrToken.ChoiceToken choicetoken, String s)
{
//¹ÚÇ×¼® Ãß°¡ search a condition ¼±Åýà set
//System.out.println("+++++++++++++++++++++++++++++IlrSyntacticEditorPane.setMenuChoice++++++++++++++");
String choicetokenstr = null;
choicetokenstr=choicetoken.getText();
hidePopupMenu();
if(isEditedToken(choicetoken))
{
if(choicetokenstr!=null && choicetokenstr.equals("")){
//System.out.println("+++++++++++++++++++++++++++++IlrSyntacticEditorPane.setMenuChoice1++++++++++++++");
boolean flag = IlrToken.isTokenTextEmpty(choicetoken);
choicetoken.setDisplayChoice(s);
selectToken(choicetoken, false);
if(flag){
document.resetTokenStyle(choicetoken);
}
// IlrGrammarChoices tokenÀº token setÀ» ÇÏ¸é ¾ÈµÈ´Ù.
String s1 = document.getTokenElementText(choicetoken);
if(IlrBRLUtil.isEmptyString(s1))
{
choicetoken.setText(s);
}
stopEditing();
}else{
//System.out.println("+++++++++++++++++++++++++++++IlrSyntacticEditorPane.setMenuChoice.replaceWord++++++++++++++");
replaceWord(s);
}
} else
{
if(s!=null && s.equals("")){
//System.out.println("+++++++++++++++++++++++++++++IlrSyntacticEditorPane.setMenuChoice2++++++++++++++");
choicetoken.setDisplayChoice(s);
selectToken(choicetoken, false);
startEditing();
}else{
//System.out.println("+++++++++++++++++++++++++++++IlrSyntacticEditorPane.setMenuChoice3++++++++++++++");
boolean flag = IlrToken.isTokenTextEmpty(choicetoken);
choicetoken.setDisplayChoice(s);
selectToken(choicetoken, false);
if(flag){
document.resetTokenStyle(choicetoken);
}
}
}
}

public void showContextualMenu(Point point)
{
IlrPopupMenu ilrpopupmenu = buildContextualMenu();
if(ilrpopupmenu != null && ilrpopupmenu.getComponentCount() > 0)
ilrpopupmenu.show(this, point.x, point.y);
}

protected IlrPopupMenu buildContextualMenu()
{
IlrPopupMenu ilrpopupmenu = new IlrPopupMenu(this);
if(hasSelectedTokens() && isEditionMode())
{
addCutAndPasteMenuItems(ilrpopupmenu);
if(!isEditing())
{
addMultipleMenuItems(ilrpopupmenu);
if(getTokenModel().isTemplate())
addFreezeMenuItems(ilrpopupmenu);
}
} else
if(isEditable())
{
addNoSelectionMenuItems(ilrpopupmenu);
addBRLDFMenuItems(ilrpopupmenu);
}
return ilrpopupmenu;
}

private String makeLabel(String s, String s1, boolean flag)
{


if(s == null)
{
if(s1 != null)
s = getMessage(s1);
} else
{
s = getTokenModel().getMessage(s);
}



if(s == null)
return "";
s = s.trim();
if(s.length() == 0)
return "";
if(flag)
return " " + s;
else
return s;
}

protected void addCutAndPasteMenuItems(IlrPopupMenu ilrpopupmenu)
{
Vector vector = new Vector();
int i = cutAndCopySelectionType(vector);
boolean flag = i != 0;
boolean flag1 = i != 0;
String s = "";
if(i == 1)
{
flag = document.canRemoveTokens(vector);
flag1 = document.canInsertTokens(vector);
s = buildTokensLabel(vector, "Label.Term", "Label.Terms");
}
boolean flag2 = canPasteClipboard();
Vector vector1 = getClipboard();
String s1 = "";
if(vector1 != null)
s1 = buildTokensLabel(vector1, "Label.Term", "Label.Terms");
JMenuItem jmenuitem = new JMenuItem(getMessage("MenuItem.Delete") + s);
jmenuitem.addActionListener(removeSelectionAction);
jmenuitem.setEnabled(flag);
ilrpopupmenu.add(jmenuitem);
jmenuitem = new JMenuItem(getMessage("MenuItem.Cut") + s);
jmenuitem.addActionListener(cutSelectionAction);
jmenuitem.setEnabled(flag && flag1);
ilrpopupmenu.add(jmenuitem);
jmenuitem = new JMenuItem(getMessage("MenuItem.Copy") + s);
jmenuitem.addActionListener(copySelectionAction);
jmenuitem.setEnabled(flag1);
ilrpopupmenu.add(jmenuitem);
jmenuitem = new JMenuItem(getMessage("MenuItem.Paste") + s1);
jmenuitem.addActionListener(pasteSelectionAction);
jmenuitem.setEnabled(flag2);
ilrpopupmenu.add(jmenuitem);
}

protected void addMultipleMenuItems(IlrPopupMenu ilrpopupmenu)
{
Vector vector = getSelectedTokens();
ilog.rules.brl.IlrToken.AbstractMultipleToken abstractmultipletoken = IlrToken.findMultipleToken(vector);
if(abstractmultipletoken == null)
return;
if(abstractmultipletoken instanceof ilog.rules.brl.IlrToken.ExpressionToken)
{
ilog.rules.brl.IlrToken.ExpressionToken expressiontoken = (ilog.rules.brl.IlrToken.ExpressionToken)abstractmultipletoken;
ilog.rules.brl.IlrToken.Token token = (ilog.rules.brl.IlrToken.Token)vector.elementAt(0);
ilog.rules.brl.IlrToken.Token token1 = (ilog.rules.brl.IlrToken.Token)vector.elementAt(vector.size() - 1);
boolean flag = expressiontoken.canInsertBefore(token);
boolean flag1 = expressiontoken.canInsertAfter(token1);
token = IlrToken.findChildToken(token, expressiontoken);
token1 = IlrToken.findChildToken(token1, expressiontoken);
int i = expressiontoken.indexOf(token);
int j = expressiontoken.indexOf(token1) + 1;
boolean flag2 = !expressiontoken.canInsertValue(i);
boolean flag3 = !expressiontoken.canInsertValue(j);
boolean flag4 = i >= expressiontoken.firstSignificantIndex();
boolean flag5 = j <= expressiontoken.lastSignificantIndex() + 1;
boolean flag6 = false;
boolean flag7 = false;
boolean flag8 = false;
ilog.rules.brl.IlrToken.Token token2 = expressiontoken.getUnaryOperatorTokenModel();
Object obj = null;
if(document.canInsertInMultiple(expressiontoken))
{
String s1 = expressiontoken.getValueTokenModel().getLabel(false);
s1 = makeLabel(s1, "Label.Term", true);

JMenuItem jmenuitem1 = new JMenuItem(getMessage("MenuItem.Insert") + s1);
jmenuitem1.addActionListener(insertTermAction);
ilrpopupmenu.add(jmenuitem1);
}
if(flag2 && flag && flag4)
{
JMenuItem jmenuitem2 = new JMenuItem("(...");
jmenuitem2.addActionListener(startParenthesisAction);
if(!flag8)
{
ilrpopupmenu.addSeparator();
flag8 = true;
}
ilrpopupmenu.add(jmenuitem2);
flag6 = true;
}
if(!flag2 && flag && flag4 && i > 0)
{
JMenuItem jmenuitem3 = new JMenuItem(")...");
jmenuitem3.addActionListener(startParenthesisAction);
if(!flag8)
{
ilrpopupmenu.addSeparator();
flag8 = true;
}
ilrpopupmenu.add(jmenuitem3);
}
if(flag3 && flag1 && flag5)
{
JMenuItem jmenuitem4 = new JMenuItem("...(");
jmenuitem4.addActionListener(endParenthesisAction);
if(!flag8)
{
ilrpopupmenu.addSeparator();
flag8 = true;
}
ilrpopupmenu.add(jmenuitem4);
}
if(!flag3 && flag1 && flag5)
{
JMenuItem jmenuitem5 = new JMenuItem("...)");
jmenuitem5.addActionListener(endParenthesisAction);
if(!flag8)
{
ilrpopupmenu.addSeparator();
flag8 = true;
}
ilrpopupmenu.add(jmenuitem5);
flag7 = true;
}
if(flag6 && flag7)
{
JMenuItem jmenuitem6 = new JMenuItem("(...)");
jmenuitem6.addActionListener(bothParenthesisAction);
if(!flag8)
{
ilrpopupmenu.addSeparator();
boolean flag9 = true;
}
ilrpopupmenu.add(jmenuitem6);
}
if(token2 != null)
{
String s2 = token2.getLabel(false);
s2 = makeLabel(s2, "Label.UnaryOperator", false);

if(flag2 && flag && flag4 && checkNoUnaryOperatorToken(expressiontoken, i))
{
JMenuItem jmenuitem7 = new JMenuItem(s2 + " ...");
jmenuitem7.addActionListener(insertUnaryOperatorBeforeAction);
ilrpopupmenu.add(jmenuitem7);
if(token.isTemplateFrozen())
jmenuitem7.setEnabled(false);
}
if(flag3 && flag1 && flag5 && checkNoUnaryOperatorToken(expressiontoken, i + 1))
{
JMenuItem jmenuitem8 = new JMenuItem("... " + s2);
jmenuitem8.addActionListener(insertUnaryOperatorAfterAction);
ilrpopupmenu.add(jmenuitem8);
}
}
} else
if(abstractmultipletoken instanceof ilog.rules.brl.IlrToken.MultipleToken)
{
ilog.rules.brl.IlrToken.MultipleToken multipletoken = (ilog.rules.brl.IlrToken.MultipleToken)abstractmultipletoken;
if(document.canInsertInMultiple(multipletoken))
{
String s = multipletoken.getChildTokenLabel(false);
s = makeLabel(s, "Label.Term", true);

JMenuItem jmenuitem = new JMenuItem(getMessage("MenuItem.Insert") + s);
jmenuitem.addActionListener(insertTermAction);
ilrpopupmenu.add(jmenuitem);
}
}
}

protected void addFreezeMenuItems(IlrPopupMenu ilrpopupmenu)
{
Vector vector = getSelectedTokens();
if(vector != null && vector.size() > 0)
{
JMenuItem jmenuitem = new JMenuItem(getMessage("MenuItem.Freeze"));
jmenuitem.addActionListener(freezeTokensAction);
jmenuitem.setEnabled(IlrToken.oneFreezableToken(vector));
ilrpopupmenu.add(jmenuitem);
jmenuitem = new JMenuItem(getMessage("MenuItem.Unfreeze"));
jmenuitem.addActionListener(unfreezeTokensAction);
jmenuitem.setEnabled(IlrToken.oneFrozenToken(vector));
ilrpopupmenu.add(jmenuitem);
}
}

protected void addNoSelectionMenuItems(IlrPopupMenu ilrpopupmenu)
{
if(isEditable() && isEditionMode() && getTokenModel().isTemplate())
{
JMenuItem jmenuitem = new JMenuItem(getMessage("MenuItem.FreezeAll"));
jmenuitem.addActionListener(freezeAllAction);
ilrpopupmenu.add(jmenuitem);
jmenuitem = new JMenuItem(getMessage("MenuItem.UnfreezeAll"));
jmenuitem.addActionListener(unfreezeAllAction);
ilrpopupmenu.add(jmenuitem);
}
}

protected void addBRLDFMenuItems(IlrPopupMenu ilrpopupmenu)
{
if(isEditable() && isEditionMode() && getTokenModel().isTemplate() && (getTokenModel() instanceof IlrGrammarTokenModel))
{
JMenuItem jmenuitem = new JMenuItem(getMessage("MenuItem.ReloadBRLDefinition"));
jmenuitem.addActionListener(reloadBRLDefinitionAction);
ilrpopupmenu.add(jmenuitem);
}
}

public void reloadBRLDefinition()
{
((IlrGrammarTokenModel)getTokenModel()).updateBRLDefinition();
}

public void beginUpdate()
{
IlrTokenModel ilrtokenmodel = getTokenModel();
if(ilrtokenmodel != null)
ilrtokenmodel.beginUpdate();
}

public void endUpdate()
{
IlrTokenModel ilrtokenmodel = getTokenModel();
if(ilrtokenmodel != null)
ilrtokenmodel.endUpdate();
}

private void insertInMultiple(int i)
{

Vector vector = getSelectedTokens();
if(vector != null)
{
beginUpdate();
ilog.rules.brl.IlrToken.AbstractMultipleToken abstractmultipletoken = IlrToken.findMultipleToken(vector);
if(abstractmultipletoken instanceof ilog.rules.brl.IlrToken.ExpressionToken)
{
ilog.rules.brl.IlrToken.ExpressionToken expressiontoken = (ilog.rules.brl.IlrToken.ExpressionToken)abstractmultipletoken;
ilog.rules.brl.IlrToken.Token token = (ilog.rules.brl.IlrToken.Token)vector.elementAt(0);
ilog.rules.brl.IlrToken.Token token2 = (ilog.rules.brl.IlrToken.Token)vector.elementAt(vector.size() - 1);
ilog.rules.brl.IlrToken.Token token3 = IlrToken.findChildToken(token, expressiontoken);
ilog.rules.brl.IlrToken.Token token4 = IlrToken.findChildToken(token2, expressiontoken);
int k = expressiontoken.indexOf(token3);
int l = expressiontoken.indexOf(token4) + 1;
switch(i)
{
case 0: // ''\0''
expressiontoken.addParenthesisToken(k);
break;

case 1: // ''\001''
expressiontoken.addParenthesisToken(l);
break;

case 2: // ''\002''
expressiontoken.addParenthesisToken(k);
expressiontoken.addParenthesisToken(l + 1);
break;

case 3: // ''\003''
int i1 = expressiontoken.getInsertionIndex(null, token);
expressiontoken.addNewChildTokens(i1);
break;

case 4: // ''\004''
expressiontoken.addUnaryOperatorToken(k);
break;

case 5: // ''\005''
expressiontoken.addUnaryOperatorToken(k + 1);
break;
}
} else
if(abstractmultipletoken instanceof ilog.rules.brl.IlrToken.MultipleToken)
{
ilog.rules.brl.IlrToken.MultipleToken multipletoken = (ilog.rules.brl.IlrToken.MultipleToken)abstractmultipletoken;
ilog.rules.brl.IlrToken.Token token1 = (ilog.rules.brl.IlrToken.Token)vector.elementAt(0);
switch(i)
{
case 3: // ''\003''
int j = multipletoken.getInsertionIndex(null, token1);
multipletoken.addNewChildTokens(j);
break;
}
}
endUpdate();
}
}

public String buildTokensLabel(Vector vector, String s, String s1)
{
String s2 = null;
if(vector != null && vector.size() > 0)
{
Vector vector1 = new Vector(vector.size());
for(int i = 0; i < vector.size(); i++)
if(vector.elementAt(i) instanceof ilog.rules.brl.IlrToken.Token)
{
ilog.rules.brl.IlrToken.Token token = (ilog.rules.brl.IlrToken.Token)vector.elementAt(i);
String s3 = null;
if(!ilog.rules.brl.IlrToken.ExpressionToken.isOperatorToken(token) && !ilog.rules.brl.IlrToken.ExpressionToken.isUnaryOperatorToken(token) && !ilog.rules.brl.IlrToken.ExpressionToken.isParenthesisToken(token)){
s3 = makeLabel(token.getLabel(false), s, false);

}
vector1.addElement(s3);
}

for(int j = 0; j < vector1.size(); j++)
{
String s4 = (String)vector1.elementAt(j);
if(s4 != null)
{
boolean flag = false;
for(int k = j + 1; k < vector1.size(); k++)
{
String s5 = (String)vector1.elementAt(k);
if(s4.equals(s5))
{
flag = true;
vector1.setElementAt(null, k);
}
}

if(flag)
{
ilog.rules.brl.IlrToken.Token token1 = (ilog.rules.brl.IlrToken.Token)vector.elementAt(j);
s4 = makeLabel(token1.getLabel(true), s1, false);

}
if(s4 != null)
if(s2 == null)
s2 = " " + s4;
else
s2 = s2 + " and";
}
}

}
return s2 != null ? s2 : "";
}

private boolean checkNoUnaryOperatorToken(ilog.rules.brl.IlrToken.ExpressionToken expressiontoken, int i)
{
if(expressiontoken.isMultipleUnaryOperators())
return true;
int j = expressiontoken.subTokensCount();
if(i < j && i >= 0)
{
ilog.rules.brl.IlrToken.Token token = expressiontoken.getSubToken(i);
if(ilog.rules.brl.IlrToken.ExpressionToken.isUnaryOperatorToken(token))
return false;
}
if(--i < j && i >= 0)
{
ilog.rules.brl.IlrToken.Token token1 = expressiontoken.getSubToken(i);
if(ilog.rules.brl.IlrToken.ExpressionToken.isUnaryOperatorToken(token1))
return false;
}
return true;
}

public void freezeSelectedTokens()
{
IlrToken.freezeTokens(getSelectedTokens());
}

public void unfreezeSelectedTokens()
{
IlrToken.unfreezeTokens(getSelectedTokens());
}

public void freezeAllTokens()
{
Vector vector = new Vector();
vector.addElement(getTokenModel().getRootToken());
IlrToken.freezeTokens(vector);
}

public void unfreezeAllTokens()
{
Vector vector = new Vector();
vector.addElement(getTokenModel().getRootToken());
IlrToken.unfreezeTokens(vector);
}

public boolean deleteSelection(boolean flag)
{
return deleteSelection(flag, false);
}

public boolean deleteSelection(boolean flag, boolean flag1)
{
byte byte0 = flag1 ? ((byte)(flag ? 3 : 2)) : ((byte) (((byte)(flag ? 1 : 0))));
return applyToSelection(byte0) != 0;
}

public boolean removeSelection()
{
return applyToSelection(4) != 0;
}

public boolean cutSelection()
{
return applyToSelection(5) != 0;
}

public boolean copySelection()
{
return applyToSelection(6) != 0;
}

public int cutAndCopySelectionType(Vector vector)
{
return applyToSelection(7, vector);
}

private int applyToSelection(int i)
{
return applyToSelection(i, null);
}

private int applyToSelection(int i, Vector vector)
{
int j = 0;
if(isEditable())
{
IlrSyntacticEditorCaret ilrsyntacticeditorcaret = getSyntacticCaret();
if(ilrsyntacticeditorcaret == null)
return j;
if(isEditing())
{
int k = ilrsyntacticeditorcaret.getDot();
int l = ilrsyntacticeditorcaret.getMark();
int i1 = 0;
int j1 = 0;
boolean flag = false;
if(i == 3)
{
i1 = Math.min(k, l);
int k1 = document.getPreviousWordStart(i1);
j1 = i1 - k1;
i1 = k1;
} else
if(i == 2)
{
i1 = Math.min(k, l);
int l1 = document.getNextWordEnd(i1);
j1 = l1 - i1;
} else
if(k != l)
{
i1 = Math.min(k, l);
j1 = Math.abs(k - l);
} else
if(i == 0)
{
if(k < document.getLength())
{
i1 = k;
j1 = 1;
}
} else
if(i == 1 && k > 0)
{
i1 = k - 1;
j1 = 1;
}
if(j1 > 0 && isAreaEditable(i1, j1))
{
switch(i)
{
case 5: // ''\005''
cut();
break;

case 6: // ''\006''
copy();
break;

case 0: // ''\0''
case 1: // ''\001''
case 2: // ''\002''
case 3: // ''\003''
case 4: // ''\004''
replaceSelection(i1, j1, null);
break;
}
j = 2;
}
} else
{
if(i != 7)
hidePopupMenu();
Vector vector1 = getSelectedTokens();
switch(i)
{
case 7: // ''\007''
if(document.canCopyTokens(vector1, vector))
j = 1;
break;

case 5: // ''\005''
Vector vector2 = new Vector();
if(document.cutTokens(vector1, vector2))
{
j = 1;
clipboard = vector2;
}
break;

case 6: // ''\006''
Vector vector3 = new Vector();
if(document.copyTokens(vector1, vector3))
{
j = 1;
clipboard = vector3;
}
break;

case 0: // ''\0''
case 1: // ''\001''
if(document.deleteTokens(vector1))
j = 1;
break;

case 4: // ''\004''
if(document.removeTokens(vector1))
j = 1;
break;
}
if(j != 0 && i != 7 && i != 6)
ilrsyntacticeditorcaret.updatePosition(false);
}
if(j == 0 && i != 7)
getToolkit().beep();
}
return j;
}

public boolean pasteClipboard()
{
return pasteClipboard(false);
}

public boolean canPasteClipboard()
{
return pasteClipboard(true);
}

private boolean pasteClipboard(boolean flag)
{
boolean flag1 = false;
if(isEditing())
{
if(isSelectionEditable())
{
if(!flag)
paste();
flag1 = true;
}
} else
if(isEditable() && clipboard != null && clipboard.size() > 0)
{
int i = getSelectionStart();
int j = getSelectionEnd();
if(i == j || !isSelectionEditable())
if(flag)
{
flag1 = document.canPasteTokens(i, clipboard);
} else
{
hidePopupMenu();
flag1 = document.pasteTokens(i, clipboard);
}
}
if(!flag1 && !flag)
getToolkit().beep();
return flag1;
}

public Vector getClipboard()
{
return clipboard;
}

public void paste()
{
Clipboard clipboard1 = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable transferable = clipboard1.getContents(this);
if(transferable.isDataFlavorSupported(DataFlavor.stringFlavor))
try
{
String s = (String)transferable.getTransferData(DataFlavor.stringFlavor);
s = s.replace(''\n'', '' '');
StringSelection stringselection = new StringSelection(s);
clipboard1.setContents(stringselection, stringselection);
}
catch(Exception exception) { }
super.paste();
}

public void cut()
{
if(isEditable() && isEnabled())
try
{
Clipboard clipboard1 = getToolkit().getSystemClipboard();
MutableAttributeSet mutableattributeset = getInputAttributes();
Caret caret = getCaret();
int i = Math.min(caret.getDot(), caret.getMark());
int j = Math.max(caret.getDot(), caret.getMark());
if(i != j)
{
Document document1 = getDocument();
String s = document1.getText(i, j - i);
StringSelection stringselection = new StringSelection(s);
clipboard1.setContents(stringselection, defaultClipboardOwner);
replaceSelection(i, j - i, null);
}
}
catch(BadLocationException badlocationexception) { }
else
getToolkit().beep();
}





protected static final Color Jdk12SelectedBackgroundColor = new Color(196, 219, 244);
protected static final Color SelectedBackgroundColor = UIManager.getColor("textHighlight");
protected static final Color SelectedForegroundColor = UIManager.getColor("textHighlightText");
protected static final Color NoFocusSelectedBackgroundColor = UIManager.getColor("inactiveCaption");
protected static final Color NoFocusSelectedForegroundColor = UIManager.getColor("inactiveCaptionText");
private String resourcePrefix;
private IlrStyledTokenDocument document;
private IlrSyntacticEditorPopupMenu popupMenu;
private ilog.rules.brl.IlrToken.Token popupToken;
private ilog.rules.brl.IlrToken.Token currentToken;
private boolean editing;
private IlrValueEditor valueEditor;
private boolean ghostEnabled;
private JComponent ghost;
private boolean ghostAdded;
private Object ghostObject;
private ilog.rules.brl.IlrToken.Token ghostToken;
private AttributeSet inputAttributes;
private IlrTokenComponent editedTokenComponent;
private String editedTokenText;
private Vector clipboard;
private IlrUndoSupportManager textUndoManager;
private static boolean qfTestActivation = IlrPreferences.getBoolean("builder.QFTest.activate", false);
private IlrSyntacticEditorInputMethod inputMethod;
private static boolean isJdkTested = false;
private static boolean isJdk13;
private static boolean isJdk14;
private static boolean isWindowsLook;
private static boolean french_flag;
private SelectionRemover selectionRemover;
private ActionListener editionModeAction;
private ActionListener removeSelectionAction;
private ActionListener cutSelectionAction;
private ActionListener copySelectionAction;
private ActionListener pasteSelectionAction;
private ActionListener freezeTokensAction;
private ActionListener unfreezeTokensAction;
private ActionListener freezeAllAction;
private ActionListener unfreezeAllAction;
private ActionListener reloadBRLDefinitionAction;
private static final int START_PARENTHESIS = 0;
private static final int END_PARENTHESIS = 1;
private static final int BOTH_PARENTHESIS = 2;
private static final int INSERT_TERM = 3;
private static final int INSERT_UNARY_OPERATOR_BEFORE = 4;
private static final int INSERT_UNARY_OPERATOR_AFTER = 5;
private MultipleAction startParenthesisAction;
private MultipleAction endParenthesisAction;
private MultipleAction bothParenthesisAction;
private MultipleAction insertTermAction;
private MultipleAction insertUnaryOperatorBeforeAction;
private MultipleAction insertUnaryOperatorAfterAction;
private static final int DELETE = 0;
private static final int DELETE_BEFORE = 1;
private static final int DELETE_WORD = 2;
private static final int DELETE_WORD_BEFORE = 3;
private static final int REMOVE = 4;
private static final int CUT = 5;
private static final int COPY = 6;
private static final int CHECK = 7;
public static final int NONE = 0;
public static final int TOKEN = 1;
public static final int TEXT = 2;
private static ClipboardOwner defaultClipboardOwner = new ClipboardObserver();

//¹ÚÇ×¼® Ãß°¡ - token array »ý¼º search½Ã classnameÀ» ã±â À§ÇØ
private ArrayList choiceIndexes;
// search popupmenu list
private static String popupmenustr[];


static
{
french_flag = Locale.getDefault().toString().equals(Locale.FRANCE.toString());
}

}




















// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)

package ilog.rules.ui.editor;

import ilog.rules.brl.IlrChoicesProvider;
import ilog.rules.brl.IlrToken;
import ilog.rules.brl.IlrToken.ChoiceToken;
import ilog.rules.ui.util.IlrPopupMenu;
import ilog.rules.ui.util.IlrScrollPane;
import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.EventObject;
import javax.swing.*;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.text.*;
import ilog.rules.ui.editor.IlrSyntacticEditorPane;

// Referenced classes of package ilog.rules.ui.editor:
// IlrSyntacticEditorPane, IlrStyledTokenDocument, IlrTokenActionManager

public class IlrSyntacticEditorPopupMenu extends IlrPopupMenu
{
private class NullAction
implements ActionListener
{

public void actionPerformed(ActionEvent actionevent)
{
}

private NullAction()
{
}

}

private class ReturnAction
implements ActionListener
{

public void actionPerformed(ActionEvent actionevent)
{
doAction();
setVisible(false);
setActionPerformed(true);
}

private ReturnAction()
{
}

}

private class CancelAction
implements ActionListener
{

public void actionPerformed(ActionEvent actionevent)
{
setVisible(false);
setActionPerformed(true);
}

private CancelAction()
{
}

}

private class PopupCaretListener
implements CaretListener
{

public void caretUpdate(CaretEvent caretevent)
{
searchMenuItem(caretevent.getDot());
}

PopupCaretListener()
{
}
}

protected class ListMouseMotionHandler extends MouseMotionAdapter
{

public void mouseMoved(MouseEvent mouseevent)
{
Point point = mouseevent.getPoint();
Rectangle rectangle = new Rectangle();
list.computeVisibleRect(rectangle);
if(rectangle.contains(point))
updateListBoxSelectionForEvent(mouseevent, false);
}

protected ListMouseMotionHandler()
{
}
}

protected class ListMouseHandler extends MouseAdapter
{

public void mousePressed(MouseEvent mouseevent)
{
}

public void mouseReleased(MouseEvent mouseevent)
{
doAction();
setVisible(false);
}

protected ListMouseHandler()
{
}
}


public IlrSyntacticEditorPopupMenu(IlrSyntacticEditorPane ilrsyntacticeditorpane, ilog.rules.brl.IlrToken.Token token1, String as[])
{
super(ilrsyntacticeditorpane);
minWidth = 50;
automaticSearch = false;
pane = ilrsyntacticeditorpane;
token = token1;
choices = as;
setOffScreenPolicy(1);
listMouseListener = new ListMouseHandler();
listMouseMotionListener = new ListMouseMotionHandler();
popupCaretListener = new PopupCaretListener();
list = createList();
configureList();
scroller = createScroller();
configureScroller();
configurePopup();
registerActions();
}

public boolean isFocusTraversable()
{
return false;
}

public boolean isFocusable()
{
return false;
}

public void setVisible(boolean flag)
{
super.setVisible(flag);
if(flag)
{
pane.addCaretListener(popupCaretListener);
searchMenuItem(pane.getCaret().getDot());
} else
{
pane.removeCaretListener(popupCaretListener);
}
}

public ilog.rules.brl.IlrToken.Token getToken()
{
return token;
}

public int getMaximumRowCount()
{
return maximumRowCount;
}

public void setMaximumRowCount(int i)
{
maximumRowCount = i;
}

public int getMinimumWidth()
{
return minWidth;
}

public void setMinimumWidth(int i)
{
minWidth = i;
}

public boolean isAutomaticSearch()
{
return automaticSearch;
}

public void setAutomaticSearch(boolean flag)
{
automaticSearch = flag;
}

public void doAction()
{
//¹ÚÇ×¼® Ãß°¡ - ¸¶¿ì½º·Î popup menu ¼±Åýà select a condition À̳ª search a condition °Ë»öµÈ popumenu ¿¡ µû¶ó¼­ ¼±ÅÃÀûÀ¸·Î action À» ¸¸µé¾î°¨
//System.out.println("+++++++++++++++++++++++++++++IlrSyntacticEditorPopupMenu.doAction++++++++++++++");
if(token != null)
{
String s = (String)list.getSelectedValue();
if(s != null)
{
IlrTokenActionManager ilrtokenactionmanager = pane.getTokenDocument().getTokenActionManager(token);
if(s.equals("") && obj==null){
checksearch=true;
}
}
return checksearch;
}

public void setSelectedIndex(int i)
{
if(i >= 0 && i < numberOfItems())
{
list.setSelectedIndex(i);
list.ensureIndexIsVisible(i);
} else
{
list.clearSelection();
}
}

public int getSelectedIndex()
{
return list.getSelectedIndex();
}

public int numberOfItems()
{
return list.getModel().getSize();
}

private static int SCWidth()
{
if(SCWidth == -1)
{
JScrollBar jscrollbar = new JScrollBar();
SCWidth = jscrollbar.getPreferredSize().width + 4;
}
return SCWidth;
}

public void show(Component component, int i, int j)
{
Dimension dimension = list.getPreferredScrollableViewportSize();
dimension.setSize(Math.max(minWidth, dimension.width), getPopupHeightForRowCount(getMaximumRowCount()));
if(list.getModel().getSize() > getMaximumRowCount())
dimension.setSize(dimension.width + SCWidth(), dimension.height);
scroller.setPreferredSize(dimension);
list.invalidate();
super.show(component, i, j);
}

protected void configurePopup()
{
setLayout(new BoxLayout(this, 1));
setBorderPainted(true);
javax.swing.border.Border border = BorderFactory.createLineBorder(Color.lightGray);
javax.swing.border.Border border1 = BorderFactory.createRaisedBevelBorder();
javax.swing.border.Border border2 = BorderFactory.createEtchedBorder();
javax.swing.border.CompoundBorder compoundborder = BorderFactory.createCompoundBorder(border, border1);
setBorder(BorderFactory.createCompoundBorder(compoundborder, border2));
setOpaque(false);
add(scroller);
setDoubleBuffered(true);
setRequestFocusEnabled(false);
callSetFocusable(this, true);
}

public void grabFocus()
{
if(!isIBMVM)
super.grabFocus();
}

protected JScrollPane createScroller()
{
return new IlrScrollPane(list, 20, 30);
}

protected void configureScroller()
{
scroller.setRequestFocusEnabled(false);
scroller.getVerticalScrollBar().setRequestFocusEnabled(false);
scroller.getHorizontalScrollBar().setRequestFocusEnabled(false);
callSetFocusable(scroller, false);
callSetFocusable(scroller.getVerticalScrollBar(), false);
callSetFocusable(scroller.getHorizontalScrollBar(), false);
scroller.setBorder(null);
}

protected JList createList()
{
return new JList(choices);
}

protected void configureList()
{
IlrStyledTokenDocument ilrstyledtokendocument = pane.getTokenDocument();
Object obj = ilrstyledtokendocument.getTokenStyle(token);
if(obj == null)
obj = ilrstyledtokendocument.getTokenAttributes(token);
if(obj != null)
list.setFont(ilrstyledtokendocument.getFont(((javax.swing.text.AttributeSet) (obj))));
list.setBorder(null);
list.setRequestFocusEnabled(false);
callSetFocusable(list, false);
list.setSelectionMode(0);
installListListeners();
}

protected void installListListeners()
{
list.addMouseMotionListener(listMouseMotionListener);
list.addMouseListener(listMouseListener);
}

protected int getPopupHeightForRowCount(int i)
{
int j = list.getModel().getSize();
int k = Math.min(i, j);
int l = 0;
ListCellRenderer listcellrenderer = list.getCellRenderer();
Object obj = null;
for(int i1 = 0; i1 < k; i1++)
{
Object obj1 = list.getModel().getElementAt(i1);
Component component = listcellrenderer.getListCellRendererComponent(list, obj1, i1, false, false);
l += component.getPreferredSize().height;
}

return l != 0 ? l : 100;
}

protected void updateListBoxSelectionForEvent(MouseEvent mouseevent, boolean flag)
{
Point point = mouseevent.getPoint();
if(list == null)
return;
int i = list.locationToIndex(point);
if(i == -1)
if(point.y < 0)
i = 0;
else
i = list.getModel().getSize() - 1;
if(list.getSelectedIndex() != i)
{
list.setSelectedIndex(i);
if(flag)
list.ensureIndexIsVisible(i);
}
}

public void searchMenuItem(int i)
{
IlrStyledTokenDocument ilrstyledtokendocument = pane.getTokenDocument();
int j = pane.getSelectionStart();
int k = pane.getSelectionEnd();
if(j == k)
{
j = ilrstyledtokendocument.getWordStart(i);
k = ilrstyledtokendocument.getWordEnd(i);
}
if(j != k)
try
{
String s = ilrstyledtokendocument.getText(j, k - j).trim();
int l = findCompletion(s);
setSelectedIndex(l);
}
catch(BadLocationException badlocationexception) { }
}

public int findCompletion(String s)
{
if(s != null && s.length() > 0)
{
int i = numberOfItems();
int j = -1;
for(int k = 0; k < i; k++)
{
String s1 = (String)list.getModel().getElementAt(k);
if(s1 != null)
{
if(s1.equals(s))
return k;
if(j == -1 && s1.startsWith(s))
j = k;
}
}

return j;
} else
{
return -1;
}
}

public int findCharCompletion(char c)
{
int i = numberOfItems();
for(int j = 0; j < i; j++)
{
String s = (String)list.getModel().getElementAt(j);
if(firstNonBlankChar(s) == c)
return j;
}

return -1;
}

private char firstNonBlankChar(String s)
{
int i = 0;
for(int j = s.length(); i < j && s.charAt(i) == '' ''; i++);
return s.charAt(i);
}

protected void performKeyEventAction(KeyEvent keyevent)
{
KeyStroke keystroke = KeyStroke.getKeyStrokeForEvent(keyevent);
ActionListener actionlistener = getRegisteredAction(keystroke);
if(actionlistener == null && isAutomaticSearch() && keystroke.getModifiers() == 0)
{
int i = findCharCompletion(keystroke.getKeyChar());
if(i != -1)
{
setSelectedIndex(i);
keyevent.consume();
}
}
if(actionlistener != null)
{
if(performActionForKeyStroke(actionlistener, keystroke))
keyevent.consume();
} else
{
Object obj = keyevent.getSource();
if(IlrSyntacticEditorPane.isJdk14())
callSetSource(keyevent, list);
list.dispatchEvent(keyevent);
if(IlrSyntacticEditorPane.isJdk14())
callSetSource(keyevent, obj);
}
}

protected void setActionPerformed(boolean flag)
{
super.actionPerformed = flag;
}

protected void registerActions()
{
registerAction(new CancelAction(), KeyStroke.getKeyStroke(''\033''));
registerAction(new ReturnAction(), KeyStroke.getKeyStroke(10, 0));
registerAction(new NullAction(), KeyStroke.getKeyStroke(''\t''));
registerAction(new NullAction(), KeyStroke.getKeyStroke(9, 0));
registerAction(new NullAction(), KeyStroke.getKeyStroke(9, 1));
registerAction(new NullAction(), KeyStroke.getKeyStroke(65, 2));
registerAction(new NullAction(), KeyStroke.getKeyStroke(36, 0));
registerAction(new NullAction(), KeyStroke.getKeyStroke(35, 0));
registerAction(new NullAction(), KeyStroke.getKeyStroke(36, 1));
registerAction(new NullAction(), KeyStroke.getKeyStroke(35, 1));
registerAction(new NullAction(), KeyStroke.getKeyStroke(36, 2));
registerAction(new NullAction(), KeyStroke.getKeyStroke(35, 2));
registerAction(new NullAction(), KeyStroke.getKeyStroke(37, 0));
registerAction(new NullAction(), KeyStroke.getKeyStroke(39, 0));
registerAction(new NullAction(), KeyStroke.getKeyStroke(8, 0));
registerAction(new NullAction(), KeyStroke.getKeyStroke(127, 0));
}

void callSetFocusable(Component component, boolean flag)
{
if(!setFocusableMethodSearched)
{
findSetFocusableMethod();
setFocusableMethodSearched = true;
}
if(setFocusableMethod != null)
try
{
setFocusableArg[0] = flag ? ((Object) (Boolean.TRUE)) : ((Object) (Boolean.FALSE));
setFocusableMethod.invoke(component, setFocusableArg);
}
catch(IllegalAccessException illegalaccessexception) { }
catch(InvocationTargetException invocationtargetexception) { }
}

private void findSetFocusableMethod()
{
if(!IlrSyntacticEditorPane.isJdk14())
return;
try
{
Class aclass[] = {
Boolean.TYPE
};
setFocusableMethod = (java.awt.Component.class).getMethod("setFocusable", aclass);
}
catch(NoSuchMethodException nosuchmethodexception) { }
}

void callSetSource(KeyEvent keyevent, Object obj)
{
if(!setSourceMethodSearched)
{
findSetSourceMethod();
setSourceMethodSearched = true;
}
if(setSourceMethod != null)
try
{
setSourceArg[0] = obj;
setSourceMethod.invoke(keyevent, setSourceArg);
}
catch(IllegalAccessException illegalaccessexception) { }
catch(InvocationTargetException invocationtargetexception) { }
}

private void findSetSourceMethod()
{
if(!IlrSyntacticEditorPane.isJdk14())
return;
try
{
Class aclass[] = {
java.lang.Object.class
};
setSourceMethod = (java.awt.event.KeyEvent.class).getMethod("setSource", aclass);
}
catch(NoSuchMethodException nosuchmethodexception) { }
}

public static int maximumRowCount = 14;
private IlrSyntacticEditorPane pane;
private ilog.rules.brl.IlrToken.Token token;
private String choices[];
private JList list;
private JScrollPane scroller;
private int minWidth;
private MouseListener listMouseListener;
private MouseMotionListener listMouseMotionListener;
private PopupCaretListener popupCaretListener;
private boolean automaticSearch;
private static boolean isIBMVM = false;
private static int SCWidth = -1;
private static boolean setFocusableMethodSearched = false;
private static Method setFocusableMethod;
private static Object setFocusableArg[];
private static boolean setSourceMethodSearched = false;
private static Method setSourceMethod;
private static Object setSourceArg[];

static
{
String s = System.getProperty("java.vm.vendor");
if(s.indexOf("IBM") != -1)
isIBMVM = true;
setFocusableArg = (new Object[] {
Boolean.TRUE
});
setSourceArg = (new Object[] {
Boolean.TRUE
});
}

}
°ü·Ã±Û º¸±â
"search condition 2"¿Í(°ú) °ü·ÃµÈ ±ÛÀÌ  0°Ç ÀÖ½À´Ï´Ù.
search condition 2 ±èÁ¤È£ 2006-06-13