コード例 #1
0
ファイル: ThreadVMNode.java プロジェクト: PARAG00991/cdt
  protected void fillThreadDataProperties(IPropertiesUpdate update, IThreadDMData data) {
    if (data.getName() != null && data.getName().length() > 0) {
      update.setProperty(PROP_NAME, data.getName());
    }
    update.setProperty(IGdbLaunchVMConstants.PROP_OS_ID, data.getId());

    if (data instanceof IGdbThreadDMData) {
      String[] cores = ((IGdbThreadDMData) data).getCores();
      if (cores != null) {
        StringBuffer str = new StringBuffer();
        for (String core : cores) {
          str.append(core + ","); // $NON-NLS-1$
        }
        if (str.length() > 0) {
          String coresStr = str.substring(0, str.length() - 1);
          update.setProperty(IGdbLaunchVMConstants.PROP_CORES_ID, coresStr);
        }
      }
    }
  }
コード例 #2
0
ファイル: ThreadVMNode.java プロジェクト: PARAG00991/cdt
  @Override
  protected void updatePropertiesInSessionThread(IPropertiesUpdate[] updates) {
    IPropertiesUpdate[] parentUpdates = new IPropertiesUpdate[updates.length];

    for (int i = 0; i < updates.length; i++) {
      final IPropertiesUpdate update = updates[i];

      final ViewerCountingRequestMonitor countringRm =
          new ViewerCountingRequestMonitor(ImmediateExecutor.getInstance(), updates[i]);
      int count = 0;

      // Create a delegating update which will let the super-class fill in the
      // standard container properties.
      parentUpdates[i] = new VMDelegatingPropertiesUpdate(updates[i], countringRm);
      count++;

      IMIExecutionDMContext execDmc =
          findDmcInPath(
              update.getViewerInput(), update.getElementPath(), IMIExecutionDMContext.class);
      if (execDmc != null) {
        update.setProperty(ILaunchVMConstants.PROP_ID, Integer.toString(execDmc.getThreadId()));

        // set pin properties
        IPinElementColorDescriptor colorDesc =
            PinCloneUtils.getPinElementColorDescriptor(GdbPinProvider.getPinnedHandles(), execDmc);
        updates[i].setProperty(
            IGdbLaunchVMConstants.PROP_PIN_COLOR,
            colorDesc != null ? colorDesc.getOverlayColor() : null);
        updates[i].setProperty(
            IGdbLaunchVMConstants.PROP_PINNED_CONTEXT,
            PinCloneUtils.isPinnedTo(GdbPinProvider.getPinnedHandles(), execDmc));
      }

      if (update.getProperties().contains(PROP_NAME)
          || update.getProperties().contains(IGdbLaunchVMConstants.PROP_OS_ID)
          || update.getProperties().contains(IGdbLaunchVMConstants.PROP_CORES_ID)) {
        IProcesses processService = getServicesTracker().getService(IProcesses.class);
        final IThreadDMContext threadDmc =
            findDmcInPath(update.getViewerInput(), update.getElementPath(), IThreadDMContext.class);

        if (processService == null || threadDmc == null) {
          update.setStatus(
              new Status(
                  IStatus.ERROR,
                  GdbUIPlugin.PLUGIN_ID,
                  "Service or handle invalid",
                  null)); //$NON-NLS-1$
        } else {
          processService.getExecutionData(
              threadDmc,
              new ViewerDataRequestMonitor<IThreadDMData>(getExecutor(), update) {
                @Override
                public void handleCompleted() {
                  if (isSuccess()) {
                    fillThreadDataProperties(update, getData());
                  }
                  update.setStatus(getStatus());
                  countringRm.done();
                }
              });
          count++;
        }
      }

      countringRm.setDoneCount(count);
    }
    super.updatePropertiesInSessionThread(parentUpdates);
  }
コード例 #3
0
ファイル: FormattedValueTests.java プロジェクト: zhaog/cdt
  private void setFormatAndValidate(
      String formatId,
      ArrayList<ElementFormatSetting> setElementFormats,
      ArrayList<ElementFormatSetting> expectElementFormats,
      boolean expectContentCached,
      boolean expectFormattedValuesCached,
      boolean expectCacheMissError) {
    fViewerListener.reset();
    fViewerListener.addUpdates(
        TreePath.EMPTY,
        ((TestElementVMContext) fViewer.getInput()).getElement(),
        -1,
        ALL_UPDATES_COMPLETE | PROPERTY_UPDATES);

    fVMListener.reset();
    int vmUpdateFlags = PROPERTY_UPDATES;
    if (!expectContentCached) {
      vmUpdateFlags |= ALL_UPDATES_COMPLETE;
    }
    fVMListener.addUpdates(TreePath.EMPTY, fModel.getRootElement(), vmListenerLevel, vmUpdateFlags);

    fFormattedValuesListener.reset();
    if (expectFormattedValuesCached && !expectCacheMissError) {
      fFormattedValuesListener.setCachedFormats(new String[] {formatId});
    }

    if (fVMProvider instanceof IElementFormatProvider && setElementFormats != null) {
      IElementFormatProvider ep = ((IElementFormatProvider) fVMProvider);
      for (ElementFormatSetting es : setElementFormats) {
        ep.setActiveFormat(
            fViewer.getPresentationContext(),
            es.nodes.toArray(new IVMNode[es.nodes.size()]),
            fViewer.getInput(),
            es.elementPaths.toArray(new TreePath[es.elementPaths.size()]),
            es.formatId);
      }
    } else {
      // Set the new number format to the viewer.
      fViewer
          .getPresentationContext()
          .setProperty(PROP_FORMATTED_VALUE_FORMAT_PREFERENCE, formatId);
    }

    while (!fViewerListener.isFinished(ALL_UPDATES_COMPLETE | PROPERTY_UPDATES)
        || !fVMListener.isFinished(CONTENT_UPDATES | PROPERTY_UPDATES))
      if (!fDisplay.readAndDispatch()) fDisplay.sleep();

    if (expectCacheMissError) {
      try {
        validateModel(expectElementFormats, formatId, "", formatId, "");
        throw new RuntimeException("Expected validateModel to fail");
      } catch (AssertionFailedError e) {
        // expected
      }
    } else {
      validateModel(expectElementFormats, formatId, "", formatId, "");
    }

    if (expectCacheMissError) {
      String formatProperty = FormattedValueVMUtil.getPropertyForFormatId(formatId);

      assertTrue(fFormattedValuesListener.getFormattedValuesCompleted().isEmpty());
      assertFalse(fFormattedValuesListener.getPropertiesUpdates().isEmpty());
      for (IPropertiesUpdate update : fFormattedValuesListener.getPropertiesUpdates()) {
        PropertiesUpdateStatus status = (PropertiesUpdateStatus) update.getStatus();
        assertEquals(IDsfStatusConstants.INVALID_STATE, status.getCode());
        ElementFormatSetting elementFormat = null;
        if (expectElementFormats != null) {
          TreePath viewerPath = update.getElementPath();
          for (ElementFormatSetting es : expectElementFormats) {
            if (es.elementPaths.indexOf(viewerPath) >= 0) {
              elementFormat = es;
              break;
            }
          }
        }
        if (elementFormat != null) {
          assertEquals(
              "Cache contains stale data. Refresh view.",
              status
                  .getStatus(FormattedValueVMUtil.getPropertyForFormatId(elementFormat.formatId))
                  .getMessage());
        } else {
          assertEquals(
              "Cache contains stale data. Refresh view.",
              status.getStatus(formatProperty).getMessage());
        }
        assertEquals(
            "Cache contains stale data. Refresh view.",
            status.getStatus(PROP_FORMATTED_VALUE_ACTIVE_FORMAT_VALUE).getMessage());
        assertEquals(1, status.getChildren().length);
      }

    } else {
      assertTrue(fFormattedValuesListener.isFinished());
    }
  }