mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
support frames
This commit is contained in:
@@ -34,6 +34,8 @@ public class DirDiffSettings {
|
||||
public boolean showCompareModes = true;
|
||||
public CompareMode compareMode = CompareMode.CONTENT;
|
||||
|
||||
public boolean showInFrame = true; // in dialog otherwise
|
||||
|
||||
private String filter = "";
|
||||
private Pattern filterPattern = PatternUtil.fromMask("*");
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class DirDiffDialog extends DialogWrapper {
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
myDiffPanel = new DirDiffPanel(myModel, this, mySettings);
|
||||
myDiffPanel = new DirDiffPanel(myModel, new DirDiffWindow(this), mySettings);
|
||||
Disposer.register(getDisposable(), myDiffPanel);
|
||||
return myDiffPanel.getPanel();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.diff.impl.dir;
|
||||
|
||||
import com.intellij.ide.diff.DirDiffSettings;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.FrameWrapper;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class DirDiffFrame extends FrameWrapper {
|
||||
private DirDiffPanel myPanel;
|
||||
|
||||
public DirDiffFrame(Project project, DirDiffTableModel model, DirDiffSettings settings) {
|
||||
super(project, "DirDiffDialog");
|
||||
setSize(new Dimension(800, 600));
|
||||
myPanel = new DirDiffPanel(model, new DirDiffWindow(this), settings);
|
||||
Disposer.register(this, myPanel);
|
||||
setComponent(myPanel.getPanel());
|
||||
setProject(project);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void loadFrameState() {
|
||||
super.loadFrameState();
|
||||
myPanel.setupSplitter();
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,11 @@ public class DirDiffManagerImpl extends DirDiffManager {
|
||||
@Override
|
||||
public void showDiff(@NotNull final DiffElement dir1, @NotNull final DiffElement dir2, final DirDiffSettings settings) {
|
||||
final DirDiffTableModel model = new DirDiffTableModel(myProject, dir1, dir2, settings);
|
||||
new DirDiffDialog(myProject, model, settings).show();
|
||||
if (settings.showInFrame) {
|
||||
new DirDiffFrame(myProject, model, settings).show();
|
||||
} else {
|
||||
new DirDiffDialog(myProject, model, settings).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.actionSystem.ActionToolbar;
|
||||
import com.intellij.openapi.diff.impl.dir.actions.DirDiffToolbarActions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
@@ -60,22 +61,22 @@ public class DirDiffPanel implements Disposable {
|
||||
private JTextField myFilter;
|
||||
private final DirDiffTableModel myModel;
|
||||
public JLabel myErrorLabel;
|
||||
private final DirDiffDialog myDialog;
|
||||
private final DirDiffWindow myDiffWindow;
|
||||
private JComponent myDiffPanelComponent;
|
||||
private JComponent myViewComponent;
|
||||
private DiffElement myCurrentElement;
|
||||
private String oldFilter;
|
||||
|
||||
public DirDiffPanel(DirDiffTableModel model, DirDiffDialog dirDiffDialog, DirDiffSettings settings) {
|
||||
public DirDiffPanel(DirDiffTableModel model, DirDiffWindow wnd, DirDiffSettings settings) {
|
||||
myModel = model;
|
||||
myDialog = dirDiffDialog;
|
||||
myDiffWindow = wnd;
|
||||
mySourceDirField.setText(model.getSourceDir().getPath());
|
||||
myTargetDirField.setText(model.getTargetDir().getPath());
|
||||
mySourceDirLabel.setIcon(model.getSourceDir().getIcon());
|
||||
myTargetDirLabel.setIcon(model.getTargetDir().getIcon());
|
||||
myModel.setTable(myTable);
|
||||
myModel.setPanel(this);
|
||||
myModel.setDisposableParent(dirDiffDialog.getDisposable());
|
||||
Disposer.register(this, myModel);
|
||||
myTable.setModel(myModel);
|
||||
|
||||
final DirDiffTableCellRenderer renderer = new DirDiffTableCellRenderer(myTable);
|
||||
@@ -102,7 +103,7 @@ public class DirDiffPanel implements Disposable {
|
||||
}
|
||||
clearDiffPanel();
|
||||
if (element.getType() == DType.CHANGED) {
|
||||
myDiffPanelComponent = element.getSource().getDiffComponent(element.getTarget(), project, myDialog.getWindow());
|
||||
myDiffPanelComponent = element.getSource().getDiffComponent(element.getTarget(), project, myDiffWindow.getWindow());
|
||||
if (myDiffPanelComponent != null) {
|
||||
myDiffPanel.add(myDiffPanelComponent, BorderLayout.CENTER);
|
||||
myCurrentElement = element.getSource();
|
||||
@@ -134,7 +135,7 @@ public class DirDiffPanel implements Disposable {
|
||||
}
|
||||
}
|
||||
}
|
||||
myDialog.setTitle(myModel.getTitle());
|
||||
myDiffWindow.setTitle(myModel.getTitle());
|
||||
}
|
||||
});
|
||||
myTable.addKeyListener(new KeyAdapter() {
|
||||
@@ -150,14 +151,16 @@ public class DirDiffPanel implements Disposable {
|
||||
if (element.isSeparator()) {
|
||||
row++;
|
||||
}
|
||||
} else if (keyCode == KeyEvent.VK_UP && row != 0) {
|
||||
}
|
||||
else if (keyCode == KeyEvent.VK_UP && row != 0) {
|
||||
row--;
|
||||
final DirDiffElement element = myModel.getElementAt(row);
|
||||
if (element == null) return;
|
||||
if (element.isSeparator()) {
|
||||
row--;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
final DirDiffElement element = myModel.getElementAt(row);
|
||||
@@ -185,9 +188,9 @@ public class DirDiffPanel implements Disposable {
|
||||
}
|
||||
final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("DirDiff", new DirDiffToolbarActions(myModel), true);
|
||||
myToolBarPanel.add(toolbar.getComponent(), BorderLayout.CENTER);
|
||||
final JBLoadingPanel loadingPanel = new JBLoadingPanel(new BorderLayout(), dirDiffDialog.getDisposable());
|
||||
final JBLoadingPanel loadingPanel = new JBLoadingPanel(new BorderLayout(), wnd.getDisposable());
|
||||
loadingPanel.add(myComponent, BorderLayout.CENTER);
|
||||
//final LoadingDecorator decorator = new LoadingDecorator(myComponent, dirDiffDialog.getDisposable(), -1) {
|
||||
//final LoadingDecorator decorator = new LoadingDecorator(myComponent, wnd.getDisposable(), -1) {
|
||||
// @Override
|
||||
// protected NonOpaquePanel customizeLoadingLayer(JPanel parent, JLabel text, AsyncProcessIcon icon) {
|
||||
// final NonOpaquePanel panel = super.customizeLoadingLayer(parent, text, icon);
|
||||
|
||||
@@ -49,7 +49,6 @@ public class DirDiffTableModel extends AbstractTableModel implements Disposable
|
||||
private final List<DirDiffElement> myElements = new ArrayList<DirDiffElement>();
|
||||
private final AtomicBoolean myUpdating = new AtomicBoolean(false);
|
||||
private JBTable myTable;
|
||||
private Disposable myDisposableParent;
|
||||
public String DECORATOR = "DIFF_TABLE_DECORATOR";
|
||||
public volatile AtomicReference<String> text = new AtomicReference<String>(prepareText(""));
|
||||
private Updater updater;
|
||||
@@ -264,10 +263,6 @@ public class DirDiffTableModel extends AbstractTableModel implements Disposable
|
||||
}
|
||||
}
|
||||
|
||||
public void setDisposableParent(Disposable parent) {
|
||||
myDisposableParent = parent;
|
||||
}
|
||||
|
||||
private void scan(DiffElement element, DTree root, boolean source) {
|
||||
if (!myUpdating.get()) return;
|
||||
if (element.isContainer()) {
|
||||
@@ -284,7 +279,7 @@ public class DirDiffTableModel extends AbstractTableModel implements Disposable
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return "Diff for " + mySrc.getPresentablePath() + " and " + myTrg.getPresentablePath();
|
||||
return "Diff between " + mySrc.getPresentablePath() + " and " + myTrg.getPresentablePath();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.diff.impl.dir;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class DirDiffWindow {
|
||||
private final DirDiffDialog myDialog;
|
||||
private final DirDiffFrame myFrame;
|
||||
|
||||
public DirDiffWindow(DirDiffDialog dialog) {
|
||||
myDialog = dialog;
|
||||
myFrame = null;
|
||||
}
|
||||
|
||||
public DirDiffWindow(DirDiffFrame frame) {
|
||||
myFrame = frame;
|
||||
myDialog = null;
|
||||
}
|
||||
|
||||
public Window getWindow() {
|
||||
return myDialog == null ? myFrame.getFrame() : myDialog.getWindow();
|
||||
}
|
||||
|
||||
public Disposable getDisposable() {
|
||||
return myDialog == null ? myFrame : myDialog.getDisposable();
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
if (myDialog == null) {
|
||||
myFrame.getFrame().setTitle(title);
|
||||
} else {
|
||||
myDialog.setTitle(title);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user