mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -277,6 +277,7 @@ public class ClassesTable extends JBTable implements DataProvider, Disposable {
|
||||
public void clean() {
|
||||
if (!myItems.isEmpty()) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
clearSelection();
|
||||
myItems = Collections.emptyList();
|
||||
myCounts.clear();
|
||||
getRowSorter().allRowsChanged();
|
||||
|
||||
@@ -15,14 +15,26 @@
|
||||
*/
|
||||
package com.intellij.debugger.settings;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserFactory;
|
||||
import com.intellij.openapi.fileChooser.FileSaverDescriptor;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.ui.AnActionButton;
|
||||
import com.intellij.ui.AnActionButtonRunnable;
|
||||
import com.intellij.ui.TableUtil;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileWrapper;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.ui.ItemRemovable;
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -55,28 +67,101 @@ public class CaptureConfigurable implements SearchableConfigurable {
|
||||
TableColumnModel columnModel = table.getColumnModel();
|
||||
TableUtil.setupCheckboxColumn(columnModel.getColumn(MyTableModel.ENABLED_COLUMN));
|
||||
|
||||
return ToolbarDecorator.createDecorator(table)
|
||||
.setAddAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
myTableModel.addRow();
|
||||
ToolbarDecorator decorator = ToolbarDecorator.createDecorator(table);
|
||||
decorator.setAddAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
myTableModel.addRow();
|
||||
}
|
||||
});
|
||||
decorator.setRemoveAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
TableUtil.removeSelectedItems(table);
|
||||
}
|
||||
});
|
||||
decorator.setMoveUpAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
TableUtil.moveSelectedItemsUp(table);
|
||||
}
|
||||
});
|
||||
decorator.setMoveDownAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
TableUtil.moveSelectedItemsDown(table);
|
||||
}
|
||||
});
|
||||
|
||||
decorator.addExtraAction(new DumbAwareActionButton("Import", "Import", AllIcons.Actions.Install) {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull final AnActionEvent e) {
|
||||
FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, true, false, true, false) {
|
||||
@Override
|
||||
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
|
||||
return super.isFileVisible(file, showHiddenFiles) &&
|
||||
(file.isDirectory() || "xml".equals(file.getExtension()) || file.getFileType() == FileTypes.ARCHIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileSelectable(VirtualFile file) {
|
||||
return file.getFileType() == StdFileTypes.XML;
|
||||
}
|
||||
};
|
||||
descriptor.setDescription("Please select a file to import.");
|
||||
descriptor.setTitle("Import Capture Points");
|
||||
|
||||
VirtualFile file = FileChooser.chooseFile(descriptor, e.getProject(), null);
|
||||
if (file == null) return;
|
||||
try {
|
||||
Document document = JDOMUtil.loadDocument(file.getInputStream());
|
||||
table.getSelectionModel().clearSelection();
|
||||
int start = table.getRowCount();
|
||||
List<Element> children = document.getRootElement().getChildren();
|
||||
children.forEach(element -> myTableModel.add(XmlSerializer.deserialize(element, CapturePoint.class)));
|
||||
table.getSelectionModel().addSelectionInterval(start, table.getRowCount() - 1);
|
||||
}
|
||||
}).setRemoveAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
TableUtil.removeSelectedItems(table);
|
||||
catch (Exception ex) {
|
||||
final String msg = ex.getLocalizedMessage();
|
||||
Messages.showErrorDialog(e.getProject(), msg != null && msg.length() > 0 ? msg : ex.toString(), "Export Failed");
|
||||
}
|
||||
}).setMoveUpAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
TableUtil.moveSelectedItemsUp(table);
|
||||
}
|
||||
});
|
||||
decorator.addExtraAction(new DumbAwareActionButton("Export", "Export", AllIcons.Actions.Export) {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull final AnActionEvent e) {
|
||||
VirtualFileWrapper wrapper = FileChooserFactory.getInstance()
|
||||
.createSaveFileDialog(new FileSaverDescriptor("Export Selected Capture Points to File...", "", "xml"), e.getProject())
|
||||
.save(null, null);
|
||||
if (wrapper == null) return;
|
||||
|
||||
Element rootElement = new Element("capture-points");
|
||||
for (int row : table.getSelectedRows()) {
|
||||
CapturePoint c = myTableModel.get(table.convertRowIndexToModel(row));
|
||||
try {
|
||||
CapturePoint clone = c.clone();
|
||||
clone.myEnabled = false;
|
||||
rootElement.addContent(XmlSerializer.serialize(clone));
|
||||
}
|
||||
catch (CloneNotSupportedException ignore) {
|
||||
}
|
||||
}
|
||||
}).setMoveDownAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
TableUtil.moveSelectedItemsDown(table);
|
||||
try {
|
||||
JDOMUtil.writeDocument(new Document(rootElement), wrapper.getFile(), "\n");
|
||||
}
|
||||
}).createPanel();
|
||||
catch (Exception ex) {
|
||||
final String msg = ex.getLocalizedMessage();
|
||||
Messages.showErrorDialog(e.getProject(), msg != null && msg.length() > 0 ? msg : ex.toString(), "Export Failed");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return table.getSelectedRowCount() > 0;
|
||||
}
|
||||
});
|
||||
|
||||
return decorator.createPanel();
|
||||
}
|
||||
|
||||
private static class MyTableModel extends AbstractTableModel implements ItemRemovable {
|
||||
@@ -167,17 +252,23 @@ public class CaptureConfigurable implements SearchableConfigurable {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
public void addRow() {
|
||||
myCapturePoints.add(new CapturePoint());
|
||||
CapturePoint get(int idx) {
|
||||
return myCapturePoints.get(idx);
|
||||
}
|
||||
|
||||
public void add(CapturePoint p) {
|
||||
myCapturePoints.add(p);
|
||||
int lastRow = getRowCount() - 1;
|
||||
fireTableRowsInserted(lastRow, lastRow);
|
||||
}
|
||||
|
||||
public void addRow() {
|
||||
add(new CapturePoint());
|
||||
}
|
||||
|
||||
public void removeRow(final int row) {
|
||||
if (row >= 0 && row < getRowCount()) {
|
||||
myCapturePoints.remove(row);
|
||||
fireTableRowsDeleted(row, row);
|
||||
}
|
||||
myCapturePoints.remove(row);
|
||||
fireTableRowsDeleted(row, row);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,10 +72,7 @@ import com.intellij.usages.impl.UsagePreviewPanel;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBFont;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.*;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -173,17 +170,26 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
myBalloon = builder
|
||||
.setProject(myHelper.getProject())
|
||||
.setResizable(true)
|
||||
.setMovable(true)
|
||||
.setMinSize(new JBDimension(670, 240))
|
||||
.setMayBeParent(true)
|
||||
.setModalContext(false)
|
||||
.setRequestFocus(true)
|
||||
.setCancelCallback(() -> {
|
||||
DimensionService.getInstance().setSize(SIZE_KEY, myBalloon.getSize(), myHelper.getProject() );
|
||||
DimensionService.getInstance().setLocation(SIZE_KEY, myBalloon.getLocationOnScreen(), myHelper.getProject() );
|
||||
return Boolean.TRUE;
|
||||
})
|
||||
.createPopup();
|
||||
Disposer.register(myBalloon, myDisposable);
|
||||
registerCloseAction(myBalloon);
|
||||
final Window window = WindowManager.getInstance().suggestParentWindow(myProject);
|
||||
Component parent = UIUtil.findUltimateParent(window);
|
||||
RelativePoint showPoint = null;
|
||||
if (parent != null) {
|
||||
Point screenPoint = DimensionService.getInstance().getLocation(SIZE_KEY);
|
||||
if (screenPoint != null) {
|
||||
showPoint = new RelativePoint(screenPoint);
|
||||
}
|
||||
if (parent != null && showPoint == null) {
|
||||
int height = UISettings.getInstance().getShowNavigationBar() ? 135 : 115;
|
||||
if (parent instanceof IdeFrameImpl && ((IdeFrameImpl)parent).isInFullScreen()) {
|
||||
height -= 20;
|
||||
@@ -196,7 +202,14 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
} else {
|
||||
myBalloon.showCenteredInCurrentWindow(myProject);
|
||||
}
|
||||
WindowMoveListener windowListener = new WindowMoveListener(this);
|
||||
myTitleLabel.addMouseListener(windowListener);
|
||||
myTitleLabel.addMouseMotionListener(windowListener);
|
||||
myBalloon.pack(true, true);
|
||||
Dimension panelSize = getPreferredSize();
|
||||
Dimension prev = DimensionService.getInstance().getSize(SIZE_KEY);
|
||||
int width = prev != null && prev.width > panelSize.width ? prev.width : panelSize.width;
|
||||
myBalloon.setSize(new Dimension(width, panelSize.height));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,8 +579,7 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
splitter.setSecondComponent(myCodePreviewComponent);
|
||||
|
||||
setLayout(new MigLayout("flowx, ins 4, fillx, hidemode 2, gap 0"));
|
||||
add(myTitleLabel, "gapleft 4");
|
||||
add(Box.createHorizontalStrut(JBUI.scale(50)), "growx");
|
||||
add(myTitleLabel, "gapleft 4, sx 2, growx, pushx, growy");
|
||||
add(myCbCaseSensitive);
|
||||
add(myCbPreserveCase);
|
||||
add(myCbWholeWordsOnly);
|
||||
@@ -1029,7 +1041,7 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
SearchScope selectedScope = myScopeCombo.getSelectedScope();
|
||||
String customScopeName = selectedScope == null ? null : selectedScope.getDisplayName();
|
||||
model.setCustomScopeName(customScopeName);
|
||||
model.setCustomScope(selectedScope == null ? null : selectedScope);
|
||||
model.setCustomScope(selectedScope);
|
||||
model.setCustomScope(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,13 @@ import com.intellij.codeInsight.daemon.RelatedItemLineMarkerProvider;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.navigation.GotoRelatedItem;
|
||||
import com.intellij.openapi.editor.markup.GutterIconRenderer;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.SmartPointerManager;
|
||||
import com.intellij.psi.SmartPsiElementPointer;
|
||||
import com.intellij.util.PsiNavigateUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import com.jetbrains.python.psi.PyElement;
|
||||
import com.jetbrains.python.psi.PyFunction;
|
||||
@@ -71,8 +74,13 @@ public class PyiRelatedItemLineMarkerProvider extends RelatedItemLineMarkerProvi
|
||||
@Override
|
||||
public void navigate(MouseEvent e, PsiElement elt) {
|
||||
final PsiElement restoredRelatedElement = relatedElementPointer.getElement();
|
||||
if (restoredRelatedElement != null) {
|
||||
PsiNavigateUtil.navigate(restoredRelatedElement);
|
||||
if (restoredRelatedElement == null) {
|
||||
return;
|
||||
}
|
||||
final int offset = restoredRelatedElement instanceof PsiFile ? -1 : restoredRelatedElement.getTextOffset();
|
||||
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(restoredRelatedElement);
|
||||
if (virtualFile != null && virtualFile.isValid()) {
|
||||
new OpenFileDescriptor(restoredRelatedElement.getProject(), virtualFile, offset).navigate(true);
|
||||
}
|
||||
}
|
||||
}, GutterIconRenderer.Alignment.RIGHT, GotoRelatedItem.createItems(Collections.singletonList(relatedElement)));
|
||||
|
||||
Reference in New Issue
Block a user