Package net.sphene.goim.rcpreqs.installhandler

Source Code of net.sphene.goim.rcpreqs.installhandler.GOIMRCPReqsInstallHandler

/*
* File    : GOIMRCPReqsInstallHandler.java
* Created : 21.05.2006
* By      : kahless
*
* GOIM - Gamers Own Instant Messenger
* Copyright (C) 2005-2006 Herbert Poul
*              (JabberId: kahless@sphene.net / Email: herbert.poul@gmail.com)
* http://goim.sphene.net
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
*/
package net.sphene.goim.rcpreqs.installhandler;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.update.core.BaseInstallHandler;
import org.eclipse.update.core.IInstallHandler;

public class GOIMRCPReqsInstallHandler extends BaseInstallHandler implements IInstallHandler {

  /* (non-Javadoc)
   * @see org.eclipse.update.core.BaseInstallHandler#installCompleted(boolean)
   */
  @SuppressWarnings("deprecation")
  @Override
  public void installCompleted(boolean success) throws CoreException {
    super.installCompleted(success);
    Location location = Platform.getInstallLocation();
    try {
      URL url = Platform.resolve(location.getURL());
      File installLocation = null;
      try {
        installLocation = new File(url.toURI());
      } catch(Exception e) {
        e.printStackTrace();
        System.out.println("Trying from file .. : " + url.getFile());
        installLocation = new File(url.getFile());
      }
      File configIni = new File(installLocation,"configuration/config.ini");
      Properties config = new Properties();
      config.load(new FileInputStream(configIni));
      String bundles = config.getProperty("osgi.bundles");
      if(!"org.eclipse.equinox.common@2:start,org.eclipse.update.configurator@3:start,org.eclipse.core.runtime@start".equals(bundles)) {
        config.setProperty("osgi.bundles", "org.eclipse.equinox.common@2:start,org.eclipse.update.configurator@3:start,org.eclipse.core.runtime@start");
      }
      FileOutputStream out = new FileOutputStream(configIni);
      config.store(out, null);
      out.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

}
TOP

Related Classes of net.sphene.goim.rcpreqs.installhandler.GOIMRCPReqsInstallHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.