Package net.sourceforge.fullsync

Examples of net.sourceforge.fullsync.Action


        }
        break;
      case State.DirHereFileThere:
        State buff = bsd.getState(dst);
        if (buff.equals(State.Orphan, Location.Buffer)) {
          actions.add(new Action(Action.Add, Location.Destination, BufferUpdate.Destination,
              "There was a node in buff, but its orphan, so add"));
        }
        else if (buff.equals(State.DirHereFileThere, state.getLocation())) {
          if (state.getLocation() == Location.Source) {
            actions.add(new Action(Action.Nothing, Location.None, BufferUpdate.Destination,
                "dirherefilethere, but there is a dir instead of file, so its in sync"));
          }
          else {
            actions.add(new Action(Action.DirHereFileThereError, Location.Destination, BufferUpdate.None,
                "file changed from/to dir, can't overwrite"));
            // TODO ^ recompare here
          }
        }
        else {
          actions.add(new Action(Action.DirHereFileThereError, state.getLocation(), BufferUpdate.None,
              "cant update, dir here file there error occured"));
        }
        break;
      case State.FileChange:
        if (bsd.getState(dst).equals(State.NodeInSync, Location.Both)) {
          if (state.getLocation() == Source) {
            actions.add(updateDestination);
          }
          else if (state.getLocation() == Destination) {
            actions.add(overwriteDestination);
          }
        }
        else {
          actions.add(overwriteDestination);
        }
        break;
      case State.NodeInSync:
        // TODO this check is not neccessary, check rules whether to do or not
        // if( bsd.getState( dst ).equals( State.NodeInSync, Location.Both ) || bsd.getState( dst ).equals( State.NodeInSync,
        // Location.None ) )
      {
        actions.add(inSync);
        actions.add(overwriteDestination);
      }
      break;
      default:
        actions.add(new Action(Action.NotDecidableError, Location.None, BufferUpdate.None, "no rule found"));
        break;
    }

    actions.add(ignore);
View Full Code Here


        }
        break;
      case State.DirHereFileThere:
        State buff = bsd.getState(dst);
        if (buff.equals(State.Orphan, Location.Buffer)) {
          actions.add(new Action(Action.Add, Location.getOpposite(state.getLocation()), BufferUpdate.Destination,
              "There was a node in buff, but its orphan, so add"));
        }
        else if (buff.equals(State.DirHereFileThere, state.getLocation())) {
          if (state.getLocation() == Location.Source) {
            actions.add(new Action(Action.Nothing, Location.None, BufferUpdate.None,
                "dirherefilethere, but there is a dir instead of file, so its in sync"));
          }
          else {
            actions.add(new Action(Action.UnexpectedChangeError, Location.Destination, BufferUpdate.None,
                "dirherefilethere, but there is a file instead of dir, so unexpected change"));
            // TODO ^ recompare here
          }
        }
        else {
          actions.add(new Action(Action.DirHereFileThereError, state.getLocation(), BufferUpdate.None,
              "cant update, dir here file there error occured"));
        }
        break;
      case State.FileChange:
        if (bsd.getState(dst).equals(State.NodeInSync, Location.Both)) {
          actions.add(updateDestination);
        }
        else {
          actions.add(overwriteDestination);
        }
        break;
      case State.NodeInSync:
        // TODO this check is not neccessary, check rules whether to do or not
        // if( bsd.getState( dst ).equals( State.NodeInSync, Location.Both ) || bsd.getState( dst ).equals( State.NodeInSync,
        // Location.None ) )
      {
        actions.add(inSync);
        actions.add(overwriteDestination);
        actions.add(overwriteSource);
      }
      break;
      default:
        actions.add(new Action(Action.NotDecidableError, Location.None, BufferUpdate.None, "no rule found"));
        break;
    }

    actions.add(ignore);
View Full Code Here

        }
        break;
      case State.DirHereFileThere:
        State buff = bsd.getState(dst);
        if (buff.equals(State.Orphan, Buffer)) {
          actions.add(new Action(Add, Destination, BufferUpdate.Destination,
              "There was a node in buff, but its orphan, so add"));
        }
        else if (buff.equals(State.DirHereFileThere, state.getLocation())) {
          if (state.getLocation() == Source) {
            actions.add(new Action(Nothing, None, BufferUpdate.Destination,
                "dirherefilethere, but there is a dir instead of file, so its in sync"));
          }
          else {
            actions.add(new Action(DirHereFileThereError, Destination, BufferUpdate.None,
                "file changed from/to dir, can't overwrite"));
            // TODO ^ recompare here
          }
        }
        else {
          actions.add(new Action(DirHereFileThereError, state.getLocation(), BufferUpdate.None,
              "cant update, dir here file there error occured"));
        }
        break;
      case State.FileChange:
        if (bsd.getState(dst).equals(State.NodeInSync, Both)) {
          if (state.getLocation() == Source) {
            actions.add(updateDestination);
          }
          else if (state.getLocation() == Destination) {
            actions.add(overwriteDestination);
          }
        }
        else {
          actions.add(overwriteDestination);
        }
        break;
      case State.NodeInSync:
        // TODO this check is not neccessary, check rules whether to do or not
        // if( bsd.getState( dst ).equals( State.NodeInSync, Both ) || bsd.getState( dst ).equals( State.NodeInSync,
        // None ) )
      {
        actions.add(inSync);
        actions.add(overwriteDestination);
      }
      break;
      default:
        actions.add(new Action(NotDecidableError, None, BufferUpdate.None, "no rule found"));
        break;
    }

    actions.add(ignore);
View Full Code Here

        }
        break;
      case State.DirHereFileThere:
        State buff = bsd.getState(dst);
        if (buff.equals(State.Orphan, Buffer)) {
          actions.add(new Action(Add, getOpposite(state.getLocation()), BufferUpdate.Destination,
              "There was a node in buff, but its orphan, so add"));
        }
        else if (buff.equals(State.DirHereFileThere, state.getLocation())) {
          if (state.getLocation() == Source) {
            actions.add(new Action(Nothing, None, BufferUpdate.None,
                "dirherefilethere, but there is a dir instead of file, so its in sync"));
          }
          else {
            actions.add(new Action(UnexpectedChangeError, Destination, BufferUpdate.None,
                "dirherefilethere, but there is a file instead of dir, so unexpected change"));
            // TODO ^ recompare here
          }
        }
        else {
          actions.add(new Action(DirHereFileThereError, state.getLocation(), BufferUpdate.None,
              "cant update, dir here file there error occured"));
        }
        break;
      case State.FileChange:
        if (bsd.getState(dst).equals(State.NodeInSync, Both)) {
          if (state.getLocation() == Source) {
            actions.add(updateDestination);
          }
          else if (state.getLocation() == Destination) {
            actions.add(unexpectedDestinationChanged);
            actions.add(overwriteDestination);
          }
        }
        else {
          actions.add(unexpectedBothChanged);
          actions.add(overwriteDestination);
        }
        break;
      case State.NodeInSync:
        // TODO this check is not neccessary, check rules whether to do or not
        // if( bsd.getState( dst ).equals( State.NodeInSync, Both ) || bsd.getState( dst ).equals( State.NodeInSync,
        // None ) )
      {
        actions.add(inSync);
        actions.add(overwriteDestination);
        actions.add(overwriteSource);
      }
      break;
      default:
        actions.add(new Action(NotDecidableError, None, BufferUpdate.None, "no rule found"));
        break;
    }

    actions.add(ignore);
View Full Code Here

          actions.add(addToSource);
          actions.add(deleteDestinationOrphan);
        }
        break;
      case State.DirHereFileThere:
        actions.add(new Action(Action.DirHereFileThereError, state.getLocation(), BufferUpdate.None,
            "file changed from/to dir, can't overwrite"));
        break;
      case State.FileChange:
        if (state.getLocation() == Location.Source) {
          actions.add(updateDestination);
          actions.add(overwriteSource);
        }
        else if (state.getLocation() == Location.Destination) {
          actions.add(updateSource);
          actions.add(overwriteDestination);
        }
        else {
          // TODO a change but we can't tell which file is 'better' (just size changed)
        }
        break;
      case State.NodeInSync:
        actions.add(inSync);
        actions.add(overwriteDestination);
        actions.add(overwriteSource);
        break;
      default:
        actions.add(new Action(Action.NotDecidableError, Location.None, BufferUpdate.None, "no rule found"));
        break;
    }

    actions.add(ignore);
View Full Code Here

  protected void executeTask(Task task) {
    try {
      // TODO lock tasks here

      Action action = task.getCurrentAction();
      File source = task.getSource();
      File destination = task.getDestination();

      switch (action.getType()) {
        case Action.Add:
        case Action.Update:
          if (action.getLocation() == Location.Destination) {
            if (source.isDirectory()) {
              storeDirCreation(task, destination);
            }
            else {
              storeFileCopy(task, source, destination);
            }
          }
          else if (action.getLocation() == Location.Source) {
            if (destination.isDirectory()) {
              storeDirCreation(task, source);
            }
            else {
              storeFileCopy(task, destination, source);
            }
          }
          break;
        case Action.Delete:
          if (action.getLocation() == Location.Destination) {
            storeDeleteNode(task, destination);
          }
          else if (action.getLocation() == Location.Source) {
            storeDeleteNode(task, source);
          }

          break;
        default:
          break;
      }
      if ((action.getBufferUpdate() > 0) && !statisticsOnly) {
        buffer.storeEntry(new BufferUpdateEntryDescriptor(source, destination, action.getBufferUpdate()));
      }
    }
    catch (IOException ioe) {
      ExceptionHandler.reportException(ioe);
    }
View Full Code Here

    }

    SelectionListener selListener = new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        Action targetAction = (Action) e.widget.getData();

        for (TableItem item : tableItemList) {
          Task task = (Task) item.getData();
          Action[] actions = task.getActions();

          for (int iAction = 0; iAction < actions.length; iAction++) {
            Action a = actions[iAction];
            if ((a.getType() == targetAction.getType()) && (a.getLocation() == targetAction.getLocation())
                && a.getExplanation().equals(targetAction.getExplanation())) {
              task.setCurrentAction(iAction);
              break;
            }
          }

          updateTask(item);
        }
      }
    };


    Task[] taskList = new Task[tableItemList.length];
    for (int i = 0; i < tableItemList.length; i++) {
      taskList[i] = (Task) tableItemList[i].getData();
    }

    Menu m = new Menu(this);
    MenuItem mi;

    // load initial actions of first task
    Action[] possibleActions = taskList[0].getActions().clone();

    for (int iTask = 1; iTask < taskList.length; iTask++) {
      // invalidate all possible actions we dont find in this actionlist
      Action[] actions = taskList[iTask].getActions();

      for (int iPosAction = 0; iPosAction < possibleActions.length; iPosAction++) {
        Action action = possibleActions[iPosAction];
        boolean found = false;

        if (action == null) {
          continue;
        }

        // check whether action is also supported by this task
        for (Action a : actions) {
          if ((a.getType() == action.getType()) && (a.getLocation() == action.getLocation())
              && a.getExplanation().equals(action.getExplanation())) {
            // the action exists
            found = true;
            break;
          }
        }

        if (!found) {
          // invalidate action that is not supported by all selected tasks
          possibleActions[iPosAction] = null;
        }
      }
    }

    Task referenceTask = taskList.length == 1 ? taskList[0] : null;
    for (Action action : possibleActions) {
      if (action == null) {
        continue;
      }

      Image image = getTaskImage(referenceTask, action);
      mi = new MenuItem(m, SWT.NULL);
      mi.setImage(image);
      mi.setText(Action.toString(action.getType()) + " - " + action.getExplanation()); //$NON-NLS-1$
      mi.setData(action);
      mi.addSelectionListener(selListener);
    }

    m.setLocation(tableLogLines.toDisplay(x, y));
View Full Code Here

    }

    this.actionDecider = actionDecider;

    TaskTree tree = new TaskTree(source, destination);
    Task root = new Task(null, null, new State(State.NodeInSync, Location.None), new Action[] { new Action(Action.Nothing,
        Location.None, BufferUpdate.None, "Root") });
    tree.setRoot(root);

    for (TaskGenerationListener listener : taskGenerationListeners) {
      listener.taskTreeStarted(tree);
View Full Code Here

    profile.setSynchronizationType("Publish/Update");
  }
  @Override
  @Test
  public void fileInSync() throws Exception {
    expectation.put("inSync.txt", new Action(Action.Nothing, Location.None, BufferUpdate.None, "in sync"));
    super.fileInSync();
  }
View Full Code Here

    super.fileInSync();
  }
  @Override
  @Test
  public void fileChangeInSource() throws Exception {
    expectation.put("changeSource.txt", new Action(Action.Update, Location.Destination, BufferUpdate.Destination, "source changed, update destination"));
    super.fileChangeInSource();
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.fullsync.Action

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.