2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * Created by IntelliJ IDEA.
23 package com
.intellij
.ide
.impl
;
25 import com
.intellij
.openapi
.actionSystem
.DataKey
;
26 import com
.intellij
.openapi
.actionSystem
.DataProvider
;
27 import com
.intellij
.openapi
.actionSystem
.DataSink
;
28 import com
.intellij
.openapi
.actionSystem
.TypeSafeDataProvider
;
29 import org
.jetbrains
.annotations
.NonNls
;
30 import org
.jetbrains
.annotations
.Nullable
;
32 public class TypeSafeDataProviderAdapter
implements DataProvider
, DataSink
{
33 private final TypeSafeDataProvider myProvider
;
34 private DataKey myLastKey
= null;
35 private Object myValue
= null;
37 public TypeSafeDataProviderAdapter(final TypeSafeDataProvider provider
) {
38 myProvider
= provider
;
42 synchronized public Object
getData(@NonNls String dataId
) {
44 myLastKey
= DataKey
.create(dataId
);
45 myProvider
.calcData(myLastKey
, this);
49 synchronized public <T
> void put(DataKey
<T
> key
, T data
) {
50 if (key
== myLastKey
) {
56 public String
toString() {
57 return super.toString()+'('+ myProvider
+ ')';