本文整理汇总了Java中org.eclipse.core.commands.operations.IOperationHistory.execute方法的典型用法代码示例。如果您正苦于以下问题:Java IOperationHistory.execute方法的具体用法?Java IOperationHistory.execute怎么用?Java IOperationHistory.execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.commands.operations.IOperationHistory
的用法示例。
在下文中一共展示了IOperationHistory.execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
entry = unwrap(HandlerUtil.getCurrentSelection(event));
if (entry == null)
return null;
SetValueCommand setCommand = new SetValueCommand(new SetRequest(entry,
SGraphPackage.Literals.ENTRY__KIND, getEntryKind()));
IOperationHistory history = OperationHistoryFactory
.getOperationHistory();
try {
history.execute(setCommand, new NullProgressMonitor(), null);
} catch (ExecutionException e) {
e.printStackTrace();
}
return null;
}
示例2: executeOperation
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
/**
* Execute the given operation in the supplied undo context
* Tests that the operation can be executed,
* that the execute result isOK() and that no ExecutionException is thrown.
* @param operation
* @param undoContext
*/
public static final void executeOperation(IUndoableOperation operation, IUndoContext undoContext) {
operation.addContext(undoContext);
TestCase.assertTrue("Operation can't execute.", operation.canExecute());
try {
IOperationHistory history = OperationHistoryFactory.getOperationHistory();
IStatus result = history.execute(operation, null, null);
TestCase.assertTrue("failed to execute: " + operation.getLabel(), result.isOK());
} catch (ExecutionException ee) {
TestCase.fail("failed to execute");
}
TestCase.assertFalse(operation.canExecute());
IUndoContext[] contexts = operation.getContexts();
if ((contexts != null) && (contexts.length > 0)) {
// Operations that don't accept contexts don't need to be undoable.
// An example such operation is ClipboardCopyOperation,
// or any other AbstractEnsembleDoableOperation
TestCase.assertTrue("Operation is not undoable.", operation.canUndo());
}
}
示例3: modify
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
@Override
public void modify(DataPoint oldDataPoint, Object value, IUndoContext undoContext) {
if (value instanceof Date) {
DataPoint newDataPoint = JScienceFactory.eINSTANCE.createEDataPoint((Date) value, oldDataPoint.getValue());
SwapProfileDataPointOperation op = new SwapProfileDataPointOperation(profile, oldDataPoint, newDataPoint);
if (undoContext != null) {
op.addContext(undoContext);
}
IOperationHistory history = OperationHistoryFactory.getOperationHistory();
try {
history.execute(op, null, null);
} catch (ExecutionException e) {
LogUtil.error(e);
}
}
}
示例4: execute
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
public static void execute(EObject object, EStructuralFeature feature, Object newValue) {
Object oldValue = object.eGet(feature);
if (CommonUtils.equals(oldValue, newValue)) {
return;
}
String featureName = EMFUtils.getDisplayName(object, feature);
String label = "Edit " + featureName;
IUndoableOperation op = new FeatureTransactionChangeOperation(label, object, feature, oldValue, newValue);
op = EMFUtils.addContributorOperations(op, object, feature, oldValue, newValue);
IUndoContext context = TransactionUtils.getUndoContext(object);
if (context != null) {
op.addContext(context);
try {
IOperationHistory history = OperationHistoryFactory.getOperationHistory();
history.execute(op, null, null);
} catch (Exception e) {
LogUtil.error("execute", e);
}
}
}
示例5: modify
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
@Override
public void modify(T facet, Object value, IUndoContext undoContext) {
IUndoableOperation operation = new PropertyDescriptorUpdateOperation("Set value", facet, itemPropertyDescriptor, value);
operation = EMFDetailUtils.addContributorOperations(operation, facet, itemPropertyDescriptor, value);
operation.addContext(undoContext);
IWorkbenchOperationSupport operationSupport = PlatformUI.getWorkbench().getOperationSupport();
IOperationHistory operationHistory = operationSupport.getOperationHistory();
try {
IStatus execute = operationHistory.execute(operation, null, null);
if(execute.matches(IStatus.ERROR)) {
throw new ExecutionException(execute.getMessage());
}
} catch (ExecutionException e) {
LogUtil.error(e);
}
}
示例6: execute
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
/**
* Execute the operation in the undo context, in a job.
*
* If the operation is an IDisplayOperation, and both the widget and site are provided,
* then the job will be created as a DisplayOperationJob.
*
* If the operation can not be executed, it will be disposed.
*
* @param operation
* @param undoContext
* @param widget
* @param site
*/
public static void execute(final IUndoableOperation operation, IUndoContext undoContext, final Widget widget, final IWorkbenchSite site) {
IOperationHistory history = OperationHistoryFactory.getOperationHistory();
IAdaptable adaptable = null;
if ((operation instanceof IDisplayOperation) && (widget != null) && (site != null)) {
IDisplayOperation displayOperation = (IDisplayOperation) operation;
adaptable = new IDisplayOperation.Adaptable(displayOperation, widget, site);
}
if (undoContext != null) {
operation.addContext(undoContext);
}
try {
history.execute(operation, null, adaptable);
} catch (ExecutionException e) {
// should never occur
LogUtil.error(e);
}
}
示例7: copyPasteElements
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
/**
* @param plan
* @param selectedElements
* @param targetElements
* @param assertPostconditions
*/
private void copyPasteElements(final OperationTestPlanRecord plan, final EPlanElement[] selectedElements, final EPlanElement[] targetElements, final PasteOperationRunnable assertPostconditions) {
final IStructuredSelection selection = new StructuredSelection(selectedElements);
final IStructureModifier modifier = PlanStructureModifier.INSTANCE;
ITransferable transferable = modifier.getTransferable(selection);
IUndoableOperation copy = new ClipboardCopyOperation(transferable, modifier);
// copy
try {
IOperationHistory history = OperationHistoryFactory.getOperationHistory();
history.execute(copy, null, null);
} catch (ExecutionException ee) {
fail("failed to execute");
}
final IStructuredSelection targetSelection = new StructuredSelection(targetElements);
final PlanClipboardPasteOperation paste = new PlanClipboardPasteOperation(targetSelection, modifier);
testUndoableOperation(plan.plan, paste,
new Runnable() {
@Override
public void run() {
assertPostconditions.run(paste);
}
});
}
示例8: execute
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
public static <T> void execute(String label, EcoreEList<T> list, List<T> objects) {
boolean containsOne = false;
for (T item : list) {
if (objects.contains(item)) {
containsOne = true;
break;
}
}
if (!containsOne) {
return;
}
IUndoableOperation op = new FeatureTransactionRemoveAllOperation<T>(label, list, objects);
IUndoContext context = TransactionUtils.getUndoContext(list);
if (context != null) {
op.addContext(context);
try {
IOperationHistory history = OperationHistoryFactory.getOperationHistory();
history.execute(op, null, null);
} catch (Exception e) {
LogUtil.error("execute", e);
}
}
}
示例9: execute
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
public static <T> void execute(String label, EcoreEList<T> list, List<T> objects) {
if (list.getEStructuralFeature().isUnique() && list.containsAll(objects)) {
return;
}
IUndoableOperation op = new FeatureTransactionAddAllOperation<T>(label, list, objects);
IUndoContext context = TransactionUtils.getUndoContext(list);
if (context != null) {
op.addContext(context);
try {
IOperationHistory history = OperationHistoryFactory.getOperationHistory();
history.execute(op, null, null);
} catch (Exception e) {
LogUtil.error("execute", e);
}
}
}
示例10: executeCommand
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
protected void executeCommand(AbstractTransactionalCommand operation) {
IOperationHistory history = OperationHistoryFactory.getOperationHistory();
try {
history.execute(operation, new NullProgressMonitor(), null);
} catch (ExecutionException e) {
e.printStackTrace();
}
}
示例11: executeCommand
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
protected void executeCommand(IUndoableOperation command, Resource resource) {
IOperationHistory history = OperationHistoryFactory.getOperationHistory();
try {
history.execute(command, new NullProgressMonitor(), null);
} catch (ExecutionException e) {
e.printStackTrace();
}
}
示例12: execute
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
private void execute(IUndoableOperation operation, EPlan plan) {
operation.addContext(TransactionUtils.getUndoContext(plan));
// perform the operation
try {
IOperationHistory history = OperationHistoryFactory.getOperationHistory();
history.execute(operation, null, null);
} catch (ExecutionException ee) {
fail("failed to execute");
}
}
示例13: modifyStartTime
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
private static void modifyStartTime(IPlanModifier modifier, EPlanElement element, Date newStart) throws ExecutionException {
EPlan plan = EPlanUtils.getPlan(element);
TemporalExtentsCache cache = new TemporalExtentsCache(plan);
Map<EPlanElement, TemporalExtent> changedTimes = modifier.moveToStart(element, newStart, cache);
SetExtentsOperation operation = new SetExtentsOperation("set start times", plan, changedTimes, cache);
operation.addContext(TransactionUtils.getUndoContext(plan));
IOperationHistory history = OperationHistoryFactory.getOperationHistory();
history.execute(operation, null, null);
}
示例14: changeSendToTmState
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
/**
* 设置是否添加到记忆库
* @param selectedRowIds
* @param state
* "yes" or "no";
*/
public void changeSendToTmState(List<String> selectedRowIds, String state) {
IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
try {
operationHistory.execute(new SendTOTmOperation("send-to-tm", xliffEditor.getTable(), selectedRowIds,
xliffEditor.getXLFHandler(), state), null, null);
} catch (ExecutionException e) {
LOGGER.error("", e);
MessageDialog.openError(xliffEditor.getSite().getShell(),
Messages.getString("utils.NattableUtil.msgTitle2"), e.getMessage());
e.printStackTrace();
}
}
示例15: createChainOperation
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
private void createChainOperation(PlanEditorModel model, final List<EPlanChild> links) {
IUndoContext undoContext = model.getUndoContext();
PlanStructureModifier modifier = PlanStructureModifier.INSTANCE;
ChainOperation operation = new ChainOperation(modifier, links, false);
operation.addContext(undoContext);
try {
IOperationHistory history = OperationHistoryFactory.getOperationHistory();
IStatus status = history.execute(operation, null, null);
if (status instanceof JobOperationStatus) {
((JobOperationStatus) status).getJob().join();
}
} catch (Exception e) {
trace.error("OneOfEachAction.createChainOperation:operation", e);
}
}