Exemplo n.º 1
0
  private BaseMenuBar() {
    int armStatus = ArmWrapper.FAILED;
    try {
      ArmWrapper.startTransaction(
          this, "com.base.myproject.client.ui.BaseMenuBar", "BaseMenuBar", new Object[] {});

      armStatus = ArmWrapper.GOOD;
    } finally {
      ArmWrapper.stopTransaction(
          "com.base.myproject.client.ui.BaseMenuBar", "BaseMenuBar", armStatus);
    }
  }
Exemplo n.º 2
0
  void init() {
    int armStatus = ArmWrapper.FAILED;
    try {
      ArmWrapper.startTransaction(
          this, "com.base.myproject.client.busi.b2c.manager.ChartTest", "init", new Object[] {});

      armStatus = ArmWrapper.GOOD;
    } finally {
      ArmWrapper.stopTransaction(
          "com.base.myproject.client.busi.b2c.manager.ChartTest", "init", armStatus);
    }
  }
Exemplo n.º 3
0
  public void removeItem(Component item) {
    int armStatus = ArmWrapper.FAILED;
    try {
      ArmWrapper.startTransaction(
          this, "com.base.myproject.client.ui.BaseMenuBar", "removeItem", new Object[] {item});

      basemenubar.remove(item);
      armStatus = ArmWrapper.GOOD;
    } finally {
      ArmWrapper.stopTransaction(
          "com.base.myproject.client.ui.BaseMenuBar", "removeItem", armStatus);
    }
  }
Exemplo n.º 4
0
  public void _add() {
    int armStatus = ArmWrapper.FAILED;
    try {
      ArmWrapper.startTransaction(
          this, "com.base.myproject.client.ui.BaseMenuBar", "_add", new Object[] {});
      Button item1 = new Button("Button w/ Menu");
      item1.setIconStyle("icon-menu-show");
      Menu menu = new Menu();
      CheckMenuItem menuItem = new CheckMenuItem("I Like Cats");
      menuItem.setChecked(true);
      menu.add(menuItem);

      menuItem = new CheckMenuItem("I Like Dogs");
      menu.add(menuItem);
      item1.setMenu(menu);

      MenuItem menuitem2 = new MenuItem();
      menuitem2.setText("menuitem2");
      menuitem2.addSelectionListener(
          new SelectionListener() {

            @Override
            public void componentSelected(ComponentEvent ce) {
              // TODO Auto-generated method stub

            }

            public void handleEvent(BaseEvent be) {
              // TODO Auto-generated method stub
              // System.out.println("++");
              HTML homeText = new HTML("Tab you have selected is Home.");
              // BaseTabPanel.getInstance().addTab("zgw2", homeText);
              // BaseTabPanel.getInstance().addTab("zgw3", new BasePanel());
              BaseTabPanel.getInstance().addTab("zgw4", new TestBusi());
            }
          });

      menu.add(menuitem2);

      basemenubar.add(item1);
      armStatus = ArmWrapper.GOOD;
      // basemenubar.add(menuitem2);
    } finally {
      ArmWrapper.stopTransaction("com.base.myproject.client.ui.BaseMenuBar", "_add", armStatus);
    }
  }
Exemplo n.º 5
0
  public static BaseMenuBar getinstance() {
    int armStatus = ArmWrapper.FAILED;
    try {
      ArmWrapper.startTransaction(
          null, "com.base.myproject.client.ui.BaseMenuBar", "getinstance", new Object[] {});
      if (basemenubar == null) {
        basemenubar = new BaseMenuBar();
      }
      try {
        basemenubar.sendServlet("Loadmenu", "BaseServlet", "Action=loadmenu&menu1=13");
      } catch (RequestException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      armStatus = ArmWrapper.GOOD;
      return basemenubar;
    } finally {
      ArmWrapper.stopTransaction(
          "com.base.myproject.client.ui.BaseMenuBar", "getinstance", armStatus);
    }
  }
Exemplo n.º 6
0
  /**
   * 从服务器上取得菜单
   *
   * @param servletflag
   * @param url
   * @param form
   * @return
   * @throws RequestException
   */
  public boolean sendServlet(String servletflag, String url, String form) throws RequestException {
    int armStatus = ArmWrapper.FAILED;
    try {
      ArmWrapper.startTransaction(
          this,
          "com.base.myproject.client.ui.BaseMenuBar",
          "sendServlet",
          new Object[] {servletflag, url, form});

      // String url = "TestServlet" ;
      RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(url));
      builder.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
      // form = "Action=aaa&age=13";
      // builder.setRequestData(form);
      if (Env.getUid() != null) form += "&system_uuid=" + Env.getUid();
      builder.sendRequest(
          form,
          new RequestCallback() {

            @Override
            public void onError(Request request, Throwable exception) {
              // TODO Auto-generated method stub
              System.out.println(" send servlet error");
            }

            @Override
            public void onResponseReceived(Request request, Response response) {
              // TODO Auto-generated method stub

              String xmlstr = response.getText();
              // System.out.println("xmlstr----"+xmlstr);
              Document customerDom = XMLParser.parse(xmlstr);
              Element customerElement = customerDom.getDocumentElement();
              XMLParser.removeWhitespace(customerElement);
              //				String nameValue = customerElement.getElementsByTagName("Menu")
              //						.item(0).getFirstChild().getNodeValue();
              // 暂时屏蔽		NodeList nl = customerElement.getElementsByTagName("TextToolItem");
              NodeList nl = customerElement.getElementsByTagName("record");

              //				for (int i = 0; i < nl.getLength(); i++) {
              //					Element e = (Element) nl.item(i);
              //					System.out.println(e.getNodeName()+"--e.getnodename");
              //				}

              setMenu(nl);

              //				for (int i = 0; i < nl.getLength(); i++) {
              //					Element e = (Element) nl.item(i);
              //
              //					basemenubar.add(new TextToolItem(e
              //							.getAttribute("texttoolitemname")));
              //
              //					NodeList nl2 = e.getChildNodes();
              //					for (int j = 0; j < nl2.getLength(); j++) {
              //						Element e2 = (Element) nl2.item(i);
              //					}
              //
              //				}
              //	setmenufromxml(nl,null,null);

            }

            java.util.HashMap<String, Object> menuhm = new java.util.HashMap<String, Object>();

            /**
             * 从服务器上获得 str +="<records>"; str +="<record>"; str
             * +="<menucode>1001</menucode><menuname>menu1</menuname>"; str +="</record>"; str
             * +="</records>"; xml文件,通过menucode的长度,编辑4位一级,每4位为下一级菜单。注意:要想对编号进行排序
             *
             * @param nl
             */
            public void setMenu(NodeList nl) {

              for (int i = 0; i < nl.getLength(); i++) {
                Element e = (Element) nl.item(i);
                String code = "";
                String name = "";
                String cssstyle = "";
                String command = null;

                for (int j = 0; j < e.getChildNodes().getLength(); j++) {
                  Element e2 = (Element) nl.item(i).getChildNodes().item(j);

                  if (e2.getNodeName().equals("menucode")) {
                    code = e2.getFirstChild().getNodeValue();
                    if (code.length() == 4) {;
                    }

                  } else if (e2.getNodeName().equals("menuname")) {
                    name = e2.getFirstChild().getNodeValue();
                  } else if (e2.getNodeName().equals("cssstyle")) {
                    if ((e2.getFirstChild() != null) && (e2.getFirstChild().getNodeValue() != null))
                      cssstyle = e2.getFirstChild().getNodeValue();
                  } else if (e2.getNodeName().equals("command")) {
                    if ((e2.getFirstChild() != null) && (e2.getFirstChild().getNodeValue() != null))
                      command = e2.getFirstChild().getNodeValue();
                  }
                }
                if (code.length() / 4 == 1) {
                  Button tti = new Button(name);
                  tti.setIconStyle("icon-menu-show");
                  tti.setIconStyle(cssstyle);
                  basemenubar.add(tti);
                  //	menuhm.put(code.length()/4+"", tti);
                  Menu menu = new Menu();
                  // menuhm.put(code.length()/4+"", menu);
                  tti.setMenu(menu);
                  menuhm.put(code.length() / 4 + "", menu);
                }
                //					else if(code.length()/4 ==2)
                //					{
                //
                //					}
                else {
                  //						Menu menu = new Menu();
                  //						MenuItem menuitem = new MenuItem();
                  //						menuitem.setText(e.getAttribute(name));
                  //						menu.add(menuitem);

                  MenuItem item = new MenuItem(name);

                  if (command != null) {

                    item.addSelectionListener(new MenuCommandFactory(command));
                  }

                  if (menuhm.get(code.length() / 4 - 1 + "") instanceof Menu) {

                    ((Menu) menuhm.get(code.length() / 4 - 1 + "")).add(item);
                    menuhm.put(code.length() / 4 + "", item);
                  } else if (menuhm.get(code.length() / 4 - 1 + "") instanceof MenuItem) {

                    if (((MenuItem) menuhm.get(code.length() / 4 - 1 + "")).getSubMenu() != null) {
                      ((MenuItem) menuhm.get(code.length() / 4 - 1 + "")).getSubMenu().add(item);
                      menuhm.put(code.length() / 4 + "", item);
                    } else {
                      Menu menu = new Menu();
                      menu.add(item);

                      ((MenuItem) menuhm.get(code.length() / 4 - 1 + "")).setSubMenu(menu);
                      menuhm.put(code.length() / 4 + "", item);
                    }
                  }
                }
              }
            }

            public void setmenufromxml(NodeList nl, Button menuobject, Menu menu) {

              for (int i = 0; i < nl.getLength(); i++) {
                Element e = (Element) nl.item(i);
                if (e.getAttribute("type") != null)
                  if (e.getAttribute("type").equals("tooltextitem")) {
                    Button ttl = new Button(e.getAttribute("texttoolitemname"));
                    // if(menuobject==null)
                    {
                      System.out.println("toop menu...." + ttl.getText());
                      basemenubar.add(ttl);
                    }

                    if (e.hasChildNodes()) {
                      setmenufromxml(e.getChildNodes(), ttl, null);
                    }

                  } else if (e.getAttribute("type").equals("menu")) {
                    Menu menutemp = new Menu();
                    menuobject.setMenu(menutemp);

                    if (e.hasChildNodes()) {
                      setmenufromxml(e.getChildNodes(), menuobject, menutemp);
                    }

                  } else if (e.getAttribute("type").equals("menuitem")) {
                    MenuItem menuitem = new MenuItem();
                    menuitem.setText(e.getAttribute("name"));
                    menu.add(menuitem);

                    menuitem.addSelectionListener(
                        new SelectionListener() {

                          @Override
                          public void componentSelected(ComponentEvent ce) {
                            // TODO Auto-generated method stub

                          }

                          public void handleEvent(BaseEvent be) {
                            try {
                              // Class  c = Class.forName("business.client.TestBusi");
                              BaseJDBCPanel bjp =
                                  GWT.create(com.base.myproject.client.busi.TestBusi2.class);
                              BaseTabPanel.getInstance().addTab("zgw4", bjp);

                              //	c.newInstance();
                            } catch (Exception e) {
                              // TODO Auto-generated catch block
                              e.printStackTrace();
                            }
                          }
                        });

                    //						if(e.hasChildNodes())
                    //						{
                    //							setmenufromxml(e.getChildNodes(),menuitem,null);
                    //						}
                  }
              }
            }
          });

      armStatus = ArmWrapper.GOOD;
      return true;
    } finally {
      ArmWrapper.stopTransaction(
          "com.base.myproject.client.ui.BaseMenuBar", "sendServlet", armStatus);
    }
  }
Exemplo n.º 7
0
  public Widget aa() {
    int armStatus = ArmWrapper.FAILED;
    try {
      ArmWrapper.startTransaction(
          this, "com.base.myproject.client.busi.b2c.manager.ChartTest", "aa", new Object[] {});
      ContentPanel panel = new ContentPanel();
      panel.setAutoHeight(true);
      ToolBar tb = new ToolBar();
      Button addsuit = new Button("从商品库里添加套装商品");
      addsuit.setIconStyle("b2csuit");
      panel.setHeading("商品库,如果加入套装你必须先选择一行(必选)");
      tb.add(addsuit);
      panel.setTopComponent(tb);
      // addsuit.addListener(Events.Select, this);
      panel.setAutoWidth(true);
      CheckBoxSelectionModel cbs = new CheckBoxSelectionModel();
      List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
      columns.add(cbs.getColumn());
      ColumnConfig gcode = new ColumnConfig("gcode", "商品大类编码", 100);
      TextField<String> gcodetext = new TextField<String>();
      gcode.setEditor(new CellEditor(gcodetext));
      columns.add(gcode);
      ColumnConfig gname = new ColumnConfig("discountprice", "商品大类名称", 100);
      TextField<String> gnametext = new TextField<String>();
      gname.setEditor(new CellEditor(gnametext));
      columns.add(gname);

      ColumnConfig treecode = new ColumnConfig("price", "商品分类树编码", 100);

      TextField<String> treecodetext = new TextField<String>();
      treecode.setEditor(new CellEditor(treecodetext));
      columns.add(treecode);

      ColumnConfig b2cgcodecolumn = new ColumnConfig("b2cgcode", "商品编码", 100);
      TextField<String> b2cgcodetext = new TextField<String>();
      b2cgcodecolumn.setEditor(new CellEditor(b2cgcodetext));
      columns.add(b2cgcodecolumn);
      ColumnConfig b2cgname = new ColumnConfig("b2cgname", "商品名称", 100);
      TextField<String> b2cgnametext = new TextField<String>();
      b2cgname.setEditor(new CellEditor(b2cgnametext));
      columns.add(b2cgname);

      ModelType type = new ModelType();
      type.setRoot("records");
      type.setRecordName("record");

      type.addField("gcode");
      type.addField("gname");
      type.addField("b2cgcode");
      type.addField("price");
      type.addField("discountprice");
      type.addField("b2cgname");
      type.addField("mainimagepath");
      type.addField("treecode");
      type.addField("detailimage");

      StoreInfo info = new StoreInfo();

      info.setTablename("b2cgcode");
      info.setKeyname(new String[] {"b2cgcode"});
      info.setSql("select * from b2cgcode");
      BaseStore<JDBCModelData> store = new BaseStore<JDBCModelData>(type, info);

      ChartModel model =
          new ChartModel(
              "Team Sales by Month", "font-size: 14px; font-family: Verdana; text-align: center;");
      model.setBackgroundColour("#fefefe");
      model.setLegend(new Legend(Position.TOP, true));
      model.setScaleProvider(ScaleProvider.ROUNDED_NEAREST_SCALE_PROVIDER);

      BarChart bar = new BarChart(BarStyle.GLASS);
      bar.setColour("#00aa00");
      BarDataProvider barProvider = new BarDataProvider("price", "b2cgname");
      barProvider.bind(store);
      bar.setDataProvider(barProvider);
      //  bar.addChartListener(listener);
      model.addChartConfig(bar);

      bar = new BarChart(BarStyle.GLASS);
      bar.setColour("#ff6600");
      barProvider = new BarDataProvider("discountprice");
      barProvider.bind(store);
      bar.setDataProvider(barProvider);
      // bar.addChartListener(listener);
      model.addChartConfig(bar);

      LineChart line = new LineChart();
      line.setAnimateOnShow(true);
      line.setText("Average");
      line.setColour("#FF0000");
      LineDataProvider lineProvider = new LineDataProvider("discountprice");
      lineProvider.bind(store);
      line.setDataProvider(lineProvider);
      model.addChartConfig(line);

      /*	    PieChart pie = new PieChart();
      PieDataProvider piedataprovider = new PieDataProvider("discountprice");
      piedataprovider.bind(store);
      pie.setDataProvider(piedataprovider);
      model.addChartConfig(pie);*/

      String url = "chart/open-flash-chart.swf";
      final Chart chart = new Chart(url);
      chart.setChartModel(model);
      chart.setHeight("300px");
      ContentPanel cp = new ContentPanel();
      cp.setHeading("Chart");
      cp.add(chart);
      ColumnModel cm = new ColumnModel(columns);
      BaseGrid grid = new BaseGrid(store, cm);
      grid.setHeight("300px");
      cp.add(grid);
      armStatus = ArmWrapper.GOOD;
      return cp;
    } finally {
      ArmWrapper.stopTransaction(
          "com.base.myproject.client.busi.b2c.manager.ChartTest", "aa", armStatus);
    }
  }