Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added code preview for “search results” #7779

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,24 @@
*/
package org.netbeans.modules.search.ui;

import java.beans.PropertyChangeEvent;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import org.netbeans.modules.search.BasicComposition;
import org.netbeans.modules.search.ContextView;
import org.netbeans.modules.search.FindDialogMemory;
import org.netbeans.modules.search.ResultModel;
import org.openide.nodes.Node;
import org.openide.util.RequestProcessor;

/**
*
* @author jhavlin
*/
public class BasicSearchResultsPanel extends BasicAbstractResultsPanel {
private final RequestProcessor.Task SAVE_TASK = RequestProcessor.getDefault().create(new BasicSearchResultsPanel.SaveTask());
private JSplitPane splitPane;

public BasicSearchResultsPanel(ResultModel resultModel,
BasicComposition composition, boolean details, Node infoNode) {
Expand All @@ -37,6 +46,39 @@ public BasicSearchResultsPanel(ResultModel resultModel,
}

private void init() {
getContentPanel().add(resultsOutlineSupport.getOutlineView());
JPanel leftPanel = new JPanel();
leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
leftPanel.add(resultsOutlineSupport.getOutlineView());

this.splitPane = new JSplitPane();
splitPane.setLeftComponent(leftPanel);
splitPane.setRightComponent(new ContextView(resultModel,
getExplorerManager()));
initSplitDividerLocationHandling();
getContentPanel().add(splitPane);
}

private void initSplitDividerLocationHandling() {
int location = FindDialogMemory.getDefault().getReplaceResultsDivider();
if (location > 0) {
splitPane.setDividerLocation(location);
}
splitPane.addPropertyChangeListener((PropertyChangeEvent evt) -> {
String pn = evt.getPropertyName();
if (pn.equals(JSplitPane.DIVIDER_LOCATION_PROPERTY)) {
SAVE_TASK.schedule(1000);
}
});
}

private class SaveTask implements Runnable {

@Override
public void run() {
if (splitPane != null) {
FindDialogMemory.getDefault().setReplaceResultsDivider(
splitPane.getDividerLocation());
}
}
}
}
Loading