Java Code Examples for org.eclipse.e4.ui.model.application.ui.basic.MPart#getObject()

The following examples show how to use org.eclipse.e4.ui.model.application.ui.basic.MPart#getObject() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OtherWindowCmd.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
@Execute
protected void doOtherWindow(@Active MPart apart, @Named(E4CmdHandler.CMD_CTX_KEY)String cmd, @Active EmacsPlusCmdHandler handler) {
	PartAndStack ps = getParentStack(apart); 
	MElementContainer<MUIElement> otherStack = getAdjacentElement(ps.getStack(), ps.getPart(), true);
	MPart other = (MPart)otherStack.getSelectedElement();
	// TODO An egregious hack that may break at any time
	// Is there a defined way of getting the IEditorPart from an MPart?
	if (other.getObject() instanceof CompatibilityEditor) {
		IEditorPart editor = ((CompatibilityEditor) other.getObject()).getEditor();
		try {
			reactivate(other);
			if (handler.isUniversalPresent()) {
				EmacsPlusUtils.executeCommand(cmd, handler.getUniversalCount(), null, editor);
			} else {
				EmacsPlusUtils.executeCommand(cmd, null, editor);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		finally {
			reactivate(apart);
		}
	}
}
 
Example 2
Source File: AutomaticSwitchPerspectivePartListener.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void switchPerspective(final MPart part) {
    if (!isSwitching) {
        isSwitching = true;
        try {
            final String activePerspective = getActivePerspectiveId(part);
            if (part != null && "org.eclipse.e4.ui.compatibility.editor".equals(part.getElementId())) {
                final CompatibilityEditor compatibilityEditor = (CompatibilityEditor) part.getObject();
                if (compatibilityEditor != null && activePerspective != null) {
                    final String id = BonitaPerspectivesUtils.getPerspectiveId(compatibilityEditor.getEditor());
                    if (id != null && !id.equals(activePerspective)) {
                        BonitaPerspectivesUtils.switchToPerspective(id);
                    }
                }
            }
        } finally {
            isSwitching = false;
        }
    }
}
 
Example 3
Source File: HandlerDisplayIgnored.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
@Execute
public void execute(MItem item, MPart part, IConfiguration configuration, UISynchronize uiSynch) {
	LogUtil.entering(item, part, configuration, uiSynch);
	configuration.setDisplayIgnored(item.isSelected());
	final Object object = part.getObject();
	if (object instanceof Dashboard) {
		final Dashboard view = (Dashboard) object;
		uiSynch.syncExec(view::refresh);
	}
	LogUtil.exiting();
}
 
Example 4
Source File: HandlerDisplayDone.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
@Execute
public void execute(MItem item, MPart part, IConfiguration configuration, UISynchronize uiSynch) {
	LogUtil.entering(item, part, configuration, uiSynch);
	configuration.setDisplayDone(item.isSelected());
	final Object object = part.getObject();
	if (object instanceof Dashboard) {
		final Dashboard view = (Dashboard) object;
		uiSynch.syncExec(view::refresh);
	}
	LogUtil.exiting();
}
 
Example 5
Source File: HandlerRefresh.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
@Execute
public void execute(MPart part, UISynchronize uiSynch) {
	LogUtil.entering(part, uiSynch);
	final Object object = part.getObject();
	if (object instanceof Dashboard) {
		final Dashboard view = (Dashboard) object;
		uiSynch.syncExec(view::refresh);
	}
	LogUtil.exiting();
}
 
Example 6
Source File: TaskResultPartTableFilterHandler.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(MPart part, MDirectToolItem item){
	TaskResultPart taskResultPart = (TaskResultPart) part.getObject();
	
	if (item.isSelected()) {
		if (showFailuresOnlyFilter == null) {
			showFailuresOnlyFilter = (object) -> !((ITask) object).isSucceeded();
		}
		
		taskResultPart.getContentProvider().setFilter(showFailuresOnlyFilter);
	} else {
		taskResultPart.getContentProvider().setFilter(AcceptAllFilter.getInstance());
	}
	
}
 
Example 7
Source File: TaskResultPartRefreshHandler.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
@Execute
public void execute(MPart part){
	TaskResultPart taskResultPart = (TaskResultPart) part.getObject();
	taskResultPart.refresh();
}