use of com.ramussoft.gui.qualifier.table.TreeTableNode in project ramus by Vitaliy-Yakovchuk.
the class QualifierView method refreshActions.
@Override
protected void refreshActions() {
super.refreshActions();
TreePath selectionPath = table.getTreeSelectionModel().getSelectionPath();
boolean anySelected = selectionPath != null;
qualifierPreferenciesAction.setEnabled(anySelected);
Row sRow = null;
if (selectionPath != null)
sRow = ((TreeTableNode) selectionPath.getLastPathComponent()).getRow();
if (sRow == null)
convertQualifierToElementsAction.setEnabled(false);
else {
if ((sRow.getChildCount() == 0) || (table.getTreeSelectionModel().getSelectionPaths().length > 1))
convertQualifierToElementsAction.setEnabled(false);
else
convertQualifierToElementsAction.setEnabled(canDeleteLastLeveleOfQualifiers(sRow, qAttribute));
}
openQualifier.setEnabled(anySelected && sRow != null && sRow.getChildCount() == 0);
if (deleteElementAction.isEnabled()) {
TreePath[] paths = table.getTreeSelectionModel().getSelectionPaths();
boolean e = true;
for (TreePath path : paths) {
Row row = ((TreeTableNode) path.getLastPathComponent()).getRow();
if (engine.getElement(row.getElementId()) == null)
row = null;
if (row == null) {
e = false;
break;
}
if (row.getChildCount() > 0) {
e = false;
break;
}
Long attribute = (Long) row.getAttribute(qAttribute);
if ((attribute != null) && (!accessRules.canDeleteQualifier(attribute))) {
e = false;
break;
}
}
deleteElementAction.setEnabled(e);
}
}
use of com.ramussoft.gui.qualifier.table.TreeTableNode in project ramus by Vitaliy-Yakovchuk.
the class Exporter method exportToFile.
public void exportToFile(List<Attribute> attributes, Qualifier qualifier, File file) throws IOException {
Workbook workbook = new HSSFWorkbook();
CellStyle headerStyle;
Font headerFont = workbook.createFont();
headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
headerStyle = createBorderedStyle(workbook);
headerStyle.setAlignment(CellStyle.ALIGN_CENTER);
headerStyle.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
headerStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
headerStyle.setFont(headerFont);
CellStyle normalStyle;
normalStyle = createBorderedStyle(workbook);
normalStyle.setAlignment(CellStyle.ALIGN_LEFT);
normalStyle.setWrapText(true);
CellStyle dateStyle = createDateStyle(workbook);
String name = qualifier.getName();
Sheet sheet;
if ((name == null) || (name.equals("")))
sheet = workbook.createSheet();
else
sheet = workbook.createSheet(name);
sheet.setDisplayGridlines(false);
sheet.setPrintGridlines(false);
sheet.setFitToPage(true);
sheet.setHorizontallyCenter(true);
sheet.setAutobreaks(true);
Row headerRow = sheet.createRow(0);
headerRow.setHeightInPoints(12.75f);
for (int i = 0; i < attributes.size(); i++) {
Cell cell = headerRow.createCell(i);
cell.setCellValue(attributes.get(i).getName());
cell.setCellStyle(headerStyle);
}
RowSet rowSet = tableView.getComponent().getRowSet();
RowTreeTableModel model = tableView.getComponent().getModel();
int i = 1;
for (com.ramussoft.database.common.Row row : rowSet.getAllRows()) {
Row cellRow = sheet.createRow(i);
int j = 0;
for (Attribute attribute : attributes) {
if (attribute.getAttributeType().isLight()) {
Cell cell = cellRow.createCell(j);
cell.setCellStyle(normalStyle);
Object object = row.getAttribute(attribute);
if (object != null) {
if (object instanceof Date) {
cell.setCellStyle(dateStyle);
cell.setCellValue((Date) object);
} else {
TreeTableNode node = model.findNode(row);
if (node != null) {
int index = rowSet.getAttributeIndex(attribute) - 1;
if (index >= 00) {
Object object2 = model.getValueAt(node, index);
if (object2 != null)
cell.setCellValue(object2.toString());
}
}
}
}
}
j++;
}
i++;
}
FileOutputStream fileOutputStream = new FileOutputStream(file);
workbook.write(fileOutputStream);
fileOutputStream.close();
}
Aggregations