コード例 #1
0
  protected boolean resolvePage(String contextId, boolean endpoint) {
    String contextName = contextId;
    IContext context = HelpSystem.getContext(contextName);
    if (context == null) {
      if (endpoint) {
        contextName = "org.fusesource.ide.camel.editor.endpoint";
      } else {
        contextName = "org.fusesource.ide.camel.editor.allEIPs";
        context = HelpSystem.getContext("");
      }
      context = HelpSystem.getContext(contextName);

      // Activator.getLogger().debug("Context ID " + contextId +
      // " is bad using default.");
    }
    if (context == null) {
      Activator.getLogger().warning("Could not find context: " + contextName);
      return false;
    }
    IHelpResource[] relatedTopics = context.getRelatedTopics();
    if (relatedTopics != null && relatedTopics.length > 0) {
      IHelpResource resource = relatedTopics[0];
      if (resource != null) {
        String helpUrl = resource.getHref();
        IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
        URL url = helpSystem.resolve(helpUrl, true);
        return browser.setUrl(url.toExternalForm());
      }
    }
    Activator.getLogger().warning("Could not find resource in context: " + contextName);
    return false;
  }
コード例 #2
0
ファイル: Util.java プロジェクト: dargoner/fuseide
 public static String getCamelVersion(IProject project) {
   IPath pomPathValue =
       project.getProject().getRawLocation() != null
           ? project.getProject().getRawLocation().append("pom.xml")
           : ResourcesPlugin.getWorkspace()
               .getRoot()
               .getLocation()
               .append(project.getFullPath().append("pom.xml"));
   String pomPath = pomPathValue.toOSString();
   final File pomFile = new File(pomPath);
   try {
     final org.apache.maven.model.Model model = MavenPlugin.getMaven().readModel(pomFile);
     List<org.apache.maven.model.Dependency> deps = model.getDependencies();
     for (Iterator<org.apache.maven.model.Dependency> iterator = deps.iterator();
         iterator.hasNext(); ) {
       org.apache.maven.model.Dependency dependency = iterator.next();
       if (dependency.getArtifactId().equals("camel-core")) {
         return dependency.getVersion();
       }
     }
   } catch (CoreException e) {
     // not found, go with default
   }
   return org.fusesource.ide.camel.editor.Activator.getDefault().getCamelVersion();
 }
コード例 #3
0
ファイル: DetailsSection.java プロジェクト: niwashun/fuseide
 public void bindNestedComplexProperties(
     FormToolkit toolkit,
     final IMessageManager mmng,
     IPropertyDescriptor complexProperty,
     Class<?> complexType,
     Composite sectionClient,
     Object value) {
   try {
     boolean useMethods = JaxbHelper.useMethodReflection(complexType);
     BeanInfo beanInfo = Introspector.getBeanInfo(complexType);
     PropertyDescriptor[] properties = beanInfo.getPropertyDescriptors();
     for (PropertyDescriptor property : properties) {
       Method getter = property.getReadMethod();
       Method setter = property.getWriteMethod();
       if (getter != null && setter != null) {
         String propertyName = property.getName();
         if (useMethods) {
           if (!JaxbHelper.hasXmlAnnotation(getter) && !JaxbHelper.hasXmlAnnotation(setter)) {
             continue;
           }
         } else {
           // lets look for the field
           try {
             Field field = complexType.getDeclaredField(propertyName);
             if (!JaxbHelper.hasXmlAnnotation(field)) {
               continue;
             }
           } catch (Exception e) {
             Activator.getLogger()
                 .debug("Failed to find field: " + propertyName + " on " + complexType.getName());
             continue;
           }
         }
         bindNestedPojoProperty(
             toolkit, mmng, complexProperty, sectionClient, value, property, complexType);
       }
     }
   } catch (IntrospectionException e) {
     Activator.getLogger()
         .warning("Failed to introspect " + complexType.getName() + ". Reason: " + e, e);
   }
 }
コード例 #4
0
ファイル: DetailsSection.java プロジェクト: niwashun/fuseide
 protected Object[] getEnumValues(Class<? extends Enum> enumType) {
   try {
     Method method = enumType.getMethod("values");
     Object result = method.invoke(null);
     if (result instanceof Object[]) {
       return (Object[]) result;
     }
   } catch (Exception e) {
     Activator.getLogger().warning("Failed to get enum values from " + enumType, e);
   }
   return EMPTY_STRING_ARRAY;
 }
コード例 #5
0
ファイル: AddNodeCommand.java プロジェクト: niwashun/fuseide
 @Override
 protected void doExecute() {
   CreateNodeConnectionFeature feature =
       new CreateNodeConnectionFeature(editor.getFeatureProvider(), aClass);
   PictogramElement selectedElement =
       editor.getFeatureProvider().getPictogramElementForBusinessObject(selectedNode);
   PictogramElement[] selectedElements;
   if (selectedElement != null) {
     selectedElements = new PictogramElement[] {selectedElement};
   } else {
     Activator.getLogger()
         .debug(
             "==== TODO - could not find PictogramElement for node "
                 + selectedNode
                 + " probably its that the RiderOutlinePage is out of sync with the Diagram model!");
     selectedElements = editor.getSelectedPictogramElements();
   }
   CustomContext context = new CustomContext(selectedElements);
   feature.execute(context);
 }
コード例 #6
0
 protected void showDocumentationPage() {
   if (node != null) {
     boolean loadedPage = false;
     // lets see if we can find the docs for an endpoints URI...
     if (node instanceof Endpoint) {
       Endpoint endpoint = (Endpoint) node;
       String uri = endpoint.getUri();
       if (uri != null) {
         int idx = uri.indexOf(':');
         if (idx > 0) {
           String scheme = uri.substring(0, idx);
           String contextId = "org.fusesource.ide.camel.editor." + scheme;
           // Activator.getLogger().debug("Resolving context ID:" +
           // contextId);
           loadedPage = resolvePage(contextId, true);
           Activator.getLogger().debug("Loaded page " + contextId + " " + loadedPage);
         }
       }
     }
     if (!loadedPage) {
       String text = node.getDocumentationFileName();
       String uri = "org.fusesource.ide.camel.editor.allEIPs";
       if (text != null) {
         uri = "org.fusesource.ide.camel.editor." + text;
       }
       // Activator.getLogger().debug("Resolving context ID:" + uri);
       resolvePage(uri, false);
     }
     // browser.layout();
   } else {
     // lets zap the old form
   }
   /*
    * browser.layout(); browser.pack(); parent.pack();
    */
 }
コード例 #7
0
ファイル: MavenUtils.java プロジェクト: prabalrakshit/fuseide
  /**
   * checks if we need to add a maven dependency for the chosen component and inserts it into the
   * pom.xml if needed
   */
  public static void updateMavenDependencies(
      List<org.fusesource.ide.camel.model.catalog.Dependency> compDeps) throws CoreException {
    RiderDesignEditor editor = Activator.getDiagramEditor();
    if (editor == null) {
      Activator.getLogger()
          .error(
              "Unable to add component dependencies because Editor instance can't be determined.");
      return;
    }

    IProject project = editor.getCamelContextFile().getProject();
    if (project == null) {
      Activator.getLogger()
          .error(
              "Unable to add component dependencies because selected project can't be determined.");
      return;
    }

    IPath pomPathValue =
        project.getProject().getRawLocation() != null
            ? project.getProject().getRawLocation().append("pom.xml")
            : ResourcesPlugin.getWorkspace()
                .getRoot()
                .getLocation()
                .append(project.getFullPath().append("pom.xml"));
    String pomPath = pomPathValue.toOSString();
    final File pomFile = new File(pomPath);
    final Model model = MavenPlugin.getMaven().readModel(pomFile);

    // then check if component dependency is already a dep
    ArrayList<org.fusesource.ide.camel.model.catalog.Dependency> missingDeps =
        new ArrayList<org.fusesource.ide.camel.model.catalog.Dependency>();
    List<Dependency> deps = model.getDependencies();
    for (org.fusesource.ide.camel.model.catalog.Dependency conDep : compDeps) {
      boolean found = false;
      for (Dependency pomDep : deps) {
        if (pomDep.getGroupId().equalsIgnoreCase(conDep.getGroupId())
            && pomDep.getArtifactId().equalsIgnoreCase(conDep.getArtifactId())) {
          // check for correct version
          if (pomDep.getVersion().equalsIgnoreCase(conDep.getVersion()) == false) {
            // not the correct version - change it to fit
            pomDep.setVersion(conDep.getVersion());
          }
          found = true;
          break;
        }
      }
      if (!found) {
        missingDeps.add(conDep);
      }
    }

    for (org.fusesource.ide.camel.model.catalog.Dependency missDep : missingDeps) {
      Dependency dep = new Dependency();
      dep.setGroupId(missDep.getGroupId());
      dep.setArtifactId(missDep.getArtifactId());
      dep.setVersion(missDep.getVersion());
      model.addDependency(dep);
    }

    if (missingDeps.size() > 0) {
      OutputStream os = null;
      try {
        os = new BufferedOutputStream(new FileOutputStream(pomFile));
        MavenPlugin.getMaven().writeModel(model, os);
        IFile pomIFile = project.getProject().getFile("pom.xml");
        if (pomIFile != null) {
          pomIFile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
        }
      } catch (Exception ex) {
        Activator.getLogger().error(ex);
      } finally {
        try {
          if (os != null) {
            os.close();
          }
        } catch (IOException e) {
          Activator.getLogger().error(e);
        }
      }
    }
  }