public void init(IWorkbench workbench, IStructuredSelection selection) {
   if (selection instanceof TreeSelection) {
     try {
       TreeSelection treeSelection = (TreeSelection) selection;
       for (TreePath path : treeSelection.getPaths()) {
         for (int i = 0; i < path.getSegmentCount(); i++) {
           Object obj = path.getSegment(i);
           if (obj instanceof Category<?>) {
             setLighthouseDomain(((Category<?>) obj).getLighthouseDomain());
           }
           if (obj instanceof Operation) {
             addOperation((Operation) obj);
           }
           if (obj instanceof LighthouseDomain) {
             setLighthouseDomain((LighthouseDomain) obj);
           }
           if (obj instanceof Deployment) {
             addDeployment((Deployment) obj);
           }
         }
       }
       if (treeSelection.getPaths().length == 0
           || (selectedDeployments == null && selectedOperations == null)) {
         tryToInitFromActiveEditor();
       }
     } catch (Exception e) {
       OperationsUI.getPlugin()
           .getLog()
           .log(new Status(IStatus.ERROR, OperationsUI.PLUGIN_ID, e.getMessage(), e));
     }
   } else {
     tryToInitFromActiveEditor();
   }
 }
Beispiel #2
0
 /** Handles the verify action. Checks whether is can be done or not. */
 private void handleVerify(boolean step) {
   if (!shouldVerify()) return;
   TreeSelection s = ((TreeSelection) (fileTree.getSelection()));
   TreeProject p = (TreeProject) s.getPaths()[0].getFirstSegment();
   Object o = s.getFirstElement();
   if (!(o instanceof IFile)) return;
   VerifyJob.verify((IFile) o, p.java_project, step);
   close();
 }
  /*
   * (non-Javadoc)
   *
   * @see org.talend.designer.fileoutputxml.ui.footer.AbstractTreeNodeButton#updateButtonStatus()
   */
  @Override
  protected void updateStatus(TreeSelection selection) {
    if (selection.isEmpty()) {
      getButton().setEnabled(false);
      return;
    }
    final TreePath[] paths = selection.getPaths();
    boolean sameSegment = true;
    for (int i = 0; i < paths.length - 1; i++) {
      if (paths[i].getSegmentCount() != paths[i + 1].getSegmentCount()) {
        sameSegment = false;
      }
    }
    if (sameSegment) {
      getButton().setEnabled(true);
    } else {
      getButton().setEnabled(false);
      return;
    }

    // if same segment ,they have the same parent and parent must be an element
    final Element parent = (Element) ((FOXTreeNode) selection.getFirstElement()).getParent();
    if (parent == null) {
      getButton().setEnabled(false);
      return;
    }
    final List<? extends FOXTreeNode> attrChildren = parent.getAttributeChildren();
    final List<? extends FOXTreeNode> nameSpaceChildren = parent.getNameSpaceChildren();
    final List<FOXTreeNode> elementChildren = parent.getElementChildren();
    final Iterator iterator = selection.iterator();
    while (iterator.hasNext()) {
      final Object next = iterator.next();
      if (next instanceof Attribute) {
        if (attrChildren.contains(next) && attrChildren.indexOf(next) == 0) {
          getButton().setEnabled(false);
          return;
        }
      } else if (next instanceof NameSpaceNode) {
        if (nameSpaceChildren.contains(next) && nameSpaceChildren.indexOf(next) == 0) {
          getButton().setEnabled(false);
          return;
        }
      } else if (next instanceof Element) {
        if (elementChildren.contains(next) && elementChildren.indexOf(next) == 0) {
          getButton().setEnabled(false);
          return;
        }
      }
    }
  }
Beispiel #4
0
 public boolean equals(Object obj) {
   if (!(obj instanceof TreeSelection)) {
     // Fall back to super implementation, see bug 135837.
     return super.equals(obj);
   }
   TreeSelection selection = (TreeSelection) obj;
   int size = getPaths().length;
   if (selection.getPaths().length == size) {
     IElementComparer comparerOrNull =
         (getElementComparer() == selection.getElementComparer()) ? getElementComparer() : null;
     if (size > 0) {
       for (int i = 0; i < paths.length; i++) {
         if (!paths[i].equals(selection.paths[i], comparerOrNull)) {
           return false;
         }
       }
     }
     return true;
   }
   return false;
 }
  /**
   * the command has been executed, so extract extract the needed information from the application
   * context.
   */
  public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);

    IWorkbenchPage activePage = window.getActivePage();
    ISelection selection = activePage.getSelection();
    if (selection != null && selection instanceof ITreeSelection) {
      TreeSelection treeSelection = (TreeSelection) selection;
      TreePath[] treePaths = treeSelection.getPaths();
      TreePath treePath = treePaths[0];

      Object firstSegmentObj = treePath.getFirstSegment();

      IProject project = (IProject) ((IAdaptable) firstSegmentObj).getAdapter(IProject.class);
      String workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString();
      File projectDir = new File(workspacePath + File.separator + project.getName());

      // System.out.println("FireFox path: " + WebCLSDKPreferencePage.getFirefoxPath());
      // "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe";
      String nodejsPath = WebCLSDKPreferencePage.getNodeJSPath();
      if (nodejsPath == null || nodejsPath.isEmpty()) {
        MessageDialog.openWarning(
            window.getShell(),
            "High Web Warning - NodeJS Path",
            "NodeJS 경로가 세팅되어 있지 않습니다.\n"
                + "Window - Preferences - High Web Tool 에서 NodeJS 경로를 세팅해 주세요");
        return null;
      }

      String defaultWebBrwoserRegKey = "";
      try {
        defaultWebBrwoserRegKey =
            Utils.WindowsRegistry.getKeySz(
                Utils.WindowsRegistry.HKEY_LOCAL_MACHINE, "SOFTWARE\\Mozilla\\Firefox", "");
      } catch (java.util.prefs.BackingStoreException e) {
        try {
          defaultWebBrwoserRegKey =
              Utils.WindowsRegistry.getKeySz(
                  Utils.WindowsRegistry.HKEY_CURRENT_USER, "SOFTWARE\\Mozilla\\Firefox", "");
        } catch (java.util.prefs.BackingStoreException e1) {
          MessageDialog.openWarning(
              window.getShell(),
              "High Web Warning - Mozilla Firefox Installation",
              "Mozilla Firefox 브라우저가 설치되어 있지 않습니다.\n"
                  + "Mozilla Firefox 3.3 버전 및 Nokia WebCL Extension을 설치해 주세요");
          return null;
        }
      }

      String firefoxPath = WebCLSDKPreferencePage.getFirefoxPath();
      if (firefoxPath == null || firefoxPath.isEmpty()) {
        MessageDialog.openWarning(
            window.getShell(),
            "High Web Warning - Firefox Path",
            "Firefox 경로가 세팅되어 있지 않습니다.\n"
                + "Window - Preferences - High Web Tool 에서 Firefox 경로를 세팅해 주세요");
        return null;
      }

      ProcessBuilder pBuilder = null;

      try {
        String progFilesx86Dir = System.getenv("ProgramFiles(x86)");
        String helper =
            progFilesx86Dir
                + File.separator
                + "Mozilla Firefox"
                + File.separator
                + "uninstall"
                + File.separator
                + "helper.exe";
        pBuilder = new ProcessBuilder(new String[] {helper, "/SetAsDefaultAppUser"});
        pBuilder.redirectErrorStream(true);
        Process proc = pBuilder.start();
        proc.waitFor();
      } catch (Exception e) {
        e.printStackTrace();
      }

      try {
        Process proc = null;
        if (Activator.nodejsProcess != null && Activator.nodejsProcess.isAlive()) {
          String url = "http://localhost:4400/?enableripple=true";
          pBuilder = new ProcessBuilder(new String[] {firefoxPath, url});
          pBuilder.redirectErrorStream(true);
          proc = pBuilder.start();
        } else {
          String webContentPath = projectDir.getAbsolutePath() + File.separator + "WebContent";
          String appdata = System.getenv("APPDATA");
          String ripple =
              appdata
                  + File.separator
                  + "npm"
                  + File.separator
                  + "node_modules"
                  + File.separator
                  + "ripple-emulator"
                  + File.separator
                  + "bin"
                  + File.separator
                  + "ripple";
          String rippleArg = "emulate";
          pBuilder = new ProcessBuilder(new String[] {nodejsPath, ripple, rippleArg});
          pBuilder.redirectErrorStream(true);
          pBuilder.directory(new File(webContentPath));
          proc = pBuilder.start();
          Activator.nodejsProcess = proc;
        }
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
    return null;
  }