Example usage for com.google.gwt.user.client.ui Widget getTitle

List of usage examples for com.google.gwt.user.client.ui Widget getTitle

Introduction

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

Prototype

public String getTitle() 

Source Link

Document

Gets the title associated with this object.

Usage

From source file:ch.unifr.pai.ice.client.dragNdrop.DND4users4spaces.java

License:Apache License

/******************************************
 * Set the drop panels with the grid// w  w  w . ja  va2 s  .  c o  m
 ******************************************/

private void setDropPanels() {

    for (int row = 0; row < 4; ++row) {
        for (int col = 0; col < 10; ++col) {

            dropGrid.getColumnFormatter().setWidth(col, "10%");
            dropPanel = new FocusPanel();
            dropPanel.setSize("100%", "100%");

            Label l = new Label(String.valueOf(col));
            l.getElement().getStyle().setBackgroundColor(colors[row]);
            l.getElement().getStyle().setFontSize(18, Unit.PX);
            l.getElement().getStyle().setFontWeight(FontWeight.BOLD);

            if (colors[row].equals("black"))
                l.getElement().getStyle().setColor("white");

            final DropAbsolutePanel absDropPanel = new DropAbsolutePanel((row * 10) + col);
            absDropPanel.add(l);
            absDropPanel.setTitle(String.valueOf(row) + String.valueOf(col));
            absDropPanel.setSize("100%", "100%");

            dropPanel.add(absDropPanel);
            dropGrid.setWidget(row, col, dropPanel);

            /**************************
             * Set the drop handler
             *************************/

            DragNDrop.setDropHandler(dropPanel, new DropTargetHandlerAdapter() {

                @Override
                public boolean onDrop(String deviceId, Widget widget, Element dragProxy, Event event,
                        Double intersectionPercentage, Double intersectionPercentageWithTarget) {

                    if (((DraggableLabelledBlob) widget).getBlobNumber() == absDropPanel.getPanelID()) {

                        absDropPanel.clear();
                        absDropPanel.add(widget);

                        ((DraggableLabelledBlob) widget).setDropTime(System.currentTimeMillis());
                        ((DraggableLabelledBlob) widget).setDragStarted(false);
                        ((DraggableLabelledBlob) widget).setDropTime(System.currentTimeMillis());

                        resultVector.add(

                                new String("user" + widget.getTitle().charAt(0) + ";" + "blob"
                                        + ((DraggableLabelledBlob) widget).getBlobName() + ";"
                                        + ((DraggableLabelledBlob) widget).getDragNdropTime())

                        );

                        if (--blobsToDrop == 0) {
                            // log the results if all blobs are dropped!!!
                            log();
                        }
                        return true;
                    } else
                        return false;
                }

            }, false);
        }
    }
}

From source file:ch.unifr.pai.twice.layout.client.eclipseLayout.MiceLayoutTabPanel.java

License:Apache License

/**
 * Adds a component to the tab panel. If it the widget is an instance of {@link MiceTabLabel}, it takes the predefined label value for the labelling of the
 * tab. Otherwise it looks after a title attribute of the widget and labels the tab after this value. If no such value exists, its tab will get an empty
 * label./*from   w  w w. j  ava2s  .  c o  m*/
 * 
 * @see com.google.gwt.user.client.ui.TabLayoutPanel#add(com.google.gwt.user.client.ui.Widget)
 */
@Override
public void add(Widget w) {
    if (w instanceof MiceTabLabel) {
        add((MiceTabLabel) w);
        if (((MiceTabLabel) w).getWidget() instanceof RequiresResize) {
            ((RequiresResize) ((MiceTabLabel) w).getWidget()).onResize();
        }
    } else
        add(new MiceTabLabel(w.getTitle() != null && !w.getTitle().isEmpty() ? w.getTitle() : "&nbsp;", w));
}

From source file:com.github.gwt.sample.showcase.client.Showcase.java

License:Apache License

private void bindHistory(final SingleSelectionModel<Widget> selectionModel,
        final LeftMenuTreeViewModel treeModel) {

    // Setup a history handler to reselect the associate menu item.
    final CellTree mainMenu = showCase.getMainMenu();

    // Change the history token when a main menu item is selected.
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            Widget selected = selectionModel.getSelectedObject();
            if (selected != null) {
                History.newItem(selected.getTitle(), true);
            }//from www . j  av  a2 s .c om
        }
    });

    final ValueChangeHandler<String> historyHandler = new ValueChangeHandler<String>() {
        public void onValueChange(ValueChangeEvent<String> event) {
            // Get the content widget associated with the history token.
            Widget contentWidget = treeModel.getWidget(event.getValue());
            if (contentWidget == null) {
                return;
            }

            // Expand the tree node associated with the content.
            LeftMenuTreeViewModel.Category category = treeModel.getCategoryForWidget(contentWidget);
            TreeNode node = mainMenu.getRootTreeNode();
            int childCount = node.getChildCount();
            for (int i = 0; i < childCount; i++) {
                if (node.getChildValue(i) == category) {
                    node.setChildOpen(i, true, true);
                    break;
                }
            }

            // Select the node in the tree.
            selectionModel.setSelected(contentWidget, true);

            // Display the content widget.
            displayContentWidget(contentWidget);
        }

        /**
         * Set the content to the {@link com.google.gwt.user.client.ui.Widget}.
         *
         * @param content the {@link com.google.gwt.user.client.ui.Widget} to display
         */
        private void displayContentWidget(Widget content) {
            if (content == null) {
                return;
            }

            showCase.setContent(content);
            Window.setTitle("Showcase of Features: " + content.getTitle());
        }
    };
    History.addValueChangeHandler(historyHandler);
}

From source file:com.gmail.cjbooms.thesis.pythonappengine.client.menus.Toolbar.java

License:Open Source License

private int getButtonIndex(String title) {
    for (int i = 0; i < buttons.size(); i++) {
        Widget w = buttons.get(i);
        if (w.getTitle().equals(title)) {
            return i;
        }/*from  www. ja  v a  2  s .  c  om*/
    }
    return -1;
}

From source file:com.nabla.wapp.client.ui.ListGridToolbarMenu.java

License:Apache License

@Override
public void add(final Widget w) {
    Assert.argumentNotNull(w);/* w w  w  . j av  a 2s.com*/

    if (w instanceof Menu) {
        final com.smartgwt.client.widgets.menu.MenuItem proxy = new com.smartgwt.client.widgets.menu.MenuItem(
                w.getTitle());
        proxy.setSubmenu((Menu) w);
        proxy.setTitle(((com.nabla.wapp.client.ui.Menu) w).getTitle());
        proxy.setIcon(((com.nabla.wapp.client.ui.Menu) w).getIcon());
        menu.addItem(proxy);
    } else if (w instanceof MenuItem)
        menu.addItem(((MenuItem) w).getImpl());
    else if (w instanceof MenuItemSeparator)
        menu.addItem(((MenuItemSeparator) w).getImpl());
    else {
        logger.log(Level.SEVERE, "adding a widget of type '" + w.getClass().toString() + "' to a "
                + Util.getClassSimpleName(this.getClass()) + " is not supported");
    }
}

From source file:com.nabla.wapp.client.ui.MenuButton.java

License:Apache License

@Override
public void add(Widget w) {
    Assert.argumentNotNull(w);//from  w w w. j  a va 2  s  .co  m

    if (w instanceof Menu) {
        final com.smartgwt.client.widgets.menu.MenuItem proxy = new com.smartgwt.client.widgets.menu.MenuItem(
                w.getTitle());
        proxy.setSubmenu((Menu) w);
        proxy.setTitle(((com.nabla.wapp.client.ui.Menu) w).getTitle());
        proxy.setIcon(((com.nabla.wapp.client.ui.Menu) w).getIcon());
        menu.addItem(proxy);
    } else if (w instanceof MenuItem)
        menu.addItem(((MenuItem) w).getImpl());
    else if (w instanceof MenuItemSeparator)
        menu.addItem(((MenuItemSeparator) w).getImpl());
    else {
        log.log(Level.SEVERE, "adding a widget of type '" + w.getClass().toString() + "' to a "
                + Util.getClassSimpleName(this.getClass()) + " is not supported");
    }
}

From source file:com.qualogy.qafe.gwt.client.ui.GWTUIGenerator.java

License:Apache License

private static void addToDockPanel(final WindowGVO windowGVO, final String uuid, final String title,
        final String appId) {
    if (windowGVO != null && windowGVO.getIcon() != null && windowGVO.getIcon().length() > 0) {
        final String windowId = windowGVO.getId();
        final Image dockImage = new Image(windowGVO.getIcon());
        dockImage.setTitle(title);/* www.  java2s  .c  o  m*/
        //dockImage.setHeight(60 + "px");
        //dockImage.setWidth(40 + "px");
        dockImage.setStylePrimaryName("dockItem");
        fillInMandatoryOnly(windowGVO, dockImage, uuid, windowId, appId);

        dockImage.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                WindowPanel existingWindowPanel = ClientApplicationContext.getInstance()
                        .windowIdExists(windowId, uuid);
                if (existingWindowPanel == null) {
                    EventListenerGVO[] events = windowGVO.getEvents();
                    if (events != null) {
                        String eventType = QAMLConstants.EVENT_ONCLICK;
                        for (EventListenerGVO eventGVO : events) {
                            if (eventGVO.getEventComponentId().equals(windowId)
                                    && eventGVO.getEventListenerType().equals(eventType)) {
                                createCallBack4OpenWindow(dockImage, eventType, eventGVO);
                                break;
                            }
                        }
                    }
                    //                  MainFactoryActions.getUIByUUID(uuid, windowId);
                } else {
                    Iterator itr = ClientApplicationContext.getInstance().getHorizontalPanel().iterator();
                    while (itr.hasNext()) {
                        Widget w = (Widget) itr.next();
                        if (w.getTitle().equals(title)) {
                            existingWindowPanel.setWindowState(WindowState.NORMAL);
                            existingWindowPanel.show();
                            ClientApplicationContext.getInstance().getHorizontalPanel().remove(w);
                        }
                    }
                    existingWindowPanel.toFront();
                }
            }
        });

        if (ClientApplicationContext.getInstance().getDockPanel() != null) {
            ClientApplicationContext.getInstance().getDockPanel().add(dockImage);
            int dockWidth = ClientApplicationContext.getInstance().getDockPanel().getOffsetWidth();
            DOM.setStyleAttribute(ClientApplicationContext.getInstance().getDockPanel().getElement(), "left",
                    Window.getClientWidth() / 2 - (dockWidth / 2) + "");
        }
    }
}

From source file:com.qualogy.qafe.gwt.client.ui.GWTUIGenerator.java

License:Apache License

private static void createDesktopIcon(final WindowGVO windowGVO, final String uuid, final String title,
        final String appId) {
    if (windowGVO != null && windowGVO.getIcon() != null && windowGVO.getIcon().length() > 0) {
        final String windowId = windowGVO.getId();
        final DesktopIcon desktopIcon = new DesktopIcon(windowGVO.getIcon(), title);
        fillInMandatoryOnly(windowGVO, desktopIcon, uuid, windowId, appId);

        desktopIcon.addDoubleClickHandler(new DoubleClickHandler() {

            public void onDoubleClick(DoubleClickEvent event) {
                // ClientApplicationContext.getInstance().removeWindow(windowId,
                // uuid);
                WindowPanel existingWindowPanel = ClientApplicationContext.getInstance()
                        .windowIdExists(windowId, uuid);
                if (existingWindowPanel == null) {
                    EventListenerGVO[] events = windowGVO.getEvents();
                    if (events != null) {
                        String eventType = QAMLConstants.EVENT_ONCLICK;
                        for (EventListenerGVO eventGVO : events) {
                            if (eventGVO.getEventComponentId().equals(windowId)
                                    && eventGVO.getEventListenerType().equals(eventType)) {
                                createCallBack4OpenWindow(desktopIcon, eventType, eventGVO);
                                break;
                            }/*from w  w  w.  ja v  a  2 s  .c o m*/
                        }
                    }
                    //                  MainFactoryActions.getUIByUUID(uuid, windowId);
                } else {
                    Iterator itr = ClientApplicationContext.getInstance().getHorizontalPanel().iterator();
                    while (itr.hasNext()) {
                        Widget w = (Widget) itr.next();
                        if (w.getTitle().equals(title)) {
                            existingWindowPanel.setWindowState(WindowState.NORMAL);
                            existingWindowPanel.show();
                            ClientApplicationContext.getInstance().getHorizontalPanel().remove(w);
                        }
                    }
                    existingWindowPanel.toFront();
                }

            }
        });
        ClientApplicationContext.getInstance().getDragController().makeDraggable(desktopIcon,
                desktopIcon.getTitleLabel());
        ClientApplicationContext.getInstance().addDesktopIcon(desktopIcon);
    }
}

From source file:com.qualogy.qafe.gwt.client.ui.GWTUIGenerator.java

License:Apache License

private static MenuItem createMenuItem(final String title, final String uuid, final String windowId,
        final UIGVO uiGVO, final boolean tryMe) {
    final MenuItem menuItem = new MenuItem(title, (Command) null);
    MenuItemGVO menuItemGVO = new MenuItemGVO();
    menuItemGVO.setId(windowId);/*from   w w w .  j  a  va 2s  . co  m*/
    RendererHelper.fillIn(menuItemGVO, menuItem, uuid, null, uiGVO.getAppId());

    Command command = new Command() {
        public void execute() {

            if (ClientApplicationContext.getInstance().isDesktopNotificationPossible()
                    && Notification.isNotificationNotAllowed()) {
                Notification.requestPermission();
            }

            // ClientApplicationContext.getInstance().removeWindow(windowId,
            // uuid);
            WindowPanel existingWindowPanel = ClientApplicationContext.getInstance().windowIdExists(windowId,
                    uuid);
            if (existingWindowPanel == null) {
                if (tryMe) {
                    MainFactoryActions.getUIByUUID(uuid, windowId);
                } else {
                    String eventType = QAMLConstants.EVENT_ONCLICK;
                    EventListenerGVO eventGVO = uiGVO.getEventMap().get(windowId);
                    createCallBack4OpenWindow(menuItem, eventType, eventGVO);
                }
                // MainFactoryActions.getUIByUUID(uuid, windowId);
            } else {
                Iterator itr = ClientApplicationContext.getInstance().getHorizontalPanel().iterator();
                while (itr.hasNext()) {
                    Widget w = (Widget) itr.next();
                    if (w.getTitle().equals(title)) {
                        existingWindowPanel.setWindowState(WindowState.NORMAL);
                        existingWindowPanel.show();
                        ClientApplicationContext.getInstance().getHorizontalPanel().remove(w);
                    }
                }
                existingWindowPanel.toFront();
            }
        }

    };
    menuItem.setCommand(command);

    return menuItem;
}

From source file:org.pentaho.pat.client.ui.panels.MainTabPanel.java

License:Open Source License

/**
 * Adds a new Tab to the contentPanel.//from  w ww. j  a va 2 s  . c  om
 * 
 * @param content
 * @param tabName
 */
public static void addContent(final AbstractDataWidget content, String tabName) {

    if (content != null) {

        Integer countName = 0;
        Boolean done = false;
        List<String> tabnames = new ArrayList<String>();

        for (Widget widget : CONTENTWRAPPER) {
            if (widget.getTitle() != null && widget.getTitle().length() > 0) {
                tabnames.add(widget.getTitle());
            }
        }
        while (!done) {
            done = true;
            if (tabnames.contains(tabName) && countName == 0) {
                countName++;
                done = false;
            }
            if (tabnames.contains(tabName + " (" + countName + ")")) {
                countName++;
                done = false;
            }

        }

        if (countName > 0) {
            tabName = tabName + " (" + countName + ")";
        }
        content.setTitle(tabName);

        if (Pat.getApplicationState().getMode().equals(State.Mode.ONECUBE)) {
            CONTENTWRAPPER.add(content, tabName);
        } else {
            CONTENTWRAPPER.add(content, tabCloseLabel(content, tabName));
        }
        CONTENTWRAPPER.selectTab(counter);
        counter++;
        CONTENTWRAPPER.layout();
    }

}