/**
  * register the event handler for this cache
  *
  * @param controlledBy the events which will invalidate the cache
  */
 private void registerHandler(ControlTypes controlledBy) {
   if (controlledBy == ControlTypes.PROJECT_LOADED) {
     DataEventDispatcher.getInstance().addProjectLoadedListener(this, true);
   }
   if (controlledBy == ControlTypes.DATA_CHANGED) {
     DataEventDispatcher.getInstance().addDataChangedListener(this, true);
   }
 }
示例#2
0
 /** {@inheritDoc} */
 public void createPartControlImpl(Composite parent) {
   createMainPart(parent);
   GridData gridData = new GridData(GridData.FILL_BOTH);
   getMainTreeViewer().getControl().setLayoutData(gridData);
   setControl(getMainTreeViewer().getControl());
   getMainTreeViewer().setContentProvider(new TestJobEditorContentProvider());
   addDragAndDropSupport();
   getEditorHelper().addListeners();
   setActionHandlers();
   addDoubleClickListener(CommandIDs.OPEN_SPECIFICATION_COMMAND_ID, getMainTreeViewer());
   setInitialInput();
   DataEventDispatcher ded = DataEventDispatcher.getInstance();
   ded.addPropertyChangedListener(this, true);
   GuiEventDispatcher.getInstance().addEditorDirtyStateListener(this, true);
 }
 /** {@inheritDoc} */
 public boolean setProperty(Object value) {
   if (getPoNode() instanceof IParamNodePO) {
     IParamNodePO node = (IParamNodePO) getPoNode();
     if (node instanceof IExecTestCasePO) {
       IExecTestCasePO exec = (IExecTestCasePO) node;
       int index = Integer.valueOf(String.valueOf(value));
       if (index >= 0) {
         final String newDataSource = getUserChoosableValues().get(index);
         boolean shouldBeLocal = newDataSource == I18n.getString(DATA_SOURCE_LOCAL);
         boolean isLocal = !exec.getHasReferencedTD();
         if (shouldBeLocal == isLocal) {
           return false;
         } else if (shouldBeLocal) {
           exec.resolveTDReference();
         } else {
           exec.setHasReferencedTD(true);
         }
         DataEventDispatcher.getInstance()
             .fireDataChangedListener(
                 node, DataState.StructureModified, UpdateState.onlyInEditor);
         return true;
       }
     }
   }
   return false;
 }
 /**
  * Deletes children of a node then the node itself
  *
  * @param node the node
  * @param sess the session
  */
 private static void deleteNode(INodePO node, EntityManager sess) {
   node.getParentNode().removeNode(node);
   if (node.getId() != null) {
     sess.remove(node);
   }
   DataEventDispatcher.getInstance()
       .fireDataChangedListener(node, DataState.Deleted, UpdateState.onlyInEditor);
 }
示例#5
0
 /**
  * clears the content of client
  *
  * @param alsoProjectIndependent whether also project independent editors should be closed such as
  *     the testresultviewer
  */
 public static void clearClient(final boolean alsoProjectIndependent) {
   final DataEventDispatcher ded = DataEventDispatcher.getInstance();
   TestExecution.getInstance().stopExecution();
   GeneralStorage gs = GeneralStorage.getInstance();
   if (gs != null && Persistor.instance() != null) {
     IProjectPO currProj = gs.getProject();
     if (currProj != null) {
       gs.nullProject();
     }
     gs.reset();
   }
   Plugin.getDisplay()
       .syncExec(
           new Runnable() {
             public void run() {
               Plugin.clearAllEditorsClipboard();
               final ProblemsBP problemsBP = ProblemsBP.getInstance();
               problemsBP.clearOldProblems();
               problemsBP.cleanupProblems();
               TestExecutionContributor.getInstance().getClientTest().resetToTesting();
               ded.fireRecordModeStateChanged(RecordModeState.notRunning);
               ded.fireOMStateChanged(OMState.notRunning);
               ded.fireProjectStateChanged(ProjectState.closed);
               Plugin.closeAllOpenedJubulaEditors(alsoProjectIndependent);
               ded.fireTestresultChanged(TestresultState.Clear);
               setTreeViewerInputNull(Constants.TESTRE_ID);
               for (TestCaseBrowser tcb : MultipleTCBTracker.getInstance().getOpenTCBs()) {
                 tcb.getTreeViewer().setInput(null);
               }
               setTreeViewerInputNull(Constants.TS_BROWSER_ID);
               setTreeViewerInputNull(Constants.COMPNAMEBROWSER_ID);
               clearAnalyzeResultPage();
             }
           });
   ded.fireProjectLoadedListener(new NullProgressMonitor());
 }
  /**
   * Deletes all selected items unless an error occurs.
   *
   * @param selection The selected items to delete.
   */
  private void deleteSelection(IStructuredSelection selection) {
    // cleanup set for entries, that are children of other contained nodes
    Set<INodePO> set = new HashSet<INodePO>(selection.toList());
    Set<INodePO> topNodesToDelete = new HashSet<INodePO>();
    for (INodePO node : set) {
      if (!containsParent(set, node)) {
        topNodesToDelete.add(node);
      }
    }

    // determine all nodes, which have to be deleted
    // (children of selected nodes which are CategoryPO or SpecTestCasePO
    List<INodePO> nodesToDelete = new ArrayList<INodePO>();
    for (INodePO node : topNodesToDelete) {
      MultipleNodePM.collectAffectedNodes(nodesToDelete, node);
    }

    // reverse List, to get the right order of deletion (child first)
    Collections.reverse(nodesToDelete);

    List<AbstractCmdHandle> cmds = getDeleteCommands(nodesToDelete);
    if (!cmds.isEmpty()) {
      try {
        MultipleNodePM.getInstance().executeCommands(cmds);

        List<DataChangedEvent> eventList = new ArrayList<DataChangedEvent>();
        for (INodePO node : topNodesToDelete) {
          eventList.add(new DataChangedEvent(node, DataState.Deleted, UpdateState.all));
        }
        DataEventDispatcher.getInstance()
            .fireDataChangedListener(eventList.toArray(new DataChangedEvent[0]));
      } catch (PMException e) {
        PMExceptionHandler.handlePMExceptionForMasterSession(e);
      } catch (ProjectDeletedException e) {
        PMExceptionHandler.handleProjectDeletedException();
      }
    }
  }
 /** {@inheritDoc} */
 public Message execute() {
   // do nothing since this is only for the data
   DataEventDispatcher.getInstance().fireWindowsChanged(m_message.getWindowTitles());
   return null;
 }
示例#8
0
 private void init() {
   final DataEventDispatcher ded = DataEventDispatcher.getInstance();
   ded.addProjectLoadedListener(m_projLoadedListener, true);
   ded.addDataChangedListener(m_currentProjDeletedListener, true);
   ded.addAutStateListener(m_autStateListener, true);
   ded.addLanguageChangedListener(m_langChangedListener, true);
   ded.addProjectStateListener(m_projPropModifyListener);
   ded.addTestSuiteStateListener(m_testSuiteStateListener, true);
   ded.addOMStateListener(m_omStateListener, true);
   ded.addRecordModeStateListener(m_recordModeStateListener, true);
   ded.addDataChangedListener(m_dataChangedListener, true);
 }
 /** private constructor */
 private WorkingLanguageBP() {
   DataEventDispatcher ded = DataEventDispatcher.getInstance();
   ded.addProjectLoadedListener(this, true);
   ded.addProjectStateListener(m_projectPropertiesModifyListener);
   ded.addDataChangedListener(m_dataChangedListener, true);
 }
  /** {@inheritDoc} */
  public boolean performOk() {
    try {
      if (!m_oldProjectName.equals(m_newProjectName)) {
        if (ProjectPM.doesProjectNameExist(m_newProjectName)) {

          ErrorHandlingUtil.createMessageDialog(
              MessageIDs.E_PROJECTNAME_ALREADY_EXISTS, new Object[] {m_newProjectName}, null);
          return false;
        }
      }
      if (m_isReusableCheckbox != null) {
        getProject().setIsReusable(m_isReusableCheckbox.getSelection());
      }
      if (m_isProtectedCheckbox != null) {
        getProject().setIsProtected(m_isProtectedCheckbox.getSelection());
      }
      storeAutoTestResultCleanup();

      if (!m_oldProjectName.equals(m_newProjectName)) {
        ProjectNameBP.getInstance()
            .setName(getEditSupport().getSession(), getProject().getGuid(), m_newProjectName);
      }
      fireOkPressed();
      Set<IReusedProjectPO> origReused =
          ((IProjectPropertiesPO) getEditSupport().getOriginal()).getUsedProjects();
      Set<IReusedProjectPO> newReused =
          new HashSet<IReusedProjectPO>(
              ((IProjectPropertiesPO) getEditSupport().getWorkVersion()).getUsedProjects());
      newReused.removeAll(origReused);
      getEditSupport().saveWorkVersion();
      refreshAutMainList();
      DataEventDispatcher.getInstance().fireProjectStateChanged(ProjectState.prop_modified);
      for (IReusedProjectPO reused : newReused) {
        try {
          IProjectPO reusedProject = ProjectPM.loadReusedProject(reused);
          if (reusedProject != null) {
            // incomplete database, see https://bxapps.bredex.de/bugzilla/show_bug.cgi?id=854
            ComponentNamesBP.getInstance().refreshNames(reusedProject.getId());
          }
        } catch (JBException e) {
          // Could not refresh Component Name information for
          // reused project. Log the exception.
          log.error(Messages.ErrorWhileRetrievingReusedProjectInformation, e);
        }
      }
      // FIXME zeb This updates the Test Case Browser. Once we have separate
      //           EditSupports for each property page, then we can use
      //           "real" ReusedProjectPOs instead of a placeholder.
      DataEventDispatcher.getInstance()
          .fireDataChangedListener(
              PoMaker.createReusedProjectPO("1", 1, 1), // $NON-NLS-1$
              DataState.ReuseChanged,
              UpdateState.notInEditor);
      DataEventDispatcher.getInstance()
          .fireDataChangedListener(
              GeneralStorage.getInstance().getProject(),
              DataState.Renamed,
              UpdateState.notInEditor);
      CompletenessBP.getInstance().completeProjectCheck();
    } catch (PMException e) {
      ErrorHandlingUtil.createMessageDialog(e, null, null);
    } catch (ProjectDeletedException e) {
      PMExceptionHandler.handleProjectDeletedException();
    } catch (IncompatibleTypeException ite) {
      ErrorHandlingUtil.createMessageDialog(ite, ite.getErrorMessageParams(), null);
    }

    return true;
  }
示例#11
0
 /** Private constructor */
 private ShowServerLogBP() {
   m_isConnectedToServer = false;
   DataEventDispatcher.getInstance().addAutAgentConnectionListener(this, true);
 }