net.sf.taverna.t2.workflowmodel.Edit类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(206)

本文整理了Java中net.sf.taverna.t2.workflowmodel.Edit类的一些代码示例,展示了Edit类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Edit类的具体详情如下:
包路径:net.sf.taverna.t2.workflowmodel.Edit
类名称:Edit

Edit介绍

[英]The workflow object model exposed by this API is read only. Properties of the model can only be changed through implementations of this interface, this ensures a consistant approach to grouped edits (transactions) and undo / redo support within the UI. It also potentially allows for capture of editing provenance where a workflow is repurposed or created from an aggregate of several others.
[中]此API公开的工作流对象模型是只读的。模型的属性只能通过此接口的实现来更改,这确保了用户界面中分组编辑(事务)和撤消/重做支持的一致性。它还可能允许捕获编辑来源,其中工作流被重新调整用途或从其他几个工作流的集合中创建。

代码示例

代码示例来源:origin: net.sf.taverna.t2.core/workflowmodel-impl

@Override
protected void doEditAction(ProcessorImpl processor) throws EditException {
  compoundEdit.doEdit();
}

代码示例来源:origin: net.sf.taverna.t2/workflowmodel-api

/**
 * Attempts to call the doEdit method of all child edits. If any of those
 * children throws an EditException any successful edits are rolled back and
 * the exception is rethrown as the cause of a new EditException from the
 * CompoundEdit
 */
public synchronized Object doEdit() throws EditException {
  if (isApplied()) {
    throw new EditException("Cannot apply an edit more than once!");
  }
  List<Edit<?>> doneEdits = new ArrayList<Edit<?>>();
  try {
    for (Edit<?> edit : childEdits) {
      edit.doEdit();
      // Insert the done edit at position 0 in the list so we can
      // iterate over the list in the normal order if we need to
      // rollback, this ensures that the most recent edit is first.
      doneEdits.add(0, edit);
    }
    applied = true;
  } catch (EditException ee) {
    for (Edit<?> undoMe : doneEdits) {
      undoMe.undo();
    }
    applied = false;
    throw new EditException("Failed child of compound edit", ee);
  }
  return null;
}

代码示例来源:origin: net.sf.taverna.t2.activities/biomoby-activity-ui

@Override
protected void undoEditAction(DataflowImpl dataflow) {
  if (linkEdit!=null && linkEdit.isApplied())
    linkEdit.undo();
  if (compoundEdit!=null && compoundEdit.isApplied())
    compoundEdit.undo();
  if (upstreamObjectEdit!=null && upstreamObjectEdit.isApplied()) {
    upstreamObjectEdit.undo();
  }
  
}

代码示例来源:origin: net.sf.taverna.t2/workflowmodel-impl

@Override
protected void undoEditAction(ProcessorImpl processor) {
  compoundEdit.undo();
}

代码示例来源:origin: net.sf.taverna.t2.workbench/edits-impl

public void notify(Observable<EditManagerEvent> sender,
      EditManagerEvent message) throws Exception {
    events.add(message);
    if (message instanceof DataflowEditEvent) {
      DataflowEditEvent dataflowEdit = (DataflowEditEvent) message;
      assertTrue("Edit was not applied on edit event", dataflowEdit
          .getEdit().isApplied());
    } else if (message instanceof DataFlowUndoEvent) {
      DataFlowUndoEvent dataflowUndo = (DataFlowUndoEvent) message;
      assertFalse("Edit was applied on undo event", dataflowUndo
          .getEdit().isApplied());
    } else if (message instanceof DataFlowRedoEvent) {
      DataFlowRedoEvent dataflowEdit = (DataFlowRedoEvent) message;
      assertTrue("Edit was not applied on edit event", dataflowEdit
          .getEdit().isApplied());
    } else {
      fail("Unknown event: " + message);
    }
  }
}

代码示例来源:origin: net.sf.taverna.t2.ui-components/workflow-view

Object subject = edit.getSubject();
if (subject instanceof Dataflow) {
  DataflowSelectionModel selectionModel = DataflowSelectionManager
  .getInstance().getDataflowSelectionModel(
      (Dataflow) edit.getSubject());
  Object objectOfEdit = null;
  if (edit instanceof AddProcessorEdit) {

代码示例来源:origin: net.sf.taverna.t2.core/workflowmodel-impl

@Override
protected void undoEditAction(ProcessorImpl processor) {
  compoundEdit.undo();
}

代码示例来源:origin: net.sf.taverna.t2.workbench/edits-impl

@Test
public void addProcessor() throws Exception {
  EditManager editManager = EditManager.getInstance();
  editManager.addObserver(editManagerObserver);
  Edits edits = editManager.getEdits();
  Edit<Dataflow> edit = edits.getAddProcessorEdit(dataflow, processor);
  assertFalse("Edit was already applied", edit.isApplied());
  assertTrue("Did already add processor", dataflow.getProcessors()
      .isEmpty());
  editManager.doDataflowEdit(dataflow, edit);
  assertTrue("Edit was not applied", edit.isApplied());
  assertEquals("Did not add processor", processor, dataflow
      .getProcessors().get(0));
  // Should have received the edit event
  assertEquals("Incorrect number of events", 1,
      editManagerObserver.events.size());
  EditManagerEvent event = editManagerObserver.events.get(0);
  assertTrue("Event was not a DataflowEditEvent",
      event instanceof DataflowEditEvent);
  DataflowEditEvent dataEditEvent = (DataflowEditEvent) event;
  assertEquals("Event did not have correct dataflow", dataflow,
      dataEditEvent.getDataFlow());
  assertEquals("Event did not have correct edit", edit, dataEditEvent
      .getEdit());
}

代码示例来源:origin: net.sf.taverna.t2.ui-api/contextual-views-api

private void considerEdit(EditManagerEvent message, Edit edit) {
  // boolean result = false;
  if (edit instanceof CompoundEdit) {
    for (Edit subEdit : ((CompoundEdit) edit).getChildEdits()) {
      considerEdit(message, subEdit);
    }
  } else {
    Object subject = edit.getSubject();
    if (subject == owningProcessor) {
      // panel.reevaluate();
      setTitle(getRelativeName(owningDataflow, activity));
    } else if (subject == owningDataflow) {
      if (!owningDataflow.getProcessors().contains(owningProcessor)) {
        ActivityConfigurationAction.clearDialog(activity);
      }
    } else if (subject == activity) {
      if (message instanceof DataFlowUndoEvent) {
        logger.info("undo of activity edit found");
        panel.refreshConfiguration();
      } else if (message instanceof DataFlowRedoEvent) {
        logger.info("redo of activity edit found");
        panel.refreshConfiguration();
      }
    }
  }
}

代码示例来源:origin: net.sf.taverna.t2/workflowmodel-impl

@Override
protected void doEditAction(ProcessorImpl processor) throws EditException {
  compoundEdit.doEdit();
}

代码示例来源:origin: net.sf.taverna.t2.core/workflowmodel-api

/**
 * Attempts to call the doEdit method of all child edits. If any of those
 * children throws an EditException any successful edits are rolled back and
 * the exception is rethrown as the cause of a new EditException from the
 * CompoundEdit
 */
public synchronized Object doEdit() throws EditException {
  if (isApplied()) {
    throw new EditException("Cannot apply an edit more than once!");
  }
  List<Edit<?>> doneEdits = new ArrayList<Edit<?>>();
  try {
    for (Edit<?> edit : childEdits) {
      edit.doEdit();
      // Insert the done edit at position 0 in the list so we can
      // iterate over the list in the normal order if we need to
      // rollback, this ensures that the most recent edit is first.
      doneEdits.add(0, edit);
    }
    applied = true;
  } catch (EditException ee) {
    for (Edit<?> undoMe : doneEdits) {
      undoMe.undo();
    }
    applied = false;
    throw new EditException("Failed child of compound edit", ee);
  }
  return null;
}

代码示例来源:origin: net.sf.taverna.t2.ui-activities/biomoby-activity-ui

@Override
protected void undoEditAction(DataflowImpl dataflow) {
  if (linkEdit!=null && linkEdit.isApplied())
    linkEdit.undo();
  if (compoundEdit!=null && compoundEdit.isApplied())
    compoundEdit.undo();
  if (upstreamObjectEdit!=null && upstreamObjectEdit.isApplied()) {
    upstreamObjectEdit.undo();
  }
  
}

代码示例来源:origin: net.sf.taverna.t2/workflowmodel-api

/**
 * Rolls back all child edits in reverse order
 */
public synchronized void undo() {
  for (int i = (childEdits.size() - 1); i >= 0; i--) {
    // Undo child edits in reverse order
    childEdits.get(i).undo();
  }
  applied = false;
}

代码示例来源:origin: net.sf.taverna.t2.workbench/edits-impl

@Test
public void undoAddProcessor() throws Exception {
  EditManager editManager = EditManager.getInstance();
  editManager.addObserver(editManagerObserver);
  Edits edits = editManager.getEdits();
  Edit<Dataflow> edit = edits.getAddProcessorEdit(dataflow, processor);
  editManager.doDataflowEdit(dataflow, edit);
  assertFalse("Did not add processor", dataflow.getProcessors().isEmpty());
  editManager.undoDataflowEdit(dataflow);
  assertTrue("Did not undo add processor", dataflow.getProcessors()
      .isEmpty());
  // Should have received the undo event
  assertEquals("Incorrect number of events", 2,
      editManagerObserver.events.size());
  EditManagerEvent event = editManagerObserver.events.get(1);
  assertTrue("Event was not a DataflowEditEvent",
      event instanceof DataFlowUndoEvent);
  DataFlowUndoEvent dataEditEvent = (DataFlowUndoEvent) event;
  assertEquals("Event did not have correct dataflow", dataflow,
      dataEditEvent.getDataFlow());
  assertEquals("Event did not have correct edit", edit, dataEditEvent
      .getEdit());
  assertFalse("Edit was still applied", edit.isApplied());
}

代码示例来源:origin: net.sf.taverna.t2.core/workflowmodel-impl

@Override
protected void undoEditAction(ProcessorImpl processor) {
  try {
    new EditsImpl().getAddProcessorOutputPortEdit(processor, port).doEdit();
  } catch (EditException e) {
    logger.error("There was an error adding an input port to a Processor whilst undoing a remove");
  }
}

代码示例来源:origin: net.sf.taverna.t2/maelstrom-api

/**
 * Attempts to call the doEdit method of all child edits. If any of those
 * children throws an EditException any successful edits are rolled back and
 * the exception is rethrown as the cause of a new EditException from the
 * CompoundEdit
 */
public synchronized Object doEdit() throws EditException {
  if (isApplied()) {
    throw new EditException("Cannot apply an edit more than once!");
  }
  List<Edit<?>> doneEdits = new ArrayList<Edit<?>>();
  try {
    for (Edit<?> edit : childEdits) {
      edit.doEdit();
      // Insert the done edit at position 0 in the list so we can
      // iterate over the list in the normal order if we need to
      // rollback, this ensures that the most recent edit is first.
      doneEdits.add(0, edit);
    }
    applied = true;
  } catch (EditException ee) {
    for (Edit<?> undoMe : doneEdits) {
      undoMe.undo();
    }
    applied = false;
    throw new EditException("Failed child of compound edit", ee);
  }
  return null;
}

代码示例来源:origin: net.sf.taverna.t2.activities/biomoby-activity-ui

@Override
protected void undoEditAction(DataflowImpl subjectImpl) {
  if (linkEdit != null && linkEdit.isApplied())
    linkEdit.undo();
  if (compoundEdit != null && compoundEdit.isApplied())
    compoundEdit.undo();
}

代码示例来源:origin: net.sf.taverna.t2/workflowmodel-impl

@Override
protected void undoEditAction(MergeImpl mergeImpl) {
  if (connectOutLinkEdit!=null) connectOutLinkEdit.undo();
  connectInLinkEdit.undo();
  mergeImpl.removeInputPort(mergeInputPort);
}

代码示例来源:origin: net.sf.taverna.t2/workflowmodel-impl

@Override
protected void undoEditAction(ProcessorImpl processor) {
  try {
    new EditsImpl().getAddProcessorInputPortEdit(processor, port).doEdit();
  } catch (EditException e) {
    logger.error("There was an error adding an input port to a Processor whilst undoing a remove");
  }
}

代码示例来源:origin: net.sf.taverna.t2/maelstrom-impl

/**
 * Check that the outgoing link to the sink port is retained when undoing a second merged input.
 */
@Test
public void undoSecond() throws Exception {
  Edit<Merge> theEdit = new ConnectMergedDatalinkEdit(merge,sourcePort,sinkPort);
  theEdit.doEdit();
  ProcessorImpl p3=new ProcessorImpl();
  ProcessorOutputPortImpl sourcePort2=new ProcessorOutputPortImpl(p3,"source_port2",0,0);
  Edit<Merge> theEdit2 = new ConnectMergedDatalinkEdit(merge,sourcePort2,sinkPort);
  theEdit2.doEdit();
  theEdit2.undo();
  assertEquals(1,merge.getInputPorts().size());
  assertEquals(1,merge.getOutputPort().getOutgoingLinks().size());
}

相关文章