Package com.suwish.pc.ui.component.list

Examples of com.suwish.pc.ui.component.list.FileListCellEntry


      @Override
      public void actionPerformed(ActionEvent e) {
//        if(!(e.getSource() instanceof JMenuItem)) return;
        String cmd = ((AbstractButton)e.getSource()).getActionCommand();
        if(StringUtils.isEmpty(cmd))return;
        FileListCellEntry cell = (FileListCellEntry)fileList.getSelectedValue();
        try{
          if(UIHelper.ACTION_FOLDER_OPEN.equals(cmd)){
            if(!cell.getFileEntry().isDirectory()) return;
            initData(cell.getFileEntry());
          }else if(UIHelper.ACTION_FILE_UPLOAD.equals(cmd)){
            UIHelper.uploadFile(device, root);
          }else if(UIHelper.ACTION_FILE_DOWNLOAD.equals(cmd)){
            if(cell.getFileEntry().isDirectory()) return;
            UIHelper.downloadFile(device, cell.getFileEntry());
          }
        }catch(Exception ex){
          ex.printStackTrace();
          UIHelper.showErrorDialog(getParent(), ex);
        }
      }
    };
    upLoadButton.addActionListener(actionListsner);
    downLoadButton.addActionListener(actionListsner);
    final JPopupMenu menu = new JPopupMenu();
    final JMenuItem openItem = new JMenuItem("Open", _Icon("fileopen_12x12.png"));
    menu.add(openItem);
    openItem.addActionListener(actionListsner);
    openItem.setActionCommand(UIHelper.ACTION_FOLDER_OPEN);
    menu.addSeparator();
    final JMenuItem upLoadItem = new JMenuItem("Upload", _Icon("upload_16x16.png"));
    menu.add(upLoadItem);
    upLoadItem.setActionCommand(UIHelper.ACTION_FILE_UPLOAD);
    upLoadItem.addActionListener(actionListsner);
    upLoadItem.setToolTipText("Upload file to current folder");
    final JMenuItem downLoadItem = new JMenuItem("Download", _Icon("download_16x16.png"));
    menu.add(downLoadItem);
    downLoadItem.setActionCommand(UIHelper.ACTION_FILE_DOWNLOAD);
    downLoadItem.addActionListener(actionListsner);
    fileList.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        if(e.getClickCount() == 2 && !e.isPopupTrigger()){
          FileListCellEntry cell = (FileListCellEntry)fileList.getSelectedValue();
          if(cell == null || !cell.getFileEntry().isDirectory()) return;
          initData(cell.getFileEntry());
        }
      }
      @Override
      public void mouseReleased(MouseEvent e) {
        if(!e.isPopupTrigger()) return;
        int index = fileList.locationToIndex(e.getPoint());
        if(index == -1) return;
        fileList.setSelectedIndex(index);
        FileListCellEntry cell = (FileListCellEntry)fileList.getSelectedValue();
        if(cell == null)return;
        boolean isDir = cell.getFileEntry().isDirectory();
        openItem.setEnabled(isDir);
        downLoadItem.setEnabled(!isDir);
        menu.show(fileList, e.getX(), e.getY());
      }
    });
View Full Code Here


      root = currentEntry;
      pathLabel.setText("<html><div style='margin-left: 12px;font: 12px;'>" + currentEntry.getFullPath() + "</div></html>");
      FileEntry[] entrys = DeviceUtils.getChildrenEntry(device, currentEntry);
      listModel.removeAllElements();
      for(FileEntry entry : entrys){
        listModel.addElement(new FileListCellEntry(entry));
      }
    }catch(Exception e){
      e.printStackTrace();
    }
  }
View Full Code Here

TOP

Related Classes of com.suwish.pc.ui.component.list.FileListCellEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.