Package de.innovationgate.eclipse.wgadesigner.actions

Source Code of de.innovationgate.eclipse.wgadesigner.actions.OpenWGAAdminPage

/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.wgadesigner.actions;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.browser.IWebBrowser;

import de.innovationgate.eclipse.wgadesigner.WGADesignerPlugin;
import de.innovationgate.eclipse.wgadesigner.natures.WGARuntime;
import de.innovationgate.eclipse.wgadesigner.tomcat.TomcatUtils;

public class OpenWGAAdminPage implements IObjectActionDelegate {

  private WGARuntime _wgaRuntime;
 
  public static final String BROWSER_ID = WGADesignerPlugin.PLUGIN_ID + "browser.WGAAdminPage";

  public OpenWGAAdminPage() {
  }

  public void setActivePart(IAction action, IWorkbenchPart targetPart) {
  }

  public void run(IAction action) {
     call(_wgaRuntime);
  }

  public static void call(WGARuntime runtime) {
    try {
       if (runtime != null) {
         IWebBrowser browser = WGADesignerPlugin.getDefault().createBrowser(BROWSER_ID);
         browser.openURL(runtime.getAdminPageURL());
       }
    } catch (PartInitException e) {
      WGADesignerPlugin.getDefault().logError("Unable to open admin page.", e);
    }
  }

  public void selectionChanged(IAction action, ISelection selection) {
    action.setEnabled(false);
    _wgaRuntime = WGARuntime.fromSelection(selection);
    if (_wgaRuntime != null) {
      action.setEnabled(TomcatUtils.getInstance().isRunning(_wgaRuntime));
    }
  }

}
TOP

Related Classes of de.innovationgate.eclipse.wgadesigner.actions.OpenWGAAdminPage

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.