public void setRestrictingValuesToThoseInList(boolean flag) { restrictingValuesToThoseInList = flag; if (flag) { list.getSelectionManager().setMinimumNumberSelected(1); } else { list.getSelectionManager().setMinimumNumberSelected(0); } }
public void setContents(Strings contents) { list.setContents(contents); String value = textField.getValue(); if (restrictingValuesToThoseInList) { if ((!contents.contains(value)) && (contents.size() > 0)) { textField.setValue(contents.elementAt(0)); list.setValue(textField.getValue()); } } else { if (!list.getContents().contains(value)) list.getSelectionManager().deSelectAll(); else list.setValue(textField.getValue()); } }
public void setList(MiTable list) { if (this.list != null) this.list.removeActionHandlers(this); this.list = list; list.appendActionHandler(this, Mi_ITEM_SELECTED_ACTION); list.setMinimumNumberOfVisibleRows(3); list.setPreferredNumberOfVisibleRows(7); list.setInsetMargins(0); MiToolkit.setBackgroundAttributes( list.getContentsBackground(), MiToolkit.Mi_TOOLKIT_UNEDITABLE_BG_ATTRIBUTES); list.getSelectionManager().setMinimumNumberSelected(1); // Do not allow interactive resizing of scrolled list cause not usefull and // when menu pops down the TableHeaderAndFooterManager is left grabbing the window list.getTableHeaderAndFooterManager().setEnabled(false); scrolledBox = new MiScrolledBox(list); scrolledBox.setInsetMargins(0); if (menu != null) menu.removeActionHandlers(this); menu = new MiMenu(scrolledBox); menu.setInsetMargins(2); menu.insertActionHandler(this, Mi_VISIBLE_ACTION, 0); menuLauncherButton.setMenu(menu); }
/** * This method sets the value of Text, Widgets and pure Strings. Warning, right and center * justfication does not work for pure String cells, only graphics cells. */ public void setValue(String value) { if ((strValue == value) || ((strValue != null) && (strValue.equals(value)))) return; if (graphics != null) { if (graphics instanceof MiWidget) ((MiWidget) graphics).setValue(value); if (graphics instanceof MiText) ((MiText) graphics).setText(value); } strValue = value; table.invalidateLayout(); }
public void setVisible(boolean flag) { visible = flag; // Graphics may be a table (i.e. subwindow which is registered with Draw Manager) // which will get drawn regardless of whether this cell is visible or not... if (graphics != null) { graphics.setVisible(flag); } table.invalidateLayout(); }
public void setValue(String value) { if (value != null) { value = MiSystem.getProperty(value, value); } if (Utility.isEqualTo(value, textField.getValue())) { return; } if (restrictingValuesToThoseInList) { if ((list.getIndexOfItem(value, restrictionIgnoresCase) == -1) && (list.getNumberOfItems() > 0)) { if (restrictionWarnsOnly) { textField.setValue(value); list.getSelectionManager().deSelectAll(); } else { throw new IllegalArgumentException( MiDebug.getMicaClassName(this) + ": Rejecting value: \"" + value + "\" because it is not present in list" + " (see MiComboBox.setRestrictingValuesToThoseInList()).\n" + "Values present in list are: " + getContents()); } } } textField.setValue(value); if (!list.getContents().contains(value)) list.getSelectionManager().deSelectAll(); else list.setValue(textField.getValue()); }
// Of graphics... public MiSize getPreferredSize(MiSize size) { if (graphics != null) { graphics.getPreferredSize(size); } else if (attributes != null) { attributes.getFont().getSize(strValue, size); } else { table.getAttributes().getFont().getSize(strValue, size); } if (insetMargins != null) size.addMargins(insetMargins); if (margins != null) size.addMargins(margins); return (size); }
public boolean processAction(MiiAction action) { // MiDebug.println(this + " proecssAction: " + action); if (action.hasActionType(Mi_ITEM_SELECTED_ACTION)) { textField.setValue(list.getSelectedItem()); dispatchAction(Mi_VALUE_CHANGED_ACTION); menu.popdown(); } else if (action.hasActionType(Mi_LOST_KEYBOARD_FOCUS_ACTION | Mi_REQUEST_ACTION_PHASE)) { if (restrictingValuesToThoseInList) { String value = textField.getValue(); if ((list.getIndexOfItem(value) == -1) && (list.getNumberOfItems() > 0)) { if (restrictionWarnsOnly) { dispatchAction(Mi_INVALID_VALUE_ACTION); } else { action.veto(); dispatchAction(Mi_INVALID_VALUE_ACTION); if (MiDebug.debug && MiDebug.isTracing(null, MiDebug.TRACE_KEYBOARD_FOCUS_DISPATCHING)) { MiDebug.println( MiDebug.getMicaClassName(this) + ": Rejecting loss of keyboard focus because " + "isRestrictingValuesToThoseInList() == true."); } return (true); } } } dispatchAction(Mi_VALUE_CHANGED_ACTION); } else if ((action.hasActionType(Mi_LOST_KEYBOARD_FOCUS_ACTION)) || (action.hasActionType(Mi_ENTER_KEY_ACTION))) { dispatchAction(Mi_VALUE_CHANGED_ACTION); if (!list.getContents().contains(textField.getValue())) list.getSelectionManager().deSelectAll(); else list.setValue(textField.getValue()); } else if (action.hasActionType(Mi_TEXT_CHANGE_ACTION)) { dispatchAction(Mi_TEXT_CHANGE_ACTION); } else if (action.hasActionType(Mi_VISIBLE_ACTION)) { MiSize prefSize = menu.getPreferredSize(new MiSize()); if (prefSize.getWidth() < getWidth() - getMargins(new MiMargins()).getWidth()) { prefSize.setWidth(getWidth() - getMargins(new MiMargins()).getWidth()); menu.setPreferredSize(prefSize); menu.setSize(prefSize); menu.validateLayout(); } } return (true); }
public void setGraphics(MiPart part) { if (graphics == part) return; if (graphics != null) { if (part != null) { graphics.replaceSelf(part); } else { graphics.removeSelf(); } graphics = part; } else { graphics = part; if (graphics != null) { table.getAppropriateContainer(rowNumber, columnNumber).appendPart(graphics); } } /** * * MiContainer container = table.getAppropriateContainer(rowNumber, columnNumber); if * (graphics != null) container.removePart(graphics); graphics = part; if (graphics != null) * container.appendPart(graphics); * */ }
public void setVerticalJustification(int justification) { vJustification = justification; table.invalidateLayout(); }
// When assigned a string value this is used // (otherwise uses table's attributes) // Also used for statusHelp public void setAttributes(MiAttributes attributes) { this.attributes = attributes; table.invalidateLayout(); }
/** * ------------------------------------------------------ Sets the height of the column this cell * represents. Used by table row and column defaults only. If the desire is to not let the user * resize this height, then set this cell's attributes by setFixedHeight(true); * * @param width the height * @see #setFixedWidth * @see #getFixedHeight ------------------------------------------------------ */ public void setFixedHeight(MiDistance height) { fixedHeight = height; table.invalidateLayout(); }
/** * ------------------------------------------------------ Sets the width of the column this cell * represents. Used by table row and column defaults only. If the desire is to not let the user * resize this width, then set this cell's attributes by setFixedWidth(true); * * @param width the width * @see #getFixedWidth * @see #setFixedHeight ------------------------------------------------------ */ public void setFixedWidth(MiDistance width) { fixedWidth = width; table.invalidateLayout(); }
public void setMargins(MiMargins margins) { this.margins = margins; table.invalidateLayout(); }
public void setVerticalSizing(int sizing) { vSizing = sizing; table.invalidateLayout(); }
public void setHorizontalJustification(int justification) { hJustification = justification; table.invalidateLayout(); }
public Strings getContents() { return (list.getContents()); }
protected void layoutParts() { MiTableCell defaults; int h_sizing = hSizing; if (h_sizing == Mi_NONE) { defaults = table.getRowDefaults(rowNumber); if (defaults != null) h_sizing = defaults.hSizing; } if (h_sizing == Mi_NONE) { defaults = table.getColumnDefaults(columnNumber); if (defaults != null) h_sizing = defaults.hSizing; } if (h_sizing == Mi_NONE) { defaults = table.getTableWideDefaults(); if (defaults != null) h_sizing = defaults.hSizing; } int v_sizing = vSizing; if (v_sizing == Mi_NONE) { defaults = table.getRowDefaults(rowNumber); if (defaults != null) v_sizing = defaults.vSizing; } if (v_sizing == Mi_NONE) { defaults = table.getColumnDefaults(columnNumber); if (defaults != null) v_sizing = defaults.vSizing; } if (v_sizing == Mi_NONE) { defaults = table.getTableWideDefaults(); if (defaults != null) v_sizing = defaults.vSizing; } int h_justification = hJustification; if (h_justification == Mi_NONE) { defaults = table.getRowDefaults(rowNumber); if (defaults != null) h_justification = defaults.hJustification; } if (h_justification == Mi_NONE) { defaults = table.getColumnDefaults(columnNumber); if (defaults != null) h_justification = defaults.hJustification; } if (h_justification == Mi_NONE) { defaults = table.getTableWideDefaults(); if (defaults != null) h_justification = defaults.hJustification; } int v_justification = vJustification; if (v_justification == Mi_NONE) { defaults = table.getRowDefaults(rowNumber); if (defaults != null) v_justification = defaults.vJustification; } if (v_justification == Mi_NONE) { defaults = table.getColumnDefaults(columnNumber); if (defaults != null) v_justification = defaults.vJustification; } if (v_justification == Mi_NONE) { defaults = table.getTableWideDefaults(); if (defaults != null) v_justification = defaults.vJustification; } layoutParts(h_sizing, v_sizing, h_justification, v_justification); }
public void setHorizontalSizing(int sizing) { hSizing = sizing; table.invalidateLayout(); }