001package org.gwtbootstrap3.extras.summernote.client.ui.base; 002 003/* 004 * #%L 005 * GwtBootstrap3 006 * %% 007 * Copyright (C) 2015 GwtBootstrap3 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023import java.util.ArrayList; 024import java.util.List; 025 026import com.google.gwt.core.client.JsArrayMixed; 027 028/** 029 * Wrapper for the Summernote WYSIWYG Editor 030 * <p/> 031 * See: http://summernote.org/ 032 * 033 * @author Xiaodong Sun 034 */ 035public class Toolbar { 036 037 private static final String GROUP_PREFIX = "group_"; 038 private static int GROUP_INDEX = 0; 039 private List<JsArrayMixed> groups = new ArrayList<>(0); 040 041 /** 042 * Add a new toolbar group with the specified buttons. 043 * 044 * @param buttons the toolbar buttons to be added 045 * @return {@link Toolbar} 046 */ 047 public Toolbar addGroup(ToolbarButton... buttons) { 048 groups.add(SummernoteOptions.newToolbarGroup(GROUP_PREFIX + GROUP_INDEX++, buttons)); 049 return this; 050 } 051 052 JsArrayMixed build() { 053 return SummernoteOptions.buildToolbar(groups.toArray(new JsArrayMixed[0])); 054 } 055} 056