コード例 #1
0
 private void writeHTMLPageHeader(DbObject model, int operation) throws DbException {
   writer.write("<html>"); // NOT LOCALIZABLE
   writer.write("<head>"); // NOT LOCALIZABLE
   String title = operation == AbstractIntegrity.INTEGRITY ? kTitleInteg : kTitleClean;
   writer.write("<TR><TD CLASS=Titre><FONT SIZE=+2>" + title);
   writer.write("</FONT></TD></TR>");
   writer.write("</head>"); // NOT LOCALIZABLE
   writer.write("<body bgcolor=\"#FFFFFF\">"); // NOT LOCALIZABLE
   writer.write("<i>" + kNote + "</i>" + EOL + EOL); // NOT LOCALIZABLE
   writer.write("<hr>"); // NOT LOCALIZABLE
   writer.write("<b>"); // NOT LOCALIZABLE
   if (model instanceof DbBEModel) {
     writer.write(
         MessageFormat.format(
                 AbstractBEIntegrity.kBeModel,
                 new Object[] {getLinksForDbObject(model, false, false)})
             + EOL);
   } else {
     writer.write(
         MessageFormat.format(
                 AbstractORIntegrity.kDataModel,
                 new Object[] {getLinksForDbObject(model, false, false)})
             + EOL);
   }
   writer.write("</b>");
 }
コード例 #2
0
  private void generateExplorerToolBar(IndentWriter writer) throws IOException {
    writer.println("<table style=\"width: 100%;\">");
    writer.println("<tr><td style=\"width: 100%; text-align: right;\">");
    writer.indent();

    // decrease font size
    String pattern =
        "<img src=\"images/font_size_decrease.png\" title=\"{0}\" onclick=\"javascript:decreaseFontSize();\" />";
    String tooltip = LocaleMgr.getInstance().getString("fontSizeDecrease");
    String line = MessageFormat.format(pattern, new Object[] {tooltip});
    writer.println(line);

    // increase font size
    pattern =
        "<img src=\"images/font_size_increase.png\" title=\"{0}\" onclick=\"javascript:increaseFontSize();\" />";
    tooltip = LocaleMgr.getInstance().getString("fontSizeIncrease");
    line = MessageFormat.format(pattern, new Object[] {tooltip});
    writer.println(line);

    // print
    pattern = "<img src=\"images/print.gif\" title=\"{0}\" onclick=\"javascript:print();\" />";
    tooltip = LocaleMgr.getInstance().getString("print");
    line = MessageFormat.format(pattern, new Object[] {tooltip});
    writer.println(line);

    // open all
    pattern = "<img src=\"images/expandall.gif\" title=\"{0}\" onclick=\"openAll();\" />";
    tooltip = LocaleMgr.getInstance().getString("openAll");
    line = MessageFormat.format(pattern, new Object[] {tooltip});
    writer.println(line);

    // close all
    pattern = "<img src=\"images/collapseall.gif\" title=\"{0}\" onclick=\"closeAll();\" />";
    tooltip = LocaleMgr.getInstance().getString("closeAll");
    line = MessageFormat.format(pattern, new Object[] {tooltip});
    writer.println(line);

    writer.unindent();
    writer.println("</td></tr>");
    writer.println("</table>");
  }
コード例 #3
0
  private void writeHTMLPageFooter() throws DbException {
    writer.write("<b><i>"); // NOT LOCALIZABLE
    writer.write(EOL + EOL);
    if (modelErrorCount > 0)
      writer.write(
          MessageFormat.format(kErrorCount0, new Object[] {new Integer(modelErrorCount)}) + EOL);
    if (modelWarningCount > 0)
      writer.write(
          MessageFormat.format(kWarningCount0, new Object[] {new Integer(modelWarningCount)})
              + EOL);
    if (modelErrorCount == 0 && modelWarningCount == 0) writer.write(kNoErrorFound + EOL);
    writer.write("</i></b>"); // NOT LOCALIZABLE

    if (cleanUpMode) {
      String deleteAllOcc =
          this.getCleanupLink(AbstractIntegrity.DELETE_ALL, kCleanAllTip, showDeleteAlImageURL);
      writer.write(EOL + deleteAllOcc + EOL);
    }

    writer.write(EOL + EOL);
    writer.write("</body>"); // NOT LOCALIZABLE
    writer.write("</html>"); // NOT LOCALIZABLE
  }
コード例 #4
0
 // Called at the end of a cell edition, to process the edition result.
 public final void valueForPathChanged(TreePath path, Object newValue) {
   DynamicNode node = (DynamicNode) path.getLastPathComponent();
   Object obj = node.getRealObject();
   if (obj instanceof DbObject) {
     boolean editable = false;
     try {
       Db db = ((DbObject) obj).getDb();
       if (db.isValid()) {
         db.beginReadTrans();
         MetaField editableMetaField = getEditableMetaField((DbObject) obj);
         if (editableMetaField == null)
           editable =
               ApplicationContext.getSemanticalModel()
                   .isNameEditable((DbObject) obj, Explorer.class);
         else
           editable =
               ApplicationContext.getSemanticalModel()
                   .isEditable(editableMetaField, (DbObject) obj, Explorer.class);
         db.commitTrans();
       }
     } catch (DbException ex) {
       org.modelsphere.jack.util.ExceptionHandler.processUncatchedException(
           ApplicationContext.getDefaultMainFrame(), ex);
       editable = false;
     }
     if (!editable) return;
   } else {
     return;
   }
   DbObject semObj = (DbObject) obj;
   try {
     MetaField editableMetaField = getEditableMetaField(semObj);
     String transName =
         (editableMetaField == null
             ? LocaleMgr.action.getString("rename")
             : MessageFormat.format(kUpdate0, new Object[] {editableMetaField.getGUIName()}));
     semObj.getDb().beginTrans(Db.WRITE_TRANS, transName);
     if (editableMetaField == null) {
       if (semObj.getTransStatus() == Db.OBJ_REMOVED) return;
       semObj.setName((String) newValue);
     } else semObj.set(editableMetaField, (String) newValue);
     semObj.getDb().commitTrans();
     nodeChanged(node); // in case it is a secondary node (only the
     // primary node is updated by the refresh
     // listener).
   } catch (Exception ex) {
     org.modelsphere.jack.util.ExceptionHandler.processUncatchedException(
         ApplicationContext.getDefaultMainFrame(), ex);
   }
 }
コード例 #5
0
  // this update is always safe
  public final void updateSelectionAction() throws DbException {
    ApplicationDiagram diag = ApplicationContext.getFocusManager().getActiveDiagram();
    Object[] objects = ApplicationContext.getFocusManager().getSelectedSemanticalObjects();
    if ((diag == null) || (objects.length != 1) || !(objects[0] instanceof DbORAssociationEnd)) {
      setSelectedIndex(-1);
      setEnabled(false);
      return;
    }

    // update values
    dbos.clear();

    DbORAssociationEnd end = (DbORAssociationEnd) objects[0];
    DbORPrimaryUnique selKey = end.getReferencedConstraint();

    DbORAbsTable tableSo = (DbORAbsTable) end.getOppositeEnd().getClassifier();
    DbEnumeration dbEnum = tableSo.getComponents().elements(DbORPrimaryUnique.metaClass);
    while (dbEnum.hasMoreElements()) {
      DbORPrimaryUnique key = (DbORPrimaryUnique) dbEnum.nextElement();
      dbos.add(key);
    }
    dbEnum.close();

    int sizeadjustment = (dbos.size() == 0) ? 1 : 2; // adding a separator
    // and an item for
    // removing the
    // referenced
    // constraint
    // if no keys, do not add a separator
    Object[] items = new Object[dbos.size() + sizeadjustment];

    items[0] = kNoReferencedConstraint;
    if (sizeadjustment == 2) {
      items[1] = null;
    }

    String tableName = tableSo.getName();
    for (int i = 0; i < dbos.size(); i++) {
      String name = ((DbORPrimaryUnique) dbos.get(i)).getName();
      items[i + sizeadjustment] =
          MessageFormat.format(kKeyNamePatern, new Object[] {tableName, name});
    }
    setDomainValues(items);

    if (selKey == null) setSelectedIndex(0);
    else setSelectedIndex(dbos.indexOf(selKey) + sizeadjustment);

    setEnabled(true);
  }
コード例 #6
0
  protected final void doActionPerformed() {
    DbObject[] selObjs = ORActionFactory.getActiveObjects();
    if (selObjs == null || selObjs.length > 1 || selObjs.length == 0) {
      throw new RuntimeException("Expecting selection of one database");
    }
    boolean userHasCancelled = false;
    DbORDatabase database = null;
    try {
      selObjs[0].getDb().beginTrans(Db.READ_TRANS);
      DbORModel model = null;

      if (selObjs[0] instanceof DbORDatabase) {
        database = (DbORDatabase) selObjs[0];
      } else {
        model =
            (selObjs[0] instanceof DbORModel)
                ? (DbORModel) selObjs[0]
                : (DbORModel) selObjs[0].getCompositeOfType(DbORModel.metaClass);
        if (model != null) {
          if (model instanceof DbORDataModel) {
            database = ((DbORDataModel) model).getDeploymentDatabase();
          } else if (model instanceof DbORDomainModel) {
            database = ((DbORDomainModel) model).getDeploymentDatabase();
          } else if (model instanceof DbOROperationLibrary) {
            database = ((DbOROperationLibrary) model).getDeploymentDatabase();
          } // end if
        } // end if
      } // end if
      selObjs[0].getDb().commitTrans();

      if ((model != null) && (database == null)) {
        String transName =
            MessageFormat.format(
                kCreation, new Object[] {DbORDataModel.fDeploymentDatabase.getGUIName()});
        selObjs[0].getDb().beginWriteTrans(transName);
        int option =
            JOptionPane.showConfirmDialog(
                ApplicationContext.getDefaultMainFrame(),
                kNoActiveDatabase,
                ApplicationContext.getApplicationName(),
                JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.INFORMATION_MESSAGE);
        if (option == 0) {
          DbObject composite = model.getProject();
          DbSMSTargetSystem ts = model.getTargetSystem();
          database = AnyORObject.createDatabase(composite, ts);
          if (model instanceof DbORDataModel) {
            DbORDataModel dm = (DbORDataModel) model;
            dm.setDeploymentDatabase(database);
          } else if (model instanceof DbOROperationLibrary) {
            DbOROperationLibrary ol = (DbOROperationLibrary) model;
            ol.setDeploymentDatabase(database);
          } else if (model instanceof DbORDomainModel) {
            DbORDomainModel dm = (DbORDomainModel) model;
            dm.setDeploymentDatabase(database);
          } // end if
        } else if (option == 1) {
          userHasCancelled = true;
        } // end if

        selObjs[0].getDb().commitTrans();
      } // end if
    } catch (DbException e) {
      ExceptionHandler.processUncatchedException(ApplicationContext.getDefaultMainFrame(), e);
    } // end try

    if (userHasCancelled) {
      return;
    }

    DbSMSTargetSystem target = null;
    try {
      Db db = database.getDb();
      db.beginTrans(Db.READ_TRANS);
      target = database.getTargetSystem();
      DBMSDefaultForwardWizardModel model =
          new DBMSDefaultForwardWizardModel(target.getID().intValue());
      model.setAbstractPackage(database);
      model.setDatabaseName(database.getName());
      db.commitTrans();
      Wizard wizard = new Wizard(model);
      wizard.setVisible(true);
    } catch (InstantiationException e) {
      Component parent = ApplicationContext.getDefaultMainFrame();
      Db.abortAllTrans();
      ExceptionHandler.showErrorMessage(parent, e.getMessage());
    } catch (DbException e) {
      ExceptionHandler.processUncatchedException(ApplicationContext.getDefaultMainFrame(), e);
    } catch (RuntimeException e) {
      Component parent = ApplicationContext.getDefaultMainFrame();
      String pattern = kPattern;
      String targetName = kUnknown;

      try {
        Db db = target.getDb();
        db.beginReadTrans();
        targetName = target.getName() + " " + target.getVersion();
        db.commitTrans();
      } catch (DbException ex) {
        // leave targetName's value to unknown
      }

      String msg = MessageFormat.format(pattern, new Object[] {targetName});
      Db.abortAllTrans();
      ExceptionHandler.showErrorMessage(parent, msg);
    }
  }
コード例 #7
0
 private void refreshTitle() throws DbException {
   setTitle(MessageFormat.format(NOTATIONS, new Object[] {project.getFullDisplayName()}));
 }