Skip to content

Commit

Permalink
Version 0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
hajdam committed Dec 8, 2023
1 parent d191ecd commit 696b574
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 25 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
.idea/sonarlint

.gradle
out/
*~
guipopup-intellij-plugin.jar
guipopup-intellij-plugin.zip
/.idea/dbnavigator.xml
/.idea/jpa-buddy.xml
1 change: 1 addition & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
0.1.3
- Fixes for 2023.3

0.1.2 (2023-02-18)
- Support for copy link/image
Expand Down
3 changes: 3 additions & 0 deletions guipopup-intellij-plugin.iml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="dependencies" level="project" />
</component>
<component name="SonarLintModuleSettings">
<option name="uniqueId" value="20bed214-bc19-4c3d-bd91-94656312ddca" />
</component>
</module>
8 changes: 3 additions & 5 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin url="https://github.com/hajdam/guipopup-intellij-plugin">
<id>org.exbin.utils.guipopup</id>
<name>GUI Popup &amp; Inspect</name>
<version>0.1.2</version>
<version>0.1.3</version>
<vendor email="hajdam@users.sf.net" url="https://exbin.org">ExBin Project</vendor>

<description><![CDATA[
Expand All @@ -12,7 +12,7 @@
</ul></p>
<h1>Preview</h1>
<p><img src="https://www.exbin.org/images/guipopup-intellij-preview-0.1.2.png" alt="guipopup-intellij-preview"/></p>
<p><img src="https://www.exbin.org/images/guipopup-intellij-preview-0.1.3.png" alt="guipopup-intellij-preview"/></p>
<h1>License</h1>
<a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>
Expand All @@ -22,9 +22,7 @@ Sources: <a href="https://github.com/hajdam/guipopup-intellij-plugin">https://gi
]]></description>

<change-notes><![CDATA[
<ul><li>Support for copy link/image</li>
<li>Added plugin icon</li>
<li>Added integration with BinEd plugin</li>
<ul><li>Fixes for 2023.3</li>
</ul>
]]>
</change-notes>
Expand Down
51 changes: 49 additions & 2 deletions src/org/exbin/framework/utils/ActionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;
Expand All @@ -34,6 +35,7 @@
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.net.URL;
import java.util.Map;
import java.util.ResourceBundle;

Expand Down Expand Up @@ -104,10 +106,55 @@ public static void setupAction(Action action, ResourceBundle bundle, Class<?> re
action.putValue(Action.SHORT_DESCRIPTION, bundle.getString(actionId + ACTION_SHORT_DESCRIPTION_POSTFIX));
}
if (bundle.containsKey(actionId + ACTION_SMALL_ICON_POSTFIX)) {
action.putValue(Action.SMALL_ICON, IconLoader.getIcon(bundle.getString(actionId + ACTION_SMALL_ICON_POSTFIX), AllIcons.class));
Icon icon = null;
try {
String imagePath = bundle.getString(actionId + ACTION_SMALL_ICON_POSTFIX);
switch (imagePath) {
case "/actions/menu-cut.png": {
icon = AllIcons.Actions.MenuCut;
break;
}
case "/actions/copy.png": {
icon = AllIcons.Actions.Copy;
break;
}
case "/actions/menu-paste.png": {
icon = AllIcons.Actions.MenuPaste;
break;
}
case "/actions/delete.png": {
icon = AllIcons.Actions.Cancel;
break;
}
default: {
icon = IconLoader.getIcon(imagePath, resourceClass);
}
}
} catch (Throwable ex) {
// Cannot get icon, get backup
// URL resource = resourceClass.getResource(bundle.getString(actionId + ACTION_SMALL_ICON_POSTFIX));
// if (resource != null) {
// icon = new javax.swing.ImageIcon(resource);
// }
}
if (icon != null) {
action.putValue(Action.SMALL_ICON, icon);
}
}
if (bundle.containsKey(actionId + ACTION_SMALL_LARGE_POSTFIX)) {
action.putValue(Action.LARGE_ICON_KEY, IconLoader.getIcon(bundle.getString(actionId + ACTION_SMALL_LARGE_POSTFIX), AllIcons.class));
Icon icon = null;
try {
icon = IconLoader.getIcon(bundle.getString(actionId + ACTION_SMALL_LARGE_POSTFIX), resourceClass);
} catch (Throwable ex) {
// Cannot get icon, get backup
// URL resource = resourceClass.getResource(bundle.getString(actionId + ACTION_SMALL_LARGE_POSTFIX));
// if (resource != null) {
// icon = new javax.swing.ImageIcon(resource);
// }
}
if (icon != null) {
action.putValue(Action.LARGE_ICON_KEY, icon);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/org/exbin/utils/guipopup/IntelliJDefaultPopupMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private void unregisterQueue() {
}

private void initDefaultPopupMenu() {
initDefaultPopupMenu(resourceBundle, this.getClass());
initDefaultPopupMenu(resourceBundle, DefaultPopupMenu.class);
}

@ParametersAreNonnullByDefault
Expand Down
43 changes: 26 additions & 17 deletions src/org/exbin/utils/guipopup/gui/PropertyTablePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.awt.Component;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.swing.JComponent;
import javax.swing.JTable;
Expand Down Expand Up @@ -58,7 +59,6 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
component.setToolTipText("(" + tableItem.getTypeName() + ") " + tableItem.getValueName());
return component;
}

};
columns.getColumn(0).setCellRenderer(nameCellRenderer);
valueCellRenderer = new PropertyTableCellRenderer();
Expand Down Expand Up @@ -97,33 +97,42 @@ public void setObject(Object object) {
} else {
while (clazz != null) {
Field[] fields = clazz.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
Field field = fields[i];
for (Field field : fields) {
if (!showStaticFields && java.lang.reflect.Modifier.isStatic(field.getModifiers())) {
continue;
}

Object value;
try {
boolean accessible = field.isAccessible();
if (!accessible) {
field.setAccessible(true);
}
value = field.get(object);
if (!accessible) {
field.setAccessible(false);
}
} catch (IllegalArgumentException | IllegalAccessException ex) {
value = null;
}
Object value = accessField(field, object);
PropertyTableItem item = new PropertyTableItem(field.getName(), field.getGenericType().getTypeName(), value);
tableModel.addRow(item);
}
clazz = clazz.getSuperclass();
}
}
}


@Nullable
private static Object accessField(Field field, Object object) {
Object result = null;
try {
result = field.get(object);
} catch (Throwable ex) {
try {
// Try to make field accessible
field.setAccessible(true);
try {
result = field.get(object);
} catch (Throwable ex3) {
}
field.setAccessible(false);
} catch (Throwable ex2) {
// Can't set it back, just ignore it
}
}

return result;
}

public boolean isShowStaticFields() {
return showStaticFields;
}
Expand Down

0 comments on commit 696b574

Please sign in to comment.