Search in sources :

Example 1 with ArtifactIdChangeHandler

use of org.guvnor.common.services.project.client.ArtifactIdChangeHandler in project kie-wb-common by kiegroup.

the class POMWizardPage method addChangeHandlers.

private void addChangeHandlers() {
    this.pomEditor.addNameChangeHandler(new NameChangeHandler() {

        @Override
        public void onChange(String newName) {
            validateName(pomEditor.getPom().getName());
            if (pomEditor.getPom().getGav().getArtifactId() == null || pomEditor.getPom().getGav().getArtifactId().isEmpty()) {
                userModifiedArtifactId = false;
            }
            // TODO Move to PomBuilder
            final String sanitizedProjectName = NewWorkspaceProjectUtils.sanitizeProjectName(pomEditor.getPom().getName());
            if (!userModifiedArtifactId) {
                pomEditor.setArtifactID(sanitizedProjectName);
                validateArtifactId(sanitizedProjectName);
            }
            final WizardPageStatusChangeEvent event = new WizardPageStatusChangeEvent(POMWizardPage.this);
            POMWizardPage.this.wizardPageStatusChangeEvent.fire(event);
        }
    });
    this.pomEditor.addGroupIdChangeHandler(new GroupIdChangeHandler() {

        @Override
        public void onChange(String newGroupId) {
            validateGroupId(pomEditor.getPom().getGav().getGroupId());
            final WizardPageStatusChangeEvent event = new WizardPageStatusChangeEvent(POMWizardPage.this);
            POMWizardPage.this.wizardPageStatusChangeEvent.fire(event);
        }
    });
    this.pomEditor.addArtifactIdChangeHandler(new ArtifactIdChangeHandler() {

        @Override
        public void onChange(String newArtifactId) {
            userModifiedArtifactId = true;
            validateArtifactId(pomEditor.getPom().getGav().getArtifactId());
            final WizardPageStatusChangeEvent event = new WizardPageStatusChangeEvent(POMWizardPage.this);
            POMWizardPage.this.wizardPageStatusChangeEvent.fire(event);
        }
    });
    this.pomEditor.addVersionChangeHandler(new VersionChangeHandler() {

        @Override
        public void onChange(String newVersion) {
            validateVersion(pomEditor.getPom().getGav().getVersion());
            final WizardPageStatusChangeEvent event = new WizardPageStatusChangeEvent(POMWizardPage.this);
            POMWizardPage.this.wizardPageStatusChangeEvent.fire(event);
        }
    });
}
Also used : ArtifactIdChangeHandler(org.guvnor.common.services.project.client.ArtifactIdChangeHandler) GroupIdChangeHandler(org.guvnor.common.services.project.client.GroupIdChangeHandler) WizardPageStatusChangeEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent) NameChangeHandler(org.guvnor.common.services.project.client.NameChangeHandler) VersionChangeHandler(org.guvnor.common.services.project.client.VersionChangeHandler)

Example 2 with ArtifactIdChangeHandler

use of org.guvnor.common.services.project.client.ArtifactIdChangeHandler in project kie-wb-common by kiegroup.

the class POMWizardPageTest method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
    gavEditor = new GAVEditor(gavEditorView);
    pomEditor = spy(new POMEditorPanel(pomEditorView, syncBeanManager, gavPreferences, projectScopedResolutionStrategySupplier));
    // POMEditorView implementation updates a nested GAVEditor presenter. Mock the implementation to avoid use of real widgets
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(final InvocationOnMock invocation) throws Throwable {
            final String artifactId = (String) invocation.getArguments()[0];
            gavEditor.setArtifactID(artifactId);
            return null;
        }
    }).when(pomEditorView).setArtifactID(any(String.class));
    // POMEditorView implementation updates a nested GAVEditor presenter. Mock the implementation to avoid use of real widgets
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(final InvocationOnMock invocation) throws Throwable {
            final GAV gav = (GAV) invocation.getArguments()[0];
            gavEditor.setGAV(gav);
            return null;
        }
    }).when(pomEditorView).setGAV(any(GAV.class));
    // POMEditorView implementation updates a nested GAVEditor presenter. Mock the implementation to avoid use of real widgets
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(final InvocationOnMock invocation) throws Throwable {
            final ArtifactIdChangeHandler handler = (ArtifactIdChangeHandler) invocation.getArguments()[0];
            gavEditor.addArtifactIdChangeHandler(handler);
            return null;
        }
    }).when(pomEditorView).addArtifactIdChangeHandler(any(ArtifactIdChangeHandler.class));
    page = spy(new POMWizardPage(pomEditor, view, event, new CallerMock<ProjectScreenService>(projectScreenService), new CallerMock<ValidationService>(validationService)));
    page.initialise();
    doAnswer(invocationOnMock -> {
        ((ParameterizedCommand<GAVPreferences>) invocationOnMock.getArguments()[1]).execute(gavPreferences);
        return null;
    }).when(gavPreferences).load(any(PreferenceScopeResolutionStrategyInfo.class), any(ParameterizedCommand.class), any(ParameterizedCommand.class));
}
Also used : POMEditorPanel(org.guvnor.common.services.project.client.POMEditorPanel) ArtifactIdChangeHandler(org.guvnor.common.services.project.client.ArtifactIdChangeHandler) InvocationOnMock(org.mockito.invocation.InvocationOnMock) PreferenceScopeResolutionStrategyInfo(org.uberfire.preferences.shared.impl.PreferenceScopeResolutionStrategyInfo) GAVEditor(org.guvnor.common.services.project.client.GAVEditor) ValidationService(org.kie.workbench.common.services.shared.validation.ValidationService) ProjectScreenService(org.kie.workbench.common.screens.projecteditor.service.ProjectScreenService) GAV(org.guvnor.common.services.project.model.GAV) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Before(org.junit.Before)

Aggregations

ArtifactIdChangeHandler (org.guvnor.common.services.project.client.ArtifactIdChangeHandler)2 GAVEditor (org.guvnor.common.services.project.client.GAVEditor)1 GroupIdChangeHandler (org.guvnor.common.services.project.client.GroupIdChangeHandler)1 NameChangeHandler (org.guvnor.common.services.project.client.NameChangeHandler)1 POMEditorPanel (org.guvnor.common.services.project.client.POMEditorPanel)1 VersionChangeHandler (org.guvnor.common.services.project.client.VersionChangeHandler)1 GAV (org.guvnor.common.services.project.model.GAV)1 Before (org.junit.Before)1 ProjectScreenService (org.kie.workbench.common.screens.projecteditor.service.ProjectScreenService)1 ValidationService (org.kie.workbench.common.services.shared.validation.ValidationService)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 WizardPageStatusChangeEvent (org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent)1 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)1 PreferenceScopeResolutionStrategyInfo (org.uberfire.preferences.shared.impl.PreferenceScopeResolutionStrategyInfo)1