1 package net.suberic.pooka.gui; 2 import java.util.*; 3 4 8 public class DisplayStyleComboBox extends net.suberic.util.gui.ConfigurableComboBox { 9 10 public boolean displayStyle = false; 11 public boolean headerStyle = false; 12 13 19 public void configureComponent(String key, net.suberic.util.VariableBundle vars) { 20 super.configureComponent(key, vars); 21 22 24 for (int i = 0; i < getItemCount(); i++) { 25 String cmd = (String ) selectionMap.get(getItemAt(i)); 26 if (cmd.equalsIgnoreCase("file-open-textdisplay") || cmd.equalsIgnoreCase("file-open-htmldisplay") || cmd.equalsIgnoreCase("file-open-rawdisplay")) { 27 displayStyle = true; 28 } else if (cmd.equalsIgnoreCase("file-open-defaultdisplay") || cmd.equalsIgnoreCase("file-open-fulldisplay")) { 29 headerStyle=true; 30 } 31 } 32 33 } 34 35 38 public void styleUpdated(int newDisplayStyle, int newHeaderStyle) { 39 42 for (int i = 0; i < getItemCount(); i++) { 43 String cmd = (String ) selectionMap.get(getItemAt(i)); 44 if (cmd != null) { 45 javax.swing.Action currentAction = getAction(cmd); 46 while (currentAction instanceof net.suberic.util.thread.ActionWrapper) { 47 currentAction = ((net.suberic.util.thread.ActionWrapper) currentAction).getWrappedAction(); 48 } 49 if (currentAction != null && currentAction instanceof MessageProxy.OpenAction) { 50 MessageProxy.OpenAction oa = (MessageProxy.OpenAction) currentAction; 51 if (((displayStyle && (oa.getDisplayModeValue() == newDisplayStyle)) || !displayStyle) && ((headerStyle && (oa.getHeaderModeValue() == newHeaderStyle)) || !headerStyle)) { 52 if (getSelectedIndex() != i) { 53 setSelectedIndex(i); 54 } 55 } 56 } 57 } 58 } 59 } 60 61 } 62 | Popular Tags |