1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.charts.editor;
\r
14 import org.simantics.databoard.util.ObjectUtils;
\r
15 import org.simantics.db.Resource;
\r
16 import org.simantics.utils.datastructures.hints.HintContext;
\r
19 * @author Tuukka Lehtonen
\r
21 public class ChartKeys {
\r
24 * //@deprecated use {@link #chartSourceKey(Resource)} with model resource as argument instead
\r
27 //public static final Key KEY_ACTIVE_CHART_SOURCE = new HintContext.KeyOf(ChartData.class, "CHART_DATA");
\r
29 public static ChartSourceKey chartSourceKey(Resource model) {
\r
30 return new ChartSourceKey(model);
\r
34 * For having multiple different chart data sources. The sources are
\r
35 * identified by resources.
\r
37 public static class ChartSourceKey extends HintContext.KeyOf {
\r
39 private final Resource source;
\r
41 public ChartSourceKey(Resource source) {
\r
42 super(ChartData.class, "CHART_DATA(" + source.getResourceId() + ")");
\r
43 this.source = source;
\r
46 public Resource getResource() {
\r
51 public int hashCode() {
\r
52 return source != null ? source.hashCode() : 0;
\r
56 public boolean equals(Object obj) {
\r
59 if (!(obj instanceof ChartSourceKey))
\r
61 ChartSourceKey other = (ChartSourceKey) obj;
\r
62 return ObjectUtils.objectEquals(source, other.source);
\r
66 public String toString() {
\r
67 return getClass().getSimpleName() + "[" + source + "]";
\r