Ejemplo n.º 1
0
  /**
   * Starts a protocol, taking part as client in the communication
   *
   * @param allMessages A map containing all messages that belong to the protocol. The message code
   *     as key
   * @param incomingMessages A collection containing the message ids of all incoming messages. The
   *     message ids much match the id field in a ProtocolMsgDefinition object from the allMessages
   *     map
   * @param outgoingMessages A collection containing the message ids of all outgoing messages. The
   *     message ids much match the id field in a ProtocolMsgDefinition object from the allMessages
   *     map
   * @param protocolInitializer The sequence of steps to execute for connection initialization
   * @param isBigEndianProtocol True if the protocol is big endian, false if little endian
   * @param host The host where the server is running
   * @param port The ported where the server is listening for requests at host
   * @param parameters A Map with parameters other than host and port, for customization purposes.
   *     Accepts null if apply.
   * @return A handle to identify the connection just made
   */
  public static ProtocolHandle requestStartProtocolAsClient(
      Map<Long, ProtocolMsgDefinition> allMessages,
      Collection<String> incomingMessages,
      Collection<String> outgoingMessages,
      IProtocolHandshake protocolInitializer,
      IProtocolExceptionHandler exceptionHandler,
      Boolean isBigEndianProtocol,
      String host,
      int port,
      Map<String, Object> parameters) {

    BasePlugin.logDebugMessage(
        "ProtocolActionDelegate",
        "An user is requesting to start a client protocol. host=" + host + "; port=" + port + ".");
    ClientModel model = ClientModel.getInstance();
    return model.requestStartProtocol(
        allMessages,
        incomingMessages,
        outgoingMessages,
        protocolInitializer,
        exceptionHandler,
        isBigEndianProtocol,
        host,
        port,
        parameters);
  }
Ejemplo n.º 2
0
  /**
   * Stops the provided protocol instance
   *
   * @param handle An object provided at the connection time, that identifies the connection that is
   *     to be stopped
   */
  public static void requestStopProtocol(ProtocolHandle handle) {

    BasePlugin.logDebugMessage(
        "ProtocolActionDelegate",
        "A user is requesting to stop the protocol identified by " + handle);
    ClientModel clientModel = ClientModel.getInstance();
    clientModel.requestStopProtocol(handle);

    ServerModel serverModel = ServerModel.getInstance();
    serverModel.stopListeningToPort(handle);
  }
Ejemplo n.º 3
0
  /**
   * Restarts the provided protocol instance
   *
   * @param handle An object provided at the connection time, that identifies the connection that is
   *     to be restarted
   */
  public static void requestRestartProtocol(ProtocolHandle handle) {

    BasePlugin.logDebugMessage(
        "ProtocolActionDelegate",
        "An user is requesting to restart the protocol identified by " + handle);

    ClientModel clientModel = ClientModel.getInstance();
    clientModel.requestRestartProtocol(handle);

    ServerModel serverModel = ServerModel.getInstance();
    serverModel.requestRestartProtocol(handle);
  }
Ejemplo n.º 4
0
  /**
   * Translate the string passed as parameter
   *
   * @param string string to translate
   * @param fromLanguage language ID to translate from
   * @param toLanguage language ID to translate to
   * @return a TranslationResult object with information about the translation
   */
  public TranslationResult translate(String string, String fromLanguage, String toLanguage) {

    TranslationResult translationResults = null;

    ITranslator translator = preferencesManager.getDefaultTranslator();

    try {
      translationResults = translator.translate(string, fromLanguage, toLanguage);
    } catch (Exception e) {
      BasePlugin.logError(Messages.TranslatorManager_1);
    }

    return translationResults;
  }
Ejemplo n.º 5
0
  /**
   * Translate all strings passed as parameter
   *
   * @param strings strings to translate
   * @param fromLanguage language ID to translate from
   * @param toLanguage language ID to translate to
   * @return a TranslationResult object with information about the translation
   */
  public List<TranslationResult> translateAll(
      List<String> strings, String fromLanguage, String toLanguage) {

    List<TranslationResult> translationResults = null;

    ITranslator translator = preferencesManager.getDefaultTranslator();

    try {
      translationResults = translator.translateAll(strings, fromLanguage, toLanguage, null);
    } catch (Exception e) {
      BasePlugin.logError(Messages.TranslatorManager_2);
    }

    return translationResults;
  }
 @Override
 public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
   try {
     getEditorInput().revert(actualState.getId());
   } catch (IOException e) {
     BasePlugin.logError("Error reverting column: " + actualState.getId(), e);
   }
   savedState =
       new ColumnInfo(
           actualState.getId(),
           actualState.getTooltip(),
           getEditorInput().getValues(actualState.getId()),
           actualState.canRemove());
   return redo(monitor, info);
 }
Ejemplo n.º 7
0
  private static ContentProvider createContentProviderFromElement(IConfigurationElement element) {
    ContentProvider contentProvider = null;
    String contextHelpID = null;
    Object inputClazz = null;
    Object opClazz = null;
    Object cellValidator = null;

    try {
      inputClazz = element.createExecutableExtension(PROVIDER_EDITOR_INPUT_ID);

      opClazz = element.createExecutableExtension(PROVIDER_OPERATION_PROV_ID);
      cellValidator = element.createExecutableExtension(PROVIDER_CELL_VALIDATOR_ID);
      contextHelpID = element.getAttribute(PROVIDER_EDITOR_CONTEXT_HELP_ID);

    } catch (CoreException e) {
      BasePlugin.logWarning(
          "No operation provider found for "
              + element.getDeclaringExtension().getUniqueIdentifier()
              + ". Using a default operation provider.");
    }
    IStringEditorInput input = null;
    IOperationProvider provider = null;
    ICellValidator validator = null;

    if (inputClazz instanceof IStringEditorInput) {
      input = (IStringEditorInput) inputClazz;
    }
    if (opClazz instanceof IOperationProvider) {
      provider = (IOperationProvider) opClazz;
    } else {
      provider = new DefaultOperationProvider();
    }
    if (cellValidator instanceof ICellValidator) {
      validator = (ICellValidator) cellValidator;
    }
    if (input != null) {
      contentProvider =
          new ContentProvider(
              input, provider, validator, contextHelpID.length() > 0 ? contextHelpID : null);
    }
    return contentProvider;
  }
Ejemplo n.º 8
0
  /**
   * Starts a protocol, taking part as server in the communication
   *
   * @param portToBind The local port where to bind the server to
   * @param allMessages A map containing all messages that belong to the protocol. The message code
   *     as key
   * @param incomingMessages A collection containing the message ids of all incoming messages. The
   *     message ids much match the id field in a ProtocolMsgDefinition object from the allMessages
   *     map
   * @param outgoingMessages A collection containing the message ids of all outgoing messages. The
   *     message ids much match the id field in a ProtocolMsgDefinition object from the allMessages
   *     map
   * @param protocolInitializer The sequence of steps to execute for connection initialization
   * @param isBigEndianProtocol True if the protocol is big endian, false if little endian
   * @return A handle to identify the connection just made
   */
  public static ProtocolHandle requestStartProtocolAsServer(
      int portToBind,
      Map<Long, ProtocolMsgDefinition> allMessages,
      Collection<String> incomingMessages,
      Collection<String> outgoingMessages,
      IProtocolHandshake protocolInitializer,
      IProtocolExceptionHandler exceptionHandler,
      boolean isBigEndianProtocol) {

    BasePlugin.logDebugMessage(
        "ProtocolActionDelegate",
        "An user is requesting to start a server protocol at port " + portToBind + ".");
    ServerModel model = ServerModel.getInstance();
    return model.startListeningToPort(
        portToBind,
        allMessages,
        incomingMessages,
        outgoingMessages,
        protocolInitializer,
        exceptionHandler,
        isBigEndianProtocol);
  }
Ejemplo n.º 9
0
 /*
  * (non-Javadoc)
  * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
  */
 public void stop(BundleContext context) throws Exception {
   plugin = null;
   super.stop(context);
 }
Ejemplo n.º 10
0
 /*
  * (non-Javadoc)
  * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
  */
 public void start(BundleContext context) throws Exception {
   super.start(context);
   plugin = this;
 }