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