leave icon when inplace editing a watch

This commit is contained in:
Egor.Ushakov
2017-05-23 20:02:19 +03:00
parent 996d1be0d7
commit 90b4152578
3 changed files with 47 additions and 3 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -40,6 +40,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.util.List;
/**
@@ -139,4 +140,17 @@ public class CustomFieldInplaceEditor extends XDebuggerTreeInplaceEditor {
}
}).getPath();
}
@Nullable
@Override
protected Rectangle getEditorBounds() {
Rectangle bounds = super.getEditorBounds();
if (bounds == null) {
return null;
}
int afterIconX = getAfterIconX();
bounds.x += afterIconX;
bounds.width -= afterIconX;
return bounds;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -25,6 +25,8 @@ import com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
/**
* @author nik
*/
@@ -65,4 +67,17 @@ public class WatchInplaceEditor extends XDebuggerTreeInplaceEditor {
}
TreeUtil.selectNode(myTree, myNode);
}
@Nullable
@Override
protected Rectangle getEditorBounds() {
Rectangle bounds = super.getEditorBounds();
if (bounds == null) {
return null;
}
int afterIconX = getAfterIconX();
bounds.x += afterIconX;
bounds.width -= afterIconX;
return bounds;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -18,6 +18,7 @@ package com.intellij.xdebugger.impl.ui.tree;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.ui.AppUIUtil;
import com.intellij.ui.SimpleColoredComponent;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XDebugSessionListener;
import com.intellij.xdebugger.XExpression;
@@ -27,6 +28,7 @@ import com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode;
import org.jetbrains.annotations.NonNls;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.plaf.basic.ComboPopup;
import javax.swing.tree.TreePath;
@@ -145,4 +147,17 @@ public abstract class XDebuggerTreeInplaceEditor extends TreeInplaceEditor {
protected Project getProject() {
return myNode.getTree().getProject();
}
protected final int getAfterIconX() {
Icon icon = myNode.getIcon();
if (icon != null) {
SimpleColoredComponent iconLabel = new SimpleColoredComponent();
iconLabel.getIpad().right = 0;
iconLabel.getIpad().left = 0;
iconLabel.setIcon(myNode.getIcon());
Border border = iconLabel.getMyBorder();
return iconLabel.getPreferredSize().width - (border != null ? border.getBorderInsets(iconLabel).right : 0);
}
return 0;
}
}