KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > text > TextEditModuleInstall


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.xml.text;
20
21 import org.openide.modules.ModuleInstall;
22 import org.openide.text.PrintSettings;
23 import org.openide.options.SystemOption;
24 import org.openide.util.*;
25
26 import org.netbeans.editor.Settings;
27
28 import org.netbeans.modules.xml.text.syntax.XMLPrintOptions;
29 import org.netbeans.modules.xml.text.syntax.DTDPrintOptions;
30 import org.netbeans.modules.xml.text.syntax.XMLSettingsInitializer;
31
32 /**
33  * Module installation class for text-edit module.
34  *
35  * @author Libor Kramolis
36  */

37 public class TextEditModuleInstall extends ModuleInstall {
38
39     public void installed() {
40         restored();
41     }
42     
43     /**
44      */

45     public void restored () {
46         restoredTextEditor();
47     }
48
49     /**
50      */

51     public void uninstalled () {
52         uninstalledTextEditor();
53     }
54
55     /**
56      */

57     public void restoredTextEditor () {
58         //layer based defaults still need it
59
Settings.addInitializer (new XMLSettingsInitializer());
60
61         // editor options
62
PrintSettings ps = (PrintSettings)PrintSettings.findObject (PrintSettings.class, true);
63         ps.addOption ((XMLPrintOptions)XMLPrintOptions.findObject(XMLPrintOptions.class, true));
64         ps.addOption ((DTDPrintOptions)DTDPrintOptions.findObject(DTDPrintOptions.class, true));
65     }
66     
67     /**
68      */

69     public void uninstalledTextEditor () {
70         // remove options
71
PrintSettings ps = (PrintSettings) PrintSettings.findObject (PrintSettings.class, true);
72         
73         SystemOption opt = (SystemOption) SystemOption.findObject (XMLPrintOptions.class, false);
74         if (opt != null)
75         ps.removeOption (opt);
76
77         opt = (SystemOption) SystemOption.findObject (DTDPrintOptions.class, false);
78         if (opt != null)
79         ps.removeOption (opt);
80         
81         //layer based defaults still need it
82
Settings.removeInitializer (XMLSettingsInitializer.NAME);
83     }
84     
85 }
86
Popular Tags