List of usage examples for com.google.gwt.user.client.ui FlexTable getFlexCellFormatter
public FlexCellFormatter getFlexCellFormatter()
From source file:com.hazelcast.monitor.client.HazelcastMonitor.java
License:Open Source License
private DisclosurePanel createClusterAddPanel() { final DisclosurePanel disclosurePanel = new DisclosurePanel("Add Cluster to Monitor"); final TextBox tbGroupName = new TextBox(); tbGroupName.setText(getTextValue(GROUP_NAME_COOKIE_NAME, "dev")); tbGroupName.setWidth("120px"); final TextBox tbGroupPass = new TextBox(); tbGroupPass.setText(getTextValue(GROUP_PASSWORD_COOKIE_NAME, "dev-pass")); tbGroupPass.setWidth("120px"); final TextBox tbAddresses = new TextBox(); tbAddresses.setWidth("120px"); tbAddresses.setText(getTextValue(GROUP_MEMBERS_COOKIE_NAME, "127.0.0.1:5701")); final Label lbError = new Label(""); lbError.setVisible(false);/* w ww.j av a2 s . co m*/ final Button btAddCluster = new Button("Add Cluster"); btAddCluster .addClickHandler(new AddClusterClickHandler(this, tbGroupName, tbGroupPass, tbAddresses, lbError)); FlexTable table = new FlexTable(); table.setWidget(0, 0, new Label("Group Name:")); table.setWidget(1, 0, new Label("Password:")); table.setWidget(2, 0, new Label("Address:")); table.setWidget(0, 1, tbGroupName); table.setWidget(1, 1, tbGroupPass); table.setWidget(2, 1, tbAddresses); table.setWidget(3, 1, btAddCluster); table.setWidget(4, 0, lbError); table.getFlexCellFormatter().setColSpan(4, 0, 2); table.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT); table.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT); table.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT); // disclosurePanel.add(vPanel); disclosurePanel.add(table); disclosurePanel.setOpen(true); return disclosurePanel; }
From source file:com.hazelcast.monitor.client.MapBrowserPanel.java
License:Open Source License
@Override protected FlexTable createTable() { FlexTable table = new FlexTable(); table.addStyleName("table"); table.addStyleName("mapstats"); FlexTable getTable = new FlexTable(); table.setWidget(0, 0, new Label("")); table.getFlexCellFormatter().setColSpan(0, 0, 2); table.setWidget(1, 1, getTable);// w w w .j av a 2s.co m final TextBox key = new TextBox(); getTable.setWidget(0, 0, new Label("Key: ")); getTable.setWidget(0, 1, key); Button button = new Button("Get"); button.addStyleName("map_get_button"); getTable.setWidget(0, 2, button); FlexTable resultTable = new FlexTable(); resultTable.setWidth("500px"); table.setWidget(1, 2, resultTable); resultTable.setWidget(0, 0, new Label("Value: ")); resultTable.setWidget(1, 0, new Label("Hits: ")); resultTable.setWidget(2, 0, new Label("Cost: ")); resultTable.setWidget(3, 0, new Label("Valid: ")); resultTable.setWidget(4, 0, new Label("Expiration Time: ")); resultTable.setWidget(5, 0, new Label("Last Acess Time: ")); resultTable.setWidget(6, 0, new Label("Last Update Time: ")); resultTable.setWidget(7, 0, new Label("Creation Time: ")); for (int i = 0; i < resultTable.getRowCount(); i++) { Label label = (Label) resultTable.getWidget(i, 0); label.addStyleName("bold"); if (i % 2 == 1) { resultTable.getRowFormatter().addStyleName(i, "mapstatsEvenRow"); } } final TextArea value = new TextArea(); final Label hits = new Label(); final Label cost = new Label(); final Label expirationTime = new Label(); final Label lastAcessTime = new Label(); final Label lastUpdateTime = new Label(); final Label creationTime = new Label(); final Label valid = new Label(); resultTable.setWidget(0, 1, value); resultTable.setWidget(1, 1, hits); resultTable.setWidget(2, 1, cost); resultTable.setWidget(3, 1, valid); resultTable.setWidget(4, 1, expirationTime); resultTable.setWidget(5, 1, lastAcessTime); resultTable.setWidget(6, 1, lastUpdateTime); resultTable.setWidget(7, 1, creationTime); final DateTimeFormat dateFormatter = DateTimeFormat.getFormat("yyyy.MM.dd HH:mm:ss"); button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent clickEvent) { mapService.get(clusterWidgets.clusterId, name, key.getText(), new AsyncCallback<MapEntry>() { public void onFailure(Throwable throwable) { if (throwable instanceof ClientDisconnectedException) { clusterWidgets.disconnected(); } value.setText(throwable.toString()); } public void onSuccess(MapEntry mapEntry) { value.setText((mapEntry == null) ? "null" : mapEntry.getValue()); hits.setText((mapEntry == null) ? "" : String.valueOf(mapEntry.getHits())); cost.setText((mapEntry == null) ? "" : formatMemorySize(mapEntry.getCost())); valid.setText((mapEntry == null) ? "" : String.valueOf(mapEntry.isValid())); expirationTime.setText( (mapEntry == null) ? "" : format(dateFormatter, mapEntry.getExpirationTime())); lastAcessTime.setText( (mapEntry == null) ? "" : format(dateFormatter, mapEntry.getLastAccessTime())); lastUpdateTime.setText( (mapEntry == null) ? "" : format(dateFormatter, mapEntry.getLastUpdateTime())); creationTime.setText( (mapEntry == null) ? "" : format(dateFormatter, mapEntry.getCreationTime())); } }); } }); return table; }
From source file:com.hazelcast.monitor.client.MapEntrySetBrowserPanel.java
License:Open Source License
@Override protected FlexTable createTable() { FlexTable table = new FlexTable(); table.addStyleName("table"); table.addStyleName("mapstats"); table.setWidget(0, 0, new Label("")); table.getFlexCellFormatter().setColSpan(0, 0, 2); Button button = new Button("Refresh"); table.setWidget(1, 0, button);/*from www .ja va2 s .c o m*/ final TextArea value = new TextArea(); value.setVisible(false); table.setWidget(1, 1, value); button.addStyleName("map_refresh_button"); final Grid resultTable = new Grid(2, 4); resultTable.setWidth("800px"); table.setWidget(2, 0, resultTable); table.getFlexCellFormatter().setColSpan(2, 0, 2); resultTable.setText(0, 0, "Key:"); resultTable.setText(0, 1, "Key class:"); resultTable.setText(0, 2, "Value:"); resultTable.setText(0, 3, "Value class:"); resultTable.getRowFormatter().addStyleName(0, "mapstatsEvenRow"); button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent clickEvent) { mapService.getEntries(clusterWidgets.clusterId, name, new AsyncCallback<MapEntry[]>() { public void onFailure(Throwable throwable) { if (throwable instanceof ClientDisconnectedException) { clusterWidgets.disconnected(); } value.setVisible(true); value.setText(throwable.toString()); } public void onSuccess(MapEntry[] mapEntries) { resultTable.resizeRows(mapEntries.length + 1); value.setVisible(false); int row = 1; for (final MapEntry mapEntry : mapEntries) { resultTable.setText(row, 0, mapEntry.getKey()); resultTable.setText(row, 1, mapEntry.getKeyClass()); resultTable.setText(row, 2, mapEntry.getValue()); resultTable.setText(row, 3, mapEntry.getValueClass()); if (row % 2 == 0) { resultTable.getRowFormatter().addStyleName(row, "mapstatsEvenRow"); } row++; } } }); } }); return table; }
From source file:com.ikon.frontend.client.widget.dashboard.keymap.KeyMapTable.java
License:Open Source License
/** * Adding document row//from w ww . java 2 s. com * * @param gwtQueryResult Query result * @param score Document score */ private void addDocumentRow(GWTQueryResult gwtQueryResult, Score score) { Collection<String> selectedKeyList = Main.get().mainPanel.dashboard.keyMapDashboard.getFiltering(); int rows = table.getRowCount(); int firstRow = rows; firtRowList.add("" + firstRow); GWTDocument doc = new GWTDocument(); if (gwtQueryResult.getDocument() != null) { doc = gwtQueryResult.getDocument(); } else if (gwtQueryResult.getAttachment() != null) { doc = gwtQueryResult.getAttachment(); } final String docPath = doc.getPath(); Image gotoDocument = new Image("img/icon/actions/goto_document.gif"); gotoDocument.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { CommonUI.openPath(docPath.substring(0, docPath.lastIndexOf("/")), docPath); } }); gotoDocument.setTitle(Main.i18n("dashboard.keyword.goto.document")); gotoDocument.setStyleName("okm-KeyMap-ImageHover"); table.setWidget(rows, 0, gotoDocument); if (doc.isAttachment()) { SimplePanel sp = new SimplePanel(); // Solves some middle alignament problem derived from mimeImageHTML method sp.add(new HTML(Util.imageItemHTML("img/email_attach.gif") + Util.mimeImageHTML(doc.getMimeType()))); table.setWidget(rows, 1, sp); } else { SimplePanel sp = new SimplePanel(); // Solves some middle alignament problem derived from mimeImageHTML method sp.add(new HTML(Util.mimeImageHTML(doc.getMimeType()))); table.setWidget(rows, 1, sp); } Hyperlink hLink = new Hyperlink(); hLink.setHTML(doc.getName()); // On attachment case must remove last folder path, because it's internal usage not for visualization if (doc.isAttachment()) { hLink.setTitle(doc.getParentPath().substring(0, doc.getParentPath().lastIndexOf("/"))); } else { hLink.setTitle(doc.getParentPath()); } table.setWidget(rows, 2, hLink); // Format table.getCellFormatter().setHorizontalAlignment(rows, 0, HasAlignment.ALIGN_CENTER); table.getCellFormatter().setHorizontalAlignment(rows, 1, HasAlignment.ALIGN_RIGHT); table.getCellFormatter().setHorizontalAlignment(rows, 2, HasAlignment.ALIGN_LEFT); table.getCellFormatter().setVerticalAlignment(rows, 0, HasAlignment.ALIGN_MIDDLE); table.getCellFormatter().setVerticalAlignment(rows, 0, HasAlignment.ALIGN_MIDDLE); table.getCellFormatter().setVerticalAlignment(rows, 2, HasAlignment.ALIGN_MIDDLE); table.getFlexCellFormatter().setWidth(rows, 0, "24"); table.getFlexCellFormatter().setWidth(rows, 1, "47"); for (int i = 0; i < 2; i++) { table.getCellFormatter().addStyleName(rows, i, "okm-DisableSelect"); } // Writing detail rows++; // Next row line FlexTable tableDocument = new FlexTable(); FlexTable tableProperties = new FlexTable(); FlexTable tableSubscribedUsers = new FlexTable(); tableDocument.setWidget(0, 0, tableProperties); tableDocument.setHTML(0, 1, ""); tableDocument.setWidget(0, 2, tableSubscribedUsers); tableDocument.getFlexCellFormatter().setVerticalAlignment(0, 0, HasAlignment.ALIGN_TOP); tableDocument.getFlexCellFormatter().setVerticalAlignment(0, 2, HasAlignment.ALIGN_TOP); tableDocument.getCellFormatter().setWidth(0, 0, "75%"); tableDocument.getCellFormatter().setWidth(0, 1, "25"); tableDocument.getCellFormatter().setWidth(0, 2, "25%"); tableDocument.setWidth("100%"); table.setWidget(rows, 0, tableDocument); table.getFlexCellFormatter().setColSpan(rows, 0, 3); table.getCellFormatter().setHorizontalAlignment(rows, 0, HasHorizontalAlignment.ALIGN_LEFT); tableDocument.setStyleName("okm-DisableSelect"); tableProperties.setStyleName("okm-DisableSelect"); tableSubscribedUsers.setStyleName("okm-DisableSelect"); tableProperties.setHTML(0, 0, "<b>" + Main.i18n("document.folder") + "</b>"); tableProperties.setHTML(0, 1, doc.getParentPath()); tableProperties.setHTML(1, 0, "<b>" + Main.i18n("document.size") + "</b>"); tableProperties.setHTML(1, 1, Util.formatSize(doc.getActualVersion().getSize())); tableProperties.setHTML(2, 0, "<b>" + Main.i18n("document.created") + "</b>"); DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.date.pattern")); tableProperties.setHTML(2, 1, dtf.format(doc.getCreated()) + " " + Main.i18n("document.by") + " " + doc.getAuthor()); tableProperties.setHTML(3, 0, "<b>" + Main.i18n("document.lastmodified") + "</b>"); tableProperties.setHTML(3, 1, dtf.format(doc.getLastModified()) + " " + Main.i18n("document.by") + " " + doc.getActualVersion().getAuthor()); tableProperties.setHTML(4, 0, "<b>" + Main.i18n("document.mimetype") + "</b>"); tableProperties.setHTML(4, 1, doc.getMimeType()); tableProperties.setHTML(5, 0, "<b>" + Main.i18n("document.status") + "</b>"); if (doc.isCheckedOut()) { tableProperties.setHTML(5, 1, Main.i18n("document.status.checkout") + " " + doc.getLockInfo().getOwner()); } else if (doc.isLocked()) { tableProperties.setHTML(5, 1, Main.i18n("document.status.locked") + " " + doc.getLockInfo().getOwner()); } else { tableProperties.setHTML(5, 1, Main.i18n("document.status.normal")); } tableProperties.setHTML(6, 0, "<b>" + Main.i18n("document.subscribed") + "</b>"); if (doc.isSubscribed()) { tableProperties.setHTML(6, 1, Main.i18n("document.subscribed.yes")); } else { tableProperties.setHTML(6, 1, Main.i18n("document.subscribed.no")); } // Sets wordWrap for al rows for (int i = 0; i < 7; i++) { setRowWordWarp(i, 2, false, tableProperties); } // Setting subscribers tableSubscribedUsers.setHTML(0, 0, "<b>" + Main.i18n("document.subscribed.users") + "<b>"); setRowWordWarp(0, 1, false, tableSubscribedUsers); // Sets the folder subscribers for (GWTUser subscriptor : doc.getSubscriptors()) { tableSubscribedUsers.setHTML(tableSubscribedUsers.getRowCount(), 0, subscriptor.getUsername()); setRowWordWarp(tableSubscribedUsers.getRowCount() - 1, 1, false, tableSubscribedUsers); } HorizontalPanel hKeyPanel = addKeywords(table, doc.getKeywords(), selectedKeyList); // Drawing keywords // Setting visibility switch (visibleStatus) { case VISIBLE_SMALL: tableDocument.setVisible(false); hKeyPanel.setVisible(false); table.getCellFormatter().addStyleName(firstRow, 0, "okm-Table-BottomBorder"); table.getCellFormatter().addStyleName(firstRow, 1, "okm-Table-BottomBorder"); table.getCellFormatter().addStyleName(firstRow, 2, "okm-Table-BottomBorder"); break; case VISIBLE_MEDIUM: tableDocument.setVisible(false); hKeyPanel.setVisible(true); break; case VISIBLE_BIG: tableDocument.setVisible(true); hKeyPanel.setVisible(true); break; } // Saving object for refreshing language and setting visible ( true / false ) tableDocumentList.add(tableDocument); hKeyPanelList.add(hKeyPanel); }
From source file:com.ikon.frontend.client.widget.dashboard.keymap.KeyMapTable.java
License:Open Source License
/** * Adding folder/*from w ww .ja va 2 s. c o m*/ * * @param gwtQueryResult Query result * @param score The folder score */ private void addFolderRow(GWTQueryResult gwtQueryResult, Score score) { Collection<String> selectedKeyList = Main.get().mainPanel.dashboard.keyMapDashboard.getFiltering(); int rows = table.getRowCount(); int firstRow = rows; firtRowList.add("" + firstRow); GWTFolder folder = new GWTFolder(); if (gwtQueryResult.getFolder() != null) { folder = gwtQueryResult.getFolder(); } final String fldPath = folder.getPath(); Image gotoFolder = new Image("img/icon/actions/goto_folder.gif"); gotoFolder.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { CommonUI.openPath(fldPath, null); } }); gotoFolder.setTitle(Main.i18n("dashboard.keyword.goto.folder")); gotoFolder.setStyleName("okm-KeyMap-ImageHover"); table.setWidget(rows, 0, gotoFolder); // Solves some middle alignament problem derived from mimeImageHTML method SimplePanel sp = new SimplePanel(); if (folder.isHasChildren()) { sp.add(new HTML(Util.imageItemHTML("img/menuitem_childs.gif"))); } else { sp.add(new HTML(Util.imageItemHTML("img/menuitem_empty.gif"))); } table.setWidget(rows, 1, sp); Hyperlink hLink = new Hyperlink(); hLink.setHTML(folder.getName()); hLink.setTitle(folder.getPath()); table.setWidget(rows, 2, hLink); // Format table.getCellFormatter().setHorizontalAlignment(rows, 0, HasAlignment.ALIGN_CENTER); table.getCellFormatter().setHorizontalAlignment(rows, 1, HasAlignment.ALIGN_RIGHT); table.getCellFormatter().setHorizontalAlignment(rows, 2, HasAlignment.ALIGN_LEFT); table.getCellFormatter().setVerticalAlignment(rows, 0, HasAlignment.ALIGN_MIDDLE); table.getCellFormatter().setVerticalAlignment(rows, 0, HasAlignment.ALIGN_MIDDLE); table.getCellFormatter().setVerticalAlignment(rows, 2, HasAlignment.ALIGN_MIDDLE); table.getFlexCellFormatter().setWidth(rows, 0, "24"); table.getFlexCellFormatter().setWidth(rows, 1, "47"); for (int i = 0; i < 2; i++) { table.getCellFormatter().addStyleName(rows, i, "okm-DisableSelect"); } // Writing detail rows++; // Next row line FlexTable tableFolder = new FlexTable(); FlexTable tableProperties = new FlexTable(); FlexTable tableSubscribedUsers = new FlexTable(); tableFolder.setWidget(0, 0, tableProperties); tableFolder.setHTML(0, 1, ""); tableFolder.setWidget(0, 2, tableSubscribedUsers); tableFolder.getFlexCellFormatter().setVerticalAlignment(0, 0, HasAlignment.ALIGN_TOP); tableFolder.getFlexCellFormatter().setVerticalAlignment(0, 2, HasAlignment.ALIGN_TOP); tableFolder.getCellFormatter().setWidth(0, 0, "75%"); tableFolder.getCellFormatter().setWidth(0, 1, "25"); tableFolder.getCellFormatter().setWidth(0, 2, "25%"); tableFolder.setWidth("100%"); table.setWidget(rows, 0, tableFolder); table.getFlexCellFormatter().setColSpan(rows, 0, 3); table.getCellFormatter().setHorizontalAlignment(rows, 0, HasHorizontalAlignment.ALIGN_LEFT); tableFolder.setStyleName("okm-DisableSelect"); tableProperties.setStyleName("okm-DisableSelect"); tableSubscribedUsers.setStyleName("okm-DisableSelect"); tableProperties.setHTML(0, 0, "<b>" + Main.i18n("folder.name") + "</b>"); tableProperties.setHTML(0, 1, folder.getName()); tableProperties.setHTML(1, 0, "<b>" + Main.i18n("folder.parent") + "</b>"); tableProperties.setHTML(1, 1, folder.getParentPath()); tableProperties.setHTML(2, 0, "<b>" + Main.i18n("folder.created") + "</b>"); DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.date.pattern")); tableProperties.setHTML(2, 1, dtf.format(folder.getCreated()) + " " + Main.i18n("folder.by") + " " + folder.getAuthor()); tableProperties.setHTML(3, 0, "<b>" + Main.i18n("document.subscribed") + "</b>"); if (folder.isSubscribed()) { tableProperties.setHTML(3, 1, Main.i18n("document.subscribed.yes")); } else { tableProperties.setHTML(3, 1, Main.i18n("document.subscribed.no")); } // Sets wordWrap for al rows for (int i = 0; i < 4; i++) { setRowWordWarp(i, 2, false, tableProperties); } // Setting subscribers tableSubscribedUsers.setHTML(0, 0, "<b>" + Main.i18n("folder.subscribed.users") + "<b>"); setRowWordWarp(0, 1, false, tableSubscribedUsers); // Sets the folder subscribers for (GWTUser subscriptor : folder.getSubscriptors()) { tableSubscribedUsers.setHTML(tableSubscribedUsers.getRowCount(), 0, subscriptor.getUsername()); setRowWordWarp(tableSubscribedUsers.getRowCount() - 1, 1, false, tableSubscribedUsers); } HorizontalPanel hKeyPanel = addKeywords(table, folder.getKeywords(), selectedKeyList); // Drawing keywords // Setting visibility switch (visibleStatus) { case VISIBLE_SMALL: tableFolder.setVisible(false); hKeyPanel.setVisible(false); table.getCellFormatter().addStyleName(firstRow, 0, "okm-Table-BottomBorder"); table.getCellFormatter().addStyleName(firstRow, 1, "okm-Table-BottomBorder"); table.getCellFormatter().addStyleName(firstRow, 2, "okm-Table-BottomBorder"); break; case VISIBLE_MEDIUM: tableFolder.setVisible(false); hKeyPanel.setVisible(true); break; case VISIBLE_BIG: tableFolder.setVisible(true); hKeyPanel.setVisible(true); break; } // Saving object for refreshing language and setting visible ( true / false ) tableFolderList.add(tableFolder); hKeyPanelList.add(hKeyPanel); }
From source file:com.ikon.frontend.client.widget.dashboard.keymap.KeyMapTable.java
License:Open Source License
/** * Adding mail/* www .j a v a 2s . c o m*/ * * @param gwtQueryResult Query result * @param score The mail score */ private void addMailRow(GWTQueryResult gwtQueryResult, Score score) { Collection<String> selectedKeyList = Main.get().mainPanel.dashboard.keyMapDashboard.getFiltering(); int rows = table.getRowCount(); int firstRow = rows; firtRowList.add("" + firstRow); GWTMail mail = gwtQueryResult.getMail(); ; final String mailPath = mail.getPath(); Image gotoMail = new Image("img/icon/actions/goto_document.gif"); gotoMail.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { CommonUI.openPath(mailPath.substring(0, mailPath.lastIndexOf("/")), mailPath); } }); gotoMail.setTitle(Main.i18n("dashboard.keyword.goto.mail")); gotoMail.setStyleName("okm-KeyMap-ImageHover"); table.setWidget(rows, 0, gotoMail); SimplePanel sp = new SimplePanel(); // Solves some middle alignament problem derived from mimeImageHTML method if (mail.getAttachments().size() > 0) { sp.add(new HTML(Util.imageItemHTML("img/email_attach.gif"))); } else { sp.add(new HTML(Util.imageItemHTML("img/email.gif"))); } table.setWidget(rows, 1, sp); Hyperlink hLink = new Hyperlink(); hLink.setHTML(mail.getSubject()); // On attachemt case must remove last folder path, because it's internal usage not for visualization hLink.setTitle(mail.getSubject()); table.setWidget(rows, 2, hLink); // Format table.getCellFormatter().setHorizontalAlignment(rows, 0, HasAlignment.ALIGN_CENTER); table.getCellFormatter().setHorizontalAlignment(rows, 1, HasAlignment.ALIGN_RIGHT); table.getCellFormatter().setHorizontalAlignment(rows, 2, HasAlignment.ALIGN_LEFT); table.getCellFormatter().setVerticalAlignment(rows, 0, HasAlignment.ALIGN_MIDDLE); table.getCellFormatter().setVerticalAlignment(rows, 0, HasAlignment.ALIGN_MIDDLE); table.getCellFormatter().setVerticalAlignment(rows, 2, HasAlignment.ALIGN_MIDDLE); table.getFlexCellFormatter().setWidth(rows, 0, "24"); table.getFlexCellFormatter().setWidth(rows, 1, "47"); for (int i = 0; i < 2; i++) { table.getCellFormatter().addStyleName(rows, i, "okm-DisableSelect"); } // Writing detail rows++; // Next row line FlexTable tableMail = new FlexTable(); FlexTable tableProperties = new FlexTable(); FlexTable tableSubscribedUsers = new FlexTable(); tableMail.setWidget(0, 0, tableProperties); tableMail.setHTML(0, 1, ""); tableMail.setWidget(0, 2, tableSubscribedUsers); tableMail.getFlexCellFormatter().setVerticalAlignment(0, 0, HasAlignment.ALIGN_TOP); tableMail.getFlexCellFormatter().setVerticalAlignment(0, 2, HasAlignment.ALIGN_TOP); tableMail.getCellFormatter().setWidth(0, 0, "75%"); tableMail.getCellFormatter().setWidth(0, 1, "25"); tableMail.getCellFormatter().setWidth(0, 2, "25%"); tableMail.setWidth("100%"); table.setWidget(rows, 0, tableMail); table.getFlexCellFormatter().setColSpan(rows, 0, 3); table.getCellFormatter().setHorizontalAlignment(rows, 0, HasHorizontalAlignment.ALIGN_LEFT); tableMail.setStyleName("okm-DisableSelect"); tableProperties.setStyleName("okm-DisableSelect"); tableSubscribedUsers.setStyleName("okm-DisableSelect"); tableProperties.setHTML(0, 0, "<b>" + Main.i18n("mail.folder") + "</b>"); tableProperties.setHTML(0, 1, mail.getParentPath()); tableProperties.setHTML(1, 0, "<b>" + Main.i18n("mail.size") + "</b>"); tableProperties.setHTML(1, 1, Util.formatSize(mail.getSize())); tableProperties.setHTML(2, 0, "<b>" + Main.i18n("mail.created") + "</b>"); DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.date.pattern")); tableProperties.setHTML(2, 1, dtf.format(mail.getCreated()) + " " + Main.i18n("mail.by") + " " + mail.getAuthor()); tableProperties.setHTML(3, 0, "<b>" + Main.i18n("mail.mimetype") + "</b>"); tableProperties.setHTML(3, 1, mail.getMimeType()); // Sets wordWrap for al rows for (int i = 0; i < 4; i++) { setRowWordWarp(i, 2, false, tableProperties); } HorizontalPanel hKeyPanel = addKeywords(table, mail.getKeywords(), selectedKeyList); // Drawing keywords // Setting visibility switch (visibleStatus) { case VISIBLE_SMALL: tableMail.setVisible(false); hKeyPanel.setVisible(false); table.getCellFormatter().addStyleName(firstRow, 0, "okm-Table-BottomBorder"); table.getCellFormatter().addStyleName(firstRow, 1, "okm-Table-BottomBorder"); table.getCellFormatter().addStyleName(firstRow, 2, "okm-Table-BottomBorder"); break; case VISIBLE_MEDIUM: tableMail.setVisible(false); hKeyPanel.setVisible(true); break; case VISIBLE_BIG: tableMail.setVisible(true); hKeyPanel.setVisible(true); break; } tableMailList.add(tableMail); hKeyPanelList.add(hKeyPanel); }
From source file:com.ikon.frontend.client.widget.dashboard.keymap.KeyMapTable.java
License:Open Source License
/** * addKeywords/* ww w . jav a2 s. c o m*/ * * @param table * @param keywords * @param selectedKeyList * @return */ private HorizontalPanel addKeywords(FlexTable table, Set<String> keywords, Collection<String> selectedKeyList) { int rows = table.getRowCount(); // Writing keys rows++; // Next row line HorizontalPanel hKeyPanel = new HorizontalPanel(); table.setWidget(rows, 0, hKeyPanel); table.getFlexCellFormatter().setColSpan(rows, 0, 3); table.getCellFormatter().setHorizontalAlignment(rows, 0, HasHorizontalAlignment.ALIGN_RIGHT); table.getCellFormatter().addStyleName(rows, 0, "okm-Table-BottomBorder"); for (final String keyword : keywords) { // First adds only new keywords if (!selectedKeyList.contains(keyword)) { HorizontalPanel externalPanel = new HorizontalPanel(); HorizontalPanel hPanel = new HorizontalPanel(); HTML space = new HTML(); ImageHover add = new ImageHover("img/icon/actions/add_disabled.gif", "img/icon/actions/add.gif"); add.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // remove keyword on all keyword panels Main.get().mainPanel.dashboard.keyMapDashboard.selectKey(keyword); } }); add.setStyleName("okm-KeyMap-ImageHover"); hPanel.add(new HTML(keyword)); hPanel.add(space); hPanel.add(add); hPanel.setCellWidth(space, "6"); hPanel.setStyleName("okm-KeyMap-Gray"); HTML space1 = new HTML(); externalPanel.add(hPanel); externalPanel.add(space1); externalPanel.setCellWidth(space1, "6"); hKeyPanel.add(externalPanel); } } for (final String keyword : selectedKeyList) { // Last adding selected keywords HorizontalPanel externalPanel = new HorizontalPanel(); HorizontalPanel hPanel = new HorizontalPanel(); HTML space = new HTML(); ImageHover add = new ImageHover("img/icon/actions/delete_disabled.gif", "img/icon/actions/delete.gif"); add.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // remove keyword on all keyword panels Main.get().mainPanel.dashboard.keyMapDashboard.removeKey(keyword); } }); add.setStyleName("okm-KeyMap-ImageHover"); hPanel.add(new HTML(keyword)); hPanel.add(space); hPanel.add(add); hPanel.setCellWidth(space, "6"); hPanel.setStyleName("okm-KeyMap-Selected"); HTML space1 = new HTML(); externalPanel.add(hPanel); externalPanel.add(space1); externalPanel.setCellWidth(space1, "6"); hKeyPanel.add(externalPanel); } return hKeyPanel; }
From source file:com.ikon.frontend.client.widget.form.FormManager.java
License:Open Source License
/** * drawFormElement//from www . ja v a 2 s .com */ private void drawFormElement(int row, final GWTFormElement gwtFormElement, boolean readOnly, boolean searchView) { final String propertyName = gwtFormElement.getName(); if (gwtFormElement instanceof GWTButton) { final GWTButton gWTButton = (GWTButton) gwtFormElement; if (submitForm != null) { submitForm.setVisible(false); // Always set form hidden because there's new buttons } Button transButton = new Button(gWTButton.getLabel()); String style = Character.toUpperCase(gWTButton.getStyle().charAt(0)) + gWTButton.getStyle().substring(1); transButton.setStyleName("okm-" + style + "Button"); HTML space = new HTML(" "); submitButtonPanel.add(transButton); submitButtonPanel.add(space); submitButtonPanel.setCellWidth(space, "5px"); // Setting submit button transButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (gWTButton.getConfirmation() != null && !gWTButton.getConfirmation().equals("")) { Main.get().confirmPopup.setConfirm(ConfirmPopup.CONFIRM_WORKFLOW_ACTION); Main.get().confirmPopup.setConfirmationText(gWTButton.getConfirmation()); ValidationButton validationButton = new ValidationButton(gWTButton, singleton); Main.get().confirmPopup.setValue(validationButton); Main.get().confirmPopup.center(); } else { if (gWTButton.isValidate()) { if (validationProcessor.validate()) { if (gWTButton.getTransition().equals("")) { workflow.setTaskInstanceValues(taskInstance.getId(), null); } else { workflow.setTaskInstanceValues(taskInstance.getId(), gWTButton.getTransition()); } disableAllButtonList(); } } else { if (gWTButton.getTransition().equals("")) { workflow.setTaskInstanceValues(taskInstance.getId(), null); } else { workflow.setTaskInstanceValues(taskInstance.getId(), gWTButton.getTransition()); } disableAllButtonList(); } } } }); // Adding button to control list if (!buttonControlList.contains(transButton)) { buttonControlList.add(transButton); } } else if (gwtFormElement instanceof GWTTextArea) { HorizontalPanel hPanel = new HorizontalPanel(); TextArea textArea = new TextArea(); textArea.setEnabled((!readOnly && !((GWTTextArea) gwtFormElement).isReadonly()) || isSearchView); // read only hPanel.add(textArea); textArea.setStyleName("okm-TextArea"); textArea.setText(((GWTTextArea) gwtFormElement).getValue()); textArea.setSize(gwtFormElement.getWidth(), gwtFormElement.getHeight()); HTML text = new HTML(); // Create a widget for this property text.setHTML(((GWTTextArea) gwtFormElement).getValue().replaceAll("\n", "<br>")); hWidgetProperties.put(propertyName, hPanel); table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>"); table.setWidget(row, 1, text); table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP); table.getCellFormatter().setWidth(row, 1, "100%"); if (searchView) { final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon()); removeImage.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { for (int row = 0; row < table.getRowCount(); row++) { if (table.getWidget(row, 2).equals(removeImage)) { table.removeRow(row); break; } } hWidgetProperties.remove(propertyName); hPropertyParams.remove(propertyName); formElementList.remove(gwtFormElement); search.propertyRemoved(); } }); removeImage.addStyleName("okm-Hyperlink"); table.setWidget(row, 2, removeImage); table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP); if (search != null) { textArea.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { search.metadataValueChanged(); } }); } setRowWordWarp(row, 3, true); } else { setRowWordWarp(row, 2, true); } } else if (gwtFormElement instanceof GWTInput) { final HorizontalPanel hPanel = new HorizontalPanel(); final TextBox textBox = new TextBox(); // Create a widget for this property textBox.setEnabled((!readOnly && !((GWTInput) gwtFormElement).isReadonly()) || isSearchView); // read only hPanel.add(textBox); String value = ""; if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_TEXT) || ((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_LINK) || ((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_FOLDER)) { textBox.setText(((GWTInput) gwtFormElement).getValue()); value = ((GWTInput) gwtFormElement).getValue(); } else if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_DATE)) { if (((GWTInput) gwtFormElement).getDate() != null) { DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.day.pattern")); textBox.setText(dtf.format(((GWTInput) gwtFormElement).getDate())); value = dtf.format(((GWTInput) gwtFormElement).getDate()); } } textBox.setWidth(gwtFormElement.getWidth()); textBox.setStyleName("okm-Input"); hWidgetProperties.put(propertyName, hPanel); table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>"); table.setHTML(row, 1, value); if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_DATE)) { final PopupPanel calendarPopup = new PopupPanel(true); final CalendarWidget calendar = new CalendarWidget(); calendar.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { calendarPopup.hide(); DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.day.pattern")); textBox.setText(dtf.format(calendar.getDate())); ((GWTInput) gwtFormElement).setDate(calendar.getDate()); if (search != null) { search.metadataValueChanged(); } } }); calendarPopup.add(calendar); final Image calendarIcon = new Image(OKMBundleResources.INSTANCE.calendar()); if (readOnly || ((GWTInput) gwtFormElement).isReadonly()) { // read only calendarIcon.setResource(OKMBundleResources.INSTANCE.calendarDisabled()); } else { calendarIcon.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { calendarPopup.setPopupPosition(calendarIcon.getAbsoluteLeft(), calendarIcon.getAbsoluteTop() - 2); if (calendar.getDate() != null) { calendar.setNow((Date) calendar.getDate().clone()); } else { calendar.setNow(null); } calendarPopup.show(); } }); } calendarIcon.setStyleName("okm-Hyperlink"); hPanel.add(Util.hSpace("5")); hPanel.add(calendarIcon); textBox.setEnabled(false); } else if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_LINK)) { if (!value.equals("")) { HorizontalPanel hLinkPanel = new HorizontalPanel(); Anchor anchor = new Anchor(value, true); final String url = value; anchor.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Window.open(url, url, ""); } }); anchor.setStyleName("okm-Hyperlink"); String containerName = ((GWTInput) gwtFormElement).getName() + "ContainerName"; hLinkPanel.add(new HTML("<div id=\"" + containerName + "\"></div>\n")); HTML space = new HTML(""); hLinkPanel.add(space); hLinkPanel.add(anchor); hLinkPanel.setCellWidth(space, "5px"); table.setWidget(row, 1, hLinkPanel); Util.createLinkClipboardButton(url, containerName); } else { table.setHTML(row, 1, ""); } } else if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_FOLDER)) { if (!value.equals("")) { Anchor anchor = new Anchor(); final GWTFolder folder = ((GWTInput) gwtFormElement).getFolder(); // remove first ocurrence String path = value.substring(value.indexOf("/", 1) + 1); // Looks if must change icon on parent if now has no childs and properties with user security // atention if (folder.isHasChildren()) { anchor.setHTML(Util.imageItemHTML("img/menuitem_childs.gif", path, "top")); } else { anchor.setHTML(Util.imageItemHTML("img/menuitem_empty.gif", path, "top")); } anchor.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent arg0) { CommonUI.openPath(folder.getPath(), null); } }); anchor.setStyleName("okm-KeyMap-ImageHover"); table.setWidget(row, 1, anchor); } else { table.setHTML(row, 1, ""); } Image pathExplorer = new Image(OKMBundleResources.INSTANCE.folderExplorer()); pathExplorer.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // when any changes is done is fired search.metadataValueChanged(); folderSelectPopup.show(textBox, search); } }); pathExplorer.setStyleName("okm-KeyMap-ImageHover"); hPanel.add(Util.hSpace("5")); hPanel.add(pathExplorer); hPanel.setCellVerticalAlignment(pathExplorer, HasAlignment.ALIGN_MIDDLE); pathExplorer.setVisible((!readOnly && !((GWTInput) gwtFormElement).isReadonly()) || isSearchView); // read only textBox.setEnabled(false); } table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP); table.getCellFormatter().setWidth(row, 1, "100%"); if (searchView) { // Second date input if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_DATE)) { final TextBox textBoxTo = new TextBox(); textBoxTo.setWidth(gwtFormElement.getWidth()); textBoxTo.setStyleName("okm-Input"); hPanel.add(new HTML(" ↔ ")); hPanel.add(textBoxTo); if (((GWTInput) gwtFormElement).getDateTo() != null) { DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.day.pattern")); textBoxTo.setText(dtf.format(((GWTInput) gwtFormElement).getDateTo())); } final PopupPanel calendarPopup = new PopupPanel(true); final CalendarWidget calendar = new CalendarWidget(); calendar.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { calendarPopup.hide(); DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.day.pattern")); textBoxTo.setText(dtf.format(calendar.getDate())); ((GWTInput) gwtFormElement).setDateTo(calendar.getDate()); if (search != null) { search.metadataValueChanged(); } } }); calendarPopup.add(calendar); final Image calendarIcon = new Image(OKMBundleResources.INSTANCE.calendar()); calendarIcon.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { calendarPopup.setPopupPosition(calendarIcon.getAbsoluteLeft(), calendarIcon.getAbsoluteTop() - 2); calendarPopup.show(); } }); calendarIcon.setStyleName("okm-Hyperlink"); hPanel.add(Util.hSpace("5")); hPanel.add(calendarIcon); textBoxTo.setEnabled(false); // Clean final Image cleanIcon = new Image(OKMBundleResources.INSTANCE.cleanIcon()); cleanIcon.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { TextBox textBox = (TextBox) hPanel.getWidget(0); textBox.setText(""); textBoxTo.setText(""); ((GWTInput) gwtFormElement).setDate(null); ((GWTInput) gwtFormElement).setDateTo(null); } }); cleanIcon.setStyleName("okm-Hyperlink"); hPanel.add(Util.hSpace("5")); hPanel.add(cleanIcon); } // Delete final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon()); removeImage.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { for (int row = 0; row < table.getRowCount(); row++) { if (table.getWidget(row, 2).equals(removeImage)) { table.removeRow(row); break; } } hWidgetProperties.remove(propertyName); hPropertyParams.remove(propertyName); formElementList.remove(gwtFormElement); search.propertyRemoved(); } }); removeImage.addStyleName("okm-Hyperlink"); table.setWidget(row, 2, removeImage); table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP); if (search != null) { textBox.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { search.metadataValueChanged(); } }); } setRowWordWarp(row, 3, true); } else { // Clean icon ( case is not readonly ) final Image cleanIcon = new Image(OKMBundleResources.INSTANCE.cleanIcon()); cleanIcon.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { TextBox textBox = (TextBox) hPanel.getWidget(0); textBox.setText(""); ((GWTInput) gwtFormElement).setDate(null); ((GWTInput) gwtFormElement).setFolder(new GWTFolder()); } }); cleanIcon.setStyleName("okm-Hyperlink"); hPanel.add(Util.hSpace("5")); hPanel.add(cleanIcon); cleanIcon.setVisible((!readOnly && !((GWTInput) gwtFormElement).isReadonly())); // read only setRowWordWarp(row, 2, true); } } else if (gwtFormElement instanceof GWTSuggestBox) { HorizontalPanel hPanel = new HorizontalPanel(); final GWTSuggestBox suggestBox = (GWTSuggestBox) gwtFormElement; final TextBox textBox = new TextBox(); // Create a widget for this property textBox.setWidth(gwtFormElement.getWidth()); textBox.setStyleName("okm-Input"); textBox.setReadOnly(true); textBox.setEnabled((!readOnly && !suggestBox.isReadonly()) || isSearchView); // read only final HTML hiddenKey = new HTML(""); hiddenKey.setVisible(false); if (suggestBox.getValue() != null) { hiddenKey.setHTML(suggestBox.getValue()); } hPanel.add(textBox); hPanel.add(hiddenKey); final HTML value = new HTML(""); table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>"); table.setWidget(row, 1, value); table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP); table.getCellFormatter().setWidth(row, 1, "100%"); if (textBox.isEnabled()) { final Image databaseRecordImage = new Image(OKMBundleResources.INSTANCE.databaseRecord()); databaseRecordImage.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { List<String> tables = new ArrayList<String>(); if (suggestBox.getTable() != null) { tables.add(suggestBox.getTable()); } DatabaseRecord databaseRecord = new DatabaseRecord(hiddenKey, textBox); // when any changes is done is fired search.metadataValueChanged(); DatabaseRecordSelectPopup drsPopup = new DatabaseRecordSelectPopup(suggestBox, databaseRecord, search); drsPopup.setWidth("300"); drsPopup.setHeight("220"); drsPopup.setStyleName("okm-Popup"); drsPopup.setPopupPosition(databaseRecordImage.getAbsoluteLeft(), databaseRecordImage.getAbsoluteTop() - 2); drsPopup.show(); } }); databaseRecordImage.setStyleName("okm-Hyperlink"); hPanel.add(new HTML(" ")); hPanel.add(databaseRecordImage); } hWidgetProperties.put(propertyName, hPanel); if (!suggestBox.getValue().equals("")) { textBox.setValue(suggestBox.getText()); value.setHTML(suggestBox.getText()); hiddenKey.setHTML(suggestBox.getValue()); /*List<String> tables = new ArrayList<String>(); if (suggestBox.getTable() != null) { tables.add(suggestBox.getTable()); } String formatedQuery = MessageFormat.format(suggestBox.getValueQuery(), suggestBox.getValue()); keyValueService.getKeyValues(tables, formatedQuery, new AsyncCallback<List<GWTKeyValue>>() { @Override public void onSuccess(List<GWTKeyValue> result) { if (!result.isEmpty()) { GWTKeyValue keyValue = result.get(0); textBox.setValue(keyValue.getValue()); value.setHTML(keyValue.getValue()); hiddenKey.setHTML(keyValue.getKey()); } } @Override public void onFailure(Throwable caught) { Main.get().showError("getKeyValues", caught); } }); */ } if (searchView) { final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon()); removeImage.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { for (int row = 0; row < table.getRowCount(); row++) { if (table.getWidget(row, 2).equals(removeImage)) { table.removeRow(row); break; } } hWidgetProperties.remove(propertyName); hPropertyParams.remove(propertyName); formElementList.remove(gwtFormElement); search.propertyRemoved(); } }); removeImage.addStyleName("okm-Hyperlink"); table.setWidget(row, 2, removeImage); table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP); textBox.addKeyUpHandler( Main.get().mainPanel.search.searchBrowser.searchIn.searchControl.keyUpHandler); setRowWordWarp(row, 3, true); } else { setRowWordWarp(row, 2, true); } } else if (gwtFormElement instanceof GWTCheckBox) { CheckBox checkBox = new CheckBox(); checkBox.setEnabled((!readOnly && !((GWTCheckBox) gwtFormElement).isReadonly()) || isSearchView); // read only checkBox.setValue(((GWTCheckBox) gwtFormElement).getValue()); hWidgetProperties.put(propertyName, checkBox); table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>"); if (checkBox.getValue()) { table.setWidget(row, 1, new Image(OKMBundleResources.INSTANCE.yes())); } else { table.setWidget(row, 1, new Image(OKMBundleResources.INSTANCE.no())); } table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP); table.getCellFormatter().setWidth(row, 1, "100%"); if (searchView) { final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon()); removeImage.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { for (int row = 0; row < table.getRowCount(); row++) { if (table.getWidget(row, 2).equals(removeImage)) { table.removeRow(row); break; } } hWidgetProperties.remove(propertyName); hPropertyParams.remove(propertyName); formElementList.remove(gwtFormElement); search.propertyRemoved(); } }); removeImage.addStyleName("okm-Hyperlink"); table.setWidget(row, 2, removeImage); table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP); if (search != null) { checkBox.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { search.metadataValueChanged(); } }); } setRowWordWarp(row, 3, true); } else { setRowWordWarp(row, 2, true); } } else if (gwtFormElement instanceof GWTSelect) { final GWTSelect gwtSelect = (GWTSelect) gwtFormElement; if (!gwtSelect.getOptionsData().equals("") && workflowVarMap.keySet().contains(gwtSelect.getOptionsData())) { gwtSelect.setOptions(getOptionsFromVariable(workflowVarMap.get(gwtSelect.getOptionsData()))); } if (gwtSelect.getType().equals(GWTSelect.TYPE_SIMPLE)) { String selectedLabel = ""; HorizontalPanel hPanel = new HorizontalPanel(); ListBox listBox = new ListBox(); listBox.setEnabled((!readOnly && !gwtSelect.isReadonly()) || isSearchView); // read only hPanel.add(listBox); listBox.setStyleName("okm-Select"); listBox.addItem("", ""); // Always we set and empty value for (GWTOption option : gwtSelect.getOptions()) { listBox.addItem(option.getLabel(), option.getValue()); if (option.isSelected()) { listBox.setItemSelected(listBox.getItemCount() - 1, true); selectedLabel = option.getLabel(); } } hWidgetProperties.put(propertyName, hPanel); table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>"); table.setHTML(row, 1, selectedLabel); table.getCellFormatter().setWidth(row, 1, "100%"); if (searchView) { final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon()); removeImage.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { for (int row = 0; row < table.getRowCount(); row++) { if (table.getWidget(row, 2).equals(removeImage)) { table.removeRow(row); break; } } hWidgetProperties.remove(propertyName); hPropertyParams.remove(propertyName); formElementList.remove(gwtFormElement); search.propertyRemoved(); } }); removeImage.addStyleName("okm-Hyperlink"); table.setWidget(row, 2, removeImage); table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP); if (search != null) { listBox.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { search.metadataValueChanged(); } }); } setRowWordWarp(row, 3, true); } else { setRowWordWarp(row, 2, true); } } else if (gwtSelect.getType().equals(GWTSelect.TYPE_MULTIPLE)) { final HorizontalPanel hPanel = new HorizontalPanel(); ListBox listMulti = new ListBox(); listMulti.setEnabled((!readOnly && !gwtSelect.isReadonly()) || isSearchView); // read only listMulti.setStyleName("okm-Select"); listMulti.addItem("", ""); // Always we set and empty value // Table for values FlexTable tableMulti = new FlexTable(); Button addButton = new Button(Main.i18n("button.add"), new ClickHandler() { @Override public void onClick(ClickEvent event) { HorizontalPanel hPanel = (HorizontalPanel) hWidgetProperties.get(propertyName); FlexTable tableMulti = (FlexTable) hPanel.getWidget(0); ListBox listMulti = (ListBox) hPanel.getWidget(2); Button addButton = (Button) hPanel.getWidget(4); if (listMulti.getSelectedIndex() > 0) { final HTML htmlValue = new HTML(listMulti.getValue(listMulti.getSelectedIndex())); int rowTableMulti = tableMulti.getRowCount(); Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon()); removeImage.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Widget sender = (Widget) event.getSource(); HorizontalPanel hPanel = (HorizontalPanel) hWidgetProperties.get(propertyName); FlexTable tableMulti = (FlexTable) hPanel.getWidget(0); ListBox listMulti = (ListBox) hPanel.getWidget(2); Button addButton = (Button) hPanel.getWidget(4); String value = htmlValue.getText(); String optionLabel = ""; for (Iterator<GWTOption> itOptions = gwtSelect.getOptions() .iterator(); itOptions.hasNext();) { GWTOption option = itOptions.next(); if (option.getValue().equals(htmlValue.getText())) { optionLabel = option.getLabel(); break; } } listMulti.addItem(optionLabel, value); listMulti.setVisible(true); addButton.setVisible(true); // Looking for row to delete for (int i = 0; i < tableMulti.getRowCount(); i++) { if (tableMulti.getWidget(i, 1).equals(sender)) { tableMulti.removeRow(i); } } if (search != null) { search.metadataValueChanged(); } } }); removeImage.setStyleName("okm-Hyperlink"); tableMulti.setWidget(rowTableMulti, 0, htmlValue); tableMulti.setWidget(rowTableMulti, 1, removeImage); tableMulti.setHTML(rowTableMulti, 2, listMulti.getItemText(listMulti.getSelectedIndex())); setRowWordWarp(tableMulti, rowTableMulti, 2, true); listMulti.removeItem(listMulti.getSelectedIndex()); htmlValue.setVisible(false); if (listMulti.getItemCount() <= 1) { listMulti.setVisible(false); addButton.setVisible(false); } if (search != null) { search.metadataValueChanged(); } } } }); addButton.setEnabled((!readOnly && !gwtSelect.isReadonly()) || isSearchView); // read only addButton.setStyleName("okm-AddButton"); hPanel.add(tableMulti); hPanel.add(new HTML(" ")); hPanel.add(listMulti); hPanel.add(new HTML(" ")); hPanel.add(addButton); hPanel.setVisible(true); listMulti.setVisible(false); addButton.setVisible(false); hPanel.setCellVerticalAlignment(tableMulti, VerticalPanel.ALIGN_TOP); hPanel.setCellVerticalAlignment(listMulti, VerticalPanel.ALIGN_TOP); hPanel.setCellVerticalAlignment(addButton, VerticalPanel.ALIGN_TOP); hPanel.setHeight("100%"); table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>"); table.setWidget(row, 1, hPanel); table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP); table.getCellFormatter().setVerticalAlignment(row, 1, VerticalPanel.ALIGN_TOP); table.getCellFormatter().setWidth(row, 1, "100%"); for (Iterator<GWTOption> itData = gwtSelect.getOptions().iterator(); itData.hasNext();) { final GWTOption option = itData.next(); // Looks if there's some selected value if (option.isSelected()) { int rowTableMulti = tableMulti.getRowCount(); HTML htmlValue = new HTML(option.getValue()); Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon()); // read only for this element goes at edit() logic removeImage.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Widget sender = (Widget) event.getSource(); HorizontalPanel hPanel = (HorizontalPanel) hWidgetProperties.get(propertyName); FlexTable tableMulti = (FlexTable) hPanel.getWidget(0); ListBox listMulti = (ListBox) hPanel.getWidget(2); Button addButton = (Button) hPanel.getWidget(4); listMulti.addItem(option.getLabel(), option.getValue()); listMulti.setVisible(true); addButton.setVisible(true); // Looking for row to delete for (int i = 0; i < tableMulti.getRowCount(); i++) { if (tableMulti.getWidget(i, 1).equals(sender)) { tableMulti.removeRow(i); } } if (search != null) { search.metadataValueChanged(); } } }); removeImage.setStyleName("okm-Hyperlink"); tableMulti.setWidget(rowTableMulti, 0, htmlValue); tableMulti.setWidget(rowTableMulti, 1, removeImage); tableMulti.setHTML(rowTableMulti, 2, option.getLabel()); setRowWordWarp(tableMulti, rowTableMulti, 2, true); htmlValue.setVisible(false); removeImage.setVisible(false); } else { listMulti.addItem(option.getLabel(), option.getValue()); } } // Save panel hWidgetProperties.put(propertyName, hPanel); if (searchView) { final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon()); removeImage.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { for (int row = 0; row < table.getRowCount(); row++) { if (table.getWidget(row, 2).equals(removeImage)) { table.removeRow(row); break; } } hWidgetProperties.remove(propertyName); hPropertyParams.remove(propertyName); formElementList.remove(gwtFormElement); search.propertyRemoved(); } }); removeImage.addStyleName("okm-Hyperlink"); table.setWidget(row, 2, removeImage); table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP); // not implemented // textBox.addKeyUpHandler(Main.get().mainPanel.search.searchBrowser.searchIn.searchControl.keyUpHandler); setRowWordWarp(row, 3, true); } else { setRowWordWarp(row, 2, true); } } } else if (gwtFormElement instanceof GWTUpload) { final GWTUpload upload = (GWTUpload) gwtFormElement; HorizontalPanel hPanel = new HorizontalPanel(); FileUpload fileUpload = new FileUpload(); fileUpload.setStyleName("okm-Input"); fileUpload.getElement().setAttribute("size", "" + upload.getWidth()); final Anchor documentLink = new Anchor(); // Setting document link by uuid if (upload.getDocumentUuid() != null && !upload.getDocumentUuid().equals("")) { repositoryService.getPathByUUID(upload.getDocumentUuid(), new AsyncCallback<String>() { @Override public void onSuccess(String result) { documentService.get(result, new AsyncCallback<GWTDocument>() { @Override public void onSuccess(GWTDocument result) { final String docPath = result.getPath(); documentLink.setText(result.getName()); documentLink.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { String path = docPath.substring(0, docPath.lastIndexOf("/")); CommonUI.openPath(path, docPath); } }); } @Override public void onFailure(Throwable caught) { Main.get().showError("getDocument", caught); } }); } @Override public void onFailure(Throwable caught) { Main.get().showError("getPathByUUID", caught); } }); } documentLink.setStyleName("okm-Hyperlink"); hPanel.add(documentLink); hPanel.add(fileUpload); hWidgetProperties.put(propertyName, hPanel); table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>"); table.setWidget(row, 1, new HTML("")); table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP); table.getCellFormatter().setWidth(row, 1, "100%"); setRowWordWarp(row, 2, true); // If folderPath is null must initialize value if (upload.getFolderPath() == null || upload.getFolderPath().equals("") && upload.getFolderUuid() != null && !upload.getFolderUuid().equals("")) { repositoryService.getPathByUUID(upload.getFolderUuid(), new AsyncCallback<String>() { @Override public void onSuccess(String result) { upload.setFolderPath(result); } @Override public void onFailure(Throwable caught) { Main.get().showError("getPathByUUID", caught); } }); } } else if (gwtFormElement instanceof GWTText) { HorizontalPanel hPanel = new HorizontalPanel(); HTML title = new HTML(" " + ((GWTText) gwtFormElement).getLabel() + " "); title.setStyleName("okm-NoWrap"); hPanel.add(Util.hSpace("10")); hPanel.add(title); hPanel.setCellWidth(title, ((GWTText) gwtFormElement).getWidth()); hWidgetProperties.put(propertyName, hPanel); table.setWidget(row, 0, hPanel); table.getFlexCellFormatter().setColSpan(row, 0, 2); } else if (gwtFormElement instanceof GWTSeparator) { HorizontalPanel hPanel = new HorizontalPanel(); Image horizontalLine = new Image("img/transparent_pixel.gif"); horizontalLine.setStyleName("okm-TopPanel-Line-Border"); horizontalLine.setSize("10", "2px"); Image horizontalLine2 = new Image("img/transparent_pixel.gif"); horizontalLine2.setStyleName("okm-TopPanel-Line-Border"); horizontalLine2.setSize("100%", "2px"); HTML title = new HTML(" " + ((GWTSeparator) gwtFormElement).getLabel() + " "); title.setStyleName("okm-NoWrap"); hPanel.add(horizontalLine); hPanel.add(title); hPanel.add(horizontalLine2); hPanel.setCellVerticalAlignment(horizontalLine, HasAlignment.ALIGN_MIDDLE); hPanel.setCellVerticalAlignment(horizontalLine2, HasAlignment.ALIGN_MIDDLE); hPanel.setCellWidth(horizontalLine2, ((GWTSeparator) gwtFormElement).getWidth()); hWidgetProperties.put(propertyName, hPanel); table.setWidget(row, 0, hPanel); table.getFlexCellFormatter().setColSpan(row, 0, 2); } else if (gwtFormElement instanceof GWTDownload) { HorizontalPanel hPanel = new HorizontalPanel(); hWidgetProperties.put(propertyName, hPanel); table.setWidget(row, 0, hPanel); table.getFlexCellFormatter().setColSpan(row, 0, 2); GWTDownload download = (GWTDownload) gwtFormElement; FlexTable downloadTable = new FlexTable(); HTML description = new HTML("<b>" + gwtFormElement.getLabel() + "</b>"); downloadTable.setWidget(0, 0, description); downloadTable.getFlexCellFormatter().setColSpan(0, 0, 2); for (final GWTNode node : download.getNodes()) { int downloadTableRow = downloadTable.getRowCount(); final Anchor anchor = new Anchor("<b>" + node.getLabel() + "</b>", true); if (!node.getUuid().equals("")) { repositoryService.getPathByUUID(node.getUuid(), new AsyncCallback<String>() { @Override public void onSuccess(String result) { folderService.isValid(result, new AsyncCallback<Boolean>() { @Override public void onSuccess(Boolean result) { final boolean isFolder = result; anchor.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (isFolder) { Util.downloadFileByUUID(node.getUuid(), "export"); } else { Util.downloadFileByUUID(node.getUuid(), ""); } } }); } @Override public void onFailure(Throwable caught) { Main.get().showError("getPathByUUID", caught); } }); } @Override public void onFailure(Throwable caught) { Main.get().showError("getPathByUUID", caught); } }); } else if (!node.getPath().equals("")) { repositoryService.getUUIDByPath(node.getPath(), new AsyncCallback<String>() { @Override public void onSuccess(String result) { final String uuid = result; folderService.isValid(node.getPath(), new AsyncCallback<Boolean>() { @Override public void onSuccess(Boolean result) { final boolean isFolder = result; anchor.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (isFolder) { Util.downloadFileByUUID(uuid, "export"); } else { Util.downloadFileByUUID(uuid, ""); } } }); } @Override public void onFailure(Throwable caught) { Main.get().showError("getPathByUUID", caught); } }); } @Override public void onFailure(Throwable caught) { Main.get().showError("getUUIDByPath", caught); } }); } anchor.setStyleName("okm-Hyperlink"); downloadTable.setWidget(downloadTableRow, 0, new HTML(" ")); downloadTable.setWidget(downloadTableRow, 1, anchor); } hPanel.add(downloadTable); } else if (gwtFormElement instanceof GWTPrint) { HorizontalPanel hPanel = new HorizontalPanel(); hWidgetProperties.put(propertyName, hPanel); table.setWidget(row, 0, hPanel); table.getFlexCellFormatter().setColSpan(row, 0, 2); GWTPrint print = (GWTPrint) gwtFormElement; FlexTable printTable = new FlexTable(); HTML description = new HTML("<b>" + gwtFormElement.getLabel() + "</b>"); printTable.setWidget(0, 0, description); printTable.getFlexCellFormatter().setColSpan(0, 0, 2); for (final GWTNode node : print.getNodes()) { int downloadTableRow = printTable.getRowCount(); final Button downloadButton = new Button(Main.i18n("button.print")); if (!node.getUuid().equals("")) { downloadButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Window.alert("Not available"); } }); } else if (!node.getPath().equals("")) { repositoryService.getUUIDByPath(node.getPath(), new AsyncCallback<String>() { @Override public void onSuccess(String result) { //final String uuid = result; downloadButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Window.alert("Not available"); } }); } @Override public void onFailure(Throwable caught) { Main.get().showError("getUUIDByPath", caught); } }); } downloadButton.setStyleName("okm-DownloadButton"); printTable.setWidget(downloadTableRow, 0, new HTML(" " + node.getLabel() + " ")); printTable.setWidget(downloadTableRow, 1, downloadButton); } hPanel.add(printTable); } }
From source file:com.ikon.frontend.client.widget.propertygroup.PropertyGroupWidget.java
License:Open Source License
/** * start//from ww w .j a va2 s .co m * * @param path * @param propertyGroup * @param widget * @param propertyGroupWidgetToFire */ private void start(String path, GWTPropertyGroup propertyGroup, Widget widget, PropertyGroupWidgetToFire propertyGroupWidgetToFire) { propertyGroupHandlerExtensionList = new ArrayList<PropertyGroupHandlerExtension>(); manager = new FormManager(); this.path = path; this.propertyGroup = propertyGroup; this.propertyGroupWidgetToFire = propertyGroupWidgetToFire; VerticalPanel vPanel = new VerticalPanel(); vPanel.setWidth("100%"); FlexTable table = manager.getTable(); table.setWidth("100%"); FlexTable widgetTable = new FlexTable(); widgetTable.setCellPadding(0); widgetTable.setCellSpacing(0); widgetTable.setWidth("100%"); widgetTable.setWidget(0, 0, widget); widgetTable.getFlexCellFormatter().setColSpan(0, 0, 2); // Widget format widgetTable.getCellFormatter().setHorizontalAlignment(0, 0, HasAlignment.ALIGN_CENTER); widgetTable.getCellFormatter().setVerticalAlignment(0, 0, HasAlignment.ALIGN_MIDDLE); RowFormatter rowFormatter = widgetTable.getRowFormatter(); rowFormatter.setStyleName(0, "okm-Security-Title"); cellFormatter = widgetTable.getCellFormatter(); // Gets the cell formatter // Format borders and margins cellFormatter.addStyleName(0, 0, "okm-Security-Title-RightBorder"); vPanel.add(widgetTable); vPanel.add(table); initWidget(vPanel); }
From source file:com.jwh.gwt.fasttable.sample.client.FastTableSample.java
License:Open Source License
private void buildPushButton(final FlexTable flexTable) { final PushButton refreshButton = new PushButton("Refresh Table"); refreshButton.setTitle("Build new sample objects and update the table, using options specified above"); refreshButton.addClickHandler(new ClickHandler() { @Override/*from w ww . j a v a 2s . co m*/ public void onClick(ClickEvent event) { showSamples(); } }); refreshButton.addStyleName(BUTTON); refreshButton.addStyleName(CURSOR_POINTER); flexTable.setWidget(9, 0, refreshButton); flexTable.getFlexCellFormatter().setColSpan(9, 0, 2); }