use of org.eclipse.e4.ui.workbench.modeling.ESelectionService in project whole by wholeplatform.
the class MergeResourcesAction method run.
@Override
public void run() {
ESelectionService selectionService = getContext().get(ESelectionService.class);
IBindingManager bm = (IBindingManager) selectionService.getSelection();
IEntity focusEntity = bm.wGet("focusEntity");
Shell shell = (Shell) getContext().get(IServiceConstants.ACTIVE_SHELL);
IEntity result = performWorkspaceResourceSelection(shell, focusEntity);
if (!EntityUtils.isNull(result)) {
ModelTransactionCommand mtc = new ModelTransactionCommand(focusEntity);
try {
mtc.setLabel("add Artifacts");
mtc.begin();
EntityUtils.merge(focusEntity, result, createEntityComparator(), false);
mtc.commit();
if (mtc.canUndo()) {
IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
CommandStack commandStack = viewer.getEditDomain().getCommandStack();
commandStack.execute(mtc);
}
} catch (RuntimeException e) {
mtc.rollbackIfNeeded();
throw e;
}
}
}
use of org.eclipse.e4.ui.workbench.modeling.ESelectionService in project whole by wholeplatform.
the class MergeResourcesAction method update.
@Override
public void update() {
ESelectionService selectionService = getContext().get(ESelectionService.class);
if (selectionService.getSelection() instanceof IBindingManager) {
IBindingManager bm = (IBindingManager) selectionService.getSelection();
setEnabled(HandlersBehavior.isValidFocusEntityPart(bm));
} else
setEnabled(false);
}
use of org.eclipse.e4.ui.workbench.modeling.ESelectionService in project whole by wholeplatform.
the class ReplaceWithClassNameAction method run.
@Override
public void run() {
Shell shell = (Shell) getContext().get(IServiceConstants.ACTIVE_SHELL);
FilteredItemsSelectionDialog dialog = new OpenTypeSelectionDialog(shell, true, PlatformUI.getWorkbench().getProgressService(), null, IJavaSearchConstants.TYPE);
dialog.setTitle("Select a class");
dialog.setMessage("Choose a class or a compilation unit");
dialog.setInitialPattern(StringUtils.toSimpleName(className));
if (dialog.open() != IDialogConstants.OK_ID)
return;
IType primaryType = (IType) dialog.getResult()[0];
if (primaryType == null)
return;
className = primaryType.getFullyQualifiedName();
ESelectionService selectionService = getContext().get(ESelectionService.class);
IBindingManager bm = (IBindingManager) selectionService.getSelection();
IEntity focusEntity = bm.wGet("focusEntity");
IEntity replacement = GenericEntityFactory.instance.create(ed, className);
ModelTransactionCommand mtc = new ModelTransactionCommand(focusEntity);
try {
mtc.setLabel("replace with class name");
mtc.begin();
focusEntity.wGetParent().wSet(focusEntity, replacement);
mtc.commit();
if (mtc.canUndo()) {
IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
CommandStack commandStack = viewer.getEditDomain().getCommandStack();
commandStack.execute(mtc);
}
} catch (RuntimeException e) {
mtc.rollbackIfNeeded();
throw e;
}
}
use of org.eclipse.e4.ui.workbench.modeling.ESelectionService in project whole by wholeplatform.
the class ReplaceWithResourceAction method update.
@Override
public void update() {
ESelectionService selectionService = getContext().get(ESelectionService.class);
if (selectionService.getSelection() instanceof IBindingManager) {
IBindingManager bm = (IBindingManager) selectionService.getSelection();
setEnabled(HandlersBehavior.isValidFocusEntityPart(bm));
} else
setEnabled(false);
}
Aggregations