Skip to content

Commit

Permalink
Release 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hajdam committed Sep 4, 2019
1 parent c795847 commit f000c84
Show file tree
Hide file tree
Showing 12 changed files with 216 additions and 257 deletions.
2 changes: 1 addition & 1 deletion changes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
0.2.1
0.2.1 (2019-09-04)
- Action to show debug variables as binary data
- Minor GUI improvements
- Context aware popup menu
Expand Down
2 changes: 1 addition & 1 deletion manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ OpenIDE-Module-Install: org/exbin/bined/netbeans/Installer.class
OpenIDE-Module-Layer: org/exbin/bined/netbeans/layer.xml
OpenIDE-Module-Localizing-Bundle: org/exbin/bined/netbeans/Bundle.properties
OpenIDE-Module-Requires: org.openide.windows.WindowManager
OpenIDE-Module-Specification-Version: 0.2.0
OpenIDE-Module-Specification-Version: 0.2.1
73 changes: 49 additions & 24 deletions src/org/exbin/bined/netbeans/BinaryDebugAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,24 @@
import javax.swing.JPanel;
import org.exbin.bined.netbeans.debug.DebugViewDataSource;
import org.exbin.bined.netbeans.debug.array.ByteArrayPageProvider;
import org.exbin.bined.netbeans.debug.array.CharArrayPageProvider;
import org.exbin.bined.netbeans.debug.array.DoubleArrayPageProvider;
import org.exbin.bined.netbeans.debug.array.FloatArrayPageProvider;
import org.exbin.bined.netbeans.debug.array.IntegerArrayPageProvider;
import org.exbin.bined.netbeans.debug.array.LongArrayPageProvider;
import org.exbin.bined.netbeans.debug.array.ShortArrayPageProvider;
import org.exbin.bined.netbeans.debug.panel.DebugViewPanel;
import org.exbin.framework.bined.panel.ValuesPanel;
import org.exbin.framework.gui.utils.WindowUtils;
import org.exbin.framework.gui.utils.panel.CloseControlPanel;
import org.exbin.utils.binary_data.BinaryData;
import org.exbin.utils.binary_data.ByteArrayData;
import org.exbin.utils.binary_data.ByteArrayEditableData;
import org.netbeans.api.debugger.jpda.ClassVariable;
import org.netbeans.api.debugger.jpda.Field;
import org.netbeans.api.debugger.jpda.JPDAArrayType;
import org.netbeans.api.debugger.jpda.JPDAClassType;
import org.netbeans.api.debugger.jpda.ObjectVariable;
import org.netbeans.api.debugger.jpda.Variable;
import org.netbeans.api.debugger.jpda.VariableType;
import org.netbeans.spi.debugger.ContextProvider;
import org.openide.awt.ActionID;
import org.openide.awt.ActionRegistration;
Expand Down Expand Up @@ -123,28 +126,40 @@ public static void actionPerformed(Component parent, Object variableObject) {
fallback = false;
debugViewPanel.setData(data);
}
} else if (classType instanceof JPDAArrayType) {
data = processArrayValue((ObjectVariable) variableObject, (JPDAArrayType) classType);
} else if (classObject != null && classObject.getReflectedType() instanceof JPDAArrayType) {
data = processArrayValue((ObjectVariable) variableObject, (JPDAArrayType) classObject.getReflectedType());
if (data != null) {
fallback = false;
debugViewPanel.setData(data);
}
} else if (classType instanceof JPDAArrayType) {
// TODO support for java.lang.*[] wrappers for native types
// (Throws java.lang.AssertionError: Debugger communication in AWT Event Queue!)
// data = processArrayValue((ObjectVariable) variableObject, (JPDAArrayType) classType);
// if (data != null) {
// fallback = false;
// debugViewPanel.setData(data);
// }
} else {
// classObject.getToStringValue();
int fieldsCount = ((ObjectVariable) variableObject).getFieldsCount();
if (fieldsCount == 1) {
Field[] fields = ((ObjectVariable) variableObject).getFields(0, 0);
data = processSimpleValue(fields[0]);
if (data != null) {
fallback = false;
debugViewPanel.setData(data);
}
}
// TODO support for java.lang.* wrappers for native types
// int fieldsCount = ((ObjectVariable) variableObject).getFieldsCount();
// if (fieldsCount == 1) {
// Field[] fields = ((ObjectVariable) variableObject).getFields(0, 0);
// Field field = fields[0];
// data = processSimpleValue(field.getDeclaredType(), ((ObjectVariable) variableObject).getValue());
// if (data != null) {
// fallback = false;
// debugViewPanel.setData(data);
// }
// }
}
}

if (fallback && variableObject instanceof Variable) {
data = processSimpleValue((Variable) variableObject);
String variableValue = ((Variable) variableObject).getValue();
String variableType = ((Variable) variableObject).getType();
data = processSimpleValue(variableType, variableValue);
if (data == null) {
String value = ((Variable) variableObject).getValue();
if (value != null) {
Expand All @@ -163,13 +178,9 @@ public static void actionPerformed(Component parent, Object variableObject) {
}

@Nullable
private static BinaryData processSimpleValue(Variable variableObject) {
String variableValue = ((Variable) variableObject).getValue();
String variableType = ((Variable) variableObject).getType();

private static BinaryData processSimpleValue(String variableType, String variableValue) {
switch (variableType) {
case "byte":
case "java.lang.Byte": {
case "byte": {
byte[] byteArray = new byte[1];
byte value = Byte.valueOf(variableValue);
byteArray[0] = value;
Expand Down Expand Up @@ -244,14 +255,28 @@ private static BinaryData processSimpleValue(Variable variableObject) {
private static BinaryData processArrayValue(ObjectVariable variableObject, JPDAArrayType arrayType) {
String type = arrayType.getComponentTypeName();
switch (type) {
case "byte":
case "java.lang.Byte": {
case "java.lang.Byte":
case "byte": {
return new DebugViewDataSource(new ByteArrayPageProvider(variableObject));
}
case "int":
case "java.lang.Integer": {
case "short": {
return new DebugViewDataSource(new ShortArrayPageProvider(variableObject));
}
case "int": {
return new DebugViewDataSource(new IntegerArrayPageProvider(variableObject));
}
case "long": {
return new DebugViewDataSource(new LongArrayPageProvider(variableObject));
}
case "float": {
return new DebugViewDataSource(new FloatArrayPageProvider(variableObject));
}
case "double": {
return new DebugViewDataSource(new DoubleArrayPageProvider(variableObject));
}
case "char": {
return new DebugViewDataSource(new CharArrayPageProvider(variableObject));
}
}

return null;
Expand Down
13 changes: 7 additions & 6 deletions src/org/exbin/bined/netbeans/Bundle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
OpenIDE-Module-Display-Category=Editing
OpenIDE-Module-Long-Description=\
Binary/hexadecimal editor based on BinEd library. \
Use "Open as Binary" action in main "File" menu or in project files context menu.\n\n\
<h1>Preview</h1>\n<img src="https://bined.exbin.org/images/bined-netbeans-preview-0.2.1.png" alt="bined-netbeans-preview"/>\n\n<h1>Features</h1>\n<ul><li>Visualize data as numerical (hexadecimal) codes and text representation</li>\n<li>Codes can be also binary, octal or decimal</li>\n<li>Support for Unicode, UTF-8 and other charsets</li>\n<li>Insert and overwrite edit modes</li>\n<li>Searching for text / hexadecimal code with found matches highlighting</li>\n<li>Support for undo/redo</li>\n<li>Support for files with size up to exabytes</li></ul>\n\n<h1>License</h1>\n<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>\n\n<h1>Links</h1>\nHomepage: <a href="https://bined.exbin.org/netbeans-plugin/">https://bined.exbin.org/netbeans-plugin/</a><br/>\nSources: <a href="https://github.com/exbin/bined-netbeans-plugin">https://github.com/exbin/bined-netbeans-plugin</a>
Binary/hexadecimal editor based on BinEd library.\n\n\
<p>Use "Open as Binary" action in main "File" menu or in project files context menu.\
</p>\n<p>Use "Show as Binary" action in context menu in Variables window.\
</p>\n\n<h1>Preview</h1>\n<img src="https://bined.exbin.org/images/bined-netbeans-preview-0.2.1.png" alt="bined-netbeans-preview"/>\n\n<h1>Features</h1>\n<ul><li>Visualize data as numerical (hexadecimal) codes and text representation</li>\n<li>Codes can be also binary, octal or decimal</li>\n<li>Support for Unicode, UTF-8 and other charsets</li>\n<li>Insert and overwrite edit modes</li>\n<li>Searching for text / hexadecimal code with found matches highlighting</li>\n<li>Support for undo/redo</li>\n<li>Support for files with size up to exabytes</li>\n<li>Show debug variables as binary data</li></ul>\n\n<h1>License</h1>\n<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>\n\n<h1>Links</h1>\nHomepage: <a href="https://bined.exbin.org/netbeans-plugin/">https://bined.exbin.org/netbeans-plugin/</a><br/>\nSources: <a href="https://github.com/exbin/bined-netbeans-plugin">https://github.com/exbin/bined-netbeans-plugin</a>
OpenIDE-Module-Name=BinEd - Binary/Hexadecimal Editor
OpenIDE-Module-Short-Description=Tool for viewing and editing binary files in hexadecimal and textual dump form
CTL_BinaryEditorAction=BinaryEditor
Expand All @@ -13,9 +14,9 @@ HINT_BinaryEditorTopComponent=This is a BinaryEditor window
Application.name = BinEd - Binary/Hexadecimal Editor
Application.title = BinEd NetBeans Plugin
Application.release = 0.2.1
Application.mode = DEV
Application.version = 0.2.1 DEV
Application.product= BinEd Binary/Hexadecimal Editor 0.2.1 DEV
Application.mode =
Application.version = 0.2.1
Application.product= BinEd Binary/Hexadecimal Editor 0.2.1
Application.vendor = ExBin Project
Application.homepage = https://bined.exbin.org/netbeans-plugin/
Application.vendorId = ExBin Project
Expand Down
4 changes: 2 additions & 2 deletions src/org/exbin/bined/netbeans/FileOpenAsBinaryAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.openide.loaders.DataObject;
import org.openide.loaders.DataObjectNotFoundException;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle.Messages;
import org.openide.util.NbBundle;
import org.openide.windows.Mode;
import org.openide.windows.WindowManager;

Expand All @@ -46,7 +46,7 @@
displayName = "#CTL_FileOpenAsBinaryAction"
)
@ActionReference(path = "Menu/File", position = 850)
@Messages("CTL_FileOpenAsBinaryAction=Open File as Binary...")
@NbBundle.Messages("CTL_FileOpenAsBinaryAction=Open File as Binary...")
@ParametersAreNonnullByDefault
public final class FileOpenAsBinaryAction implements ActionListener {

Expand Down
4 changes: 2 additions & 2 deletions src/org/exbin/bined/netbeans/OpenAsBinaryAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.openide.awt.ActionRegistration;
import org.openide.loaders.DataObject;
import org.openide.loaders.DataShadow;
import org.openide.util.NbBundle.Messages;
import org.openide.util.NbBundle;
import org.openide.windows.Mode;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
Expand All @@ -36,7 +36,7 @@
@ParametersAreNonnullByDefault
@ActionID(category = "File", id = "org.exbin.bined.OpenAsBinaryAction")
@ActionRegistration(displayName = "#CTL_OpenAsBinaryAction")
@Messages("CTL_OpenAsBinaryAction=Open as Binary")
@NbBundle.Messages("CTL_OpenAsBinaryAction=Open as Binary")
public final class OpenAsBinaryAction implements ActionListener {

public OpenAsBinaryAction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* Byte array data source for debugger view.
*
* @author ExBin Project (http://exbin.org)
* @version 0.2.1 2019/09/02
* @version 0.2.1 2019/09/04
*/
public class ByteArrayPageProvider implements DebugViewDataSource.PageProvider {

Expand All @@ -45,16 +45,11 @@ public byte[] getPage(long pageIndex) {
byte[] result = new byte[length];
for (int i = 0; i < values.length; i++) {
Field rawValue = values[i];
byte value = Byte.valueOf(rawValue.getValue());
// if (rawValue instanceof ObjectReference) {
// Field field = ((ObjectReference) rawValue).referenceType().fieldByName("value");
// rawValue = ((ObjectReference) rawValue).getValue(field);
// }
//
// if (rawValue instanceof ByteValue) {
// value = ((ByteValue) rawValue).value();
// if (rawValue instanceof ObjectVariable) {
// rawValue = ((ObjectVariable) rawValue).getFields(0, 0)[0];
// }

byte value = Byte.valueOf(rawValue.getValue());
result[i] = value;
}

Expand Down
67 changes: 27 additions & 40 deletions src/org/exbin/bined/netbeans/debug/array/CharArrayPageProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,60 +16,47 @@
package org.exbin.bined.netbeans.debug.array;

import org.exbin.bined.netbeans.debug.DebugViewDataSource;
import org.netbeans.api.debugger.jpda.Field;
import org.netbeans.api.debugger.jpda.ObjectVariable;


/**
* Character array data source for debugger view.
*
* @author ExBin Project (http://exbin.org)
* @version 0.2.1 2019/09/02
* @version 0.2.1 2019/09/04
*/
public class CharArrayPageProvider implements DebugViewDataSource.PageProvider {

private final ObjectVariable arrayRef;

public CharArrayPageProvider(ObjectVariable arrayRef) {
this.arrayRef = arrayRef;
}

@Override
public byte[] getPage(long pageIndex) {
throw new UnsupportedOperationException("Not supported yet.");
int pageSize = DebugViewDataSource.PAGE_SIZE / 2;
int startPos = (int) (pageIndex * pageSize);
int length = pageSize;
if (arrayRef.getFieldsCount() - startPos < pageSize) {
length = arrayRef.getFieldsCount() - startPos;
}
final Field[] values = arrayRef.getFields(startPos, startPos + length);
byte[] result = new byte[length * 2];
for (int i = 0; i < values.length; i++) {
Field rawValue = values[i];
int value = rawValue.getValue().charAt(1);

result[i * 2 ] = (byte) ((value >> 8) & 0xff);
result[i * 2 + 1] = (byte) (value & 0xff);
}

return result;
}

@Override
public long getDocumentSize() {
throw new UnsupportedOperationException("Not supported yet.");
return arrayRef.getFieldsCount() * 2;
}

// private final ArrayReference arrayRef;
//
// public CharArrayPageProvider(ArrayReference arrayRef) {
// this.arrayRef = arrayRef;
// }
//
// @Override
// public byte[] getPage(long pageIndex) {
// int pageSize = DebugViewDataSource.PAGE_SIZE / 2;
// int startPos = (int) (pageIndex * pageSize);
// int length = pageSize;
// if (arrayRef.length() - startPos < pageSize) {
// length = arrayRef.length() - startPos;
// }
// final List<Value> values = arrayRef.getValues(startPos, length);
// byte[] result = new byte[length * 2];
// for (int i = 0; i < values.size(); i++) {
// Value rawValue = values.get(i);
// if (rawValue instanceof ObjectReference) {
// Field field = ((ObjectReference) rawValue).referenceType().fieldByName("value");
// rawValue = ((ObjectReference) rawValue).getValue(field);
// }
//
// int value = (int) (rawValue instanceof CharValue ? ((CharValue) rawValue).value() : 0);
//
// result[i * 2 ] = (byte) ((value >> 8) & 0xff);
// result[i * 2 + 1] = (byte) (value & 0xff);
// }
//
// return result;
// }
//
// @Override
// public long getDocumentSize() {
// return arrayRef.length() * 2;
// }
}
Loading

0 comments on commit f000c84

Please sign in to comment.