Example usage for com.google.gwt.user.client.ui Panel add

List of usage examples for com.google.gwt.user.client.ui Panel add

Introduction

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

Prototype

public void add(IsWidget child) 

Source Link

Usage

From source file:ar.com.kyol.jet.client.JetPaginatedTable.java

License:Open Source License

public JetPaginatedTable(boolean useHyperlinks, boolean lazyInit) {
    this.useHyperlinks = useHyperlinks;
    this.lazyInit = lazyInit;
    Panel totalPanel = new VerticalPanel();
    navigationPanel = new HorizontalPanel();
    mainPanel = new AbsolutePanel();
    totalPanel.add(mainPanel);
    this.jetTable = createJetTable();
    mainPanel.add(jetTable);/*from www .j ava 2s .co m*/
    this.qty = getPageSize();
    refresh();
    this.initWidget(totalPanel);
}

From source file:ar.com.kyol.jet.client.JetPaginatedTable.java

License:Open Source License

private void callbackRefresh(List<E> values) {

    int retSize;//from  www.j a va2 s.c o m
    if (values != null)
        retSize = values.size();
    else
        retSize = 0;

    this.qtyRetrieved = retSize;

    this.jetTable.setValues(values);

    this.navigationPanel.clear();
    addNavigationLinks();

    Panel verticalPanel = new VerticalPanel();
    verticalPanel.add(navigationPanel);
    verticalPanel.add(jetTable);

    mainPanel.clear();
    mainPanel.add(verticalPanel);

    tableRefreshed();
}

From source file:cc.alcina.framework.gwt.client.util.ClientUtils.java

License:Apache License

private static void addHidden(Panel p, String key, String value) {
    p.add(new Hidden(key, value));
}

From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java

License:Apache License

public static void replace(Widget current, Widget newWidget, Panel parent) {
    if (parent == null) {
        parent = (Panel) current.getParent();
    }//from ww w . j  a va 2s  .c  o m
    if (current == null || current.getParent() != parent) {
        parent.add(newWidget);
        return;
    }
    if (parent instanceof SimplePanel) {
        ((SimplePanel) parent).setWidget(newWidget);
        return;
    }
    ComplexPanel cp = (ComplexPanel) parent;
    int index = cp.getWidgetIndex(current);
    cp.remove(index);
    if (cp instanceof FlowPanel) {
        FlowPanel fp = (FlowPanel) cp;
        fp.insert(newWidget, index);
    }
}

From source file:com.ait.ext4j.client.ui.Container.java

License:Apache License

/**
 * Add a Component to the Container./*from   w  ww.java  2  s.  co m*/
 * 
 * @param component
 *            the component to add
 */
public void add(Component component) {
    JavaScriptObject componentJS = component.isCreated() ? component.getOrCreateJsObj() : component.getConfig();
    if (layout != null && layout.getSpacing() != null) {
        Panel panel = new Panel();
        panel.setBaseCls("x-plain");
        panel.setBorder(false);
        panel.setBodyStyle(layout.getSpacing());
        panel.add(component);
        componentJS = panel.getConfig();

    }
    if (isCreated()) {
        addPostCreate(componentJS);

    } else {
        addPreCreate(componentJS);
    }
}

From source file:com.ait.ext4j.client.ui.Container.java

License:Apache License

/**
 * Add a Component to the Container./*from  www .  jav a2  s .c om*/
 * 
 * @param component
 *            the component to add
 * @param layoutData
 *            the layout to use when adding the component
 */
public void add(Component component, LayoutData layoutData) {
    if (defaultsHandler != null) {
        defaultsHandler.apply(component);
    }
    JavaScriptObject componentJS = component.isCreated() ? component.getOrCreateJsObj() : component.getConfig();
    // JavaScriptObject componentJS = component.getJsObj();
    JsoHelper.apply(layoutData.getJsObj(), componentJS);
    if (layout != null && layout.getSpacing() != null) {
        Panel panel = new Panel();
        panel.setBaseCls("x-plain");
        panel.setBorder(false);
        panel.setBodyStyle(layout.getSpacing());
        panel.add(component);
        add(panel.getConfig());
    } else {
        add(componentJS);
    }
}

From source file:com.akanoo.client.views.CanvasView.java

License:Apache License

@Override
public void addNote(Note note) {
    // hide tour panel
    createNotePanel.setVisible(false);//  ww w  . ja  v a2s.c  om

    FlowPanel notePanel = new FlowPanel();
    notePanel.addStyleName(resources.canvasStyle().note());

    // note drag and drop
    FocusPanel noteFocusPanel = new FocusPanel();
    noteFocusPanel.addStyleName(resources.canvasStyle().noteFocusPanel());
    notePanel.add(noteFocusPanel);
    // don't pass click events to the canvas
    noteFocusPanel.addClickHandler(clickStopPropagationHandler);

    // flow panel for all note elements
    Panel noteFlowPanel = new FlowPanel();
    noteFocusPanel.add(noteFlowPanel);

    // note body label
    HTML bodyLabel = new HTML();
    bodyLabel.addStyleName(resources.canvasStyle().bodyLabelPosition());
    bodyLabel.addStyleName(resources.canvasStyle().bodyLabel());
    bodyLabel.addClickHandler(new NoteClickHandler(note) {
        @Override
        protected void noteClicked(Note note) {
            CanvasView.this.noteClicked(note, false);
        }
    });
    noteFlowPanel.add(bodyLabel);

    // note back body label
    HTML backBodyLabel = new HTML();
    backBodyLabel.addStyleName(resources.canvasStyle().bodyLabelPosition());
    backBodyLabel.addStyleName(resources.canvasStyle().bodyLabel());
    backBodyLabel.addClickHandler(new NoteClickHandler(note) {
        @Override
        protected void noteClicked(Note note) {
            CanvasView.this.noteClicked(note, true);
        }
    });
    backBodyLabel.setVisible(false);
    noteFlowPanel.add(backBodyLabel);

    // delete note button
    final PushButton deleteNoteButton = new PushButton();
    deleteNoteButton.setStyleName(resources.canvasStyle().deleteNoteButton());
    deleteNoteButton.getUpFace().setImage(new Image(resources.trash()));
    deleteNoteButton.getUpHoveringFace().setImage(new Image(resources.trashHover()));
    deleteNoteButton.setTitle(messages.deleteNoteVerb());
    deleteNoteButton.addClickHandler(new NoteClickHandler(note) {

        @Override
        protected void noteClicked(Note note) {
            getUiHandlers().removeNote(note);
        }
    });
    notePanel.add(deleteNoteButton);

    /*
     * // add resize button PushButton resizeNoteButton = new PushButton();
     * resizeNoteButton.setStyleName(resources.canvasStyle()
     * .resizeNoteButton());
     * resizeNoteButton.setTitle(messages.resizeNoteVerb());
     * notePanel.add(resizeNoteButton);
     */

    canvas.add(notePanel, note.getX(), note.getY());

    // drag and drop notes enabled
    dragController.makeDraggable(notePanel, noteFocusPanel);

    NoteRepresentation representation = new NoteRepresentation();
    representation.note = note;
    representation.notePanel = notePanel;
    representation.bodyLabel = bodyLabel;
    representation.backBodyLabel = backBodyLabel;
    representations.add(representation);

    updateNoteLabels(representation);

    updateCanvasSize();
}

From source file:com.alkacon.acacia.client.EditorBase.java

License:Open Source License

/**
 * Renders the entity form within the given context.<p>
 * // w  w w  .  j ava2s.c  om
 * @param entityId the entity id
 * @param tabInfos the tab informations
 * @param context the context element
 * @param scrollParent the scroll element to be used for automatic scrolling during drag and drop
        
 */
public void renderEntityForm(String entityId, List<TabInfo> tabInfos, Panel context, Element scrollParent) {

    Entity entity = (Entity) m_vie.getEntity(entityId);
    if (entity != null) {
        boolean initUndo = (m_entity == null) || !entity.getId().equals(m_entity.getId());
        m_entity = entity;
        I_Type type = m_vie.getType(m_entity.getTypeName());
        m_formPanel = new FlowPanel();
        context.add(m_formPanel);
        AttributeHandler.setScrollElement(scrollParent);
        ButtonBarHandler.INSTANCE.setWidgetService(m_widgetService);
        if (m_rootHandler == null) {
            m_rootHandler = new RootHandler();
        } else {
            m_rootHandler.clearHandlers();
        }
        m_tabInfos = tabInfos;
        m_formTabs = m_widgetService.getRendererForType(type).renderForm(m_entity, m_tabInfos, m_formPanel,
                m_rootHandler, 0);
        m_validationHandler.registerEntity(m_entity);
        m_validationHandler.setRootHandler(m_rootHandler);
        m_validationHandler.setFormTabPanel(m_formTabs);
        if (initUndo) {
            UndoRedoHandler.getInstance().initialize(m_entity, this, m_rootHandler);
        }
        // trigger validation right away
        m_validationHandler.validate(m_entity);
    }
}

From source file:com.alkacon.acacia.client.EditorBase.java

License:Open Source License

/**
 * Renders the entity form within the given context.<p>
 * /*from  w  w w . j a v  a 2 s  . c  o m*/
 * @param entityId the entity id
 * @param context the context element
 * @param scrollParent the scroll element to be used for automatic scrolling during drag and drop
 */
public void renderEntityForm(String entityId, Panel context, Element scrollParent) {

    Entity entity = (Entity) m_vie.getEntity(entityId);
    if (entity != null) {
        boolean initUndo = (m_entity == null) || !entity.getId().equals(m_entity.getId());
        m_entity = entity;
        I_Type type = m_vie.getType(m_entity.getTypeName());
        m_formPanel = new FlowPanel();
        context.add(m_formPanel);
        AttributeHandler.setScrollElement(scrollParent);
        ButtonBarHandler.INSTANCE.setWidgetService(m_widgetService);
        if (m_rootHandler == null) {
            m_rootHandler = new RootHandler();
        } else {
            m_rootHandler.clearHandlers();
        }
        m_widgetService.getRendererForType(type).renderForm(m_entity, m_formPanel, m_rootHandler, 0);
        m_formTabs = null;
        m_tabInfos = null;
        m_validationHandler.setContentService(m_service);
        m_validationHandler.registerEntity(m_entity);
        m_validationHandler.setRootHandler(m_rootHandler);
        m_validationHandler.setFormTabPanel(null);
        if (initUndo) {
            UndoRedoHandler.getInstance().initialize(m_entity, this, m_rootHandler);
        }
    }
}

From source file:com.alkacon.acacia.client.Renderer.java

License:Open Source License

/**
 * @see com.alkacon.acacia.client.I_EntityRenderer#renderAttributeValue(com.alkacon.vie.shared.I_Entity, com.alkacon.acacia.client.AttributeHandler, int, com.google.gwt.user.client.ui.Panel)
 *///from  w w  w .  java 2 s.c  o m
public void renderAttributeValue(I_Entity parentEntity, AttributeHandler attributeHandler, int attributeIndex,
        Panel context) {

    I_Type entityType = m_vie.getType(parentEntity.getTypeName());
    I_Type attributeType = attributeHandler.getAttributeType();
    String attributeName = attributeHandler.getAttributeName();
    int minOccurrence = entityType.getAttributeMinOccurrence(attributeName);
    I_EntityAttribute attribute = parentEntity.getAttribute(attributeName);
    if ((attribute == null) && (minOccurrence > 0)) {
        attribute = createEmptyAttribute(parentEntity, attributeName, minOccurrence);
    }

    ValuePanel attributeElement = new ValuePanel();
    context.add(attributeElement);
    context.addStyleName(ENTITY_CLASS);
    RootHandler parentHandler = new RootHandler();
    parentHandler.ensureHandlers(attributeIndex);
    parentHandler.setHandler(attributeIndex, attributeName, attributeHandler);
    attributeHandler.setSingleValueIndex(attributeIndex);
    String label = m_widgetService.getAttributeLabel(attributeName);
    String help = m_widgetService.getAttributeHelp(attributeName);
    if (attribute != null) {
        I_EntityRenderer renderer = m_widgetService.getRendererForAttribute(attributeName, attributeType);
        AttributeValueView valueWidget = new AttributeValueView(attributeHandler, label, help);
        if (attributeType.isChoice() && (entityType.getAttributeMaxOccurrence(attributeName) == 1)) {
            valueWidget.setCollapsed(true);
        }
        attributeElement.add(valueWidget);
        if (attribute.isSimpleValue()) {
            valueWidget.setValueWidget(m_widgetService.getAttributeFormWidget(attributeName),
                    attribute.getSimpleValues().get(attributeIndex),
                    m_widgetService.getDefaultAttributeValue(attributeName), true);
            if (m_widgetService.isDisplayCompact(attributeName)) {
                // widget should be displayed in compact view, using only 50% of the available width
                valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_FIRST_COLUMN);
            } else {
                if (m_widgetService.isDisplaySingleLine(attributeName)) {
                    valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_SINGLE_LINE);
                }
            }
        } else {
            valueWidget.setValueEntity(renderer, attribute.getComplexValues().get(attributeIndex));
            if (m_widgetService.isDisplayCompact(attributeName)) {
                valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_NESTED);
            }
        }
        setAttributeChoice(valueWidget, attributeType);
    }
    attributeHandler.updateButtonVisisbility();
}