/** Adds the button row and the Spam Button */
  private void addButtonRow() {
    if (BUTTON_ROW != null) {
      SOUTH_PANEL = Box.createVerticalBox();
      SOUTH_PANEL.setOpaque(false);

      SOUTH_PANEL.add(Box.createVerticalStrut(GUIConstants.SEPARATOR));

      JPanel buttonPanel = new JPanel();
      buttonPanel.setLayout(new GridBagLayout());

      GridBagConstraints gbc = new GridBagConstraints();

      gbc.gridx = 1;
      gbc.gridy = 0;
      gbc.anchor = GridBagConstraints.CENTER;
      gbc.fill = GridBagConstraints.NONE;
      gbc.gridwidth = GridBagConstraints.RELATIVE;
      gbc.weightx = 1;

      buttonPanel.add(BUTTON_ROW, gbc);

      buttonPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 64));
      SOUTH_PANEL.add(buttonPanel);

      MAIN_PANEL.add(SOUTH_PANEL);
    }
  }
  /** Constructor */
  public MapListCellRenderer() {
    JPanel pFirst = new JPanel();
    pFirst.setOpaque(false);
    pFirst.setLayout(new BorderLayout(5, 0));
    pFirst.add(mapNameLabel, BorderLayout.CENTER);
    pFirst.add(playerCountLabel, BorderLayout.EAST);
    pFirst.setAlignmentX(Component.LEFT_ALIGNMENT);
    rightPanelPart.add(pFirst);
    rightPanelPart.add(mapIdLabel);
    mapIdLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    rightPanelPart.add(descriptionLabel);
    descriptionLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

    rightPanelPart.setOpaque(false);
    rightPanelPart.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    mapNameLabel.setFont(mapNameLabel.getFont().deriveFont(Font.BOLD));
    mapNameLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

    mapNameLabel.setForeground(FOREGROUND);
    mapIdLabel.setForeground(FOREGROUND);
    descriptionLabel.setForeground(FOREGROUND);
    playerCountLabel.setForeground(Color.BLUE);

    contentsPanel.setLayout(new BorderLayout());
    contentsPanel.add(rightPanelPart, BorderLayout.CENTER);
    contentsPanel.add(iconLabel, BorderLayout.WEST);
    contentsPanel.putClientProperty(ELFStyle.KEY, ELFStyle.PANEL_DRAW_BG_CUSTOM);

    iconLabel.setOpaque(false);
    iconLabel.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));

    // Update UI
    SwingUtilities.updateComponentTreeUI(contentsPanel);
  }
Exemplo n.º 3
0
  /** Creates the GUI. */
  protected void createGUI() {
    JButton throwaway = new JButton("by"); // $NON-NLS-1$
    throwaway.setBorder(LibraryBrowser.buttonBorder);
    int h = throwaway.getPreferredSize().height;
    sharedFont = throwaway.getFont();

    // create collections list
    ListModel collectionListModel =
        new AbstractListModel() {
          public int getSize() {
            return library.pathList.size();
          }

          public Object getElementAt(int i) {
            String path = library.pathList.get(i);
            return library.pathToNameMap.get(path);
          }
        };
    collectionList = new JList(collectionListModel);
    collectionList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            refreshGUI();
          }
        });
    collectionList.setFixedCellHeight(h);
    collectionList.setFont(sharedFont);
    collectionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // create import list
    ListModel importListModel =
        new AbstractListModel() {
          public int getSize() {
            return library.importedPathList.size();
          }

          public Object getElementAt(int i) {
            String path = library.importedPathList.get(i);
            return library.importedPathToLibraryMap.get(path).getName();
          }
        };
    guestList = new JList(importListModel);
    guestList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            refreshGUI();
          }
        });
    guestList.setFont(sharedFont);
    guestList.setFixedCellHeight(h);
    guestList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // create name action, field and label
    nameAction =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String path = pathField.getText();
            String prev = library.pathToNameMap.get(path);
            String input = nameField.getText().trim();
            if (input == null || input.equals("") || input.equals(prev)) { // $NON-NLS-1$
              return;
            }
            library.renameCollection(path, input);
            browser.refreshCollectionsMenu();
            collectionList.repaint();
            refreshGUI();
          }
        };
    nameField = new LibraryTreePanel.EntryField();
    nameField.addActionListener(nameAction);
    nameField.addFocusListener(
        new FocusAdapter() {
          public void focusGained(FocusEvent e) {
            nameField.selectAll();
          }

          public void focusLost(FocusEvent e) {
            nameAction.actionPerformed(null);
          }
        });
    nameField.setBackground(Color.white);

    nameLabel = new JLabel();
    nameLabel.setFont(sharedFont);
    nameLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 2));
    nameLabel.setHorizontalAlignment(SwingConstants.TRAILING);

    // create path action, field and label
    //		pathAction = new ActionListener() {
    //      public void actionPerformed(ActionEvent e) {
    //	    	int i = collectionList.getSelectedIndex();
    //      	String path = library.pathList.get(i);
    //  			String name = library.pathToNameMap.get(path);
    //      	String input = pathField.getText().trim();
    //        if(input==null || input.equals("") || input.equals(path)) { //$NON-NLS-1$
    //          return;
    //        }
    //        library.pathList.remove(i);
    //        library.pathList.add(i, input);
    //        library.pathToNameMap.remove(path);
    //        library.pathToNameMap.put(input, name);
    //
    //        browser.refreshCollectionsMenu();
    //  			collectionList.repaint();
    //  			refreshGUI();
    //     	}
    //    };
    pathField = new LibraryTreePanel.EntryField();
    pathField.setEditable(false);
    //  	pathField.addActionListener(pathAction);
    //  	pathField.addFocusListener(new FocusAdapter() {
    //      public void focusGained(FocusEvent e) {
    //      	pathField.selectAll();
    //      }
    //      public void focusLost(FocusEvent e) {
    //      	pathAction.actionPerformed(null);
    //      }
    //    });
    pathField.setBackground(Color.white);

    pathLabel = new JLabel();
    pathLabel.setFont(sharedFont);
    pathLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 2));
    pathLabel.setHorizontalAlignment(SwingConstants.TRAILING);

    // create buttons
    okButton = new JButton();
    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setVisible(false);
          }
        });

    moveUpButton = new JButton();
    moveUpButton.setOpaque(false);
    moveUpButton.setBorder(LibraryBrowser.buttonBorder);
    moveUpButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            boolean isImports = tabbedPane.getSelectedComponent() == importsPanel;
            JList list = isImports ? guestList : collectionList;
            ArrayList<String> paths = isImports ? library.importedPathList : library.pathList;
            int i = list.getSelectedIndex();
            String path = paths.get(i);
            paths.remove(path);
            paths.add(i - 1, path);
            list.setSelectedIndex(i - 1);
            browser.refreshCollectionsMenu();
            browser.refreshGUI();
          }
        });
    moveDownButton = new JButton();
    moveDownButton.setOpaque(false);
    moveDownButton.setBorder(LibraryBrowser.buttonBorder);
    moveDownButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            boolean isImports = tabbedPane.getSelectedComponent() == importsPanel;
            JList list = isImports ? guestList : collectionList;
            ArrayList<String> paths = isImports ? library.importedPathList : library.pathList;
            int i = list.getSelectedIndex();
            String path = paths.get(i);
            paths.remove(path);
            paths.add(i + 1, path);
            list.setSelectedIndex(i + 1);
            browser.refreshCollectionsMenu();
            browser.refreshGUI();
          }
        });
    addButton = new JButton();
    addButton.setOpaque(false);
    addButton.setBorder(LibraryBrowser.buttonBorder);
    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            boolean imported = tabbedPane.getSelectedComponent() == importsPanel;
            String message =
                imported
                    ? ToolsRes.getString("LibraryBrowser.Dialog.AddLibrary.Message")
                    : //$NON-NLS-1$
                    ToolsRes.getString(
                        "LibraryBrowser.Dialog.AddCollection.Message"); //$NON-NLS-1$
            String title =
                imported
                    ? ToolsRes.getString("LibraryBrowser.Dialog.AddLibrary.Title")
                    : //$NON-NLS-1$
                    ToolsRes.getString("LibraryBrowser.Dialog.AddCollection.Title"); // $NON-NLS-1$

            Object input =
                JOptionPane.showInputDialog(
                    browser, message, title, JOptionPane.QUESTION_MESSAGE, null, null, null);

            if (input == null || input.equals("")) { // $NON-NLS-1$
              return;
            }
            String path = input.toString();
            path = XML.forwardSlash(path);
            path = ResourceLoader.getNonURIPath(path);

            if (tabbedPane.getSelectedComponent() == collectionsPanel) {
              boolean isResource = false;
              if (!path.startsWith("http") && new File(path).isDirectory()) { // $NON-NLS-1$
                isResource = true;
              } else {
                XMLControl control = new XMLControlElement(path);
                if (!control.failedToRead()
                    && control.getObjectClass() == LibraryCollection.class) {
                  isResource = true;
                }
              }
              if (isResource) {
                browser.addToCollections(path);
                ListModel model = collectionList.getModel();
                collectionList.setModel(model);
                refreshGUI();
                collectionList.repaint();
                collectionList.setSelectedIndex(library.pathList.size() - 1);
                browser.refreshCollectionsMenu();
                return;
              }
            }
            if (tabbedPane.getSelectedComponent() == importsPanel) {
              boolean isLibrary = false;
              XMLControl control = new XMLControlElement(path);
              if (!control.failedToRead() && control.getObjectClass() == Library.class) {
                isLibrary = true;
              }
              if (isLibrary) {
                Library newLibrary = new Library();
                newLibrary.browser = LibraryManager.this.browser;
                control.loadObject(newLibrary);
                if (library.importLibrary(path, newLibrary)) {
                  ListModel model = guestList.getModel();
                  guestList.setModel(model);
                  refreshGUI();
                  guestList.repaint();
                  guestList.setSelectedIndex(library.importedPathList.size() - 1);
                  browser.refreshCollectionsMenu();
                }
                return;
              }
            }

            String s =
                ToolsRes.getString(
                    "LibraryBrowser.Dialog.CollectionNotFound.Message"); //$NON-NLS-1$
            JOptionPane.showMessageDialog(
                LibraryManager.this,
                s + ":\n" + path, // $NON-NLS-1$
                ToolsRes.getString("LibraryBrowser.Dialog.CollectionNotFound.Title"), // $NON-NLS-1$
                JOptionPane.WARNING_MESSAGE);
          }
        });
    removeButton = new JButton();
    removeButton.setOpaque(false);
    removeButton.setBorder(LibraryBrowser.buttonBorder);
    removeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            boolean isImports = tabbedPane.getSelectedComponent() == importsPanel;
            JList list = isImports ? guestList : collectionList;
            ArrayList<String> paths = isImports ? library.importedPathList : library.pathList;
            int i = list.getSelectedIndex();
            String path = paths.get(i);
            paths.remove(path);
            if (isImports) library.importedPathToLibraryMap.remove(path);
            else library.pathToNameMap.remove(path);
            list.repaint();
            if (i >= paths.size()) {
              list.setSelectedIndex(paths.size() - 1);
            }
            browser.refreshCollectionsMenu();
            refreshGUI();
            browser.refreshGUI();
          }
        });
    // create all and none buttons
    allButton = new JButton();
    allButton.setOpaque(false);
    allButton.setBorder(LibraryBrowser.buttonBorder);
    allButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            for (SearchCheckBox next : checkboxes) {
              next.setSelected(true);
            }
          }
        });
    noneButton = new JButton();
    noneButton.setOpaque(false);
    noneButton.setBorder(LibraryBrowser.buttonBorder);
    noneButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            for (SearchCheckBox next : checkboxes) {
              next.setSelected(false);
            }
          }
        });

    clearCacheButton = new JButton();
    clearCacheButton.setOpaque(false);
    clearCacheButton.setBorder(LibraryBrowser.buttonBorder);
    clearCacheButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            File cache = ResourceLoader.getOSPCache();
            ResourceLoader.clearOSPCache(cache, false);
            refreshCacheTab();
            tabbedPane.repaint();
          }
        });

    setCacheButton = new JButton();
    setCacheButton.setOpaque(false);
    setCacheButton.setBorder(LibraryBrowser.buttonBorder);
    setCacheButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            File newCache = ResourceLoader.chooseOSPCache(browser);
            ResourceLoader.setOSPCache(newCache);
            refreshCacheTab();
          }
        });
    Border emptyInside = BorderFactory.createEmptyBorder(1, 2, 1, 2);
    Border etched = BorderFactory.createEtchedBorder();
    Border buttonbarBorder = BorderFactory.createCompoundBorder(etched, emptyInside);

    libraryButtonbar = new JToolBar();
    libraryButtonbar.setFloatable(false);
    libraryButtonbar.setBorder(buttonbarBorder);
    libraryButtonbar.add(moveUpButton);
    libraryButtonbar.add(moveDownButton);
    libraryButtonbar.add(addButton);
    libraryButtonbar.add(removeButton);

    nameBox = Box.createHorizontalBox();
    nameBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 4));
    nameBox.add(nameLabel);
    nameBox.add(nameField);
    pathBox = Box.createHorizontalBox();
    pathBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 4));
    pathBox.add(pathLabel);
    pathBox.add(pathField);
    libraryEditBox = Box.createVerticalBox();
    libraryEditBox.add(nameBox);
    libraryEditBox.add(pathBox);

    // create and assemble tabs
    // collections tab
    collectionsPanel = new JPanel(new BorderLayout());
    JScrollPane scroller = new JScrollPane(collectionList);
    scroller.setViewportBorder(etched);
    scroller.getVerticalScrollBar().setUnitIncrement(8);
    collectionsTitleBorder = BorderFactory.createTitledBorder(""); // $NON-NLS-1$
    scroller.setBorder(collectionsTitleBorder);
    collectionsPanel.add(scroller, BorderLayout.CENTER);
    collectionsPanel.add(libraryEditBox, BorderLayout.SOUTH);
    collectionsPanel.add(libraryButtonbar, BorderLayout.NORTH);

    // imports tab
    importsPanel = new JPanel(new BorderLayout());
    scroller = new JScrollPane(guestList);
    scroller.setViewportBorder(etched);
    scroller.getVerticalScrollBar().setUnitIncrement(8);
    importsTitleBorder = BorderFactory.createTitledBorder(""); // $NON-NLS-1$
    scroller.setBorder(importsTitleBorder);
    importsPanel.add(scroller, BorderLayout.CENTER);

    // search tab
    searchPanel = new JPanel(new BorderLayout());
    searchBox = Box.createVerticalBox();
    searchBox.setBackground(Color.white);
    searchBox.setOpaque(true);
    refreshSearchTab();

    scroller = new JScrollPane(searchBox);
    scroller.setViewportBorder(etched);
    scroller.getVerticalScrollBar().setUnitIncrement(8);
    searchTitleBorder = BorderFactory.createTitledBorder(""); // $NON-NLS-1$
    scroller.setBorder(searchTitleBorder);
    searchPanel.add(scroller, BorderLayout.CENTER);
    JToolBar searchButtonbar = new JToolBar();
    searchButtonbar.setFloatable(false);
    searchButtonbar.setBorder(buttonbarBorder);
    searchButtonbar.add(allButton);
    searchButtonbar.add(noneButton);
    searchPanel.add(searchButtonbar, BorderLayout.NORTH);

    // cache tab
    cachePanel = new JPanel(new BorderLayout());
    cacheBox = Box.createVerticalBox();
    cacheBox.setBackground(Color.white);
    cacheBox.setOpaque(true);
    refreshCacheTab();

    scroller = new JScrollPane(cacheBox);
    scroller.setViewportBorder(etched);
    scroller.getVerticalScrollBar().setUnitIncrement(8);
    cacheTitleBorder = BorderFactory.createTitledBorder(""); // $NON-NLS-1$
    scroller.setBorder(cacheTitleBorder);
    cachePanel.add(scroller, BorderLayout.CENTER);
    JToolBar cacheButtonbar = new JToolBar();
    cacheButtonbar.setFloatable(false);
    cacheButtonbar.setBorder(buttonbarBorder);
    cacheButtonbar.add(clearCacheButton);
    cacheButtonbar.add(setCacheButton);
    cachePanel.add(cacheButtonbar, BorderLayout.NORTH);

    // create tabbedPane
    tabbedPane = new JTabbedPane();
    tabbedPane.addTab("", collectionsPanel); // $NON-NLS-1$
    //		tabbedPane.addTab("", importsPanel); //$NON-NLS-1$
    tabbedPane.addTab("", searchPanel); // $NON-NLS-1$
    tabbedPane.addTab("", cachePanel); // $NON-NLS-1$

    // add change listener last
    tabbedPane.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (tabbedPane.getSelectedComponent() == collectionsPanel) {
              collectionsPanel.add(libraryButtonbar, BorderLayout.NORTH);
              collectionsPanel.add(libraryEditBox, BorderLayout.SOUTH);
              refreshGUI();
            } else if (tabbedPane.getSelectedComponent() == importsPanel) {
              importsPanel.add(libraryButtonbar, BorderLayout.NORTH);
              importsPanel.add(libraryEditBox, BorderLayout.SOUTH);
              refreshGUI();
            }
          }
        });

    Border space = BorderFactory.createEmptyBorder(0, 2, 0, 2);
    listButtonBorder = BorderFactory.createCompoundBorder(etched, space);

    // assemble content pane
    JPanel contentPane = new JPanel(new BorderLayout());
    setContentPane(contentPane);
    contentPane.add(tabbedPane, BorderLayout.CENTER);
    JPanel south = new JPanel();
    south.add(okButton);
    contentPane.add(south, BorderLayout.SOUTH);
  }
Exemplo n.º 4
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);
  }
Exemplo n.º 5
0
  void createGUI() {
    // create username field info
    Box fields = Box.createVerticalBox();
    fields.add(Box.createVerticalStrut(10));
    fields.setOpaque(false);

    JPanel userNameCont = new JPanel(new GridLayout(1, 2));
    JLabel usernameLabel = new JLabel("username ");
    usernameLabel.setFont(UIHelper.VER_12_BOLD);
    usernameLabel.setForeground(UIHelper.DARK_GREEN_COLOR);
    userNameCont.add(usernameLabel);

    username = new RoundedJTextField(10, UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR);
    username.setOpaque(false);

    UIHelper.renderComponent(username, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);

    userNameCont.add(username);
    userNameCont.setOpaque(false);

    JPanel passwordCont = new JPanel(new GridLayout(1, 2));
    JLabel passwordLabel = new JLabel("password ");
    passwordLabel.setFont(UIHelper.VER_12_BOLD);
    passwordLabel.setForeground(UIHelper.DARK_GREEN_COLOR);
    passwordCont.add(passwordLabel);
    password = new RoundedJPasswordField(10, UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR);
    UIHelper.renderComponent(password, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);

    passwordCont.add(password);
    passwordCont.setOpaque(false);

    fields.add(userNameCont);
    fields.add(Box.createVerticalStrut(10));
    fields.add(passwordCont);

    JPanel northPanel = new JPanel();
    northPanel.add(new JLabel(pleaseLogin, JLabel.RIGHT), BorderLayout.NORTH);
    northPanel.add(fields, BorderLayout.CENTER);

    JPanel southPanel = new JPanel(new GridLayout(4, 1));
    southPanel.setOpaque(false);

    JPanel buttonContainer = new JPanel(new GridLayout(1, 2));
    buttonContainer.setOpaque(false);

    createProfile = new JLabel(createProfileButton, JLabel.LEFT);
    createProfile.addMouseListener(
        new MouseAdapter() {

          public void mousePressed(MouseEvent event) {
            createProfile.setIcon(createProfileButton);

            clearFields();

            confirmExitPanel.setVisible(false);

            menu.changeView(menu.getCreateProfileGUI());
          }

          public void mouseEntered(MouseEvent event) {
            createProfile.setIcon(createProfileButtonOver);
          }

          public void mouseExited(MouseEvent event) {
            createProfile.setIcon(createProfileButton);
          }
        });

    buttonContainer.add(createProfile);

    login = new JLabel(loginButton, JLabel.RIGHT);
    login.addMouseListener(
        new MouseAdapter() {

          public void mousePressed(MouseEvent event) {
            login.setIcon(Authentication.this.loginButton);
            confirmExitPanel.setVisible(false);
            login();
          }

          public void mouseEntered(MouseEvent event) {
            login.setIcon(loginButtonOver);
          }

          public void mouseExited(MouseEvent event) {
            login.setIcon(Authentication.this.loginButton);
          }
        });

    Action loginAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            login();
          }
        };

    password.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "LOGIN");
    password.getActionMap().put("LOGIN", loginAction);
    username.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "LOGIN");
    username.getActionMap().put("LOGIN", loginAction);

    buttonContainer.add(login);

    southPanel.add(status);
    southPanel.add(buttonContainer);

    exit = new JLabel(exitButtonSml, JLabel.CENTER);
    exit.addMouseListener(
        new MouseAdapter() {

          public void mousePressed(MouseEvent event) {
            exit.setIcon(exitButtonSml);
            confirmExitPanel.setVisible(true);
            confirmExitPanel.getParent().validate();
          }

          public void mouseEntered(MouseEvent event) {
            exit.setIcon(exitButtonSmlOver);
          }

          public void mouseExited(MouseEvent event) {
            exit.setIcon(exitButtonSml);
          }
        });

    JPanel exitCont = new JPanel(new GridLayout(1, 1));
    exitCont.setOpaque(false);

    exitCont.add(exit);

    southPanel.add(exitCont);

    southPanel.add(confirmExitPanel);

    northPanel.add(southPanel, BorderLayout.SOUTH);
    northPanel.setOpaque(false);

    add(northPanel, BorderLayout.CENTER);
  }
Exemplo n.º 6
0
    public DocumentPanel() {
      super(new BorderLayout());

      JLabel lblDocument = new JLabel("Document: " + document.getTitle());
      lblDocument.setBorder(new EtchedBorder());

      textPane = new JTextPane(document);
      textPane.setEditable(false);
      textPane.setMargin(new Insets(5, 20, 5, 5));
      textPane.setMaximumSize(new Dimension(364, 1000000000));
      textPane.setPreferredSize(new Dimension(364, 400));
      textPane.setMinimumSize(new Dimension(364, 10));
      textPane.addCaretListener(
          new CaretListener() {
            public void caretUpdate(CaretEvent e) {
              int length = document.getLength();
              int offset = e.getDot();

              if (e.getDot() == e.getMark()) textPane.getCaret().moveDot(offset + 1);

              Paragraph p = lockManager.getParFromOffset(offset);
              int pOffset = p.getOffset();

              lblCursor.setText(
                  "Document Length="
                      + String.valueOf(length)
                      + ", CaretOffset="
                      + String.valueOf(offset)
                      + ", Paragraph="
                      + p.toString()
                      + ", Offset in Paragraph="
                      + String.valueOf(offset - p.getOffset()));
            }
          });
      Box box = new Box(BoxLayout.X_AXIS);
      box.add(textPane);
      box.add(Box.createGlue());
      box.setBackground(Color.WHITE);
      box.setOpaque(true);
      box.setPreferredSize(new Dimension(600, 10000));

      lblCursor = new JLabel("Cursor");
      lblCursor.setBorder(new EtchedBorder());

      JPanel boxText = new JPanel(new BorderLayout());
      boxText.setBorder(new EmptyBorder(5, 5, 5, 5));
      boxText.add(lblDocument, BorderLayout.NORTH);
      boxText.add(new JScrollPane(box), BorderLayout.CENTER);
      boxText.add(lblCursor, BorderLayout.SOUTH);

      JLabel lblPars = new JLabel("Paragraphs: ");
      lblPars.setBorder(new EtchedBorder());

      parList = new JList();
      parList.setPreferredSize(new Dimension(100, 300));
      parList.setEnabled(false);

      JPanel boxPars = new JPanel(new BorderLayout());
      boxPars.setBorder(new EmptyBorder(5, 5, 5, 5));
      boxPars.add(lblPars, BorderLayout.NORTH);
      boxPars.add(new JScrollPane(parList), BorderLayout.CENTER);

      add(boxText, BorderLayout.CENTER);
      add(boxPars, BorderLayout.EAST);
    }