Scout Eclipse AbstractGroupBox auto size - layout

I would like to have AbstractGroupBox that will grep all place that is available.
For Example :
if my form is like this:
-----------------------------------------------------------
| ------------ ------------ ------------ |
| |some field| |some field| |some field| |
| ------------ ------------ ------------ |
| |
| ------------------------------------------------------ |
| | AbstractGroupBox | |
| ------------------------------------------------------ |
| |
| |
| |
| |
| |
| |
| |
| |
-----------------------------------------------------------
Now I would like to have AbstractGroupBox to take all height of the form data.
I know I need to add
#Override
protected boolean getConfiguredGridUseUiHeight() {
return false;
}
because it has no content. By default Fill Vertical is set to true.
By what I can understand I should set
#Override
protected double getConfiguredGridWeightY() {
return 1.0;
}
so grid cell will grep more space as Scout helps says.
But with all this set I still have small AbstractGroupBox.
How to set AbstractGroupBox that will grep all space available?
EDIT :
The layout is :
and my code is :
#Order(60.0)
public class ViewBox extends AbstractGroupBox {
#Override
protected String getConfiguredLabel() {
return TEXTS.get("ViewBox");
}
#Override
protected String getConfiguredBackgroundColor() {
return "364BFF";
}
#Override
protected int getConfiguredGridW() {
return 4;
}
#Override
protected double getConfiguredGridWeightY() {
return 1.0;
}
}

I am not sure to follow... This code works for me:
#Order(5000.0)
public class MyGroupBoxField extends AbstractGroupBox {
#Override
protected int getConfiguredGridW() {
return 2;
}
#Override
protected double getConfiguredGridWeightY() {
return 1.0;
}
}
Maybe I did not understood your use case, but this is what I get:

Related

display jsf 2D table

I want to display a 2D array in my view .xhtml, which contains the database column as rows, but I can not get a 2D array
my BD Table
training | experience | motivation
NA | B | AT
I want to display a data table as follows
| evaluation | comment
-------------------------------------------
training | A | ...
-------------------------------------------------- -----
experience | B | ....
You'll have to write some Java code in a managed bean like this:
public class SomethingSomethingDTO {
private final String subject;
private final String evaluation;
private final String comment;
public SomethingSomethingDTO(final String subject,
final String evaluation, final String comment) {
this.subject = subject;
this.evaluation = evaluation;
this.comment = comment;
}
public String getSubject() {
return subject;
}
public String getEvaluation() {
return evaluation;
}
public String getComment() {
return comment;
}
}
#PostConstruct // or some other event or command button action
public void initializeSomething() {
somethings = new ArrayList<>();
somethings.add(new SomethingSomethingDTO("training", "A", "..."));
somethings.add(new SomethingSomethingDTO("experiance", "B", "..."));
}
private List<SomethingSomethingDTO> somethings;
public List<SomethingSomethingDTO> getSomethings() {
return somethings;
}

Error executing slim fitnesse test case

I'm getting following error when executing test case in fitnesse:
The instance decisionTable_0.setFirst. does not exist
Below link has the screenshot:
https://github.com/unclebob/fitnesse/issues/1078
Below is the fixture java code:
package FitnesseExamples;
public class Calculator {
private int first, second;
public void setFirst(int first){
this.first = first;
}
public void setSecond(int second){
this.second = second;
}
public int addition(){
return(first+second);
}
public int minus(){
return(first-second);
}
public int multiply(){
return(first*second);
}
public float divide(){
return(first/second);
}
}
Below is the wiki test:
!define TEST_SYSTEM {slim}
!path C:\Shyam\Automation\Workspace\AddNumber\src\FitnesseExamples
!|Calculator|
|first|second|addition?|minus?|multiply?|divide?|
|4 |2 |6 |2 |8 |2.0 |
|10 |5 |15 |5 |50 |2.0 |
|10 |10 |20 |0 |100 |1.0 |
My Calculator.class file is present in the following location:
C:\Shyam\Automation\Workspace\AddNumber\src\FitnesseExamples

JavaFX how to get menubar on the bottom

I'm trying to put the menu bar on the bottom of a windows, here are a example made in paint
but I don't have enough reputation so isn't like this
________________________________________
| _ x|
| |
| |
| |
| |
| |
| |
|file | Edit | view| |
|______________________________________|
To create menu you should use MenuBar component, which you can add using any layout.
For your use case you can use BorderPane and set MenuBar to the bottom
Example code:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class Main extends Application {
#Override
public void start(Stage primaryStage) {
try {
BorderPane root = new BorderPane();
Menu menu1 = new Menu("File");
Menu menu2 = new Menu("Edit");
Menu menu3 = new Menu("View");
MenuBar menuBar = new MenuBar();
menuBar.getMenus().addAll(menu1, menu2, menu3);
root.setBottom(menuBar);
Scene scene = new Scene(root, 400, 400);
primaryStage.setScene(scene);
primaryStage.show();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}

Populate table with nested Collections

I´m looking for a solution for my problem.
I have a table that needs to be like this.
--------------------------------------------------------------|
| | Title 3 |
Title 1 |Title 2|---------------------------------------------|
| | SubTitle 1 |SubTitle 2|SubTitle 3|SubTitle 4|
--------------------------------------------------------------|
| | | | | |
Val A1 | ValB1 | ValC1 | ValC1 | ValC1 | ValC1 |
| | | | | |
|-------|------------|----------|----------|----------|
| | | | | |
| ValB2 | ValC2 | ValC2 | ValC2 | ValC2 |
| | | | | |
--------------------------------------------------------------|
| | | | | |
| | | | | |
Val A2 | ValB3 | ValC3 | ValC3 | ValC3 | ValC3 |
| | | | | |
| | | | | |
----------------------------------------------------------------
My goal it´s to make a table appear like I did above.
I´m using JSF and Primefaces 4.0.
I have this struture of class.
Class Master {
private List<ClassA> classesA
// getter and setter
}
Class A {
private List<ClassB> classesB
// getter and setter and fields
}
Class B {
private List<ClassC> classesC
// getter and setter and fields
}
Class C {
// getter and setter and fields
}
So I tried to make with two datatables or using ui:repeat, but I don´t know what´s going to be the best choose. And the titles the owns like this.
Class A have title 1, Class B have title 2 and Class C have title 3 and subtitle 1,2,3 and 4.
Or use binding.
To be more easier to understand I put a picture about how I need to create the table.
Can someone help me?
Thanks
If you are sure that the object structure won't change in future then simple solution is to go for ui:repeat with nested tables, rowspan and colspan. But if the object structure often changes and you need to do it more than one time then go for custom component.If you need olap features then i suggest you to go for pivot4j or something similar.
update: see the xhtml below it creates the body of the table.
<table border="4" cellspacing="4" cellpadding="10">
<tr>
<th rowspan="2">A</th>
<th rowspan="2">B</th>
<th colspan="4">C</th>
</tr>
<tr>
<th>p1</th>
<th>p2</th>
<th>p3</th>
<th>p4</th>
</tr>
<ui:repeat var="classa" value="#{master.classesA}" varStatus="astat">
<ui:repeat var="classb" value="#{classa.classesB}" varStatus="bstat">
<ui:repeat value="#{classb.classesC}" var="classc" varStatus="cstat">
<tr>
<h:panelGroup rendered="#{bstat.index eq 0 and cstat.index eq 0}">
<td rowspan="#{classa.colSpan}" >
<h:outputText value="#{classa.property}" />
</td>
</h:panelGroup>
<h:panelGroup rendered="#{cstat.index eq 0}">
<td rowspan="#{classb.classesC.size()}">
<h:outputText value="#{classb.property}" />
</td>
</h:panelGroup>
<td>
<h:outputText value="#{classc.prop1}" />
</td>
<td>
<h:outputText value="#{classc.prop2}" />
</td>
<td>
<h:outputText value="#{classc.prop3}" />
</td>
<td>
<h:outputText value="#{classc.prop4}" />
</td>
</tr>
</ui:repeat>
</ui:repeat>
</ui:repeat>
</table>
and classes should look like this
public class A {
private List<B> classesB;
private String property;
public List<B> getClassesB() {
return classesB;
}
public void setClassesB(List<B> classesB) {
this.classesB = classesB;
}
public A(String pro) {
classesB= new ArrayList<B>();
property=pro;
}
public void addClassB(B b){
classesB.add(b);
}
public String getProperty() {
return property;
}
public void setProperty(String property) {
this.property = property;
}
public int getColSpan(){
int size=0;
for(B b : classesB){
size+=b.getClassesC().size();
}
return size;
}
}
public class B {
private List<C> classesC;
private String property;
public B(String pro) {
this.classesC = new ArrayList<C>();
this.property=pro;
}
public List<C> getClassesC() {
return classesC;
}
public void setClassesC(List<C> classesC) {
this.classesC = classesC;
}
public void addClassC(C c){
classesC.add(c);
}
public String getProperty() {
return property;
}
public void setProperty(String property) {
this.property = property;
}
}
public class C {
private String prop1;
private String prop2;
private String prop3;
private String prop4;
public C(String prop1, String prop2, String prop3, String prop4) {
this.prop1 = prop1;
this.prop2 = prop2;
this.prop3 = prop3;
this.prop4 = prop4;
}
public void setProp1(String prop1) {
this.prop1 = prop1;
}
public void setProp2(String prop2) {
this.prop2 = prop2;
}
public void setProp3(String prop3) {
this.prop3 = prop3;
}
public void setProp4(String prop4) {
this.prop4 = prop4;
}
public String getProp1() {
return prop1;
}
public String getProp2() {
return prop2;
}
public String getProp3() {
return prop3;
}
public String getProp4() {
return prop4;
}
}
Test data in Master class.
private List<A> classesA;
#PostConstruct
public void init() {
classesA = new ArrayList<A>();
A a1 = new A("a1");
A a2 = new A("a2");
classesA.add(a1);
classesA.add(a2);
B b11 = new B("b11");
B b12 = new B("b12");
B b21 = new B("b21");
a1.addClassB(b11);
a1.addClassB(b12);
a2.addClassB(b21);
C c111 = new C("a", "b", "c", "d");
C c112 = new C("d", "e", "f", "g");
C c121 = new C("g", "h", "i", "j");
C c211 = new C("k", "l", "m", "n");
C c212 = new C("o", "p", null, null);
b11.addClassC(c111);
b11.addClassC(c112);
b12.addClassC(c121);
b21.addClassC(c211);
b21.addClassC(c212);
}
public List<A> getClassesA() {
return classesA;
}
public void setClassesA(List<A> classesA) {
this.classesA = classesA;
}
You can use dataTable with subTable (and you can add columns in row if needed).

generate Primefaces MenuModel from database

i want to ask how to make generate menumodel from database using recursive function.
i already make this class but it's not working. please help me,i already find and trying for a week .thanks
public class MenuDAOImpl extends ManagerBase<MenuMaster> implements MenuDAO {
private List<MenuMaster> list;
private List<MenuData> datas;
#Override
public MenuModel getMenu() {
MenuModel model = new DefaultMenuModel();
String[] orders = new String[]{"id"};
try {
list = getBySQLQuery("PARENT_MENU_ID=0", orders, 1000);
for (MenuMaster menuMaster : list) {
menuChild(menuMaster);
}
} catch (Exception e) {
}
return model;
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
private List<MenuData> menuChild(MenuMaster master) {
List<MenuData> listChild = new ArrayList<MenuData>();
String[] orders = new String[]{"id"};
try {
MenuData data = new MenuData();
data.mm = master;
data.mms = getBySQLQuery("PARENT_MENU_ID=" + master.getParentMenuId(), orders, 1000);
listChild.add(data);
} catch (Exception e) {
}
return listChild;
}
public class MenuData {
private MenuMaster mm;
private List<MenuMaster> mms;
public MenuData() {
}
public MenuMaster getMm() {
return mm;
}
public void setMm(MenuMaster mm) {
this.mm = mm;
}
public List<MenuMaster> getMms() {
return mms;
}
public void setMms(List<MenuMaster> mms) {
this.mms = mms;
}
}
}
this is my database table (sorry i can't upload images)
ID | MENU_NAME | DISPLAY_NAME | URL |PARENT_MENU_ID |
1 | employee | Employee | /employee.xhtml | 0 |
2 | employeemenu| Employee | /employee.xhtml | 1 |
3 | utils | Utility | | 0 |
7 | asdf | asdf | | 6 |
6 | utilsmenu | test | | 3 |
5 | utilsdata | Admin Config | asdf | 3 |
4 | menu | Menu Editor | /utility/menu.xhtml | 3 |
Here's some code I had lying around, I create the menumodel by appending submenus and menuitems to his getChildren() property
private MenuModel model;
public MenuModel getModel() {
if(model != null) return model;
model = new DefaultMenuModel();
addDynamicMenus();
return model;
}
private void addDynamicMenus(){
if(modules == null){
modules = service.getModulesByUserLogin(loginBean.getUsername());
}
Submenu currfather = null;
for(SpFeModuleForUser s : modules){
if(currfather == null || (!currfather.getId().equals("menu_" + s.getModuleID()))){
currfather = new Submenu();
currfather.setLabel(Modules.getSingleton().getString(s.getModuleName()));
currfather.setId("menu_"+s.getModuleID());
model.addSubmenu(currfather);
}
MenuItem mi = new MenuItem();
mi.setValue(Modules.getSingleton().getString(s.getNAME()));
mi.setId("_" + s.getKey());
mi.setTarget("_self");
mi.setTitle(Modules.getSingleton().getString(s.getNAME() + "_Description"));
mi.setAjax(false);
mi.setUrl(url);
// Add parameters
UIParameter param = new UIParameter();
param.setName("moduleid");
param.setValue(s.getKey());
mi.getChildren().add(param);
mi.setProcess("#all");
currfather.getChildren().add(mi);
}
}

Resources