Package net.sourceforge.fullsync

Examples of net.sourceforge.fullsync.Synchronizer


    GridData labelProgressLData = new GridData();
    labelProgressLData.horizontalAlignment = SWT.FILL;
    labelProgressLData.horizontalIndent = 5;
    labelProgressLData.grabExcessHorizontalSpace = true;
    labelProgress.setLayoutData(labelProgressLData);
    Synchronizer synchronizer = GuiController.getInstance().getSynchronizer();
    IoStatistics stats = synchronizer.getIoStatistics(taskTree);
    labelProgress.setText("Totals: " + stats.getCountActions() + " tasks, " + UISettings.formatSize(stats.getBytesTransferred()));

    list = new TaskDecisionList(content, SWT.NULL);
    list.setTaskTree(taskTree);
    GridData listLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
View Full Code Here


        final Display display = getDisplay();
        try {
          processing = true;
          list.setChangeAllowed(false);

          Synchronizer synchronizer = GuiController.getInstance().getSynchronizer();
          IoStatistics stats = synchronizer.getIoStatistics(taskTree);
          tasksTotal = stats.getCountActions();
          tasksFinished = 0;

          final Color colorFinishedSuccessful = new Color(null, 150, 255, 150);
          final Color colorFinishedUnsuccessful = new Color(null, 255, 150, 150);

          display.syncExec(new Runnable() {
            @Override
            public void run() {
              setOkButtonEnabled(false);
            }
          });

          final GUIUpdateQueue<TaskFinishedEvent> updateQueue = new GUIUpdateQueue<TaskFinishedEvent>(display, new GUIUpdateQueue.GUIUpdateTask<TaskFinishedEvent>(){
            @Override
            public void doUpdate(Display display, LinkedList<TaskFinishedEvent> items) {
              TableItem item = null;
              System.err.println("GUIUpdateQueue<TaskFinishedEvent>::doUpdate: " + items.size());
              for (TaskFinishedEvent event : items) {
                tasksFinished++;
                // TODO: move this into one translatable string with arguments
                labelProgress
                  .setText(tasksFinished
                      + " " + Messages.getString("TaskDecisionPage.of") + " " + tasksTotal + " " + Messages.getString("TaskDecisionPage.tasksFinished")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                Task task = event.getTask();
                item = list.getTableItemForTask(task);
                // FIXME This doesn't seams to work. Even if there is an exception in the sync of one item
                // the item is colored with the "successful" color.
                if (item != null) {
                  if (event.isSuccessful()) {
                    item.setBackground(colorFinishedSuccessful);
                  }
                  else {
                    item.setBackground(colorFinishedUnsuccessful);
                  }
                }
              }
              if (null != item) {
                list.showItem(item);
              }
            }
          });

          synchronizer.performActions(taskTree, new TaskFinishedListener() {
            @Override
            public void taskFinished(final TaskFinishedEvent event) {
              updateQueue.add(event);
            }
          });
View Full Code Here

    statusLine.setMessage(Messages.getString("MainWindow.Sync_Finished")); //$NON-NLS-1$
  }

  @Override
  public void profileExecutionScheduled(Profile profile) {
    Synchronizer sync = guiController.getSynchronizer();
    TaskTree tree = sync.executeProfile(profile, false);
    if (tree == null) {
      profile.setLastError(1, Messages.getString("MainWindow.Error_Comparing_Filesystems")); //$NON-NLS-1$
    }
    else {
      int errorLevel = sync.performActions(tree);
      if (errorLevel > 0) {
        profile.setLastError(errorLevel, Messages.getString("MainWindow.Error_Copying_Files")); //$NON-NLS-1$
      }
      else {
        profile.beginUpdate();
View Full Code Here

          }
        }
      }
      ProfileManager profileManager = new ProfileManager(profilesFile);

      final Synchronizer sync = new Synchronizer();

      // Apply executing options
      if (line.hasOption("r")) {
        Profile p = profileManager.getProfile(line.getOptionValue("r"));
        TaskTree tree = sync.executeProfile(p, false);
        sync.performActions(tree);
        p.setLastUpdate(new Date());
        profileManager.save();
        return;
      }

      boolean activateRemote = false;
      int port = 10000;
      String password = "admin";
      RemoteException listenerStarupException = null;

      if (line.hasOption("p")) {
        activateRemote = true;
        try {
          String portStr = line.getOptionValue("p");
          port = Integer.parseInt(portStr);
        }
        catch (NumberFormatException e) {
        }

        if (line.hasOption("a")) {
          password = line.getOptionValue("a");
        }
      }
      else {
        activateRemote = preferences.listeningForRemoteConnections();
        port = preferences.getRemoteConnectionsPort();
        password = preferences.getRemoteConnectionsPassword();
      }
      if (activateRemote) {
        try {
          Logger logger = LoggerFactory.getLogger("FullSync");

          RemoteController.getInstance().startServer(port, password, profileManager, sync);
          logger.info("Remote Interface available on port: " + port);
        }
        catch (RemoteException e) {
          ExceptionHandler.reportException(e);
          listenerStarupException = e;
        }
      }

      if (line.hasOption("d")) {
        profileManager.addSchedulerListener(new ProfileSchedulerListener() {
          @Override
          public void profileExecutionScheduled(Profile profile) {
            TaskTree tree = sync.executeProfile(profile, false);
            if (tree == null) {
              profile.setLastError(1, "An error occured while comparing filesystems.");
            }
            else {
              int errorLevel = sync.performActions(tree);
              if (errorLevel > 0) {
                profile.setLastError(errorLevel, "An error occured while copying files.");
              }
              else {
                profile.setLastUpdate(new Date());
View Full Code Here

TOP

Related Classes of net.sourceforge.fullsync.Synchronizer

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.