diff --git a/manifest.mf b/manifest.mf index 9cc33e4..5fe2932 100644 --- a/manifest.mf +++ b/manifest.mf @@ -1,7 +1,7 @@ Manifest-Version: 1.0 AutoUpdate-Show-In-Client: true OpenIDE-Module: org.idp.laf/1 -OpenIDE-Module-Implementation-Version: 1 +OpenIDE-Module-Implementation-Version: 2 OpenIDE-Module-Localizing-Bundle: org/idp/laf/Bundle.properties OpenIDE-Module-Install: org/idp/laf/Installer.class OpenIDE-Module-Requires: org.openide.windows.WindowManager diff --git a/src/org/idp/laf/Bundle.properties b/src/org/idp/laf/Bundle.properties index 6ffaf46..ab9c8c0 100644 --- a/src/org/idp/laf/Bundle.properties +++ b/src/org/idp/laf/Bundle.properties @@ -2,6 +2,5 @@ OpenIDE-Module-Display-Category=Base IDE OpenIDE-Module-Long-Description=\ This plugin was designed only to compose well readable and enoght radk theme for Netbeans, But day by day it was enlarging - and now it is what it is. OpenIDE-Module-Name=[idP!] Crew LAF -LBL_TITAN=[idP!] Titan Theme -LBL_TITAN_EDITOR=idP! +LBL_TITAN=[idP!] Titan OpenIDE-Module-Short-Description=Editor for Netbeans Metal Look and Feel diff --git a/src/org/idp/laf/Installer.java b/src/org/idp/laf/Installer.java index 967fe92..836c957 100644 --- a/src/org/idp/laf/Installer.java +++ b/src/org/idp/laf/Installer.java @@ -7,9 +7,7 @@ package org.idp.laf; import java.util.prefs.Preferences; import javax.swing.SwingUtilities; -import javax.swing.UIManager; import org.openide.modules.ModuleInstall; -import org.openide.util.NbBundle; import org.openide.util.NbPreferences; import org.openide.windows.WindowManager; @@ -18,8 +16,6 @@ import org.openide.windows.WindowManager; */ public class Installer extends ModuleInstall { - private static boolean try_to_load_companion_colors = false; - @Override public void restored() { @@ -33,14 +29,25 @@ public class Installer extends ModuleInstall } }); + final Preferences prefs = NbPreferences.root().node( "laf" ); //NOI18N + + if( !prefs.getBoolean("idp.titan_editor.installed", false) ) //NOI18N + { + WindowManager.getDefault().invokeWhenUIReady( new Runnable() + { + @Override + public void run() { + TitanEditor.load_editor(); + prefs.putBoolean("idp.titan_editor.installed", true ); //NOI18N + } + }); + + } + + + - WindowManager.getDefault().invokeWhenUIReady( new Runnable() - { - @Override - public void run() { - TitanEditor.load_editor(); - } - }); + } @@ -49,13 +56,22 @@ public class Installer extends ModuleInstall @Override public void validate() throws IllegalStateException - { - Preferences prefs = NbPreferences.root().node( "laf" ); //NOI18N - if( !prefs.getBoolean("idp.titan.installed", false) ) { //NOI18N - prefs.put( "laf", TitanLookAndFeel.class.getName() ); //NOI18N - } - prefs.putBoolean("idp.titan.installed", true ); //NOI18N + { + System.out.println(">>>> Validate"); + // Preferences prefs = NbPreferences.root().node( "laf" ); //NOI18N + // if( !prefs.getBoolean("idp.titan.installed", false) ) { //NOI18N + // prefs.put( "laf", TitanLookAndFeel.class.getName() ); //NOI18N + // } + // prefs.putBoolean("idp.titan.installed", true ); //NOI18N TitanLookAndFeel.self_install(); } + + @Override + public void uninstalled() { + System.out.println(">>>> uninstalled" ); + TitanLookAndFeel.self_remove(); +// super.uninstalled(); //To change body of generated methods, choose Tools | Templates. + + } } diff --git a/src/org/idp/laf/Kernel.java b/src/org/idp/laf/Kernel.java index 2a6146f..4eaee85 100644 --- a/src/org/idp/laf/Kernel.java +++ b/src/org/idp/laf/Kernel.java @@ -84,8 +84,8 @@ public class Kernel { private static boolean prepare_titan_laf () { - UIManager.put("nb.forceui", true); - UIManager.put("netbeans.plaf.disable.ui.customizations", false); + // UIManager.put("nb.forceui", true); + // UIManager.put("netbeans.plaf.disable.ui.customizations", false); return UIManager.getLookAndFeel().getName().equals(NbBundle.getMessage(TitanLookAndFeel.class, "LBL_TITAN")); } diff --git a/src/org/idp/laf/TitanEditor.java b/src/org/idp/laf/TitanEditor.java index 5047d36..0e61719 100644 --- a/src/org/idp/laf/TitanEditor.java +++ b/src/org/idp/laf/TitanEditor.java @@ -24,6 +24,7 @@ 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; /** @@ -91,7 +92,7 @@ public class TitanEditor { private static Object colorModel; private static final String DEFAULT_THEME_NAME = "NetBeans"; //NOI18N - private static final String TITAN_THEME_NAME = "[idP!] Titan"; //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; @@ -296,9 +297,7 @@ public class TitanEditor { private static void setup_theme () throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { String current_profile = (String) getCurrentProfile.invoke( colorModel, new Object[0] ); - // System.out.println("Current profile = " + current_profile); -// if (!current_profile.equals(TITAN_THEME_NAME)) -// { + Set profile_set = (Set) getProfiles.invoke( colorModel, new Object[0] ); boolean contain_target_theme = false; for (String str : profile_set) @@ -317,6 +316,29 @@ public class TitanEditor { //} } + public static void remove_editor () throws IllegalAccessException, IllegalArgumentException, InvocationTargetException + { + Set profile_set = (Set) 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 { diff --git a/src/org/idp/laf/TitanLookAndFeel.java b/src/org/idp/laf/TitanLookAndFeel.java index 22b4b82..e494281 100644 --- a/src/org/idp/laf/TitanLookAndFeel.java +++ b/src/org/idp/laf/TitanLookAndFeel.java @@ -5,12 +5,18 @@ */ package org.idp.laf; +import java.util.prefs.Preferences; +import javax.swing.SwingUtilities; import javax.swing.UIDefaults; import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; import javax.swing.plaf.metal.MetalLookAndFeel; import static javax.swing.plaf.metal.MetalLookAndFeel.getCurrentTheme; import static javax.swing.plaf.metal.MetalLookAndFeel.setCurrentTheme; +import org.openide.util.Exceptions; import org.openide.util.NbBundle; +import org.openide.util.NbPreferences; +import org.openide.windows.WindowManager; /** * @author Edward M. Kagan @@ -19,9 +25,63 @@ public class TitanLookAndFeel extends MetalLookAndFeel { public static void self_install () { + UIManager.LookAndFeelInfo[] installedLookAndFeels = UIManager.getInstalledLookAndFeels(); + for (UIManager.LookAndFeelInfo lafi : installedLookAndFeels) + { + String laf_name = NbBundle.getMessage(TitanLookAndFeel.class, "LBL_TITAN"); + if (lafi.getName().equals(laf_name)) + { + System.out.println("LAF Persist - no install."); + return; + } + } + System.out.print("NO LAF - installing... "); UIManager.installLookAndFeel(new UIManager.LookAndFeelInfo( NbBundle.getMessage(TitanLookAndFeel.class, "LBL_TITAN"), TitanLookAndFeel.class.getName()) ); + System.out.println("OK"); + + System.out.print("Applying LAf... "); + Preferences prefs = NbPreferences.root().node( "laf" ); //NOI18N + prefs.put( "laf", TitanLookAndFeel.class.getName() ); //NOI18N + System.out.println("OK"); } + public static void self_remove () + { + UIManager.LookAndFeelInfo[] installedLookAndFeels = UIManager.getInstalledLookAndFeels(); + + for (UIManager.LookAndFeelInfo lafi : installedLookAndFeels) + { + String laf_name = NbBundle.getMessage(TitanLookAndFeel.class, "LBL_TITAN"); + if (lafi.getName().equals(laf_name)) + { + System.out.print("LAF Persist - removing..."); + int i = 0; + UIManager.LookAndFeelInfo[] toSet = new UIManager.LookAndFeelInfo[installedLookAndFeels.length - 1]; + for (UIManager.LookAndFeelInfo copy : installedLookAndFeels) + { + if (!copy.getName().equals(laf_name)) + { + toSet[i] = copy; + i++; + } + } + UIManager.setInstalledLookAndFeels(toSet); + System.out.println("OK"); + System.out.print("Setting Metal theme by default..."); + try { + UIManager.setLookAndFeel(MetalLookAndFeel.class.getName()); + System.out.print("OK"); + } catch (Exception ex) { + Exceptions.printStackTrace(ex); + System.out.print("FAIL"); + } + return; + } + } + + System.out.println("NO LAF - nothing to remove."); + } + @Override public String getName() { return NbBundle.getMessage(TitanLookAndFeel.class, "LBL_TITAN"); diff --git a/src/org/idp/laf/TitanTheme.java b/src/org/idp/laf/TitanTheme.java index 462bc30..adcf12c 100644 --- a/src/org/idp/laf/TitanTheme.java +++ b/src/org/idp/laf/TitanTheme.java @@ -10,6 +10,7 @@ import javax.swing.UIDefaults; import javax.swing.plaf.ColorUIResource; import javax.swing.plaf.FontUIResource; import javax.swing.plaf.metal.MetalTheme; +import org.openide.util.NbBundle; /** * @author Edward M. Kagan @@ -58,7 +59,7 @@ public class TitanTheme extends MetalTheme { @Override public String getName() { - return "[idP!] Crew Titan Theme"; + return NbBundle.getMessage(TitanLookAndFeel.class, "LBL_TITAN"); } // FUCKERS - it's not obligatory to override this - IDIOTS!!!