Ejemplo n.º 1
0
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {

    ViewData.instance().setModel(null);

    IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
    activePage.hideView(activePage.findView(MainView.ID));
    try {
      activePage.showView(MainView.ID);
    } catch (PartInitException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    return null;
  }
  @Test
  public void testFilter() throws CoreException {
    IPerspectiveDescriptor persDescription =
        PlatformUI.getWorkbench()
            .getPerspectiveRegistry()
            .findPerspectiveWithId(JavaUI.ID_PERSPECTIVE);
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    page.setPerspective(persDescription);
    IViewPart arquilliaView = page.showView(ArquillianView.ID);
    try {
      assertTrue(arquilliaView instanceof CommonNavigator);
      PackageExplorerPart packageView = (PackageExplorerPart) page.showView(JavaUI.ID_PACKAGES);
      IProject project = getProject(TEST_PROJECT_NAME);
      packageView.selectAndReveal(project);

      CommonNavigator navigator = (CommonNavigator) arquilliaView;
      CommonViewer viewer = navigator.getCommonViewer();
      TreeItem[] items = viewer.getTree().getItems();
      assertTrue(items.length == 1);
      ViewerFilter[] filters = viewer.getFilters();
      assertTrue(filters.length > 0);
      WorkingSetFilter activeFilter = null;
      List<ViewerFilter> newFilters = new ArrayList<ViewerFilter>();
      int i = 0;
      for (ViewerFilter filter : filters) {
        if (!(filter instanceof ActiveProjectFilter)) {
          newFilters.add(filter);
        }
      }
      newFilters.add(new WorkingSetFilter());
      viewer.setFilters(newFilters.toArray(new ViewerFilter[0]));

      items = viewer.getTree().getItems();
      assertTrue("Invalid filter", items.length == 2);
    } finally {
      if (arquilliaView != null) {
        page.hideView(arquilliaView);
      }
    }
  }
Ejemplo n.º 3
0
 public void closeModelBrowser() {
   IWorkbenchPage page =
       ModelBrowserPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
   page.hideView(this);
 }
  /** Print the bill(s) */
  public Result<Rechnung> doOutput(
      final TYPE type, final Collection<Rechnung> rnn, Properties props) {
    IWorkbenchPage rnPage;
    final Result<Rechnung> result = new Result<Rechnung>(); // =new
    // Result<Rechnung>(Log.ERRORS,99,"Not
    // yet implemented",null,true);
    rnPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
    final Result<Rechnung> res = new Result<Rechnung>();

    try {
      final RnPrintView rnp = (RnPrintView) rnPage.showView(RnPrintView.ID);
      progressService.runInUI(
          PlatformUI.getWorkbench().getProgressService(),
          new IRunnableWithProgress() {
            public void run(final IProgressMonitor monitor) {
              monitor.beginTask("Drucke Rechnungen", rnn.size() * 10);
              int errors = 0;
              for (Rechnung rn : rnn) {
                try {
                  result.add(rnp.doPrint(rn));
                  monitor.worked(10);
                  if (!result.isOK()) {
                    String errms = "Rechnung " + rn.getNr() + "konnte nicht gedruckt werden";
                    res.add(Result.SEVERITY.ERROR, 1, errms, rn, true);
                    errors++;
                    continue;
                  }
                  int status_vorher = rn.getStatus();
                  if ((status_vorher == RnStatus.OFFEN)
                      || (status_vorher == RnStatus.MAHNUNG_1)
                      || (status_vorher == RnStatus.MAHNUNG_2)
                      || (status_vorher == RnStatus.MAHNUNG_3)) {
                    rn.setStatus(status_vorher + 1);
                  }
                  rn.addTrace(
                      Rechnung.OUTPUT,
                      getDescription() + ": " + RnStatus.getStatusText(rn.getStatus()));
                } catch (Exception ex) {
                  SWTHelper.showError(
                      "Fehler beim Drucken der Rechnung " + rn.getRnId(), ex.getMessage());
                  errors++;
                }
              }
              monitor.done();
              if (errors == 0) {
                SWTHelper.showInfo("OK", "OK");
              } else {
                SWTHelper.showError("Fehler", "Fehler");
              }
            }
          },
          null);

      rnPage.hideView(rnp);

    } catch (Exception ex) {
      ExHandler.handle(ex);
      res.add(Result.SEVERITY.ERROR, 2, ex.getMessage(), null, true);
      ErrorDialog.openError(null, "Exception", "Exception", ResultAdapter.getResultAsStatus(res));
      return res;
    }
    if (!result.isOK()) {
      ResultAdapter.displayResult(result, "Fehler beim Rechnungsdruck");
    }
    return result;
  }