Example #1
0
 /**
  * returns the protocol prefix for deployments like WRAP: or WAR:
  *
  * @param module
  * @return
  */
 private static String getProtocolPrefixForModule(IModule module) throws CoreException {
   String packaging = getPackaging(module);
   if (Strings.isBlank(packaging) || packaging.equalsIgnoreCase(PACKAGING_JAR)) {
     return PROTOCOL_PREFIX_JAR;
   } else if (packaging.equalsIgnoreCase(PACKAGING_BUNDLE)) {
     return PROTOCOL_PREFIX_OSGI;
   } else if (packaging.equalsIgnoreCase(PACKAGING_WAR)) {
     return PROTOCOL_PREFIX_WEB;
   } else {
     return PROTOCOL_PREFIX_JAR;
   }
 }
  /** /!\ Public for test purpose */
  public void validate() {
    // if runtime is selected other than NO RUNTIME
    if (getSelectedRuntime() != null) {
      // determine the camel version of that runtime
      String runtimeCamelVersion = determineRuntimeCamelVersion(getSelectedRuntime());

      if (UNKNOWN_CAMEL_VERSION.equals(runtimeCamelVersion)) {
        if (!Widgets.isDisposed(camelVersionCombo)) {
          camelVersionCombo.setEnabled(true);
        }
        camelInfoText.setText(
            Messages
                .FuseIntegrationProjectWizardRuntimeAndCamelPage_WarningMessageWhenCamelVersionCannotBeDeterminedInRuntime);
      } else {
        // and compare if selected camel version fits that version
        if (!isCompatible(runtimeCamelVersion, getSelectedCamelVersion())) {
          // Display warning and suggest the correct version
          camelInfoText.setText(
              NLS.bind(
                  Messages.newProjectWizardRuntimePageCamelVersionsDontMatchWarning,
                  runtimeCamelVersion));
        } else {
          camelInfoText.setText(""); // $NON-NLS-1$
        }
        if (!Widgets.isDisposed(camelVersionCombo)) {
          camelVersionCombo.setEnabled(false);
        }
      }
    } else {
      if (!Widgets.isDisposed(camelVersionCombo)) {
        camelVersionCombo.setEnabled(true);
      }

      if (!Widgets.isDisposed(camelInfoText)) {
        camelInfoText.setText(""); // $NON-NLS-1$
      }
    }
    // TODO: leaving that out until we decide to support other camel versions than the ones we ship
    //		try {
    //			getWizard().getContainer().run(false, false, new IRunnableWithProgress() {
    //				@Override
    //				public void run(IProgressMonitor monitor) throws InvocationTargetException,
    // InterruptedException {
    //					monitor.beginTask(Messages.newProjectWizardRuntimePageResolveDependencyStatus,
    // IProgressMonitor.UNKNOWN);
    //					validateCamelVersion();
    //					monitor.done();
    //				}
    //			});
    //		} catch (Exception ex) {
    //			ProjectTemplatesActivator.pluginLog().logError(ex);
    //		}

    if (!Widgets.isDisposed(warningIconLabel) && !Widgets.isDisposed(camelInfoText)) {
      warningIconLabel.setVisible(!camelInfoText.getText().isEmpty());
    }

    if (!Widgets.isDisposed(runtimeComboViewer) && !Widgets.isDisposed(camelVersionCombo)) {
      setPageComplete(
          !Strings.isBlank(runtimeComboViewer.getSelection().toString())
              && !Strings.isBlank(camelVersionCombo.getText())
              && !warningIconLabel.isVisible());
    }
  }