/** * Constructor. * * @param messages Localized messages. * @param label Label. */ public PortalInheritableFlagComboBox(PmsMessages messages, String label) { final Map<PortalInheritableFlag, String> m = new HashMap<PortalInheritableFlag, String>(); m.put(PortalInheritableFlag.ON, messages.valueYes()); m.put(PortalInheritableFlag.OFF, messages.valueNo()); m.put(PortalInheritableFlag.INHERIT, messages.valueInherit()); this.map = Collections.unmodifiableMap(m); setFieldLabel(label); setTriggerAction(TriggerAction.ALL); setDisplayField(DISPLAY_NAME); setEditable(false); setAllowBlank(false); setStore(newStore()); }
/** Requests the service for the Palette DTOs, and shows the results.<br> */ private void tryGetPalette() { util.mask(pmsMessages.mskPalette()); AsyncCallback<List<PaletteDTO>> callback = new AsyncCallback<List<PaletteDTO>>() { public void onSuccess(List<PaletteDTO> arg0) { List<PaletteModelData> lPaletteModelData = new LinkedList<PaletteModelData>(); for (PaletteDTO dto : arg0) { lPaletteModelData.add(new PaletteModelData(dto)); } sGrid.removeAll(); sGrid.add(lPaletteModelData); util.unmask(); } /* * (non-Javadoc) * * @see com.google.gwt.user.client.rpc.AsyncCallback#onFailure(java.lang.Throwable) */ public void onFailure(Throwable arg0) { util.unmask(); errorProcessor.processError(arg0, null, pmsMessages.msgErrorRetrievePalette()); } }; pagesService.getPalette(portalPagesLoc, callback); }
private void configWindow() { setLayout(new FitLayout()); setLayoutOnChange(true); RootPanel.get().addStyleName(DESIGN_BODY_CSS); setHeadingText(pmsMessages.titleDesignWindow(page.getName())); setMaximizable(true); setModal(true); setSize(600, 500); }
/** * <br> * * @param acceptListener */ public void init(IPaletteComponentsReceiver receiver, PortalPagesLoc portalLocator) { this.componentsReceiver = receiver; this.portalPagesLoc = portalLocator; setHeading(pmsMessages.headerComponentsPalette()); setClosable(true); setWidth(PALETTE_WINDOW_WIDTH); setLayout(new FitLayout()); setScrollMode(Scroll.AUTOY); initComponents(); }
private void initThis() { setLayout(new FitLayout()); String mapString = pmsMessages.mapFilterTypes(); mapFilterTypes = new HashMap<String, String>(); for (String s : mapString.split(",")) { String[] entry = s.trim().split("="); if (!Util.emptyString(entry[0])) { mapFilterTypes.put(entry[0], entry[1]); } } }
/** * Creates, configures and adds the components palette toolbar.<br> * * @param componentsReceiver */ private void addToolbar() { // the toolbar ToolBar gridToolBar = new ToolBar(); setTopComponent(gridToolBar); SelectionListener<ButtonEvent> ttiAddListener = new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { GridSelectionModel<PaletteModelData> selectionModel = gComponents.getSelectionModel(); List<PaletteModelData> lSelected = selectionModel.getSelectedItems(); if (!lSelected.isEmpty()) { componentsReceiver.receiveComponents(lSelected); hide(); selectionModel.deselectAll(); ttiAddSelected.disable(); } } }; ttiAddSelected = buttonsSupport.addGenericButton( pmsMessages.labelAddSelected(), styles.iNew(), gridToolBar, ttiAddListener); ttiAddSelected.disable(); gridToolBar.add(new FillToolItem()); StoreFilterField<PaletteModelData> filter = new CustomizableStoreFilter<PaletteModelData>( Arrays.asList( new String[] { PaletteModelData.PROPERTY_NAME, PaletteModelData.PROPERTY_DESCRIPTION })); filter.setHideLabel(false); filter.setFieldLabel(messages.labelFilter()); filter.bind(sGrid); gridToolBar.add(filter); setTopComponent(gridToolBar); }
/** Creates the gComponents with the list of components and add it to the panel */ private void addGrid() { List<ColumnConfig> configs = new LinkedList<ColumnConfig>(); CheckBoxSelectionModel<PaletteModelData> selectionModel = new CheckBoxSelectionModel<PaletteModelData>(); configs.add(selectionModel.getColumn()); ColumnConfig column = new ColumnConfig(); column.setId(PaletteModelData.PROPERTY_NAME); column.setHeader(pmsMessages.columnHeaderName()); column.setWidth(COLUMN_NAME_WIDTH); // render to show a tooltip column.setRenderer( new GridCellRenderer<PaletteModelData>() { public Object render( PaletteModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<PaletteModelData> store, Grid<PaletteModelData> grid) { String name = (String) model.get(property); Html html = new Html((String) model.get(property)); html.setToolTip(name); html.getToolTip().setAutoWidth(true); return html; } }); configs.add(column); column = new ColumnConfig(); column.setId(PaletteModelData.PROPERTY_DESCRIPTION); column.setHeader(pmsMessages.columnHeaderDescription()); column.setWidth(COLUMN_DESCRIPTION_WIDTH); configs.add(column); ColumnModel cm = new ColumnModel(configs); sGrid = new ListStore<PaletteModelData>(); sGrid.setStoreSorter((StoreSorter) storeSorter); sGrid.setSortField(PaletteModelData.PROPERTY_NAME); gComponents = new Grid<PaletteModelData>(sGrid, cm); gComponents.setSelectionModel(selectionModel); gComponents.addPlugin(selectionModel); gComponents.setAutoExpandColumn(PaletteModelData.PROPERTY_DESCRIPTION); gComponents.setLoadMask(true); gComponents.getView().setForceFit(true); gComponents .getSelectionModel() .addSelectionChangedListener( new SelectionChangedListener<PaletteModelData>() { @Override public void selectionChanged(SelectionChangedEvent<PaletteModelData> se) { if (se.getSelection() != null && !se.getSelection().isEmpty()) { ttiAddSelected.enable(); } else { ttiAddSelected.disable(); } } }); add(gComponents); }
private void addToolBars() { ToolBar toolbar = new ToolBar(); ToolBar bottomToolbar = new ToolBar(); SelectionListener<ButtonEvent> lNew = new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { showcreationPanel(); } }; buttonsSupport.addAddButton(toolbar, lNew); toolbar.add(new SeparatorToolItem()); SelectionListener<ButtonEvent> lEdit = new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { SetFilterModelData selected = grid.getSelectionModel().getSelectedItem(); if (selected != null) { showEditionPanel(selected); } } }; bEdit = buttonsSupport.addEditButton(toolbar, lEdit); bEdit.disable(); toolbar.add(new SeparatorToolItem()); SelectionListener<ButtonEvent> lDelete = new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { Listener<MessageBoxEvent> lConfirm1 = new Listener<MessageBoxEvent>() { public void handleEvent(MessageBoxEvent be) { if (be.getButtonClicked().getItemId().equals(Dialog.YES)) { SetFilterModelData selected = grid.getSelectionModel().getSelectedItem(); if (selected != null) { tryDeleteSetFilter(selected); } } } }; MessageBox.confirm( messages.headerConfirmWindow(), pmsMessages.msgConfirmDeleteSetFilter(), lConfirm1) .setModal(true); } }; bDelete = buttonsSupport.addDeleteButton(toolbar, lDelete); bDelete.disable(); toolbar.add(new SeparatorToolItem()); SelectionListener<ButtonEvent> lDeleteAll = new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { Listener<MessageBoxEvent> lConfirm1 = new Listener<MessageBoxEvent>() { public void handleEvent(MessageBoxEvent be) { if (be.getButtonClicked().getItemId().equals(Dialog.YES)) { tryDeleteAllSetFilter(); } } }; MessageBox.confirm( messages.headerConfirmWindow(), pmsMessages.msgConfirmDeleteAllSetFilter(), lConfirm1) .setModal(true); } }; buttonsSupport.addGenericButton( pmsMessages.labelDeleteAll(), styles.iDelete(), toolbar, lDeleteAll); toolbar.add(new FillToolItem()); SelectionListener<IconButtonEvent> lRefresh = new SelectionListener<IconButtonEvent>() { @Override public void componentSelected(IconButtonEvent ce) { tryGetSetFilters(); } }; buttonsSupport.addRefreshButton(toolbar, lRefresh); SelectionListener<ButtonEvent> lExport = new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { portalsService.exportSetFilters( portalId, new AsyncCallback<String>() { public void onSuccess(String result) { pmsUtil.exportPmsFile(result); } public void onFailure(Throwable caught) { util.error(pmsMessages.msgExportError()); } }); } }; buttonsSupport.addGenericButton( pmsMessages.labelExport(), pmsStyles.exportIcon(), bottomToolbar, lExport); buttonsSupport.addSeparator(bottomToolbar); SelectionListener<ButtonEvent> lImport = new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { PortalImportWindow w = PmsFactory.getInstance().getPortalImportWindow(); w.setPortalId(portalId); w.setPortalImportType(EPortalImportExportType.COLLECTIONS); w.show(); } }; buttonsSupport.addGenericButton( pmsMessages.labelImport(), pmsStyles.importIcon(), bottomToolbar, lImport); setTopComponent(toolbar); setBottomComponent(bottomToolbar); }
private void addGrid() { // Grid bases: List<ColumnConfig> cc = new LinkedList<ColumnConfig>(); ColumnConfig ccName = new ColumnConfig( SetFilterModelData.PROPERTY_NAME, pmsMessages.columnHeaderName(), COLUMN_NAME_WIDTH); cc.add(ccName); ColumnConfig ccDescription = new ColumnConfig( SetFilterModelData.PROPERTY_DESCRIPTION, pmsMessages.columnHeaderDescription(), COLUMN_DESCRIPTION_WIDTH); cc.add(ccDescription); ColumnConfig ccType = new ColumnConfig( SetFilterModelData.PROPERTY_TYPE, pmsMessages.columnHeaderType(), COLUMN_TYPE_WIDTH); ccType.setRenderer( new GridCellRenderer<SetFilterModelData>() { public Object render( SetFilterModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<SetFilterModelData> store, Grid<SetFilterModelData> grid) { if (model.getDTO().getType() != null) { return mapFilterTypes.get(model.getDTO().getType().toString()); } return null; } }); cc.add(ccType); ColumnModel cmOwn = new ColumnModel(cc); ListStore<SetFilterModelData> store = new ListStore<SetFilterModelData>(); grid = new Grid<SetFilterModelData>(store, cmOwn); grid.setAutoExpandColumn(SetFilterModelData.PROPERTY_NAME); grid.setStyleAttribute(BORDER_TOP_KEY, BORDER_TOP_VALUE); GridView gView = grid.getView(); gView.setForceFit(true); grid.getSelectionModel() .addSelectionChangedListener( new SelectionChangedListener<SetFilterModelData>() { @Override public void selectionChanged(SelectionChangedEvent<SetFilterModelData> se) { boolean enabled = false; if (se.getSelectedItem() != null) { enabled = true; } bEdit.setEnabled(enabled); bDelete.setEnabled(enabled); } }); add(grid); }