Exemple #1
0
  public void testCheckProviderLazilyInvoked() {
    // Check that a refresh successfully causes the provider's
    // setChecked and setGrayed methods to be invoked.
    CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;

    TestMethodsInvokedCheckStateProvider provider = new TestMethodsInvokedCheckStateProvider();

    ctv.setCheckStateProvider(provider);
    ctv.refresh();

    TestElement[] expected = fRootElement.getChildren();

    for (Iterator i = provider.isCheckedInvokedOn.iterator(); i.hasNext(); ) {
      TestElement element = (TestElement) i.next();
      boolean firstLevelElement = false;
      for (int j = 0; j < expected.length && !firstLevelElement; j++) {
        firstLevelElement = element.equals(expected[j]);
      }
      assertTrue(
          "The check provider should only be invoked with visible elements", firstLevelElement);
    }

    for (Iterator i = provider.isGrayedInvokedOn.iterator(); i.hasNext(); ) {
      TestElement element = (TestElement) i.next();
      boolean firstLevelElement = false;
      for (int j = 0; j < expected.length && !firstLevelElement; j++) {
        firstLevelElement = element.equals(expected[j]);
      }
      assertTrue(
          "The check provider should only be invoked with visible elements", firstLevelElement);
    }
  }
 private void setChecked(List<String> tasks) {
   tasksChecked.setChecked(tasks);
   if (taskSelectionTreeViewer != null) {
     taskSelectionTreeViewer.refresh();
   }
   updateOrderedTargets();
   updateLaunchConfigurationDialog();
 }
  private void updateProjectsList(final String selectedDirectory) {
    if (selectedDirectory == null || selectedDirectory.isEmpty()) {
      candidates = null;
      projectList.refresh(true);
      return;
    }
    final File directory = new File(selectedDirectory);

    try {
      getContainer()
          .run(
              true,
              true,
              new IRunnableWithProgress() {
                @Override
                public void run(IProgressMonitor monitor)
                    throws InvocationTargetException, InterruptedException {
                  if (directory.isDirectory()) {
                    List<ProjectCandidate> candies =
                        new ArrayList<HybridProjectImportPage.ProjectCandidate>();
                    collectProjectCandidates(candies, directory, monitor);
                    candidates = candies.toArray(new ProjectCandidate[candies.size()]);
                  }
                }
              });
    } catch (InvocationTargetException e) {
      if (e.getTargetException() != null) {
        if (e.getTargetException() instanceof CoreException) {
          StatusManager.handle((CoreException) e.getTargetException());
        } else {
          ErrorDialog.openError(
              getShell(),
              "Error finding projects to import",
              null,
              new Status(
                  IStatus.ERROR,
                  HybridUI.PLUGIN_ID,
                  "Error while searching for projects to import",
                  e.getTargetException()));
        }
      }
    } catch (InterruptedException e) {
      HybridUI.log(IStatus.ERROR, "Error searchig projects to import", e);
    }
    projectList.refresh(true);
  }
 protected void newFolderButtonPressed() {
   Object createdFolder = createFolder(fSelectedContainer);
   if (createdFolder != null) {
     CheckboxTreeViewer treeViewer = fViewer;
     treeViewer.refresh(fSelectedContainer);
     treeViewer.reveal(createdFolder);
     treeViewer.setChecked(createdFolder, true);
     treeViewer.setSelection(new StructuredSelection(createdFolder));
     updateOKStatus();
   }
 }
  private void initPatternsViewerWithGeneratedPatterns() {
    for (IQuerySpecification<?> pattern :
        QueryExplorerPatternRegistry.getGeneratedQuerySpecifications()) {
      String patternFqn = pattern.getFullyQualifiedName();
      QueryExplorerPatternRegistry.getInstance().addGeneratedPattern(pattern);
      QueryExplorerPatternRegistry.getInstance().addActivePattern(pattern);
      patternsViewerInput.getGeneratedPatternsRoot().addComponent(patternFqn);
    }

    patternsTreeViewer.refresh();
    patternsViewerInput.getGeneratedPatternsRoot().updateSelection(patternsTreeViewer);
  }
Exemple #6
0
  public void testCheckProviderInvoked() {
    // Check that a refresh successfully causes the provider's
    // setChecked and setGrayed methods to be invoked.
    CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;

    TestMethodsInvokedCheckStateProvider provider = new TestMethodsInvokedCheckStateProvider();

    ctv.setCheckStateProvider(provider);
    assertTrue(
        "isChecked should be invoked on a refresh", (!provider.isCheckedInvokedOn.isEmpty()));
    assertTrue("isGrayed should be invoked on a refresh", (!provider.isGrayedInvokedOn.isEmpty()));

    provider.reset();
    ctv.refresh();
    assertTrue(
        "isChecked should be invoked on a refresh", (!provider.isCheckedInvokedOn.isEmpty()));
    assertTrue("isGrayed should be invoked on a refresh", (!provider.isGrayedInvokedOn.isEmpty()));
  }
Exemple #7
0
  public void testSetCheckProviderRefreshesItems() {
    CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;

    // First provider
    // Should cause visible items' check state adhere to provider
    ctv.setCheckStateProvider(new TestCheckStateProvider(0));

    ctv.expandAll();

    // Check that all states are properly set
    checkAllStates("Testing checkbox state after refresh", ctv, 0);

    // Remove the check state provider
    ctv.setCheckStateProvider(null);

    // Test that an update doesn't fail
    TestElement update = fRootElement.getFirstChild().getChildAt(5);
    ctv.update(update, null);

    // Test that a refresh doesn't fail
    ctv.refresh();
  }
 public void setElements(List<IVariableBinding> elements, CheckboxTreeViewer tree) {
   fFields = new ArrayList<IVariableBinding>(elements);
   if (tree != null) tree.refresh();
 }
Exemple #9
0
 public void testWithoutCheckProvider() {
   // Check that without a provider, no exceptions are thrown
   CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
   ctv.expandAll();
   ctv.refresh();
 }