Ejemplo n.º 1
0
  // Do not allow the one and only layer to be deleted.
  protected void updateLayerAttributesState() {
    int numberOfDeletableLayers = 0;
    for (int i = 0; i < editor.getNumberOfLayers(); ++i) {
      MiPart layer = editor.getLayer(i);
      MiLayerAttributes layerAttributes =
          (MiLayerAttributes)
              layer.getResource(MiLayerAttributes.Mi_LAYER_ATTRIBUTES_RESOURCE_NAME);
      if ((layerAttributes != null)
          && (layerAttributes.getEditability() != MiLayerAttributes.Mi_LAYER_NEVER_EDITABLE)) {
        ++numberOfDeletableLayers;
      }
    }

    boolean deletable = numberOfDeletableLayers > 1;
    for (int i = 0; i < editor.getNumberOfLayers(); ++i) {
      MiPart layer = editor.getLayer(i);
      MiLayerAttributes layerAttributes =
          (MiLayerAttributes)
              layer.getResource(MiLayerAttributes.Mi_LAYER_ATTRIBUTES_RESOURCE_NAME);
      if (layerAttributes != null) {
        layerAttributes.setDeletable(deletable);
        layerAttributes.updateCommandManagerState();
      }
    }
  }
Ejemplo n.º 2
0
 /**
  * ------------------------------------------------------ Sets whether the order of the MiParts in
  * the layers are kept such that MiConnections are at the begining of the list. This is useful
  * when and one does not want connections to be drawn in front of the nodes.
  *
  * @param flag true if connections to be drawn first
  * @see MiConnection#setTruncateLineAtEndPointPartBoundries
  * @see MiContainer#setKeepConnectionsBelowNodes
  * @see #getKeepConnectionsBelowNodes ------------------------------------------------------
  */
 public void setKeepConnectionsBelowNodes(boolean flag) {
   keepConnectionsBelowNodes = flag;
   for (int i = 0; i < editor.getNumberOfLayers(); ++i) {
     if (editor.getLayer(i) instanceof MiContainer) {
       ((MiContainer) editor.getLayer(i)).setKeepConnectionsBelowNodes(flag);
     }
   }
 }
Ejemplo n.º 3
0
 public MiLayerManager(MiEditor editor) {
   this.editor = editor;
   editor.setHasLayers(true);
   for (int i = 0; i < editor.getNumberOfLayers(); ++i) {
     MiPart layer = editor.getLayer(i);
     MiLayerAttributes layerAttributes = new MiLayerAttributes(layer);
     appendModelEntity(layerAttributes);
   }
   editor.appendActionHandler(this, Mi_EDITOR_LAYER_ADDED_ACTION);
   editor.appendActionHandler(this, Mi_EDITOR_LAYER_REMOVED_ACTION);
   editor.appendActionHandler(this, Mi_EDITOR_LAYER_ORDER_CHANGED_ACTION);
   editor.appendActionHandler(this, Mi_EDITOR_CURRENT_LAYER_CHANGED_ACTION);
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 public MiLayerAttributes getLayerAttributes(int index) {
   MiPart layer = editor.getLayer(index);
   return ((MiLayerAttributes)
       layer.getResource(MiLayerAttributes.Mi_LAYER_ATTRIBUTES_RESOURCE_NAME));
 }