List of usage examples for com.google.gwt.i18n.client DateTimeFormat getFullDateTimeFormat
@Deprecated public static DateTimeFormat getFullDateTimeFormat()
From source file:com.google.gwt.sample.i18n.client.DateTimeFormatExampleController.java
License:Apache License
@Override protected String doGetPattern(String patternKey) { // Date + Time if ("fullDateTime".equals(patternKey)) { return DateTimeFormat.getFullDateTimeFormat().getPattern(); }/* w ww . j av a2s .c om*/ if ("longDateTime".equals(patternKey)) { return DateTimeFormat.getLongDateTimeFormat().getPattern(); } if ("mediumDateTime".equals(patternKey)) { return DateTimeFormat.getMediumDateTimeFormat().getPattern(); } if ("shortDateTime".equals(patternKey)) { return DateTimeFormat.getShortDateTimeFormat().getPattern(); } // Date only if ("fullDate".equals(patternKey)) { return DateTimeFormat.getFullDateFormat().getPattern(); } if ("longDate".equals(patternKey)) { return DateTimeFormat.getLongDateFormat().getPattern(); } if ("mediumDate".equals(patternKey)) { return DateTimeFormat.getMediumDateFormat().getPattern(); } if ("shortDate".equals(patternKey)) { return DateTimeFormat.getShortDateFormat().getPattern(); } // Time only if ("fullTime".equals(patternKey)) { return DateTimeFormat.getFullTimeFormat().getPattern(); } if ("longTime".equals(patternKey)) { return DateTimeFormat.getLongTimeFormat().getPattern(); } if ("mediumTime".equals(patternKey)) { return DateTimeFormat.getMediumTimeFormat().getPattern(); } if ("shortTime".equals(patternKey)) { return DateTimeFormat.getShortTimeFormat().getPattern(); } throw new IllegalArgumentException("Unknown pattern key '" + patternKey + "'"); }
From source file:java.text.DateFormat.java
License:Apache License
public final static DateFormat getDateTimeInstance(int dateStyle, int timeStyle) { if (dateStyle != timeStyle) { throw new IllegalArgumentException( "Unsupported combinaison of dateStyle & timeStyle : " + dateStyle + "-" + timeStyle); }/*ww w . j a va 2 s . com*/ switch (dateStyle) { case FULL: return new SimpleDateFormat(DateTimeFormat.getFullDateTimeFormat()); case LONG: return new SimpleDateFormat(DateTimeFormat.getLongDateTimeFormat()); case SHORT: return new SimpleDateFormat(DateTimeFormat.getShortDateTimeFormat()); default: return getDateTimeInstance(); } }
From source file:net.s17fabu.vip.gwt.showcase.client.content.i18n.CwDateTimeFormat.java
License:Apache License
/** * Update the selected pattern based on the pattern in the list. *///w ww . j av a 2 s . com private void updatePattern() { switch (patternList.getSelectedIndex()) { // Date + Time case 0: activeFormat = DateTimeFormat.getFullDateTimeFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 1: activeFormat = DateTimeFormat.getLongDateTimeFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 2: activeFormat = DateTimeFormat.getMediumDateTimeFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 3: activeFormat = DateTimeFormat.getShortDateTimeFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; // Date only case 4: activeFormat = DateTimeFormat.getFullDateFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 5: activeFormat = DateTimeFormat.getLongDateFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 6: activeFormat = DateTimeFormat.getMediumDateFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 7: activeFormat = DateTimeFormat.getShortDateFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; // Time only case 8: activeFormat = DateTimeFormat.getFullTimeFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 9: activeFormat = DateTimeFormat.getLongTimeFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 10: activeFormat = DateTimeFormat.getMediumTimeFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 11: activeFormat = DateTimeFormat.getShortTimeFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; // Custom case 12: patternBox.setEnabled(true); String pattern = patternBox.getText(); try { activeFormat = DateTimeFormat.getFormat(pattern); } catch (IllegalArgumentException e) { showErrorMessage(constants.cwDateTimeFormatInvalidPattern()); return; } break; } // Update the formatted value updateFormattedValue(); }
From source file:org.openempi.webapp.client.mvc.entityattribute.EntityAttributeDesignView.java
License:Open Source License
private void buildImportDialog() { if (importDialog != null) { return;/*from ww w . j a v a2 s. c o m*/ } importDialog = new Dialog(); importDialog.setBodyBorder(false); importDialog.setWidth(610); importDialog.setHeight(400); importDialog.setIcon(IconHelper.create("images/import.png")); importDialog.setHeading("Import Entity"); importDialog.setButtons(Dialog.CANCEL); importDialog.setModal(true); importDialog.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { importDialog.hide(); } }); ContentPanel cp = new ContentPanel(); cp.setFrame(false); cp.setHeaderVisible(false); cp.setLayout(new FillLayout()); cp.setSize(600, 340); // Tool bar ToolBar toolBar = new ToolBar(); toolBar.add(new Button("Import Entity", IconHelper.create("images/import.png"), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { List<UserFileWeb> importFileEntries = importFileGrid.getSelectionModel().getSelectedItems(); if (importFileEntries == null || importFileEntries.size() == 0) { Info.display("Information", "You must first select an entry before pressing the Import Entity button."); return; } controller.handleEvent(new AppEvent(AppEvents.FileEntryImport, importFileEntries)); } })); toolBar.add(new SeparatorToolItem()); toolBar.add(new Button("Remove", IconHelper.create("images/folder_delete.png"), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { List<UserFileWeb> importFileEntries = importFileGrid.getSelectionModel().getSelectedItems(); if (importFileEntries == null || importFileEntries.size() == 0) { Info.display("Information", "You must first select an entry before pressing the Remove button."); return; } controller.handleEvent(new AppEvent(AppEvents.FileEntryRemove, importFileEntries)); } })); toolBar.add(new SeparatorToolItem()); toolBar.add(new Button("Refresh", IconHelper.create("images/arrow_refresh.png"), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { showWaitCursor(); controller.handleEvent(new AppEvent(AppEvents.FileListUpdate, null)); } })); cp.setTopComponent(toolBar); // Grid List<ColumnConfig> configs = new ArrayList<ColumnConfig>(); ColumnConfig column = new ColumnConfig(); column.setId("name"); column.setHeader("File Name"); column.setWidth(150); configs.add(column); column = new ColumnConfig("dateCreated", "Date Created", 250); column.setDateTimeFormat(DateTimeFormat.getFullDateTimeFormat()); configs.add(column); column = new ColumnConfig("imported", "Imported?", 70); column.setAlignment(HorizontalAlignment.RIGHT); configs.add(column); ColumnModel cm = new ColumnModel(configs); importFileStore = new ListStore<UserFileWeb>(); importFileGrid = new Grid<UserFileWeb>(importFileStore, cm); importFileGrid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); importFileGrid.setAutoExpandColumn("name"); importFileGrid.setBorders(true); cp.add(importFileGrid); // File upload final FormPanel importPanel = new FormPanel(); importPanel.setFrame(true); String url = GWT.getModuleBaseURL() + "upload"; importPanel.setAction(url); importPanel.setEncoding(Encoding.MULTIPART); importPanel.setMethod(Method.POST); importPanel.setButtonAlign(HorizontalAlignment.CENTER); importPanel.setWidth(580); importPanel.setHeight(100); name = new TextField<String>(); name.setFieldLabel("Name"); name.setName("entity"); name.setAllowBlank(false); importPanel.add(name); importFile = new FileUploadField(); importFile.setAllowBlank(false); importFile.setFieldLabel("File"); importFile.setName("filename"); importPanel.add(importFile); importPanel.addButton(new Button("Upload", new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { if (name.getValue() == null || importFile.getValue() == null) { Info.display("Information", "You must enter a name and filename before pressing the 'Upload' button"); return; } if (existsFileName(name.getValue())) { Info.display("Information", "You already have a file with this name. Please choose another name."); return; } importPanel.submit(); } })); importPanel.addListener(Events.Submit, new Listener<FormEvent>() { public void handleEvent(FormEvent be) { GWT.log("Event is " + be, null); if (!be.getResultHtml().equals("success")) { Info.display("Information", be.getResultHtml()); return; } controller.handleEvent(new AppEvent(AppEvents.FileListUpdate, be.getResultHtml())); } }); cp.add(importPanel); importDialog.add(cp); }
From source file:org.openempi.webapp.client.mvc.user.DatasetView.java
License:Apache License
private void initUI() { long time = new java.util.Date().getTime(); GWT.log("Initializing the UI of DatasetView at " + time, null); componentLoginDialog = new ComponentLoginDialog(controller); componentLoginDialog.setClosable(false); componentLoginDialog.addListener(Events.Hide, new Listener<WindowEvent>() { public void handleEvent(WindowEvent be) { handleImportAndSendOperations(); }//from www. j a va 2s .c o m }); columnInformationsDialog = new ColumnInformationsDialog(); List<ColumnConfig> configs = new ArrayList<ColumnConfig>(); CheckBoxSelectionModel<DatasetWeb> sm = new CheckBoxSelectionModel<DatasetWeb>(); configs.add(sm.getColumn()); ColumnConfig column = new ColumnConfig(); column.setId(DatasetWeb.DATASET_ID); column.setHeader("Id"); column.setWidth(60); configs.add(column); column = new ColumnConfig(); column.setId(DatasetWeb.TABLE_NAME); column.setHeader("Table Name"); column.setWidth(160); configs.add(column); column = new ColumnConfig(); column.setId(DatasetWeb.FILE_NAME); column.setHeader("File Name"); column.setWidth(365); configs.add(column); column = new ColumnConfig(DatasetWeb.DATE_CREATED, "Date Created", 170); column.setAlignment(HorizontalAlignment.RIGHT); column.setDateTimeFormat(DateTimeFormat.getFullDateTimeFormat()); configs.add(column); column = new ColumnConfig(DatasetWeb.IMPORTED, "Imported?", 35); column.setAlignment(HorizontalAlignment.RIGHT); configs.add(column); GridCellRenderer<DatasetWeb> buttonRenderer = new GridCellRenderer<DatasetWeb>() { private boolean init; public Object render(final DatasetWeb selectedDatasetParam, String property, ColumnData config, final int rowIndex, final int colIndex, ListStore<DatasetWeb> store, final Grid<DatasetWeb> gridParam) { if (!init) { init = true; gridParam.addListener(Events.ColumnResize, new Listener<GridEvent<DatasetWeb>>() { public void handleEvent(GridEvent<DatasetWeb> be) { for (int i = 0; i < be.getGrid().getStore().getCount(); i++) { if (be.getGrid().getView().getWidget(i, be.getColIndex()) != null && be.getGrid() .getView().getWidget(i, be.getColIndex()) instanceof BoxComponent) { ((BoxComponent) be.getGrid().getView().getWidget(i, be.getColIndex())) .setWidth(be.getWidth() - 10); } } } }); } Button b = null; if (property.equals(DatasetWeb.SAVE_BUTTON)) { b = new Button("", IconHelper.create("images/disk.png"), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { List<Object> params = new ArrayList<Object>(); params.add(selectedDatasetParam); String tableName = getTableName(); if (tableName == null || tableName.length() <= 0) { Info.display("Information", "Please specify table name for the new dataset."); tableName = ""; // GWT doesn't survive null parameters :P } params.add(tableName); controller.handleEvent(new AppEvent(AppEvents.DatasetSaveToFile, params)); } }); b.setToolTip("Save dataset to a file"); } else if (property.equals(DatasetWeb.COLUMNS_BUTTON)) { b = new Button("", IconHelper.create("images/application_view_columns.png"), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { controller.handleEvent(new AppEvent(AppEvents.DatasetListShowColumnsRequest, selectedDatasetParam.getTableName())); } }); b.setToolTip("View column properties of the dataset"); } else if (property.equals(DatasetWeb.DELETE_BUTTON)) { b = new Button("", IconHelper.create("images/database_delete.png"), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { controller.handleEvent( new AppEvent(AppEvents.DatasetRemove, selectedDatasetParam)); } }); b.setToolTip("Delete dataset including every dependency, cascaded"); } b.setWidth(gridParam.getColumnModel().getColumnWidth(colIndex) - 10); return b; } }; column = new ColumnConfig(); column.setId(DatasetWeb.SAVE_BUTTON); column.setHeader("Save"); column.setWidth(35); column.setRenderer(buttonRenderer); configs.add(column); column = new ColumnConfig(); column.setId(DatasetWeb.COLUMNS_BUTTON); column.setHeader("Columns"); column.setWidth(35); column.setRenderer(buttonRenderer); configs.add(column); column = new ColumnConfig(); column.setId(DatasetWeb.DELETE_BUTTON); column.setHeader("Delete"); column.setWidth(35); column.setRenderer(buttonRenderer); configs.add(column); ColumnModel cm = new ColumnModel(configs); container = new LayoutContainer(); container.setLayout(new CenterLayout()); ContentPanel cp = new ContentPanel(); cp.setHeading("Dataset Management"); cp.setFrame(true); cp.setIcon(IconHelper.create("images/folder.png")); cp.setLayout(new FillLayout()); cp.setSize(1100, 600); toolBar = new ToolBar(); wizardButton = new Button("Wizard", IconHelper.create("images/wand.png"), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { Dispatcher.get().dispatch(AppEvents.FileImportWizardSelected); } }); toolBar.add(wizardButton); cp.setTopComponent(toolBar); Integer wizardMode = (Integer) Registry.get(Constants.WIZARD_MODE); boolean inWizardMode = (wizardMode == Constants.FILE_IMPORT_WIZARD_MODE); if (inWizardMode) toolBar.mask(); store = new ListStore<DatasetWeb>(); grid = new Grid<DatasetWeb>(store, cm); grid.setAutoExpandColumn(DatasetWeb.TABLE_NAME); grid.setStyleAttribute("borderTop", "none"); grid.setStripeRows(true); grid.setBorders(true); cp.add(grid); container.add(cp); final FormPanel panel = new FormPanel(); panel.setFrame(true); String url = GWT.getModuleBaseURL() + "upload"; panel.setAction(url); panel.setEncoding(Encoding.MULTIPART); panel.setMethod(Method.POST); panel.setFrame(true); panel.setButtonAlign(HorizontalAlignment.CENTER); panel.setWidth(350); matchNameEdit = new TextField<String>(); matchNameEdit.setFieldLabel("Match name"); matchNameEdit.setName(PersonMatchWeb.MATCH_TITLE); matchNameEdit.setValidator(new VTypeValidator(VType.ALPHANUMERIC)); panel.add(matchNameEdit); tableNameEdit = new TextField<String>(); tableNameEdit.setFieldLabel("Table Name"); tableNameEdit.setName(DatasetWeb.TABLE_NAME); tableNameEdit.setAllowBlank(false); tableNameEdit.setValidator(new VTypeValidator(VType.ALPHANUMERIC)); panel.add(tableNameEdit); recordLinkageProtocolNameCombo = new ComboBox<ModelPropertyWeb>(); recordLinkageProtocolNameCombo.setEmptyText("Select record linkage protocol..."); recordLinkageProtocolNameCombo.setFieldLabel("Linkage Protocol"); recordLinkageProtocolNameCombo.setForceSelection(true); recordLinkageProtocolNameCombo.setDisplayField("name"); recordLinkageProtocolNameCombo.setWidth(250); recordLinkageProtocolNameCombo.setStore(recordLinkageProtocolNameStore); recordLinkageProtocolNameCombo.setTypeAhead(true); recordLinkageProtocolNameCombo.setTriggerAction(TriggerAction.ALL); recordLinkageProtocolNameCombo.setEditable(false); panel.add(recordLinkageProtocolNameCombo); final FileUploadField file = new FileUploadField(); file.setAllowBlank(false); file.setFieldLabel("File"); file.setName(DatasetWeb.FILE_NAME); panel.add(file); panel.addListener(Events.Submit, new Listener<FormEvent>() { public void handleEvent(FormEvent be) { GWT.log("Event is " + be, null); if (!be.getResultHtml().equals("success")) { Info.display("Information", be.getResultHtml()); return; } controller.handleEvent(new AppEvent(AppEvents.DatasetListUpdateForImport, be.getResultHtml())); } }); panel.addListener(Events.BeforeSubmit, new Listener<FormEvent>() { public void handleEvent(FormEvent be) { GWT.log("Event is " + be, null); } }); if (inWizardMode) { Button previousButton = new Button(Constants.PREVIOUS_PAGE_WIZARD_BUTTON_TEXT, IconHelper.create("images/folder_go.png"), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { Dispatcher.get().dispatch(AppEvents.MatchConfigurationParametersView); } }); panel.addButton(previousButton); } importButton = new Button("Import", new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { String fileName = file.getValue(); if (tableNameEdit.getValue() == null || fileName == null) { Info.display("Information", "You must enter a table name and filename before pressing the 'Import' button"); return; } if (fileName.length() <= 0) { Info.display("Information", "You must enter a filename before pressing the 'Import' button"); return; } if (existsFileName(fileName)) { Info.display("Information", "You already have a file with this name. We'll use that."); } if (existsTable(tableNameEdit.getValue())) { Info.display("Information", "You already have a table with this name. Please choose another name."); return; } panel.submit(); } }); panel.addButton(importButton); sendButton = new Button("Send", IconHelper.create("images/folder_go.png"), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { String recordLinkageProtocolName = ClientUtils .getSelectedStringOfComboBox(recordLinkageProtocolNameCombo); if (recordLinkageProtocolName != null) { if (recordLinkageProtocolName.startsWith("TwoThird")) { componentLoginDialog.startMode(ComponentLoginDialog.LoginDialogMode.PRL2Login); } else if (recordLinkageProtocolName.startsWith("ThreeThird")) { componentLoginDialog.startMode(ComponentLoginDialog.LoginDialogMode.PRL3Login); } else { componentLoginDialog .startMode(ComponentLoginDialog.LoginDialogMode.DataIntegratorLogin); } } else { Info.display("Information", "Couldn't obtain send method"); return; } } }); panel.addButton(sendButton); if (inWizardMode) { exitButton = new Button(Constants.EXIT_WIZARD_BUTTON_TEXT, IconHelper.create("images/folder_delete.png"), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { Dispatcher.get().dispatch(AppEvents.ExitWizardSelected); } }); panel.addButton(exitButton); } status = new Status(); status.setBusy("data transfer in progress..."); panel.add(status); status.hide(); cp.add(panel); LayoutContainer wrapper = (LayoutContainer) Registry.get(Constants.CENTER_PANEL); wrapper.removeAll(); wrapper.add(container); wrapper.layout(); }
From source file:org.openempi.webapp.client.mvc.user.UserFileView.java
License:Open Source License
private void initUI() { List<ColumnConfig> configs = new ArrayList<ColumnConfig>(); CheckBoxSelectionModel<UserFileWeb> sm = new CheckBoxSelectionModel<UserFileWeb>(); configs.add(sm.getColumn());//from www . j a v a2 s .c om ColumnConfig column = new ColumnConfig(); column.setId("name"); column.setHeader("File Name"); column.setWidth(150); configs.add(column); column = new ColumnConfig("dateCreated", "Date Created", 250); // column.setAlignment(HorizontalAlignment.RIGHT); column.setDateTimeFormat(DateTimeFormat.getFullDateTimeFormat()); configs.add(column); column = new ColumnConfig("imported", "Imported?", 70); column.setAlignment(HorizontalAlignment.RIGHT); configs.add(column); column = new ColumnConfig("rowsImported", "Rows Imported", 115); column.setAlignment(HorizontalAlignment.RIGHT); configs.add(column); column = new ColumnConfig("rowsProcessed", "Rows Processed", 115); column.setAlignment(HorizontalAlignment.RIGHT); configs.add(column); column = new ColumnConfig("profiled", "Data Profiled?", 100); column.setAlignment(HorizontalAlignment.RIGHT); configs.add(column); column = new ColumnConfig("profileProcessed", "Data Profile Processed", 150); column.setAlignment(HorizontalAlignment.RIGHT); configs.add(column); ColumnModel cm = new ColumnModel(configs); container = new LayoutContainer(); container.setLayout(new CenterLayout()); ContentPanel cp = new ContentPanel(); cp.setHeading("User File Management"); cp.setFrame(true); cp.setIcon(IconHelper.create("images/folder.png")); cp.setLayout(new FillLayout()); cp.setSize(1000, 400); ToolBar toolBar = new ToolBar(); Label space = new Label(""); /* importOnly = new CheckBox(); importOnly.setBoxLabel("Import Only"); importOnly.setValue(false); skipHeaderLine = new CheckBox(); skipHeaderLine.setBoxLabel("Skip Header Line"); skipHeaderLine.setValue(true); */ toolBar.add(space); /* toolBar.add(importOnly); toolBar.add(skipHeaderLine); */ toolBar.add(new SeparatorToolItem()); toolBar.add(new Button("Import", IconHelper.create("images/folder_go.png"), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { if (fileLoaderConfigurations == null || fileLoaderConfigurations.size() == 0) { MessageBox.alert("Information", "No any file loader is found. Please check file loader configuration.", null); return; } List<UserFileWeb> userFileEntries = grid.getSelectionModel().getSelectedItems(); if (userFileEntries == null || userFileEntries.size() == 0) { Info.display("Information", "You must first select an entry before pressing the Import button."); return; } /* showWaitCursor(); // set values for importOnly and skipHeaderLine for (UserFileWeb userFile : userFileEntries) { userFile.setImportOnly(importOnly.getValue()); userFile.setSkipHeaderLine(skipHeaderLine.getValue()); } controller.handleEvent(new AppEvent(AppEvents.FileEntryImport, userFileEntries)); */ dynamicFieldsPanel = null; buildFileLoaderConfigurationsDialog(); fileLoaderConfigurationsDialog.setHeading("Configure File Loader"); Button ok = fileLoaderConfigurationsDialog.getButtonById("ok"); ok.setText("Import"); fileLoaderConfigurationsDialog.show(); fileLoadersCombo.setValue(currentFileLoader); } })); toolBar.add(new SeparatorToolItem()); toolBar.add(new Button("Remove", IconHelper.create("images/folder_delete.png"), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { List<UserFileWeb> userFileEntries = grid.getSelectionModel().getSelectedItems(); if (userFileEntries == null || userFileEntries.size() == 0) { Info.display("Information", "You must first select an entry before pressing the Remove button."); return; } controller.handleEvent(new AppEvent(AppEvents.FileEntryRemove, userFileEntries)); } })); toolBar.add(new SeparatorToolItem()); toolBar.add(space); toolBar.add(new Button("Data Profile", IconHelper.create("images/script.png"), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { userFileEntries = grid.getSelectionModel().getSelectedItems(); if (userFileEntries == null || userFileEntries.size() == 0 || userFileEntries.size() > 1) { Info.display("Information", "You must select one entry before pressing the Data Profile button."); return; } controller.handleEvent(new AppEvent(AppEvents.FileListUpdateDataProfile, null)); } })); toolBar.add(new SeparatorToolItem()); toolBar.add(space); toolBar.add(new Button(" Refresh Uploaded Files", IconHelper.create("images/arrow_refresh.png"), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { showWaitCursor(); controller.handleEvent(new AppEvent(AppEvents.FileListUpdate, null)); } })); cp.setTopComponent(toolBar); store = new ListStore<UserFileWeb>(); grid = new Grid<UserFileWeb>(store, cm); grid.setSelectionModel(sm); grid.setAutoExpandColumn("name"); grid.setBorders(true); grid.addPlugin(sm); cp.add(grid); container.add(cp); final FormPanel panel = new FormPanel(); panel.setFrame(true); String url = GWT.getModuleBaseURL() + "upload"; panel.setAction(url); panel.setEncoding(Encoding.MULTIPART); panel.setMethod(Method.POST); panel.setFrame(true); panel.setButtonAlign(HorizontalAlignment.CENTER); panel.setWidth(350); final TextField<String> name = new TextField<String>(); name.setFieldLabel("Name"); name.setName("name"); name.setAllowBlank(false); panel.add(name); final FileUploadField file = new FileUploadField(); file.setAllowBlank(false); file.setFieldLabel("File"); file.setName("filename"); panel.add(file); panel.addListener(Events.Submit, new Listener<FormEvent>() { public void handleEvent(FormEvent be) { GWT.log("Event is " + be, null); if (!be.getResultHtml().equals("success")) { Info.display("Information", be.getResultHtml()); return; } controller.handleEvent(new AppEvent(AppEvents.FileListUpdate, be.getResultHtml())); } }); panel.addListener(Events.BeforeSubmit, new Listener<FormEvent>() { public void handleEvent(FormEvent be) { GWT.log("Event is " + be, null); } }); panel.addButton(new Button("Upload", new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { if (name.getValue() == null || file.getValue() == null) { Info.display("Information", "You must enter a name and filename before pressing the 'Upload' button"); return; } if (existsFileName(name.getValue())) { Info.display("Information", "You already have a file with this name. Please choose another name."); return; } panel.submit(); } })); cp.add(panel); LayoutContainer wrapper = (LayoutContainer) Registry.get(Constants.CENTER_PANEL); wrapper.removeAll(); wrapper.add(container); wrapper.layout(); }