Page 2 of 2

Re: Working with Tabs

PostPosted: Fri Aug 28, 2009 10:19 am
by dskanth
Thanks for your reply jmarie.

Re: Working with Tabs

PostPosted: Fri Aug 28, 2009 10:50 am
by jburel
>For the Projects panel, i want to include 3 buttons - Create Project, Create Dataset, Delete >Project/Dataset. These buttons are just tiny icons that are to be placed at the toolbar. See the attached screenshot. ;)
>Also, i want to add few additional panels below Projects panel (Omero.jpg)

To Add (resp. Remove) the buttons (cf. your screenshot) to (resp. from),
you will have to modify the method createMenuBar() in the BrowserUI file (package agents.treeviewer.browser).
You need then to create Browser actions, e.g. DeleteAction etc, just copy how it is done for the buttons already implemented. Follow the same approach so that you have control of state change, selection changes etc.

>To add panel to the project panels,
The browsers are added to the view in the method createTabbedPane() in TreeVieweWin
(package agents.treeviewer.view).
we only add the brower
but you can easily achieve what you want there by adding new components


jmarie

Re: Working with Tabs

PostPosted: Fri Aug 28, 2009 12:12 pm
by dskanth
I have created a new JButton in the BrowserUI.java, in createMenuBar method.
But iam a bit confused with how i can create Browser actions.
And then, in TreeViewerWin.java, but i dont understand how to add my button there.

Re: Working with Tabs

PostPosted: Fri Aug 28, 2009 1:11 pm
by jburel
You will need a bit more work than that!

You should do something like
button = new JButton(controller.getAction(BrowserControl.CREATE_PROJECT));
button.setBorderPainted(false);
menuBar.add(button); //the button is now added. to the toolbar of the browser: left-hand side.

Go to BrowserControl, declare a static field CREATE_PROJECT.
then , initialize the action
Code: Select all
void createActions(){
....
actionsMap.put(CREATE_PROJECT., new BrowserCreateProjectAction(model));
}


Then go to treeviewer.actions and create a BrowserCreateProjectAction()
Code: Select all
public class BrowserCreateProjectAction
   extends BrowserAction
{

    /** Description of the action. */
    private static final String DESCRIPTION = "Create a project";
   
    /**
     * Creates a new instance.
     *
     * @param model Reference to the Model. Mustn't be <code>null</code>.
     */
    public BrowserCreateProjectAction(Browser model)
    {
        super(model);
        setEnabled(true);
        putValue(Action.SHORT_DESCRIPTION,
                UIUtilities.formatToolTipText(DESCRIPTION));
        IconManager im = IconManager.getInstance();
        putValue(Action.SMALL_ICON, im.getIcon(IconManager.CREATE)); //or other icons
    }
   
    /**
     * Displays the list of supported file formats.
     * @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
     */
    public void actionPerformed(ActionEvent e)
    {
        model.createProject() // code you will have to be implement in Browser
    }

}




The comment about TreeVieweWin was only if you want to add components other than the tree view to the tab cf. screenshot you attached

Re: Working with Tabs

PostPosted: Mon Aug 31, 2009 10:45 am
by dskanth
Thanks for your kind help, i was atlast able to create a static button (iam working on the action part). ;)