protected boolean checkPortalIconForUpdate(PortalIcon icon,boolean moved){
  Portal portal=icon.getPortal();
  if (portal == null) {
    icon.remove();
    log.error("Removed PortalIcon without Portal");
    return false;
  }
  String name=portal.getDisplayName();
  String msg=null;
  OBlock fromBlock=portal.getFromBlock();
  OBlock toBlock=portal.getToBlock();
  if (!_homeBlock.equals(fromBlock) && !_homeBlock.equals(toBlock)) {
    msg=Bundle.getMessage("iconNotOnBlock",_homeBlock.getDisplayName(),portal.getDescription());
    _adjacentBlock=null;
  }
  if (msg == null) {
    msg=iconIntersectsBlock(icon,_homeBlock);
  }
  if (log.isDebugEnabled()) {
    log.debug("checkPortalIconForUpdate: _homeBlock= " + _homeBlock.getDisplayName() + " icon On _homeBlock "+ (msg == null)+ ".  msg = "+ msg);
  }
  if (msg == null) {
    if (_homeBlock.equals(fromBlock)) {
      _adjacentBlock=toBlock;
    }
 else {
      _adjacentBlock=fromBlock;
    }
    if (_adjacentBlock == null) {
      _adjacentBlock=findAdjacentBlock(icon);
      if (_homeBlock.equals(fromBlock)) {
        portal.setToBlock(_adjacentBlock,false);
      }
 else {
        portal.setFromBlock(_adjacentBlock,false);
      }
      _portalList.dataChange();
    }
    if (moved) {
      OBlock block=findAdjacentBlock(icon);
      if (log.isDebugEnabled()) {
        log.debug("Icon also on " + (block != null ? block.getDisplayName() : "null") + ", _adjacentBlock= "+ (_adjacentBlock != null ? _adjacentBlock.getDisplayName() : "null"));
      }
      if (block != null && block.equals(_adjacentBlock)) {
        _portalList.setSelectedValue(portal,true);
        return true;
      }
    }
    if (_adjacentBlock != null) {
      msg=iconIntersectsBlock(icon,_adjacentBlock);
      if (msg == null) {
        _portalList.setSelectedValue(portal,true);
        return true;
      }
    }
    if (_adjacentBlock == null) {
      _adjacentBlock=findAdjacentBlock(icon);
      if (_adjacentBlock != null) {
        if (log.isDebugEnabled()) {
          log.debug("Current position: _homeBlock= " + _homeBlock.getDisplayName() + " and _adjacentBlock= "+ _adjacentBlock.getDisplayName());
        }
        int result=JOptionPane.showConfirmDialog(this,Bundle.getMessage("repositionPortal",name,_homeBlock.getDisplayName(),_adjacentBlock.getDisplayName()),Bundle.getMessage("makePortal"),JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
        if (result == JOptionPane.YES_OPTION) {
          if (_homeBlock.equals(fromBlock)) {
            portal.setToBlock(_adjacentBlock,true);
          }
 else {
            portal.setFromBlock(_adjacentBlock,true);
          }
        }
        msg=null;
      }
 else {
        msg=Bundle.getMessage("iconNotOnAdjacent",icon.getNameString(),_homeBlock.getDisplayName());
      }
    }
  }
  if (msg != null) {
    JOptionPane.showMessageDialog(this,msg,Bundle.getMessage("makePortal"),JOptionPane.INFORMATION_MESSAGE);
    clearListSelection();
    return false;
  }
  _portalList.setSelectedValue(portal,true);
  _portalList.dataChange();
  return true;
}

protected boolean checkPortalIconForUpdate ( PortalIcon icon , boolean moved ) { Portal portal = icon . getPortal ( ) ; if ( portal == null ) { icon . remove ( ) ; log . error ( "Removed PortalIcon without Portal" ) ; return false ; } String name = portal . getDisplayName ( ) ; String msg = null ; OBlock fromBlock = portal . getFromBlock ( ) ; OBlock toBlock = portal . getToBlock ( ) ; if ( ! _homeBlock . equals ( fromBlock ) && ! _homeBlock . equals ( toBlock ) ) { msg = Bundle . getMessage ( "iconNotOnBlock" , _homeBlock . getDisplayName ( ) , portal . getDescription ( ) ) ; _adjacentBlock = null ; } if ( msg == null ) { msg = iconIntersectsBlock ( icon , _homeBlock ) ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "checkPortalIconForUpdate: _homeBlock= " + _homeBlock . getDisplayName ( ) + " icon On _homeBlock " + ( msg == null ) + ".  msg = " + msg ) ; } if ( msg == null ) { if ( _homeBlock . equals ( fromBlock ) ) { _adjacentBlock = toBlock ; } else { _adjacentBlock = fromBlock ; } if ( _adjacentBlock == null ) { _adjacentBlock = findAdjacentBlock ( icon ) ; if ( _homeBlock . equals ( fromBlock ) ) { portal . setToBlock ( _adjacentBlock , false ) ; } else { portal . setFromBlock ( _adjacentBlock , false ) ; } _portalList . dataChange ( ) ; } if ( moved ) { OBlock block = findAdjacentBlock ( icon ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Icon also on " + ( block != null ? block . getDisplayName ( ) : "null" ) + ", _adjacentBlock= " + ( _adjacentBlock != null ? _adjacentBlock . getDisplayName ( ) : "null" ) ) ; } if ( block != null && block . equals ( _adjacentBlock ) ) { _portalList . setSelectedValue ( portal , true ) ; return true ; } } if ( _adjacentBlock != null ) { msg = iconIntersectsBlock ( icon , _adjacentBlock ) ; if ( msg == null ) { _portalList . setSelectedValue ( portal , true ) ; return true ; } } if ( _adjacentBlock == null ) { _adjacentBlock = findAdjacentBlock ( icon ) ; if ( _adjacentBlock != null ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Current position: _homeBlock= " + _homeBlock . getDisplayName ( ) + " and _adjacentBlock= " + _adjacentBlock . getDisplayName ( ) ) ; } int result = JOptionPane . showConfirmDialog ( this , Bundle . getMessage ( "repositionPortal" , name , _homeBlock . getDisplayName ( ) , _adjacentBlock . getDisplayName ( ) ) , Bundle . getMessage ( "makePortal" ) , JOptionPane . YES_NO_OPTION , JOptionPane . QUESTION_MESSAGE ) ; if ( result == JOptionPane . YES_OPTION ) { if ( _homeBlock . equals ( fromBlock ) ) { portal . setToBlock ( _adjacentBlock , true ) ; } else { portal . setFromBlock ( _adjacentBlock , true ) ; } } msg = null ; } else { msg = Bundle . getMessage ( "iconNotOnAdjacent" , icon . getNameString ( ) , _homeBlock . getDisplayName ( ) ) ; } } } if ( msg != null ) { JOptionPane . showMessageDialog ( this , msg , Bundle . getMessage ( "makePortal" ) , JOptionPane . INFORMATION_MESSAGE ) ; clearListSelection ( ) ; return false ; } _portalList . setSelectedValue ( portal , true ) ; _portalList . dataChange ( ) ; return true ; }
called after click on portal icon moved recheck block connections
