本文整理汇总了Java中org.apache.taverna.workbench.edits.Edit类的典型用法代码示例。如果您正苦于以下问题:Java Edit类的具体用法?Java Edit怎么用?Java Edit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Edit类属于org.apache.taverna.workbench.edits包,在下文中一共展示了Edit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transferConditions
import org.apache.taverna.workbench.edits.Edit; //导入依赖的package包/类
private void transferConditions(List<Edit<?>> editList,
Map<Object, Object> oldNewMapping, Processor nestingProcessor) {
for (Processor p : currentDataflow.getProcessors()) {
boolean isTargetMoved = oldNewMapping.containsKey(p);
for (BlockingControlLink c : p.controlLinksWaitingFor()) {
Processor pre = c.getUntilFinished();
boolean isControlMoved = oldNewMapping.containsKey(pre);
if (isTargetMoved && isControlMoved) {
// Add in new condition
new BlockingControlLink(
(Processor) oldNewMapping.get(pre),
(Processor) oldNewMapping.get(p));
} else if (isTargetMoved) {
editList.add(new RemoveChildEdit<>(c.getParent(),c));
editList.add(new AddChildEdit<>(c.getParent(),
new BlockingControlLink(pre, nestingProcessor)));
} else if (isControlMoved) {
editList.add(new RemoveChildEdit<>(c.getParent(), c));
editList.add(new AddChildEdit<>(c.getParent(),
new BlockingControlLink(nestingProcessor, p)));
}
}
}
}
示例2: transferProcessor
import org.apache.taverna.workbench.edits.Edit; //导入依赖的package包/类
private void transferProcessor(List<Edit<?>> editList,
Map<Object, Object> oldNewMapping, Workflow nestedDataflow,
Processor p) throws Exception {
editList.add(new RemoveChildEdit<>(currentDataflow, p));
Processor newProcessor = (Processor) p.clone();
newProcessor.setParent(nestedDataflow);
oldNewMapping.put(p, newProcessor);
for (InputProcessorPort pip : p.getInputPorts())
for (InputProcessorPort newPip : newProcessor.getInputPorts())
if (pip.getName().equals(newPip.getName())) {
oldNewMapping.put(pip, newPip);
break;
}
for (OutputProcessorPort pop : p.getOutputPorts())
for (OutputProcessorPort newPop : newProcessor.getOutputPorts())
if (pop.getName().equals(newPop.getName())) {
oldNewMapping.put(pop, newPop);
break;
}
}
示例3: connectNewProcessor
import org.apache.taverna.workbench.edits.Edit; //导入依赖的package包/类
void connectNewProcessor(Workflow d, Processor newProcessor)
throws EditException {
List<Edit<?>> editsToDo = new ArrayList<>();
for (InputProcessorPort pip : newProcessor.getInputPorts()) {
InputWorkflowPort dip = new InputWorkflowPort(d, pip.getName());
// FIXME How to set depth?
editsToDo.add(new AddWorkflowInputPortEdit(d, dip));
editsToDo.add(new AddDataLinkEdit(d, new DataLink(d, dip, pip)));
}
for (OutputProcessorPort pop : newProcessor.getOutputPorts()) {
OutputWorkflowPort dop = new OutputWorkflowPort(d, pop.getName());
// TODO How to indicate depth?
editsToDo.add(new AddWorkflowOutputPortEdit(d, dop));
editsToDo.add(new AddDataLinkEdit(d, new DataLink(d, pop, dop)));
}
em.doDataflowEdit(d.getParent(), new CompoundEdit(editsToDo));
}
示例4: pasteProcessor
import org.apache.taverna.workbench.edits.Edit; //导入依赖的package包/类
public Processor pasteProcessor(CopiedProcessor copy, Workflow d)
throws
ClassNotFoundException, InstantiationException,
IllegalAccessException, EditException {
Processor result = ProcessorXMLDeserializer.getInstance()
.deserializeProcessor(copy.processor, copy.requiredSubworkflows);
if (result == null)
return null;
String newName = Tools.uniqueProcessorName(result.getName(), d);
List<Edit<?>> editList = new ArrayList<>();
if (!newName.equals(result.getName()))
editList.add(new RenameEdit<>(result, newName));
editList.add(new AddProcessorEdit(d, result));
em.doDataflowEdit(d.getParent(), new CompoundEdit(editList));
return result;
}
示例5: addEditOrRedo
import org.apache.taverna.workbench.edits.Edit; //导入依赖的package包/类
/**
* Add an edit or redo. Common functionallity called by
* {@link #addEdit(Edit)} and {@link #addRedo(Edit)}.
*
* @see #addEdit(Edit)
* @see #addRedo(Edit)
* @param edit
* The {@link Edit} to add
* @param isRedo
* True if this is a redo
*/
protected void addEditOrRedo(Edit<?> edit, boolean isRedo) {
edits.add(edit);
if (undoes.isEmpty())
return;
if (isRedo) {
// It's a redo, remove only the last one
int lastUndoIndex = undoes.size() - 1;
Edit<?> lastUndo = undoes.get(lastUndoIndex);
if (!edit.equals(lastUndo))
throw new IllegalArgumentException(
"Can only redo last undo");
undoes.remove(lastUndoIndex);
} else
// It's a new edit, remove all redos
undoes.clear();
}
示例6: undoAddProcessor
import org.apache.taverna.workbench.edits.Edit; //导入依赖的package包/类
@Test
public void undoAddProcessor() throws Exception {
EditManager editManager = new EditManagerImpl();
editManager.addObserver(editManagerObserver);
Edit<Workflow> edit = new AddProcessorEdit(dataflow, processor);
editManager.doDataflowEdit(dataflow.getParent(), edit);
assertFalse("Did not add processor", dataflow.getProcessors().isEmpty());
editManager.undoDataflowEdit(dataflow.getParent());
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 workflow", dataflow,
dataEditEvent.getDataFlow().getWorkflows().first());
assertEquals("Event did not have correct edit", edit, dataEditEvent
.getEdit());
assertFalse("Edit was still applied", edit.isApplied());
}
示例7: actionPerformed
import org.apache.taverna.workbench.edits.Edit; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
try {
dataflowSelectionModel.removeSelection(port);
List<DataLink> datalinks = scufl2Tools.datalinksFrom(port);
if (datalinks.isEmpty())
editManager.doDataflowEdit(dataflow.getParent(),
new RemoveWorkflowInputPortEdit(dataflow, port));
else {
List<Edit<?>> editList = new ArrayList<>();
for (DataLink datalink : datalinks)
editList.add(new RemoveDataLinkEdit(dataflow, datalink));
editList.add(new RemoveWorkflowInputPortEdit(dataflow, port));
editManager.doDataflowEdit(dataflow.getParent(),
new CompoundEdit(editList));
}
} catch (EditException e1) {
logger.debug("Delete workflow input port failed", e1);
}
}
示例8: actionPerformed
import org.apache.taverna.workbench.edits.Edit; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
try {
dataflowSelectionModel.removeSelection(port);
List<DataLink> datalinks = scufl2Tools.datalinksTo(port);
if (datalinks.isEmpty())
editManager.doDataflowEdit(dataflow.getParent(),
new RemoveWorkflowOutputPortEdit(dataflow, port));
else {
List<Edit<?>> editList = new ArrayList<>();
for (DataLink datalink : datalinks)
editList.add(new RemoveDataLinkEdit(dataflow, datalink));
editList.add(new RemoveWorkflowOutputPortEdit(dataflow, port));
editManager.doDataflowEdit(dataflow.getParent(),
new CompoundEdit(editList));
}
} catch (EditException ex) {
logger.debug("Delete workflow output port failed", ex);
}
}
示例9: isChanged
import org.apache.taverna.workbench.edits.Edit; //导入依赖的package包/类
@Test
public void isChanged() throws Exception {
WorkflowBundle dataflow = openDataflow();
assertFalse("Dataflow should not have changed", fileManager
.isDataflowChanged(dataflow));
// Do a change
Processor emptyProcessor = new Processor();
Edit<Workflow> addProcessorEdit = new AddProcessorEdit(dataflow.getMainWorkflow(),
emptyProcessor);
editManager.doDataflowEdit(dataflow, addProcessorEdit);
assertTrue("Dataflow should have changed", fileManager
.isDataflowChanged(dataflow));
// Save it with the change
File dataflowFile = File.createTempFile("test", ".t2flow");
dataflowFile.deleteOnExit();
dataflowFile.delete();
fileManager.saveDataflow(dataflow, WF_BUNDLE_FILE_TYPE, dataflowFile, false);
assertFalse("Dataflow should no longer be marked as changed",
fileManager.isDataflowChanged(dataflow));
}
示例10: considerEdit
import org.apache.taverna.workbench.edits.Edit; //导入依赖的package包/类
private void considerEdit(Edit<?> edit, boolean undoing) {
if (edit instanceof CompoundEdit) {
CompoundEdit compound = (CompoundEdit) edit;
for (Edit<?> e : compound.getChildEdits())
considerEdit(e, undoing);
} else if (edit instanceof AddChildEdit
&& edit.getSubject() instanceof Workflow) {
Workflow subject = (Workflow) edit.getSubject();
DataflowSelectionModel selectionModel = getDataflowSelectionModel(subject
.getParent());
Object child = ((AddChildEdit<?>) edit).getChild();
if (child instanceof Processor
|| child instanceof InputWorkflowPort
|| child instanceof OutputWorkflowPort) {
if (undoing
&& selectionModel.getSelection().contains(child))
selectionModel.clearSelection();
else {
Set<Object> selection = new HashSet<>();
selection.add(child);
selectionModel.setSelection(selection);
}
}
}
}
示例11: considerEdit
import org.apache.taverna.workbench.edits.Edit; //导入依赖的package包/类
private void considerEdit(EditManagerEvent message, Edit<?> edit) {
// boolean result = false;
if (edit instanceof CompoundEdit) {
for (Edit<?> subEdit : ((CompoundEdit) edit).getChildEdits())
considerEdit(message, subEdit);
return;
}
Object subject = edit.getSubject();
if (subject == owningProcessor) {
// panel.reevaluate();
setTitle(getRelativeName(owningWorkflowBundle, activity));
} else if (subject == owningWorkflowBundle) {
for (Workflow workflow : owningWorkflowBundle.getWorkflows())
if (!workflow.getProcessors().contains(owningProcessor))
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();
}
}
}
示例12: configureActivity
import org.apache.taverna.workbench.edits.Edit; //导入依赖的package包/类
public void configureActivity(WorkflowBundle workflowBundle, Activity activity,
ObjectNode json, List<ActivityPortConfiguration> inputPorts,
List<ActivityPortConfiguration> outputPorts) {
try {
List<Edit<?>> editList = new ArrayList<Edit<?>>();
Profile profile = activity.getParent();
List<ProcessorBinding> processorBindings = scufl2Tools
.processorBindingsToActivity(activity);
Configuration configuration = scufl2Tools.configurationFor(activity, profile);
editList.add(new ChangeJsonEdit(configuration, json));
configurePorts(activity, editList, processorBindings, inputPorts, PortType.INPUT);
configurePorts(activity, editList, processorBindings, outputPorts, PortType.OUTPUT);
editManager.doDataflowEdit(workflowBundle, new CompoundEdit(editList));
} catch (IllegalStateException | EditException e) {
logger.error(e);
}
}
示例13: createInputPort
import org.apache.taverna.workbench.edits.Edit; //导入依赖的package包/类
private void createInputPort(Activity activity, List<Edit<?>> editList,
List<ProcessorBinding> processorBindings,
ActivityPortConfiguration portDefinition) {
InputActivityPort actPort = new InputActivityPort(null,
portDefinition.getName());
actPort.setDepth(portDefinition.getDepth());
// add port to activity
editList.add(new AddChildEdit<>(activity, actPort));
for (ProcessorBinding processorBinding : processorBindings) {
Processor processor = processorBinding.getBoundProcessor();
// add a new processor port
InputProcessorPort procPort = new InputProcessorPort();
procPort.setName(portDefinition.getName());
procPort.setDepth(portDefinition.getDepth());
editList.add(new AddProcessorInputPortEdit(processor, procPort));
// add a new port binding
ProcessorInputPortBinding binding = new ProcessorInputPortBinding();
binding.setBoundProcessorPort(procPort);
binding.setBoundActivityPort(actPort);
editList.add(new AddChildEdit<>(processorBinding, binding));
}
}
示例14: createOutputPort
import org.apache.taverna.workbench.edits.Edit; //导入依赖的package包/类
private void createOutputPort(Activity activity, List<Edit<?>> editList,
List<ProcessorBinding> processorBindings,
ActivityPortConfiguration portDefinition) {
OutputActivityPort actPort = new OutputActivityPort(null,
portDefinition.getName());
actPort.setDepth(portDefinition.getDepth());
actPort.setGranularDepth(portDefinition.getGranularDepth());
// add port to activity
editList.add(new AddChildEdit<Activity>(activity, actPort));
for (ProcessorBinding processorBinding : processorBindings) {
Processor processor = processorBinding.getBoundProcessor();
// add a new processor port
OutputProcessorPort procPort = new OutputProcessorPort();
procPort.setName(portDefinition.getName());
procPort.setDepth(portDefinition.getDepth());
procPort.setGranularDepth(portDefinition.getGranularDepth());
editList.add(new AddProcessorOutputPortEdit(processor, procPort));
// add a new port binding
ProcessorOutputPortBinding binding = new ProcessorOutputPortBinding();
binding.setBoundProcessorPort(procPort);
binding.setBoundActivityPort(actPort);
editList.add(new AddChildEdit<>(processorBinding, binding));
}
}
示例15: defineEditsForConfiguration
import org.apache.taverna.workbench.edits.Edit; //导入依赖的package包/类
private void defineEditsForConfiguration(Workflow workflow,
OutputWorkflowPort port, WorkflowBundle workflowBundle,
Activity activity, Configuration c) {
List<Edit<?>> edits = nestedPortEdit.getChildEdits();
JsonNode nested = c.getJson().get("nestedWorkflow");
Workflow nestedWorkflow = workflowBundle.getWorkflows().getByName(
nested.asText());
if (nestedWorkflow != workflow)
return;
OutputActivityPort activityPort = activity.getOutputPorts().getByName(
port.getName());
edits.add(new RemoveChildEdit<>(activity, activityPort));
for (ProcessorBinding processorBinding : scufl2Tools
.processorBindingsToActivity(activity))
for (ProcessorOutputPortBinding portBinding : processorBinding
.getOutputPortBindings())
if (portBinding.getBoundActivityPort() == activityPort) {
OutputProcessorPort processorPort = portBinding
.getBoundProcessorPort();
edits.add(new RemoveProcessorOutputPortEdit(
processorBinding.getBoundProcessor(), processorPort));
edits.add(new RemoveChildEdit<>(processorBinding,
portBinding));
}
}