Skip to content

Commit

Permalink
Merge pull request #1275 from eclipse/CHE-1086
Browse files Browse the repository at this point in the history
CHE-1086: expand containers of the classpath
  • Loading branch information
Valeriy Svydenko committed May 18, 2016
2 parents 54db11a + c8d7df3 commit a38525f
Show file tree
Hide file tree
Showing 50 changed files with 840 additions and 597 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void hide() {
@Override
public void renderKeybindings() {
list.clear();
list.render(categoriesList);
list.render(categoriesList, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void setPreferences(Map<String, Set<PreferencePagePresenter>> preferences
preferencesPageDelegate));
}

list.render(categoriesList);
list.render(categoriesList, true);
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void setImporters(Map<String, Set<ProjectImporterDescriptor>> categories)
projectImporterDelegate));
}

list.render(categoriesList);
list.render(categoriesList, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public int compare(ProjectTemplateDescriptor o1, ProjectTemplateDescriptor o2) {
}
}

categoriesList.render(categories);
categoriesList.render(categories, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public class CategoriesList extends Composite {
private final SelectionManager selectionManager;
private List<CategoryNodeElement> categoryNodeElements;

private FlowPanel rootPanel;
private FlowPanel scrollPanel;
private FlowPanel lockPanel;
private FlowPanel rootPanel;
private FlowPanel scrollPanel;
private FlowPanel lockPanel;

private boolean enabled = true;

Expand Down Expand Up @@ -65,11 +65,13 @@ public CategoriesList(Resources resources) {
*
* @param categories
* the categories
* @param renderChildren
* if is true - child node will be expanded, otherwise only root node.
*/
public void render(List<Category<?>> categories) {
public void render(List<Category<?>> categories, boolean renderChildren) {
this.categoryNodeElements = new ArrayList<>();
for (Category category : categories) {
CategoryNodeElement categoryNodeElement = new CategoryNodeElement(category, selectionManager, resources);
CategoryNodeElement categoryNodeElement = new CategoryNodeElement(category, renderChildren, selectionManager, resources);
categoryNodeElements.add(categoryNodeElement);
scrollPanel.add(categoryNodeElement);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ public class CategoryNodeElement extends FlowPanel {
private Element selectedElement;

@SuppressWarnings("unchecked")
CategoryNodeElement(Category category,
CategoriesList.SelectionManager selectionManager, CategoriesList.Resources resources) {
CategoryNodeElement(final Category category,
boolean renderChildren,
CategoriesList.SelectionManager selectionManager,
CategoriesList.Resources resources) {
this.category = category;
this.selectionManager = selectionManager;
CategoryRenderer renderer = category.getRenderer();
Expand All @@ -71,6 +73,9 @@ public class CategoryNodeElement extends FlowPanel {
header.addDomHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (category.getData().isEmpty()) {
return;
}
expandOrCollapse();
}
}, ClickEvent.getType());
Expand Down Expand Up @@ -131,10 +136,14 @@ public void onKeyDown(KeyDownEvent keyDownEvent) {
}, KeyDownEvent.getType());
add(header);
add(container);
animator = new AnimationController.Builder().setCollapse(true).setFade(true).build();
animator = new AnimationController.Builder().setCollapse(false).setFade(false).build();
expanded = true;
renderChildren();
expandControl.addClassName(resources.defaultCategoriesListCss().expandedImage());
if (renderChildren) {
expandControl.addClassName(resources.defaultCategoriesListCss().expandedImage());
} else {
expandOrCollapse();
}
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private void renderCategoriesList(Map<DebugConfigurationType, List<DebugConfigur
}

list.clear();
list.render(categoriesList);
list.render(categoriesList, true);
if (selectedConfiguration != null) {
list.selectElement(selectedConfiguration);
if (filterTextValue.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,6 @@ public interface JavaLocalizationConstant extends Messages {
@Key("library.title")
String libraryTitle();

@Key("button.remove")
String removeElementButton();

@Key("button.addJar")
String addJarButton();

Expand All @@ -384,9 +381,6 @@ public interface JavaLocalizationConstant extends Messages {
@Key("unsavedChanges.title")
String unsavedChangesTitle();

@Key("button.addClassFolder")
String buttonAddClassFolder();

@Key("button.done")
String buttonDone();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.eclipse.che.ide.ext.java.client.project.classpath.service.ClasspathServiceClient;
import org.eclipse.che.ide.ext.java.client.project.node.PackageNode;
import org.eclipse.che.ide.ext.java.client.project.node.SourceFolderNode;
import org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDTO;
import org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto;
import org.eclipse.che.ide.part.explorer.project.ProjectExplorerPresenter;
import org.eclipse.che.ide.project.node.FolderReferenceNode;

Expand Down Expand Up @@ -102,9 +102,9 @@ public void updateInPerspective(ActionEvent e) {
}

private void updateClasspath(final CurrentProject currentProject, final FolderReferenceNode folder) {
classpathService.getClasspath(currentProject.getProjectConfig().getPath()).then(new Operation<List<ClasspathEntryDTO>>() {
classpathService.getClasspath(currentProject.getProjectConfig().getPath()).then(new Operation<List<ClasspathEntryDto>>() {
@Override
public void apply(List<ClasspathEntryDTO> arg) throws OperationException {
public void apply(List<ClasspathEntryDto> arg) throws OperationException {
classpathResolver.resolveClasspathEntries(arg);
classpathResolver.getSources().add(folder.getStorablePath());
classpathResolver.updateClasspath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.eclipse.che.ide.ext.java.client.project.classpath.ClasspathResolver;
import org.eclipse.che.ide.ext.java.client.project.classpath.service.ClasspathServiceClient;
import org.eclipse.che.ide.ext.java.client.project.node.SourceFolderNode;
import org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDTO;
import org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto;
import org.eclipse.che.ide.part.explorer.project.ProjectExplorerPresenter;
import org.eclipse.che.ide.project.node.FolderReferenceNode;

Expand Down Expand Up @@ -97,9 +97,9 @@ public void updateInPerspective(ActionEvent e) {
}

private void updateClasspath(final CurrentProject currentProject, final FolderReferenceNode folder) {
classpathService.getClasspath(currentProject.getProjectConfig().getPath()).then(new Operation<List<ClasspathEntryDTO>>() {
classpathService.getClasspath(currentProject.getProjectConfig().getPath()).then(new Operation<List<ClasspathEntryDto>>() {
@Override
public void apply(List<ClasspathEntryDTO> arg) throws OperationException {
public void apply(List<ClasspathEntryDto> arg) throws OperationException {
classpathResolver.resolveClasspathEntries(arg);
classpathResolver.getSources().remove(folder.getStorablePath());
classpathResolver.updateClasspath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.eclipse.che.api.promises.client.js.Promises;
import org.eclipse.che.ide.ext.java.client.project.classpath.ClasspathChangedEvent;
import org.eclipse.che.ide.ext.java.client.project.classpath.service.ClasspathServiceClient;
import org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDTO;
import org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto;

import java.util.HashMap;
import java.util.List;
Expand All @@ -33,7 +33,7 @@
public class ClasspathContainer implements ClasspathChangedEvent.ClasspathChangedHandler {
private final ClasspathServiceClient classpathServiceClient;

private Map<String, Promise<List<ClasspathEntryDTO>>> classpathes;
private Map<String, Promise<List<ClasspathEntryDto>>> classpathes;

@Inject
public ClasspathContainer(ClasspathServiceClient classpathServiceClient, EventBus eventBus) {
Expand All @@ -52,11 +52,11 @@ public ClasspathContainer(ClasspathServiceClient classpathServiceClient, EventBu
* path to the project
* @return list of the classpath entries
*/
public Promise<List<ClasspathEntryDTO>> getClasspathEntries(String projectPath) {
public Promise<List<ClasspathEntryDto>> getClasspathEntries(String projectPath) {
if (classpathes.containsKey(projectPath)) {
return classpathes.get(projectPath);
} else {
Promise<List<ClasspathEntryDTO>> result = classpathServiceClient.getClasspath(projectPath);
Promise<List<ClasspathEntryDto>> result = classpathServiceClient.getClasspath(projectPath);
classpathes.put(projectPath, result);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void setMainClass(String mainClass) {
public String toCommandLine() {
final StringBuilder cmd = new StringBuilder("");
if (!commandLine.trim().isEmpty()) {
cmd.append(' ').append(commandLine.trim());
cmd.append(commandLine.trim());
}
return cmd.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.eclipse.che.ide.ext.java.client.command.ClasspathContainer;
import org.eclipse.che.ide.ext.java.client.project.classpath.ClasspathResolver;
import org.eclipse.che.ide.ext.java.shared.Constants;
import org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDTO;
import org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto;
import org.eclipse.che.ide.extension.machine.client.command.valueproviders.CommandPropertyValueProvider;

import java.util.List;
Expand Down Expand Up @@ -70,9 +70,9 @@ public Promise<String> getValue() {
final String projectPath = currentProject.getProjectConfig().getPath();

return classpathContainer.getClasspathEntries(projectPath).then(
new Function<List<ClasspathEntryDTO>, String>() {
new Function<List<ClasspathEntryDto>, String>() {
@Override
public String apply(List<ClasspathEntryDTO> arg) throws FunctionException {
public String apply(List<ClasspathEntryDto> arg) throws FunctionException {
classpathResolver.resolveClasspathEntries(arg);
Set<String> libs = classpathResolver.getLibs();
StringBuilder classpath = new StringBuilder("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.eclipse.che.ide.ext.java.client.command.ClasspathContainer;
import org.eclipse.che.ide.ext.java.client.project.classpath.ClasspathResolver;
import org.eclipse.che.ide.ext.java.shared.Constants;
import org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDTO;
import org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto;
import org.eclipse.che.ide.extension.machine.client.command.valueproviders.CommandPropertyValueProvider;

import java.util.List;
Expand Down Expand Up @@ -70,23 +70,23 @@ public Promise<String> getValue() {
final String projectPath = currentProject.getProjectConfig().getPath();

return classpathContainer.getClasspathEntries(projectPath).then(
new Function<List<ClasspathEntryDTO>, String>() {
new Function<List<ClasspathEntryDto>, String>() {
@Override
public String apply(List<ClasspathEntryDTO> arg) throws FunctionException {
public String apply(List<ClasspathEntryDto> arg) throws FunctionException {
classpathResolver.resolveClasspathEntries(arg);
Set<String> sources = classpathResolver.getSources();
StringBuilder classpath = new StringBuilder("");
StringBuilder sourcepath = new StringBuilder("");
for (String source : sources) {
classpath.append(source);
sourcepath.append(source.substring(projectPath.length() + 1));
}

if (classpath.toString().isEmpty()) {
classpath.append(appContext.getProjectsRoot()).append(projectPath);
if (sourcepath.toString().isEmpty()) {
sourcepath.append(appContext.getProjectsRoot()).append(projectPath);
}

classpath.append(':');
sourcepath.append(':');

return classpath.toString();
return sourcepath.toString();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

import org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDTO;
import org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto;

import java.util.List;

Expand All @@ -27,8 +27,8 @@ public class ClasspathChangedEvent extends GwtEvent<ClasspathChangedEvent.Classp
/** Type class used to register this event. */
public static Type<ClasspathChangedHandler> TYPE = new Type<>();

private final List<ClasspathEntryDTO> entries;
private final String projectPath;
private final List<ClasspathEntryDto> entries;
private final String projectPath;

/**
* Creates an event to initiate changing of classpath.
Expand All @@ -38,7 +38,7 @@ public class ClasspathChangedEvent extends GwtEvent<ClasspathChangedEvent.Classp
* @param entries
* classpath entries
*/
public ClasspathChangedEvent(String projectPath, List<ClasspathEntryDTO> entries) {
public ClasspathChangedEvent(String projectPath, List<ClasspathEntryDto> entries) {
this.projectPath = projectPath;
this.entries = entries;
}
Expand All @@ -54,7 +54,7 @@ public String getPath() {
}

/** Returns classpath entries. */
public List<ClasspathEntryDTO> getEntries() {
public List<ClasspathEntryDto> getEntries() {
return entries;
}

Expand Down
Loading

0 comments on commit a38525f

Please sign in to comment.