vcs: cleanup - remove TypeSafeDataProvider usage

This commit is contained in:
Aleksey Pivovarov
2016-11-18 11:49:34 +03:00
parent 1d44e648ca
commit dce9d29167
3 changed files with 14 additions and 66 deletions
@@ -15,11 +15,9 @@
*/
package com.intellij.openapi.diff.impl;
import com.intellij.ide.DataManager;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.actionSystem.DataSink;
import com.intellij.openapi.diff.*;
import com.intellij.openapi.vcs.AbstractDataProviderPanel;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
@@ -43,16 +41,9 @@ public class ErrorDiffViewer implements DiffViewer {
protected ErrorDiffViewer(Window window, @NotNull DiffRequest request) {
myRequest = request;
myPanel = new AbstractDataProviderPanel(new BorderLayout(), false) {
@Override
public void calcData(DataKey key, DataSink sink) {
final Object data = myRequest.getGenericData().get(key.getName());
if (data != null) {
sink.put(key, data);
}
}
};
myPanel = new JPanel(new BorderLayout());
myPanel.setFocusable(true);
DataManager.registerDataProvider(myPanel, dataId -> myRequest.getGenericData().get(dataId));
final ActionManager actionManager = ActionManager.getInstance();
myToolbar = new DiffToolbarComponent(myPanel);
@@ -1,48 +0,0 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.vcs;
import com.intellij.openapi.actionSystem.TypeSafeDataProvider;
import javax.swing.*;
import java.awt.*;
/**
* Created with IntelliJ IDEA.
* User: Irina.Chernushina
* Date: 9/14/12
* Time: 11:46 AM
*/
public abstract class AbstractDataProviderPanel extends JPanel implements TypeSafeDataProvider {
public AbstractDataProviderPanel(GridBagLayout layout) {
super(layout);
}
protected AbstractDataProviderPanel(LayoutManager layout, boolean isDoubleBuffered) {
super(layout, isDoubleBuffered);
}
protected AbstractDataProviderPanel(LayoutManager layout) {
super(layout);
}
protected AbstractDataProviderPanel(boolean isDoubleBuffered) {
super(isDoubleBuffered);
}
protected AbstractDataProviderPanel() {
}
}
@@ -26,10 +26,14 @@ import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.CommitMessageI;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.VcsConfiguration;
import com.intellij.openapi.vcs.VcsDataKeys;
import com.intellij.ui.*;
import com.intellij.util.Consumer;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -38,8 +42,7 @@ import java.awt.*;
import java.util.HashSet;
import java.util.Set;
public class CommitMessage extends AbstractDataProviderPanel implements Disposable, CommitMessageI {
public class CommitMessage extends JPanel implements Disposable, DataProvider, CommitMessageI {
public static final Key<DataContext> DATA_CONTEXT_KEY = Key.create("commit message data context");
private final EditorTextField myEditorField;
private Consumer<String> myMessageConsumer;
@@ -84,11 +87,13 @@ public class CommitMessage extends AbstractDataProviderPanel implements Disposab
setBorder(BorderFactory.createEmptyBorder());
}
@Nullable
@Override
public void calcData(DataKey key, DataSink sink) {
if (key.is(VcsDataKeys.COMMIT_MESSAGE_CONTROL.getName())) {
sink.put(VcsDataKeys.COMMIT_MESSAGE_CONTROL, this);
public Object getData(@NonNls String dataId) {
if (VcsDataKeys.COMMIT_MESSAGE_CONTROL.is(dataId)) {
return this;
}
return null;
}
public void setSeparatorText(final String text) {