001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU General
007: * Public License Version 2 only ("GPL") or the Common Development and Distribution
008: * License("CDDL") (collectively, the "License"). You may not use this file except in
009: * compliance with the License. You can obtain a copy of the License at
010: * http://www.netbeans.org/cddl-gplv2.html or nbbuild/licenses/CDDL-GPL-2-CP. See the
011: * License for the specific language governing permissions and limitations under the
012: * License. When distributing the software, include this License Header Notice in
013: * each file and include the License file at nbbuild/licenses/CDDL-GPL-2-CP. Sun
014: * designates this particular file as subject to the "Classpath" exception as
015: * provided by Sun in the GPL Version 2 section of the License file that
016: * accompanied this code. If applicable, add the following below the License Header,
017: * with the fields enclosed by brackets [] replaced by your own identifying
018: * information: "Portions Copyrighted [year] [name of copyright owner]"
019: *
020: * Contributor(s):
021: *
022: * The Original Software is NetBeans. The Initial Developer of the Original Software
023: * is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun Microsystems, Inc. All
024: * Rights Reserved.
025: *
026: * If you wish your version of this file to be governed by only the CDDL or only the
027: * GPL Version 2, indicate your decision by adding "[Contributor] elects to include
028: * this software in this distribution under the [CDDL or GPL Version 2] license." If
029: * you do not indicate a single choice of license, a recipient has the option to
030: * distribute your version of this file under either the CDDL, the GPL Version 2 or
031: * to extend the choice of license to its licensees as provided above. However, if
032: * you add GPL Version 2 code and therefore, elected the GPL Version 2 license, then
033: * the option applies only if the new code is made subject to such option by the
034: * copyright holder.
035: */
036:
037: package org.netbeans.installer.wizard.components.panels;
038:
039: import java.awt.GridBagConstraints;
040: import java.awt.Insets;
041: import java.awt.event.ActionEvent;
042: import java.awt.event.ActionListener;
043: import java.util.List;
044: import javax.swing.border.EmptyBorder;
045: import org.netbeans.installer.product.components.Product;
046: import org.netbeans.installer.product.Registry;
047: import org.netbeans.installer.utils.ErrorManager;
048: import org.netbeans.installer.utils.LogManager;
049: import org.netbeans.installer.utils.ResourceUtils;
050: import org.netbeans.installer.utils.StringUtils;
051: import org.netbeans.installer.utils.helper.swing.NbiButton;
052: import org.netbeans.installer.utils.helper.swing.NbiLabel;
053: import org.netbeans.installer.utils.helper.swing.NbiPanel;
054: import org.netbeans.installer.utils.helper.swing.NbiTextPane;
055: import org.netbeans.installer.wizard.ui.SwingUi;
056: import org.netbeans.installer.wizard.ui.WizardUi;
057: import org.netbeans.installer.wizard.components.WizardPanel;
058: import org.netbeans.installer.wizard.containers.SwingContainer;
059: import org.netbeans.installer.wizard.utils.InstallationLogDialog;
060: import static org.netbeans.installer.utils.helper.DetailedStatus.INSTALLED_SUCCESSFULLY;
061: import static org.netbeans.installer.utils.helper.DetailedStatus.INSTALLED_WITH_WARNINGS;
062: import static org.netbeans.installer.utils.helper.DetailedStatus.FAILED_TO_INSTALL;
063: import static org.netbeans.installer.utils.helper.DetailedStatus.UNINSTALLED_SUCCESSFULLY;
064: import static org.netbeans.installer.utils.helper.DetailedStatus.UNINSTALLED_WITH_WARNINGS;
065: import static org.netbeans.installer.utils.helper.DetailedStatus.FAILED_TO_UNINSTALL;
066:
067: /**
068: *
069: * @author Kirill Sorokin
070: */
071: public class PostCreateBundleSummaryPanel extends WizardPanel {
072: /////////////////////////////////////////////////////////////////////////////////
073: // Instance
074: public PostCreateBundleSummaryPanel() {
075: setProperty(MESSAGE_SUCCESS_TEXT_PROPERTY,
076: DEFAULT_MESSAGE_SUCCESS_TEXT);
077: setProperty(MESSAGE_SUCCESS_CONTENT_TYPE_PROPERTY,
078: DEFAULT_MESSAGE_SUCCESS_CONTENT_TYPE);
079: setProperty(MESSAGE_ERRORS_TEXT_PROPERTY,
080: DEFAULT_MESSAGE_ERRORS_TEXT);
081: setProperty(MESSAGE_ERRORS_CONTENT_TYPE_PROPERTY,
082: DEFAULT_MESSAGE_ERRORS_CONTENT_TYPE);
083: setProperty(
084: SUCCESSFULLY_BUNDLED_COMPONENTS_LABEL_TEXT_PROPERTY,
085: DEFAULT_SUCCESSFULLY_BUNDLED_COMPONENTS_LABEL_TEXT);
086: setProperty(SUCCESSFULLY_BUNDLED_COMPONENTS_TEXT_PROPERTY,
087: DEFAULT_SUCCESSFULLY_BUNDLED_COMPONENTS_TEXT);
088: setProperty(
089: SUCCESSFULLY_BUNDLED_COMPONENTS_CONTENT_TYPE_PROPERTY,
090: DEFAULT_SUCCESSFULLY_BUNDLED_COMPONENTS_CONTENT_TYPE);
091: setProperty(COMPONENTS_FAILED_TO_BUNDLE_LABEL_TEXT_PROPERTY,
092: DEFAULT_COMPONENTS_FAILED_TO_BUNDLE_LABEL_TEXT);
093: setProperty(COMPONENTS_FAILED_TO_BUNDLE_TEXT_PROPERTY,
094: DEFAULT_COMPONENTS_FAILED_TO_BUNDLE_TEXT);
095: setProperty(COMPONENTS_FAILED_TO_BUNDLE_CONTENT_TYPE_PROPERTY,
096: DEFAULT_COMPONENTS_FAILED_TO_BUNDLE_CONTENT_TYPE);
097: setProperty(VIEW_LOG_BUTTON_TEXT_PROPERTY,
098: DEFAULT_VIEW_LOG_BUTTON_TEXT);
099: setProperty(SEND_LOG_BUTTON_TEXT_PROPERTY,
100: DEFAULT_SEND_LOG_BUTTON_TEXT);
101: setProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY,
102: DEFAULT_COMPONENTS_LIST_SEPARATOR);
103:
104: setProperty(TITLE_PROPERTY, DEFAULT_TITLE);
105: setProperty(DESCRIPTION_PROPERTY, DEFAULT_DESCRIPTION);
106: }
107:
108: @Override
109: public WizardUi getWizardUi() {
110: if (wizardUi == null) {
111: wizardUi = new PostCreateBundleSummaryPanelUi(this );
112: }
113:
114: return wizardUi;
115: }
116:
117: /////////////////////////////////////////////////////////////////////////////////
118: // Inner Classes
119: public static class PostCreateBundleSummaryPanelUi extends
120: WizardPanelUi {
121: protected PostCreateBundleSummaryPanel component;
122:
123: public PostCreateBundleSummaryPanelUi(
124: PostCreateBundleSummaryPanel component) {
125: super (component);
126:
127: this .component = component;
128: }
129:
130: @Override
131: public SwingUi getSwingUi(SwingContainer container) {
132: if (swingUi == null) {
133: swingUi = new PostCreateBundleSummaryPanelSwingUi(
134: component, container);
135: }
136:
137: return super .getSwingUi(container);
138: }
139: }
140:
141: public static class PostCreateBundleSummaryPanelSwingUi extends
142: WizardPanelSwingUi {
143: protected PostCreateBundleSummaryPanel component;
144:
145: private NbiTextPane messagePane;
146:
147: private NbiLabel successfullyBundledComponentsLabel;
148: private NbiTextPane successfullyBundledComponentsPane;
149: private NbiLabel componentsFailedToBundleLabel;
150: private NbiTextPane componentsFailedToBundlePane;
151:
152: private NbiButton viewLogButton;
153: private NbiButton sendLogButton;
154:
155: private NbiPanel spacer;
156:
157: private InstallationLogDialog logDialog;
158:
159: public PostCreateBundleSummaryPanelSwingUi(
160: final PostCreateBundleSummaryPanel component,
161: final SwingContainer container) {
162: super (component, container);
163:
164: this .component = component;
165:
166: initComponents();
167: }
168:
169: // protected ////////////////////////////////////////////////////////////////
170: @Override
171: protected void initializeContainer() {
172: super .initializeContainer();
173:
174: // set up the back button
175: container.getBackButton().setEnabled(false);
176:
177: // set up the next (or finish) button
178: container.getNextButton().setText(
179: component.getProperty(FINISH_BUTTON_TEXT_PROPERTY));
180:
181: // set up the cancel button
182: container.getCancelButton().setEnabled(false);
183: }
184:
185: @Override
186: protected void initialize() {
187: final Registry registry = Registry.getInstance();
188:
189: final boolean errorsEncountered = registry.getProducts(
190: FAILED_TO_INSTALL).size() > 0
191: && registry.getProducts(FAILED_TO_UNINSTALL).size() > 0;
192:
193: if (errorsEncountered) {
194: messagePane
195: .setContentType(component
196: .getProperty(MESSAGE_ERRORS_CONTENT_TYPE_PROPERTY));
197: messagePane.setText(component
198: .getProperty(MESSAGE_ERRORS_TEXT_PROPERTY));
199: } else {
200: messagePane
201: .setContentType(component
202: .getProperty(MESSAGE_SUCCESS_CONTENT_TYPE_PROPERTY));
203: messagePane.setText(component
204: .getProperty(MESSAGE_SUCCESS_TEXT_PROPERTY));
205: }
206:
207: List<Product> components;
208:
209: components = registry.getProducts(INSTALLED_SUCCESSFULLY);
210: if (components.size() > 0) {
211: successfullyBundledComponentsLabel.setVisible(true);
212: successfullyBundledComponentsPane.setVisible(true);
213:
214: successfullyBundledComponentsLabel
215: .setText(component
216: .getProperty(SUCCESSFULLY_BUNDLED_COMPONENTS_LABEL_TEXT_PROPERTY));
217: successfullyBundledComponentsPane
218: .setContentType(component
219: .getProperty(SUCCESSFULLY_BUNDLED_COMPONENTS_CONTENT_TYPE_PROPERTY));
220: successfullyBundledComponentsPane
221: .setText(StringUtils
222: .format(
223: component
224: .getProperty(SUCCESSFULLY_BUNDLED_COMPONENTS_TEXT_PROPERTY),
225: StringUtils
226: .asString(
227: components,
228: component
229: .getProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY))));
230: } else {
231: successfullyBundledComponentsLabel.setVisible(false);
232: successfullyBundledComponentsPane.setVisible(false);
233: }
234:
235: components = registry.getProducts(FAILED_TO_INSTALL);
236: if (components.size() > 0) {
237: componentsFailedToBundleLabel.setVisible(true);
238: componentsFailedToBundlePane.setVisible(true);
239:
240: componentsFailedToBundleLabel
241: .setText(component
242: .getProperty(COMPONENTS_FAILED_TO_BUNDLE_LABEL_TEXT_PROPERTY));
243: componentsFailedToBundlePane
244: .setContentType(component
245: .getProperty(COMPONENTS_FAILED_TO_BUNDLE_CONTENT_TYPE_PROPERTY));
246: componentsFailedToBundlePane
247: .setText(StringUtils
248: .format(
249: component
250: .getProperty(COMPONENTS_FAILED_TO_BUNDLE_TEXT_PROPERTY),
251: StringUtils
252: .asString(
253: components,
254: component
255: .getProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY))));
256: } else {
257: componentsFailedToBundleLabel.setVisible(false);
258: componentsFailedToBundlePane.setVisible(false);
259: }
260:
261: viewLogButton.setText(component
262: .getProperty(VIEW_LOG_BUTTON_TEXT_PROPERTY));
263: sendLogButton.setText(component
264: .getProperty(SEND_LOG_BUTTON_TEXT_PROPERTY));
265: }
266:
267: // private //////////////////////////////////////////////////////////////////
268: private void initComponents() {
269: // messagePane //////////////////////////////////////////////////////////
270: messagePane = new NbiTextPane();
271:
272: // successfullyBundledComponentsPane ////////////////////////////////////
273: successfullyBundledComponentsPane = new NbiTextPane();
274:
275: // successfullyBundledComponentsLabel ///////////////////////////////////
276: successfullyBundledComponentsLabel = new NbiLabel();
277: successfullyBundledComponentsLabel
278: .setLabelFor(successfullyBundledComponentsPane);
279:
280: // componentsFailedToBundlePane /////////////////////////////////////////
281: componentsFailedToBundlePane = new NbiTextPane();
282:
283: // componentsFailedToBundleLabel ////////////////////////////////////////
284: componentsFailedToBundleLabel = new NbiLabel();
285: componentsFailedToBundleLabel
286: .setLabelFor(componentsFailedToBundlePane);
287:
288: // viewLogButton ////////////////////////////////////////////////////////
289: viewLogButton = new NbiButton();
290: viewLogButton.addActionListener(new ActionListener() {
291: public void actionPerformed(ActionEvent event) {
292: viewLogButtonClicked();
293: }
294: });
295:
296: // sendLogButton ////////////////////////////////////////////////////////
297: sendLogButton = new NbiButton();
298: sendLogButton.addActionListener(new ActionListener() {
299: public void actionPerformed(ActionEvent event) {
300: sendLogButtonClicked();
301: }
302: });
303: sendLogButton.setEnabled(false);
304:
305: // spacer ///////////////////////////////////////////////////////////////
306: spacer = new NbiPanel();
307:
308: // this /////////////////////////////////////////////////////////////////
309: add(messagePane, new GridBagConstraints(0, 0, // x, y
310: 2, 1, // width, height
311: 1.0, 0.0, // weight-x, weight-y
312: GridBagConstraints.CENTER, // anchor
313: GridBagConstraints.BOTH, // fill
314: new Insets(11, 11, 0, 11), // padding
315: 0, 0)); // padx, pady - ???
316: add(successfullyBundledComponentsLabel,
317: new GridBagConstraints(0, 1, // x, y
318: 2, 1, // width, height
319: 1.0, 0.0, // weight-x, weight-y
320: GridBagConstraints.CENTER, // anchor
321: GridBagConstraints.BOTH, // fill
322: new Insets(15, 11, 0, 11), // padding
323: 0, 0)); // padx, pady - ???
324: add(successfullyBundledComponentsPane,
325: new GridBagConstraints(0, 2, // x, y
326: 2, 1, // width, height
327: 1.0, 0.0, // weight-x, weight-y
328: GridBagConstraints.CENTER, // anchor
329: GridBagConstraints.BOTH, // fill
330: new Insets(3, 11, 0, 11), // padding
331: 0, 0)); // padx, pady - ???
332: add(componentsFailedToBundleLabel, new GridBagConstraints(
333: 0, 3, // x, y
334: 2, 1, // width, height
335: 1.0, 0.0, // weight-x, weight-y
336: GridBagConstraints.CENTER, // anchor
337: GridBagConstraints.BOTH, // fill
338: new Insets(15, 11, 0, 11), // padding
339: 0, 0)); // padx, pady - ???
340: add(componentsFailedToBundlePane, new GridBagConstraints(0,
341: 4, // x, y
342: 2, 1, // width, height
343: 1.0, 0.0, // weight-x, weight-y
344: GridBagConstraints.CENTER, // anchor
345: GridBagConstraints.BOTH, // fill
346: new Insets(3, 11, 0, 11), // padding
347: 0, 0)); // padx, pady - ???
348: add(spacer, new GridBagConstraints(0, 5, // x, y
349: 2, 1, // width, height
350: 1.0, 1.0, // weight-x, weight-y
351: GridBagConstraints.CENTER, // anchor
352: GridBagConstraints.BOTH, // fill
353: new Insets(0, 11, 0, 11), // padding
354: 0, 0)); // padx, pady - ???
355: add(viewLogButton, new GridBagConstraints(0, 6, // x, y
356: 1, 1, // width, height
357: 0.0, 0.0, // weight-x, weight-y
358: GridBagConstraints.CENTER, // anchor
359: GridBagConstraints.NONE, // fill
360: new Insets(3, 11, 11, 0), // padding
361: 0, 0)); // padx, pady - ???
362: add(sendLogButton, new GridBagConstraints(1, 6, // x, y
363: 1, 1, // width, height
364: 1.0, 0.0, // weight-x, weight-y
365: GridBagConstraints.WEST, // anchor
366: GridBagConstraints.NONE, // fill
367: new Insets(3, 6, 11, 11), // padding
368: 0, 0)); // padx, pady - ???
369: }
370:
371: private void viewLogButtonClicked() {
372: if (LogManager.getLogFile() != null) {
373: if (logDialog == null) {
374: logDialog = new InstallationLogDialog();
375: }
376: logDialog.setVisible(true);
377: logDialog.loadLogFile();
378: } else {
379: ErrorManager.notifyError("Log file is not available.");
380: }
381: }
382:
383: private void sendLogButtonClicked() {
384: // does nothing
385: }
386: }
387:
388: /////////////////////////////////////////////////////////////////////////////////
389: // Constants
390: public static final String MESSAGE_SUCCESS_TEXT_PROPERTY = "message.success.text"; // NOI18N
391: public static final String MESSAGE_SUCCESS_CONTENT_TYPE_PROPERTY = "message.success.content.type"; // NOI18N
392: public static final String MESSAGE_ERRORS_TEXT_PROPERTY = "message.errors.text"; // NOI18N
393: public static final String MESSAGE_ERRORS_CONTENT_TYPE_PROPERTY = "message.errors.content.type"; // NOI18N
394: public static final String SUCCESSFULLY_BUNDLED_COMPONENTS_LABEL_TEXT_PROPERTY = "successfully.bundled.components.label.text"; // NOI18N
395: public static final String SUCCESSFULLY_BUNDLED_COMPONENTS_TEXT_PROPERTY = "successfully.bundled.components.text"; // NOI18N
396: public static final String SUCCESSFULLY_BUNDLED_COMPONENTS_CONTENT_TYPE_PROPERTY = "successfully.bundled.components.content.type"; // NOI18N
397: public static final String COMPONENTS_FAILED_TO_BUNDLE_LABEL_TEXT_PROPERTY = "components.failed.to.bundle.label.text"; // NOI18N
398: public static final String COMPONENTS_FAILED_TO_BUNDLE_TEXT_PROPERTY = "components.failed.to.bundle.text"; // NOI18N
399: public static final String COMPONENTS_FAILED_TO_BUNDLE_CONTENT_TYPE_PROPERTY = "components.failed.to.bundle.content.type"; // NOI18N
400: public static final String VIEW_LOG_BUTTON_TEXT_PROPERTY = "view.log.button.text"; // NOI18N
401: public static final String SEND_LOG_BUTTON_TEXT_PROPERTY = "send.log.button.text"; // NOI18N
402: public static final String COMPONENTS_LIST_SEPARATOR_PROPERTY = "components.list.separator"; // NOI18N
403:
404: public static final String DEFAULT_MESSAGE_SUCCESS_TEXT = ResourceUtils
405: .getString(PostCreateBundleSummaryPanel.class,
406: "PoCBSP.message.success.text"); // NOI18N
407: public static final String DEFAULT_MESSAGE_SUCCESS_CONTENT_TYPE = ResourceUtils
408: .getString(PostCreateBundleSummaryPanel.class,
409: "PoCBSP.message.success.content.type"); // NOI18N
410: public static final String DEFAULT_MESSAGE_ERRORS_TEXT = ResourceUtils
411: .getString(PostCreateBundleSummaryPanel.class,
412: "PoCBSP.message.errors.text"); // NOI18N
413: public static final String DEFAULT_MESSAGE_ERRORS_CONTENT_TYPE = ResourceUtils
414: .getString(PostCreateBundleSummaryPanel.class,
415: "PoCBSP.message.errors.content.type"); // NOI18N
416: public static final String DEFAULT_SUCCESSFULLY_BUNDLED_COMPONENTS_LABEL_TEXT = ResourceUtils
417: .getString(PostCreateBundleSummaryPanel.class,
418: "PoCBSP.successfully.bundled.components.label.text"); // NOI18N
419: public static final String DEFAULT_SUCCESSFULLY_BUNDLED_COMPONENTS_TEXT = ResourceUtils
420: .getString(PostCreateBundleSummaryPanel.class,
421: "PoCBSP.successfully.bundled.components.text"); // NOI18N
422: public static final String DEFAULT_SUCCESSFULLY_BUNDLED_COMPONENTS_CONTENT_TYPE = ResourceUtils
423: .getString(PostCreateBundleSummaryPanel.class,
424: "PoCBSP.successfully.bundled.components.content.type"); // NOI18N
425: public static final String DEFAULT_COMPONENTS_FAILED_TO_BUNDLE_LABEL_TEXT = ResourceUtils
426: .getString(PostCreateBundleSummaryPanel.class,
427: "PoCBSP.components.failed.to.bundle.label.text"); // NOI18N
428: public static final String DEFAULT_COMPONENTS_FAILED_TO_BUNDLE_TEXT = ResourceUtils
429: .getString(PostCreateBundleSummaryPanel.class,
430: "PoCBSP.components.failed.to.bundle.text"); // NOI18N
431: public static final String DEFAULT_COMPONENTS_FAILED_TO_BUNDLE_CONTENT_TYPE = ResourceUtils
432: .getString(PostCreateBundleSummaryPanel.class,
433: "PoCBSP.components.failed.to.bundle.content.type"); // NOI18N
434: public static final String DEFAULT_VIEW_LOG_BUTTON_TEXT = ResourceUtils
435: .getString(PostCreateBundleSummaryPanel.class,
436: "PoCBSP.view.log.button.text"); // NOI18N
437: public static final String DEFAULT_SEND_LOG_BUTTON_TEXT = ResourceUtils
438: .getString(PostCreateBundleSummaryPanel.class,
439: "PoCBSP.send.log.button.text"); // NOI18N
440: public static final String DEFAULT_COMPONENTS_LIST_SEPARATOR = ResourceUtils
441: .getString(PostCreateBundleSummaryPanel.class,
442: "PoCBSP.components.list.separator"); // NOI18N
443:
444: public static final String DEFAULT_TITLE = ResourceUtils.getString(
445: PostCreateBundleSummaryPanel.class, "PoCBSP.dialog.title"); // NOI18N
446: public static final String DEFAULT_DESCRIPTION = ResourceUtils
447: .getString(PostCreateBundleSummaryPanel.class,
448: "PoCBSP.dialog.description"); // NOI18N
449: }
|