ToolBarButton Extension

Adds a new toolbar icon. Usually toolbar icons are OpenKM features like create folder, delete, upload new file, etc.

Methods

methodDescription
checkPermissions(GWTNode node, GWTNode nodeParent, int originPanel)

Checks the button permissions based on the selected node grants to enable or disable the button.

checkPermissions(GWTDocument doc, GWTNode node)

Checks the button permissions based on selected document grants to enable or disable the button.

checkPermissions(GWTMail mail, GWTNode node)

Checks the button permissions based on the selected folder grants to enable or disable the button.

checkPermissions(GWTRecord record, GWTNode node);

Checks the button permissions based on the selected record node grants to enable or disable the button.

isEnabled()

Returns a boolean value indicating if the button is enabled or disabled.

enable(boolean enable)

Enables or disables button.

Sample

package com.openkm.extension.frontend.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Image;
import com.openkm.extension.frontend.client.util.OKMExtensionBundleExampleResources;
import com.openkm.frontend.client.bean.GWTDocument;
import com.openkm.frontend.client.bean.GWTMail;
import com.openkm.frontend.client.bean.GWTNode;
import com.openkm.frontend.client.bean.GWTRecord;
import com.openkm.frontend.client.extension.widget.toolbar.ToolBarButtonExtension;

public class ToolBarButtonExample {

    ToolBarButton button;
    String title = "title";
    String lang = "en-GB";

    public ToolBarButtonExample() {
        button = new ToolBarButton(new Image(OKMExtensionBundleExampleResources.INSTANCE.box()), title, new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                Window.alert("make some operation");
            }
        });
    }

    /**
     * ToolBarButtonExtension
     */
    public ToolBarButtonExtension getButton() {
        return button;
    }

    private class ToolBarButton extends ToolBarButtonExtension {

        public ToolBarButton(Image image, String title, ClickHandler handler) {
            super(image, title, handler);
        }

        @Override
        public void checkPermissions(GWTNode node, GWTNode nodeParent, int originPanel) {
        }

        @Override
        public void checkPermissions(GWTDocument doc, GWTNode node) {
        }

        @Override
        public void checkPermissions(GWTMail mail, GWTNode node) {
        }

        @Override
        public void checkPermissions(GWTRecord record, GWTNode node) {
        }

        @Override
        public void enable(boolean enable) {
        }

        @Override
        public boolean isEnabled() {
            return false;
        }
    }
}