예제 #1
0
  private void jbInit() {

    this.setTitle(fileInfo.getName() + " Info");
    treeDetailInfo.setUI(new AnimatedTreeUI());
    // treeDetailInfo.setBackground(this.getBackground());
    treeDetailInfo.setOpaque(false);
    treeDetailInfo.setCellRenderer(new FileInfoTreeCellRenderer());
    treeDetailInfo.setShowsRootHandles(true);
    treeDetailInfo.setEditable(false);

    // Create the top title label that serves as teh root node
    // that will never change.
    lblTitle.setIcon(getFileItemIcon());
    lblTitle.setText(getTitleHTML());
    // Create the expanding General Info field
    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    treeDetailInfo.setModel(new DefaultTreeModel(root));
    treeDetailInfo.setRootVisible(false);

    generalMenuTreeNode = new DefaultMutableTreeNode("General:");
    // "<html><body><p>General:</p></body></html>");
    root.add(generalMenuTreeNode);

    DefaultMutableTreeNode nKind =
        new DefaultMutableTreeNode(new String[] {"Kind", DetailListModel.getTypeName(fileInfo)});
    nKind.setAllowsChildren(false);
    generalMenuTreeNode.add(nKind);

    DefaultMutableTreeNode nSize =
        new DefaultMutableTreeNode(new String[] {"Size", DetailListModel.getSize(fileInfo)});
    nSize.setAllowsChildren(false);
    generalMenuTreeNode.add(nSize);

    DefaultMutableTreeNode nWhere =
        new DefaultMutableTreeNode(new String[] {"Where", getAddress()});
    nWhere.setAllowsChildren(false);
    generalMenuTreeNode.add(nWhere);

    DefaultMutableTreeNode nCreated =
        new DefaultMutableTreeNode(new String[] {"Created", getCreated()});
    nCreated.setAllowsChildren(false);
    generalMenuTreeNode.add(nCreated);

    DefaultMutableTreeNode nModified =
        new DefaultMutableTreeNode(new String[] {"Modified", getCreated()});
    nModified.setAllowsChildren(false);
    generalMenuTreeNode.add(nModified);

    // Create the expandable access panel
    accessMenuTreeNode = new DefaultMutableTreeNode("<html><body><p>Access:</p></body></html>");
    root.add(accessMenuTreeNode);

    DefaultMutableTreeNode nAccess =
        new DefaultMutableTreeNode(
            new String[] {"Type", FTPType.FTP_PROTOCOL[this.tBrowse.ftpServer.type]});
    nAccess.setAllowsChildren(false);
    accessMenuTreeNode.add(nAccess);

    DefaultMutableTreeNode nServer =
        new DefaultMutableTreeNode(new String[] {"System", this.tBrowse.ftpServer.name});
    nServer.setAllowsChildren(false);
    accessMenuTreeNode.add(nServer);

    // Create the expandable permissions panel
    permissionMenuTreeNode =
        new DefaultMutableTreeNode("<html><body><p>Ownership & Permissions:</p></body></html>");
    permissionMenuTreeNode.setAllowsChildren(true);
    root.add(permissionMenuTreeNode);

    DefaultMutableTreeNode youNode =
        new DefaultMutableTreeNode(
            new String[] {
              "You can",
              getPermission(
                  fileInfo.userCanRead(), fileInfo.userCanWrite(), fileInfo.userCanExecute())
            });

    youNode.setAllowsChildren(false);
    permissionMenuTreeNode.add(youNode);

    pnlPermissions = PermissionPanelFactory.getPermissionsPanel(tBrowse, path, fileInfo);
    pnlPermissions.setVisible(isPermissionNodeExpanded);

    // expand the General info node by default
    treeDetailInfo.addTreeExpansionListener(new FileInfoTreeExpansionListener(this));
    // treeDetailInfo.setBackground(this.getBackground());

    if (isGeneralNodeExpanded)
      treeDetailInfo.expandPath(new TreePath(generalMenuTreeNode.getPath()));
    if (isAccessNodeExpanded) treeDetailInfo.expandPath(new TreePath(accessMenuTreeNode.getPath()));
    if (isPermissionNodeExpanded)
      treeDetailInfo.expandPath(new TreePath(permissionMenuTreeNode.getPath()));

    JPanel treePanel = new JPanel();
    // treePanel.setLayout(new BoxLayout(treePanel,BoxLayout.LINE_AXIS));
    treePanel.add(treeDetailInfo);
    treePanel.setOpaque(false);
    treeDetailInfo.setAlignmentX(LEFT_ALIGNMENT);

    Box pemBox = Box.createHorizontalBox();
    pemBox.add(pnlPermissions);
    pemBox.add(Box.createHorizontalGlue());
    pnlPermissions.setAlignmentX(Component.LEFT_ALIGNMENT);

    Box scrollBox = Box.createVerticalBox();
    scrollBox.add(treePanel);
    scrollBox.add(pemBox);
    scrollBox.add(Box.createGlue());
    scrollBox.setBorder(BorderFactory.createLineBorder(Color.GRAY));

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.getViewport().add(scrollBox);
    scrollPane.getViewport().setBackground(this.getBackground());
    scrollPane.getViewport().setOpaque(true);
    scrollPane.setWheelScrollingEnabled(true);
    IAppWidgetFactory.makeIAppScrollPane(scrollPane);
    scrollPane.setAutoscrolls(true);

    pnlMain.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    pnlMain.setLayout(new BoxLayout(pnlMain, BoxLayout.Y_AXIS));
    pnlMain.add(lblTitle, Component.TOP_ALIGNMENT);
    pnlMain.add(scrollPane, Component.CENTER_ALIGNMENT);
    pnlMain.add(Box.createGlue());
    lblTitle.setAlignmentX(JPanel.TOP_ALIGNMENT);
    scrollPane.setAlignmentX(JPanel.CENTER_ALIGNMENT);
    scrollPane.setPreferredSize(new Dimension(280, 450));
    scrollPane.setBackground(Color.GRAY);

    // pnlMain.setMinimumSize(new Dimension(280, 480));
    pnlMain.setPreferredSize(new Dimension(280, 480));
    pnlMain.setBackground(Color.BLACK);

    getContentPane().add(pnlMain); // , JDialog.LEFT_ALIGNMENT);
  }
예제 #2
0
  private void slInit() {
    this.setTitle(fileInfo.getName() + " Info");
    // Create the top title label that serves as teh root node
    // that will never change.
    lblTitle.setIcon(getFileItemIcon());
    lblTitle.setText(getTitleHTML());
    lblTitle.setBorder(BorderFactory.createEmptyBorder(10, 5, 2, 5));

    String[][] generalTableRows =
        new String[][] {
          {"General:", ""},
          {"Kind: ", DetailListModel.getTypeName(fileInfo)},
          {"Size: ", DetailListModel.getSize(fileInfo)},
          {"Where: ", getAddress()},
          {"Created: ", getCreated()},
          {"Modified: ", getCreated()}
        };
    ttGeneral = new JXTreeTable(new FileInfoTreeTableModel(generalTableRows));
    //		ttGeneral.addTreeExpansionListener(new FileInfoTreeExpansionListener(
    //				this));
    ttGeneral.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.GRAY));
    ttGeneral.setTableHeader(null);
    ttGeneral.setRootVisible(true);
    ttGeneral.setEditable(false);
    ttGeneral.setColumnSelectionAllowed(false);
    ttGeneral.setCellSelectionEnabled(false);
    ttGeneral.setBackground(this.getBackground());
    ttGeneral.setSelectionBackground(this.getBackground());
    ttGeneral.setSelectionForeground(this.getForeground());

    ttGeneral.setTreeCellRenderer(new FileInfoTreeRenderer());
    ttGeneral.getColumn(0).setCellRenderer(new FileInfoTableCellRenderer());
    ttGeneral.getColumn(1).setCellRenderer(new FileInfoTableCellRenderer());
    //		ttGeneral.setDefaultRenderer(Object.class, new FileInfoTableCellRenderer());
    ttGeneral.setLeafIcon(null);
    ttGeneral.setOpaque(false);
    ttGeneral.setEditable(false);
    ttGeneral.setSelectionBackground(this.getBackground());
    TableColumn col = ttGeneral.getColumn(0);
    col.setMinWidth(100);
    col.setMaxWidth(100);

    String[][] accessTableRows =
        new String[][] {
          {"Access:", ""},
          {"Type:", FTPType.FTP_PROTOCOL[this.tBrowse.ftpServer.type]},
          //				{"Type: ",DetailListModel.getTypeName(fileInfo)},
          {"System: ", this.tBrowse.ftpServer.name}
        };
    ttAccess = new JXTreeTable(new FileInfoTreeTableModel(accessTableRows));
    //		ttAccess.addTreeExpansionListener(new FileInfoTreeExpansionListener(
    //				this));
    ttAccess.setRowSelectionAllowed(false);
    ttAccess.setEditable(false);
    ttAccess.setColumnSelectionAllowed(false);
    ttAccess.setCellSelectionEnabled(false);
    ttAccess.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.GRAY));
    ttAccess.setBackground(this.getBackground());
    ttAccess.setTableHeader(null);
    ttAccess.setRootVisible(true);
    ttAccess.setTreeCellRenderer(new FileInfoTreeRenderer());
    ttAccess.getColumn(0).setCellRenderer(new FileInfoTableCellRenderer());
    ttAccess.getColumn(1).setCellRenderer(new FileInfoTableCellRenderer());
    //		ttAccess.setDefaultRenderer(Object.class, new FileInfoTableCellRenderer());
    ttAccess.setLeafIcon(null);
    ttAccess.setOpaque(false);
    ttAccess.setEditable(false);
    ttAccess.setSelectionBackground(this.getBackground());
    col = ttAccess.getColumn(0);
    col.setMinWidth(100);
    col.setMaxWidth(100);
    // Version info for TGShare files -- uncomment to add back support
    //		if (tBrowse.ftpServer.type == FTPType.TGSHARE) {
    //			Version version;
    //			String[][] versionTableRows;
    //			try {
    //				if (((TGShareFileInfo)fileInfo).isVersioned()) {
    //					version = tBrowse.ftpSrvConn.getCurrentVersion(path + "/" + fileInfo.getName());
    //					versionTableRows = new String[][]{
    //							{"Version:",""},
    //							{"Label: ",version.getVersionLabel()},
    //							{"Date: ",formatDate(version.getCreatedDate())},
    //							{"Creator: ",version.getCreator()},
    //							{"Comments: ",null}
    //					};
    //					txtVersion = new JTextArea((String)version.getVersionProperty(Version.PROP_DESCRIPTION));
    ////					txtVersion.setAlignmentX(LEFT_ALIGNMENT);
    //				} else {
    //					versionTableRows = new String[][]{
    //							{"Version:",""},
    //							{"No version info",null}
    //					};
    //					txtVersion = new JTextArea();
    //				}
    //			} catch (ServerException e) {
    //				versionTableRows = new String[][]{
    //						{"Version:",""},
    //						{"No version info",null}
    //				};
    //				txtVersion = new JTextArea();
    //			}
    //
    //			ttVersion = new JXTreeTable(new FileInfoTreeTableModel(versionTableRows));
    //			ttVersion.addTreeExpansionListener(new FileInfoTreeExpansionListener(
    //					this));
    //			ttVersion.setRowSelectionAllowed(false);
    //			ttVersion.setEditable(false);
    //			ttVersion.setColumnSelectionAllowed(false);
    //			ttVersion.setCellSelectionEnabled(false);
    //			ttVersion.setBorder(BorderFactory.createMatteBorder(1,0,0,0,Color.GRAY));
    //			ttVersion.setBackground(this.getBackground());
    //			ttVersion.setTableHeader(null);
    //			ttVersion.setRootVisible(true);
    //			ttVersion.setTreeCellRenderer(new FileInfoTreeRenderer());
    //			ttVersion.getColumn(0).setCellRenderer(new FileInfoTableCellRenderer());
    //			ttVersion.getColumn(1).setCellRenderer(new FileInfoTableCellRenderer());
    //	//		ttAccess.setDefaultRenderer(Object.class, new FileInfoTableCellRenderer());
    //			ttVersion.setLeafIcon(null);
    //			ttVersion.setOpaque(false);
    //			ttVersion.setEditable(false);
    //			ttVersion.setSelectionBackground(this.getBackground());
    //			col = ttVersion.getColumn(0);
    //			col.setMinWidth(150);
    //			col.setMaxWidth(170);
    //
    //			txtVersion.setBackground(Color.WHITE);
    //			txtVersion.setFont(MacFontUtils.SOURCE_LIST_ITEM_FONT);
    //			txtVersion.setLineWrap(true);
    //			txtVersion.setWrapStyleWord(true);
    //			txtVersion.addFocusListener(new VersionCommentFocusListener(this));
    //
    //			spVersion = new JScrollPane(txtVersion);
    //			spVersion.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    //			spVersion.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    //			spVersion.setWheelScrollingEnabled(true);
    //			spVersion.setPreferredSize(new Dimension(225,75));
    //			spVersion.setMaximumSize(new Dimension(280,100));
    //			spVersion.setVisible(isVersionNodeExpanded);
    //			IAppWidgetFactory.makeIAppScrollPane(spVersion);
    //
    //		}

    String[][] permissionTableRows =
        new String[][] {
          {"Permissions:", ""},
          {
            "You can: ",
            getPermission(
                fileInfo.userCanRead(), fileInfo.userCanWrite(), fileInfo.userCanExecute())
          }
        };
    ttPermissions = new JXTreeTable(new FileInfoTreeTableModel(permissionTableRows));
    ttPermissions.addTreeExpansionListener(new FileInfoTreeExpansionListener(this));
    ttPermissions.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.GRAY));
    ttPermissions.setTableHeader(null);
    ttPermissions.setRootVisible(true);
    ttPermissions.setEditable(false);
    ttPermissions.setColumnSelectionAllowed(false);
    ttPermissions.setCellSelectionEnabled(false);
    ttPermissions.setBackground(this.getBackground());
    ttPermissions.setTreeCellRenderer(new FileInfoTreeRenderer());
    ttGeneral.getColumn(0).setCellRenderer(new FileInfoTableCellRenderer());
    ttPermissions.getColumn(1).setCellRenderer(new FileInfoTableCellRenderer());
    //		ttPermissions.setLeafIcon(null);
    ttPermissions.setOpaque(false);
    ttPermissions.setSelectionBackground(this.getBackground());
    col = ttPermissions.getColumn(0);
    col.setMinWidth(100);
    col.setMaxWidth(120);

    pnlPermissions = PermissionPanelFactory.getPermissionsPanel(tBrowse, path, fileInfo);
    pnlPermissions.setVisible(isPermissionNodeExpanded);

    JPanel treePanel = new JPanel();
    treePanel.setLayout(new BoxLayout(treePanel, BoxLayout.Y_AXIS));
    treePanel.add(ttGeneral);
    treePanel.add(ttAccess);
    if (tBrowse.ftpServer.type == FTPType.XSHARE) {
      //			Box bVersion = Box.createHorizontalBox();
      //			bVersion.add(spVersion);
      //			bVersion.add(Box.createHorizontalGlue());
      //			bVersion.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
      //			treePanel.add(ttVersion);
      ////			treePanel.add(new JLabel("test label"));
      //			treePanel.add(bVersion);
    }
    treePanel.add(ttPermissions);
    treePanel.setOpaque(true);
    treePanel.setBackground(this.getBackground());

    treeDetailInfo.setAlignmentX(LEFT_ALIGNMENT);

    pemBox = Box.createHorizontalBox();
    pemBox.add(pnlPermissions);
    pemBox.add(Box.createHorizontalGlue());
    pnlPermissions.setAlignmentX(Component.LEFT_ALIGNMENT);

    Box scrollBox = Box.createVerticalBox();
    scrollBox.add(treePanel);
    scrollBox.add(pemBox);
    scrollBox.add(Box.createGlue());
    scrollBox.setOpaque(true);
    scrollBox.setBackground(this.getBackground());

    if (isGeneralNodeExpanded) ttGeneral.expandAll();
    if (isAccessNodeExpanded) ttAccess.expandAll();
    if (isVersionNodeExpanded && (tBrowse.ftpServer.type == FTPType.XSHARE))
      //			ttVersion.expandAll();
      if (isPermissionNodeExpanded) ttPermissions.expandAll();

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.getViewport().add(scrollBox);
    scrollPane.setWheelScrollingEnabled(true);
    IAppWidgetFactory.makeIAppScrollPane(scrollPane);
    scrollPane.setAutoscrolls(true);

    pnlMain.setLayout(new BoxLayout(pnlMain, BoxLayout.Y_AXIS));
    pnlMain.add(lblTitle, Component.TOP_ALIGNMENT);
    pnlMain.add(scrollPane, Component.CENTER_ALIGNMENT);
    pnlMain.add(Box.createGlue());
    lblTitle.setAlignmentX(JPanel.TOP_ALIGNMENT);
    scrollPane.setAlignmentX(JPanel.CENTER_ALIGNMENT);
    scrollPane.setPreferredSize(new Dimension(280, 600));

    // pnlMain.setMinimumSize(new Dimension(280, 480));
    pnlMain.setPreferredSize(new Dimension(280, 620));
    pnlMain.setOpaque(true);

    getContentPane().add(pnlMain); // , JDialog.LEFT_ALIGNMENT);
  }