Package com.onpositive.gae.baseviewer

Source Code of com.onpositive.gae.baseviewer.OpenAction

/**
*
*/
package com.onpositive.gae.baseviewer;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PartInitException;

import com.onpositive.gae.tools.Activator;
import com.onpositive.gae.tools.GaeBridge;
import com.onpositive.gae.tools.GaeToolsViewerAction;
import com.onpositive.gae.tools.core.CheckLaunchJob;
import com.onpositive.gae.tools.deploy.BroswserEditorInput;

public final class OpenAction extends GaeToolsViewerAction implements IWorkbenchWindowActionDelegate{

  private static final String INTERNAL_BROWSER_ID = "com.onpositive.gae.tools.core.viewApplicationEditor";

  public OpenAction() {
    super("",true);
  }
 
  protected boolean isDebug() {
    boolean isLocal = com.onpositive.gae.baseviewer.Activator.getDefault()
        .getPreferenceStore().getBoolean(
            "CONNECTION_MODE");
    return isLocal;
  }

 
  protected String getUrl(CheckLaunchJob checkLaunchJob) {
    debug=isDebug();
    if (checkLaunchJob.getConfiguration() != null) {
      try {
        return super.getUrl(checkLaunchJob)
            + checkLaunchJob.getConfiguration().getAttribute(
                "com.google.gwt.eclipse.core.URL", "");
      } catch (CoreException e) {
        Activator.log(e);
      }
    }
    return super.getUrl(checkLaunchJob);
  }

  boolean shouldOpenBrowser() {
    return false;
  }

  protected void openViewer(final IJavaProject javaGaeProject,
      final String string) throws PartInitException {
    String appId = GaeBridge.getAppId(javaGaeProject.getProject());
    if (appId==null||appId.length()==0){
      MessageDialog
      .openError(
          Display.getCurrent().getActiveShell(),
          "Error",
          "Please setup application id for "
              + javaGaeProject
                  .getElementName()
              + " before using opening browser to deployed application");
      return;
    }
//    Application readApplication;
//    try {
//      readApplication = Application
//          .readApplication(javaGaeProject.getProject()
//              .get;                 
//    } catch (IOException e) {
//      Activator.log(e);
//      MessageDialog.openError(Display.getCurrent()
//          .getActiveShell(), "Error", e.getMessage());
//    }
    getPage().openEditor(new BroswserEditorInput(string, javaGaeProject),
        INTERNAL_BROWSER_ID);
  }
  public void dispose() {
    // TODO Auto-generated method stub
   
  }
  public void init(IWorkbenchWindow window) {
   
  }
  public void run(IAction action) {
    run();
  }
  public void selectionChanged(IAction action, ISelection selection) {
   
  }

}
TOP

Related Classes of com.onpositive.gae.baseviewer.OpenAction

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.