use of com.igormaznitsa.meta.annotation.ReturnsOriginal in project netbeans-mmd-plugin by raydac.
the class MindMapPanelConfig method saveTo.
@Nullable
@ReturnsOriginal
public Preferences saveTo(@Nullable final Preferences prefs) {
if (prefs != null) {
final String prefix = MindMapPanelConfig.class.getSimpleName();
for (final Field f : MindMapPanelConfig.class.getDeclaredFields()) {
if ((f.getModifiers() & (Modifier.STATIC | Modifier.TRANSIENT | Modifier.FINAL)) != 0) {
continue;
}
final Class<?> fieldClass = f.getType();
final String fieldName = prefix + '.' + f.getName();
try {
if (fieldClass == boolean.class) {
prefs.putBoolean(fieldName, f.getBoolean(this));
} else if (fieldClass == int.class) {
prefs.putInt(fieldName, f.getInt(this));
} else if (fieldClass == float.class) {
prefs.putFloat(fieldName, f.getFloat(this));
} else if (fieldClass == double.class) {
prefs.putDouble(fieldName, f.getDouble(this));
} else if (fieldClass == Font.class) {
final Font theFont = (Font) f.get(this);
prefs.put(fieldName + ".name", theFont.getName());
prefs.putInt(fieldName + ".size", theFont.getSize());
prefs.putInt(fieldName + ".style", theFont.getStyle());
} else if (fieldClass == Color.class) {
prefs.putInt(fieldName, ((Color) f.get(this)).getRGB());
} else if (fieldClass == String.class) {
prefs.put(fieldName, (String) f.get(this));
} else if (fieldClass == RenderQuality.class) {
prefs.put(fieldName, ((RenderQuality) f.get(this)).name());
} else {
throw new Error("Unexpected field type " + fieldClass.getName());
}
} catch (IllegalAccessException ex) {
throw new Error("IllegalAccessException [" + fieldClass.getName() + ']', ex);
} catch (IllegalArgumentException ex) {
throw new Error("IllegalArgumentException [" + fieldClass.getName() + ']', ex);
}
}
for (final Map.Entry<String, KeyShortcut> e : this.mapShortCut.entrySet()) {
prefs.put("mapShortCut." + e.getValue().getID(), e.getValue().packToString());
}
}
return prefs;
}
use of com.igormaznitsa.meta.annotation.ReturnsOriginal in project netbeans-mmd-plugin by raydac.
the class SwingUtils method addTextActions.
@Nonnull
@ReturnsOriginal
public static JPopupMenu addTextActions(@Nonnull final JPopupMenu menu) {
final Action cut = new DefaultEditorKit.CutAction();
cut.putValue(Action.NAME, "Cut");
menu.add(cut);
final Action copy = new DefaultEditorKit.CopyAction();
copy.putValue(Action.NAME, "Copy");
menu.add(copy);
final Action paste = new DefaultEditorKit.PasteAction();
paste.putValue(Action.NAME, "Paste");
menu.add(paste);
menu.add(new SelectAllTextAction());
return menu;
}
Aggregations