|
|
|
|
@ -1,20 +1,16 @@
|
|
|
|
|
/*
|
|
|
|
|
* To change this license header, choose License Headers in Project Properties.
|
|
|
|
|
* To change this template file, choose Tools | Templates
|
|
|
|
|
* and open the template in the editor.
|
|
|
|
|
/* Copyright (C) Edward M. Kagan - All Rights Reserved
|
|
|
|
|
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
|
|
|
* Proprietary and confidential
|
|
|
|
|
* Written by Edward M. Kagan <atman@idp-crew.com>, 2015
|
|
|
|
|
*/
|
|
|
|
|
package org.idp.laf;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
import java.util.AbstractMap;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.Enumeration;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.prefs.BackingStoreException;
|
|
|
|
|
import java.util.prefs.Preferences;
|
|
|
|
|
@ -24,43 +20,37 @@ import javax.swing.text.SimpleAttributeSet;
|
|
|
|
|
import javax.swing.text.StyleConstants;
|
|
|
|
|
import org.openide.util.Exceptions;
|
|
|
|
|
import org.openide.util.Lookup;
|
|
|
|
|
import org.openide.util.NbBundle;
|
|
|
|
|
import org.openide.util.NbPreferences;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @author Edward M. Kagan <atman@idp-crew.com>
|
|
|
|
|
*/
|
|
|
|
|
@SuppressWarnings ({"rawtypes","unchecked"})
|
|
|
|
|
public class TitanEditor {
|
|
|
|
|
|
|
|
|
|
private static final String COLOR_MODEL_CLASS_NAME = "org.netbeans.modules.options.colors.ColorModel"; //NOI18N
|
|
|
|
|
private static final String COLOR_MODEL_CLASS_NAME = "org.netbeans.modules.options.colors.ColorModel"; //NOI18N
|
|
|
|
|
private static final String EDITOR_SETTINGS_CLASS_NAME = "org.netbeans.api.editor.settings.EditorStyleConstants"; //NOI18N
|
|
|
|
|
private static final String ANNOTATION_TYPE_CLASS_NAME = "org.netbeans.editor.AnnotationType"; //NOI18N
|
|
|
|
|
|
|
|
|
|
private static final String PROVIDER_CLASS_NAME = "org.netbeans.modules.versioning.util.OptionsPanelColorProvider"; //NOI18N
|
|
|
|
|
// private static final String PROVIDER_GIT_CLASS_NAME = "org.netbeans.modules.git.options.AnnotationColorProvider"; //NOI18N
|
|
|
|
|
// private static final String PROVIDER_SVN_CLASS_NAME = "org.netbeans.modules.subversion.options.AnnotationColorProvider"; //NOI18N
|
|
|
|
|
// private static final String PROVIDER_HG_CLASS_NAME = "org.netbeans.modules.mercurial.options.AnnotationColorProvider"; //NOI18N
|
|
|
|
|
private static final String PROVIDER_GIT_CLASS_NAME = "org.netbeans.modules.git.GitModuleConfig"; //NOI18N
|
|
|
|
|
private static final String PROVIDER_SVN_CLASS_NAME = "org.netbeans.modules.subversion.SvnModuleConfig"; //NOI18N
|
|
|
|
|
private static final String PROVIDER_HG_CLASS_NAME = "org.netbeans.modules.mercurial.HgModuleConfig"; //NOI18N
|
|
|
|
|
private static final String PROVIDER_CLASS_NAME = "org.netbeans.modules.versioning.util.OptionsPanelColorProvider"; //NOI18N
|
|
|
|
|
private static final String PROVIDER_GIT_CLASS_NAME = "org.netbeans.modules.git.GitModuleConfig"; //NOI18N
|
|
|
|
|
private static final String PROVIDER_SVN_CLASS_NAME = "org.netbeans.modules.subversion.SvnModuleConfig"; //NOI18N
|
|
|
|
|
private static final String PROVIDER_HG_CLASS_NAME = "org.netbeans.modules.mercurial.HgModuleConfig"; //NOI18N
|
|
|
|
|
private static final String PROVIDER_DIFF_CLASS_NAME = "org.netbeans.modules.diff.DiffModuleConfig"; //NOI18N
|
|
|
|
|
|
|
|
|
|
private static final boolean no_load = false;
|
|
|
|
|
private static final boolean no_load = false;
|
|
|
|
|
private static final String DEFAULT_THEME_NAME = "NetBeans 5.5"; //NOI18N
|
|
|
|
|
|
|
|
|
|
private static ClassLoader working_classLoader = null;
|
|
|
|
|
|
|
|
|
|
private static Class COLOR_MODEL;
|
|
|
|
|
private static Class EDITOR_SETTINGS;
|
|
|
|
|
private static Class ANNOTATION_TYPE;
|
|
|
|
|
|
|
|
|
|
private static Class GIT_CONFIG;
|
|
|
|
|
|
|
|
|
|
private static Field DisplayName;
|
|
|
|
|
private static Field WaveUnderlineColor;
|
|
|
|
|
|
|
|
|
|
private static Method getName;
|
|
|
|
|
|
|
|
|
|
private static Method getProfiles;
|
|
|
|
|
private static Method getCurrentProfile;
|
|
|
|
|
private static Method setCurrentProfile;
|
|
|
|
|
|
|
|
|
|
@ -87,35 +77,22 @@ public class TitanEditor {
|
|
|
|
|
|
|
|
|
|
private static Method getLanguages;
|
|
|
|
|
|
|
|
|
|
private static Object const_DisplayName;
|
|
|
|
|
private static Object const_WaveUnderlineColor;
|
|
|
|
|
private static Object colorModel;
|
|
|
|
|
|
|
|
|
|
private static final String DEFAULT_THEME_NAME = "NetBeans 5.5"; //NOI18N
|
|
|
|
|
//private static final String TITAN_THEME_NAME = NbBundle.getMessage(TitanLookAndFeel.class, "LBL_TITAN");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Class provider_GIT = null;
|
|
|
|
|
private static Class provider_SVN = null;
|
|
|
|
|
private static Class provider_HG = null;
|
|
|
|
|
private static Class provider_CLASS = null;
|
|
|
|
|
private static Class provider_DIFF = null;
|
|
|
|
|
|
|
|
|
|
//private static Method provider_getInstance;
|
|
|
|
|
// private static Method provider_getColors;
|
|
|
|
|
// private static Method provider_colorsChanged;
|
|
|
|
|
|
|
|
|
|
private static Method provider_getDefault;
|
|
|
|
|
private static Method provider_getPreferences;
|
|
|
|
|
|
|
|
|
|
private static ClassLoader working_classLoader = null;
|
|
|
|
|
|
|
|
|
|
private static void extractDiffModule () throws IllegalAccessException
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (provider_DIFF != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
HashMap <String, Integer> linkMap = new HashMap<String, Integer>();
|
|
|
|
|
|
|
|
|
|
java.awt.Color nb_diff_added_color = (java.awt.Color) UIManager.get ("nb.diff.added.color");
|
|
|
|
|
@ -175,17 +152,13 @@ public class TitanEditor {
|
|
|
|
|
res += "\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (InvocationTargetException ex) {
|
|
|
|
|
Exceptions.printStackTrace(ex);
|
|
|
|
|
}
|
|
|
|
|
catch (InvocationTargetException ex) {}
|
|
|
|
|
|
|
|
|
|
res += "};\n";
|
|
|
|
|
res += "// </editor-fold>\n";
|
|
|
|
|
System.out.println(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void applyColorForDiffModule () throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
|
|
|
|
|
@ -212,10 +185,8 @@ public class TitanEditor {
|
|
|
|
|
|
|
|
|
|
getName = ANNOTATION_TYPE.getDeclaredMethod("getName", new Class[0]);
|
|
|
|
|
|
|
|
|
|
DisplayName = EDITOR_SETTINGS.getField("DisplayName"); //NOI18N
|
|
|
|
|
WaveUnderlineColor = EDITOR_SETTINGS.getField("WaveUnderlineColor"); //NOI18N
|
|
|
|
|
|
|
|
|
|
getProfiles = COLOR_MODEL.getDeclaredMethod( "getProfiles", new Class[0] ); //NOI18N
|
|
|
|
|
getCurrentProfile = COLOR_MODEL.getDeclaredMethod( "getCurrentProfile", new Class[0] ); //NOI18N
|
|
|
|
|
setCurrentProfile = COLOR_MODEL.getDeclaredMethod( "setCurrentProfile", String.class ); //NOI18N
|
|
|
|
|
|
|
|
|
|
@ -241,7 +212,6 @@ public class TitanEditor {
|
|
|
|
|
|
|
|
|
|
getLanguages = COLOR_MODEL.getDeclaredMethod( "getLanguages", new Class[0] ); //NOI18N
|
|
|
|
|
|
|
|
|
|
const_DisplayName = DisplayName.get(EDITOR_SETTINGS);
|
|
|
|
|
const_WaveUnderlineColor = WaveUnderlineColor.get(EDITOR_SETTINGS);
|
|
|
|
|
colorModel = COLOR_MODEL.newInstance();
|
|
|
|
|
|
|
|
|
|
@ -256,22 +226,23 @@ public class TitanEditor {
|
|
|
|
|
|
|
|
|
|
if (provider_CLASS != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
provider_HG = working_classLoader.loadClass(PROVIDER_HG_CLASS_NAME);
|
|
|
|
|
} catch (ClassNotFoundException ex) {}
|
|
|
|
|
}
|
|
|
|
|
catch (ClassNotFoundException ex) {}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
provider_SVN = working_classLoader.loadClass(PROVIDER_SVN_CLASS_NAME);
|
|
|
|
|
} catch (ClassNotFoundException ex) {}
|
|
|
|
|
}
|
|
|
|
|
catch (ClassNotFoundException ex) {}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
provider_GIT = working_classLoader.loadClass(PROVIDER_GIT_CLASS_NAME);
|
|
|
|
|
} catch (ClassNotFoundException ex) {}
|
|
|
|
|
|
|
|
|
|
// provider_getColors = provider_CLASS.getDeclaredMethod( "getColors", new Class[0] ); //NOI18N
|
|
|
|
|
// provider_colorsChanged = provider_CLASS.getDeclaredMethod( "colorsChanged", Map.class ); //NOI18N
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (ClassNotFoundException ex) {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
@ -294,115 +265,55 @@ public class TitanEditor {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// private static String setup_theme () throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
|
|
|
|
|
// {
|
|
|
|
|
// // String current_profile
|
|
|
|
|
////
|
|
|
|
|
//// Set<String> profile_set = (Set<String>) getProfiles.invoke( colorModel, new Object[0] );
|
|
|
|
|
//// //boolean contain_target_theme = false;
|
|
|
|
|
////// for (String str : profile_set)
|
|
|
|
|
////// {
|
|
|
|
|
////// System.out.println("> " + str);
|
|
|
|
|
//////// if (str.equals(TITAN_THEME_NAME)) contain_target_theme = true;
|
|
|
|
|
//// }
|
|
|
|
|
////
|
|
|
|
|
//// if (!contain_target_theme)
|
|
|
|
|
//// {
|
|
|
|
|
// // Ugly dublication routine, sorry NB developers...
|
|
|
|
|
//
|
|
|
|
|
// // }
|
|
|
|
|
//
|
|
|
|
|
// // setCurrentProfile.invoke(colorModel, TITAN_THEME_NAME);
|
|
|
|
|
// //}
|
|
|
|
|
// return current_profile;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// public static void remove_editor () throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
|
|
|
|
|
// {
|
|
|
|
|
// Set<String> profile_set = (Set<String>) getProfiles.invoke( colorModel, new Object[0] );
|
|
|
|
|
// boolean contain_target_theme = false;
|
|
|
|
|
// for (String str : profile_set)
|
|
|
|
|
// {
|
|
|
|
|
// if (str.equals(TITAN_THEME_NAME)) contain_target_theme = true;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (contain_target_theme)
|
|
|
|
|
// {
|
|
|
|
|
// setCurrentProfile.invoke(colorModel, TITAN_THEME_NAME);
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// setCurrentProfile.invoke(colorModel, DEFAULT_THEME_NAME);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void extractColorsForModule (String name, Class provider) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
String res = "// <editor-fold desc=\"" +name + "\" defaultstate=\"collapsed\">" +
|
|
|
|
|
"\npublic static final org.idp.laf.Color[] " + name + " = {\n";
|
|
|
|
|
|
|
|
|
|
if (provider != null)
|
|
|
|
|
{
|
|
|
|
|
Preferences forModule = NbPreferences.forModule(provider);
|
|
|
|
|
try {
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
for (String key : forModule.keys())
|
|
|
|
|
{
|
|
|
|
|
java.awt.Color cc = new java.awt.Color(Integer.parseInt(forModule.get(key, null)));
|
|
|
|
|
res += " " + (new Color(key, Color.ColorClass.AT,
|
|
|
|
|
java.awt.Color cc = new java.awt.Color(Integer.parseInt(forModule.get(key, null)));
|
|
|
|
|
res += " " + (new Color(key, Color.ColorClass.AT,
|
|
|
|
|
cc.getRed(),
|
|
|
|
|
cc.getGreen(),
|
|
|
|
|
cc.getBlue(),
|
|
|
|
|
cc.getAlpha(), "")).getString() + ",\n";
|
|
|
|
|
}
|
|
|
|
|
} catch (BackingStoreException ex) {
|
|
|
|
|
Exceptions.printStackTrace(ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (BackingStoreException ex) {}
|
|
|
|
|
}
|
|
|
|
|
res += "};\n";
|
|
|
|
|
res += "// </editor-fold>\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void applyColorForModule (Class provider, org.idp.laf.Color[] colors_theme) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (provider != null)
|
|
|
|
|
{
|
|
|
|
|
Preferences forModule = NbPreferences.forModule(provider);
|
|
|
|
|
try {
|
|
|
|
|
for (String key : forModule.keys())
|
|
|
|
|
{
|
|
|
|
|
for (org.idp.laf.Color cc : colors_theme)
|
|
|
|
|
{
|
|
|
|
|
if (cc.getName().equals(key))
|
|
|
|
|
{
|
|
|
|
|
java.awt.Color toSet = (java.awt.Color) cc.getObject();
|
|
|
|
|
forModule.put(key, String.valueOf(toSet.getRGB()));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} catch (BackingStoreException ex) {
|
|
|
|
|
Exceptions.printStackTrace(ex);
|
|
|
|
|
}
|
|
|
|
|
for (org.idp.laf.Color cc : colors_theme)
|
|
|
|
|
{
|
|
|
|
|
java.awt.Color toSet = (java.awt.Color) cc.getObject();
|
|
|
|
|
forModule.put(cc.getPname(), String.valueOf(toSet.getRGB()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void load_editor ()
|
|
|
|
|
public static void load_editor (boolean first_run)
|
|
|
|
|
{
|
|
|
|
|
if (!pre_load()) return;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
// String swith_back = (String) getCurrentProfile.invoke( colorModel, new Object[0] );
|
|
|
|
|
String swith_back = (String) getCurrentProfile.invoke( colorModel, new Object[0] );
|
|
|
|
|
|
|
|
|
|
if (no_load)
|
|
|
|
|
{
|
|
|
|
|
@ -432,54 +343,49 @@ public class TitanEditor {
|
|
|
|
|
extractColorsForModule ("SVN", provider_SVN);
|
|
|
|
|
extractColorsForModule ("HG", provider_HG);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extractDiffModule();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setCurrentProfile.invoke(colorModel, DEFAULT_THEME_NAME);
|
|
|
|
|
Collection<AttributeSet> annotations = (Collection<AttributeSet>) getAnnotations.invoke(colorModel, DEFAULT_THEME_NAME);
|
|
|
|
|
Collection<AttributeSet> annotations_upd = apply_set ("annotations", annotations, true);
|
|
|
|
|
setAnnotations.invoke(colorModel, DEFAULT_THEME_NAME, annotations_upd);
|
|
|
|
|
setCurrentProfile.invoke(colorModel, DEFAULT_THEME_NAME);
|
|
|
|
|
Collection<AttributeSet> annotations = (Collection<AttributeSet>) getAnnotations.invoke(colorModel, DEFAULT_THEME_NAME);
|
|
|
|
|
Collection<AttributeSet> annotations_upd = apply_set ("annotations", annotations, true);
|
|
|
|
|
setAnnotations.invoke(colorModel, DEFAULT_THEME_NAME, annotations_upd);
|
|
|
|
|
|
|
|
|
|
Collection<AttributeSet> highlightings = (Collection<AttributeSet>) getHighlightings.invoke(colorModel, DEFAULT_THEME_NAME);
|
|
|
|
|
Collection<AttributeSet> highlightings_upd = apply_set ("highlightings", highlightings, false);
|
|
|
|
|
setHighlightings.invoke(colorModel, DEFAULT_THEME_NAME, highlightings_upd);
|
|
|
|
|
Collection<AttributeSet> highlightings = (Collection<AttributeSet>) getHighlightings.invoke(colorModel, DEFAULT_THEME_NAME);
|
|
|
|
|
Collection<AttributeSet> highlightings_upd = apply_set ("highlightings", highlightings, false);
|
|
|
|
|
setHighlightings.invoke(colorModel, DEFAULT_THEME_NAME, highlightings_upd);
|
|
|
|
|
|
|
|
|
|
Object languages = getLanguages.invoke( colorModel, new Object[0] );
|
|
|
|
|
Set<String> languages_set = (Set<String>) languages;
|
|
|
|
|
Object languages = getLanguages.invoke( colorModel, new Object[0] );
|
|
|
|
|
Set<String> languages_set = (Set<String>) languages;
|
|
|
|
|
|
|
|
|
|
for (String str : languages_set)
|
|
|
|
|
for (String str : languages_set)
|
|
|
|
|
{
|
|
|
|
|
if (str.equals("All Languages") ||
|
|
|
|
|
str.equals("Java") ||
|
|
|
|
|
str.equals("C++") ||
|
|
|
|
|
str.equals("C"))
|
|
|
|
|
{
|
|
|
|
|
if (str.equals("All Languages") ||
|
|
|
|
|
str.equals("Java") ||
|
|
|
|
|
str.equals("C++") ||
|
|
|
|
|
str.equals("C"))
|
|
|
|
|
{
|
|
|
|
|
Collection<AttributeSet> category = (Collection<AttributeSet>) getCategories.invoke(colorModel, DEFAULT_THEME_NAME, str);
|
|
|
|
|
Collection<AttributeSet> category_upd = apply_set (str, category, false);
|
|
|
|
|
setCategories.invoke(colorModel, DEFAULT_THEME_NAME, str, category_upd);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Collection<AttributeSet> category = (Collection<AttributeSet>) getCategories.invoke(colorModel, DEFAULT_THEME_NAME, str);
|
|
|
|
|
Collection<AttributeSet> category_upd = apply_set (str, category, false);
|
|
|
|
|
setCategories.invoke(colorModel, DEFAULT_THEME_NAME, str, category_upd);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!first_run)
|
|
|
|
|
{
|
|
|
|
|
setCurrentProfile.invoke(colorModel, swith_back);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
applyColorForModule (provider_GIT, ColorTheme.GIT);
|
|
|
|
|
applyColorForModule (provider_SVN, ColorTheme.SVN);
|
|
|
|
|
applyColorForModule (provider_HG, ColorTheme.HG);
|
|
|
|
|
applyColorForModule (provider_HG, ColorTheme.HG);
|
|
|
|
|
|
|
|
|
|
applyColorForDiffModule ();
|
|
|
|
|
|
|
|
|
|
// if (!first_run)
|
|
|
|
|
// {
|
|
|
|
|
// setCurrentProfile.invoke(colorModel, swith_back);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (IllegalAccessException ex) {
|
|
|
|
|
Exceptions.printStackTrace(ex);
|
|
|
|
|
} catch (IllegalArgumentException ex) {
|
|
|
|
|
@ -537,8 +443,7 @@ public class TitanEditor {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static SimpleAttributeSet apply_colors (AttributeSetConfigured asc, AttributeSet at, boolean annotation) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
SimpleAttributeSet sas = new SimpleAttributeSet(at);
|
|
|
|
|
|
|
|
|
|
if (sas.isDefined(StyleConstants.Background)) sas.removeAttribute(StyleConstants.Background);
|
|
|
|
|
@ -560,19 +465,14 @@ public class TitanEditor {
|
|
|
|
|
if (asc.underColor != null) sas.addAttribute(const_WaveUnderlineColor, asc.underColor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object annotationType = at.getAttribute("annotationType");
|
|
|
|
|
if (annotationType != null)
|
|
|
|
|
{
|
|
|
|
|
Boolean v_isUseHighlightColor = null;
|
|
|
|
|
Boolean v_isInheritForegroundColor = null;
|
|
|
|
|
Boolean v_isUseWaveUnderlineColor = null;
|
|
|
|
|
|
|
|
|
|
if (annotation)
|
|
|
|
|
{
|
|
|
|
|
v_isUseHighlightColor = (Boolean) isUseHighlightColor.invoke(annotationType, new Object[0]);
|
|
|
|
|
v_isInheritForegroundColor = (Boolean) isInheritForegroundColor.invoke(annotationType, new Object[0]);
|
|
|
|
|
v_isUseWaveUnderlineColor = (Boolean) isUseWaveUnderlineColor.invoke(annotationType, new Object[0]);
|
|
|
|
|
Boolean v_isUseHighlightColor = (Boolean) isUseHighlightColor.invoke(annotationType, new Object[0]);
|
|
|
|
|
Boolean v_isInheritForegroundColor = (Boolean) isInheritForegroundColor.invoke(annotationType, new Object[0]);
|
|
|
|
|
Boolean v_isUseWaveUnderlineColor = (Boolean) isUseWaveUnderlineColor.invoke(annotationType, new Object[0]);
|
|
|
|
|
|
|
|
|
|
if (v_isUseHighlightColor)
|
|
|
|
|
{
|
|
|
|
|
@ -585,9 +485,7 @@ public class TitanEditor {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (v_isUseWaveUnderlineColor)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
setWaveUnderlineColor.invoke(annotationType, asc.a_getWaveUnderlineColor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -598,14 +496,11 @@ public class TitanEditor {
|
|
|
|
|
|
|
|
|
|
private static void process_set(String set_name, Collection<AttributeSet> data, boolean annotation) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("\n// <editor-fold desc=\"" +set_name + "\" defaultstate=\"collapsed\">");
|
|
|
|
|
LinkedList<AttributeSetConfigured> conf_annotations = new LinkedList<AttributeSetConfigured>();
|
|
|
|
|
|
|
|
|
|
for (AttributeSet at : data)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//String description;
|
|
|
|
|
String name = "BAD ASS";
|
|
|
|
|
Boolean v_isUseHighlightColor = null;
|
|
|
|
|
@ -615,12 +510,9 @@ public class TitanEditor {
|
|
|
|
|
java.awt.Color a_getForegroundColor = null;
|
|
|
|
|
java.awt.Color a_getWaveUnderlineColor = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (annotation)
|
|
|
|
|
{
|
|
|
|
|
Object annotationType = at.getAttribute("annotationType");
|
|
|
|
|
//System.out.println(">>> " + description + " | " + annotationType);
|
|
|
|
|
//String name = "BAD ASS";
|
|
|
|
|
if (annotationType != null)
|
|
|
|
|
{
|
|
|
|
|
name = (String) getName.invoke(annotationType, new Object[0]);
|
|
|
|
|
@ -640,24 +532,13 @@ public class TitanEditor {
|
|
|
|
|
{
|
|
|
|
|
name = (String) at.getAttribute(javax.swing.text.StyleConstants.NameAttribute);
|
|
|
|
|
}
|
|
|
|
|
// else if (type == 2)
|
|
|
|
|
// {
|
|
|
|
|
// name = (String) at.getAttribute(javax.swing.text.StyleConstants.NameAttribute);
|
|
|
|
|
// }
|
|
|
|
|
//System.out.println(type + " : " + name );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
java.awt.Color bgColor = (java.awt.Color) at.getAttribute(StyleConstants.Background);
|
|
|
|
|
java.awt.Color fgColor = (java.awt.Color) at.getAttribute(StyleConstants.Foreground);
|
|
|
|
|
java.awt.Color underColor = (java.awt.Color) at.getAttribute(const_WaveUnderlineColor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Boolean bold = (Boolean) at.getAttribute(javax.swing.text.StyleConstants.FontConstants.Bold);
|
|
|
|
|
Boolean italic = (Boolean) at.getAttribute(javax.swing.text.StyleConstants.FontConstants.Italic);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conf_annotations.add(new AttributeSetConfigured(name,
|
|
|
|
|
bgColor,
|
|
|
|
|
@ -671,7 +552,6 @@ public class TitanEditor {
|
|
|
|
|
a_getWaveUnderlineColor,
|
|
|
|
|
bold,
|
|
|
|
|
italic));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AttributeSetConfigured.compileSet(set_name, conf_annotations);
|
|
|
|
|
|