Example #1
0
  private void shutdownSystem() {
    List<String> names = _nucleus.getCellNames();
    List<String> nonSystem = new ArrayList<>(names.size());
    List<String> system = new ArrayList<>(names.size());

    for (String name : names) {
      CellInfo info = _nucleus.getCellInfo(name);
      if (info == null) {
        continue;
      }
      String cellName = info.getCellName();
      if (cellName.equals("System")) {
        // Don't kill the system cell
      } else if (info.getCellType().equals("System")) {
        system.add(cellName);
      } else {
        nonSystem.add(cellName);
      }
    }

    _log.info("Will try to shutdown non-system cells {}", nonSystem);
    shutdownCells(nonSystem, 3000);

    _log.info("Will try to shutdown remaining cells {}", system);
    shutdownCells(system, 5000);
  }
Example #2
0
 private static void addVacantCell(Rect current, CellInfo cellInfo) {
   CellInfo.VacantCell cell = CellInfo.VacantCell.acquire();
   cell.cellX = current.left;
   cell.cellY = current.top;
   cell.spanX = current.right - current.left + 1;
   cell.spanY = current.bottom - current.top + 1;
   if (cell.spanX > cellInfo.maxVacantSpanX) {
     cellInfo.maxVacantSpanX = cell.spanX;
     cellInfo.maxVacantSpanXSpanY = cell.spanY;
   }
   if (cell.spanY > cellInfo.maxVacantSpanY) {
     cellInfo.maxVacantSpanY = cell.spanY;
     cellInfo.maxVacantSpanYSpanX = cell.spanX;
   }
   cellInfo.vacantCells.add(cell);
 }
Example #3
0
 /** Implement the Parcelable interface */
 @Override
 public void writeToParcel(Parcel dest, int flags) {
   if (DBG) log("writeToParcel(Parcel, int): " + toString());
   super.writeToParcel(dest, flags, TYPE_LTE);
   mCellIdentityLte.writeToParcel(dest, flags);
   mCellSignalStrengthLte.writeToParcel(dest, flags);
 }
Example #4
0
  @Override
  public EditorCell findCell(final EditorComponent editorComponent) {
    if (myCellId != null) {
      final EditorContext editorContext = editorComponent.getEditorContext();
      if (myNodeReference == null) return null;

      final EditorCell[] cell = new EditorCell[] {null};
      editorContext
          .getRepository()
          .getModelAccess()
          .runReadAction(
              new Runnable() {
                @Override
                public void run() {
                  cell[0] =
                      editorComponent.findCellWithId(
                          myNodeReference.resolve(editorContext.getRepository()), myCellId);
                }
              });
      return cell[0];
    } else if (myParentInfo != null) {
      EditorCell parentCell = myParentInfo.findCell(editorComponent);
      if (!(parentCell instanceof EditorCell_Collection)) {
        return null;
      }
      EditorCell_Collection parentCollection = (EditorCell_Collection) parentCell;
      if (myCellNumber >= parentCollection.getCellsCount()) {
        return null;
      }
      EditorCell editorCell = parentCollection.getChildAt(myCellNumber);
      // This editorCell should not have any cellId due to corresponding conditions in constructor
      return editorCell.getCellId() == null ? editorCell : null;
    }
    return null;
  }
Example #5
0
  private static void findIntersectingVacantCells(
      CellInfo cellInfo, int x, int y, int xCount, int yCount, boolean[][] occupied) {

    cellInfo.maxVacantSpanX = Integer.MIN_VALUE;
    cellInfo.maxVacantSpanXSpanY = Integer.MIN_VALUE;
    cellInfo.maxVacantSpanY = Integer.MIN_VALUE;
    cellInfo.maxVacantSpanYSpanX = Integer.MIN_VALUE;
    cellInfo.clearVacantCells();

    if (occupied[x][y]) {
      return;
    }

    cellInfo.current.set(x, y, x, y);

    findVacantCell(cellInfo.current, xCount, yCount, occupied, cellInfo);
  }
 @Override
 public jetbrains.mps.nodeEditor.cells.EditorCell findCell(EditorComponent editorComponent) {
   jetbrains.mps.nodeEditor.cells.EditorCell cell =
       myCollectionCellInfo.findCell(editorComponent);
   if (!(cell instanceof EditorCell_Collection)) return null;
   EditorCell_Collection parent = (EditorCell_Collection) cell;
   if (myOpeningBrace) {
     return parent.myOpeningBrace;
   } else {
     return parent.myClosingBrace;
   }
 }
Example #7
0
 CellInfo _getCellInfo() {
   CellInfo info = new CellInfo();
   info.setCellName(getCellName());
   info.setDomainName(getCellDomainName());
   info.setCellType(getCellType());
   info.setCreationTime(_creationTime);
   try {
     info.setCellVersion(_cell.getCellVersion());
   } catch (Exception e) {
   }
   try {
     info.setPrivateInfo(_cell.getInfo());
   } catch (Exception e) {
     info.setPrivateInfo("Not yet/No more available\n");
   }
   try {
     info.setShortInfo(_cell.toString());
   } catch (Exception e) {
     info.setShortInfo("Not yet/No more available");
   }
   info.setCellClass(_cellClass);
   try {
     info.setEventQueueSize(getEventQueueSize());
     info.setState(_state);
     info.setThreadCount(_threads.activeCount());
   } catch (Exception e) {
     info.setEventQueueSize(0);
     info.setState(0);
     info.setThreadCount(0);
   }
   return info;
 }
 public boolean equals(Object o) {
   if (!(o instanceof BraceCellInfo)) return false;
   BraceCellInfo cellInfo = ((BraceCellInfo) o);
   return myCollectionCellInfo.equals(cellInfo.myCollectionCellInfo)
       && myOpeningBrace == cellInfo.myOpeningBrace;
 }
 public int hashCode() {
   return myCollectionCellInfo.hashCode() + (myOpeningBrace ? 50 : -50);
 }
Example #10
0
  CellInfo findAllVacantCells(boolean[] occupiedCells, View ignoreView) {
    final boolean portrait = mPortrait;
    final int xCount = portrait ? mShortAxisCells : mLongAxisCells;
    final int yCount = portrait ? mLongAxisCells : mShortAxisCells;

    boolean[][] occupied = mOccupied;

    if (occupiedCells != null) {
      for (int y = 0; y < yCount; y++) {
        for (int x = 0; x < xCount; x++) {
          occupied[x][y] = occupiedCells[y * xCount + x];
        }
      }
    } else {
      findOccupiedCells(xCount, yCount, occupied, ignoreView);
    }

    CellInfo cellInfo = new CellInfo();

    cellInfo.cellX = -1;
    cellInfo.cellY = -1;
    cellInfo.spanY = 0;
    cellInfo.spanX = 0;
    cellInfo.maxVacantSpanX = Integer.MIN_VALUE;
    cellInfo.maxVacantSpanXSpanY = Integer.MIN_VALUE;
    cellInfo.maxVacantSpanY = Integer.MIN_VALUE;
    cellInfo.maxVacantSpanYSpanX = Integer.MIN_VALUE;
    cellInfo.screen = mCellInfo.screen;

    Rect current = cellInfo.current;

    for (int x = 0; x < xCount; x++) {
      for (int y = 0; y < yCount; y++) {
        if (!occupied[x][y]) {
          current.set(x, y, x, y);
          findVacantCell(current, xCount, yCount, occupied, cellInfo);
          occupied[x][y] = true;
        }
      }
    }

    cellInfo.valid = cellInfo.vacantCells.size() > 0;

    // Assume the caller will perform their own cell searching, otherwise we
    // risk causing an unnecessary rebuild after findCellForSpan()

    return cellInfo;
  }
Example #11
0
  @Override
  public boolean onInterceptTouchEvent(MotionEvent ev) {
    final int action = ev.getAction();
    final CellInfo cellInfo = mCellInfo;

    if (action == MotionEvent.ACTION_DOWN) {
      final Rect frame = mRect;
      final int x = (int) ev.getX() + mScrollX;
      final int y = (int) ev.getY() + mScrollY;
      final int count = getChildCount();

      boolean found = false;
      for (int i = count - 1; i >= 0; i--) {
        final View child = getChildAt(i);

        if ((child.getVisibility()) == VISIBLE || child.getAnimation() != null) {
          child.getHitRect(frame);
          if (frame.contains(x, y)) {
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            cellInfo.cell = child;
            cellInfo.cellX = lp.cellX;
            cellInfo.cellY = lp.cellY;
            cellInfo.spanX = lp.cellHSpan;
            cellInfo.spanY = lp.cellVSpan;
            cellInfo.valid = true;
            found = true;
            mDirtyTag = false;
            break;
          }
        }
      }

      mLastDownOnOccupiedCell = found;

      if (!found) {
        int cellXY[] = mCellXY;
        pointToCellExact(x, y, cellXY);

        final boolean portrait = mPortrait;
        final int xCount = portrait ? mShortAxisCells : mLongAxisCells;
        final int yCount = portrait ? mLongAxisCells : mShortAxisCells;

        final boolean[][] occupied = mOccupied;
        findOccupiedCells(xCount, yCount, occupied, null);

        cellInfo.cell = null;
        cellInfo.cellX = cellXY[0];
        cellInfo.cellY = cellXY[1];
        cellInfo.spanX = 1;
        cellInfo.spanY = 1;
        cellInfo.valid =
            cellXY[0] >= 0
                && cellXY[1] >= 0
                && cellXY[0] < xCount
                && cellXY[1] < yCount
                && !occupied[cellXY[0]][cellXY[1]];

        // Instead of finding the interesting vacant cells here, wait until a
        // caller invokes getTag() to retrieve the result. Finding the vacant
        // cells is a bit expensive and can generate many new objects, it's
        // therefore better to defer it until we know we actually need it.

        mDirtyTag = true;
      }
      setTag(cellInfo);
    } else if (action == MotionEvent.ACTION_UP) {
      cellInfo.cell = null;
      cellInfo.cellX = -1;
      cellInfo.cellY = -1;
      cellInfo.spanX = 0;
      cellInfo.spanY = 0;
      cellInfo.valid = false;
      mDirtyTag = false;
      setTag(cellInfo);
    }

    return false;
  }
Example #12
0
 @Override
 protected void onAttachedToWindow() {
   super.onAttachedToWindow();
   mCellInfo.screen = ((ViewGroup) getParent()).indexOfChild(this);
 }
Example #13
0
 public int hashCode() {
   return (myParentInfo == null ? 0 : myParentInfo.hashCode())
       + (myNodeReference == null ? 0 : myNodeReference.hashCode())
       + (myCellId == null ? 0 : myCellId.hashCode())
       + myCellNumber;
 }
Example #14
0
 /** Implements CellMessageSender interface. */
 @Override
 public void setCellEndpoint(CellEndpoint endpoint) {
   _endpoint = endpoint;
   CellInfo cellInfo = _endpoint.getCellInfo();
   _cellAddress = new CellAddressCore(cellInfo.getCellName(), cellInfo.getDomainName());
 }