⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jawetypechoicebutton.java

📁 jawe的最新版本,基于Java的图形化工作流编辑器。图形化工作流编辑器 。使用JAVA语言开发
💻 JAVA
字号:
/** * Miroslav Popov, Oct 4, 2005 * miroslav.popov@gmail.com */package org.enhydra.jawe.base.controller;import java.awt.Dimension;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.Iterator;import java.util.List;import javax.swing.Icon;import javax.swing.ImageIcon;import javax.swing.JMenuItem;import javax.swing.JPopupMenu;import org.enhydra.jawe.ChoiceButton;import org.enhydra.jawe.ChoiceButtonListener;import org.enhydra.shark.utilities.SequencedHashMap;/** * @author Miroslav Popov *   */public class JaWETypeChoiceButton extends ChoiceButton implements ActionListener{   protected ChoiceButtonListener parent;      protected SequencedHashMap choiceMap=new SequencedHashMap();   protected JPopupMenu popup=new JPopupMenu();   protected Class choiceType;   protected Class xpdlChoiceType;   protected Class xpdlChoiceTypeParentForEA;      public JaWETypeChoiceButton(Class choiceType,Class xpdlChoiceType,Class xpdlChoiceTypeParentForEA,ChoiceButtonListener parent,ImageIcon icon) {      this.parent = parent;      this.choiceType=choiceType;      this.xpdlChoiceType=xpdlChoiceType;      this.xpdlChoiceTypeParentForEA=xpdlChoiceTypeParentForEA;            setIcon(icon);      addActionListener(this);      setMargin(new Insets(1, 2, 1, 2));      setSize(new Dimension(10, 8));      setAlignmentY(0.5f);   }   public void actionPerformed(ActionEvent ae) {      if (ae.getSource() == this) {         refresh();         if (choiceMap.size() > 1) {            popup.show(this.getParent(), this.getX(), this.getY()+this.getHeight());         }      } else {         JMenuItem selected = (JMenuItem) ae.getSource();         int sel=popup.getComponentIndex(selected);         Object obj=choiceMap.getValue(sel);         parent.selectionChanged(this,obj);         choiceMap.clear();      }         }   protected void refresh() {      choiceMap.clear();      popup.removeAll();      List choices = parent.getChoices(this);      if (choices != null) {         Iterator it = choices.iterator();         while (it.hasNext()) {            JaWEType jtype = (JaWEType) it.next();            choiceMap.put(jtype.getDisplayName(), jtype);         }      }       if (choiceMap.size() > 1) {         String[] names = new String[choiceMap.size()];         choiceMap.keySet().toArray(names);         for (int i = 0; i < choiceMap.size(); i++) {            JMenuItem mi = popup.add(names[i]);            Icon icon = ((JaWEType)choiceMap.getValue(i)).getIcon();            if (icon != null)	            mi.setIcon(icon);            mi.addActionListener(this);         }      }            if (choiceMap.size() == 1)         parent.selectionChanged(this, choiceMap.getValue(0));            if (choiceMap == null || choiceMap.size() == 0) {         parent.selectionChanged(this, null);      }   }   public Class getChoiceType () {      return choiceType;   }      public Class getXPDLChoiceType () {      return xpdlChoiceType;   }      public Class getXPDLChoiceTypeParentForEA () {      return xpdlChoiceTypeParentForEA;   }      }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -