コード例 #1
0
  public SelectWidgetVariableInterface(
      String activityPath,
      String xmlPath,
      String codingType,
      JRadioButton[] modifierRadioButton,
      JRadioButton[] isListenerRadioButton)
      throws Exception {
    this.activityPath = activityPath;
    this.xmlPath = xmlPath;
    this.codingType = codingType;
    this.modifierRadioButton = modifierRadioButton;
    this.isListenerRadioButton = isListenerRadioButton;

    setLayout(null);
    setVisible(true);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setSize(700, 600);
    CommonMethod.setLayoutCenter(this);
    // 固定窗体大小
    setResizable(false);
    // 设置Swing界面UI跟随系统变化
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    setTitle("选择XML控件");
    common = new CommonMethod(getContentPane());

    init();
  }
コード例 #2
0
  /**
   * 将数据写入到指定的文件中
   *
   * @param targetFilePath
   * @param methodName
   */
  public static void inputDataToTargetFile(
      String targetFilePath, String insertContent, String codingType) {
    if (targetFilePath.isEmpty() && insertContent.isEmpty() && codingType.isEmpty()) {
      System.out.println("目标文件,写入内容,编码类型不能为空!");
      return;
    }

    try {
      RandomAccessFile rf = CommonMethod.reSetUpFile(targetFilePath);
      rf.write(insertContent.getBytes(codingType));
      rf.close();
    } catch (IOException e) {
      System.err.println("写入" + insertContent + "异常!!!");
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
コード例 #3
0
  /** 生成树形结构 */
  public void generateTree(List<FileLayoutVariableModel> getTreeList) {
    JTree tree = new JTree();
    CheckBoxTreeNode rootNode = new CheckBoxTreeNode("全选");
    for (int i = 0; i < getTreeList.size(); i++) {
      File file = new File(getTreeList.get(i).getFileName());
      CheckBoxTreeNode subTree = new CheckBoxTreeNode(file.getName() + "   路径:" + file.getPath());
      List<VariableDataModel> subList = getTreeList.get(i).getVariableList();

      for (int j = 0; j < subList.size(); j++) {
        String temp = subList.get(j).getVariableType();
        int tempIndex = temp.lastIndexOf(".");
        if (tempIndex != -1) {
          temp = temp.substring(tempIndex + 1, temp.length());
        }
        CheckBoxTreeNode subTreeList =
            new CheckBoxTreeNode(
                "类型:" + temp + "              名称:" + subList.get(j).getVariableName());
        subTree.add(subTreeList);
      }
      rootNode.add(subTree);
    }
    DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
    tree.addMouseListener(new CheckBoxTreeNodeSelectionListener());
    tree.setModel(treeModel);
    // 展开一棵树
    CommonMethod.expandAll(tree, new TreePath(tree.getModel().getRoot()), true);
    // 用来绘制checkbox
    tree.setCellRenderer(new CheckBoxTreeCellRenderer());
    JScrollPane scroll = new JScrollPane(tree);
    scroll.setBounds(0, 0, 700, 500);
    add(scroll);

    JButton button = new JButton("确定");
    button.setBounds(10, 520, 150, 30);
    button.addActionListener(new ClickListener(treeModel));
    add(button);
  }
コード例 #4
0
 /**
  * @param copyFile
  * @param targetFile
  */
 public static void fileCopy(File copyFile, File targetFile) throws Exception {
   String result = CommonMethod.fileToString(copyFile.getPath(), "utf-8");
   RandomAccessFile rf = new RandomAccessFile(targetFile, "rw");
   rf.write(result.getBytes("utf-8"));
   rf.close();
 }