Package net.sf.jeters.componentInterface.dataStructs

Examples of net.sf.jeters.componentInterface.dataStructs.NamedDataSet


            new UIRequest_String("text", str("articleText"), str("helpArticleText"), text.getText(),multipleLines,lineWrap),
            new UIRequest_String("summary", str("summary"), str("helpSummary"), text.getEditSummary()),
            new UIRequest_Boolean("minor", str("minor"), str("helpMinor"), text.isMinorEdit())
        };
         
        NamedDataSet overviewReply = uiForRequests.request(overviewRequestArray);
         
        if ( overviewReply == null ) {
          text = null;
          completed = true;
        } else {         
         
          try {
            createBot(conf_wikiURLs[overviewReply.<Integer>get("url")]);
           
            text.setLabel(overviewReply.<String>get("label"));
            text.setText(overviewReply.<String>get("text"));
            text.setEditSummary(overviewReply.<String>get("summary"));
            text.setMinorEdit(overviewReply.<Boolean>get("minor"));
             
            completed = true;
           
          } catch (MalformedURLException e) {
            uiForRequests.request(
                new UIRequest_Output(
                    str("errorMalformedURL", e.getMessage())));
          } catch (NamedDataNotAvailableException e) {       
            uiForRequests.request(new UIRequest_Output(str("errorUserInput")));
          }
         
        }
       
      }
     
    } else {

      if (text.getWikiURL() != null) {
        try {
          createBot(text.getWikiURL().toString());         
        } catch (MalformedURLException e) {
          //do nothing, user will be asked
        }
      }
     
      if (bot == null || alwaysAskForOutputWiki) {
       
        int selectedURLIndex = indexOfUrlInURLStringArray(wikiURLs, text.getWikiURL());
       
        UIRequest[] requestArray = new UIRequest[] {
            new UIRequest_Selection("url", str("mediaWikiWrite"), str("helpMediaWikiWrite"), selectedURLIndex, conf_wikiURLs)
        };
       
        NamedDataSet reply = uiForRequests.request(requestArray);
       
        try {
          createBot(conf_wikiURLs[reply.<Integer>get("url")]);
        } catch (MalformedURLException e) {
          uiForRequests.request(
              new UIRequest_Output(
                  str("errorMalformedURL", e.getMessage())));
        } catch (NamedDataNotAvailableException e) {       
          uiForRequests.request(new UIRequest_Output(str("errorUserInput")));
        }
       
      }
     
    }
     
    /* write the article to the wiki (after logging in) */
     
    if( text != null ){   
     
      /*
       * if the bot is not logged in,
       * but all information is available to log in, do so
       */
       
      if( !bot.isLoggedIn()
          && username != null && !username.equals("")
          && password != null ){         
         
        try {
          bot.login(username, password);
        } catch (ActionException e) {
          /* the "Login failed" message will be printed */         
        }
         
        if ( !bot.isLoggedIn() && !password.equals("") ) {
          uiForRequests.request(
              new UIRequest_Output(str("errorLoginFailed")) );       
       
           
      }
       
      /*
       * if bot (still) not logged in, ask for username and password
       * until the bot is logged in or the user gives up
       */
       
      boolean tryAgain = true;
   
      while( !bot.isLoggedIn() && tryAgain ){
                       
        UIRequest requestArray[] = {
          new UIRequest_String("username", str("username"),
              str("helpUsername"), username),
          new UIRequest_String("password", str("password"),
              str("helpPassword"),
              UIRequest_String.LayoutFlag.hideInput)
        };
       
        NamedDataSet reply = uiForRequests.request(requestArray);
       
        if ( reply == null ) { //cancelled
          tryAgain = false;
        }
         
        else {
           
          try {               
            username = reply.get("username");
            password = reply.get("password");
             
            try {
              bot.login(username,password);
            } catch (ActionException e) {
              /* error message will be printed */
 
View Full Code Here


      String rwith = null;
      Boolean ask = false;
     
      while (regex == null || rwith == null) {
     
        NamedDataSet reply = uiForRequests.request(requestArray);
               
        if (reply == null) { //user cancelled request
          return null; // #### !! return-point !! ####
        }
       
        try{       
         
          regex = reply.get("regex");
          rwith = reply.get("rwith");
          summary = reply.get("summary");
          ask = reply.get("ask");

          //test whether the regex is correct
          Pattern.compile(regex);
         
        } catch (NamedDataNotAvailableException e) {
View Full Code Here

      new UIRequest_String("input",
                       str("inputText"),
                       str("helpInputText"),
                       multipleLines);
   
    NamedDataSet reply = uiForRequests.request(request);
   
    if (reply == null) { //user cancelled input
      return null;
    } else {
   
      try {       
        text = reply.get("input");
      } catch (NamedDataNotAvailableException e) {
        //input couldn't be received
        uiForRequests.request(
            new UIRequest_Output(str("errorUserInput")) );
        return null;
View Full Code Here

  }
 
 
  public NamedDataSet request(UIRequest... requests){

    NamedDataSet reply = new NamedDataSet();

    //if only one value is requested, sometimes a dialog box can be used
    //(for boolean values, pure output and file paths)
   
    /*++ TODO: problem: help texts ?! ++*/

    //single boolean request
   
    if( requests.length == 1 && requests[0].getType() == Request_Boolean ){     
     
      int response = JOptionPane.showConfirmDialog(mainFrame,requests[0].label,str("titleWindow"),JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
       
      if( response == JOptionPane.YES_OPTION ){

        reply.add(requests[0].name,true);
       
      }
     
      else{

        reply.add(requests[0].name,false);
       
      }
     
    }   
   
    //output-"request"
   
    else if( requests.length == 1 && requests[0].getType() == Request_Output ){ 
     
      output(requests[0].label);     
     
    }
       
    //request for a file path
     
    else if( requests.length == 1 && requests[0].getType() == UIRequest.Type.Request_String
             && ((UIRequest_String)requests[0]).layoutFlags != null
             && ( ((UIRequest_String)requests[0]).layoutFlags.contains(readPath)
                || ((UIRequest_String)requests[0]).layoutFlags.contains(writePath) ) ){
                
      String response = null;
     
      //create a file chooser dialog
               
      JFileChooser chooser = new JFileChooser();
     
      chooser.setDialogTitle(requests[0].label);
     
      //show the dialog
     
      int returnVal;
     
      if( ((UIRequest_String)requests[0]).layoutFlags.contains(readPath) ){
        returnVal = chooser.showOpenDialog(mainFrame);
      } else {
        returnVal = chooser.showSaveDialog(mainFrame);
      }
           
      //get the result
     
      if(returnVal == JFileChooser.APPROVE_OPTION) {
         response = chooser.getSelectedFile().getPath();
      }
      else{ //cancelled
         return null;
      }

      if( response != null ){
        reply.add(requests[0].name,response);
      }
     
    }   
   
   
    //other requests: full window
   
    else{     
     
      //prepare panel and layout-object
   
      JPanel requestPanel = new JPanel();
 
      GridBagLayout gbLayout = new GridBagLayout();
     
      requestPanel.setLayout(gbLayout);   
           
           
      listener = new GUIListener();

   
     
      //variable for finding out whether this is an output-only request
     
      boolean outputOnly = true;
     
     
      //create arrays where the GUI's components are stored so they can be accessed later
     
      JLabel guiLabelArray[] = new JLabel[requests.length];
      JComponent guiObjectArray[] = new JComponent[requests.length];
       
     
      //arrange GUI
           
      for( int requestIndex = 0; requestIndex < requests.length; ++ requestIndex ){
       
        UIRequest request = requests[requestIndex];
       
        //modify the outputOnly-variable
       
        if( request.name != null ){ outputOnly = false; }
       
        //place the label (unless type is UIRequest_Boolean or UIRequest_Output)
               
        if( request.getType() != Request_Boolean && request.getType() != Request_Output ){

          guiLabelArray[requestIndex] = new JLabel(request.label);

          if(showToolTips && request.help != null && !request.help.equals("") ){
            guiLabelArray[requestIndex].setToolTipText(request.help);
          }
         
          gbLayout.setConstraints(guiLabelArray[requestIndex],new GBC(0,(2*requestIndex),3,SOUTHWEST,NONE,new Insets(5,0,1,0)));
         
          requestPanel.add(guiLabelArray[requestIndex]);
         
        }     
       
        //place the other objects for the request
       
        switch( requests[requestIndex].getType() ){
         
          case Request_Output:  {
   
            UIRequest_Output outputRequest = (UIRequest_Output)request;
                       
            //create a not-editable text area (with line wrap at word boundaries)
            //that has the same color as the panel (indicating read-only) 
           
            JTextArea outputTextArea = new JTextArea(outputRequest.label);

            outputTextArea.setEditable(false);
           
            outputTextArea.setLineWrap(true);
            outputTextArea.setWrapStyleWord(true);
         
            if(showToolTips && outputRequest.help != null && !outputRequest.help.equals("") ){
              outputTextArea.setToolTipText(outputRequest.help);
            }
           
            outputTextArea.setBackground( requestPanel.getBackground() );
           
            //create a scroll pane for the text area and put it on the panel
             
            JScrollPane textScrollPane = new JScrollPane(outputTextArea);
             
            gbLayout.setConstraints(textScrollPane,new GBC(0,(2*requestIndex)+1,3,NORTHWEST,BOTH,new Insets(10,0,3,0)))
             
            requestPanel.add(textScrollPane);
               
          } break;
           
          case Request_Boolean:
         
            UIRequest_Boolean booleanRequest = (UIRequest_Boolean)request;
         
            //create the check box
           
            JCheckBox checkBoxBooleanRequest = new JCheckBox(booleanRequest.label);

            if(showToolTips && booleanRequest.help != null && !booleanRequest.help.equals("") ){
              checkBoxBooleanRequest.setToolTipText(booleanRequest.help);
            }
           
            if( booleanRequest.startingValue != null ){
              checkBoxBooleanRequest.setSelected(booleanRequest.startingValue);
            }
           
            if( booleanRequest.name == null ){
              //setEditable impossible for checkboxes, setEnabled used instead
              checkBoxBooleanRequest.setEnabled(false);
            }
           
            gbLayout.setConstraints(checkBoxBooleanRequest,new GBC(0,(2*requestIndex)+1,3,NORTHWEST,NONE,new Insets(5,0,0,0)))
         
            requestPanel.add(checkBoxBooleanRequest);
           
            guiObjectArray[requestIndex] = checkBoxBooleanRequest;
           
            break;   

          case Request_String:
   
            UIRequest_String stringRequest = (UIRequest_String)request;
                       
            //create the text field / password field / text area (depending on the flags)
           
            JTextComponent textComponentStringRequest;
           
            if( stringRequest.layoutFlags != null &&
                stringRequest.layoutFlags.contains( multipleLines ) ){
           
              textComponentStringRequest = new JTextArea(stringRequest.startingValue);

              ((JTextArea)textComponentStringRequest).setLineWrap(stringRequest.layoutFlags.contains(lineWrap));
              ((JTextArea)textComponentStringRequest).setWrapStyleWord(true);
             
              JScrollPane textScrollPane = new JScrollPane(textComponentStringRequest);
             
              gbLayout.setConstraints(textScrollPane,new GBC(0,(2*requestIndex)+1,3,NORTHWEST,BOTH))
             
              requestPanel.add(textScrollPane);
               
            else if( stringRequest.layoutFlags != null &&
                       stringRequest.layoutFlags.contains( hideInput ) ){
             
              textComponentStringRequest = new JPasswordField(stringRequest.startingValue);
             
              gbLayout.setConstraints(textComponentStringRequest,new GBC(0,(2*requestIndex)+1,3,NORTHWEST,HORIZONTAL))

              requestPanel.add(textComponentStringRequest);
             
            else{
           
              textComponentStringRequest = new JTextField(stringRequest.startingValue);
   
              gbLayout.setConstraints(textComponentStringRequest,new GBC(0,(2*requestIndex)+1,3,NORTHWEST,HORIZONTAL))
             
              requestPanel.add(textComponentStringRequest);
             
            }

            if(showToolTips && stringRequest.help != null && !stringRequest.help.equals("") ){
              textComponentStringRequest.setToolTipText(stringRequest.help);
            }
           
            if( stringRequest.name == null ){
              textComponentStringRequest.setEditable(false);
            }
           
            guiObjectArray[requestIndex] = textComponentStringRequest;             
           
            break;
           
          case Request_Integer:

            UIRequest_Integer integerRequest = (UIRequest_Integer)request;
                 
            //create the text field
           
            JTextField textFieldIntegerRequest = new JTextField();

            if(showToolTips && integerRequest.help != null && !integerRequest.help.equals("") ){
              textFieldIntegerRequest.setToolTipText(integerRequest.help);
            }
           
            if( integerRequest.startingValue != null ){
              textFieldIntegerRequest.setText(integerRequest.startingValue.toString());
            }
           
            if( integerRequest.name == null ){
              textFieldIntegerRequest.setEditable(false);
            }
       
            gbLayout.setConstraints(textFieldIntegerRequest,new GBC(0,(2*requestIndex)+1,3,NORTHWEST,HORIZONTAL));
           
            requestPanel.add(textFieldIntegerRequest);

            guiObjectArray[requestIndex] = textFieldIntegerRequest;           
           
            break;
         
          case Request_Float:

            UIRequest_Float floatRequest = (UIRequest_Float)request;
       
            //create the text field
           
            JTextField textFieldFloatRequest = new JTextField();

            if( showToolTips && floatRequest.help != null && !floatRequest.help.equals("") ){
              textFieldFloatRequest.setToolTipText(floatRequest.help);
            }
           
            if( floatRequest.startingValue != null ){
              textFieldFloatRequest.setText(floatRequest.startingValue.toString());
            }
           
            if( floatRequest.name == null ){
              textFieldFloatRequest.setEditable(false);
            }
           
            requestPanel.add(textFieldFloatRequest);

            gbLayout.setConstraints(textFieldFloatRequest,new GBC(0,(2*requestIndex)+1,3,NORTHWEST,HORIZONTAL));

            guiObjectArray[requestIndex] = textFieldFloatRequest;           
           
            break;           
                     
          case Request_Selection:
   
            UIRequest_Selection selectionRequest = (UIRequest_Selection)request;
       
            //create the combo box
           
            JComboBox comboBoxSelectionRequest = new JComboBox();

            if( showToolTips && selectionRequest.help != null && !selectionRequest.help.equals("") ){
              comboBoxSelectionRequest.setToolTipText(selectionRequest.help);
            }   
           
            for( String selectionName : selectionRequest.selectionNames ){
           
              comboBoxSelectionRequest.addItem(selectionName);
           
            }

            if( selectionRequest.startingValue != null
             && selectionRequest.startingValue >= 0 && selectionRequest.startingValue < selectionRequest.selectionNames.length ){
              comboBoxSelectionRequest.setSelectedIndex(selectionRequest.startingValue);
            } else {
              comboBoxSelectionRequest.setSelectedIndex(-1);
            }
           
            if( selectionRequest.name == null ){           
              comboBoxSelectionRequest.setEditable(false);
            }
           
            gbLayout.setConstraints(comboBoxSelectionRequest,new GBC(0,(2*requestIndex)+1,3,NORTHWEST,HORIZONTAL));

            requestPanel.add(comboBoxSelectionRequest);

            guiObjectArray[requestIndex] = comboBoxSelectionRequest;           
           
            break

        }
           
      }
     
      //cancel-Button (only if at least one component requiring input exists)
      //it will always be created because it's used for size calculation of the OK button.
           
      JButton cancelButton = new JButton(str("buttonCancel"));
     
      cancelButton.setActionCommand(ACTION_CANCEL);
 
      if( !outputOnly ){   
       
        cancelButton.addActionListener(listener);
     
        gbLayout.setConstraints(cancelButton,new GBC(1,(2*requests.length),1,SOUTHEAST,NONE,1,0.01,new Insets(3,0,0,5)));
     
        requestPanel.add(cancelButton);
      }
     
      //ok-Button
     
      JButton okButton = new JButton(str("buttonOK"));
     
      okButton.setActionCommand(ACTION_OK);
     
      okButton.addActionListener(listener);
     
      okButton.setPreferredSize( cancelButton.getPreferredSize() ); //same size as Cancel-button
           
      gbLayout.setConstraints(okButton,new GBC(2,(2*requests.length),1,SOUTHEAST,NONE,0,0.01,new Insets(3,0,0,0)));
     
      requestPanel.add(okButton);
       
     
      //put the request panel into the main frame
     
      setMainFrameContent(requestPanel);
     
     
      //wait for valid user replies
      //if Cancel is pressed, the method is left immediately, returning null !!!
     
      boolean validRepliesEntered = false;
     
      while( !validRepliesEntered ){
              
        //wait for OK or Cancel being pressed
             
        boolean buttonOKPressed = false;
       
        while( !buttonOKPressed ){
       
          try{
            Thread.sleep(100);
          }
          catch(InterruptedException ie){}
         
          if( listener.hasNewActionCommand() ){
           
            String actionCommand = listener.getNextActionCommand();
           
            if( actionCommand.equals(ACTION_OK) ){
           
              buttonOKPressed = true;
           
            }

            else if( actionCommand.equals(ACTION_CANCEL) ){
           
              return null;   // #### !! return-point !! ####
           
            }
           
          }
         
        }     
       
        //get replies
       
        validRepliesEntered = true;
       
        for( int requestIndex = 0; requestIndex < requests.length && validRepliesEntered == true; ++ requestIndex ){
         
          if( requests[requestIndex].name != null ){
         
            switch( requests[requestIndex].getType() ){
   
              case Request_Boolean:
             
                reply.add(requests[requestIndex].name,((JCheckBox)guiObjectArray[requestIndex]).isSelected());
               
                break;   
   
              case Request_String:
   
                reply.add(requests[requestIndex].name,((JTextComponent)guiObjectArray[requestIndex]).getText());
   
                break;
               
              case Request_Integer:
           
                String integerAsString = ((JTextField)guiObjectArray[requestIndex]).getText();
               
                try{
                 
                  int integerValue = Integer.parseInt(integerAsString);
                 
                  if( integerValue < ((UIRequest_Integer)requests[requestIndex]).range_min
                   || integerValue > ((UIRequest_Integer)requests[requestIndex]).range_max ){
                    
                    output(str("errorRange", integerAsString, ((UIRequest_Integer)requests[requestIndex]).range_min, ((UIRequest_Integer)requests[requestIndex]).range_max));
                                   
                    validRepliesEntered = false;         
                   
                  }
 
                  reply.add(requests[requestIndex].name,integerValue);
                 
                }
               
                catch( NumberFormatException nfe ){
                 
                  output(str("errorNoValidInteger", integerAsString));
                                   
                  validRepliesEntered = false;
                 
                }
               
                break;
             
              case Request_Float:
             
                String floatAsString = ((JTextField)guiObjectArray[requestIndex]).getText();
               
                try{
                 
                  float floatValue = Float.parseFloat(floatAsString);
                 
                  if( floatValue < ((UIRequest_Float)requests[requestIndex]).range_min
                   || floatValue > ((UIRequest_Float)requests[requestIndex]).range_max ){
                    
                    output(str("errorRange", floatAsString, ((UIRequest_Float)requests[requestIndex]).range_min, ((UIRequest_Float)requests[requestIndex]).range_max));
                                   
                    validRepliesEntered = false;         
                   
                  }
                 
                  reply.add(requests[requestIndex].name,floatValue);
                 
                }
               
                catch( NumberFormatException nfe ){
                 
                  output(str("errorNoValidFloat", floatAsString));
                                   
                  validRepliesEntered = false;
                 
                }
                             
                break;           
             
              case Request_Selection:
             
                int selectedIndex = ((JComboBox)guiObjectArray[requestIndex]).getSelectedIndex();
               
                if( selectedIndex < 0 || selectedIndex > ((UIRequest_Selection)requests[requestIndex]).selectionNames.length ){
                 
                  output(str("errorNoValidOption"));
                                   
                  validRepliesEntered = false;
                 
                }                 
       
                reply.add(requests[requestIndex].name,selectedIndex);
                           
                break
   
            }
         
View Full Code Here

   
    String inputFileName = null;
   
    while (inputFileName == null) {
   
      NamedDataSet reply = uiForRequests.request(new UIRequest_String(
          "path", str("titleInputFilePath"), str("helpInputFilePath"),
          UIRequest_String.LayoutFlag.readPath));
     
      if (reply == null) {
        return null; //cancelled - #### !! return-point !! ####
      }
        
      try {
       
        inputFileName = reply.get("path");
       
      } catch (NamedDataNotAvailableException ndnae) {
        uiForRequests.request( new UIRequest_Output(
            str("errorUserInput")));
      }
View Full Code Here

      while (outputFileName == null && tryAgain) {
     
        //get the path from user interface
       
        NamedDataSet reply = uiForRequests.request(new UIRequest_String(
            "path", str("titleOutputFilePath"),
            str("helpOutputFilePath"),
            UIRequest_String.LayoutFlag.writePath));
       
        if (reply == null) { tryAgain = false; } //cancelled
       
        else{
         
          try {
           
            outputFileName = reply.get("path");
           
          } catch (NamedDataNotAvailableException e) {
            uiForRequests.request(
                new UIRequest_Output(str("errorUserInput")) );
          }
View Full Code Here

      System.out.println(cleanedStrings[1]);
      System.out.println("\nvorgenommene Änderungen:\n");
      System.out.println(descriptionOfChanges);
         
      UIRequest requestArray[] = { new UIRequest_Boolean("confirmation","\nÄnderungen übernehmen?","Bei „ja“ werden alle(!) Änderungen in diesem Textabschnitt übernommen.") };
      NamedDataSet reply = this.request(requestArray);
     
      Boolean newVersionAccepted = false;
      try{
        newVersionAccepted = reply.get("confirmation");
      } catch( NamedDataNotAvailableException ndnae ){ /* newVersionAccepted remains false */ }
     
      return (newVersionAccepted)?(newVersion):(oldVersion);
       
    }             
View Full Code Here

  }
 
 
  public NamedDataSet request(UIRequest... requests){
   
    NamedDataSet reply = new NamedDataSet();
   
    for( UIRequest request : requests ){
   
      //output request
     
      System.out.println(request.label);

      if( request.getType() == UIRequest.Type.Request_Boolean ){
       
        output("[y]es or [n]o");         
       
      }       
     
      else if( request.getType() == UIRequest.Type.Request_Selection ){
       
        for( int possibilityIndex = 0; possibilityIndex < ((UIRequest_Selection)request).selectionNames.length; ++ possibilityIndex ){
         
          output(String.valueOf(possibilityIndex) + ": " + ((UIRequest_Selection)request).selectionNames[possibilityIndex]);         
         
        }       
       
      }
     
      if( showHelpTexts && !request.help.equals("") ){ output("explanation: " + request.help); }

      //get answer from System input stream
     
      if( request.getType() != UIRequest.Type.Request_Output ){
     
        try{
         
          boolean requestAnswered = false;
         
          do{
         
            //create String from inputs
           
            BufferedInputStream keyboardInputStream = new BufferedInputStream(System.in);
           
            String input = new String();
           
            char readChar = (char)keyboardInputStream.read();
               
            while( readChar != '\n' ){
             
              input += readChar;
           
              readChar = (char)keyboardInputStream.read();
             
            }
           
            if( input.length() > 0 ){
               
              //interprete input depending on request type
             
              switch( request.getType() ){
             
                case Request_Boolean:
               
                  if( input.charAt(0) == 'y' ){
                 
                    reply.add(request.name,true);
                   
                    requestAnswered = true;
                   
                  }
                 
                  else if( input.charAt(0) == 'n' ){
                 
                    reply.add(request.name,false);
                   
                    requestAnswered = true;
                   
                  }
                 
                  else{
                   
                    output("answer must be y or n" );
                   
                  }
                 
                  break;   
               
                case Request_String:
   
                  reply.add(request.name,input);
                 
                  requestAnswered = true;
                 
                  break;
                 
                case Request_Integer:
               
                  try{
                 
                    int inputInt = Integer.parseInt(input);
   
                    if( inputInt >= ((UIRequest_Integer)request).range_min && inputInt <= ((UIRequest_Integer)request).range_max ){
                     
                      reply.add(request.name,inputInt);
                   
                      requestAnswered = true;
                     
                    }
                   
                    else{
                     
                      output("Value not in range [" + String.valueOf(((UIRequest_Integer)request).range_min) + ";" + String.valueOf(((UIRequest_Integer)request).range_max) + "]!" );
                     
                    }
                   
                  }
                  catch( NumberFormatException nfe ){
                   
                    output("Not a valid integer!");
                   
                  }
                 
                  break;
               
                case Request_Float:
               
                  try{
                 
                    float inputFloat = Float.parseFloat(input);
   
                    if( inputFloat >= ((UIRequest_Float)request).range_min && inputFloat <= ((UIRequest_Float)request).range_max ){
                     
                      reply.add(request.name,inputFloat);
                   
                      requestAnswered = true;
                     
                    }
                   
                    else{
                     
                      output("Value not in range [" + String.valueOf(((UIRequest_Float)request).range_min) + ";" + String.valueOf(((UIRequest_Float)request).range_max) + "]!" );
                     
                    }
                   
                  }
                  catch( NumberFormatException nfe ){
                   
                    output("Not a valid floating point value!");
                   
                  }
                               
                  break;           
               
                case Request_Selection:
   
                  try{
                 
                    int inputInt = Integer.parseInt(input);
   
                    if( inputInt >= 0 && inputInt < ((UIRequest_Selection)request).selectionNames.length ){
                     
                      reply.add(request.name,inputInt);
                   
                      requestAnswered = true;
                     
                    }
                   
View Full Code Here

     
     
      UIRequest[] requestArray = new UIRequest[requestList.size()];
      requestArray = requestList.toArray(requestArray);
     
      NamedDataSet reply = uiForRequests.request(requestArray);
       
      if (reply == null) { return null; } //cancelled - #### !! return-point !! ####
       
      try { //catch MalformedURLException and NamedDataNotAvailableException
       
        createBot(conf_wikiURLs[reply.<Integer>get("url")]);
       
        Integer type = reply.get("type");       
        String name = reply.get("name");
               
        if ( type == 0 /*article*/ ){
                                   
          result = readArticle(name);
       
        }
         
        else { //one of the iterator-generating types
 
          try { //catch JWBFExceptions
           
            /* get the appropriate iterator */
           
            switch (type) {
               
              case 1: /*articles from*/
                      titleIterator = new AllPageTitles(bot, name,null,nonredirects).iterator();
                      break;
 
              case 2: /*articles starting with*/
                        titleIterator = new AllPageTitles(bot,null,name,nonredirects).iterator();
                        break;
                 
              case 3: /*category*/
                  titleIterator = new CategoryMembersSimple(bot, name).iterator();
                  break;
             
              case 4: /*backlinks*/
                  titleIterator = new BacklinkTitles(bot, name).iterator();
                  break;
 
              case 5: /*imagelinks*/
                  if (!imagePrefix.equals("")) {
                    name = imagePrefix + name;
                  }
                  titleIterator = new ImageUsageTitles(bot, name).iterator();
                  break;
   
              case 6: /*template users*/
                  if (!templatePrefix.equals("")) {
                    name = templatePrefix + name;
                  }                 
                  titleIterator = new TemplateUserTitles(bot, name).iterator();
                  break;
                 
            }
           
            /* apply the restrictions */
           
            for (int i = 0; i < restrictionsInArticleSelection;
              i ++) {
                         
              Integer restrictionType =
                reply.get("restriction_type_" + i);       
              String restrictionValue =
                reply.get("restriction_value_" + i);

              if (restrictionType > 0 &&
                  restrictionValue != null) {

                switch (restrictionType) {
View Full Code Here

TOP

Related Classes of net.sf.jeters.componentInterface.dataStructs.NamedDataSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.