Package net.sourceforge.fullsync

Examples of net.sourceforge.fullsync.ProfileManager


    this.guiController = initGuiController;
    initGUI();

    getShell().addShellListener(this);

    ProfileManager pm = guiController.getProfileManager();
    pm.addSchedulerListener(this);
    pm.addSchedulerChangeListener(this);
    guiController.getSynchronizer().getTaskGenerator().addTaskGenerationListener(this);

    // REVISIT [Michele] Autogenerated event? I don't like it!
    schedulerStatusChanged(pm.isSchedulerEnabled());
  }
View Full Code Here


  }

  @Override
  public void deleteProfile(final Profile p) {
    if (p != null) {
      ProfileManager profileManager = guiController.getProfileManager();

      MessageBox mb = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
      mb.setText(Messages.getString("MainWindow.Confirmation")); //$NON-NLS-1$
      mb.setMessage(Messages.getString("MainWindow.Do_You_Want_To_Delete_Profile") + " " + p.getName() + " ?"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      if (mb.open() == SWT.YES) {
        profileManager.removeProfile(p);
        profileManager.save();
      }
    }
  }
View Full Code Here

      }
    }
  }

  protected void toolItemScheduleWidgedSelected(SelectionEvent evt) {
    ProfileManager profileManager = guiController.getProfileManager();
    if (profileManager.isSchedulerEnabled()) {
      profileManager.stopScheduler();
    }
    else {
      profileManager.startScheduler();
    }
    // updateTimerEnabled();
  }
View Full Code Here

          if (oldProfiles.exists()) {
            backupFile(oldProfiles, newProfiles, "profiles_old.xml");
          }
        }
      }
      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());
              }
            }
          }
        });
        profileManager.startScheduler();
        /*
         * Object mutex = new Object();
         * synchronized (mutex) {
         * mutex.wait();
         * }
         */
      }
      else {
        try {
          GuiController guiController = new GuiController(preferences, profileManager, sync);
          guiController.startGui(line.hasOption('m'));

          if (!line.hasOption('P') && !preferences.getHelpShown() && (null == System.getProperty("net.sourceforge.fullsync.skipHelp"))) {
            preferences.setHelpShown(true);
            preferences.save();
            File f = new File("docs/manual/manual.html");
            if (f.exists()) {
              GuiController.launchProgram(f.getAbsolutePath());
            }
          }

          if (listenerStarupException != null) {
            ExceptionHandler.reportException("Unable to start incoming connections listener.", listenerStarupException);
          }

          if (preferences.getAutostartScheduler()) {
            profileManager.startScheduler();
          }

          guiController.run();
          guiController.disposeGui();
        }
        catch (Exception ex) {
          ExceptionHandler.reportException(ex);
        }
        finally {
          profileManager.save();
        }

        // FIXME [Michele] For some reasons there is some thread still alive if you run the remote interface
        RemoteController.getInstance().stopServer();
        if (null == System.getProperty("net.sourceforge.fullsync.skipExit")) {
View Full Code Here

TOP

Related Classes of net.sourceforge.fullsync.ProfileManager

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.