Remove of LAF - fixed, now switch back to Metall if removed

master
Wizard Atman 11 years ago
parent 3bc3f0b215
commit 4ab179f3a9

@ -1,7 +1,7 @@
Manifest-Version: 1.0 Manifest-Version: 1.0
AutoUpdate-Show-In-Client: true AutoUpdate-Show-In-Client: true
OpenIDE-Module: org.idp.laf/1 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-Localizing-Bundle: org/idp/laf/Bundle.properties
OpenIDE-Module-Install: org/idp/laf/Installer.class OpenIDE-Module-Install: org/idp/laf/Installer.class
OpenIDE-Module-Requires: org.openide.windows.WindowManager OpenIDE-Module-Requires: org.openide.windows.WindowManager

@ -2,6 +2,5 @@ OpenIDE-Module-Display-Category=Base IDE
OpenIDE-Module-Long-Description=\ 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. 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 OpenIDE-Module-Name=[idP!] Crew LAF
LBL_TITAN=[idP!] Titan Theme LBL_TITAN=[idP!] Titan
LBL_TITAN_EDITOR=idP!
OpenIDE-Module-Short-Description=Editor for Netbeans Metal Look and Feel OpenIDE-Module-Short-Description=Editor for Netbeans Metal Look and Feel

@ -7,9 +7,7 @@ package org.idp.laf;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import org.openide.modules.ModuleInstall; import org.openide.modules.ModuleInstall;
import org.openide.util.NbBundle;
import org.openide.util.NbPreferences; import org.openide.util.NbPreferences;
import org.openide.windows.WindowManager; import org.openide.windows.WindowManager;
@ -18,8 +16,6 @@ import org.openide.windows.WindowManager;
*/ */
public class Installer extends ModuleInstall public class Installer extends ModuleInstall
{ {
private static boolean try_to_load_companion_colors = false;
@Override @Override
public void restored() { public void restored() {
@ -33,14 +29,25 @@ public class Installer extends ModuleInstall
} }
}); });
final Preferences prefs = NbPreferences.root().node( "laf" ); //NOI18N
WindowManager.getDefault().invokeWhenUIReady( new Runnable() if( !prefs.getBoolean("idp.titan_editor.installed", false) ) //NOI18N
{ {
@Override WindowManager.getDefault().invokeWhenUIReady( new Runnable()
public void run() { {
TitanEditor.load_editor(); @Override
} public void run() {
}); TitanEditor.load_editor();
prefs.putBoolean("idp.titan_editor.installed", true ); //NOI18N
}
});
}
} }
@ -50,12 +57,21 @@ public class Installer extends ModuleInstall
@Override @Override
public void validate() throws IllegalStateException public void validate() throws IllegalStateException
{ {
Preferences prefs = NbPreferences.root().node( "laf" ); //NOI18N System.out.println(">>>> Validate");
if( !prefs.getBoolean("idp.titan.installed", false) ) { //NOI18N // Preferences prefs = NbPreferences.root().node( "laf" ); //NOI18N
prefs.put( "laf", TitanLookAndFeel.class.getName() ); //NOI18N // if( !prefs.getBoolean("idp.titan.installed", false) ) { //NOI18N
} // prefs.put( "laf", TitanLookAndFeel.class.getName() ); //NOI18N
prefs.putBoolean("idp.titan.installed", true ); //NOI18N // }
// prefs.putBoolean("idp.titan.installed", true ); //NOI18N
TitanLookAndFeel.self_install(); 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.
}
} }

@ -84,8 +84,8 @@ public class Kernel {
private static boolean prepare_titan_laf () private static boolean prepare_titan_laf ()
{ {
UIManager.put("nb.forceui", true); // UIManager.put("nb.forceui", true);
UIManager.put("netbeans.plaf.disable.ui.customizations", false); // UIManager.put("netbeans.plaf.disable.ui.customizations", false);
return UIManager.getLookAndFeel().getName().equals(NbBundle.getMessage(TitanLookAndFeel.class, "LBL_TITAN")); return UIManager.getLookAndFeel().getName().equals(NbBundle.getMessage(TitanLookAndFeel.class, "LBL_TITAN"));
} }

@ -24,6 +24,7 @@ import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants; import javax.swing.text.StyleConstants;
import org.openide.util.Exceptions; import org.openide.util.Exceptions;
import org.openide.util.Lookup; import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.util.NbPreferences; import org.openide.util.NbPreferences;
/** /**
@ -91,7 +92,7 @@ public class TitanEditor {
private static Object colorModel; private static Object colorModel;
private static final String DEFAULT_THEME_NAME = "NetBeans"; //NOI18N 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_GIT = null;
private static Class provider_SVN = null; private static Class provider_SVN = null;
@ -296,9 +297,7 @@ public class TitanEditor {
private static void setup_theme () throws IllegalAccessException, IllegalArgumentException, InvocationTargetException private static void setup_theme () throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
{ {
String current_profile = (String) getCurrentProfile.invoke( colorModel, new Object[0] ); 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<String> profile_set = (Set<String>) getProfiles.invoke( colorModel, new Object[0] ); Set<String> profile_set = (Set<String>) getProfiles.invoke( colorModel, new Object[0] );
boolean contain_target_theme = false; boolean contain_target_theme = false;
for (String str : profile_set) for (String str : profile_set)
@ -317,6 +316,29 @@ public class TitanEditor {
//} //}
} }
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 private static void extractColorsForModule (String name, Class provider) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
{ {

@ -5,12 +5,18 @@
*/ */
package org.idp.laf; package org.idp.laf;
import java.util.prefs.Preferences;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults; import javax.swing.UIDefaults;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.metal.MetalLookAndFeel; import javax.swing.plaf.metal.MetalLookAndFeel;
import static javax.swing.plaf.metal.MetalLookAndFeel.getCurrentTheme; import static javax.swing.plaf.metal.MetalLookAndFeel.getCurrentTheme;
import static javax.swing.plaf.metal.MetalLookAndFeel.setCurrentTheme; import static javax.swing.plaf.metal.MetalLookAndFeel.setCurrentTheme;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.util.NbPreferences;
import org.openide.windows.WindowManager;
/** /**
* @author Edward M. Kagan <pagan@idp-crew.com> * @author Edward M. Kagan <pagan@idp-crew.com>
@ -19,7 +25,61 @@ public class TitanLookAndFeel extends MetalLookAndFeel {
public static void self_install () 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()) ); 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 @Override

@ -10,6 +10,7 @@ import javax.swing.UIDefaults;
import javax.swing.plaf.ColorUIResource; import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.FontUIResource; import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.metal.MetalTheme; import javax.swing.plaf.metal.MetalTheme;
import org.openide.util.NbBundle;
/** /**
* @author Edward M. Kagan <pagan@idp-crew.com> * @author Edward M. Kagan <pagan@idp-crew.com>
@ -58,7 +59,7 @@ public class TitanTheme extends MetalTheme {
@Override @Override
public String getName() { public String getName() {
return "[idP!] Crew Titan Theme"; return NbBundle.getMessage(TitanLookAndFeel.class, "LBL_TITAN");
} }
// FUCKERS - it's not obligatory to override this - IDIOTS!!! // FUCKERS - it's not obligatory to override this - IDIOTS!!!

Loading…
Cancel
Save