Exemplo n.º 1
0
  public void writeToShell(String command) {
    DataElement commandElement = _status.getParent();
    DataStore dataStore = commandElement.getDataStore();

    if (command.equals("") || command.equals("#break")) // $NON-NLS-1$ //$NON-NLS-2$
    {
      String cmd = command;
      if (cmd.equals("")) // $NON-NLS-1$
      cmd = "#enter"; // $NON-NLS-1$
      DataElement commandDescriptor = getSendInputDescriptor(commandElement);
      if (commandDescriptor != null) {
        DataElement in = dataStore.createObject(null, "input", cmd); // $NON-NLS-1$
        dataStore.command(commandDescriptor, in, commandElement);
      }
    } else {
      String[] tokens = command.split("\n\r"); // $NON-NLS-1$
      for (int i = 0; i < tokens.length; i++) {
        String cmd = tokens[i];

        if (cmd != null) {
          // first, find out if the server support conversion
          DataElement fsD = dataStore.findObjectDescriptor(DataStoreResources.model_directory);
          DataElement convDes =
              dataStore.localDescriptorQuery(fsD, "C_CHAR_CONVERSION", 1); // $NON-NLS-1$
          if (convDes != null) {
            if (!_sentCharConversionCommand) {
              dataStore.command(convDes, _status);
              _sentCharConversionCommand = true;
            }

            cmd = convertSpecialCharacters(cmd);
          }

          DataElement commandDescriptor = getSendInputDescriptor(commandElement);
          if (commandDescriptor != null) {
            DataElement in = dataStore.createObject(null, "input", cmd); // $NON-NLS-1$
            dataStore.command(commandDescriptor, in, commandElement);
          }
        }
      }
    }
  }
Exemplo n.º 2
0
  public void exit() {
    // send cancel command
    DataElement command = _status.getParent();
    DataStore dataStore = command.getDataStore();
    DataElement cmdDescriptor = command.getDescriptor();
    DataElement cancelDescriptor =
        dataStore.localDescriptorQuery(cmdDescriptor, "C_CANCEL"); // $NON-NLS-1$

    if (cancelDescriptor != null) {
      dataStore.command(cancelDescriptor, command);
    }

    _status.setAttribute(DE.A_VALUE, "done"); // $NON-NLS-1$

    _stdoutHandler.finish();
    _stderrHandler.finish();
  }