Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.cdlflex.ui.markup.html.repeater.data.table;
 
 import static org.rauschig.wicketjs.JsExpression.THIS;
 import static org.rauschig.wicketjs.jquery.JQuery.$;
 
 import java.util.List;
 
A Column that provides a menu of actions for a given row model.

Parameters:
<T> the type of the object that will be rendered in this column's cells
<S> the type of the sort property
 
 public abstract class ActionsColumn<T, S> extends DataTableColumn<T, S> {
 
     private static final long serialVersionUID = 1L;
 
     private IModel<StringbuttonDisplayModel;
     private IModel<IconTypebuttonIconTypeModel;
 
     public ActionsColumn(IModel<StringcolumnDisplayModel) {
         this(columnDisplayModel, Model.of(""), (IconTypenull);
     }
 
     public ActionsColumn(IModel<StringcolumnDisplayModelIModel<StringbuttonDisplayModel) {
         this(columnDisplayModelbuttonDisplayModel, (IconTypenull);
     }
 
     protected ActionsColumn(IModel<StringdisplayModelIconType buttonIconType) {
         this(displayModel, Model.of(""), Model.of(buttonIconType));
     }
 
     protected ActionsColumn(IModel<StringdisplayModelIModel<StringbuttonDisplayModelIconType buttonIconType) {
         this(displayModelbuttonDisplayModel, Model.of(buttonIconType));
     }
 
     public ActionsColumn(IModel<StringdisplayModelIModel<StringbuttonDisplayModel,
             IModel<IconTypebuttonIconTypeModel) {
         super(displayModel);
         this. = buttonDisplayModel;
         this. = buttonIconTypeModel;
     }
 
     @Override
     public String getCssClass() {
         return "action-column";
     }
 
     @Override
     public boolean isSortable() {
         return false;
     }
 
     public IModel<StringgetButtonDisplayModel() {
         return ;
     }
 
     public IModel<IconTypegetButtonIconTypeModel() {
         return ;
     }
 
     @Override
     protected void populateItem(DataTableCell<T, S> cellString componentId) {
         DropDownButton dropDownButton = newDropDownButton(componentIdcell.getRowModel(), cell);
 
         dropDownButton.setIconType(getButtonIconTypeModel().getObject());
 
         cell.add(dropDownButton);
     }

    
Creates the drop-down button that stores the actions.

Parameters:
componentId the component id for the button
rowModel the model of the row the button is created for
cell the actual cell item
Returns:
a new drop down button
    protected DropDownButton newDropDownButton(String componentIdfinal IModel<T> rowModel,
        final DataTableCell<T, S> cell) {
        return new DropDownButton(componentIdgetButtonDisplayModel(), getButtonIconTypeModel()) {
            private static final long serialVersionUID = 1L;
            @Override
            protected List<AbstractLinknewSubMenuButtons(String id) {
                return createActions(idrowModelcell);
            }
            @Override
            protected void onInitialize() {
                super.onInitialize();
                onDropDownButtonInitialize(thisrowModel);
            }
        };
    }

    
Called by onInitialize of the DropDownButton for each row.

Parameters:
button the button being initialized
model the row model
    protected void onDropDownButtonInitialize(DropDownButton buttonIModel<T> model) {
        // hook
    }

    
Returns a list of AbstractLink objects that can be selected from the drop-down menu.

Parameters:
componentId the component id the links should all have
rowModel the model of the row the button is created for
cell the actual cell item
Returns:
a list of Links
    protected abstract List<AbstractLinkcreateActions(String componentIdfinal IModel<T> rowModel,
        DataTableCell<T, S> cell);

    
Behavior that is used in combination with ActionColumn that should have toggled visibility on mouse hover.
    public static class ToggleOnHoverBehavior extends JsBehavior {
        private static final long serialVersionUID = 1L;
        @Override
        protected IJavaScript domReadyJs() {
            return new JsStatements($("tr .action-column .dropdown"this).addClass("invisible"), $("tr"this).on(
                    "mouseenter mouseleave"$(".action-column .dropdown").toggleClass("invisible")));
        }
    }
New to GrepCode? Check out our FAQ X