Search in sources :

Example 6 with ExampleProject

use of org.kie.workbench.common.screens.examples.model.ExampleProject in project kie-wb-common by kiegroup.

the class ProjectPage method fetchRepository.

private void fetchRepository(final ExampleRepository selectedRepository) {
    examplesService.call(new RemoteCallback<Set<ExampleProject>>() {

        @Override
        public void callback(final Set<ExampleProject> projects) {
            activeView = projectsView;
            model.getProjects().clear();
            model.setSourceRepository(selectedRepository);
            final List<ExampleProject> sortedProjects = sort(projects);
            projectsView.setProjectsInRepository(sortedProjects);
            exampleProjects = sortedProjects;
            pageSelectedEvent.fire(new WizardPageSelectedEvent(ProjectPage.this));
        }
    }, new DefaultErrorCallback() {

        @Override
        public boolean error(final Message message, final Throwable throwable) {
            model.setSourceRepository(null);
            model.getSelectedRepository().setUrlValid(false);
            return super.error(message, throwable);
        }
    }).getProjects(selectedRepository);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) Message(org.jboss.errai.bus.client.api.messaging.Message) DefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback) WizardPageSelectedEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageSelectedEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject)

Example 7 with ExampleProject

use of org.kie.workbench.common.screens.examples.model.ExampleProject in project kie-wb-common by kiegroup.

the class ProjectPage method updateProjectsInRepository.

private void updateProjectsInRepository(final Collection<String> tags) {
    List<ExampleProject> resultList = exampleProjects.stream().filter(p -> tags.stream().allMatch(userTag -> p.getTags().stream().anyMatch(projectTag -> projectTag.toLowerCase().contains(userTag.toLowerCase())))).sorted((o1, o2) -> o1.getName().compareTo(o2.getName())).collect(Collectors.toList());
    projectsView.setProjectsInRepository(resultList);
    pageSelectedEvent.fire(new WizardPageSelectedEvent(ProjectPage.this));
}
Also used : WizardPageStatusChangeEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent) ArrayList(java.util.ArrayList) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) HashSet(java.util.HashSet) Inject(javax.inject.Inject) WizardPageSelectedEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageSelectedEvent) IsWidget(com.google.gwt.user.client.ui.IsWidget) DefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback) Event(javax.enterprise.event.Event) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) Collection(java.util.Collection) Set(java.util.Set) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) ExamplesService(org.kie.workbench.common.screens.examples.service.ExamplesService) Collectors(java.util.stream.Collectors) ExamplesScreenConstants(org.kie.workbench.common.screens.examples.client.resources.i18n.ExamplesScreenConstants) List(java.util.List) Widget(com.google.gwt.user.client.ui.Widget) Message(org.jboss.errai.bus.client.api.messaging.Message) Dependent(javax.enterprise.context.Dependent) Callback(org.uberfire.client.callbacks.Callback) Caller(org.jboss.errai.common.client.api.Caller) BaseExamplesWizardPage(org.kie.workbench.common.screens.examples.client.wizard.pages.BaseExamplesWizardPage) PostConstruct(javax.annotation.PostConstruct) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject) Comparator(java.util.Comparator) Collections(java.util.Collections) WizardPageSelectedEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageSelectedEvent) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject)

Example 8 with ExampleProject

use of org.kie.workbench.common.screens.examples.model.ExampleProject in project kie-wb-common by kiegroup.

the class ProjectPageViewImpl method setProjectsInRepository.

@Override
public void setProjectsInRepository(final List<ExampleProject> projects) {
    this.projects.removeAllChildren();
    for (ExampleProject project : projects) {
        final ProjectItemView w = makeProjectWidget(project);
        this.projects.appendChild(w.asWidget().getElement());
    }
}
Also used : ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject)

Example 9 with ExampleProject

use of org.kie.workbench.common.screens.examples.model.ExampleProject in project kie-wb-common by kiegroup.

the class ProjectPageTest method testIsComplete_SelectedProjects.

@Test
@SuppressWarnings("unchecked")
public void testIsComplete_SelectedProjects() {
    model.addProject(new ExampleProject(mock(Path.class), "", "", Collections.EMPTY_LIST));
    final Callback<Boolean> callback = mock(Callback.class);
    page.isComplete(callback);
    verify(callback, times(1)).callback(eq(true));
}
Also used : ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject) Test(org.junit.Test)

Example 10 with ExampleProject

use of org.kie.workbench.common.screens.examples.model.ExampleProject in project kie-wb-common by kiegroup.

the class ProjectPageTest method testIsProjectSelected_Selected.

@Test
public void testIsProjectSelected_Selected() {
    final ExampleProject project = mock(ExampleProject.class);
    model.addProject(project);
    assertTrue(page.isProjectSelected(project));
}
Also used : ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject) Test(org.junit.Test)

Aggregations

ExampleProject (org.kie.workbench.common.screens.examples.model.ExampleProject)27 Test (org.junit.Test)18 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)14 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)8 ExampleOrganizationalUnit (org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit)7 WorkspaceProjectContextChangeEvent (org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)6 Module (org.guvnor.common.services.project.model.Module)6 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)6 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)6 Branch (org.guvnor.structure.repositories.Branch)6 Path (org.uberfire.backend.vfs.Path)6 HashSet (java.util.HashSet)5 ConfigGroup (org.guvnor.structure.server.config.ConfigGroup)4 ArrayList (java.util.ArrayList)3 NewProjectEvent (org.guvnor.common.services.project.events.NewProjectEvent)3 KieModule (org.kie.workbench.common.services.shared.project.KieModule)3 WizardPageSelectedEvent (org.uberfire.ext.widgets.core.client.wizards.WizardPageSelectedEvent)3 HashMap (java.util.HashMap)2 Set (java.util.Set)2 POM (org.guvnor.common.services.project.model.POM)2