Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » refrash underlying diagrammodel(How can I programaticaly refrash my model)
refrash underlying diagrammodel [message #672212] Fri, 20 May 2011 10:42 Go to next message
AlexejS Mising name is currently offline AlexejS Mising nameFriend
Messages: 25
Registered: May 2010
Junior Member
Hi, when I add Elements to my diagramm my model is synchronized with my diagramfile until I don't open a sub diagram and add there new elemnts.

The model of my basediagram don't recognize changes in my subdiagram and don't update itself.

My question: How can I programaticaly update my model for example out of my file.

Something like it is done by open whole editor in:



protected void setDocumentContent(IDocument document, IEditorInput element)
			throws CoreException {
		IDiagramDocument diagramDocument = (IDiagramDocument) document;
		TransactionalEditingDomain domain = diagramDocument.getEditingDomain();
		if (element instanceof URIEditorInput) {
			URI uri = ((URIEditorInput) element).getURI();
			Resource resource = null;
			try {
				resource = domain.getResourceSet().getResource(
						uri.trimFragment(), false);
				if (resource == null) {
					resource = domain.getResourceSet().createResource(
							uri.trimFragment());
				}
				if (!resource.isLoaded()) {
					try {
						Map options = new HashMap(GMFResourceFactory
								.getDefaultLoadOptions());
						// @see 171060 
						// options.put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
						resource.load(options);
					} catch (IOException e) {
						resource.unload();
						throw e;
					}
				}
				if (uri.fragment() != null) {
					EObject rootElement = resource.getEObject(uri.fragment());
					if (rootElement instanceof Diagram) {
						document.setContent((Diagram) rootElement);
						return;
					}
				} else {
					for (Iterator it = resource.getContents().iterator(); it
							.hasNext();) {
						Object rootElement = it.next();
						if (rootElement instanceof Diagram) {
							document.setContent((Diagram) rootElement);
							return;
						}
					}
				}
				throw new RuntimeException(
						Messages.PetrinetsModelDocumentProvider_NoDiagramInResourceError);
			} catch (Exception e) {
				CoreException thrownExcp = null;
				if (e instanceof CoreException) {
					thrownExcp = (CoreException) e;
				} else {
					String msg = e.getLocalizedMessage();
					thrownExcp = new CoreException(
							new Status(
									IStatus.ERROR,
									PetrinetsModelDiagramEditorPlugin.ID,
									0,
									msg != null ? msg
											: Messages.PetrinetsModelDocumentProvider_DiagramLoadingError,
									e));
				}
				throw thrownExcp;
			}
		} else {
			throw new CoreException(
					new Status(
							IStatus.ERROR,
							PetrinetsModelDiagramEditorPlugin.ID,
							0,
							NLS
									.bind(
											Messages.PetrinetsModelDocumentProvider_IncorrectInputError,
											new Object[] { element,
													"org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ 
							null));
		}
	}


Re: refrash underlying diagrammodel [message #672251 is a reply to message #672212] Fri, 20 May 2011 12:56 Go to previous message
AlexejS Mising name is currently offline AlexejS Mising nameFriend
Messages: 25
Registered: May 2010
Junior Member
Hi, everything solved - it was my error.
I created a singleton which had everytime an old ModelImpl without refrashing a new one by me. Thx Smile
Previous Topic:Contributing my own "SAVE" Action
Next Topic:Delete doen't work
Goto Forum:
  


Current Time: Sun Dec 01 20:39:08 GMT 2024

Powered by FUDForum. Page generated in 0.03080 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top