01: /*
02: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
03: *
04: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
05: *
06: * The contents of this file are subject to the terms of either the GNU General
07: * Public License Version 2 only ("GPL") or the Common Development and Distribution
08: * License("CDDL") (collectively, the "License"). You may not use this file except in
09: * compliance with the License. You can obtain a copy of the License at
10: * http://www.netbeans.org/cddl-gplv2.html or nbbuild/licenses/CDDL-GPL-2-CP. See the
11: * License for the specific language governing permissions and limitations under the
12: * License. When distributing the software, include this License Header Notice in
13: * each file and include the License file at nbbuild/licenses/CDDL-GPL-2-CP. Sun
14: * designates this particular file as subject to the "Classpath" exception as
15: * provided by Sun in the GPL Version 2 section of the License file that
16: * accompanied this code. If applicable, add the following below the License Header,
17: * with the fields enclosed by brackets [] replaced by your own identifying
18: * information: "Portions Copyrighted [year] [name of copyright owner]"
19: *
20: * Contributor(s):
21: *
22: * The Original Software is NetBeans. The Initial Developer of the Original Software
23: * is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun Microsystems, Inc. All
24: * Rights Reserved.
25: *
26: * If you wish your version of this file to be governed by only the CDDL or only the
27: * GPL Version 2, indicate your decision by adding "[Contributor] elects to include
28: * this software in this distribution under the [CDDL or GPL Version 2] license." If
29: * you do not indicate a single choice of license, a recipient has the option to
30: * distribute your version of this file under either the CDDL, the GPL Version 2 or
31: * to extend the choice of license to its licensees as provided above. However, if
32: * you add GPL Version 2 code and therefore, elected the GPL Version 2 license, then
33: * the option applies only if the new code is made subject to such option by the
34: * copyright holder.
35: */
36:
37: package org.netbeans.installer.wizard.components.actions;
38:
39: import org.netbeans.installer.product.Registry;
40: import org.netbeans.installer.utils.StringUtils;
41: import org.netbeans.installer.utils.helper.ErrorLevel;
42: import org.netbeans.installer.utils.ErrorManager;
43: import org.netbeans.installer.utils.ResourceUtils;
44: import org.netbeans.installer.utils.exceptions.InitializationException;
45: import org.netbeans.installer.utils.progress.Progress;
46: import org.netbeans.installer.wizard.components.WizardAction;
47:
48: /**
49: *
50: * @author Kirill Sorokin
51: */
52: public class InitializeRegistryAction extends WizardAction {
53: /////////////////////////////////////////////////////////////////////////////////
54: // Instance
55: public InitializeRegistryAction() {
56: setProperty(TITLE_PROPERTY, DEFAULT_TITLE);
57: setProperty(DESCRIPTION_PROPERTY, DEFAULT_DESCRIPTION);
58: setProperty(REGISTRY_INITIALIZATION_FAILED_PROPERTY,
59: DEFAULT_REGISTRY_INITIALIZATION_FAILED_MESSAGE);
60: }
61:
62: public void execute() {
63: try {
64: final Progress progress = new Progress();
65:
66: getWizardUi().setProgress(progress);
67: Registry.getInstance().initializeRegistry(progress);
68: } catch (InitializationException e) {
69: ErrorManager
70: .notifyCritical(
71: StringUtils
72: .format(getProperty(REGISTRY_INITIALIZATION_FAILED_PROPERTY)),
73: e);
74: }
75: }
76:
77: @Override
78: public boolean isCancelable() {
79: return false;
80: }
81:
82: /////////////////////////////////////////////////////////////////////////////////
83: // Constants
84: public static final String DEFAULT_TITLE = ResourceUtils.getString(
85: InitializeRegistryAction.class, "IRA.title"); // NOI18N
86: public static final String DEFAULT_DESCRIPTION = ResourceUtils
87: .getString(InitializeRegistryAction.class,
88: "IRA.description"); // NOI18N
89: public static final String DEFAULT_REGISTRY_INITIALIZATION_FAILED_MESSAGE = ResourceUtils
90: .getString(InitializeRegistryAction.class,
91: "IRA.registry.initialization.failed"); // NOI18N
92: public static final String REGISTRY_INITIALIZATION_FAILED_PROPERTY = "registry.initialization.failed"; // NOI18N
93:
94: }
|