2017-05-02 1 views
1

Actuellement nous affichons le conteneur qui contient la disposition de la table avec 7 colonnes au centre de l'écran dans la résolution 1280x800 pixels.Comment afficher le conteneur contient tablelayout de 7 colonnes au centre de l'écran pour tous les écrans de résolution dans le nom de code un

Mais nous avons besoin du même conteneur affichant dans la résolution 1920x1200 pixels au centre de l'écran.

En fait, le conteneur est affiché mais les données de ligne sont manquantes. Quelque chose ne va pas dans mon code? S'il vous plaît aidez-moi comment résoudre celui-ci.

FlowLayout centerLayout = new FlowLayout(); 
centerLayout.setAlign(Component.CENTER); 
centerLayout.setValign(Component.TOP); 

Container centerContainer = new Container(centerLayout); 
topTabelcontainer = new Container(new TableLayout(7, 1)); 

commonComponentsForm = new CommonComponentsForm(); 
eventPostSchedulesForm = commonComponentsForm.setEventPostSchedulesFormHeader(eventPostSchedulesForm, res, workerBreaksPreferences); 
topTabelcontainer = commonComponentsForm.getEventInfoHeader(eventPostSchedulesForm, res, topTabelcontainer, "showroster"); 

filterLayoutContainer = this.getFilterBody(); 
postScheduleTableContainer = this.getEventPostScheduleTable(); 

TableLayout.Constraint postScheduleTableConstraint = new TableLayout.Constraint(); 
postScheduleTableConstraint.setHorizontalAlign(BorderLayout.CENTER_BEHAVIOR_SCALE); 
postScheduleTableConstraint.setVerticalAlign(BorderLayout.CENTER_BEHAVIOR_SCALE); 

topTabelcontainer.add(filterLayoutContainer); 
headerContainer); 
topTabelcontainer.add(postScheduleTableConstraint, postScheduleTableContainer); 
centerContainer.add(topTabelcontainer); 

centerContainer.setScrollableY(Boolean.TRUE); 
centerContainer.setTactileTouch(Boolean.TRUE); 

centerContainer.addPointerDraggedListener(new ActionListener() { 
    @Override 
    public void actionPerformed(ActionEvent evt) { 
     float val = Display.getInstance().getDragSpeed(false); 
     boolean upperFlag = false; 
     if (Display.getInstance().isPortrait()) { 
      if (portRaitUpperBound < toralRecourdsCount) 
       upperFlag = true; 
     } else if (landScapeUpperBound < toralRecourdsCount) 
      upperFlag = true; 

     boolean lowerFlag = false; 
     if (Display.getInstance().isPortrait()) { 
      if ((portRaitLowerBound > 0 && portRaitLowerBound <= toralRecourdsCount)) 
       lowerFlag = true; 
     } else if (landScapeLowerBound > 0 && landScapeLowerBound < toralRecourdsCount) 
      lowerFlag = true; 

     if (val >= 0.5 && scrollFlag) { 
      dragFlag = true; 
      if (upperFlag) { 
       scrollFlag = false; 
       setPageUpperAndLowerBound(Constants.NEXTFLAG); 
       postScheduleTableContainer.removeAll(); 
       setEventPostScheduleTable(postScheduleTableContainer); 
       eventPostSchedulesForm.revalidate(); 
      } 
     } else if (val <= -0.5 && scrollFlag) { 
      dragFlag = true; 
      if (lowerFlag) { 
       scrollFlag = false; 
       setPageUpperAndLowerBound(Constants.PREVIOUSFLAG); 
       postScheduleTableContainer.removeAll(); 
       setEventPostScheduleTable(postScheduleTableContainer); 
       eventPostSchedulesForm.revalidate(); 
      } 
     } 
    } 
}); 

eventPostSchedulesForm.setUIID("workersListForm"); 
eventPostSchedulesForm.add(BorderLayout.CENTER, centerContainer); 
commonComponentsForm.getFooterTag(eventPostSchedulesForm); 
eventPostSchedulesForm.show(); 
} 

public Container getEventPostSchedulesTableHeader(Container postSchedulesTableHeaderContainer) { 

    Label position = new Label(Constants.POSITION, searchingButtonImage); 
    Label name = new Label(Constants.NAME, searchingButtonImage); 
    Label callInOutLabel = new Label(Constants.CALLINOUT); 
    position.setTextPosition(LEFT); 
    name.setTextPosition(LEFT); 

    TextArea actualCallIn1 = null; 
    Label actualCallIn = null; 

    TextArea actualCallOut1 = null; 
    Label actualCallOut = null; 

    TextArea agencyWorker1 = null; 
    Label agencyWorker = null; 
    if (Display.getInstance().isPortrait()) { 
     actualCallIn1 = new TextArea(Constants.ACTUALCALLIN); 
     actualCallIn1.setEditable(false); 
     actualCallIn1.setFocusable(false); 
     actualCallIn1.setColumns(3); 
     actualCallIn1.setVerticalAlignment(Component.CENTER); 

     actualCallOut1 = new TextArea(Constants.ACTUALCALLOUT); 
     actualCallOut1.setEditable(false); 
     actualCallOut1.setFocusable(false); 
     actualCallOut1.setColumns(3); 
     actualCallOut1.setVerticalAlignment(Component.CENTER); 

     agencyWorker1 = new TextArea(Constants.AGENCYWORKER); 
     agencyWorker1.setEditable(false); 
     agencyWorker1.setFocusable(false); 
     agencyWorker1.setColumns(3); 
     agencyWorker1.setVerticalAlignment(Component.CENTER); 
    } else { 
     agencyWorker = new Label(Constants.AGENCYWORKER); 
     actualCallIn = new Label(Constants.ACTUALCALLIN); 
     actualCallOut = new Label(Constants.ACTUALCALLOUT); 

    } 
    Label workerBreak = new Label(" "); 


    position.setUIID("workerTableHeader"); 
    name.setUIID("workerTableHeader"); 
    callInOutLabel.setUIID("workerTableHeader"); 

    if (Display.getInstance().isPortrait()) { 
     agencyWorker1.setUIID("workerTableHeader"); 
     actualCallIn1.setUIID("workerTableHeader"); 
     actualCallOut1.setUIID("workerTableHeader"); 
    } else { 
     agencyWorker.setUIID("workerTableHeader"); 
     actualCallIn.setUIID("workerTableHeader"); 
     actualCallOut.setUIID("workerTableHeader"); 
    } 
    workerBreak.setUIID("workerTableHeader"); 


    if (Display.getInstance().isPortrait()) { 
     postSchedulesTableHeaderContainer.addComponent(getTableConstraint(16, 8), position); 
     postSchedulesTableHeaderContainer.addComponent(getTableConstraint(15, 8), name); 
     postSchedulesTableHeaderContainer.addComponent(getTableConstraint(24, 8), callInOutLabel); 
     postSchedulesTableHeaderContainer.addComponent(getTableConstraint(13, 8), actualCallIn1); 
     postSchedulesTableHeaderContainer.addComponent(getTableConstraint(13, 8), actualCallOut1); 
     postSchedulesTableHeaderContainer.add(getTableConstraint(13, 8), agencyWorker1); 
     if (workerBreaksPreferences.getAllowbreaks() != null && !"".equals(workerBreaksPreferences.getAllowbreaks()) && "1".equals(workerBreaksPreferences.getAllowbreaks())) 
      postSchedulesTableHeaderContainer.addComponent(getTableConstraint(6, 8), workerBreak); 
    } else { 
     postSchedulesTableHeaderContainer.addComponent(getTableConstraint(13, 10), position); 
     postSchedulesTableHeaderContainer.addComponent(getTableConstraint(18, 10), name); 
     postSchedulesTableHeaderContainer.addComponent(getTableConstraint(20, 10), callInOutLabel); 
     postSchedulesTableHeaderContainer.addComponent(getTableConstraint(13, 10), actualCallIn); 
     postSchedulesTableHeaderContainer.addComponent(getTableConstraint(13, 10), actualCallOut); 
     postSchedulesTableHeaderContainer.addComponent(getTableConstraint(16, 10), agencyWorker); 
     if (workerBreaksPreferences.getAllowbreaks() != null && !"".equals(workerBreaksPreferences.getAllowbreaks()) && "1".equals(workerBreaksPreferences.getAllowbreaks())) 
      postSchedulesTableHeaderContainer.addComponent(getTableConstraint(7, 10), workerBreak); 
    } 

    return postSchedulesTableHeaderContainer; 
} 

public Container getEventPostScheduleTable() { 
    List <WorkerBean> eventPostSchedulesList = null; 
    roasterDao = RoasterDao.getInstance(); 
    if (Display.getInstance().isPortrait()) { 
     eventPostSchedulesList = roasterDao.getEventPostSchedulesDetails(positionFilterValue, nameFilterValue, portRaitLowerBound, portRaitPageSize); 
    } else { 
     eventPostSchedulesList = roasterDao.getEventPostSchedulesDetails(positionFilterValue, nameFilterValue, landScapeLowerBound, landScapePageSize); 
    } 
    int tableRowCount = Constants.INITIALTABLEROWS; 
    boolean pagingFlag = false; 
    int eventPostScheduleCount = roasterDao.getEventPostSchedulesCount(positionFilterValue, nameFilterValue); 
    this.toralRecourdsCount = eventPostScheduleCount; 

    FlowLayout centerLayout = new FlowLayout(); 
    centerLayout.setAlign(Component.CENTER); 
    postScheduleTableContainer = new Container(centerLayout); 
    postScheduleTableContainer.setUIID("tableBodyContainer"); 

    if (eventPostSchedulesList.size() > landScapePageSize) { 
     tableRowCount = landScapePageSize + 1; 
    } else { 
     tableRowCount = eventPostSchedulesList.size() + 1; 
    } 

    Container borderTopPagingContainer = new Container(new BorderLayout()); 

    if (eventPostScheduleCount > landScapePageSize) { 
     pagingFlag = true; 
     if (Display.getInstance().isPortrait()) { 
      borderTopPagingContainer = this.setHeaderPaging(eventPostScheduleCount, portRaitLowerBound, portRaitUpperBound, res); 
     } else { 
      borderTopPagingContainer = this.setHeaderPaging(eventPostScheduleCount, landScapeLowerBound, landScapeUpperBound, res); 
     } 
    } 
    if (pagingFlag) { 
     tableRowCount = tableRowCount + 1; 
    } 

    int columnCount = 6; 
    if (workerBreaksPreferences.getAllowbreaks() != null && !"".equals(workerBreaksPreferences.getAllowbreaks()) && "1".equals(workerBreaksPreferences.getAllowbreaks())) 
     columnCount++; 
    Container postSchedulesListContainer = new Container(new TableLayout(tableRowCount, columnCount)); 

    if (pagingFlag) { 
     TableLayout.Constraint postSchedulesListConstraint1 = new TableLayout.Constraint(); 
     postSchedulesListConstraint1.setHorizontalSpan(columnCount); 
     postSchedulesListContainer.add(postSchedulesListConstraint1, borderTopPagingContainer); 
    } 

    postSchedulesListContainer = this.getEventPostSchedulesTableHeader(postSchedulesListContainer); 

    String callInDBValue = ""; 
    String callOutDBValue = ""; 
    String actCallInDBValue = ""; 
    String actCallOutDBValue = ""; 
    Label position = null; 
    Label name = null; 
    Label callInOutLabel = null; 
    Label actualCallIn = null; 
    Label actualCallOut = null; 
    TextField agencyWorker = null; 
    Label workerBreak = null; 

    for (WorkerBean eventPostSchedules: eventPostSchedulesList) { 

     callInDBValue = ""; 
     if (eventPostSchedules != null) { 
      if (eventPostSchedules.getCallIn().length() > 10) 
       callInDBValue = eventPostSchedules.getCallIn().substring(10).trim(); 
      else { 
       if (Constants.PLATFORMNAME.equals(Display.getInstance().getPlatformName())) 
        callInDBValue = "    "; 
       else 
        callInDBValue = "    "; 
      } 
     } 

     callOutDBValue = ""; 
     if (eventPostSchedules != null) { 
      if (eventPostSchedules.getCallOut().length() > 10) 
       callOutDBValue = eventPostSchedules.getCallOut().substring(10).trim(); 
      else { 
       if (Constants.PLATFORMNAME.equals(Display.getInstance().getPlatformName())) 
        callOutDBValue = "    "; 
       else 
        callOutDBValue = "    "; 
      } 
     } 

     actCallInDBValue = ""; 
     if (eventPostSchedules != null) { 
      if (eventPostSchedules.getActCallIn().length() > 10) 
       actCallInDBValue = eventPostSchedules.getActCallIn().substring(10).trim(); 
      else 
       actCallInDBValue = eventPostSchedules.getActCallIn().trim(); 
     } 

     actCallOutDBValue = ""; 
     if (null != eventPostSchedules) { 
      if (eventPostSchedules.getActCallOut().length() > 10) 
       actCallOutDBValue = eventPostSchedules.getActCallOut().substring(10).trim(); 
      else 
       actCallOutDBValue = eventPostSchedules.getActCallOut().trim(); 
     } 
     callInDBValue = ((callInDBValue.trim().length() < 8) ? " ".concat(callInDBValue) : callInDBValue) + ((callOutDBValue.trim().equals("")) ? callOutDBValue : " - " + callOutDBValue); 
     position = new Label(eventPostSchedules.getPersonnelType()); 
     name = new Label(eventPostSchedules.getName()); 
     callInOutLabel = new Label(callInDBValue); 
     actualCallIn = new Label(actCallInDBValue); 
     actualCallIn.setFocusable(Boolean.TRUE); 
     actualCallIn.addPointerPressedListener(createActualCallChangeListener(actualCallIn, eventPostSchedules.getSerialId(), Constants.ACTUALCALLINFLAG, eventPostSchedules.getName(), eventPostSchedules.getActCallIn(), eventPostSchedules.getActCallOut(), eventPostSchedules.getActCallIn())); 

     actualCallOut = new Label(actCallOutDBValue); 
     actualCallOut.setFocusable(Boolean.TRUE); 
     actualCallOut.addPointerPressedListener(createActualCallChangeListener(actualCallOut, eventPostSchedules.getSerialId(), Constants.ACTUALCALLOUTFLAG, eventPostSchedules.getName(), eventPostSchedules.getActCallIn(), eventPostSchedules.getActCallOut(), eventPostSchedules.getActCallOut())); 


     agencyWorker = new TextField(eventPostSchedules.getAgencyWorker(), null, 5, TextArea.ANY); 

     position.setUIID("workersList"); 
     name.setUIID("workersList"); 
     callInOutLabel.setUIID("workersList"); 
     actualCallIn.setUIID("workersListEditable"); 
     actualCallOut.setUIID("workersListEditable"); 
     agencyWorker.setUIID("workersListEditable"); 

     workerBreak.setUIID("workersList"); 

     if (Display.getInstance().isPortrait()) { 
      postSchedulesListContainer.addComponent(getTableConstraint(16, 8), position); 
      postSchedulesListContainer.addComponent(getTableConstraint(15, 8), name); 
      postSchedulesListContainer.addComponent(getTableConstraint(24, 8), callInOutLabel); 
      postSchedulesListContainer.addComponent(getTableConstraint(13, 8), actualCallIn); 
      postSchedulesListContainer.addComponent(getTableConstraint(13, 8), actualCallOut); 
      postSchedulesListContainer.addComponent(getTableConstraint(13, 8), agencyWorker); 
      if (workerBreaksPreferences.getAllowbreaks() != null && !"".equals(workerBreaksPreferences.getAllowbreaks()) && "1".equals(workerBreaksPreferences.getAllowbreaks())) 
       postSchedulesListContainer.addComponent(getTableConstraint(6, 8), workerBreak); 
     } else { 
      postSchedulesListContainer.addComponent(getTableConstraint(13, 10), position); 
      postSchedulesListContainer.addComponent(getTableConstraint(18, 10), name); 
      postSchedulesListContainer.addComponent(getTableConstraint(20, 10), callInOutLabel); 
      postSchedulesListContainer.addComponent(getTableConstraint(13, 10), actualCallIn); 
      postSchedulesListContainer.addComponent(getTableConstraint(13, 10), actualCallOut); 
      postSchedulesListContainer.addComponent(getTableConstraint(16, 10), agencyWorker); 
      if (workerBreaksPreferences.getAllowbreaks() != null && !"".equals(workerBreaksPreferences.getAllowbreaks()) && "1".equals(workerBreaksPreferences.getAllowbreaks())) 
       postSchedulesListContainer.addComponent(getTableConstraint(7, 10), workerBreak); 
     } 
    } 
    postScheduleTableContainer.add(postSchedulesListContainer); 
    return postScheduleTableContainer; 
} 

} 
} 
public TableLayout.Constraint getTableConstraint(int widthPercent, int heightPercent) { 
    TableLayout.Constraint tableConstraint = new TableLayout.Constraint(); 
    tableConstraint.setWidthPercentage(widthPercent); 
    tableConstraint.setHeightPercentage(heightPercent); 
    return tableConstraint; 
} 
} 

this is in 1920x1200 resolution

Répondre

0

Ne pas utiliser de flux pour la mise en page de grandes données dynamiques. Vous mettez en page la bordure avec la contrainte du centre ou le centre absolu.

La disposition de flux est trop simpliste et ne doit pas être utilisée pour des structures complexes car Codename One ne se reproduit pas. Il y a une grande discussion à ce sujet dans le guide du développeur.