mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
Merge remote-tracking branch 'origin/GP-945_ghidravore_adding_margin_click_listener_to_marker_service--SQUASHED'
This commit is contained in:
commit
efcb96e18f
3 changed files with 68 additions and 0 deletions
|
@ -99,6 +99,7 @@ public class MarkerManager implements MarkerService {
|
||||||
private PopupWindow popupWindow;
|
private PopupWindow popupWindow;
|
||||||
|
|
||||||
private List<ChangeListener> listeners = new ArrayList<>();
|
private List<ChangeListener> listeners = new ArrayList<>();
|
||||||
|
private MarkerClickedListener markerClickedListener = null;
|
||||||
|
|
||||||
public MarkerManager(Plugin ownerPlugin) {
|
public MarkerManager(Plugin ownerPlugin) {
|
||||||
this(ownerPlugin.getName(), ownerPlugin.getTool());
|
this(ownerPlugin.getName(), ownerPlugin.getTool());
|
||||||
|
@ -128,6 +129,23 @@ public class MarkerManager implements MarkerService {
|
||||||
markerPanel.setPreferredSize(new Dimension(16, 1));
|
markerPanel.setPreferredSize(new Dimension(16, 1));
|
||||||
marginProvider = new MyMarginProvider();
|
marginProvider = new MyMarginProvider();
|
||||||
|
|
||||||
|
markerPanel.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
if (e.getClickCount() != 2 || markerClickedListener == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Address addr = getAddress(e.getY());
|
||||||
|
if (addr == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MarkerSet marker = getMarkerSet(addr);
|
||||||
|
MarkerLocation location =
|
||||||
|
new MarkerLocation(marker, currentProgram, addr, e.getX(), e.getY());
|
||||||
|
markerClickedListener.markerDoubleClicked(location);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
actionList = new MarkerActionList();
|
actionList = new MarkerActionList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,4 +883,12 @@ public class MarkerManager implements MarkerService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMarkerClickedListener(MarkerClickedListener listener) {
|
||||||
|
if (listener != null && markerClickedListener != null) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Attempted to assign more than one MarkerClickedListener!");
|
||||||
|
}
|
||||||
|
markerClickedListener = listener;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import javax.swing.ImageIcon;
|
||||||
import javax.swing.event.ChangeListener;
|
import javax.swing.event.ChangeListener;
|
||||||
|
|
||||||
import ghidra.app.plugin.core.marker.MarkerManagerPlugin;
|
import ghidra.app.plugin.core.marker.MarkerManagerPlugin;
|
||||||
|
import ghidra.app.util.viewer.listingpanel.MarkerClickedListener;
|
||||||
import ghidra.framework.plugintool.ServiceInfo;
|
import ghidra.framework.plugintool.ServiceInfo;
|
||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.Address;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
|
@ -258,4 +259,15 @@ public interface MarkerService {
|
||||||
* @param listener the listener
|
* @param listener the listener
|
||||||
*/
|
*/
|
||||||
public void removeChangeListener(ChangeListener listener);
|
public void removeChangeListener(ChangeListener listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the listener to be notified when the user double-clicks in the Marker Margin area. Note
|
||||||
|
* that only one listener is allowed to be set at a time. If an attempt to set a second listener
|
||||||
|
* occurs, then an IllegalStateException is thrown.
|
||||||
|
*
|
||||||
|
* @param listener the listener to be notified or null to remove the current listener
|
||||||
|
* @throws IllegalStateException if a listener is already set.
|
||||||
|
*/
|
||||||
|
public void setMarkerClickedListener(MarkerClickedListener listener);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* Licensed 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 ghidra.app.util.viewer.listingpanel;
|
||||||
|
|
||||||
|
import ghidra.program.util.MarkerLocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for notifications when the user double-clicks in the marker margin
|
||||||
|
*/
|
||||||
|
public interface MarkerClickedListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notification that the user double-clicked in the marker margin
|
||||||
|
* @param location the MarkerLocation where the user double-clicked
|
||||||
|
*/
|
||||||
|
public void markerDoubleClicked(MarkerLocation location);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue