Logo Search packages:      
Sourcecode: jets3t version File versions  Download package

void org::jets3t::apps::cockpitlite::CockpitLite::initGui (  )  [inline, private]

Initialises the application's GUI elements.

Definition at line 423 of file CockpitLite.java.

References actionPerformed(), org::jets3t::gui::GuiUtils::applyIcon(), org::jets3t::gui::UserInputFields::buildFieldsPanel(), org::jets3t::gui::skins::SkinsFactory::createSkinnedJButton(), org::jets3t::gui::skins::SkinsFactory::createSkinnedJCheckBox(), org::jets3t::gui::skins::SkinsFactory::createSkinnedJHtmlLabel(), org::jets3t::gui::skins::SkinsFactory::createSkinnedJMenuItem(), org::jets3t::gui::skins::SkinsFactory::createSkinnedJPanel(), org::jets3t::gui::skins::SkinsFactory::createSkinnedJPopupMenu(), org::jets3t::gui::skins::SkinsFactory::createSkinnedJScrollPane(), org::jets3t::gui::skins::SkinsFactory::createSkinnedJTable(), org::jets3t::gui::skins::SkinsFactory::createSkinnedJTextField(), org::jets3t::gui::skins::SkinsFactory::createSkinnedMetalTheme(), org::jets3t::service::utils::ByteFormatter::formatByteSize(), org::jets3t::gui::skins::SkinsFactory::getInstance(), org::jets3t::service::Jets3tProperties::getProperties(), initDropTarget(), and org::jets3t::gui::TableSorter::setTableHeader().

Referenced by init().

                           {
        // Initialise skins factory.
        skinsFactory = SkinsFactory.getInstance(cockpitLiteProperties.getProperties());

        // Set Skinned Look and Feel.
        LookAndFeel lookAndFeel = skinsFactory.createSkinnedMetalTheme("SkinnedLookAndFeel");
        try {
            UIManager.setLookAndFeel(lookAndFeel);
        } catch (UnsupportedLookAndFeelException e) {
            log.error("Unable to set skinned LookAndFeel", e);
        }

        // Primary panel that contains all other items.
        JPanel primaryPanel = skinsFactory.createSkinnedJPanel("PrimaryPanel");
        primaryPanel.setLayout(new GridBagLayout());
        this.getContentPane().add(primaryPanel);

        // Setup the stack panel, which contains all other panels as a stack.
        stackPanel = skinsFactory.createSkinnedJPanel("StackPanel");
        stackPanelCardLayout = new CardLayout();
        stackPanel.setLayout(stackPanelCardLayout);
        primaryPanel.add(stackPanel,
            new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0));

        // Progress notification panel
        progressNotificationPanel = skinsFactory.createSkinnedJPanel("ProgressNotificationPanel");
        progressNotificationPanel.setLayout(new GridBagLayout());
        primaryPanel.add(progressNotificationPanel,
            new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                new Insets(5, 0, 5, 0), 0, 0));

        int row = 0;

        // Login panel.
        row = 0;
        loginPanel = skinsFactory.createSkinnedJPanel("LoginPanel");
        loginPanel.setLayout(new GridBagLayout());

        userInputFields = new UserInputFields(insetsDefault, null, skinsFactory);
        userInputFields.buildFieldsPanel(loginPanel, cockpitLiteProperties);

        loginButton = skinsFactory.createSkinnedJButton("LoginButton");
        loginButton.setText("Log me in");
        loginButton.addActionListener(this);
        loginPanel.add(loginButton,
            new GridBagConstraints(0, loginPanel.getComponentCount(), 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsDefault, 0, 0));

        // Filter panel.
        filterObjectsPanel = skinsFactory.createSkinnedJPanel("FilterPanel");
        filterObjectsPanel.setLayout(new GridBagLayout());
        filterObjectsPrefix = skinsFactory.createSkinnedJTextField("FilterPrefix");
        filterObjectsPrefix.setToolTipText("Only show files starting with this string");
        filterObjectsPrefix.addActionListener(this);
        filterObjectsPrefix.setActionCommand("RefreshObjects");
        JLabel filterPrefixLabel = skinsFactory.createSkinnedJHtmlLabel("FilterPrefixLable", this);
        filterPrefixLabel.setText("File name starts with: ");
        filterObjectsPanel.add(filterPrefixLabel,
            new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0));
        filterObjectsPanel.add(filterObjectsPrefix,
            new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
        filterObjectsPanel.setVisible(false);

        // Objects panel.
        row = 0;
        JPanel objectsPanel = skinsFactory.createSkinnedJPanel("ObjectsPanel");
        objectsPanel.setLayout(new GridBagLayout());
        filterObjectsCheckBox = skinsFactory.createSkinnedJCheckBox("FilterCheckbox");
        filterObjectsCheckBox.setText("Search files");
        filterObjectsCheckBox.setEnabled(true);
        filterObjectsCheckBox.addActionListener(this);
        filterObjectsCheckBox.setToolTipText("Check this option to search your files");
        objectsHeadingLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectsHeadingLabel", this);
        objectsHeadingLabel.setText("Not logged in");
        objectsPanel.add(objectsHeadingLabel,
            new GridBagConstraints(0, row, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));
        objectsPanel.add(filterObjectsCheckBox,
            new GridBagConstraints(1, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));

        JButton objectActionButton = skinsFactory.createSkinnedJButton("ObjectMenuButton");
        objectActionButton.setToolTipText("File actions menu");
        guiUtils.applyIcon(objectActionButton, "/images/nuvola/16x16/actions/misc.png");
        objectActionButton.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
                JButton sourceButton = (JButton) e.getSource();
                objectActionMenu.show(sourceButton, 0, sourceButton.getHeight());
           }
        });
        objectsPanel.add(objectActionButton,
            new GridBagConstraints(2, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));

        objectsPanel.add(filterObjectsPanel,
            new GridBagConstraints(0, ++row, 3, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));

        objectsTable = skinsFactory.createSkinnedJTable("ObjectsTable");
        objectTableModel = new CLObjectTableModel();
        objectTableModelSorter = new TableSorter(objectTableModel);
        objectTableModelSorter.setTableHeader(objectsTable.getTableHeader());
        objectsTable.setModel(objectTableModelSorter);
        objectsTable.setDefaultRenderer(Long.class, new DefaultTableCellRenderer() {
            private static final long serialVersionUID = 7229656175879985698L;

            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                String formattedSize = byteFormatter.formatByteSize(((Long)value).longValue());
                return super.getTableCellRendererComponent(table, formattedSize, isSelected, hasFocus, row, column);
            }
        });
        objectsTable.setDefaultRenderer(Date.class, new DefaultTableCellRenderer() {
            private static final long serialVersionUID = -4983176028291916397L;

            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                Date date = (Date) value;
                return super.getTableCellRendererComponent(table, yearAndTimeSDF.format(date), isSelected, hasFocus, row, column);
            }
        });
        objectsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        objectsTable.getSelectionModel().addListSelectionListener(this);
        objectsTable.setShowHorizontalLines(true);
        objectsTable.setShowVerticalLines(true);
        objectsTable.addMouseListener(new ContextMenuListener());
        objectsTableSP = skinsFactory.createSkinnedJScrollPane("ObjectsTableSP", objectsTable);
        objectsPanel.add(objectsTableSP,
                new GridBagConstraints(0, ++row, 3, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0));
        objectsSummaryLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectsSummary", this);
        objectsSummaryLabel.setHorizontalAlignment(JLabel.CENTER);
        objectsSummaryLabel.setFocusable(false);
        objectsPanel.add(objectsSummaryLabel,
                new GridBagConstraints(0, ++row, 3, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        // Object action menu.
        objectActionMenu = skinsFactory.createSkinnedJPopupMenu("ObjectPopupMenu");

        refreshObjectMenuItem = skinsFactory.createSkinnedJMenuItem("RefreshMenuItem");
        refreshObjectMenuItem.setText("Refresh file listing");
        refreshObjectMenuItem.setActionCommand("RefreshObjects");
        refreshObjectMenuItem.addActionListener(this);
        guiUtils.applyIcon(refreshObjectMenuItem, "/images/nuvola/16x16/actions/reload.png");
        objectActionMenu.add(refreshObjectMenuItem);

        viewObjectPropertiesMenuItem = skinsFactory.createSkinnedJMenuItem("PropertiesMenuItem");
        viewObjectPropertiesMenuItem.setText("View file properties...");
        viewObjectPropertiesMenuItem.setActionCommand("ViewObjectProperties");
        viewObjectPropertiesMenuItem.addActionListener(this);
        guiUtils.applyIcon(viewObjectPropertiesMenuItem, "/images/nuvola/16x16/actions/viewmag.png");
        objectActionMenu.add(viewObjectPropertiesMenuItem);

        downloadObjectMenuItem = skinsFactory.createSkinnedJMenuItem("DownloadMenuItem");
        downloadObjectMenuItem.setText("Download file(s)...");
        downloadObjectMenuItem.setActionCommand("DownloadObjects");
        downloadObjectMenuItem.addActionListener(this);
        guiUtils.applyIcon(downloadObjectMenuItem, "/images/nuvola/16x16/actions/1downarrow.png");
        objectActionMenu.add(downloadObjectMenuItem);

        uploadFilesMenuItem = skinsFactory.createSkinnedJMenuItem("UploadMenuItem");
        uploadFilesMenuItem.setText("Upload file(s)...");
        uploadFilesMenuItem.setActionCommand("UploadFiles");
        uploadFilesMenuItem.addActionListener(this);
        guiUtils.applyIcon(uploadFilesMenuItem, "/images/nuvola/16x16/actions/1uparrow.png");
        objectActionMenu.add(uploadFilesMenuItem);

        objectActionMenu.add(new JSeparator());

        togglePublicMenuItem = skinsFactory.createSkinnedJMenuItem("AclToggleMenuItem");
        togglePublicMenuItem.setText("Change privacy setting...");
        togglePublicMenuItem.setActionCommand("TogglePublicPrivate");
        togglePublicMenuItem.addActionListener(this);
        guiUtils.applyIcon(togglePublicMenuItem, "/images/nuvola/16x16/actions/encrypted.png");
        objectActionMenu.add(togglePublicMenuItem);

        generatePublicGetUrl = skinsFactory.createSkinnedJMenuItem("PublicUrlMenuItem");
        generatePublicGetUrl.setText("Public web link...");
        generatePublicGetUrl.setActionCommand("GeneratePublicGetURL");
        generatePublicGetUrl.addActionListener(this);
        guiUtils.applyIcon(generatePublicGetUrl, "/images/nuvola/16x16/actions/wizard.png");
        objectActionMenu.add(generatePublicGetUrl);

        objectActionMenu.add(new JSeparator());

        deleteObjectMenuItem = skinsFactory.createSkinnedJMenuItem("DeleteMenuItem");
        deleteObjectMenuItem.setText("Delete file(s)...");
        deleteObjectMenuItem.setActionCommand("DeleteObjects");
        deleteObjectMenuItem.addActionListener(this);
        guiUtils.applyIcon(deleteObjectMenuItem, "/images/nuvola/16x16/actions/cancel.png");
        objectActionMenu.add(deleteObjectMenuItem);

        viewObjectPropertiesMenuItem.setEnabled(false);
        refreshObjectMenuItem.setEnabled(false);
        togglePublicMenuItem.setEnabled(false);
        downloadObjectMenuItem.setEnabled(false);
        generatePublicGetUrl.setEnabled(false);
        deleteObjectMenuItem.setEnabled(false);

        // Card layout in stack panel
        stackPanel.add(loginPanel, "LoginPanel");
        stackPanel.add(objectsPanel, "ObjectsPanel");

        // Set preferred sizes
        int preferredWidth = 800;
        int preferredHeight = 600;
        this.setBounds(new Rectangle(new Dimension(preferredWidth, preferredHeight)));

        // Initialize drop target.
        initDropTarget(new JComponent[] {objectsPanel} );
        objectsPanel.getDropTarget().setActive(true);
    }


Generated by  Doxygen 1.6.0   Back to index