use of org.eclipse.e4.ui.workbench.modeling.ESelectionService in project whole by wholeplatform.
the class ReplaceWithClassNameAction method update.
@Override
public void update() {
ESelectionService selectionService = getContext().get(ESelectionService.class);
if (selectionService.getSelection() instanceof IBindingManager) {
IBindingManager bm = (IBindingManager) selectionService.getSelection();
IJavaProject javaProject = (IJavaProject) bm.wGetValue("javaProject");
setEnabled(javaProject != null && HandlersBehavior.isValidFocusEntityPart(bm));
} else
setEnabled(false);
}
use of org.eclipse.e4.ui.workbench.modeling.ESelectionService in project whole by wholeplatform.
the class ReplaceWithResourceAction method run.
@Override
public void run() {
ESelectionService selectionService = getContext().get(ESelectionService.class);
IBindingManager bm = (IBindingManager) selectionService.getSelection();
IEntity focusEntity = bm.wGet("focusEntity");
ResourceKind resourceKind = getResourceKind(focusEntity);
Shell shell = (Shell) getContext().get(IServiceConstants.ACTIVE_SHELL);
boolean selectionPerformed = false;
switch(resourceKind) {
case WORKSPACE:
selectionPerformed = performWorkspaceResourceSelection(shell, focusEntity);
break;
case CLASSPATH:
selectionPerformed = performClasspathResourceSelection(shell, focusEntity);
break;
case FILE_SYSTEM:
case URL:
selectionPerformed = performFilesystemSelection(shell, focusEntity, resourceKind == ResourceKind.URL);
break;
}
if (!selectionPerformed)
return;
IEntity replacement = GenericEntityFactory.instance.create(ed, path);
ModelTransactionCommand mtc = new ModelTransactionCommand(focusEntity);
try {
mtc.setLabel("replace with class name");
mtc.begin();
performReplace(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 AbstractSelectionConstrainedVisibleWhen method evaluate.
@Override
public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
ESelectionService selectionService = (ESelectionService) context.getVariable(ESelectionService.class.getName());
Object selection = selectionService.getSelection();
if (selection instanceof IBindingManager) {
if (isVisible((IBindingManager) selection))
return EvaluationResult.TRUE;
}
return EvaluationResult.FALSE;
}
use of org.eclipse.e4.ui.workbench.modeling.ESelectionService in project whole by wholeplatform.
the class ActivateToolAction method update.
@Override
public void update() {
setEnabled(false);
ESelectionService selectionService = getContext().get(ESelectionService.class);
if (selectionService.getSelection() instanceof IBindingManager) {
IBindingManager bm = (IBindingManager) selectionService.getSelection();
if (bm.wIsSet("viewer"))
setEnabled(!tool.isActive((IEntityPartViewer) bm.wGetValue("viewer")));
}
}
use of org.eclipse.e4.ui.workbench.modeling.ESelectionService in project whole by wholeplatform.
the class ActivateToolAction method run.
@Override
public void run() {
ESelectionService selectionService = getContext().get(ESelectionService.class);
IBindingManager bm = (IBindingManager) selectionService.getSelection();
IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
boolean clearCaret = Tools.TEXTUAL != tool && Tools.TEXTUAL.isActive(viewer);
if (tool.ensureActive(viewer) && clearCaret) {
IEntity focusEntity = bm.wGet("focusEntity");
IEntityPart focusPart = viewer.getEditPartRegistry().get(focusEntity);
if (focusPart instanceof ITextualEntityPart) {
ITextualEntityPart textualPart = (ITextualEntityPart) focusPart;
textualPart.setCaretVisible(false);
viewer.setSelection(new StructuredSelection(textualPart));
}
}
}
Aggregations