001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: package org.netbeans.installer;
021:
022: import com.installshield.product.service.product.ProductService;
023: import com.installshield.product.wizardbeans.DestinationPanel;
024: import com.installshield.util.Log;
025: import com.installshield.wizard.WizardBeanEvent;
026: import com.installshield.wizard.service.ServiceException;
027:
028: import java.io.File;
029:
030: public class InstallLocationPanel extends DestinationPanel {
031:
032: private static final String BUNDLE = "$L(org.netbeans.installer.Bundle,";
033:
034: public boolean queryEnter(WizardBeanEvent event) {
035: logEvent(this , Log.DBG, "queryEnter ENTER");
036: try {
037: ProductService service = (ProductService) getService(ProductService.NAME);
038: String destination = (String) service
039: .getProductBeanProperty(
040: ProductService.DEFAULT_PRODUCT_SOURCE,
041: null, "installLocation");
042:
043: if (!Util.isWindowsOS()) {
044: File root = new File("/");
045: if (!root.canWrite()) {
046: service
047: .setProductBeanProperty(
048: ProductService.DEFAULT_PRODUCT_SOURCE,
049: null,
050: "installLocation",
051: resolveString(BUNDLE
052: + "Product.installLocationForNonRoot)"));
053: }
054: } else {
055: service.setProductBeanProperty(
056: ProductService.DEFAULT_PRODUCT_SOURCE, null,
057: "installLocation", resolveString(BUNDLE
058: + "Product.installLocationWindows)"));
059: }
060: } catch (ServiceException e) {
061: logEvent(this , Log.ERROR, e);
062: }
063:
064: return super .queryEnter(event);
065: }
066:
067: public void exited(WizardBeanEvent event) {
068: logEvent(this , Log.DBG, "exited ENTER");
069: super .exited(event);
070: try {
071: //Set install location for storage builder
072: ProductService service = (ProductService) getService(ProductService.NAME);
073: String productDestination = (String) service
074: .getProductBeanProperty(
075: ProductService.DEFAULT_PRODUCT_SOURCE,
076: null, "installLocation");
077: logEvent(this , Log.DBG, "exited productDestination: "
078: + productDestination);
079: } catch (ServiceException e) {
080: logEvent(this , Log.ERROR, e);
081: }
082: }
083:
084: public void execute(WizardBeanEvent event) {
085: logEvent(this , Log.DBG, "execute ENTER");
086: super .execute(event);
087: try {
088: //Set install location for storage builder
089: ProductService service = (ProductService) getService(ProductService.NAME);
090: String productDestination = (String) service
091: .getProductBeanProperty(
092: ProductService.DEFAULT_PRODUCT_SOURCE,
093: null, "installLocation");
094: logEvent(this , Log.DBG, "execute productDestination: "
095: + productDestination);
096: } catch (ServiceException e) {
097: logEvent(this, Log.ERROR, e);
098: }
099: }
100:
101: }
|