org.eclipse.e4.ui.model.application.ui.basic.MWindow Java Examples

The following examples show how to use org.eclipse.e4.ui.model.application.ui.basic.MWindow. 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: PerspectiveImportService.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
private MPerspectiveStack getPerspectiveStack(){
	EModelService modelService = getService(EModelService.class);
	MWindow window = getActiveWindow();
	List<MPerspectiveStack> theStack =
		modelService.findElements(window, null, MPerspectiveStack.class, null);
	if (theStack.size() > 0) {
		return theStack.get(0);
	}
	
	for (MWindowElement child : window.getChildren()) {
		if (child instanceof MPerspectiveStack) {
			return (MPerspectiveStack) child;
		}
	}
	return null;
}
 
Example #2
Source File: InitialPerspectiveStorageAddon.java    From codeexamples-eclipse with Eclipse Public License 1.0 6 votes vote down vote up
@Inject
@Optional
public void selectedElement(@EventTopic(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT) Event event, EModelService modelService) {
	if (!UIEvents.isSET(event)) {
		return;
	}

	Object newlySelectedPerspective = event.getProperty(EventTags.NEW_VALUE);
	if (newlySelectedPerspective instanceof MPerspective) {
		MPerspective perspectiveToBeCloned = (MPerspective) newlySelectedPerspective;

		MWindow topLevelWindow = modelService.getTopLevelWindowFor(perspectiveToBeCloned);
		
		// try to find already existing snippet
		if (null == modelService.findSnippet(topLevelWindow, perspectiveToBeCloned.getElementId())) {
			// clone perspective in case there is no snippet yet
			modelService.cloneElement(perspectiveToBeCloned, topLevelWindow);
		}
	}
}
 
Example #3
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 #4
Source File: E4WindowCmd.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Get the list of detached windows, if any
 * 
 * NB: The docs don't guarantee a non-null return, but the implementation seems to
 * Nor do they guarantee an order, but the implementation currently returns the same order
 * @return the list of detached windows 
 */
List<MTrimmedWindow> getDetachedFrames() {
	final MWindow topWindow = application.getChildren().get(0); 
	// NB Selectors aren't supported until Luna
	//		final Selector match = new Selector() {
	//			public boolean select(MApplicationElement element) {
	//				boolean result = element != topWindow && ((MTrimmedWindow)element).isToBeRendered();
	//				return result && !modelService.findElements((MUIElement)element, null, MPart.class, EDITOR_TAG, EModelService.IN_ANY_PERSPECTIVE).isEmpty();
	//			}
	//		};
	//		List<MTrimmedWindow> mts = modelService.findElements(topWindow, MTrimmedWindow.class, EModelService.IN_ANY_PERSPECTIVE, match); 
	// get the all detached editor trimmed windows
	// the implementation searches all detached windows in this case
	List<MTrimmedWindow> mts = modelService.findElements(topWindow, null, MTrimmedWindow.class, null, EModelService.IN_ANY_PERSPECTIVE); 
	List<MTrimmedWindow> refined = new ArrayList<MTrimmedWindow>();
	for (MTrimmedWindow mt : mts) {
		if (mt != topWindow && mt.isToBeRendered() && !modelService.findElements(mt, null, MPart.class, EDITOR_TAG, EModelService.IN_ANY_PERSPECTIVE).isEmpty()) {
			refined.add(mt);
		}
	}
	return refined; 
}
 
Example #5
Source File: SwitchToBufferFrameCmd.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
@Execute
public Object execute(@Active MWindow window, @Active MPart apart, @Active IEditorPart editor, @Active EmacsPlusCmdHandler handler, @Named(E4CmdHandler.CMD_CTX_KEY)boolean display, @Named(E4CmdHandler.PRE_CTX_KEY) String prefix) {
	this.window = window;
	this.handler = handler;
	this.apart = apart;
	this.displayOnly = display;
	this.prefix = prefix;
	try {
		ITextEditor ted = EmacsPlusUtils.getTextEditor(editor, true);
		if (ted != null) {
			MinibufferHandler.bufferTransform(new SwitchMinibuffer(this, true), ted, null);
		}
	} catch (BadLocationException e) {
		// Shouldn't happen
		Beeper.beep();
	}		
	return null;
}
 
Example #6
Source File: BonitaStudioWorkbenchWindowAdvisor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Register to selection service to update button enablement
 * Register the Automatic Perspective switch part listener
 */
@Override
public void postWindowOpen() {
    IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
    configurer.addEditorAreaTransfer(EditorInputTransfer.getInstance());
    configurer.addEditorAreaTransfer(ResourceTransfer.getInstance());
    configurer.addEditorAreaTransfer(FileTransfer.getInstance());
    configurer.addEditorAreaTransfer(MarkerTransfer.getInstance());
    configurer.configureEditorAreaDropListener(new EditorAreaDropAdapter(
            configurer.getWindow()));

    final MWindow model = ((WorkbenchPage) window.getActivePage()).getWindowModel();
    model.getContext().get(EPartService.class).addPartListener(new AutomaticSwitchPerspectivePartListener());
    final Object widget = model.getWidget();
    if (widget instanceof Shell) {
        ((Widget) widget).setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_MAIN_SHELL);
    }
    // Replace ObjectActionContributorManager with filtered actions
    CustomObjectActionContributorManager.getManager();
}
 
Example #7
Source File: FrameOtherCmd.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
@Execute
public Object execute(@Active MWindow apart, @Active IEditorPart editor, @Active EmacsPlusCmdHandler handler) {
	// This assumes that getDatchedFrames returns them in order
	List<MTrimmedWindow> frames = getDetachedFrames();
	if (frames != null && !frames.isEmpty()) {
		int size = frames.size()+1;
		int count = handler.getUniversalCount();
		int index = frames.indexOf(apart) + (count % size) + 1;
		index = (index < 0 ? index + size : (index < size) ? index : index - size);
		if (index == 0) {
			// just make the main window first in line
			focusIt(getEditArea(application.getChildren().get(0)));
		} else {
			focusIt(frames.get(--index));
		}
	}
	return null;
}
 
Example #8
Source File: QuitHandlerAddon.java    From offspring with MIT License 5 votes vote down vote up
@Override
public void handleEvent(final Event inEvent) {
  if (!UIEvents.isSET(inEvent)) {
    return;
  }
  final Object lElement = inEvent.getProperty(UIEvents.EventTags.ELEMENT);
  if (!(lElement instanceof MWindow)) {
    return;
  }
  final MWindow lWindow = (MWindow) lElement;
  if ("com.dgex.offspring.application.mainwindow".equals(lWindow
      .getElementId())) {
    logger.trace(UIEvents.Context.TOPIC_CONTEXT);
    if (lWindow.equals(inEvent.getProperty("ChangedElement"))
        && lWindow.getContext() != null) {
      lWindow.getContext().runAndTrack(new RunAndTrack() {

        @Override
        public boolean changed(final IEclipseContext inContext) {
          final Object lHandler = inContext.get(IWindowCloseHandler.class);
          if (!quitHandler.equals(lHandler)) {
            inContext.set(IWindowCloseHandler.class, quitHandler);
          }
          return true;
        }
      });
    }
  }
}
 
Example #9
Source File: PerspectiveImportService.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public MTrimmedWindow getActiveWindow(){
	EModelService modelService = getService(EModelService.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);
		}
	}
	return mWindow;
}
 
Example #10
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 #11
Source File: PerspectiveUtil.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public static MTrimmedWindow getActiveWindow(){
	EModelService modelService = getService(EModelService.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);
		}
	}
	return mWindow;
}
 
Example #12
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 #13
Source File: ElexisFastViewUtil.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private static MTrimmedWindow getCurrentWindow(EModelService eModelService,
	MApplication mApplication){
	MTrimmedWindow window = (MTrimmedWindow) eModelService.find("IDEWindow", mApplication);
	if (window == null) {
		List<MWindow> windows = mApplication.getChildren();
		if (!windows.isEmpty() && windows.get(0) instanceof MTrimmedWindow) {
			window = (MTrimmedWindow) windows.get(0);
		}
	}
	return window;
}
 
Example #14
Source File: SmallCoolBarHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	MWindow model = ((WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow()).getModel();
	EModelService modelService = model.getContext().get(EModelService.class);
	MToolControl bonitaCoolBar = (MToolControl) modelService.find(
			"BonitaCoolbar", model);
	if(bonitaCoolBar != null){
		CoolbarToolControl coolbarControl = (CoolbarToolControl) bonitaCoolBar.getObject();
		coolbarControl.minimizeCoolbar();
	}
	return null;
}
 
Example #15
Source File: NormalCoolBarHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	MWindow model = ((WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow()).getModel();
	EModelService modelService = model.getContext().get(EModelService.class);
	MToolControl bonitaCoolBar = (MToolControl) modelService.find(
			"BonitaCoolbar", model);
	if(bonitaCoolBar != null){
		CoolbarToolControl coolbarControl = (CoolbarToolControl) bonitaCoolBar.getObject();
		coolbarControl.maximizeCoolbar();
	}
	return null;
}
 
Example #16
Source File: AutomaticSwitchPerspectivePartListener.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected String getActivePerspectiveId(final MPart part) {
    if (part != null && part.getContext() != null) {
        final EModelService service = part.getContext().get(EModelService.class);
        final MWindow window = service.getTopLevelWindowFor(part);
        String activePerspective = null;
        final MPerspective selectedElement = service.getActivePerspective(window);
        if (selectedElement != null) {
            activePerspective = selectedElement.getElementId();
        }
        return activePerspective;
    }
    return null;
}
 
Example #17
Source File: EmbeddedEditorSite.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Shell getShell() {
    // Compatibility: This method should not be used outside the UI
    // thread... but since this condition
    // was not always in the JavaDoc, we still try to return our best guess
    // about the shell if it is
    // called from the wrong thread.
    Display currentDisplay = Display.getCurrent();
    if (currentDisplay == null) {
        // Uncomment this to locate places that try to access the shell from
        // a background thread
        // WorkbenchPlugin.log(new Exception("Error:
        // IWorkbenchSite.getShell() was called outside the UI thread. Fix
        // this code.")); //$NON-NLS-1$

        return getWorkbenchWindow().getShell();
    }

    Control control = (Control) getMWindow().getWidget();
    if (control != null && !control.isDisposed()) {
        return control.getShell();
    }
    // likely means the part has been destroyed, return the parent window's
    // shell, we don't just arbitrarily return the workbench window's shell
    // because we may be in a detached window
    MWindow window = e4Context.get(MWindow.class);
    return window == null ? getWorkbenchWindow().getShell() : (Shell) window.getWidget();
}
 
Example #18
Source File: DummyEditorSite.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Shell getShell() {

    // Compatibility: This method should not be used outside the UI
    // thread... but since this condition
    // was not always in the JavaDoc, we still try to return our best guess
    // about the shell if it is
    // called from the wrong thread.
    final Display currentDisplay = Display.getCurrent();
    if (currentDisplay == null) {
        // Uncomment this to locate places that try to access the shell from
        // a background thread
        // WorkbenchPlugin.log(new Exception("Error:
        // IWorkbenchSite.getShell() was called outside the UI thread. Fix
        // this code.")); //$NON-NLS-1$

        final IWorkbenchWindow workbenchWindow = getWorkbenchWindow();
        if (workbenchWindow != null) {
            return workbenchWindow.getShell();
        }
        return null;
    }
    IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    MWindow window = null;
    if (activeWorkbenchWindow != null) {
        window = ((WorkbenchWindow) activeWorkbenchWindow).getModel();
        final Control control = (Control) window.getWidget();
        if (control != null && !control.isDisposed()) {
            return control.getShell();
        }
    }
    // likely means the part has been destroyed, return the parent window's
    // shell, we don't just arbitrarily return the workbench window's shell
    // because we may be in a detached window
    return window == null ? getWorkbenchWindow().getShell() : (Shell) window.getWidget();
}
 
Example #19
Source File: ApplicationConfiguration.java    From warcraft-remake with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Execute the injection.
 * 
 * @param eventBroker The event broker service.
 */
@PostConstruct
public void execute(IEventBroker eventBroker)
{
    final MWindow existingWindow = application.getChildren().get(0);
    existingWindow.setLabel(Activator.PLUGIN_NAME);
    eventBroker.subscribe(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE, new AppStartupCompleteEventHandler());
}
 
Example #20
Source File: WindowDeclOtherCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public Object execute(@Active MPart apart, @Active IEditorPart editor, @Active MWindow mwin, @Active EmacsPlusCmdHandler handler) {

	try {
		this.apart = apart;
		this.handler = handler;
		Command ex = getOpenCmd(editor);
		if (ex != null) {
			MUIElement area = getEditArea(application.getChildren().get(0));
			MUIElement osel = getSelected(area);
			EmacsPlusUtils.executeCommand(ex.getId(), null);
			MUIElement sel = getSelected(area);
			// see if it was able to open a declaration
			if (sel instanceof MPart && sel != apart && sel != osel) {
				// another way of determining if we're main or frame
				if (!mwin.getTags().contains(TOP_TAG) && !handler.isUniversalPresent()) {
					// If they're in different frames, move copy to source frame first
					modelService.move(sel, getParentStack(apart).getStack(), 0);
				};
				switchTo((MPart)sel);
			}
		}
	} catch (Exception e) {
		// Shouldn't happen
		Beeper.beep();
	}
	return null;
}
 
Example #21
Source File: RestorePerspectiveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@CanExecute
public boolean canExecute(EModelService modelService, MWindow window) {

	// check whether a snippet for the active perspective exists
	MPerspective activePerspective = modelService.getActivePerspective(window);
	return modelService.findSnippet(window, activePerspective.getElementId()) != null;
}
 
Example #22
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);
}
 
Example #23
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 #24
Source File: SavePerspectiveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(EModelService modelService, MWindow window) {

	// clone the currently active perspective
	MPerspective activePerspective = modelService
			.getActivePerspective(window);
	modelService.cloneElement(activePerspective, window);
}
 
Example #25
Source File: QuitHandlerAddon.java    From offspring with MIT License 5 votes vote down vote up
@Override
public boolean close(final MWindow inWindow) {
  logger.trace("IWindowCloseHandler.close");

  return Shutdown
      .execute(display.getActiveShell(), broker, sync, nxt, pool);
}
 
Example #26
Source File: EmbeddedEditorSite.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected static MWindow getMWindow() {
    Workbench workbench = (Workbench) PlatformUI.getWorkbench();
    WorkbenchWindow activeWorkbenchWindow = (WorkbenchWindow) workbench.getActiveWorkbenchWindow();
    return activeWorkbenchWindow.getModel();
}
 
Example #27
Source File: SwitchToBufferFrameCmd.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
private boolean alreadyFramed(MWindow partWindow, List<MTrimmedWindow> frames) {
	// NB: This differs from emacs behavior, but seems much more useful in Eclipse
	// as it allows easily adding a buffer to a frame's stack.
	// buffer is in a frame, and command comes from main window
	return frames.contains(partWindow) && !frames.contains(window);
}
 
Example #28
Source File: CoolbarToolControl.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected MTrimBar getTrimBar(final IEclipseContext context, final String trimBarId) {
    final EModelService modelService = context.get(EModelService.class);
    final MWindow window = context.get(MWindow.class);
    final MTrimBar topTrim = (MTrimBar) modelService.find(trimBarId, window);
    return topTrim;
}
 
Example #29
Source File: PerspectiveExportService.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
@SuppressWarnings("restriction")
@Override
public void exportPerspective(String pathToExport, String newCode, String newLabel)
	throws IOException{
	
	try (OutputStream outputStream = new FileOutputStream(pathToExport)) {
		EModelService modelService = getService(EModelService.class);
		
		MApplication mApplication = getService(MApplication.class);
		MTrimmedWindow window = (MTrimmedWindow) modelService.find("IDEWindow", mApplication);
		if (window == null) {
			List<MWindow> windows = mApplication.getChildren();
			if (!windows.isEmpty() && windows.get(0) instanceof MTrimmedWindow) {
				window = (MTrimmedWindow) windows.get(0);
			}
		}
		
		// store model of the active perspective
		MPerspective activePerspective = modelService.getActivePerspective(window);
		
		// create a resource, which is able to store e4 model elements
		E4XMIResourceFactory e4xmiResourceFactory = new E4XMIResourceFactory();
		Resource resource = e4xmiResourceFactory.createResource(null);
		
		//clone the perspective and replace the placeholder ref with element ids of their content
		MPerspective clone = clonePerspectiveWithWorkaround(modelService, activePerspective);
		
		if (newLabel != null) {
			clone.setLabel(newLabel);
		}
		
		if (newCode != null) {
			clone.setElementId(newCode);
		}
		
		List<MPlaceholder> placeholderClones = modelService.findElements(clone, null,
			MPlaceholder.class, null, EModelService.IN_ANY_PERSPECTIVE);
		for (MPlaceholder placeholder : placeholderClones) {
			/* MUIElement ref = placeholder.getRef();
			if placeholder elementid is not the view id then use tags
			if (ref != null && !placeholder.getTags().contains(ref.getElementId())) {
				placeholder.getTags().add(0, ref.getElementId());
			}*/
			placeholder.setRef(null);
		}
		
		ElexisFastViewUtil.transferFastViewPersistedState(window, clone);
		
		// add the cloned model element to the resource so that it may be stored
		resource.getContents().add((EObject) clone);
		
		resource.save(outputStream, null);
	}
}