/**
     * Checks if <code>newText</code> is a valid name.
     *
     * @return The error message if the name is not valid or null otherwise.
     */
    public String isValid(String newText) {
      String message = "";

      newText = newText.trim();
      if (newText.length() == 0) {
        message = Properties.getProperty("name_specified");
      } else if (newText.length() > 50) {
        message = Properties.getProperty("name_too_long");
      } else if (!(newText.equalsIgnoreCase(oldValue)) && this.childExists(oldValue, newText)) {
        message = Properties.getProperty("name_already_exists");
      } else {
        boolean valid = true;
        char[] invalidChracteres = new char[] {'\\', '/', ':', '*', '?', '"', '<', '>', '|'};
        for (int i = 0; i < invalidChracteres.length; i++) {
          if (newText.indexOf(invalidChracteres[i]) != -1) {
            valid = false;
            break;
          }
        }
        if (!valid) {
          message = Properties.getProperty("forbidden_characters") + " \\  /  :  * ? \"  <  >";
        }
      }

      return (message.length() > 0) ? message : null;
    }
  /** The behaviour of the action. Checks if the name entered by the user is valid. */
  public void run() {
    ISelection selection = viewer.getSelection();
    if (selection.isEmpty()) {
      this.setEnabled(false);
    }
    TreeObject object = (TreeObject) ((IStructuredSelection) selection).getFirstElement();
    if (object instanceof DocumentTreeObject) {

      String oldValue = object.getValue().toString();

      IInputValidator validator = new TextValidator(oldValue);
      InputDialog dialog =
          new InputDialog(
              parent.getShell(),
              Properties.getProperty("rename"),
              Properties.getProperty("new_name"),
              oldValue,
              validator);
      dialog.setBlockOnOpen(true); // waits for user enter a name

      int res = dialog.open(); // opens the rename dialog

      if (res == InputDialog.OK) {
        String newValue = dialog.getValue();

        String newExtension = GUIUtil.getFileExtension(newValue);
        String oldExtension = GUIUtil.getFileExtension(oldValue);

        if (!newExtension.equalsIgnoreCase(oldExtension)) {
          newValue += oldExtension;
        }

        if (!newValue.equalsIgnoreCase(oldValue)) {
          if (!ProjectManagerController.getInstance().renameDocument(oldValue, newValue)) {
            MessageDialog.openError(
                parent.getShell(),
                Properties.getProperty("error_while_renaming"),
                Properties.getProperty("can_not_rename"));
          }
          try {
            GUIManager.getInstance().refreshViews();
          } catch (TargetException e) {
            MessageDialog.openError(
                this.parent.getShell(),
                Properties.getProperty("error_while_reloading_project"),
                e.getMessage());
            e.printStackTrace();
          }
        }
      }
    }
  }
 /**
  * The constructor of the action. It also sets the name of the action to be displayed.
  *
  * @param parent The parent component of this action.
  * @param viewer The viewer that is used to get the current selection of a tree.
  * @param useCaseParentNode The node that is the parent of the children documents.
  * @param testCaseParentNode The node that is the parent of the children of the test suites.
  */
 public RenameDocumentAction(
     Composite parent,
     TreeViewer viewer,
     TreeObject useCaseParentNode,
     TreeObject testCaseParentNode) {
   this.setText(Properties.getProperty("rename"));
   this.viewer = viewer;
   this.parent = parent;
   this.useCaseParentNode = useCaseParentNode;
   this.testCaseParentNode = testCaseParentNode;
 }
 /** Default constructor. Initializes the parent nodes and the double click action to null. */
 public ArtifactsView() {
   super();
   this.featureNode = new TreeObject(Properties.getProperty("features"));
   this.testCaseNode = new TreeObject(Properties.getProperty("test_cases"));
   this.doubleClickAction = null;
 }