Example usage for com.google.gwt.user.client.ui MenuBar addItem

List of usage examples for com.google.gwt.user.client.ui MenuBar addItem

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui MenuBar addItem.

Prototype

public MenuItem addItem(String text, MenuBar popup) 

Source Link

Document

Adds a menu item to the bar, that will open the specified menu when it is selected.

Usage

From source file:org.gwtportlets.portlet.client.edit.PageEditor.java

License:Open Source License

/**
 * Add menu options for this layout editor manager to bar (e.g. for
 * undo, redo and add widget).// ww w. ja  v  a 2 s.c  o  m
 */
protected void buildManagerMenuItems(MenuBar bar) {
    UndoStack.Operation op = undoStack.getUndo();
    if (op != null) {
        String s = "Undo " + op.getDescription();
        bar.addItem(s, new Command() {
            public void execute() {
                undoStack.undo();
            }
        }).setTitle(s + " (Ctrl-Z)");
    }

    op = undoStack.getRedo();
    if (op != null) {
        String s = "Redo " + op.getDescription();
        bar.addItem(s, new Command() {
            public void execute() {
                undoStack.redo();
            }
        }).setTitle(s + " (Ctrl-Shift-Z)");
    }

    bar.addItem("Add", buildAddMenu());
}

From source file:org.gwtportlets.portlet.client.edit.TitlePanelEditor.java

License:Open Source License

public void createMenuItems(final PageEditor manager, MenuBar bar, final Widget widget) {
    super.createMenuItems(manager, bar, widget);

    bar.addItem("Edit Title...", new Command() {
        public void execute() {
            manager.displayEditWidgetDialog(widget, new TitlePanelDialog((TitlePanel) widget));
        }//from w w w . j  av a 2 s  .  co  m
    }).setTitle("Edit title settings");
}

From source file:org.iplantc.phyloviewer.viewer.client.Phyloviewer.java

License:Creative Commons License

/**
 * This is the entry point method.//from  w w w .  j  a v  a 2s .  co  m
 */
public void onModuleLoad() {

    widget = new TreeWidget(searchService, eventBus);

    Style highlight = new Style("highlight");
    highlight.setNodeStyle(new NodeStyle("#C2C2F5", Double.NaN, null));
    highlight.setLabelStyle(new LabelStyle(null));
    highlight.setGlyphStyle(new GlyphStyle(null, "#C2C2F5", Double.NaN));
    highlight.setBranchStyle(new BranchStyle("#C2C2F5", Double.NaN));

    RenderPreferences rp = new RenderPreferences();
    rp.setHighlightStyle(highlight);
    widget.setRenderPreferences(rp);

    MenuBar fileMenu = new MenuBar(true);
    fileMenu.addItem("Open...", new Command() {

        @Override
        public void execute() {
            Phyloviewer.this.displayTrees();
        }

    });

    Command openURL = new Command() {
        @Override
        public void execute() {
            Window.open(widget.exportImageURL(), "_blank", "");
        }
    };

    fileMenu.addItem("Get image (opens in a popup window)", openURL);

    Command showSVG = new Command() {
        @Override
        public void execute() {
            String svg = getSVG();
            String url = "data:image/svg+xml;charset=utf-8," + svg;
            Window.open(url, "_blank", "");
        }
    };
    fileMenu.addItem("Export to SVG", showSVG);

    MenuBar layoutMenu = new MenuBar(true);
    layoutMenu.addItem("Rectangular Cladogram", new Command() {
        @Override
        public void execute() {
            ITree tree = widget.getDocument().getTree();
            byte[] treeID = ((RemoteTree) tree).getHash();
            widget.setDocument(null);
            widget.setViewType(TreeWidget.ViewType.VIEW_TYPE_CLADOGRAM);
            layoutType = "LAYOUT_TYPE_CLADOGRAM";

            loadTree(null, treeID, layoutType);
        }
    });
    layoutMenu.addItem("Rectangular Phylogram", new Command() {
        @Override
        public void execute() {
            ITree tree = widget.getDocument().getTree();
            byte[] treeID = ((RemoteTree) tree).getHash();
            widget.setDocument(null);
            widget.setViewType(TreeWidget.ViewType.VIEW_TYPE_CLADOGRAM);
            layoutType = "LAYOUT_TYPE_PHYLOGRAM";

            loadTree(null, treeID, layoutType);
        }
    });
    layoutMenu.addItem("Circular", new Command() {
        @Override
        public void execute() {
            ITree tree = widget.getDocument().getTree();
            byte[] treeID = ((RemoteTree) tree).getHash();
            widget.setDocument(null);
            widget.setViewType(TreeWidget.ViewType.VIEW_TYPE_RADIAL);
            layoutType = "LAYOUT_TYPE_CLADOGRAM";

            loadTree(null, treeID, layoutType);
        }
    });

    MenuBar styleMenu = new MenuBar(true);
    final TextInputPopup styleTextPopup = new TextInputPopup();
    styleTextPopup.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String style = event.getValue();

            try {
                IStyleMap styleMap = StyleServiceClient.parseJSON(style);
                widget.getDocument().setStyleMap(styleMap);
                widget.render();
            } catch (StyleServiceException e) {
                Window.alert(
                        "Unable to parse style document. See https://pods.iplantcollaborative.org/wiki/display/iptol/Using+Phyloviewer+GWT+client+library#UsingPhyloviewerGWTclientlibrary-Addingstylingmarkuptoviewer for help.");
            }
        }
    });

    styleTextPopup.setModal(true);

    styleMenu.addItem("Import Tree Styling", new Command() {
        @Override
        public void execute() {
            styleTextPopup.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
                @Override
                public void setPosition(int offsetWidth, int offsetHeight) {
                    int left = (Window.getClientWidth() - offsetWidth) / 3;
                    int top = (Window.getClientHeight() - offsetHeight) / 3;
                    styleTextPopup.setPopupPosition(left, top);
                }
            });
        }
    });

    // Make a search box
    final SuggestBox searchBox = new SuggestBox(searchService);
    searchBox.setLimit(10); // TODO make scrollable?
    searchBox.addSelectionHandler(new SelectionHandler<Suggestion>() {
        @Override
        public void onSelection(SelectionEvent<Suggestion> event) {
            Box2D box = ((RemoteNodeSuggestion) event.getSelectedItem()).getResult().layout.boundingBox;
            widget.show(box);
        }
    });

    // create some styling widgets for the context menu
    NodeStyleWidget nodeStyleWidget = new NodeStyleWidget(widget.getDocument());
    BranchStyleWidget branchStyleWidget = new BranchStyleWidget(widget.getDocument());
    GlyphStyleWidget glyphStyleWidget = new GlyphStyleWidget(widget.getDocument());
    LabelStyleWidget labelStyleWidget = new LabelStyleWidget(widget.getDocument());

    // replace their default TextBoxes with ColorBoxes, which jscolor.js will add a color picker to
    nodeStyleWidget.setColorWidget(createColorBox());
    branchStyleWidget.setStrokeColorWidget(createColorBox());
    glyphStyleWidget.setStrokeColorWidget(createColorBox());
    glyphStyleWidget.setFillColorWidget(createColorBox());
    labelStyleWidget.setColorWidget(createColorBox());

    // add the widgets to separate panels on the context menu
    final ContextMenu contextMenuPanel = new ContextMenu(widget);
    contextMenuPanel.add(new NodeTable(), "Node details", 3);
    contextMenuPanel.add(nodeStyleWidget, "Node", 3);
    contextMenuPanel.add(branchStyleWidget, "Branch", 3);
    contextMenuPanel.add(glyphStyleWidget, "Glyph", 3);
    contextMenuPanel.add(labelStyleWidget, "Label", 3);

    HorizontalPanel searchPanel = new HorizontalPanel();
    searchPanel.add(new Label("Search:"));
    searchPanel.add(searchBox);

    // Make the UI.
    MenuBar menu = new MenuBar();
    final DockLayoutPanel mainPanel = new DockLayoutPanel(Unit.EM);
    mainPanel.addNorth(menu, 2);
    mainPanel.addSouth(searchPanel, 2);
    mainPanel.addWest(contextMenuPanel, 0);
    mainPanel.add(widget);
    RootLayoutPanel.get().add(mainPanel);

    MenuBar viewMenu = new MenuBar(true);
    viewMenu.addItem("Layout", layoutMenu);
    viewMenu.addItem("Style", styleMenu);

    contextMenuPanel.setVisible(false);
    viewMenu.addItem("Toggle Context Panel", new Command() {
        @Override
        public void execute() {
            if (contextMenuPanel.isVisible()) {
                contextMenuPanel.setVisible(false);
                mainPanel.setWidgetSize(contextMenuPanel, 0);
                mainPanel.forceLayout();
            } else {
                contextMenuPanel.setVisible(true);
                mainPanel.setWidgetSize(contextMenuPanel, 20);
                mainPanel.forceLayout();
            }
        }
    });

    menu.addItem("File", fileMenu);
    menu.addItem("View", viewMenu);

    // Draw for the first time.
    RootLayoutPanel.get().forceLayout();
    mainPanel.forceLayout();
    widget.setViewType(ViewType.VIEW_TYPE_CLADOGRAM);
    widget.render();

    initColorPicker();

    String[] splitPath = Window.Location.getPath().split("/");
    String treeIdString = null;
    for (int i = 0; i < splitPath.length; i++) {
        if (splitPath[i].equalsIgnoreCase("tree")) {
            treeIdString = splitPath[i + 1];
        }
    }

    if (treeIdString != null && !treeIdString.equals("")) {
        try {
            final byte[] treeId = Hex.decodeHex(treeIdString.toCharArray());
            this.loadTree(null, treeId, layoutType);
        } catch (Exception e) {
            Window.alert("Unable to parse tree ID string from URL");
        }
    } else {
        // Present the user the dialog to load a tree.
        this.displayTrees();
    }

    updateStyle();
    History.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            updateStyle();
        }
    });
}

From source file:org.jboss.bpm.console.client.engine.DeploymentListView.java

License:Open Source License

public void initialize() {
    if (!initialized) {
        deploymentList = new VerticalPanel();

        // toolbar

        final HorizontalPanel toolBox = new HorizontalPanel();

        final MenuBar toolBar = new MenuBar();
        toolBar.addItem("Refresh", new Command() {
            public void execute() {

                reset();//www . ja v a2  s . com

                // force loading
                controller.handleEvent(new Event(UpdateDeploymentsAction.ID, null));
            }
        });

        MenuItem deleteBtn = new MenuItem("Delete", new Command() {
            public void execute() {
                DeploymentRef deploymentRef = getSelection();
                if (deploymentRef != null) {
                    if (Window.confirm(
                            "Delete deployment. Do you want to delete this deployment? Any related data will be removed.")) {
                        controller.handleEvent(new Event(DeleteDeploymentAction.ID, getSelection().getId()));
                    }
                } else {
                    Window.alert("Missing selection. Please select a deployment");
                }
            }
        });

        if (!isRiftsawInstance) {
            toolBar.addItem(deleteBtn);
        }

        toolBox.add(toolBar);

        // filter
        VerticalPanel filterPanel = new VerticalPanel();
        filterPanel.setStyleName("mosaic-ToolBar");
        final com.google.gwt.user.client.ui.ListBox dropBox = new com.google.gwt.user.client.ui.ListBox(false);
        dropBox.setStyleName("bpm-operation-ui");
        dropBox.addItem("All");
        dropBox.addItem("Active");
        dropBox.addItem("Retired");

        dropBox.addChangeListener(new ChangeListener() {
            public void onChange(Widget sender) {
                switch (dropBox.getSelectedIndex()) {
                case 0:
                    currentFilter = FILTER_NONE;
                    break;
                case 1:
                    currentFilter = FILTER_ACTIVE;
                    break;
                case 2:
                    currentFilter = FILTER_SUSPENDED;
                    break;
                default:
                    throw new IllegalArgumentException("No such index");
                }

                renderFiltered();
            }
        });
        filterPanel.add(dropBox);

        toolBox.add(filterPanel);

        this.deploymentList.add(toolBox);
        this.deploymentList.add(listBox);

        // details
        // detail panel
        detailView = new DeploymentDetailView();
        controller.addView(DeploymentDetailView.ID, detailView);

        Timer t = new Timer() {
            @Override
            public void run() {
                controller.handleEvent(new Event(UpdateDeploymentsAction.ID, null));
            }
        };

        t.schedule(500);

        initialized = true;
    }

}

From source file:org.jboss.bpm.console.client.engine.JobListView.java

License:Open Source License

public void initialize() {
    if (!initialized) {
        jobList = new VerticalPanel();

        // toolbar

        final HorizontalPanel toolBox = new HorizontalPanel();

        // toolbar
        final MenuBar toolBar = new MenuBar();
        toolBar.addItem("Refresh", new Command() {
            public void execute() {
                // force loading
                controller.handleEvent(new Event(UpdateJobsAction.ID, null));
            }/*from   w w  w. j a v a 2  s.c om*/
        });

        toolBar.addItem("Execute", new Command() {
            public void execute() {
                JobRef selection = getSelection();
                if (null == selection) {
                    Window.alert("Missing selection. Please select a job!");
                } else {
                    controller.handleEvent(new Event(ExecuteJobAction.ID, selection.getId()));
                }
            }
        });

        toolBox.add(toolBar);

        // filter
        VerticalPanel filterPanel = new VerticalPanel();
        filterPanel.setStyleName("mosaic-ToolBar");
        final com.google.gwt.user.client.ui.ListBox dropBox = new com.google.gwt.user.client.ui.ListBox(false);
        dropBox.setStyleName("bpm-operation-ui");
        dropBox.addItem("All");
        dropBox.addItem("Timers");
        dropBox.addItem("Messages");

        dropBox.addChangeListener(new ChangeListener() {
            public void onChange(Widget sender) {
                switch (dropBox.getSelectedIndex()) {
                case 0:
                    currentFilter = FILTER_NONE;
                    break;
                case 1:
                    currentFilter = FILTER_TIMER;
                    break;
                case 2:
                    currentFilter = FILTER_MESSAGE;
                    break;
                default:
                    throw new IllegalArgumentException("No such index");
                }

                renderFiltered();
            }
        }

        );
        filterPanel.add(dropBox);

        toolBox.add(filterPanel);

        this.jobList.add(toolBox);
        this.jobList.add(listBox);

        // details
        /*JobDetailView detailsView = new JobDetailView();
        controller.addView(JobDetailView.ID, detailsView);
        controller.addAction(UpdateJobDetailAction.ID, new UpdateJobDetailAction());
        layout.add(detailsView, new BorderLayoutData(BorderLayout.Region.SOUTH, 10,200));
        */

        Timer t = new Timer() {
            @Override
            public void run() {
                controller.handleEvent(new Event(UpdateJobsAction.ID, null));
            }
        };

        t.schedule(500);

        controller.addAction(UpdateJobsAction.ID, new UpdateJobsAction(clientFactory.getApplicationContext()));

        this.initialized = true;
    }
}

From source file:org.jboss.bpm.console.client.process.DefinitionHistoryListView.java

License:Open Source License

public void initialize() {
    if (!isInitialized) {

        definitionList = new VerticalPanel();

        // toolbar

        final HorizontalPanel toolBox = new HorizontalPanel();

        // toolbar
        final MenuBar toolBar = new MenuBar();

        toolBar.addItem("Refresh", new Command() {
            public void execute() {
                reload();//  w  w w. j  a v a2  s  . c om
            }
        });

        toolBox.add(toolBar);

        definitionList.add(toolBox);

        definitionList.add(listBox);
        pagingPanel = new PagingPanel(new PagingCallback() {
            public void rev() {
                renderFiltered();
            }

            public void ffw() {
                renderFiltered();
            }
        });
        definitionList.add(pagingPanel);

        panel.add(definitionList);

        // deployments model listener
        ErraiBus.get().subscribe(Model.SUBJECT, new MessageCallback() {
            public void callback(Message message) {
                switch (ModelCommands.valueOf(message.getCommandType())) {
                case HAS_BEEN_UPDATED:
                    if (message.get(String.class, ModelParts.CLASS).equals(Model.DEPLOYMENT_MODEL)) {
                        reload();
                    }
                    break;
                }
            }
        });

        isInitialized = true;
    }
}

From source file:org.jboss.bpm.console.client.process.DefinitionListView.java

License:Open Source License

public void initialize() {
    if (!isInitialized) {

        definitionList = new VerticalPanel();

        // toolbar

        final HorizontalPanel toolBox = new HorizontalPanel();

        // toolbar
        final MenuBar toolBar = new MenuBar();

        toolBar.addItem("Refresh", new Command() {
            public void execute() {
                reload();//from   ww  w.j  a v a  2s.  c o  m
            }
        });

        toolBox.add(toolBar);

        // filter
        VerticalPanel filterPanel = new VerticalPanel();
        filterPanel.setStyleName("mosaic-ToolBar");
        final com.google.gwt.user.client.ui.ListBox dropBox = new com.google.gwt.user.client.ui.ListBox(false);
        dropBox.setStyleName("bpm-operation-ui");
        dropBox.addItem("All");
        dropBox.addItem("Active");
        dropBox.addItem("Retired");

        dropBox.addChangeHandler(new ChangeHandler() {

            public void onChange(ChangeEvent changeEvent) {
                switch (dropBox.getSelectedIndex()) {
                case 0:
                    currentFilter = FILTER_NONE;
                    break;
                case 1:
                    currentFilter = FILTER_ACTIVE;
                    break;
                case 2:
                    currentFilter = FILTER_SUSPENDED;
                    break;
                default:
                    throw new IllegalArgumentException("No such index");
                }

                renderFiltered();
            }
        });
        filterPanel.add(dropBox);

        toolBox.add(filterPanel);

        definitionList.add(toolBox);
        definitionList.add(listBox);
        pagingPanel = new PagingPanel(new PagingCallback() {
            public void rev() {
                renderFiltered();
            }

            public void ffw() {
                renderFiltered();
            }
        });
        definitionList.add(pagingPanel);

        // layout
        //MosaicPanel layout = new MosaicPanel(new BorderLayout());
        //layout.add(definitionList, new BorderLayoutData(BorderLayout.Region.CENTER));

        // details
        /*ProcessDetailView detailsView = new ProcessDetailView();
        controller.addView(ProcessDetailView.ID, detailsView);
        controller.addAction(UpdateProcessDetailAction.ID, new UpdateProcessDetailAction());
        layout.add(detailsView, new BorderLayoutData(BorderLayout.Region.SOUTH, 10,200));*/

        //panel.add(layout);

        panel.add(definitionList);

        // deployments model listener
        ErraiBus.get().subscribe(Model.SUBJECT, new MessageCallback() {
            public void callback(Message message) {
                switch (ModelCommands.valueOf(message.getCommandType())) {
                case HAS_BEEN_UPDATED:
                    if (message.get(String.class, ModelParts.CLASS).equals(Model.DEPLOYMENT_MODEL)) {
                        reload();
                    }
                    break;
                }
            }
        });

        isInitialized = true;
    }
}

From source file:org.jboss.bpm.console.client.process.HistoryInstanceListView.java

License:Open Source License

public void initialize() {
    if (!isInitialized) {
        instanceList = new VerticalPanel();

        // create history list box elements
        listBoxHistory = createHistoryListBox();
        // create list of activities executed for currently selected history process instance
        this.listBoxInstanceActivity = createHistoryActivitiesListBox();

        // toolbar
        final HorizontalPanel toolBox = new HorizontalPanel();

        toolBox.setSpacing(5);/*w  ww. j a  va2  s .com*/

        final MenuBar toolBar = new MenuBar();
        toolBar.addItem("Refresh", new Command() {

            public void execute() {

                controller.handleEvent(new Event(UpdateHistoryDefinitionAction.ID, getCurrentDefinition()));
            }
        });

        diagramBtn = new MenuItem("Diagram", new Command() {
            public void execute() {
                String diagramUrl = currentDefinition.getDiagramUrl();
                if (currentDefinition != null && executedActivities != null) {
                    HistoryActivityDiagramEvent eventData = new HistoryActivityDiagramEvent(currentDefinition,
                            executedActivities);
                    if (diagramUrl != null && !diagramUrl.equals("")) {
                        createDiagramWindow();
                        controller.handleEvent(new Event(LoadHistoryDiagramAction.ID, eventData));

                    } else {
                        Window.alert("Incomplete deployment, No diagram associated with process");
                    }
                }
            }
        });

        // terminate works on any BPM Engine
        toolBar.addItem(diagramBtn);
        diagramBtn.setEnabled(false);

        toolBox.add(toolBar);

        instanceList.add(toolBox);
        instanceList.add(listBoxHistory);

        pagingPanel = new

        PagingPanel(new PagingCallback() {
            public void rev() {
                renderUpdate();
            }

            public void ffw() {
                renderUpdate();
            }
        });
        instanceList.add(pagingPanel);
        instanceList.add(listBoxInstanceActivity);

        // cached data?
        if (this.cachedInstances != null) {
            bindData(this.cachedInstances);
        }

        // layout
        SimplePanel layout = new SimplePanel();
        layout.add(instanceList);

        panel.add(layout);

        isInitialized = true;

        this.executedActivities = new ArrayList<String>();

    }
}

From source file:org.jboss.bpm.console.client.process.InstanceListView.java

License:Open Source License

private void createSignalWindow() {
    signalTextBoxes = new ArrayList<TextBox>();

    VerticalPanel layout = new VerticalPanel();
    layout.setStyleName("bpm-window-layout");

    // toolbar/*  w w  w.  j  a v a 2s.c om*/
    final HorizontalPanel toolBox = new HorizontalPanel();

    toolBox.setSpacing(5);

    final MenuBar toolBar = new MenuBar();
    toolBar.addItem("Signal", new Command() {

        public void execute() {
            int selectedToken = listBoxTokens.getSelectedIndex();
            int selectedSignal = listBoxTokenSignals.getSelectedIndex();
            if (selectedToken != -1 && selectedSignal != -1) {

                controller.handleEvent(new Event(SignalExecutionAction.ID,
                        new SignalInstanceEvent(getCurrentDefinition(), getSelection(),
                                listBoxTokens.getItem(selectedToken),
                                listBoxTokenSignals.getItem(selectedSignal), selectedToken)));

            } else {
                Window.alert("Incomplete selection. Please select both token and signal name");
            }

        }
    });

    toolBar.addItem("Cancel", new Command() {
        public void execute() {

            signalWindowPanel.close();
        }
    });

    Label header = new Label("Available tokens to signal: ");
    header.setStyleName("bpm-label-header");
    layout.add(header);

    toolBox.add(toolBar);

    layout.add(toolBox);

    listBoxTokens = new CustomizableListBox<TokenReference>(
            new CustomizableListBox.ItemFormatter<TokenReference>() {
                public String format(TokenReference tokenReference) {
                    String result = "";

                    result += tokenReference.getId();

                    result += " ";

                    result += tokenReference.getName() == null ? tokenReference.getCurrentNodeName()
                            : tokenReference.getName();

                    return result;
                }
            });

    listBoxTokens.setFirstLine("Id, Name");

    listBoxTokens.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {
            int index = listBoxTokens.getSelectedIndex();
            if (index != -1) {
                TokenReference item = listBoxTokens.getItem(index);
                renderAvailableSignals(item);
            }
        }
    });

    renderSignalListBox(-1);
    layout.add(listBoxTokens);

    Label headerSignals = new Label("Available signal names");
    headerSignals.setStyleName("bpm-label-header");
    layout.add(headerSignals);

    listBoxTokenSignals = new CustomizableListBox<String>(new CustomizableListBox.ItemFormatter<String>() {
        public String format(String item) {
            return item;
        }
    });

    listBoxTokenSignals.setFirstLine("Signal name");

    layout.add(listBoxTokenSignals);

    signalWindowPanel = new WidgetWindowPanel("Signal process from wait state", layout, true);

}

From source file:org.jboss.bpm.console.client.task.AssignedTasksView.java

License:Open Source License

public void initialize() {
    if (!isInitialized) {
        // workaround
        OpenTasksView.registerCommonActions(appContext, controller);

        taskList = new VerticalPanel();

        listBox = new CustomizableListBox<TaskRef>(new CustomizableListBox.ItemFormatter<TaskRef>() {
            public String format(TaskRef taskRef) {

                String result = "";

                result += String.valueOf(taskRef.getPriority());

                result += " ";

                result += taskRef.getProcessId();

                result += " ";

                result += taskRef.getName();

                result += " ";

                result += taskRef.getDueDate() != null ? dateFormat.format(taskRef.getDueDate()) : "";

                return result;
            }/*from  w  w w.j  ava2  s .  c o  m*/
        });

        listBox.setFirstLine("Priority, Process, Task Name, Due Date");

        listBox.addChangeHandler(new ChangeHandler() {
            public void onChange(ChangeEvent event) {
                TaskRef task = getSelection(); // first call always null?
                if (task != null) {
                    controller.handleEvent(
                            new Event(UpdateDetailsAction.ID, new DetailViewEvent("AssignedDetailView", task)));
                }

            }
        });

        // toolbar
        final VerticalPanel toolBox = new VerticalPanel();
        toolBox.setSpacing(5);

        final MenuBar toolBar = new MenuBar();
        toolBar.addItem("Refresh", new Command() {
            public void execute() {
                reload();
            }
        });

        MenuItem viewBtn = new MenuItem("View", new Command() {
            public void execute() {
                TaskRef selection = getSelection();

                if (selection != null) {
                    if (selection.getUrl() != null && !selection.getUrl().equals("")) {
                        iframeWindow = new IFrameWindowPanel(selection.getUrl(),
                                "Task Form: " + selection.getName());

                        iframeWindow.setCallback(new IFrameWindowCallback() {
                            public void onWindowClosed() {
                                reload();
                            }
                        });

                        iframeWindow.show();
                    } else {
                        Window.alert("Invalid operation. The task doesn't provide a UI");
                    }
                } else {
                    Window.alert("Missing selection. Please select a task");
                }
            }
        });
        toolBar.addItem(viewBtn);

        toolBar.addItem("Release", new Command() {
            public void execute() {
                TaskRef selection = getSelection();

                if (selection != null) {
                    TaskIdentityEvent payload = new TaskIdentityEvent(null, selection);

                    controller.handleEvent(new Event(ReleaseTaskAction.ID, payload));
                } else {
                    Window.alert("Missing selection. Please select a task");
                }
            }
        });

        toolBox.add(toolBar);

        this.taskList.add(toolBox);
        this.taskList.add(listBox);

        pagingPanel = new

        PagingPanel(new PagingCallback() {
            public void rev() {
                renderUpdate();
            }

            public void ffw() {
                renderUpdate();
            }
        });

        this.taskList.add(pagingPanel);

        detailsView = new TaskDetailView(false);
        controller.addView("AssignedDetailView", detailsView);
        detailsView.initialize();

        // plugin availability
        this.hasDispatcherPlugin = ServerPlugins
                .has("org.jboss.bpm.console.server.plugin.FormDispatcherPlugin");
        viewBtn.setEnabled(hasDispatcherPlugin);

        // deployments model listener
        ErraiBus.get().subscribe(Model.SUBJECT, new MessageCallback() {
            public void callback(Message message) {
                switch (ModelCommands.valueOf(message.getCommandType())) {
                case HAS_BEEN_UPDATED:
                    if (message.get(String.class, ModelParts.CLASS).equals(Model.PROCESS_MODEL)) {
                        reload();
                    }
                    break;
                }
            }
        });

        Timer t = new Timer() {
            @Override
            public void run() {
                // force loading
                reload();
            }
        };

        t.schedule(500);

        isInitialized = true;
    }
}