Search in sources :

Example 11 with FillToolItem

use of com.extjs.gxt.ui.client.widget.toolbar.FillToolItem in project jahia by Jahia.

the class UrlMappingEditor method onRender.

@Override
protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setHeight(610);
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
    ColumnConfig column = new ColumnConfig();
    column.setId("url");
    column.setHeaderHtml(Messages.get("label_url", "URL"));
    TextField<String> text = new TextField<String>();
    text.setAllowBlank(false);
    text.setMaxLength(250);
    CellEditor ce = new CellEditor(text);
    ce.addListener(Events.BeforeComplete, new Listener<EditorEvent>() {

        public void handleEvent(EditorEvent be) {
            Window.alert((String) be.getValue());
            be.stopEvent();
        }
    });
    column.setEditor(ce);
    configs.add(column);
    final CheckColumnConfig defaultColumn;
    final CheckColumnConfig activeColumn;
    if (editable) {
        defaultColumn = new CheckColumnConfig("default", Messages.get("label.urlmapping.default", "Default"), 70);
        defaultColumn.setEditor(new CellEditor(new CheckBox()));
        activeColumn = new CheckColumnConfig("active", Messages.get("label.urlmapping.active", "Active"), 55);
        activeColumn.setEditor(new CellEditor(new CheckBox()));
    } else {
        defaultColumn = new CheckColumnConfig("default", Messages.get("label.urlmapping.default", "Default"), 70) {

            protected String getCheckState(ModelData model, String property, int rowIndex, int colIndex) {
                return "-disabled";
            }
        };
        activeColumn = new CheckColumnConfig("active", Messages.get("label.urlmapping.active", "Active"), 55) {

            protected String getCheckState(ModelData model, String property, int rowIndex, int colIndex) {
                return "-disabled";
            }
        };
    }
    configs.add(defaultColumn);
    configs.add(activeColumn);
    column = new ColumnConfig("actions", "", 100);
    column.setAlignment(HorizontalAlignment.CENTER);
    column.setRenderer(new GridCellRenderer<GWTJahiaUrlMapping>() {

        public Object render(GWTJahiaUrlMapping modelData, String s, ColumnData columnData, final int rowIndex, final int colIndex, ListStore<GWTJahiaUrlMapping> listStore, Grid<GWTJahiaUrlMapping> grid) {
            Button button = new Button(Messages.get("label_remove", "Remove"), new SelectionListener<ButtonEvent>() {

                @Override
                public void componentSelected(ButtonEvent buttonEvent) {
                    store.remove(store.getAt(rowIndex));
                }
            });
            button.addStyleName("button-remove");
            button.setIcon(StandardIconsProvider.STANDARD_ICONS.minusRound());
            button.setEnabled(editable);
            return button;
        }
    });
    column.setFixed(true);
    configs.add(column);
    final RowEditor<GWTJahiaUrlMapping> re = new RowEditor<GWTJahiaUrlMapping>();
    // Add a cancel edit event listener to remove empty line
    re.addListener(Events.CancelEdit, new Listener<RowEditorEvent>() {

        public void handleEvent(RowEditorEvent ree) {
            GWTJahiaUrlMapping urlMapping = store.getModels().get(ree.getRowIndex());
            if (urlMapping.getUrl().length() == 0) {
                store.remove(ree.getRowIndex());
            }
        }
    });
    re.addListener(Events.ValidateEdit, new Listener<RowEditorEvent>() {

        public void handleEvent(RowEditorEvent ree) {
            if (ree.getChanges().get("url").toString().matches("/sites")) {
                ree.setCancelled(true);
                store.remove(ree.getRowIndex());
                Window.alert(Messages.get("label.urlmapping.error.contains.sites", "SEO Url should not contains /sites as it is used by the system."));
            }
        }
    });
    final Grid<GWTJahiaUrlMapping> grid = new Grid<GWTJahiaUrlMapping>(store, new ColumnModel(configs));
    grid.setAutoExpandColumn("url");
    grid.setBorders(true);
    grid.addPlugin(defaultColumn);
    grid.addPlugin(activeColumn);
    if (editable) {
        grid.addPlugin(re);
    }
    store.addStoreListener(new StoreListener<GWTJahiaUrlMapping>() {

        @Override
        public void storeUpdate(StoreEvent<GWTJahiaUrlMapping> se) {
            super.storeUpdate(se);
            if (se.getOperation() == RecordUpdate.EDIT && se.getModel().isDefault()) {
                clearOtherDefaults(se.getModel(), se.getStore());
            }
        }

        private void clearOtherDefaults(GWTJahiaUrlMapping model, Store<? extends GWTJahiaUrlMapping> store) {
            for (GWTJahiaUrlMapping data : store.getModels()) {
                if (data.isDefault() && !data.equals(model)) {
                    grid.getStore().getRecord(data).set(defaultColumn.getDataIndex(), Boolean.FALSE);
                }
            }
        }
    });
    ToolBar toolBar = new ToolBar();
    Button add = new Button(Messages.get("label.add", "Add"), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            re.stopEditing(false);
            GWTJahiaUrlMapping mapping = new GWTJahiaUrlMapping("", locale, store.getCount() == 0, true);
            store.insert(mapping, 0);
            re.startEditing(store.indexOf(mapping), true);
        }
    });
    add.addStyleName("button-add");
    add.setIcon(StandardIconsProvider.STANDARD_ICONS.plusRound());
    add.setEnabled(editable);
    toolBar.add(add);
    if (URL.getServerBaseURL().startsWith("http://localhost:") || URL.getServerBaseURL().startsWith("https://localhost:")) {
        toolBar.add(new FillToolItem());
        LabelField warningLabel = new LabelField(Messages.get("label.urlmapping.inactiveOnLocalhost", "URL mapping is inactive for server-name: localhost"));
        warningLabel.setStyleAttribute("color", "red");
        toolBar.add(warningLabel);
    }
    ContentPanel cp = new ContentPanel(new FitLayout());
    cp.setHeadingHtml("<div class='seo-title'>" + Messages.get("ece_seo_urlMapping", "URL mapping") + "</div><div class='seo-title-path'>" + node.getUrl() + "</div>");
    // cp.setHeaderVisible(false);
    cp.setTopComponent(toolBar);
    cp.add(grid);
    // FieldSet fs = new FieldSet();
    setLayout(new FitLayout());
    // fs.setHeadingHtml(Messages.get("ece_seo_urlMapping", "URL mapping"));
    // fs.setCollapsible(true);
    // 
    // fs.add(cp);
    add(cp);
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) ArrayList(java.util.ArrayList) Button(com.extjs.gxt.ui.client.widget.button.Button) TextField(com.extjs.gxt.ui.client.widget.form.TextField) LabelField(com.extjs.gxt.ui.client.widget.form.LabelField) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout) GWTJahiaUrlMapping(org.jahia.ajax.gwt.client.data.seo.GWTJahiaUrlMapping) ContentPanel(com.extjs.gxt.ui.client.widget.ContentPanel) CheckBox(com.extjs.gxt.ui.client.widget.form.CheckBox) ToolBar(com.extjs.gxt.ui.client.widget.toolbar.ToolBar) FillToolItem(com.extjs.gxt.ui.client.widget.toolbar.FillToolItem)

Example 12 with FillToolItem

use of com.extjs.gxt.ui.client.widget.toolbar.FillToolItem in project geo-platform by geosdi.

the class SessionLoginWidget method addStatusComponent.

@Override
public void addStatusComponent() {
    status = new LoginStatus();
    status.setAutoWidth(true);
    getButtonBar().add(status);
    getButtonBar().add(new FillToolItem());
}
Also used : EnumLoginStatus(org.geosdi.geoplatform.gui.client.widget.LoginStatus.EnumLoginStatus) FillToolItem(com.extjs.gxt.ui.client.widget.toolbar.FillToolItem)

Example 13 with FillToolItem

use of com.extjs.gxt.ui.client.widget.toolbar.FillToolItem in project geo-platform by geosdi.

the class DisplayServerWidget method createToolBar.

private void createToolBar() {
    this.toolbar = new ToolBar();
    this.searchStatus = new SearchStatus();
    searchStatus.setAutoWidth(true);
    this.toolbar.add(this.searchStatus);
    this.toolbar.add(this.comboServer);
    this.toolbar.add(new SeparatorToolItem());
    toolbar.add(new FillToolItem());
    this.toolbar.add(this.manageServersButton);
}
Also used : EnumSearchStatus(org.geosdi.geoplatform.gui.client.widget.SearchStatus.EnumSearchStatus) SeparatorToolItem(com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem) ToolBar(com.extjs.gxt.ui.client.widget.toolbar.ToolBar) FillToolItem(com.extjs.gxt.ui.client.widget.toolbar.FillToolItem)

Example 14 with FillToolItem

use of com.extjs.gxt.ui.client.widget.toolbar.FillToolItem in project geo-platform by geosdi.

the class GridLayersWidget method initFormPanel.

private void initFormPanel() {
    this.formPanel = new FormPanel();
    this.formPanel.setHeaderVisible(false);
    this.formPanel.setFrame(true);
    this.formPanel.setLayout(new FlowLayout());
    this.formPanel.setTopComponent(this.displayServerWidget.getToolbar());
    this.formPanel.add(this.grid);
    StoreFilterField<L> filter = this.createFilter();
    filter.setToolTip(ServerModuleConstants.INSTANCE.GridLayersWidget_filterTooltipText());
    filter.bind(super.store);
    this.formPanel.setButtonAlign(HorizontalAlignment.LEFT);
    this.formPanel.getButtonBar().add(filter);
    this.formPanel.getButtonBar().add(new FillToolItem());
    this.done = new Button(ButtonsConstants.INSTANCE.doneText(), AbstractImagePrototype.create(BasicWidgetResources.ICONS.done()));
    this.done.addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            expander.executeActionRequest();
        }
    });
    this.done.disable();
    this.formPanel.getButtonBar().add(this.done);
}
Also used : FlowLayout(com.extjs.gxt.ui.client.widget.layout.FlowLayout) FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) Button(com.extjs.gxt.ui.client.widget.button.Button) FillToolItem(com.extjs.gxt.ui.client.widget.toolbar.FillToolItem)

Example 15 with FillToolItem

use of com.extjs.gxt.ui.client.widget.toolbar.FillToolItem in project geo-platform by geosdi.

the class ManageRolesWidget method createToolbar.

private void createToolbar() {
    ToolBar toolbar = new ToolBar();
    rolesComboBox = new SimpleComboBox<String>() {

        @Override
        protected void onSelect(SimpleComboValue<String> model, int index) {
            super.onSelect(model, index);
            role = model.getValue();
            loadPermissions();
        }
    };
    rolesComboBox.setEmptyText(UserModuleConstants.INSTANCE.ManageRolesWidget_rolePermissionsText());
    rolesComboBox.setToolTip(new ToolTipConfig(rolesComboBox.getEmptyText(), UserModuleConstants.INSTANCE.ManageRolesWidget_rolePermissionsTooltipText()));
    rolesComboBox.setMaxHeight(150);
    rolesComboBox.setEditable(false);
    rolesComboBox.setTypeAhead(true);
    rolesComboBox.setTriggerAction(TriggerAction.ALL);
    toolbar.add(rolesComboBox);
    allPermissionsButton = new SplitButton(UserModuleConstants.INSTANCE.ManageRolesWidget_allPermissionsToText());
    allPermissionsButton.setToolTip(new ToolTipConfig(allPermissionsButton.getHtml(), UserModuleConstants.INSTANCE.ManageRolesWidget_rolePermissionsToASinglePermissionText()));
    allPermissionsButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
    allPermissionsButton.setMenu(this.createPermissionsMenu());
    toolbar.add(allPermissionsButton);
    copyPermissionsButton = new Button(UserModuleConstants.INSTANCE.ManageRolesWidget_copyPermissionsText());
    copyPermissionsButton.setToolTip(new ToolTipConfig(copyPermissionsButton.getHtml(), UserModuleConstants.INSTANCE.ManageRolesWidget_copyPermissionsTooltipText()));
    copyPermissionsButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
    copyPermissionsButton.setMenu(this.createRolesMenu());
    toolbar.add(copyPermissionsButton);
    this.disableModifyButtons();
    toolbar.add(new FillToolItem());
    toolbar.add(new SeparatorToolItem());
    Button newRoleButton = new Button(UserModuleConstants.INSTANCE.ManageRolesWidget_newRoleText(), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            createNewRole();
        }
    });
    newRoleButton.setToolTip(new ToolTipConfig(newRoleButton.getHtml(), UserModuleConstants.INSTANCE.ManageRolesWidget_newRoleTooltipText()));
    toolbar.add(newRoleButton);
    mainPanel.setTopComponent(toolbar);
}
Also used : SeparatorToolItem(com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem) SplitButton(com.extjs.gxt.ui.client.widget.button.SplitButton) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) SplitButton(com.extjs.gxt.ui.client.widget.button.SplitButton) ToolBar(com.extjs.gxt.ui.client.widget.toolbar.ToolBar) ToolTipConfig(com.extjs.gxt.ui.client.widget.tips.ToolTipConfig) FillToolItem(com.extjs.gxt.ui.client.widget.toolbar.FillToolItem)

Aggregations

FillToolItem (com.extjs.gxt.ui.client.widget.toolbar.FillToolItem)24 Button (com.extjs.gxt.ui.client.widget.button.Button)20 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)18 Status (com.extjs.gxt.ui.client.widget.Status)12 SelectionListener (com.extjs.gxt.ui.client.event.SelectionListener)9 FormPanel (com.extjs.gxt.ui.client.widget.form.FormPanel)8 FieldSet (com.extjs.gxt.ui.client.widget.form.FieldSet)7 ToolBar (com.extjs.gxt.ui.client.widget.toolbar.ToolBar)7 LabelField (com.extjs.gxt.ui.client.widget.form.LabelField)6 FlowLayout (com.extjs.gxt.ui.client.widget.layout.FlowLayout)6 FormLayout (com.extjs.gxt.ui.client.widget.layout.FormLayout)6 TextField (com.extjs.gxt.ui.client.widget.form.TextField)5 FormData (com.extjs.gxt.ui.client.widget.layout.FormData)5 SeparatorToolItem (com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem)4 SplitButton (com.extjs.gxt.ui.client.widget.button.SplitButton)3 NumberField (com.extjs.gxt.ui.client.widget.form.NumberField)3 SimpleComboBox (com.extjs.gxt.ui.client.widget.form.SimpleComboBox)3 ModelData (com.extjs.gxt.ui.client.data.ModelData)2 ComponentEvent (com.extjs.gxt.ui.client.event.ComponentEvent)2 MenuEvent (com.extjs.gxt.ui.client.event.MenuEvent)2