Beispiel #1
0
 /* Load script into editor and switch to editor view */
 private void editScript(Script script, Boolean switchTab) {
   try {
     currentScript = script;
     fnameTextView.setText(script.getName());
     sourceEditor.setText(script.getContents());
     if (switchTab) tabs.setCurrentTab(EDITOR_TAB);
   } catch (IOException e) {
     Toast.makeText(this, "Could not open " + script.getName(), Toast.LENGTH_SHORT).show();
   }
 }
Beispiel #2
0
 /* Save the script currently in the editor */
 private void saveEditorScript() {
   try {
     currentScript
         .setName(fnameTextView.getText().toString())
         .setContents(sourceEditor.getText().toString())
         .save();
     scanScripts();
     Toast.makeText(this, "Saved " + currentScript.getName(), Toast.LENGTH_SHORT).show();
     tabs.setCurrentTab(SCRIPTS_TAB);
   } catch (IOException e) {
     Toast.makeText(this, "Could not write " + currentScript.getName(), Toast.LENGTH_SHORT).show();
   }
 }
  // Add/Insert
  public int add(Script script) {
    // Find the correct spot to add it alphabetically
    int i, limit;
    for (i = 0, limit = scripts.size(); i < limit; i++) {
      Script scriptTemp = (Script) scripts.get(i);
      if (scriptTemp.getName().compareTo(script.getName()) >= 0) {
        break;
      }
    }

    scripts.add(i, script);

    // Update the table
    fireTableRowsInserted(i, i);

    return i;
  }
  public int indexOf(String name) {
    for (int i = 0, limit = scripts.size(); i < limit; i++) {
      Script script = get(i);
      if (script.getName().equals(name)) {
        return i;
      }
    }

    return -1;
  }
Beispiel #5
0
 /* Run the script currently in the editor */
 private void runEditorScript() {
   try {
     irbOutput.append("[Running editor script (" + currentScript.getName() + ")]\n");
     String inspected = currentScript.setContents(sourceEditor.getText().toString()).execute();
     irbOutput.append("=> " + inspected + "\n>> ");
     tabs.setCurrentTab(IRB_TAB);
   } catch (IOException e) {
     Toast.makeText(this, "Could not execute script", Toast.LENGTH_SHORT).show();
   }
 }
 public GenericScriptPopupAction(Script script, UserScriptAdmin admin, boolean targetType) {
   super(script.getName());
   m_script = script;
   m_admin = admin;
   m_targetType = targetType;
 }