Exemplo n.º 1
0
  public int compareTo(Category other) {
    int compareTo = 0;

    compareTo = Format.null2blank(this.name).compareTo(Format.null2blank(other.name));

    return compareTo;
  }
  @Override
  public int compareTo(AbstractObjectModel other) {
    WithSchemaModel otherModel = (WithSchemaModel) other;

    int compareTo = 0;

    compareTo =
        Format.null2blank(this.schema)
            .toUpperCase()
            .compareTo(Format.null2blank(otherModel.schema).toUpperCase());

    if (compareTo != 0) {
      return compareTo;
    }

    compareTo =
        Format.null2blank(this.getName())
            .toUpperCase()
            .compareTo(Format.null2blank(other.getName()).toUpperCase());

    if (compareTo != 0) {
      return compareTo;
    }

    return compareTo;
  }
  /** {@inheritDoc} */
  @Override
  protected void refreshOutlineVisuals() {
    Relation model = (Relation) this.getModel();

    ERDiagram diagram = (ERDiagram) this.getRoot().getContents().getModel();

    int viewMode = diagram.getDiagramContents().getSettings().getOutlineViewMode();

    boolean first = true;
    StringBuilder sb = new StringBuilder();

    for (NormalColumn foreignKeyColumn : model.getForeignKeyColumns()) {
      if (first) {
        first = false;
      } else {
        sb.append(", ");
      }

      if (viewMode == Settings.VIEW_MODE_PHYSICAL) {
        sb.append(Format.null2blank(foreignKeyColumn.getPhysicalName()));

      } else if (viewMode == Settings.VIEW_MODE_LOGICAL) {
        sb.append(Format.null2blank(foreignKeyColumn.getLogicalName()));

      } else {
        sb.append(Format.null2blank(foreignKeyColumn.getLogicalName()));
        sb.append("/");
        sb.append(Format.null2blank(foreignKeyColumn.getPhysicalName()));
      }
    }

    this.setWidgetText(sb.toString());
    this.setWidgetImage(Activator.getImage(ImageKey.FOREIGN_KEY));
  }
  public String getNameWithSchema(String database) {
    if (this.schema == null) {
      return Format.null2blank(this.getName());
    }

    DBManager dbManager = DBManagerFactory.getDBManager(database);

    if (!dbManager.isSupported(DBManager.SUPPORT_SCHEMA)) {
      return Format.null2blank(this.getName());
    }

    return this.schema + "." + Format.null2blank(this.getName());
  }
  @Override
  public void initComposite() {
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    this.setLayout(gridLayout);

    this.descriptionText =
        CompositeFactory.createTextArea(null, this, "label.table.description", -1, 400, 1, true);

    this.descriptionText.setText(Format.null2blank(copyData.getDescription()));
  }
  /** {@inheritDoc} */
  @Override
  protected Control createDialogArea(Composite parent) {
    this.getShell().setText(ResourceString.getResourceString(this.getTitle()));

    Composite composite = (Composite) super.createDialogArea(parent);

    this.textArea =
        CompositeFactory.createTextArea(
            null, composite, this.getMessage(), 400, 200, 1, false, false);

    composite.setLayout(new GridLayout());

    this.textArea.setText(Format.null2blank(this.getData()));

    return composite;
  }
  private void setComplexUniqueKeyMatrix(
      HSSFWorkbook workbook,
      HSSFSheet sheet,
      ERTable table,
      CellLocation cellLocation,
      MatrixCellStyle matrixCellStyle,
      boolean isLogical) {

    int rowNum = cellLocation.r;
    int columnNum = cellLocation.c;

    HSSFRow headerTemplateRow = sheet.getRow(rowNum);
    HSSFCell headerTemplateCell = headerTemplateRow.getCell(columnNum);

    int num = table.getComplexUniqueKeyList().size();

    if (num == 0) {
      headerTemplateRow.removeCell(headerTemplateCell);

      HSSFRow row = sheet.getRow(rowNum - 1);
      if (row != null) {
        HSSFCell cell = row.getCell(columnNum);
        if (cell != null) {
          cell.getCellStyle().setBorderBottom(headerTemplateCell.getCellStyle().getBorderBottom());
        }
      }
      return;
    }

    HSSFRow headerRow = sheet.createRow(rowNum++);

    for (int i = 0; i < num + 1; i++) {
      HSSFCell cell = headerRow.createCell(columnNum + i);

      if (i == 0) {
        cell.setCellStyle(matrixCellStyle.style11);

      } else {
        ComplexUniqueKey complexUniqueKey = table.getComplexUniqueKeyList().get(i - 1);
        HSSFRichTextString text =
            new HSSFRichTextString(Format.null2blank(complexUniqueKey.getUniqueKeyName()));
        cell.setCellValue(text);

        if (i != num) {
          cell.setCellStyle(matrixCellStyle.style12);
        } else {
          cell.setCellStyle(matrixCellStyle.style13);
        }
      }
    }

    int columnSize = table.getExpandedColumns().size();
    for (int j = 0; j < columnSize; j++) {
      NormalColumn normalColumn = table.getExpandedColumns().get(j);

      HSSFRow row = POIUtils.insertRow(sheet, rowNum++);

      for (int i = 0; i < num + 1; i++) {
        HSSFCell cell = row.createCell(columnNum + i);

        if (i == 0) {
          String columnName = null;
          if (isLogical) {
            columnName = normalColumn.getLogicalName();
          } else {
            columnName = normalColumn.getPhysicalName();
          }

          HSSFRichTextString text = new HSSFRichTextString(columnName);
          cell.setCellValue(text);
          cell.setCellStyle(headerTemplateCell.getCellStyle());

          if (j != columnSize - 1) {
            cell.setCellStyle(matrixCellStyle.style21);
          } else {
            cell.setCellStyle(matrixCellStyle.style31);
          }

        } else {
          ComplexUniqueKey complexUniqueKey = table.getComplexUniqueKeyList().get(i - 1);
          List<NormalColumn> targetColumnList = complexUniqueKey.getColumnList();

          int indexNo = targetColumnList.indexOf(normalColumn);
          if (indexNo != -1) {
            cell.setCellValue(indexNo + 1);
          }

          if (i != num) {
            if (j != columnSize - 1) {
              cell.setCellStyle(matrixCellStyle.style22);
            } else {
              cell.setCellStyle(matrixCellStyle.style32);
            }

          } else {
            if (j != columnSize - 1) {
              cell.setCellStyle(matrixCellStyle.style23);
            } else {
              cell.setCellStyle(matrixCellStyle.style33);
            }
          }
        }
      }
    }
  }