protected void applyDefaults() { expandedIcon = new ArrowIcon(ArrowIcon.SOUTH, UIManager.getColor(CourierSystem.TITLE_FOREGROUND_KEY)); collapsedIcon = new ArrowIcon(ArrowIcon.EAST, UIManager.getColor(CourierSystem.TITLE_FOREGROUND_KEY)); setBorder( new MatteBorder(0, 0, 0, 1, UIManager.getColor(CourierSystem.CONTROL_MID_SHADOW_KEY))); if (titlePanel != null) { titlePanel.setGradientColor1(UIManager.getColor(CourierSystem.TITLE_GRADIENT_COLOR1_KEY)); titlePanel.setGradientColor2(UIManager.getColor(CourierSystem.TITLE_GRADIENT_COLOR2_KEY)); } if (demoListLabel != null) { demoListLabel.setForeground(UIManager.getColor(CourierSystem.TITLE_FOREGROUND_KEY)); demoListLabel.setFont(UIManager.getFont(CourierSystem.TITLE_FONT_KEY)); } if (viewPanel != null) { viewPanel.setBackground(UIManager.getColor(CourierSystem.SUB_PANEL_BACKGROUND_KEY)); } if (collapsePanels != null) { for (CollapsiblePanel collapsePanel : collapsePanels) { collapsePanel.setFont(UIManager.getFont("CheckBox.font").deriveFont(Font.BOLD)); collapsePanel.setForeground(UIManager.getColor(CourierSystem.TITLE_FOREGROUND_KEY)); collapsePanel.setExpandedIcon(expandedIcon); collapsePanel.setCollapsedIcon(collapsedIcon); } } revalidate(); }
protected JComponent createDemoSelector(List<Demo> demoSet) { JPanel selectorPanel = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); selectorPanel.setLayout(gridbag); GridBagConstraints c = new GridBagConstraints(); c.gridx = c.gridy = 0; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; HashMap<String, JPanel> categoryMap = new HashMap<String, JPanel>(); GridBagLayout categoryGridbag = null; GridBagConstraints cc = new GridBagConstraints(); cc.gridx = cc.gridy = 0; cc.weightx = 1; cc.fill = GridBagConstraints.HORIZONTAL; CollapsiblePanel collapsePanel; for (Demo demo : demoSet) { String category = demo.getCategory(); demo.setLoginInfor(args[0], args[1], args[2]); LoginDAL lgDal = new LoginDAL(); int adRole = Integer.parseInt(args[2]); /////////////////////////////////////////////// Show Courier Chung/////////////////////////// if (demo.getName().equals("View Courier")) { JPanel categoryPanel = categoryMap.get(category); if (categoryPanel == null) { // Create category collapsible panel categoryPanel = new JPanel(); categoryGridbag = new GridBagLayout(); categoryPanel.setLayout(categoryGridbag); collapsePanel = new CollapsiblePanel(categoryPanel, category, "click to expand or contract category"); collapsePanels.add(collapsePanel); collapsePanel.setBorder(categoryBorder); categoryMap.put(category, categoryPanel); gridbag.addLayoutComponent(collapsePanel, c); selectorPanel.add(collapsePanel); c.gridy++; } DemoButton demoButton = new DemoButton(demo); categoryGridbag.addLayoutComponent(demoButton, cc); cc.gridy++; group.add(demoButton); categoryPanel.add(demoButton); if (buttonHeight == 0) { buttonHeight = demoButton.getPreferredSize().height; } } ///////////////////////////////////////////////////////////////////////////////////////////// if (adRole == 0) { int depRole = lgDal.getDepartmentRole(Integer.parseInt(args[0])); if (depRole == 1) { if (demo.getName().equals("Receiving-Returning")) { JPanel categoryPanel = categoryMap.get(category); if (categoryPanel == null) { // Create category collapsible panel categoryPanel = new JPanel(); categoryGridbag = new GridBagLayout(); categoryPanel.setLayout(categoryGridbag); collapsePanel = new CollapsiblePanel( categoryPanel, category, "click to expand or contract category"); collapsePanels.add(collapsePanel); collapsePanel.setBorder(categoryBorder); categoryMap.put(category, categoryPanel); gridbag.addLayoutComponent(collapsePanel, c); selectorPanel.add(collapsePanel); c.gridy++; } DemoButton demoButton = new DemoButton(demo); categoryGridbag.addLayoutComponent(demoButton, cc); cc.gridy++; group.add(demoButton); categoryPanel.add(demoButton); if (buttonHeight == 0) { buttonHeight = demoButton.getPreferredSize().height; } } } else if (depRole == 2) { if (demo.getName().equals("Despatching")) { JPanel categoryPanel = categoryMap.get(category); if (categoryPanel == null) { // Create category collapsible panel categoryPanel = new JPanel(); categoryGridbag = new GridBagLayout(); categoryPanel.setLayout(categoryGridbag); collapsePanel = new CollapsiblePanel( categoryPanel, category, "click to expand or contract category"); collapsePanels.add(collapsePanel); collapsePanel.setBorder(categoryBorder); categoryMap.put(category, categoryPanel); gridbag.addLayoutComponent(collapsePanel, c); selectorPanel.add(collapsePanel); c.gridy++; } DemoButton demoButton = new DemoButton(demo); categoryGridbag.addLayoutComponent(demoButton, cc); cc.gridy++; group.add(demoButton); categoryPanel.add(demoButton); if (buttonHeight == 0) { buttonHeight = demoButton.getPreferredSize().height; } } } else if (depRole == 3) { if (demo.getName().equals("Storing")) { JPanel categoryPanel = categoryMap.get(category); if (categoryPanel == null) { // Create category collapsible panel categoryPanel = new JPanel(); categoryGridbag = new GridBagLayout(); categoryPanel.setLayout(categoryGridbag); collapsePanel = new CollapsiblePanel( categoryPanel, category, "click to expand or contract category"); collapsePanels.add(collapsePanel); collapsePanel.setBorder(categoryBorder); categoryMap.put(category, categoryPanel); gridbag.addLayoutComponent(collapsePanel, c); selectorPanel.add(collapsePanel); c.gridy++; } DemoButton demoButton = new DemoButton(demo); categoryGridbag.addLayoutComponent(demoButton, cc); cc.gridy++; group.add(demoButton); categoryPanel.add(demoButton); if (buttonHeight == 0) { buttonHeight = demoButton.getPreferredSize().height; } } } } else if (adRole == 1) { int depRole = lgDal.getDepartmentRoleOfAdministrator(Integer.parseInt(args[0])); if (depRole == 4) { if (demo.getName().equals("Department")) { JPanel categoryPanel = categoryMap.get(category); if (categoryPanel == null) { // Create category collapsible panel categoryPanel = new JPanel(); categoryGridbag = new GridBagLayout(); categoryPanel.setLayout(categoryGridbag); collapsePanel = new CollapsiblePanel( categoryPanel, category, "click to expand or contract category"); collapsePanels.add(collapsePanel); collapsePanel.setBorder(categoryBorder); categoryMap.put(category, categoryPanel); gridbag.addLayoutComponent(collapsePanel, c); selectorPanel.add(collapsePanel); c.gridy++; } DemoButton demoButton = new DemoButton(demo); categoryGridbag.addLayoutComponent(demoButton, cc); cc.gridy++; group.add(demoButton); categoryPanel.add(demoButton); if (buttonHeight == 0) { buttonHeight = demoButton.getPreferredSize().height; } } if (demo.getName().equals("Employee")) { JPanel categoryPanel = categoryMap.get(category); if (categoryPanel == null) { // Create category collapsible panel categoryPanel = new JPanel(); categoryGridbag = new GridBagLayout(); categoryPanel.setLayout(categoryGridbag); collapsePanel = new CollapsiblePanel( categoryPanel, category, "click to expand or contract category"); collapsePanels.add(collapsePanel); collapsePanel.setBorder(categoryBorder); categoryMap.put(category, categoryPanel); gridbag.addLayoutComponent(collapsePanel, c); selectorPanel.add(collapsePanel); c.gridy++; } DemoButton demoButton = new DemoButton(demo); categoryGridbag.addLayoutComponent(demoButton, cc); cc.gridy++; group.add(demoButton); categoryPanel.add(demoButton); if (buttonHeight == 0) { buttonHeight = demoButton.getPreferredSize().height; } } if (demo.getName().equals("Calculation")) { JPanel categoryPanel = categoryMap.get(category); if (categoryPanel == null) { // Create category collapsible panel categoryPanel = new JPanel(); categoryGridbag = new GridBagLayout(); categoryPanel.setLayout(categoryGridbag); collapsePanel = new CollapsiblePanel( categoryPanel, category, "click to expand or contract category"); collapsePanels.add(collapsePanel); collapsePanel.setBorder(categoryBorder); categoryMap.put(category, categoryPanel); gridbag.addLayoutComponent(collapsePanel, c); selectorPanel.add(collapsePanel); c.gridy++; } DemoButton demoButton = new DemoButton(demo); categoryGridbag.addLayoutComponent(demoButton, cc); cc.gridy++; group.add(demoButton); categoryPanel.add(demoButton); if (buttonHeight == 0) { buttonHeight = demoButton.getPreferredSize().height; } } } } } // add empty component to take up any extra room on bottom JPanel trailer = new JPanel(); c.weighty = 1.0; gridbag.addLayoutComponent(trailer, c); selectorPanel.add(trailer); applyDefaults(); return selectorPanel; }