コード例 #1
0
 /** Verify dialog state */
 private void verify() {
   String text = myNameTextField.getText().trim();
   if (text.length() == 0) {
     setError("Empty configuration name is not allowed.");
     return;
   } else if (myTarget != null && text.equals(myTarget.getName())) {
   } else if (myExistingConfigNames.contains(text)) {
     setError("There is another configuration with the same name");
     return;
   }
   for (BranchDescriptor d : myBranches) {
     switch (d.status) {
       case BRANCH_NAME_EXISTS:
         setError("Duplicate branch name for root " + d.getRoot());
         return;
       case INVALID_BRANCH_NAME:
         setError("Invalid branch name for root " + d.getRoot());
         return;
       case BAD_REVISION:
         setError("Invalid revision for root " + d.getRoot());
         return;
       case MISSING_REVISION:
         setError("The revision must be specified for root " + d.getRoot());
         return;
       case CHECKOUT_NEEDED:
       case NO_ACTION:
       case REMOVED_ROOT:
         break;
       default:
         throw new RuntimeException("Unexpected status: " + d.status);
     }
   }
   setError(null);
 }
コード例 #2
0
 /** {@inheritDoc} */
 @Override
 public Object getValueAt(int rowIndex, int columnIndex) {
   BranchDescriptor d = myBranches.get(rowIndex);
   switch (columnIndex) {
     case ROOT_COLUMN:
       return Pair.create(d.getRoot(), d.root != null);
     case REVISION_COLUMN:
       return Pair.create(d.referenceToCheckout, d.isReferenceValid);
     case NEW_BRANCH_COLUMN:
       return Pair.create(d.newBranchName == null ? "" : d.newBranchName, d.isNewBranchValid);
     case STATUS_COLUMN:
       switch (d.status) {
         case INVALID_BRANCH_NAME:
           return Pair.create("Invalid new branch name", false);
         case BAD_REVISION:
           return Pair.create("Invalid revision", false);
         case MISSING_REVISION:
           return Pair.create("Missing revision", false);
         case CHECKOUT_NEEDED:
           return Pair.create("Checkout", true);
         case REMOVED_ROOT:
           return Pair.create("Removed root", true);
         case NO_ACTION:
           return Pair.create("", true);
         case BRANCH_NAME_EXISTS:
           return Pair.create("Branch name exists", false);
         default:
           throw new IllegalStateException("Unknown status:" + d.status);
       }
     default:
       throw new IllegalStateException("Unknown column: " + columnIndex);
   }
 }