-
Notifications
You must be signed in to change notification settings - Fork 933
Expand file tree
/
Copy pathErrorNavigatorProviderImpl.java
More file actions
115 lines (100 loc) · 3.91 KB
/
Copy pathErrorNavigatorProviderImpl.java
File metadata and controls
115 lines (100 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.netbeans.modules.java.debug;
import java.awt.BorderLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.ActionMap;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.ListSelectionModel;
import org.netbeans.api.java.source.CancellableTask;
import org.netbeans.api.java.source.CompilationInfo;
import org.netbeans.spi.navigator.NavigatorPanel;
import org.openide.explorer.ExplorerManager;
import org.openide.explorer.ExplorerUtils;
import org.openide.explorer.view.BeanTreeView;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
/**
*
* @author Max Sauer
*/
public class ErrorNavigatorProviderImpl implements NavigatorPanel {
private JComponent panel;
private final ExplorerManager manager = new ExplorerManager();
/**
* Default constructor for layer instance.
*/
public ErrorNavigatorProviderImpl() {
manager.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {
TreeNavigatorProviderImpl.setHighlights(ElementNavigatorJavaSourceFactory.getInstance().getFile(), manager);
}
}
});
}
public String getDisplayName() {
return NbBundle.getMessage(ErrorNavigatorProviderImpl.class, "NM_Errors");
}
public String getDisplayHint() {
return NbBundle.getMessage(ErrorNavigatorProviderImpl.class, "SD_Errors");
}
public JComponent getComponent() {
if (panel == null) {
final BeanTreeView view = new BeanTreeView();
view.setRootVisible(false);
view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
class Panel extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
// Make sure action context works correctly:
private final Lookup lookup = ExplorerUtils.createLookup(manager, new ActionMap());
{
setLayout(new BorderLayout());
add(view, BorderLayout.CENTER);
}
public ExplorerManager getExplorerManager() {
return manager;
}
public Lookup getLookup() {
return lookup;
}
}
panel = new Panel();
}
return panel;
}
public Lookup getLookup() {
return null;
}
public void panelActivated(Lookup context) {
ElementNavigatorJavaSourceFactory.getInstance().setLookup(context, new TaskImpl());
}
public void panelDeactivated() {
ElementNavigatorJavaSourceFactory.getInstance().setLookup(Lookup.EMPTY, null);
}
private final class TaskImpl implements CancellableTask<CompilationInfo> {
public void cancel() {
}
public void run(CompilationInfo info) {
//XXX set proper root
manager.setRootContext(ErrorNode.getTree(info));
}
}
}