📄 applicationmetadatahelper.java
字号:
for(int rowIdx = 0; rowIdx < rows.length; rowIdx++) {
Col[] cols = rows[rowIdx].getCol();
FormLayoutMeta.Col[] metaCols = new FormLayoutMeta.Col[cols.length];
for(int colIdx = 0; colIdx < cols.length; colIdx++) {
Col col = cols[colIdx];
String fieldId = col.getFieldid();
Button button = EntityHelper.FormHelper.getButtonById(form, fieldId);
if (button != null &&
!AccessRightsManager.canUserPerformAction(formPermissions.getLevel(), getActionForButton(button))) {
metaCols[colIdx] = new FormLayoutMeta.Col("", col.getRowspan(), col.getColspan());
} else {
metaCols[colIdx] = new FormLayoutMeta.Col(fieldId, col.getRowspan(), col.getColspan());
}
}
metaRows[rowIdx] = new FormLayoutMeta.Row(metaCols);
}
HiddenControl[] hiddenControls = EntityHelper.FormHelper.getHiddenControls(form);
String[] hiddenControlsIds = new String[hiddenControls.length];
for(int i = 0; i < hiddenControls.length; i++) {
hiddenControlsIds[i] = hiddenControls[i].getFieldid();
}
return new FormLayoutMeta(metaRows, metaHeaders, hiddenControlsIds);
} else {
return null;
}
}
private static ContextMenuMeta getContextMenuMeta(Form form, PermissionSet permissions, String langId, ServletContext ctx) {
ContextMenuConfigManagerLocal contextMenuManager = IntegratorHelper.getActionContext(ctx).getContextMenuManager();
ContextMenu contextMenu = contextMenuManager.getContextMenuByForm(form.getName());
ContextMenuMeta meta = null;
if(contextMenu != null) {
contextMenu = contextMenuManager.getLocalizedContextMenu(langId, contextMenu);
List<MenuItemMeta> menuItems = new ArrayList<MenuItemMeta>();
for(MenuItem menuItem : contextMenu.getMenuItem()) {
MenuItemMeta metaItem = null;
if("delete".equalsIgnoreCase(menuItem.getName())) {
Permission formPerm = permissions.getPermissionObject(PermissionObjectType.FORM, form.getName());
if(AccessRightsManager.canUserPerformAction(formPerm.getLevel(), CommonActionTypes.DELETE_OWNED_RECORDS)) {
metaItem = new MenuItemMeta(menuItem.getName(), menuItem.getCaption());
}
} else {
metaItem = new MenuItemMeta(menuItem.getName(), menuItem.getCaption());
}
if(metaItem != null) {
menuItems.add(metaItem);
}
}
meta = new ContextMenuMeta(menuItems.toArray(new MenuItemMeta[0]));
}
return meta;
}
private static void fillLinkedFormIndexes(MetaData metaData) {
for(FocusMeta focusMeta : metaData.getFocuses()) {
for(SubFocusMeta subFocusMeta : focusMeta.getSubFocuses()) {
for(TabMeta tabMeta : subFocusMeta.getTabs()) {
for(FamgMeta meta : tabMeta.getFamgs()) {
Map<String, String> links = new HashMap<String, String>();
FormLinkMeta[] linksMeta = meta.getForm().getLinks();
for(FormLinkMeta link : linksMeta) {
links.put(link.getFieldId(), link.getLinkedFormId());
}
FieldMeta[] fields = meta.getForm().getEntityMeta().getFields();
for(FieldMeta field : fields) {
String formId = links.get(field.getFieldID());
if(formId != null) {
field.setLinkedForm(getFamgIndex(metaData, formId));
}
}
}
}
}
}
}
private static void addButton(ArrayList<FormButtonMeta> buttons,
String id, String caption, String icon, String tag,
String captionStyle) {
FormButtonMeta meta;
meta = new FormButtonMeta(id, caption, FormButtonMeta.BUTTON_TYPE_LINK,
icon, captionStyle);
meta.setTag(tag);
buttons.add(meta);
}
private static FormLayoutMeta createLayout(FormButtonMeta[] resultButtons) {
final int TOTAL_COLUMNS = 6;
final int FORMS_FIRST_COLUMN = 2;
final int INDENT_WIDTH = 30;
final int DESCRIPTION_INDENT_WIDTH = 300;
ArrayList<FormLayoutMeta.Row> rowsList = new ArrayList<FormLayoutMeta.Row>();
int n = resultButtons.length;
int i = 0;
while (i < n) {
FormButtonMeta buttonMeta = resultButtons[i];
String objectType = buttonMeta.getTag();
FormLayoutMeta.Col[] cols;
if ("FORM".equals(objectType)) {
cols = createLayoutColumns(TOTAL_COLUMNS);
int j = FORMS_FIRST_COLUMN;
do {
cols[j].setFieldID(buttonMeta.getId());
cols[j + 1].setFieldID(buttonMeta.getId() + "_desc");
j += 2;
i++;
if (i < n) {
buttonMeta = resultButtons[i];
objectType = buttonMeta.getTag();
}
} while ((i < n ) && (j < TOTAL_COLUMNS) && "FORM".equals(objectType));
} else {
int position = -1;
if ("TAB".equals(objectType)) {
// position = 2;
} else if ("SUBFOCUS".equals(objectType)) {
position = 1;
} else if ("FOCUS".equals(objectType)) {
position = 0;
}
cols = createLayoutColumnsWithColspan(position + 1, TOTAL_COLUMNS);
cols[position].setFieldID(buttonMeta.getId());
i++;
}
FormLayoutMeta.Row row = new FormLayoutMeta.Row(cols);
rowsList.add(row);
}
FormLayoutMeta.Row[] rows = rowsList.toArray(new FormLayoutMeta.Row[0]);
FormLayoutMeta resultFormLayout = new FormLayoutMeta(rows);
FormLayoutMeta.ColumnHeader[] headers = new FormLayoutMeta.ColumnHeader[TOTAL_COLUMNS];
for (int j = 0; j < headers.length; j++) {
headers[j] = new FormLayoutMeta.ColumnHeader();
if (j < FORMS_FIRST_COLUMN) {
headers[j].setClientWidth(INDENT_WIDTH);
} else if ((j == FORMS_FIRST_COLUMN + 1) || (j == FORMS_FIRST_COLUMN + 3)) {
headers[j].setClientWidth(DESCRIPTION_INDENT_WIDTH);
}
}
resultFormLayout.setHeaders(headers);
return resultFormLayout;
}
private static FormLayoutMeta.Col[] createLayoutColumns(int columnsNumber) {
FormLayoutMeta.Col[] cols = new FormLayoutMeta.Col[columnsNumber];
for (int j = 0; j < cols.length; j++) {
cols[j] = new FormLayoutMeta.Col();
}
return cols;
}
private static FormLayoutMeta.Col[] createLayoutColumnsWithColspan(int columnsNumber, int totalColumnsNumber) {
FormLayoutMeta.Col[] cols = createLayoutColumns(columnsNumber);
int colspan = totalColumnsNumber - columnsNumber + 1;
cols[columnsNumber - 1].setColspan(colspan);
return cols;
}
private static void createAdhocReportGridMeta(MetaData metaData, LogonSession ls, ServletContext ctx) {
FieldMeta[] fieldsForGrid = EntityViewHelper.getMetaInfoForEntity(IntegratorReports.REPORT_SAVING_ENTITY,
EntityViewHelper.FieldsModificator.GRID, true, ls, IntegratorHelper.getActionContext(ctx));
metaData.setAdhocReportsMeta(new GridMeta(fieldsForGrid, CollectionsHelper.createIncrementalArray(fieldsForGrid.length, 0)));
}
private static void createMyQueWebTab(MetaData metaData) {
TabMeta tabMeta = metaData.getTabMeta(
MY_QUEWEB_FOCUS_NAME, MY_QUEWEB_SUBFOCUS_NAME, MY_QUEWEB_TAB_NAME);
if (tabMeta == null) {
return; // the user does not have My QueWeb tab
}
ArrayList<FamgMeta> resultFamgs = new ArrayList<FamgMeta>();
EntityMeta resultEntity = new EntityMeta();
FormMeta resultForm = new FormMeta(resultEntity, "My QueWeb");
GridMeta resultGrid = new GridMeta(resultEntity.getFields(), new long[0]);
FamgMeta resultFamg = new FamgMeta(resultForm, resultGrid, "MyQueWeb");
resultFamgs.add(resultFamg);
ArrayList<FormButtonMeta> resultButtonsList = new ArrayList<FormButtonMeta>();
ArrayList<FormHtmlElementMeta> resultHtmlElementsList = new ArrayList<FormHtmlElementMeta>();
FocusMeta[] focuses = metaData.getFocuses();
for (int i = 0; i < focuses.length; i++) {
FocusMeta focus = focuses[i];
String focusID = focus.getFocusName();
if (focusID.equalsIgnoreCase("MyQueWeb")) {
continue; // ignore My QueWeb focus
}
addButton(resultButtonsList, focusID,
focus.getCaption(), focus.getIcon(), "FOCUS",
"myQueWeb_focus");
SubFocusMeta[] subFocuses = focus.getSubFocuses();
for (int j = 0; j < subFocuses.length; j++) {
SubFocusMeta subFocus = subFocuses[j];
String subFocusID = focusID + "__" + subFocus.getSubFocusName();
addButton(resultButtonsList, subFocusID,
subFocus.getCaption(), subFocus.getIcon(), "SUBFOCUS",
"myQueWeb_subFocus");
TabMeta[] tabs = subFocus.getTabs();
for (int k = 0; k < tabs.length; k++) {
TabMeta tab = tabs[k];
// String tabID = subFocusID + "__" + tab.getTabName();
// addButton(resultButtonsList, tabID,
// tab.getCaption(), tab.getIcon(), "TAB");
FamgMeta[] famgs = tab.getFamgs();
for (int l = 0; l < famgs.length; l++) {
FormMeta form = famgs[l].getForm();
if (form.isInMyQueWeb()) {
String formID = famgs[l].getFormID();
addButton(resultButtonsList, formID,
form.getCaption(), form.getIcon(), "FORM",
"myQueWeb_form");
FormHtmlElementMeta htmlMeta = new FormHtmlElementMeta(formID + "_desc",
"<div style='padding: 2px 20px; color: blue;'>" +
form.getDescription() +
"</div>");
resultHtmlElementsList.add(htmlMeta);
}
}
}
}
}
FormButtonMeta[] resultButtons = resultButtonsList.toArray(new FormButtonMeta[0]);
resultForm.setButtons(resultButtons);
FormHtmlElementMeta[] resultHtmlElements = resultHtmlElementsList.toArray(new FormHtmlElementMeta[0]);
resultForm.setHtmlElements(resultHtmlElements);
// create layout:
FormLayoutMeta resultFormLayout = createLayout(resultButtons);
resultForm.setLayoutMeta(resultFormLayout);
FamgMeta[] famgs = resultFamgs.toArray(new FamgMeta[0]);
tabMeta.setFamgs(famgs);
}
private static void createDashboardTab(MetaData metaData, LogonSession ls, ActionContext ctx) {
TabMeta tabMeta = metaData.getTabMeta(
MY_QUEWEB_FOCUS_NAME, MY_QUEWEB_SUBFOCUS_NAME, DASHBOARD_TAB_NAME);
if (tabMeta == null) {
return; // the user does not have the Dashboard tab
}
EntityMeta entityMeta = new EntityMeta();
FormMeta formMeta = new FormMeta(entityMeta, "Dashboard"); // TODO caption?
GridMeta gridMeta = new GridMeta(); // no grid
FamgMeta famgMeta = new FamgMeta(formMeta, gridMeta, "dashboard"); // TODO formID?
ChartModel[] chartModels = new ChartModel[0];
try {
chartModels = ChartDataManager.getSystemCharts(ls, ctx);
logger.DEBUG("Count of loaded system charts: " + chartModels.length);
} catch (EQLException e) {
logger.ERROR("Unable to retrieve system charts", e);
throw new GenericSystemException("Unable to retrieve system charts", e);
}
formMeta.setCharts(chartModels);
// create layout:
List<FormLayoutMeta.Row> rows = new ArrayList<FormLayoutMeta.Row>();
FormLayoutMeta.Row row = null;
List<FormLayoutMeta.Col> cols = new ArrayList<FormLayoutMeta.Col>();
for (int i = 0; i < chartModels.length; i++) {
String chartId = chartModels[i].getMeta().getID().toString();
cols.add(new FormLayoutMeta.Col(chartId));
if ((i + 1) % 2 == 0 || (i + 1) == chartModels.length) {
row = new FormLayoutMeta.Row(cols.toArray(new FormLayoutMeta.Col[0]));
rows.add(row);
cols.clear();
}
}
FormLayoutMeta layoutMeta = new FormLayoutMeta(rows.toArray(new FormLayoutMeta.Row[0]));
formMeta.setLayoutMeta(layoutMeta);
tabMeta.setFamgs(new FamgMeta[]{ famgMeta });
}
private static ProductMeta getProductMeta() {
Properties props = AbstractPropertyFactory.loadSysProperties(VERSION_PROP_FILE);
String name = props.getProperty("name");
String version = props.getProperty("version");
ProductMeta res = new ProductMeta(name, version);
return res;
}
private static Set<String> getAllFormFields(Form form) {
HashSet<String> formFields = new HashSet<String>();
Row[] rows = EntityHelper.FormHelper.getLayoutRows(form);
for(Row row : rows) {
Col[] cols = row.getCol();
for(Col col : cols) {
formFields.add(col.getFieldid());
}
}
HiddenControl[] hiddenControls = EntityHelper.FormHelper.getHiddenControls(form);
for (HiddenControl hiddenControl : hiddenControls) {
formFields.add(hiddenControl.getFieldid());
}
return formFields;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -