org.eclipse.e4.ui.model.application.ui.MUIElement Java Examples

The following examples show how to use org.eclipse.e4.ui.model.application.ui.MUIElement. 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: E4WindowCmd.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Find the first element with which we should join
 * 
 * @param dragStack the stack to join
 * @return the target stack 
 */
@SuppressWarnings("unchecked")  // for safe cast to MElementContainer<MUIElement>
protected MElementContainer<MUIElement> getAdjacentElement(MElementContainer<MUIElement> dragStack, MPart part, boolean stackp) {
	MElementContainer<MUIElement> result = null;
	if (dragStack != null) {
		MElementContainer<MUIElement> psash = dragStack.getParent();
		if ((Object)psash instanceof MPartSashContainer) {
			List<MUIElement> children = psash.getChildren();
			int size = children.size(); 
			if (size > 1) {
				int index = children.indexOf(dragStack)+1;
				// use the next element, or previous if we're the last one
				result = (MElementContainer<MUIElement>)children.get((index == size) ? index - 2 : index);
				if (stackp) {
					result =  findTheStack(result);
				}
			}
		}
	}
	return result;
}
 
Example #2
Source File: E4WindowCmd.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * The parent of the apart is typically a PartStack, but it could be something under an MCompositePart, so look up
 * @param apart the original selection
 * @return the MPart and PartStack
 */
protected PartAndStack getParentStack(MPart apart) {
	MPartSashContainerElement part = apart;
	MElementContainer<MUIElement> stack = apart.getParent();
	try {
		while (!((MPartSashContainerElement)stack instanceof MPartStack)) {
			if ((MPartSashContainerElement)stack instanceof MArea) {
				// some unexpected structure
				stack = null;
				part = apart;
				break;
			} else {
				part = (MPartSashContainerElement)stack;
				stack = stack.getParent();
			}
		}
	} catch (Exception e) {
		// Bail on anything unexpected - will just make the command a noop
		stack = null;
		part = apart;
	}
	return new PartAndStack((MPart)part, stack);
}
 
Example #3
Source File: FrameJoinCmd.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see com.mulgasoft.emacsplus.e4.commands.E4WindowCmd#getAdjacentElement(org.eclipse.e4.ui.model.application.ui.MElementContainer, boolean, org.eclipse.e4.ui.model.application.ui.basic.MPart)
 */
protected MElementContainer<MUIElement> getAdjacentElement(MElementContainer<MUIElement> dragStack, MPart part, boolean stackp) {
	MElementContainer<MUIElement> result = null;
	if (dragStack != null) {
		MElementContainer<MUIElement> psash = dragStack.getParent();
		MElementContainer<MUIElement> top = getTopElement(psash);
		if ((Object)top instanceof MTrimmedWindow) {
			// if we contain splits, remove them first
			if (top != psash) {
				super.joinAll(part);
			}
			Collection<MPart> parts = getParts(application.getChildren().get(0), EModelService.IN_SHARED_AREA);
			for (MPart p : parts) {
				List<MElementContainer<MUIElement>> all = getOrderedStacks(p);
				// if it has a PartStack, it sh/c/ould be an editor stack
				if (!all.isEmpty()) {
					result = all.get(0);
					break;
				};
			};
		}
	}
	return result;
}
 
Example #4
Source File: WindowJoinCmd.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Merge the stack containing the selected part into its neighbor and return the 
 * element to activate.  This will be the originating buffer on split-self or the
 * active element in the other stack if not.
 * 
 * @param apart
 * @return the element to select
 */
MPart joinOne(MPart apart) {
	// We're going to end up with 1, so avoid the overhead of futzing with the stacks
	if (isSplitSelf() && getOrderedStacks(apart).size() < 3) {
		this.joinAll(apart);
		return apart;
	} else {
		PartAndStack ps = getParentStack(apart);
		MElementContainer<MUIElement> pstack = ps.getStack();
		MPart part = ps.getPart();		
		MElementContainer<MUIElement> adjacent = getAdjacentElement(pstack, part, true);
		MUIElement otherPart = getSelected(adjacent);
		// deduplicate editors across these two stacks
		closeOthers(pstack, adjacent);
		if (pstack == null || join2Stacks(pstack, adjacent, part) == null) {
			// Invalid state 
			Beeper.beep();
		}
		return (otherPart instanceof MPart) ? (MPart)otherPart : apart;
	}
}
 
Example #5
Source File: SwitchToBufferOtherCmd.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
void switchTo(MPart newPart) {
	if (getOrderedStacks(apart).size() == 1) {
		// case 1: 1 frame, split with miniPart
		// convenience hack: change direction on uArg
		splitIt(newPart, getDirection((isUniversalPresent()) ? !DISPLAY_HORIZONTAL : DISPLAY_HORIZONTAL));
	} else {
		// case 2: multiple stacks, move to adjacent stack
		// get the starting stack
		MElementContainer<MUIElement> stack = getParentStack(apart).getStack();
		// get the topart's stack
		MElementContainer<MUIElement> tstack = getParentStack(newPart).getStack();
		stack = findNextStack(apart, stack, 1);
		if (stack != null && stack != tstack) {
			modelService.move(newPart, stack, 0);
		}
	}
	if (displayOnly) {
		// brings to top
		partService.showPart(newPart, PartState.VISIBLE);
		reactivate(apart);
	} else {
		// bug in Kepler forces us to activate the old before the new
		reactivate(apart);
		reactivate(newPart);
	}
}
 
Example #6
Source File: WindowJoinCmd.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Get all the IEditorReferences in a given part stack
 * 
 * @param stack
 * @return the collection of IEditorReferences
 */
private Collection<IEditorReference> getStackEditors(MElementContainer<MUIElement> stack) {
	Collection<IEditorReference> editors = new ArrayList<IEditorReference>(); 
	for (MUIElement child : stack.getChildren()) {
		if (child instanceof MPart) {
			// TODO: There must be a better way of getting the editor out of e4, but I can't find it
			Object cEditor = ((MPart) child).getObject();
			if (cEditor != null) {
				try {
					// avoid discouraged access of org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor
					// which is expected cEditor's type in e4
					Method method = cEditor.getClass().getMethod(GET_REF);
					if (method != null) {
						IEditorReference ie = (IEditorReference)method.invoke(cEditor);					
						editors.add(ie);

					}
				} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException
						| InvocationTargetException | ClassCastException e) {

				}
			}
		}
	}
	return editors;
}
 
Example #7
Source File: E4WindowCmd.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Find the edit area.  
 * 
 * @param w
 * 
 * @return the MArea element containing the editors
 */
protected MUIElement getEditArea(MWindow w) {
	// Seems like we should be able to use modelService.find(ID_EDITOR_AREA, w), but that returns a useless PlaceHolder
	// NB Selectors aren't supported until Luna
	//		final Selector match = new Selector() {
	//			public boolean select(MApplicationElement element) {
	//				return !modelService.findElements((MUIElement)element, null, MPart.class, EDITOR_TAG, EModelService.IN_ANY_PERSPECTIVE).isEmpty();
	//			}
	//		};
	//		List<MArea> area = modelService.findElements(w, MArea.class, EModelService.IN_SHARED_AREA, match);
	List<MArea> area = modelService.findElements(w, null, MArea.class, null, EModelService.IN_SHARED_AREA);
	List<MArea> refined = new ArrayList<MArea>();
	if (area != null) {
		for (MArea m : area) {
			if (!modelService.findElements(m, null, MPart.class, EDITOR_TAG, EModelService.IN_ANY_PERSPECTIVE).isEmpty()) {
				refined.add(m);
			}
		}
	}
	return refined.isEmpty() ? null : refined.get(0);
}
 
Example #8
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 #9
Source File: CustomPopupMenuExtender.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * well, this goes to the renderer.
 *
 * @param mgr
 */
public void addMenuContributions(IMenuManager mgr) {
    IRendererFactory factory = modelPart.getContext().get(IRendererFactory.class);
    AbstractPartRenderer obj = factory.getRenderer(menuModel, null);
    if (obj instanceof MenuManagerRenderer) {
        MenuManagerRenderer renderer = (MenuManagerRenderer) obj;
        renderer.reconcileManagerToModel(menu, menuModel);
        renderer.processContributions(menuModel, menuModel.getElementId(), false, true);
        // double cast because we're bad people
        renderer.processContents((MElementContainer<MUIElement>) ((Object) menuModel));
        List<MMenuElement> toRemove = new ArrayList<>();
        for (MMenuElement e : menuModel.getChildren()) {
            if (!(e instanceof MMenuSeparator || INCLUDES.contains(e.getElementId())
                    || e.getElementId() == null)) {
                if (e.getElementId() != null && !e.getElementId().startsWith("org.bonitasoft.studio.")) {
                    toRemove.add(e);
                    e.setVisible(false);
                }
            }
        }
        menuModel.getChildren().removeAll(toRemove);
    }

}
 
Example #10
Source File: LayoutTreeConverter.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
private void save(final MUIElement element, final List<MPlaceholder> holders, final GamaNode<String> parent,
		final String weight) {
	final String data = weight == null ? getWeight(element) : weight;
	if (element instanceof MPlaceholder && holders.contains(element)) {
		parent.addChild(valueOf(element.getTransientData().get(DISPLAY_INDEX_KEY)), parseInt(data));
	} else if (element instanceof MElementContainer) {
		final MElementContainer<?> container = (MElementContainer<?>) element;
		final List<? extends MUIElement> children = getNonEmptyChildren(container, holders);
		if (children.size() == 0) { return; }
		if (children.size() == 1) {
			save(children.get(0), holders, parent, data);
		} else {
			final GamaNode<String> node = parent.addChild(prefix(container), parseInt(data));
			children.forEach(e -> save(e, holders, node, null));
		}
	}
}
 
Example #11
Source File: ArrangeDisplayViews.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
public static void hideDisplays(final MPartStack displayStack, final List<MPlaceholder> holders) {
	final MElementContainer<MUIElement> parent = displayStack.getParent();
	parent.setVisible(false);
	holders.forEach((ph) -> {
		ph.setVisible(false);
		displayStack.getChildren().add(ph);
	});
	activateDisplays(holders, false);
	for (final MUIElement element : new ArrayList<>(parent.getChildren())) {
		if (element.getTransientData().containsKey(LAYOUT)) {
			element.setVisible(false);
			element.setToBeRendered(false);
			parent.getChildren().remove(element);
		}
	}
}
 
Example #12
Source File: E4WindowCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
private int sizeIt(MUIElement ele) {
	int result = 0;
	if (ele.getContainerData() != null) {
		result = getIntData(ele);
	} else if (ele instanceof MElementContainer) {
		@SuppressWarnings("unchecked") //checked
		List<MUIElement> mlist = ((MElementContainer<MUIElement>)ele).getChildren();
		for (MUIElement mui : mlist) {
			result += sizeIt(mui);
		}
	}
	return result;
}
 
Example #13
Source File: E4WindowCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("unchecked") // manually checked
MUIElement getSelected(MUIElement ele) {
 	MUIElement sel = ele;
	while (sel instanceof MElementContainer) {
		sel = ((MElementContainer<MUIElement>)sel).getSelectedElement();
	}
	// on occasion the above returns null which is bizarre, so try skipping the first level
	if (sel == null && ele instanceof MElementContainer) {
		List<MUIElement> c = ((MElementContainer<MUIElement>)ele).getChildren();
		if (c.size() == 1 && c.get(0) instanceof MPartStack) {
			sel = ((MElementContainer<MUIElement>)c.get(0)).getSelectedElement();
		}
	}
	return sel;
}
 
Example #14
Source File: WindowSplitCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
protected void splitIt(MPart apart, int location) {
	PartAndStack ps = getParentStack(apart);
	MElementContainer<MUIElement> pstack = ps.getStack();
	if (pstack.getChildren().size() > 1) {
		MPart newpart = ps.getPart();		

		MPartStack nstack = getStack(newpart, pstack);
		// Let the model service take care of the rest of the split
		modelService.insert(nstack, (MPartSashContainerElement)pstack, location, ratio);
	}
}
 
Example #15
Source File: E4WindowCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
protected int getIntData(MUIElement mui) {
	try {
		return Integer.parseInt(mui.getContainerData());
	} catch (NumberFormatException e) {
		// Ignore - someone has messed with the container data
		return 0;
	}
}
 
Example #16
Source File: WindowSplitCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Wrap the editor (MPart) up in a new PartStack
 * @param apart
 * @return the wrapped MPart
 */
private MPartStack getStack(MPart apart, MElementContainer<MUIElement> parent) {
	MPartStack result = MBasicFactory.INSTANCE.createPartStack();
	MStackElement stackElement = (MStackElement) apart;
	parent.getChildren().remove(apart);
	result.getChildren().add(stackElement);
	result.setSelectedElement(stackElement);
	return result;
}
 
Example #17
Source File: PerspektiveImportHandler.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private void switchToPerspectiveLegacy(MPerspective loadedPerspective,
	List<String> preLoadedFastViewIds){
	
	EModelService modelService = getService(EModelService.class);
	EPartService partService = getService(EPartService.class);
	MApplication mApplication = getService(MApplication.class);
	MTrimmedWindow mWindow = (MTrimmedWindow) modelService.find("IDEWindow", mApplication);
	if (mWindow == null) {
		List<MWindow> windows = mApplication.getChildren();
		if (!windows.isEmpty() && windows.get(0) instanceof MTrimmedWindow) {
			mWindow = (MTrimmedWindow) windows.get(0);
		}
	}
	MPerspective activePerspective = modelService.getActivePerspective(mWindow);
	MElementContainer<MUIElement> perspectiveParent = activePerspective.getParent();
	List<String> fastViewIds = preLoadedFastViewIds;
	
	// add the loaded perspective and switch to it
	String id = loadedPerspective.getElementId();
	Iterator<MUIElement> it = perspectiveParent.getChildren().iterator();
	while (it.hasNext()) {
		MUIElement element = it.next();
		if (id.equals(element.getElementId()) || element.getElementId().startsWith(id + ".<")) {
			it.remove();
		}
	}
	perspectiveParent.getChildren().add(loadedPerspective);
	
	// add fast view
	for (String fastViewId : fastViewIds) {
		ElexisFastViewUtil.addToFastView(loadedPerspective.getElementId(), fastViewId);
	}
	// the workbench window must be on top - otherwise the exception 'Application does not have an active window' occurs
	PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().open();
	
	partService.switchPerspective(loadedPerspective);
}
 
Example #18
Source File: FrameJoinCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
@Override
void joinAll(MPart apart) {
	joined = true;
	List<MTrimmedWindow> frames = getDetachedFrames();
	MElementContainer<MUIElement> last = getTopElement((MElementContainer<MUIElement>) apart.getParent());
	for (MTrimmedWindow mt : frames) {
		if (!mt.equals(last)) {
			joinOne(mt);
		}
	}
	// only join apart if its top element is a frame
	if ((Object)last instanceof MTrimmedWindow) {
		super.joinOne(apart);
	}
}
 
Example #19
Source File: FrameOtherCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * If we can find a selected MPart, activate it
 * 
 * @param ele
 */
private void focusIt(MUIElement ele) {
 	MUIElement sel = getSelected(ele);
 	// There's a bug somewhere in eclipse where this could return null, so check
 	if (sel != null) {
 		sel.setVisible(true);
 		if (sel instanceof MPart) {
 			reactivate((MPart)sel);
 		}
 	}
}
 
Example #20
Source File: WindowJoinCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Merge all stacks into one
 * 
 * @param apart - the selected MPart
 */
void joinAll(MPart apart) {
	try {
		// deduplicate editors across all stacks
		IDeduplication.closeAllDuplicates(EmacsPlusUtils.getWorkbenchPage());
	} catch (PartInitException e) {
		// Ignore
	}
	List<MElementContainer<MUIElement>> stacks = getOrderedStacks(apart);
	if (stacks.size() > 1) {
		PartAndStack ps = getParentStack(apart);
		MElementContainer<MUIElement> pstack = ps.getStack();
		MPart part = ps.getPart();		

		// check for unexpected result - who knows what Eclipse might do
		if (pstack != null) {
			MElementContainer<MUIElement> dropStack = stacks.get(0);
			for (int i = 1; i < stacks.size(); i++) {
				MElementContainer<MUIElement> stack = stacks.get(i); 
				if (stack == pstack) {
					continue;
				}
				join2Stacks(stacks.get(i), dropStack, null);
			}
			// lastly, join in the selected stack
			if (pstack != dropStack) {
				join2Stacks(pstack, dropStack, part);
			}
		} else {
			Beeper.beep();
		}
	}
}
 
Example #21
Source File: WindowJoinCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Close any duplicate editors in the supplied part stacks
 * 
 * @param stack1
 * @param stack2
 * @return true if any duplicates were closed
 */
boolean closeOthers(MElementContainer<MUIElement> stack1, 	MElementContainer<MUIElement> stack2) {
	boolean result = false;
	Collection<IEditorReference> editors = getStackEditors(stack1);
	editors.addAll(getStackEditors(stack2));
	try {
		result = IDeduplication.closeDuplicates(EmacsPlusUtils.getWorkbenchPage(), editors.toArray(new IEditorReference[editors.size()]));
	} catch (PartInitException e) {
		// Ignore
	}
	return result;
}
 
Example #22
Source File: WindowJoinCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Given 2 partStacks, move children of pstack into dropStack
 * @param pstack - source stack
 * @param dropStack - destination stack
 * @param apart - the initiating part
 * @return the enhanced dropStack
 */
protected MElementContainer<MUIElement> join2Stacks(MElementContainer<MUIElement> pstack, MElementContainer<MUIElement> dropStack, MPart apart) {
	if (dropStack != null && ((MPartSashContainerElement)dropStack) instanceof MPartStack) {
		List<MUIElement> eles = pstack.getChildren();
		boolean hasPart = apart != null;
		int offset = 1;
		List<MUIElement> drops = dropStack.getChildren();
		while (eles.size() > (hasPart ? 1 : 0)) {
			MUIElement ele = eles.get(eles.size() - offset);
			if (hasPart && ele == apart) {
				offset++;
				continue;
			}
			eles.remove(ele);
			if (hasPart) {
					drops.add(0,ele);
				} else {
					drops.add(ele);
				}
		}
		if (hasPart) {
			// Move the selected element to the leftmost position
			eles.remove(apart);
			drops.add(0,apart);
			dropStack.setSelectedElement(apart);
		}
		checkSizeData(pstack,dropStack);
	} 
	return dropStack;
}
 
Example #23
Source File: WindowJoinCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Check if containerData size needs updating.
 * This should be handled by the Eclipse framework, but apparently not...
 * @param pstack - source stack
 * @param dropStack - destination stack
 */
protected void checkSizeData(MElementContainer<MUIElement> pstack, MElementContainer<MUIElement> dropStack) {
	if (pstack.getParent().getContainerData() == null) {
		int s1 = getIntData(pstack);;
		if (dropStack.getParent().getContainerData() == null) {
			// stacks are vertically side by side, add their sizes together 
			dropStack.setContainerData(String.valueOf(s1 + getIntData(dropStack)));
		} else {
			// source is vertical & destination is in a horizontal containing PartSash
			dropStack.getParent().setContainerData(String.valueOf(s1 + getIntData(dropStack.getParent())));
		}
	}
}
 
Example #24
Source File: ElexisRendererFactory.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public AbstractPartRenderer getRenderer(MUIElement uiElement, Object parent){
	if (uiElement instanceof MPartStack) {
		if (stackRenderer == null) {
			stackRenderer = new ElexisStackRenderer();
			super.initRenderer(stackRenderer);
		}
		return stackRenderer;
	}
	return super.getRenderer(uiElement, parent);
}
 
Example #25
Source File: ElexisProcessor.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private void updateModelVersions(MApplication mApplication, EModelService eModelService){
	try {
		List<MWindow> windows = mApplication.getChildren();
		if (!windows.isEmpty() && windows.get(0) instanceof MTrimmedWindow) {
			MTrimmedWindow mWindow = (MTrimmedWindow) windows.get(0);
			// remove old model elements like perspectives etc
			for (String modelElementId : removeModelElements) {
				MUIElement element = eModelService.find(modelElementId, mApplication);
				if (element != null) {
					if (element instanceof MPerspective) {
						eModelService.removePerspectiveModel((MPerspective) element, mWindow);
						logger.info(
							"model element (perspective): " + modelElementId + " removed!");
					} else {
						MElementContainer<MUIElement> parent = element.getParent();
						parent.getChildren().remove(element);
						element.setToBeRendered(false);
						logger.info("model element: " + modelElementId + " removed!");
					}
				}
			}
		} else {
			logger.warn("cannot find active window");
		}
	} catch (Exception e) {
		logger.error("unexpected exception - cannot do updates on models", e);
	}
}
 
Example #26
Source File: E4WindowCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param ele start from here
 * @return the most distant parent for the editor area
 */
protected MElementContainer<MUIElement> getTopElement(MElementContainer<MUIElement> ele) {
	MElementContainer<MUIElement> parent = ele;
	// get the outer container
	if (parent != null) {
		while (!((Object)parent instanceof MArea) && parent.getParent() != null) {
				parent = parent.getParent();
		}
	}
	return parent;
}
 
Example #27
Source File: LayoutTreeConverter.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
String getWeight(final MUIElement element) {
	String data = element.getContainerData();
	final MUIElement parent = element.getParent();
	while (data == null && parent != null) {
		data = parent.getContainerData();
	}
	return data;
}
 
Example #28
Source File: PerspectiveHelper.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public static void showBottomTray(final WorkbenchWindow window, final Boolean show) {

		final MUIElement trimStatus = getTrimStatus(window);
		if ( trimStatus != null ) {
			// toggle statusbar visibility
			trimStatus.setVisible(show);
		}

	}
 
Example #29
Source File: SwitchPerspectiveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(EModelService modelService, EPartService partService,
		MWindow window,
		@Named("com.vogella.rcp.jface.translation.commandparameter.perspectiveid") String id) {
	MPerspective activePerspective = modelService
			.getActivePerspective(window);


	MUIElement find = modelService.find(id, window);
	if (find == null || activePerspective.equals(find)) {
		return;
	}

	partService.switchPerspective((MPerspective) find);
}
 
Example #30
Source File: RestorePerspectiveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(EModelService modelService, MWindow window, EPartService partService) {

	// get active perpective and find stored snippet of this perspective
	MPerspective activePerspective = modelService.getActivePerspective(window);
	MUIElement perspectiveSnippet = modelService.cloneSnippet(window, activePerspective.getElementId(), window);

	// remove existing active perspective
	MElementContainer<MUIElement> parent = activePerspective.getParent();
	modelService.removePerspectiveModel(activePerspective, window);

	// add stored perspective snippet and switch to it
	parent.getChildren().add(perspectiveSnippet);
	partService.switchPerspective((MPerspective) perspectiveSnippet);
}