mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ability to copy/paste path to setting to give user a hint where to search
This commit is contained in:
+34
@@ -24,6 +24,7 @@ import com.intellij.openapi.options.ex.SortedConfigurableGroup;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.GradientViewport;
|
||||
import com.intellij.ui.treeStructure.CachingSimpleNode;
|
||||
@@ -33,8 +34,11 @@ import com.intellij.ui.treeStructure.SimpleTreeStructure;
|
||||
import com.intellij.ui.treeStructure.filtered.FilteringTreeBuilder;
|
||||
import com.intellij.ui.treeStructure.filtered.FilteringTreeStructure;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.ButtonlessScrollBarUI;
|
||||
import com.intellij.util.ui.GraphicsUtil;
|
||||
import com.intellij.util.ui.TextTransferable;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import com.intellij.util.ui.tree.WideSelectionTreeUI;
|
||||
@@ -54,6 +58,7 @@ import javax.swing.tree.TreeCellRenderer;
|
||||
import javax.swing.tree.TreePath;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
@@ -106,6 +111,35 @@ final class SettingsTreeView extends JComponent implements Disposable, OptionsEd
|
||||
myTree.setExpandableItemsEnabled(false);
|
||||
RelativeFont.BOLD.install(myTree);
|
||||
|
||||
myTree.setTransferHandler(new TransferHandler() {
|
||||
@Nullable
|
||||
@Override
|
||||
protected Transferable createTransferable(JComponent c) {
|
||||
final TreePath path = myTree.getPathForRow(myTree.getLeadSelectionRow());
|
||||
if (path != null) {
|
||||
return new TextTransferable(StringUtil.join(ContainerUtil.mapNotNull(path.getPath(), new NullableFunction<Object, String>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String fun(Object o) {
|
||||
if (o == path.getPath()[0]) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
final MyNode node = extractNode(o);
|
||||
return node != null ? node.myDisplayName : null;
|
||||
}
|
||||
}
|
||||
}), " | "));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourceActions(JComponent c) {
|
||||
return COPY;
|
||||
}
|
||||
});
|
||||
|
||||
myScroller = ScrollPaneFactory.createScrollPane(null, true);
|
||||
myScroller.setViewport(new GradientViewport(myTree, 5, 0, 0, 0, true) {
|
||||
private JLabel myHeader;
|
||||
|
||||
Reference in New Issue
Block a user