public void runInBackground() {
   ApplicationContext appC = qedit.QEditApp.getInstance().getContext();
   TaskMonitor taskMonitor = appC.getTaskMonitor();
   TaskService taskService = appC.getTaskService();
   taskService.execute(this);
   taskMonitor.setForegroundTask(this);
 }
  @Override
  protected Object doInBackground() throws Exception {

    java.io.File selectedFile =
        rif.getRelatedFile() == null
            ? saveFileChooserWindow.getSelectedFile()
            : rif.getRelatedFile();

    if (selectedFile == null) {
      QEditApp.getView().getStatusLabel().setText("Info: Report is not saved");
      return null;
    }

    String filePath = selectedFile.getAbsolutePath();
    if (!filePath.contains(".report")) {
      filePath += ".report";
    }

    java.io.File f = new java.io.File(filePath);
    rif.updateReport();
    ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(f));
    oos.writeObject((QPRFReport) rif.getQprfreport());

    rif.setTitle(selectedFile.getName().replaceAll(".report", ""));
    QEditApp.getView().getStatusLabel().setText("Document Saved");

    Preferences prefs = Preferences.userRoot();
    String sessionHistoryFromPrefsXML = prefs.get(QEditView.QEDIT_SESSION_HISTORY, null);
    SessionHistory sh = null;

    if (sessionHistoryFromPrefsXML == null) {
      sh = new SessionHistory();
    } else {
      sh = (SessionHistory) new XStream().fromXML(sessionHistoryFromPrefsXML);
    }
    Session session =
        new Session(
            filePath,
            rif.getQprfreport().getCompound().getUri(),
            rif.getQprfreport().getModel().getUri());
    session.setName(rif.getTitle());
    sh.push(session);
    prefs.put(QEditView.QEDIT_SESSION_HISTORY, new XStream().toXML(sh));
    QEditView.setSessionHistory(sh);
    QEditApp.getView().refreshSessionsFromPreferences();
    return null;
  }
Exemple #3
0
 @Override
 protected Object doInBackground() throws Exception {
   try {
     AuthenticationToken token = new AuthenticationToken(username, password);
     QEditApp.setAuthentication(token);
     return token;
   } catch (final ServiceInvocationException sie) {
     exceptionMessage = "Invalid credentials";
     throw sie;
   }
 }
 public AbstractTask() {
   super(qedit.QEditApp.getApplication());
 }