/**
   * Rename the selected session.
   *
   * @param session The session to be renamed
   */
  protected void renameSession(SessionAdapter session) {
    TopLinkSessionsAdapter sessions = (TopLinkSessionsAdapter) session.getParent();
    SimplePropertyValueModel stringHolder = new SimplePropertyValueModel();
    stringHolder.setValue(session.getName());

    RenameDialog dialog =
        new RenameDialog(getWorkbenchContext(), stringHolder, sessions.getAllSessionsNames());
    dialog.setVisible(true);

    if (dialog.wasConfirmed()) {
      session.setName((String) stringHolder.getValue());
    }
  }
Ejemplo n.º 2
0
  private boolean saveImp(File savePath, WorkbenchContext workbenchContext) {
    TopLinkSessionsAdapter sessions = this.topLinkSessions();

    try {
      sessions
          .getProperties()
          .saveAs(preferences(), savePath); // Need to be done before sessions.save()
      sessions.save(savePath);
      return true;
    } catch (Throwable e) {
      showErrorMessage(e, workbenchContext);
      return false;
    }
  }
Ejemplo n.º 3
0
  public boolean save(File mostRecentSaveDirectory, WorkbenchContext workbenchContext) {
    TopLinkSessionsAdapter sessions = this.topLinkSessions();
    File path = sessions.getPath();
    boolean saved = false;

    // - There is no directory before the file name and it starts with Sessions,
    //   we assume this is an untitled sessions.xml
    // - The location might have been marked read only, always do a Save As
    if (path.getPath().startsWith(SCSessionsPropertiesManager.UNTITLED_FILE_NAME)) {
      saved = saveAs(mostRecentSaveDirectory, workbenchContext);
    } else {
      // The Read-Only flag was changed after the file was opened
      if (!path.canWrite()) {
        // Show an error message and ask if we should try again
        if (firstTimeReadOnlyFlagWasDetected) {
          showErrorReadOnlyMessage(workbenchContext);
          firstTimeReadOnlyFlagWasDetected = false;

          // We can try to save again, use Save As path
          if (canRetryToSave(workbenchContext)) {
            saved = saveAs(mostRecentSaveDirectory, workbenchContext);

            if (saved) {
              displayStringChanged();
            }
          }
        }
        // - A Read-Only file was opened and needs to be saved
        // - The save is invoked again on a Read-Only file, right away use the Save As path
        else {
          saved = saveAs(mostRecentSaveDirectory, workbenchContext);
        }
      }
      // The file is not an untitled file, the file is not marked as Read-Only
      // then attempt to save it
      else {
        saved = saveImp(path, workbenchContext);
        firstTimeReadOnlyFlagWasDetected = false;

        if (saved) {
          displayStringChanged();
        }
      }
    }
    return saved;
  }
Ejemplo n.º 4
0
  public ProjectNode(
      TopLinkSessionsAdapter topLinkSessions,
      TreeNodeValueModel parent,
      SCPlugin plugin,
      ApplicationContext context) {

    super(topLinkSessions, parent, plugin, context);
    this.firstTimeReadOnlyFlagWasDetected = topLinkSessions.getPath().canWrite();
  }