Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 2ee92887974825a5e4fd9a38fe319a6085cc294c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*******************************************************************************
 * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * CONTRIBUTORS:
 * 		Juergen Haug (initial contribution)
 * 
 *******************************************************************************/

package org.eclipse.etrice.ui.common.base.resource;

import java.io.IOException;
import java.util.Map;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
import org.eclipse.etrice.core.common.scoping.RelativeFileURIHandler;

import com.google.common.collect.Maps;

public class DiagramResource extends XMIResourceImpl {

	public DiagramResource() {
		super();
	}

	public DiagramResource(URI uri) {
		super(uri);
	}

	@Override
	public void load(Map<?, ?> options) throws IOException {
		// force RelativeFileURIHandler
		Map<Object, Object> optionsCopy = (options == null) ? getDefaultLoadOptions() : Maps.newHashMap(options);
		super.load(RelativeFileURIHandler.addToOptions(optionsCopy));
	}

	@Override
	public void save(Map<?, ?> options) throws IOException {
		// force RelativeFileURIHandler
		Map<Object, Object> optionsCopy = (options == null) ? getDefaultSaveOptions() : Maps.newHashMap(options);
		super.save(RelativeFileURIHandler.addToOptions(optionsCopy));
	}

	@Override
	public Map<Object, Object> getDefaultSaveOptions() {
		if (defaultSaveOptions == null) {
			return RelativeFileURIHandler.addToOptions(super.getDefaultLoadOptions());
		}

		return super.getDefaultSaveOptions();
	}

	@Override
	public Map<Object, Object> getDefaultLoadOptions() {
		if (defaultLoadOptions == null) { 
			return RelativeFileURIHandler.addToOptions(super.getDefaultLoadOptions());
		}

		return super.getDefaultLoadOptions();
	}
}

Back to the top