Example usage for com.google.gwt.user.client.ui FlexTable getFlexCellFormatter

List of usage examples for com.google.gwt.user.client.ui FlexTable getFlexCellFormatter

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui FlexTable getFlexCellFormatter.

Prototype

public FlexCellFormatter getFlexCellFormatter() 

Source Link

Document

Explicitly gets the FlexCellFormatter .

Usage

From source file:org.sigmah.client.page.passwordreset.PasswordResetView.java

License:Open Source License

void showPasswordUpdateForm(final FlexTable form, final String email) {

    int y = 0;//from www .  jav  a  2 s .c o  m

    // E-Mail field
    form.setText(y, 0, I18N.CONSTANTS.loginLoginField());
    form.getCellFormatter().setStyleName(y, 0, "login-box-form-label");

    final TextBox loginTextBox = new TextBox();
    loginTextBox.setWidth("100%");
    loginTextBox.setValue(email);
    loginTextBox.setEnabled(false);
    form.setWidget(y, 1, loginTextBox);
    form.getFlexCellFormatter().setColSpan(y, 1, 2);
    y++;

    // Separator
    for (int i = 0; i < 3; i++)
        form.getCellFormatter().setStyleName(y, i, "login-box-form-separator");
    y++;

    // Password field
    form.setText(y, 0, I18N.CONSTANTS.newPassword() + "*");
    form.getCellFormatter().setStyleName(y, 0, "login-box-form-label");

    final PasswordTextBox passwordTextBox = new PasswordTextBox();
    passwordTextBox.setWidth("100%");
    form.setWidget(y, 1, passwordTextBox);
    form.getFlexCellFormatter().setColSpan(y, 1, 2);
    y++;

    // Separator
    for (int i = 0; i < 3; i++)
        form.getCellFormatter().setStyleName(y, i, "login-box-form-separator");
    y++;

    // Confirm Password field
    form.setText(y, 0, I18N.CONSTANTS.confirmPassword() + "*");
    form.getCellFormatter().setStyleName(y, 0, "login-box-form-label");
    final PasswordTextBox confirmPasswordTextBox = new PasswordTextBox();
    confirmPasswordTextBox.setWidth("100%");
    form.setWidget(y, 1, confirmPasswordTextBox);
    form.getFlexCellFormatter().setColSpan(y, 1, 2);
    y++;

    // Separator
    for (int i = 0; i < 2; i++)
        form.getCellFormatter().setStyleName(y, i, "login-box-form-separator");
    y++;

    // Update button
    final HorizontalPanel bottomPanel = new HorizontalPanel();
    bottomPanel.setSpacing(6);

    final Image loader = new Image("image/login-loader.gif");
    loader.getElement().getStyle().setVisibility(Visibility.HIDDEN);

    bottomPanel.add(loader);

    final Button updateButton = new Button(I18N.CONSTANTS.confirmUpdate());
    updateButton.setWidth("130px");
    bottomPanel.add(updateButton);

    form.setWidget(y, 1, bottomPanel);
    form.getCellFormatter().setHorizontalAlignment(y, 1, HasHorizontalAlignment.ALIGN_RIGHT);
    form.getCellFormatter().setWidth(y, 1, "100%");
    y++;

    // Login actions
    updateButton.addListener(Events.Select, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            String password = passwordTextBox.getValue();

            if (password.length() == 0) {
                MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.formWindowFieldsUnfilledDetails(),
                        null);
                return;
            }

            if (!password.equals(confirmPasswordTextBox.getValue())) {
                MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.passwordNotMatch(), null);
                return;
            }

            updateButton.setEnabled(false);
            loader.getElement().getStyle().setVisibility(Visibility.VISIBLE);

            service.updatePassword(email, password, new AsyncCallback<Void>() {

                @Override
                public void onFailure(Throwable caught) {
                    updateButton.setEnabled(true);
                    MessageBox.alert(I18N.CONSTANTS.save(), I18N.CONSTANTS.saveError(), null);
                }

                @Override
                public void onSuccess(Void result) {
                    Notification.show(I18N.CONSTANTS.infoConfirmation(), I18N.CONSTANTS.passwordUpdated());

                    //Redirect to login page after 3 sec
                    Timer timer = new Timer() {
                        public void run() {
                            Window.Location.replace(GWT.getModuleBaseURL());
                        }
                    };
                    timer.schedule(3000);

                }
            });
        }
    });

    final KeyDownHandler handler = new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                updateButton.fireEvent(Events.Select);
            }
        }
    };
    confirmPasswordTextBox.addKeyDownHandler(handler);
    passwordTextBox.addKeyDownHandler(handler);
}

From source file:org.sigmah.client.ui.GlobalExportForm.java

License:Open Source License

public GlobalExportForm(final Integer organizationId, final Dispatcher dispatcher) {

    button = new Button(I18N.CONSTANTS.exportAll(), IconImageBundle.ICONS.excel());
    exportForm = new FormPanel();
    exportForm.setBodyBorder(false);/*from w ww.  ja v a 2  s .  c o  m*/
    exportForm.setHeaderVisible(false);
    exportForm.setPadding(0);
    exportForm.setEncoding(Encoding.URLENCODED);
    exportForm.setMethod(Method.POST);
    exportForm.setAction(GWT.getModuleBaseURL() + "export");

    final Map<String, String> fieldMap = new HashMap<String, String>();
    fieldMap.put(ExportUtils.PARAM_EXPORT_TYPE, ExportUtils.ExportType.GLOBAL_EXPORT.name());
    fieldMap.put(ExportUtils.PARAM_EXPORT_ORGANIZATION_ID, String.valueOf(organizationId));

    button.addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            final Window w = new Window();
            w.setPlain(true);
            w.setModal(true);
            w.setBlinkModal(true);
            w.setLayout(new FitLayout());
            w.setSize(420, 150);
            w.setHeading(I18N.CONSTANTS.globalExport());

            final FormPanel panel = new FormPanel();
            panel.setHeaderVisible(false);
            FormLayout layout = new FormLayout();
            layout.setLabelWidth(220);
            panel.setLayout(layout);
            panel.setScrollMode(Scroll.AUTOY);

            // version
            final Radio liveChoice = new Radio();
            liveChoice.setBoxLabel(I18N.CONSTANTS.liveData());
            liveChoice.setName("version");
            liveChoice.setValue(true);

            final Radio backupChoice = new Radio();
            backupChoice.setBoxLabel(I18N.CONSTANTS.backedUpData());
            backupChoice.setName("version");

            RadioGroup radioGroup = new RadioGroup();
            radioGroup.setOrientation(Orientation.VERTICAL);
            radioGroup.setFieldLabel(I18N.CONSTANTS.versionOfDataToExport());
            radioGroup.add(liveChoice);
            radioGroup.add(backupChoice);
            panel.add(radioGroup);

            // period
            final DateField fromDate = getDateField();
            final DateField toDate = getDateField();
            toDate.setValue(new Date());
            final Button search = new Button(I18N.CONSTANTS.search());

            final ListStore<GlobalExportDTO> periodsStore = new ListStore<GlobalExportDTO>();
            final ComboBox<GlobalExportDTO> periods = new ComboBox<GlobalExportDTO>();
            periods.setWidth(180);
            periods.setStore(periodsStore);
            periods.setDisplayField("date");
            periods.setValueField("id");
            periods.setEditable(false);
            periods.setTriggerAction(TriggerAction.ALL);
            periods.setHideLabel(false);
            periods.setEnabled(false);

            final FlexTable periodTable = new FlexTable();
            periodTable.setHTML(0, 0, "<b>" + I18N.CONSTANTS.exportBackSelection() + "</b>");
            periodTable.getFlexCellFormatter().setWidth(0, 0, "220px");
            periodTable.setHTML(1, 0, I18N.CONSTANTS.specifyPeriodForBackup());
            periodTable.setWidget(1, 1, fromDate);
            periodTable.setWidget(1, 2, new LabelField(" -"));
            periodTable.setWidget(1, 3, toDate);
            periodTable.setWidget(1, 4, search);
            periodTable.getFlexCellFormatter().setHeight(1, 0, "30px");

            periodTable.setHTML(2, 0, I18N.CONSTANTS.selectBackupToExport());
            periodTable.setWidget(2, 1, periods);
            periodTable.getFlexCellFormatter().setColSpan(2, 1, 4);
            panel.add(periodTable);
            periodTable.setVisible(false);
            backupChoice.addListener(Events.OnClick, new Listener<FieldEvent>() {
                public void handleEvent(FieldEvent fe) {
                    periods.setAllowBlank(false);
                    periodTable.setVisible(true);
                    w.setSize(500, 220);

                }
            });
            liveChoice.addListener(Events.OnClick, new Listener<FieldEvent>() {
                public void handleEvent(FieldEvent fe) {
                    fromDate.clear();
                    toDate.clear();
                    periods.setAllowBlank(true);
                    periods.clear();
                    periodTable.setVisible(false);
                    w.setSize(420, 150);
                }
            });

            search.addSelectionListener(new SelectionListener<ButtonEvent>() {

                @Override
                public void componentSelected(ButtonEvent ce) {
                    if (fromDate.isValid() && toDate.isValid()) {
                        periods.setEmptyText("");
                        dispatcher.execute(
                                new GetGlobalExports(fromDate.getValue(), toDate.getValue(),
                                        I18N.CONSTANTS.savedDateExportFormat()),
                                null, new AsyncCallback<GlobalExportListResult>() {

                                    @Override
                                    public void onFailure(Throwable caught) {
                                        periods.setEmptyText(I18N.CONSTANTS.adminChoiceProblem());
                                    }

                                    @Override
                                    public void onSuccess(GlobalExportListResult result) {
                                        periodsStore.removeAll();
                                        if (result != null) {
                                            if (result.getList().size() > 0) {
                                                periods.setEmptyText(
                                                        I18N.CONSTANTS.createProjectTypeFundingSelect());
                                            }
                                            periodsStore.add(result.getList());
                                            periodsStore.commitChanges();
                                            periods.setEnabled(true);
                                        }
                                    }
                                });
                    }
                }
            });

            final Button exportButton = new Button(I18N.CONSTANTS.export());
            final Button settingsButton = new Button(I18N.CONSTANTS.changeConfiguration());
            panel.getButtonBar().add(exportButton);
            panel.getButtonBar().add(settingsButton);

            exportButton.addSelectionListener(new SelectionListener<ButtonEvent>() {

                @Override
                public void componentSelected(ButtonEvent ce) {
                    // Clears the form.
                    exportForm.removeAll();

                    // set version
                    if (liveChoice.getValue()) {
                        fieldMap.put(ExportUtils.PARAM_EXPORT_DATA_VERSION,
                                ExportUtils.ExportDataVersion.LIVE_DATA.name());
                    } else {
                        if (!periods.validate())
                            return;

                        fieldMap.put(ExportUtils.PARAM_EXPORT_DATA_VERSION,
                                ExportUtils.ExportDataVersion.BACKED_UP_DATA.name());
                        fieldMap.put(ExportUtils.PARAM_EXPORT_GLOBAL_EXPORT_ID,
                                String.valueOf(periods.getValue().getId()));
                    }

                    // Adds parameters.
                    for (String name : fieldMap.keySet()) {
                        final HiddenField<String> hiddenField = new HiddenField<String>();
                        hiddenField.setName(name);
                        hiddenField.setValue(fieldMap.get(name));
                        exportForm.add(hiddenField);
                    }

                    exportForm.layout();

                    // Submits the form.
                    exportForm.submit();

                    w.hide();
                }
            });

            settingsButton.addSelectionListener(new SelectionListener<ButtonEvent>() {

                @Override
                public void componentSelected(ButtonEvent ce) {
                    new GlobalExportSettingsForm(organizationId, dispatcher);
                }
            });

            w.add(panel);
            w.show();

        }
    });
}

From source file:org.sigmah.client.ui.GlobalExportSettingsForm.java

License:Open Source License

public GlobalExportSettingsForm(final Integer organizationId, final Dispatcher dispatcher) {

    modelsStore = new ListStore<ProjectModelDTO>();
    fieldsStore = new ListStore<FlexibleElementDTO>();
    this.organizationId = organizationId;
    fieldsMap = new HashMap<Integer, Boolean>();

    autoExportSchedules = new ArrayList<SimpleComboBoxData>();
    for (Integer value : exportScheduleMap.keySet()) {
        autoExportSchedules.add(exportScheduleMap.get(value));
    }//from   w ww  . j av  a 2 s  .  c  o m
    autoDeleteSchedules = new ArrayList<SimpleComboBoxData>();
    for (Integer value : deleteScheduleMap.keySet()) {
        autoDeleteSchedules.add(deleteScheduleMap.get(value));
    }

    autoExportMonthlySchedules = new ArrayList<SimpleComboBoxData>();
    for (Integer value : monthScheduleMap.keySet()) {
        autoExportMonthlySchedules.add(monthScheduleMap.get(value));
    }
    autoExportWeeklySchedules = new ArrayList<SimpleComboBoxData>();
    for (Integer value : weekScheduleMap.keySet()) {
        autoExportWeeklySchedules.add(weekScheduleMap.get(value));
    }

    final Window w = new Window();
    w.setPlain(true);
    w.setModal(true);
    w.setBlinkModal(true);
    w.setLayout(new FitLayout());
    w.setSize(900, 420);
    w.setHeading(I18N.CONSTANTS.globalExportConfiguration());

    final FormPanel panel = new FormPanel();
    panel.setHeaderVisible(false);
    FormLayout layout = new FormLayout();
    layout.setLabelWidth(150);

    panel.setLayout(layout);
    // file format
    final Radio calcChoice = new Radio();
    calcChoice.setBoxLabel(I18N.CONSTANTS.openDocumentSpreadsheet());
    calcChoice.setValue(true);
    calcChoice.setName("type");

    final Radio excelChoice = new Radio();
    excelChoice.setBoxLabel(I18N.CONSTANTS.msExcel());
    excelChoice.setName("type");

    RadioGroup radioGroup = new RadioGroup();
    radioGroup.setOrientation(Orientation.VERTICAL);
    radioGroup.setFieldLabel(I18N.CONSTANTS.chooseFileType());
    radioGroup.add(calcChoice);
    radioGroup.add(excelChoice);
    panel.add(radioGroup);

    // configure fields
    // project model
    final Grid<ProjectModelDTO> pModelsGrid = getModelsGrid();
    // flex elements
    final Grid<FlexibleElementDTO> elementsGrid = getElementsGrid();

    final FlexTable fieldsTable = new FlexTable();
    fieldsTable.setCellPadding(0);
    fieldsTable.setCellSpacing(0);
    fieldsTable.setWidget(0, 0, new LabelField(I18N.CONSTANTS.configureFieldsToExport() + ":"));
    fieldsTable.getFlexCellFormatter().setWidth(0, 0, "170px");
    fieldsTable.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
    fieldsTable.setWidget(0, 1, pModelsGrid);
    fieldsTable.setWidget(0, 2, elementsGrid);
    panel.add(fieldsTable);

    // auto export schedule
    final ListStore<SimpleComboBoxData> exportScheduleStore = new ListStore<SimpleComboBoxData>();
    final ComboBox<SimpleComboBoxData> exportSchedulesBox = new ComboBox<SimpleComboBoxData>();
    exportSchedulesBox.setFieldLabel(I18N.CONSTANTS.autoExportSchedule());
    exportSchedulesBox.setStore(exportScheduleStore);
    exportSchedulesBox.setDisplayField("label");
    exportSchedulesBox.setValueField("value");
    exportSchedulesBox.setEditable(false);
    exportSchedulesBox.setTriggerAction(TriggerAction.ALL);
    exportScheduleStore.add(autoExportSchedules);
    exportScheduleStore.commitChanges();
    exportSchedulesBox.setValue(exportScheduleMap.get(0));
    panel.add(exportSchedulesBox);

    // auto export monthly schedule
    final ListStore<SimpleComboBoxData> exportMonthlyScheduleStore = new ListStore<SimpleComboBoxData>();
    final ComboBox<SimpleComboBoxData> exportMonthlySchedulesBox = new ComboBox<SimpleComboBoxData>();
    exportMonthlySchedulesBox.setFieldLabel(I18N.CONSTANTS.dayInMonth());
    exportMonthlySchedulesBox.setStore(exportMonthlyScheduleStore);
    exportMonthlySchedulesBox.setDisplayField("label");
    exportMonthlySchedulesBox.setValueField("value");
    exportMonthlySchedulesBox.setEditable(false);
    exportMonthlySchedulesBox.setTriggerAction(TriggerAction.ALL);
    exportMonthlyScheduleStore.add(autoExportMonthlySchedules);
    exportMonthlyScheduleStore.commitChanges();
    exportMonthlySchedulesBox.setValue(monthScheduleMap.get(31));
    exportMonthlySchedulesBox.hide();
    panel.add(exportMonthlySchedulesBox);

    // auto export Weekly schedule
    final ListStore<SimpleComboBoxData> exportWeeklyScheduleStore = new ListStore<SimpleComboBoxData>();
    final ComboBox<SimpleComboBoxData> exportWeeklySchedulesBox = new ComboBox<SimpleComboBoxData>();
    exportWeeklySchedulesBox.setFieldLabel(I18N.CONSTANTS.dayInWeek());
    exportWeeklySchedulesBox.setStore(exportWeeklyScheduleStore);
    exportWeeklySchedulesBox.setDisplayField("label");
    exportWeeklySchedulesBox.setValueField("value");
    exportWeeklySchedulesBox.setEditable(false);
    exportWeeklySchedulesBox.setTriggerAction(TriggerAction.ALL);
    exportWeeklyScheduleStore.add(autoExportWeeklySchedules);
    exportWeeklyScheduleStore.commitChanges();
    exportWeeklySchedulesBox.setValue(weekScheduleMap.get(61));
    exportWeeklySchedulesBox.hide();
    panel.add(exportWeeklySchedulesBox);

    // auto delete schedule
    final ListStore<SimpleComboBoxData> deleteScheduleStore = new ListStore<SimpleComboBoxData>();
    final ComboBox<SimpleComboBoxData> deleteSchedulesBox = new ComboBox<SimpleComboBoxData>();
    deleteSchedulesBox.setFieldLabel(I18N.CONSTANTS.autoCleanupSchedule());
    deleteSchedulesBox.setStore(deleteScheduleStore);
    deleteSchedulesBox.setDisplayField("label");
    deleteSchedulesBox.setValueField("value");
    deleteSchedulesBox.setEditable(false);
    deleteSchedulesBox.setTriggerAction(TriggerAction.ALL);
    deleteScheduleStore.add(autoDeleteSchedules);
    deleteScheduleStore.commitChanges();
    deleteSchedulesBox.setValue(deleteScheduleMap.get(0));
    panel.add(deleteSchedulesBox);

    //Add onChange handler for exportSchedulesBox
    exportSchedulesBox.addListener(Events.Select, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            exportMonthlySchedulesBox.hide();
            exportWeeklySchedulesBox.hide();

            if (exportSchedulesBox.getValue().getValue() == 31) { //Case of Monthly Schedule
                exportMonthlySchedulesBox.show();
            } else if (exportSchedulesBox.getValue().getValue() == 61) { //Case of Weekly Schedule
                exportWeeklySchedulesBox.show();
            } else {
                //Regular case of every N days
            }
        }
    });
    //onChange handler for exportSchedulesBox handled

    // button
    final Button saveButton = new Button(I18N.CONSTANTS.saveExportConfiguration());
    panel.getButtonBar().add(saveButton);
    saveButton.addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            UpdateGlobalExportSettings settings = new UpdateGlobalExportSettings(fieldsMap);
            if (excelChoice.getValue()) {
                settings.setExportFormat(ExportUtils.ExportFormat.XLS);
            } else {
                settings.setExportFormat(ExportUtils.ExportFormat.ODS);
            }
            if (exportSchedulesBox.getValue() == null || exportSchedulesBox.getValue().getValue() == 0) {
                settings.setAutoExportFrequency(null);
            } else {

                if (exportSchedulesBox.getValue().getValue() == 31) { //Case of Monthly Schedule
                    // Push the value selected in the Monthly export schedule box
                    // Value between 31-38 (both inclusive)
                    settings.setAutoExportFrequency(exportMonthlySchedulesBox.getValue().getValue());
                } else if (exportSchedulesBox.getValue().getValue() == 61) { //Case of Weekly Schedule
                    // Value between 61-67 (both inclusive)
                    // Push the value selected in the Weekly export schedule box
                    settings.setAutoExportFrequency(exportWeeklySchedulesBox.getValue().getValue());
                } else {
                    //Regular case of every N days
                    settings.setAutoExportFrequency(exportSchedulesBox.getValue().getValue());
                }

            }
            if (deleteSchedulesBox.getValue() == null || deleteSchedulesBox.getValue().getValue() == 0) {
                settings.setAutoDeleteFrequency(null);
            } else {
                settings.setAutoDeleteFrequency(deleteSchedulesBox.getValue().getValue());
            }

            settings.setOrganizationId(organizationId);
            dispatcher.execute(settings, null, new AsyncCallback<VoidResult>() {

                @Override
                public void onFailure(Throwable caught) {
                    MessageBox.alert(
                            I18N.CONSTANTS.saveExportConfiguration(), I18N.MESSAGES
                                    .adminStandardCreationFailure(I18N.CONSTANTS.globalExportConfiguration()),
                            null);
                }

                @Override
                public void onSuccess(VoidResult result) {
                    w.hide();
                    Notification.show(I18N.CONSTANTS.saveExportConfiguration(), I18N.MESSAGES
                            .adminStandardUpdateSuccess(I18N.CONSTANTS.globalExportConfiguration()));
                }
            });
        }
    });

    w.add(panel);
    w.show();

    // action
    final GetGlobalExportSettings settingsCommand = new GetGlobalExportSettings(organizationId);
    dispatcher.execute(settingsCommand, new MaskingAsyncMonitor(panel, I18N.CONSTANTS.loading()),
            new AsyncCallback<GlobalExportSettingsDTO>() {

                @Override
                public void onFailure(Throwable caught) {
                    MessageBox.alert(I18N.CONSTANTS.globalExportConfiguration(), I18N.CONSTANTS.serverError(),
                            null);
                }

                @Override
                public void onSuccess(GlobalExportSettingsDTO result) {
                    // set export format
                    if (result.getExportFormat() != null) {
                        switch (result.getExportFormat()) {
                        case XLS:
                            excelChoice.setValue(true);
                            break;

                        case ODS:
                            calcChoice.setValue(true);
                            break;
                        }

                    }

                    // set pmodels
                    modelsStore.add(result.getProjectModelsDTO());
                    modelsStore.commitChanges();

                    // auto export schdule
                    if (exportScheduleMap.get(result.getAutoExportFrequency()) != null
                            || monthScheduleMap.get(result.getAutoExportFrequency()) != null
                            || weekScheduleMap.get(result.getAutoExportFrequency()) != null) {

                        if (result.getAutoExportFrequency() >= 31 && result.getAutoExportFrequency() <= 58) {//Case of Monthly Update
                            exportSchedulesBox.setValue(exportScheduleMap.get(31));
                            exportMonthlySchedulesBox.show();

                            exportMonthlySchedulesBox
                                    .setValue(monthScheduleMap.get(result.getAutoExportFrequency()));
                        } else if (result.getAutoExportFrequency() >= 61
                                && result.getAutoExportFrequency() <= 67) {//Case of Weekly Update
                            exportSchedulesBox.setValue(exportScheduleMap.get(61));
                            exportWeeklySchedulesBox.show();

                            exportWeeklySchedulesBox
                                    .setValue(weekScheduleMap.get(result.getAutoExportFrequency()));
                        } else {
                            //Regular case of every N-days
                            exportSchedulesBox.setValue(exportScheduleMap.get(result.getAutoExportFrequency()));
                        }

                    }

                    // auto delete schedule
                    if (deleteScheduleMap.get(result.getAutoDeleteFrequency()) != null) {
                        deleteSchedulesBox.setValue(deleteScheduleMap.get(result.getAutoDeleteFrequency()));
                    }
                }
            });

}

From source file:org.sigmah.client.ui.view.contact.export.ExportContactsSettingView.java

License:Open Source License

@Override
public void initialize() {

    autoExportSchedules = new ArrayList<SimpleComboBoxData>();
    for (Integer value : exportScheduleMap.keySet()) {
        autoExportSchedules.add(exportScheduleMap.get(value));
    }/*from   w w w.  jav a2  s.  c  om*/
    autoDeleteSchedules = new ArrayList<SimpleComboBoxData>();
    for (Integer value : deleteScheduleMap.keySet()) {
        autoDeleteSchedules.add(deleteScheduleMap.get(value));
    }

    autoExportMonthlySchedules = new ArrayList<SimpleComboBoxData>();
    for (Integer value : monthScheduleMap.keySet()) {
        autoExportMonthlySchedules.add(monthScheduleMap.get(value));
    }
    autoExportWeeklySchedules = new ArrayList<SimpleComboBoxData>();
    for (Integer value : weekScheduleMap.keySet()) {
        autoExportWeeklySchedules.add(weekScheduleMap.get(value));
    }

    panel = new FormPanel();
    panel.setHeaderVisible(false);
    FormLayout layout = new FormLayout();
    layout.setLabelWidth(150);
    panel.setAutoWidth(true);
    panel.setAutoHeight(true);

    panel.setLayout(layout);
    // file format
    calcChoice = new Radio();
    calcChoice.setBoxLabel(I18N.CONSTANTS.openDocumentSpreadsheet());
    calcChoice.setValue(true);
    calcChoice.setName("type");

    excelChoice = new Radio();
    excelChoice.setBoxLabel(I18N.CONSTANTS.msExcel());
    excelChoice.setName("type");

    RadioGroup radioGroup = new RadioGroup();
    radioGroup.setOrientation(Orientation.VERTICAL);
    radioGroup.setFieldLabel(I18N.CONSTANTS.chooseFileType());
    radioGroup.add(calcChoice);
    radioGroup.add(excelChoice);
    panel.add(radioGroup);

    // configure fields
    // contact model
    Grid<ContactModelDTO> pModelsGrid = getModelsGrid();
    // flex elements
    Grid<FlexibleElementDTO> elementsGrid = getElementsGrid();

    FlexTable fieldsTable = new FlexTable();

    LabelField fildsTableLabel = new LabelField(I18N.CONSTANTS.configureFieldsToExport() + " :");
    fildsTableLabel.setWidth(150);
    fieldsTable.setWidget(0, 0, fildsTableLabel);

    fieldsTable.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);

    fieldsTable.setWidget(0, 1, pModelsGrid);
    fieldsTable.setWidget(0, 2, elementsGrid);
    fieldsTable.getFlexCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP);
    fieldsTable.getFlexCellFormatter().setVerticalAlignment(0, 2, HasVerticalAlignment.ALIGN_TOP);
    panel.add(fieldsTable);

    // auto export schedule
    exportScheduleStore = new ListStore<SimpleComboBoxData>();
    exportSchedulesBox = new ComboBox<SimpleComboBoxData>();
    exportSchedulesBox.setFieldLabel(I18N.CONSTANTS.autoExportSchedule());
    exportSchedulesBox.setStore(exportScheduleStore);
    exportSchedulesBox.setDisplayField("label");
    exportSchedulesBox.setValueField("value");
    exportSchedulesBox.setEditable(false);
    exportSchedulesBox.setTriggerAction(TriggerAction.ALL);
    exportScheduleStore.add(autoExportSchedules);
    exportScheduleStore.commitChanges();
    exportSchedulesBox.setValue(exportScheduleMap.get(0));
    panel.add(exportSchedulesBox);

    // auto export monthly schedule
    exportMonthlyScheduleStore = new ListStore<SimpleComboBoxData>();
    exportMonthlySchedulesBox = new ComboBox<SimpleComboBoxData>();
    exportMonthlySchedulesBox.setFieldLabel(I18N.CONSTANTS.dayInMonth());
    exportMonthlySchedulesBox.setStore(exportMonthlyScheduleStore);
    exportMonthlySchedulesBox.setDisplayField("label");
    exportMonthlySchedulesBox.setValueField("value");
    exportMonthlySchedulesBox.setEditable(false);
    exportMonthlySchedulesBox.setTriggerAction(TriggerAction.ALL);
    exportMonthlyScheduleStore.add(autoExportMonthlySchedules);
    exportMonthlyScheduleStore.commitChanges();
    exportMonthlySchedulesBox.setValue(monthScheduleMap.get(31));
    exportMonthlySchedulesBox.hide();
    panel.add(exportMonthlySchedulesBox);

    // auto export Weekly schedule
    exportWeeklyScheduleStore = new ListStore<SimpleComboBoxData>();
    exportWeeklySchedulesBox = new ComboBox<SimpleComboBoxData>();
    exportWeeklySchedulesBox.setFieldLabel(I18N.CONSTANTS.dayInWeek());
    exportWeeklySchedulesBox.setStore(exportWeeklyScheduleStore);
    exportWeeklySchedulesBox.setDisplayField("label");
    exportWeeklySchedulesBox.setValueField("value");
    exportWeeklySchedulesBox.setEditable(false);
    exportWeeklySchedulesBox.setTriggerAction(TriggerAction.ALL);
    exportWeeklyScheduleStore.add(autoExportWeeklySchedules);
    exportWeeklyScheduleStore.commitChanges();
    exportWeeklySchedulesBox.setValue(weekScheduleMap.get(61));
    exportWeeklySchedulesBox.hide();
    panel.add(exportWeeklySchedulesBox);

    // auto delete schedule
    deleteScheduleStore = new ListStore<SimpleComboBoxData>();
    deleteSchedulesBox = new ComboBox<SimpleComboBoxData>();
    deleteSchedulesBox.setFieldLabel(I18N.CONSTANTS.autoCleanupSchedule());
    deleteSchedulesBox.setStore(deleteScheduleStore);
    deleteSchedulesBox.setDisplayField("label");
    deleteSchedulesBox.setValueField("value");
    deleteSchedulesBox.setEditable(false);
    deleteSchedulesBox.setTriggerAction(TriggerAction.ALL);
    deleteScheduleStore.add(autoDeleteSchedules);
    deleteScheduleStore.commitChanges();
    deleteSchedulesBox.setValue(deleteScheduleMap.get(0));
    panel.add(deleteSchedulesBox);

    // Add onChange handler for exportSchedulesBox
    exportSchedulesBox.addListener(Events.Select, new Listener<BaseEvent>() {

        @Override
        public void handleEvent(BaseEvent be) {
            exportMonthlySchedulesBox.hide();
            exportWeeklySchedulesBox.hide();

            if (exportSchedulesBox.getValue().getValue() == 31) { // Case of Monthly Schedule
                exportMonthlySchedulesBox.show();
            } else if (exportSchedulesBox.getValue().getValue() == 61) { // Case of Weekly Schedule
                exportWeeklySchedulesBox.show();
            } else {
                // Regular case of every N days
            }
        }
    });
    // onChange handler for exportSchedulesBox handled

    // button
    saveButton = new Button(I18N.CONSTANTS.saveExportConfiguration());
    panel.getButtonBar().add(saveButton);
    panel.setScrollMode(Scroll.AUTO);
    initPopup(panel);

}

From source file:org.sigmah.client.ui.view.contact.export.ExportContactsView.java

License:Open Source License

@Override
public void initialize() {

    final FormPanel panel = Forms.panel(I18N.CONSTANTS.GLOBAL_EXPORT());
    panel.setHeaderVisible(false);//w  w  w .  ja v  a2 s . c o  m
    FormLayout layout = new FormLayout();
    layout.setLabelWidth(220);
    panel.setLayout(layout);
    panel.setScrollMode(Scroll.AUTOY);

    // version
    liveChoice = new Radio();
    liveChoice.setBoxLabel(I18N.CONSTANTS.liveData());
    liveChoice.setName("version");
    liveChoice.setValue(true);

    backupChoice = new Radio();
    backupChoice.setBoxLabel(I18N.CONSTANTS.backedUpData());
    backupChoice.setName("version");

    RadioGroup radioGroup = new RadioGroup();
    radioGroup.setOrientation(Orientation.VERTICAL);
    radioGroup.setFieldLabel(I18N.CONSTANTS.versionOfDataToExport());
    radioGroup.add(liveChoice);
    radioGroup.add(backupChoice);
    panel.add(radioGroup);

    // period
    fromDate = getDateField();
    toDate = getDateField();
    toDate.setValue(new Date());
    searchButton = new Button(I18N.CONSTANTS.search());

    periodsStore = new ListStore<GlobalContactExportDTO>();
    periods = new ComboBox<GlobalContactExportDTO>();
    periods.setWidth(180);
    periods.setStore(periodsStore);
    periods.setDisplayField("date");
    periods.setValueField("id");
    periods.setEditable(false);
    periods.setTriggerAction(TriggerAction.ALL);
    periods.setHideLabel(false);
    periods.setEnabled(false);

    final FlexTable periodTable = new FlexTable();
    periodTable.setHTML(0, 0, "<b>" + I18N.CONSTANTS.exportBackSelection() + "</b>");
    periodTable.getFlexCellFormatter().setWidth(0, 0, "220px");
    periodTable.setHTML(1, 0, I18N.CONSTANTS.specifyPeriodForBackup());
    periodTable.setWidget(1, 1, fromDate);
    periodTable.setWidget(1, 2, new LabelField(" -"));
    periodTable.setWidget(1, 3, toDate);
    periodTable.setWidget(1, 4, searchButton);
    periodTable.getFlexCellFormatter().setHeight(1, 0, "30px");

    periodTable.setHTML(2, 0, I18N.CONSTANTS.selectBackupToExport());
    periodTable.setWidget(2, 1, periods);
    periodTable.getFlexCellFormatter().setColSpan(2, 1, 4);
    panel.add(periodTable);
    periodTable.setVisible(false);

    backupChoice.addListener(Events.OnClick, new Listener<FieldEvent>() {

        @Override
        public void handleEvent(FieldEvent fe) {
            periods.setAllowBlank(false);
            periodTable.setVisible(true);

        }
    });

    liveChoice.addListener(Events.OnClick, new Listener<FieldEvent>() {

        @Override
        public void handleEvent(FieldEvent fe) {
            fromDate.clear();
            toDate.clear();
            periods.setAllowBlank(true);
            periods.clear();
            periodTable.setVisible(false);
        }
    });

    exportButton = new Button(I18N.CONSTANTS.export());
    settingsButton = new Button(I18N.CONSTANTS.changeConfiguration());
    panel.getButtonBar().add(exportButton);
    panel.getButtonBar().add(settingsButton);

    initPopup(panel);

}

From source file:org.sigmah.client.ui.view.LoginView.java

License:Open Source License

/**
 * {@inheritDoc}// ww w .  j a  v a  2 s  . c om
 */
@Override
public void initialize() {

    final SimplePanel panel = new SimplePanel();
    panel.setStyleName(LOGIN_BG);

    final Grid grid = new Grid(1, 2);
    grid.setStyleName(LOGIN_BOX);

    // Logo.
    grid.setWidget(0, 0, new Image(LOGO_URL));

    // Form.
    final FlexTable form = new FlexTable();
    form.setWidth("90%");

    int y = 0;

    // Login field (email).
    form.setText(y, 0, I18N.CONSTANTS.loginLoginField());
    form.getCellFormatter().setStyleName(y, 0, LOGIN_BOX_FORM_LABEL);

    loginTextBox = new TextBox();
    loginTextBox.setWidth("100%");
    form.setWidget(y, 1, loginTextBox);
    form.getFlexCellFormatter().setColSpan(y, 1, 2);
    y++;

    // Separator.
    for (int i = 0; i < 3; i++) {
        form.getCellFormatter().setStyleName(y, i, LOGIN_BOX_FORM_SEPARATOR);
    }
    y++;

    // Password field.
    form.setText(y, 0, I18N.CONSTANTS.loginPasswordField());
    form.getCellFormatter().setStyleName(y, 0, LOGIN_BOX_FORM_LABEL);

    passwordTextBox = new PasswordTextBox();
    passwordTextBox.setWidth("100%");
    form.setWidget(y, 1, passwordTextBox);
    form.getFlexCellFormatter().setColSpan(y, 1, 2);
    y++;

    // Separator.
    for (int i = 0; i < 3; i++) {
        form.getCellFormatter().setStyleName(y, i, LOGIN_BOX_FORM_SEPARATOR);
    }
    y++;

    // Language field.
    form.setText(y, 0, I18N.CONSTANTS.loginLanguageField());
    form.getCellFormatter().setStyleName(y, 0, LOGIN_BOX_FORM_LABEL);

    languageListBox = new ListBox(false);
    languageListBox.setWidth("100%");
    form.setWidget(y, 1, languageListBox);
    form.getFlexCellFormatter().setColSpan(y, 1, 2);
    y++;

    // Separator.
    for (int i = 0; i < 3; i++) {
        form.getCellFormatter().setStyleName(y, i, LOGIN_BOX_FORM_SEPARATOR);
    }
    y++;

    // Password forgotten link.
    final FlowPanel bottomPanel = new FlowPanel();
    bottomPanel.getElement().getStyle().setPosition(Position.RELATIVE);

    lostPasswordLink = new Anchor(I18N.CONSTANTS.loginPasswordForgotten());
    lostPasswordLink.setStyleName(LOGIN_BOX_FORM_FORGOTTEN);
    bottomPanel.add(lostPasswordLink);

    form.setWidget(y, 0, bottomPanel);
    form.getFlexCellFormatter().setColSpan(y, 0, 2);

    // Login button.
    loginButton = new Button(I18N.CONSTANTS.loginConnectButton());
    loginButton.setWidth("120px");
    form.setWidget(y, 1, loginButton);
    form.getCellFormatter().setHorizontalAlignment(y, 1, HasHorizontalAlignment.ALIGN_RIGHT);
    y++;

    // Adding the form to the orange box.
    grid.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
    grid.setWidget(0, 1, form);

    // Styles.
    grid.getCellFormatter().setStyleName(0, 0, LOGIN_BOX_LOGO);
    grid.getCellFormatter().setStyleName(0, 1, LOGIN_BOX_FORM);

    panel.add(grid);

    add(panel);
}

From source file:org.sigmah.client.ui.view.password.ResetPasswordView.java

License:Open Source License

/**
 * {@inheritDoc}/*  ww w .j  ava 2 s . c om*/
 */
@Override
public void initialize() {

    final SimplePanel panel = new SimplePanel();
    panel.setStyleName(LoginView.LOGIN_BG);

    final Grid grid = new Grid(1, 2);
    grid.setStyleName(LoginView.LOGIN_BOX);

    // Logo.
    grid.setWidget(0, 0, new Image(LoginView.LOGO_URL));

    // Form.
    final FlexTable form = new FlexTable();
    form.setWidth("90%");

    int y = 0;

    // Login field (email).
    form.setText(y, 0, I18N.CONSTANTS.loginLoginField());
    form.getCellFormatter().setStyleName(y, 0, LoginView.LOGIN_BOX_FORM_LABEL);

    emailTextBox = new TextBox();
    emailTextBox.setWidth("100%");
    emailTextBox.setEnabled(false);
    form.setWidget(y, 1, emailTextBox);
    form.getFlexCellFormatter().setColSpan(y, 1, 2);
    y++;

    // Separator.
    for (int i = 0; i < 3; i++) {
        form.getCellFormatter().setStyleName(y, i, LoginView.LOGIN_BOX_FORM_SEPARATOR);
    }
    y++;

    // Password field.
    form.setText(y, 0, I18N.CONSTANTS.newPassword() + '*');
    form.getCellFormatter().setStyleName(y, 0, LoginView.LOGIN_BOX_FORM_LABEL);

    passwordTextBox = new PasswordTextBox();
    passwordTextBox.setWidth("100%");
    form.setWidget(y, 1, passwordTextBox);
    form.getFlexCellFormatter().setColSpan(y, 1, 2);
    y++;

    // Separator.
    for (int i = 0; i < 3; i++) {
        form.getCellFormatter().setStyleName(y, i, LoginView.LOGIN_BOX_FORM_SEPARATOR);
    }
    y++;

    // Confirmation password field.
    form.setText(y, 0, I18N.CONSTANTS.confirmPassword() + '*');
    form.getCellFormatter().setStyleName(y, 0, LoginView.LOGIN_BOX_FORM_LABEL);

    passwordConfirmationTextBox = new PasswordTextBox();
    passwordConfirmationTextBox.setWidth("100%");
    form.setWidget(y, 1, passwordConfirmationTextBox);
    form.getFlexCellFormatter().setColSpan(y, 1, 2);
    y++;

    // Separator.
    for (int i = 0; i < 3; i++) {
        form.getCellFormatter().setStyleName(y, i, LoginView.LOGIN_BOX_FORM_SEPARATOR);
    }
    y++;

    // Validation button.
    validationButton = new Button(I18N.CONSTANTS.confirmUpdate());
    validationButton.setWidth("130px");
    form.setWidget(y, 0, validationButton);
    form.getCellFormatter().setHorizontalAlignment(y, 1, HasHorizontalAlignment.ALIGN_RIGHT);
    y++;

    // Adding the form to the orange box.
    grid.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
    grid.setWidget(0, 1, form);

    // Styles.
    grid.getCellFormatter().setStyleName(0, 0, LoginView.LOGIN_BOX_LOGO);
    grid.getCellFormatter().setStyleName(0, 1, LoginView.LOGIN_BOX_FORM);

    panel.add(grid);

    add(panel);
}

From source file:org.sigmah.client.ui.view.project.export.ExportProjectsSettingView.java

License:Open Source License

@Override
public void initialize() {

    autoExportSchedules = new ArrayList<SimpleComboBoxData>();
    for (Integer value : exportScheduleMap.keySet()) {
        autoExportSchedules.add(exportScheduleMap.get(value));
    }//w ww  .  j a v  a  2s  .  c  o  m
    autoDeleteSchedules = new ArrayList<SimpleComboBoxData>();
    for (Integer value : deleteScheduleMap.keySet()) {
        autoDeleteSchedules.add(deleteScheduleMap.get(value));
    }

    autoExportMonthlySchedules = new ArrayList<SimpleComboBoxData>();
    for (Integer value : monthScheduleMap.keySet()) {
        autoExportMonthlySchedules.add(monthScheduleMap.get(value));
    }
    autoExportWeeklySchedules = new ArrayList<SimpleComboBoxData>();
    for (Integer value : weekScheduleMap.keySet()) {
        autoExportWeeklySchedules.add(weekScheduleMap.get(value));
    }

    panel = new FormPanel();
    panel.setHeaderVisible(false);
    FormLayout layout = new FormLayout();
    layout.setLabelWidth(150);
    panel.setAutoWidth(true);
    panel.setAutoHeight(true);

    panel.setLayout(layout);
    // file format
    calcChoice = new Radio();
    calcChoice.setBoxLabel(I18N.CONSTANTS.openDocumentSpreadsheet());
    calcChoice.setValue(true);
    calcChoice.setName("type");

    excelChoice = new Radio();
    excelChoice.setBoxLabel(I18N.CONSTANTS.msExcel());
    excelChoice.setName("type");

    RadioGroup radioGroup = new RadioGroup();
    radioGroup.setOrientation(Orientation.VERTICAL);
    radioGroup.setFieldLabel(I18N.CONSTANTS.chooseFileType());
    radioGroup.add(calcChoice);
    radioGroup.add(excelChoice);
    panel.add(radioGroup);

    // configure fields
    // project model
    Grid<ProjectModelDTO> pModelsGrid = getModelsGrid();
    // flex elements
    Grid<FlexibleElementDTO> elementsGrid = getElementsGrid();

    FlexTable fieldsTable = new FlexTable();

    LabelField fildsTableLabel = new LabelField(I18N.CONSTANTS.configureFieldsToExport() + " :");
    fildsTableLabel.setWidth(150);
    fieldsTable.setWidget(0, 0, fildsTableLabel);

    fieldsTable.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);

    fieldsTable.setWidget(0, 1, pModelsGrid);
    fieldsTable.setWidget(0, 2, elementsGrid);
    fieldsTable.getFlexCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP);
    fieldsTable.getFlexCellFormatter().setVerticalAlignment(0, 2, HasVerticalAlignment.ALIGN_TOP);
    panel.add(fieldsTable);

    // auto export schedule
    exportScheduleStore = new ListStore<SimpleComboBoxData>();
    exportSchedulesBox = new ComboBox<SimpleComboBoxData>();
    exportSchedulesBox.setFieldLabel(I18N.CONSTANTS.autoExportSchedule());
    exportSchedulesBox.setStore(exportScheduleStore);
    exportSchedulesBox.setDisplayField("label");
    exportSchedulesBox.setValueField("value");
    exportSchedulesBox.setEditable(false);
    exportSchedulesBox.setTriggerAction(TriggerAction.ALL);
    exportScheduleStore.add(autoExportSchedules);
    exportScheduleStore.commitChanges();
    exportSchedulesBox.setValue(exportScheduleMap.get(0));
    panel.add(exportSchedulesBox);

    // auto export monthly schedule
    exportMonthlyScheduleStore = new ListStore<SimpleComboBoxData>();
    exportMonthlySchedulesBox = new ComboBox<SimpleComboBoxData>();
    exportMonthlySchedulesBox.setFieldLabel(I18N.CONSTANTS.dayInMonth());
    exportMonthlySchedulesBox.setStore(exportMonthlyScheduleStore);
    exportMonthlySchedulesBox.setDisplayField("label");
    exportMonthlySchedulesBox.setValueField("value");
    exportMonthlySchedulesBox.setEditable(false);
    exportMonthlySchedulesBox.setTriggerAction(TriggerAction.ALL);
    exportMonthlyScheduleStore.add(autoExportMonthlySchedules);
    exportMonthlyScheduleStore.commitChanges();
    exportMonthlySchedulesBox.setValue(monthScheduleMap.get(31));
    exportMonthlySchedulesBox.hide();
    panel.add(exportMonthlySchedulesBox);

    // auto export Weekly schedule
    exportWeeklyScheduleStore = new ListStore<SimpleComboBoxData>();
    exportWeeklySchedulesBox = new ComboBox<SimpleComboBoxData>();
    exportWeeklySchedulesBox.setFieldLabel(I18N.CONSTANTS.dayInWeek());
    exportWeeklySchedulesBox.setStore(exportWeeklyScheduleStore);
    exportWeeklySchedulesBox.setDisplayField("label");
    exportWeeklySchedulesBox.setValueField("value");
    exportWeeklySchedulesBox.setEditable(false);
    exportWeeklySchedulesBox.setTriggerAction(TriggerAction.ALL);
    exportWeeklyScheduleStore.add(autoExportWeeklySchedules);
    exportWeeklyScheduleStore.commitChanges();
    exportWeeklySchedulesBox.setValue(weekScheduleMap.get(61));
    exportWeeklySchedulesBox.hide();
    panel.add(exportWeeklySchedulesBox);

    // auto delete schedule
    deleteScheduleStore = new ListStore<SimpleComboBoxData>();
    deleteSchedulesBox = new ComboBox<SimpleComboBoxData>();
    deleteSchedulesBox.setFieldLabel(I18N.CONSTANTS.autoCleanupSchedule());
    deleteSchedulesBox.setStore(deleteScheduleStore);
    deleteSchedulesBox.setDisplayField("label");
    deleteSchedulesBox.setValueField("value");
    deleteSchedulesBox.setEditable(false);
    deleteSchedulesBox.setTriggerAction(TriggerAction.ALL);
    deleteScheduleStore.add(autoDeleteSchedules);
    deleteScheduleStore.commitChanges();
    deleteSchedulesBox.setValue(deleteScheduleMap.get(0));
    panel.add(deleteSchedulesBox);

    // Add onChange handler for exportSchedulesBox
    exportSchedulesBox.addListener(Events.Select, new Listener<BaseEvent>() {

        @Override
        public void handleEvent(BaseEvent be) {
            exportMonthlySchedulesBox.hide();
            exportWeeklySchedulesBox.hide();

            if (exportSchedulesBox.getValue().getValue() == 31) { // Case of Monthly Schedule
                exportMonthlySchedulesBox.show();
            } else if (exportSchedulesBox.getValue().getValue() == 61) { // Case of Weekly Schedule
                exportWeeklySchedulesBox.show();
            } else {
                // Regular case of every N days
            }
        }
    });
    // onChange handler for exportSchedulesBox handled

    // button
    saveButton = new Button(I18N.CONSTANTS.saveExportConfiguration());
    panel.getButtonBar().add(saveButton);
    panel.setScrollMode(Scroll.AUTO);
    initPopup(panel);

}

From source file:org.sigmah.client.ui.view.project.export.ExportProjectsView.java

License:Open Source License

@Override
public void initialize() {

    final FormPanel panel = Forms.panel(I18N.CONSTANTS.GLOBAL_EXPORT());
    panel.setHeaderVisible(false);/*ww  w .  j  a  v a2  s.  c o  m*/
    FormLayout layout = new FormLayout();
    layout.setLabelWidth(220);
    panel.setLayout(layout);
    panel.setScrollMode(Scroll.AUTOY);

    // version
    liveChoice = new Radio();
    liveChoice.setBoxLabel(I18N.CONSTANTS.liveData());
    liveChoice.setName("version");
    liveChoice.setValue(true);

    backupChoice = new Radio();
    backupChoice.setBoxLabel(I18N.CONSTANTS.backedUpData());
    backupChoice.setName("version");

    RadioGroup radioGroup = new RadioGroup();
    radioGroup.setOrientation(Orientation.VERTICAL);
    radioGroup.setFieldLabel(I18N.CONSTANTS.versionOfDataToExport());
    radioGroup.add(liveChoice);
    radioGroup.add(backupChoice);
    panel.add(radioGroup);

    // period
    fromDate = getDateField();
    toDate = getDateField();
    toDate.setValue(new Date());
    searchButton = new Button(I18N.CONSTANTS.search());

    periodsStore = new ListStore<GlobalExportDTO>();
    periods = new ComboBox<GlobalExportDTO>();
    periods.setWidth(180);
    periods.setStore(periodsStore);
    periods.setDisplayField("date");
    periods.setValueField("id");
    periods.setEditable(false);
    periods.setTriggerAction(TriggerAction.ALL);
    periods.setHideLabel(false);
    periods.setEnabled(false);

    final FlexTable periodTable = new FlexTable();
    periodTable.setHTML(0, 0, "<b>" + I18N.CONSTANTS.exportBackSelection() + "</b>");
    periodTable.getFlexCellFormatter().setWidth(0, 0, "220px");
    periodTable.setHTML(1, 0, I18N.CONSTANTS.specifyPeriodForBackup());
    periodTable.setWidget(1, 1, fromDate);
    periodTable.setWidget(1, 2, new LabelField(" -"));
    periodTable.setWidget(1, 3, toDate);
    periodTable.setWidget(1, 4, searchButton);
    periodTable.getFlexCellFormatter().setHeight(1, 0, "30px");

    periodTable.setHTML(2, 0, I18N.CONSTANTS.selectBackupToExport());
    periodTable.setWidget(2, 1, periods);
    periodTable.getFlexCellFormatter().setColSpan(2, 1, 4);
    panel.add(periodTable);
    periodTable.setVisible(false);

    backupChoice.addListener(Events.OnClick, new Listener<FieldEvent>() {

        @Override
        public void handleEvent(FieldEvent fe) {
            periods.setAllowBlank(false);
            periodTable.setVisible(true);

        }
    });

    liveChoice.addListener(Events.OnClick, new Listener<FieldEvent>() {

        @Override
        public void handleEvent(FieldEvent fe) {
            fromDate.clear();
            toDate.clear();
            periods.setAllowBlank(true);
            periods.clear();
            periodTable.setVisible(false);
        }
    });

    exportButton = new Button(I18N.CONSTANTS.export());
    settingsButton = new Button(I18N.CONSTANTS.changeConfiguration());
    panel.getButtonBar().add(exportButton);
    panel.getButtonBar().add(settingsButton);

    initPopup(panel);

}

From source file:org.sigmah.client.ui.widget.CalendarWidget.java

License:Open Source License

/**
 * Render the whole calendar but do not render the events.
 *//*w  w w.  ja va2  s .  c  o  m*/
public void drawEmptyCells() {
    final FlexTable grid = (FlexTable) getWidget();

    final int rows = displayMode.getRows() + displayHeaders;
    final int columns = displayMode.getColumns() + (displayWeekNumber ? 1 : 0);

    Date date = displayMode.getStartDate(startDate, firstDayOfWeek);

    // Column headers
    if (displayHeaders != NO_HEADERS) {
        if (displayHeaders == ALL_HEADERS) {
            // Header of the calendar
            final Label calendarHeader = new Label(getHeading());
            calendarHeader.addStyleName("calendar-header");
            grid.setWidget(0, 0, calendarHeader);
            grid.getFlexCellFormatter().setColSpan(0, 0, columns + (displayWeekNumber ? 1 : 0));
        }

        final Date currentHeader = new Date(date.getTime());
        for (int x = displayWeekNumber ? 1 : 0; x < columns; x++) {
            final Label columnHeader = new Label(headerFormatter.format(currentHeader));
            columnHeader.addStyleName("calendar-column-header");
            grid.setWidget(displayHeaders == ALL_HEADERS ? 1 : 0, x, columnHeader);

            currentHeader.setDate(currentHeader.getDate() + 1);
        }
    }

    int currentMonth = startDate.getMonth();
    for (int y = displayHeaders; y < rows; y++) {
        if (displayWeekNumber) {
            grid.getCellFormatter().addStyleName(y, 0, "calendar-row-header");
            grid.setText(y, 0, Integer.toString(getWeekNumber(date, firstDayOfWeek)));
        }

        for (int x = displayWeekNumber ? 1 : 0; x < columns; x++) {
            drawCell(y, x, date, currentMonth);
            date.setDate(date.getDate() + 1);
        }
    }
}