protected boolean isValid(final IObjectDistributor<IValidationResult> validationResultDistributor) { final IValidationResult result = validationResultDistributor.get(); return result == null || result.isValid(); }
private void updateWizardState(final IWizardPage page) { synchronized (this.mutex) { if (this.currentPage != null) { this.currentPage.getNextEnabledModel().removeChangeListener(this.nextEnableListener); this.currentPage.getBackEnabledModel().removeChangeListener(this.backEnableListener); this.currentPage.getDataStateModel().removeChangeListener(this.dataStateListener); this.currentPage.getMessageDistributor().removeChangeListener(this.messageListener); } this.currentPage = page; this.nextEnabledModel.set(this.currentPage.getNextEnabledModel().get() && hasNext()); this.backEnabledModel.set(this.currentPage.getBackEnabledModel().get() && hasPrevious()); this.dataStateModel.set(this.currentPage.getDataStateModel().get()); this.currentPage.getNextEnabledModel().addChangeListener(this.nextEnableListener); this.currentPage.getBackEnabledModel().addChangeListener(this.backEnableListener); this.currentPage.getDataStateModel().addChangeListener(this.dataStateListener); this.currentPage.getMessageDistributor().addChangeListener(this.messageListener); } this.wizardStateModel.set(new WizardState()); }
public ConfigurableAction(final IActionConfiguration configuration) { super(configuration.getCustomization()); final IBooleanDistributor enabledDistributor = configuration.getEnabledDistributor().and(this.internalEnabledModel); enabledDistributor.addChangeListener(() -> ConfigurableAction.super.setEnabled(enabledDistributor.get())); super.setEnabled(enabledDistributor.get()); this.closure = configuration.getProcedure(); final IObjectDistributor<IGuiIcon> iconDistributor = configuration.getIconDistributor(); iconDistributor.addChangeListener( () -> GuiUtilities.invokeLater( () -> putValue( Action.SMALL_ICON, Optional.of(iconDistributor.get()).convert(i -> i.getSmallIcon()).get()))); final IObjectDistributor<String> toolTipTextDistributor = configuration.getToolTipTextDistributor(); toolTipTextDistributor.addChangeListener( () -> GuiUtilities.invokeLater(() -> putValue(Action.SHORT_DESCRIPTION, toolTipTextDistributor.get()))); }
this.controller.getDataStateDistributor().addChangeListener(new IChangeableObjectListener() { this.controller.getMessageDistributor().addChangeListener(new IChangeableObjectListener() {
void update(final JPanel contentComponent, final ISelectionModel<IChooserPanelConfiguration<T>> selectionModel) { if (this.validStateModel != null) { this.validStateModel.removeChangeListener(this.validateStateListener); this.validStateModel = this.chooserPanel.getValidStateModel(); this.valueModel.addChangeListener(this.valueChangeListener); this.validStateModel.addChangeListener(this.validateStateListener); contentComponent.removeAll(); contentComponent.add(this.chooserPanel.getComponent()); if (this.valueModel.get() == null || !this.validStateModel.get().isValid()) { setTryEnabled(false); setOkEnabled(false);
public IObjectField<O> build() { final IObjectFieldConfiguration<O> configuration = this.builder.build(); final AbstractObjectTextField<O> field = create(configuration); final Color validColor = configuration.getBackgroundColor() == null ? this.VALID_COLOR : configuration.getBackgroundColor(); final IObjectDistributor<IValidationResult> validationResultDistributor = field.getValidationResultDistributor(); validationResultDistributor.addChangeListener(new IChangeableObjectListener() { @Override public void objectChanged() { GuiUtilities.invokeLater(new Runnable() { @Override public void run() { final IValidationResult validationResult = validationResultDistributor.get(); field.getColorReciever().setBackground( validationResult.isValid() ? validColor : AbstractObjectFieldBuilder.this.INVALID_COLOR); } }); } }); final IValidationResult validationResult = validationResultDistributor.get(); if (validationResult != null) { field.getColorReciever().setBackground(validationResult.isValid() ? this.VALID_COLOR : this.INVALID_COLOR); } return field; }
hourField.getValidationResultDistributor().addChangeListener(validatorsListener); minuteField.getValidationResultDistributor().addChangeListener(validatorsListener); dateModel.addChangeListener(validatorsListener);
void update(final JPanel contentComponent, final IObjectModel<IChooserPanelConfiguration<T>> selectionModel) { if (this.validStateModel != null) { this.validStateModel.removeChangeListener(this.validateStateListener); this.validStateModel = this.chooserPanel.getValidStateModel(); this.valueModel.addChangeListener(this.valueChangeListener); this.validStateModel.addChangeListener(this.validateStateListener); contentComponent.removeAll(); contentComponent.add(this.chooserPanel.getComponent()); if (this.valueModel.get() == null || !this.validStateModel.get().isValid()) { setTryEnabled(false); setOkEnabled(false);
@Override public void objectChanged() { final IWizardPage page = AbstractWizardController.this.currentPage; AbstractWizardController.this.dataStateModel.set(page.getDataStateModel().get()); } };
final protected void updateOkAction() { checkButton(this.controller.getDataStateDistributor().get()); }
@Override public void objectChanged() { if (AbstractWizardController.this.currentPage == null) { AbstractWizardController.this.messageModel.set(null); return; } AbstractWizardController.this.messageModel .set(AbstractWizardController.this.currentPage.getMessageDistributor().get()); } };
@Override public String getToolTipText() { final IToolTipFactory toolTipFactory = this.configuration.getToolTipFactory(); if (toolTipFactory == null) { return super.getToolTipText(); } final String value = getText(); final int columnWidth = getWidth(); final double valueWidth = JTextComponentUtilities.getValueWidth(this, value); if (valueWidth > columnWidth - 2) { return toolTipFactory.create(this.validationResult.get(), value); } return toolTipFactory.create(this.validationResult.get(), null); } }
@Override public String getToolTipText() { final IToolTipFactory toolTipFactory = this.configuration.getToolTipFactory(); if (toolTipFactory == null) { return super.getToolTipText(); } final String value = getText(); final int columnWidth = getWidth(); final double valueWidth = JTextComponentUtilities.getValueWidth(this, value); if (valueWidth > columnWidth - 2) { return toolTipFactory.create(this.validationResult.get(), value); } return toolTipFactory.create(this.validationResult.get(), null); } }
@Override public void objectChanged() { if (!ListChooserDialog.this.validStateModel.get().isValid()) { setMessage( new MessageBuilder().setText(ListChooserDialog.this.validStateModel.get().getMessage()).setError().build()); setTryEnabled(false); setOkEnabled(false); return; } setMessage(ListChooserDialog.this.chooserPanel.getMessage()); setTryEnabled(!(ListChooserDialog.this.chooserPanelConfiguration.getTryTaskFactory() == null)); setOkEnabled(true); } };
@Override public void objectChanged() { if (!ComboBoxChooserDialog.this.validStateModel.get().isValid()) { return; } final T object = ComboBoxChooserDialog.this.valueModel.get(); if (object == null) { setTryEnabled(false); setOkEnabled(false); return; } setTryEnabled(!(ComboBoxChooserDialog.this.chooserPanelConfiguration.getTryTaskFactory() == null)); setOkEnabled(true); } };
@Override public void objectChanged() { setMessage(ListChooserDialog.this.chooserPanel.getMessage()); if (!ListChooserDialog.this.validStateModel.get().isValid()) { setTryEnabled(false); setOkEnabled(false); return; } setTryEnabled(!(ListChooserDialog.this.chooserPanelConfiguration.getTryTaskFactory() == null)); setOkEnabled(true); } };
@Override public void objectChanged() { if (!ComboBoxChooserDialog.this.validStateModel.get().isValid()) { setMessage( new MessageBuilder() .setText(ComboBoxChooserDialog.this.validStateModel.get().getMessage()) .setError() .build()); setTryEnabled(false); setOkEnabled(false); return; } setMessage(ComboBoxChooserDialog.this.chooserPanel.getMessage()); setTryEnabled(!(ComboBoxChooserDialog.this.chooserPanelConfiguration.getTryTaskFactory() == null)); setOkEnabled(true); } };
@Override public void objectChanged() { if (dateModel.get() == null) { set("Date", "missing selected value"); return; } IValidationResult result = hourField.getValidationResultDistributor().get(); if (!result.isValid()) { set("Hour", result.getMessage()); return; } result = minuteField.getValidationResultDistributor().get(); if (!result.isValid()) { set("Minute", result.getMessage()); return; } getMessageModel().set(null); getDataStateModel().set(DataState.MODIFIED); }
public StringFieldContentPane(final String label, final IObjectFieldConfiguration<String> configuration) { this.label = label; this.stringField = new StringField(configuration); this.stringField.getModel().addChangeListener(() -> { final IValidationResult validationResult = this.stringField.getValidationResultDistributor().get(); if (validationResult.isValid()) { getDataStateModel().set(DataState.VALIDE); getMessageModel().set(null); return; } getDataStateModel().set(DataState.INVALIDE); getMessageModel() .set(Message.create(validationResult.getMessage(), validationResult.getMessage(), MessageType.ERROR)); }); }