public boolean processAction(MiiAction action) { MiPart layer = (MiPart) action.getActionSystemInfo(); if (action.hasActionType(Mi_EDITOR_LAYER_ADDED_ACTION)) { appendModelEntity(new MiLayerAttributes(layer)); updateLayerAttributesState(); } else if (action.hasActionType(Mi_EDITOR_LAYER_REMOVED_ACTION)) { MiLayerAttributes layerAttributes = (MiLayerAttributes) layer.getResource(MiLayerAttributes.Mi_LAYER_ATTRIBUTES_RESOURCE_NAME); if (layerAttributes != null) { removeModelEntity(layerAttributes); } updateLayerAttributesState(); } else if (action.hasActionType(Mi_EDITOR_LAYER_ORDER_CHANGED_ACTION)) { removeAllModelEntities(); for (int i = 0; i < editor.getNumberOfLayers(); ++i) { layer = editor.getLayer(i); MiLayerAttributes layerAttributes = (MiLayerAttributes) layer.getResource(MiLayerAttributes.Mi_LAYER_ATTRIBUTES_RESOURCE_NAME); if (layerAttributes == null) { layerAttributes = new MiLayerAttributes(layer); } appendModelEntity(layerAttributes); } updateLayerAttributesState(); } else if (action.hasActionType(Mi_EDITOR_CURRENT_LAYER_CHANGED_ACTION)) { MiPart currentLayer = editor.getCurrentLayer(); MiModelEntityList list = getModelEntities(); for (int i = 0; i < list.size(); ++i) { MiLayerAttributes atts = (MiLayerAttributes) list.elementAt(i); if (atts.getLayer() == currentLayer) atts.setCurrent(true); else if (atts.isCurrent()) atts.setCurrent(false); } updateLayerAttributesState(); } return (true); }
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); }