Skip to content

Commit

Permalink
Shows icons specific to visibility in "file structure" window. (#11898)
Browse files Browse the repository at this point in the history
Use icons specific to visibility

Signed-off-by: Thomas Mäder <[email protected]>
  • Loading branch information
tsmaeder authored Nov 13, 2018
1 parent 9826864 commit 052f719
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ protected void configure() {
GinMapBinder.newMapBinder(binder(), String.class, FqnProvider.class);
fqnProviders.addBinding("maven").to(JavaFqnProvider.class);

install(
new GinFactoryModuleBuilder()
.build(org.eclipse.che.ide.ext.java.client.navigation.filestructure.NodeFactory.class));
install(new GinFactoryModuleBuilder().build(JavaNodeFactory.class));
install(
new GinFactoryModuleBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.languageserver.ide.filestructure;
package org.eclipse.che.ide.ext.java.client.navigation.filestructure;

/**
* Interface to signal selection of an element
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.eclipse.che.ide.util.loging.Log;
import org.eclipse.che.jdt.ls.extension.api.dto.ExtendedSymbolInformation;
import org.eclipse.che.jdt.ls.extension.api.dto.FileStructureCommandParameters;
import org.eclipse.che.plugin.languageserver.ide.filestructure.ElementSelectionDelegate;
import org.eclipse.che.plugin.languageserver.ide.util.DtoBuildHelper;
import org.eclipse.che.plugin.languageserver.ide.util.OpenFileInEditorHelper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.languageserver.ide.filestructure;
package org.eclipse.che.ide.ext.java.client.navigation.filestructure;

import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.Event;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.languageserver.ide.filestructure;
package org.eclipse.che.ide.ext.java.client.navigation.filestructure;

import static org.eclipse.che.ide.ui.smartTree.SelectionModel.Mode.SINGLE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
-->
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g="urn:import:org.eclipse.che.plugin.languageserver.ide.filestructure">
xmlns:g="urn:import:org.eclipse.che.ide.ext.java.client.navigation.filestructure">
<g:FileStructureTree ui:field="tree" debugId="file-structure-mainPanel" />
</ui:UiBinder>
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
import org.eclipse.che.ide.util.input.SignalEvent;
import org.eclipse.che.ide.util.input.SignalEventUtils;
import org.eclipse.che.jdt.ls.extension.api.dto.ExtendedSymbolInformation;
import org.eclipse.che.plugin.languageserver.ide.filestructure.ElementSelectionDelegate;
import org.eclipse.che.plugin.languageserver.ide.filestructure.FileStructureView;
import org.eclipse.che.plugin.languageserver.ide.filestructure.NodeFactory;

/**
* A window showing a java specific file structure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.languageserver.ide.filestructure;
package org.eclipse.che.ide.ext.java.client.navigation.filestructure;

import org.eclipse.che.jdt.ls.extension.api.dto.ExtendedSymbolInformation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,40 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.languageserver.ide.filestructure;
package org.eclipse.che.ide.ext.java.client.navigation.filestructure;

import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.che.api.promises.client.Promise;
import org.eclipse.che.api.promises.client.PromiseProvider;
import org.eclipse.che.ide.ext.java.client.util.SymbolIcons;
import org.eclipse.che.ide.ui.smartTree.data.AbstractTreeNode;
import org.eclipse.che.ide.ui.smartTree.data.HasAction;
import org.eclipse.che.ide.ui.smartTree.data.Node;
import org.eclipse.che.ide.ui.smartTree.presentation.HasNewPresentation;
import org.eclipse.che.ide.ui.smartTree.presentation.NewNodePresentation;
import org.eclipse.che.jdt.ls.extension.api.dto.ExtendedSymbolInformation;
import org.eclipse.che.plugin.languageserver.ide.navigation.symbol.SymbolKindHelper;

/**
* A node presenting {@link ExtendedSymbolInformation} objects
*
* @author Thomas Mäder
*/
public class SymbolNode extends AbstractTreeNode implements HasNewPresentation, HasAction {
private SymbolKindHelper symbolHelper;
private SymbolIcons symbolIcons;
private PromiseProvider promiseProvider;
private ElementSelectionDelegate<ExtendedSymbolInformation> delegate;
private ExtendedSymbolInformation symbol;

@Inject
public SymbolNode(
SymbolKindHelper symbolHelper,
SymbolIcons symbolIcons,
PromiseProvider promiseProvider,
@Assisted ElementSelectionDelegate<ExtendedSymbolInformation> delegate,
@Assisted ExtendedSymbolInformation symbol) {
this.symbolHelper = symbolHelper;
this.symbolIcons = symbolIcons;
this.promiseProvider = promiseProvider;
this.delegate = delegate;
this.symbol = symbol;
Expand All @@ -64,15 +64,15 @@ protected Promise<List<Node>> getChildrenImpl() {
symbol
.getChildren()
.stream()
.map(child -> new SymbolNode(symbolHelper, promiseProvider, delegate, child))
.map(child -> new SymbolNode(symbolIcons, promiseProvider, delegate, child))
.collect(Collectors.toList()));
}

@Override
public NewNodePresentation getPresentation() {
String name = symbol.getInfo().getName();
return new NewNodePresentation.Builder()
.withIcon(symbolHelper.getIcon(symbol.getInfo().getKind()))
.withIcon(symbolIcons.get(symbol))
.withNodeText(name)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.ide.ext.java.client.util;

import com.google.common.collect.ImmutableMap;
import java.util.Map;
import org.eclipse.che.ide.ext.java.client.JavaResources;
import org.eclipse.che.jdt.ls.extension.api.Visibility;
import org.eclipse.che.jdt.ls.extension.api.dto.ExtendedSymbolInformation;
import org.eclipse.lsp4j.SymbolKind;
import org.vectomatic.dom.svg.ui.SVGResource;

public class SymbolIcons {
private static final Map<Visibility, Map<SymbolKind, SVGResource>> resources;

static {
resources =
new ImmutableMap.Builder<Visibility, Map<SymbolKind, SVGResource>>()
.put(
Visibility.PUBLIC,
new ImmutableMap.Builder<SymbolKind, SVGResource>()
.put(SymbolKind.Package, JavaResources.INSTANCE.packageItem())
.put(SymbolKind.Class, JavaResources.INSTANCE.svgClassItem())
.put(SymbolKind.Method, JavaResources.INSTANCE.publicMethod())
.put(SymbolKind.Field, JavaResources.INSTANCE.publicField())
.put(SymbolKind.Constructor, JavaResources.INSTANCE.publicMethod())
.put(SymbolKind.Enum, JavaResources.INSTANCE.enumItem())
.put(SymbolKind.Interface, JavaResources.INSTANCE.interfaceItem())
.put(SymbolKind.Field, JavaResources.INSTANCE.publicField())
.put(SymbolKind.Constant, JavaResources.INSTANCE.publicField())
.put(SymbolKind.EnumMember, JavaResources.INSTANCE.publicField())
.build())
.put(
Visibility.PROTECTED,
new ImmutableMap.Builder<SymbolKind, SVGResource>()
.put(SymbolKind.Package, JavaResources.INSTANCE.packageItem())
.put(SymbolKind.Class, JavaResources.INSTANCE.svgClassItem())
.put(SymbolKind.Method, JavaResources.INSTANCE.protectedMethod())
.put(SymbolKind.Field, JavaResources.INSTANCE.protectedField())
.put(SymbolKind.Constructor, JavaResources.INSTANCE.protectedMethod())
.put(SymbolKind.Enum, JavaResources.INSTANCE.enumItem())
.put(SymbolKind.Interface, JavaResources.INSTANCE.interfaceItem())
.put(SymbolKind.Field, JavaResources.INSTANCE.protectedField())
.put(SymbolKind.Constant, JavaResources.INSTANCE.protectedField())
.put(SymbolKind.EnumMember, JavaResources.INSTANCE.protectedField())
.build())
.put(
Visibility.PACKAGE,
new ImmutableMap.Builder<SymbolKind, SVGResource>()
.put(SymbolKind.Package, JavaResources.INSTANCE.packageItem())
.put(SymbolKind.Class, JavaResources.INSTANCE.svgClassItem())
.put(SymbolKind.Method, JavaResources.INSTANCE.defaultMethod())
.put(SymbolKind.Field, JavaResources.INSTANCE.defaultField())
.put(SymbolKind.Constructor, JavaResources.INSTANCE.defaultMethod())
.put(SymbolKind.Enum, JavaResources.INSTANCE.enumItem())
.put(SymbolKind.Interface, JavaResources.INSTANCE.interfaceItem())
.put(SymbolKind.Field, JavaResources.INSTANCE.defaultField())
.put(SymbolKind.Constant, JavaResources.INSTANCE.defaultField())
.put(SymbolKind.EnumMember, JavaResources.INSTANCE.defaultField())
.build())
.put(
Visibility.PRIVATE,
new ImmutableMap.Builder<SymbolKind, SVGResource>()
.put(SymbolKind.Package, JavaResources.INSTANCE.packageItem())
.put(SymbolKind.Class, JavaResources.INSTANCE.svgClassItem())
.put(SymbolKind.Method, JavaResources.INSTANCE.privateMethod())
.put(SymbolKind.Field, JavaResources.INSTANCE.privateField())
.put(SymbolKind.Constructor, JavaResources.INSTANCE.privateMethod())
.put(SymbolKind.Enum, JavaResources.INSTANCE.enumItem())
.put(SymbolKind.Interface, JavaResources.INSTANCE.interfaceItem())
.put(SymbolKind.Field, JavaResources.INSTANCE.privateField())
.put(SymbolKind.Constant, JavaResources.INSTANCE.privateField())
.put(SymbolKind.EnumMember, JavaResources.INSTANCE.privateField())
.build())
.build();
}

public SVGResource get(ExtendedSymbolInformation symbol) {
Visibility visiblity = symbol.getVisiblity();
return resources
.get(visiblity == null ? Visibility.PACKAGE : visiblity)
.get(symbol.getInfo().getKind());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ protected void configure() {
install(new GinFactoryModuleBuilder().build(LanguageServerReconcileStrategyFactory.class));
install(new GinFactoryModuleBuilder().build(LanguageServerSignatureHelpFactory.class));
install(new GinFactoryModuleBuilder().build(RenameNodeFactory.class));
install(
new GinFactoryModuleBuilder()
.build(org.eclipse.che.plugin.languageserver.ide.filestructure.NodeFactory.class));

bind(PublishDiagnosticsReceiver.class).asEagerSingleton();
bind(ShowMessageJsonRpcReceiver.class).asEagerSingleton();
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<che.dashboard.version>6.14.0-SNAPSHOT</che.dashboard.version>
<che.docs.version>6.14.0-SNAPSHOT</che.docs.version>
<che.lib.version>6.14.0-SNAPSHOT</che.lib.version>
<che.ls.jdt.version>0.0.1</che.ls.jdt.version>
<che.ls.jdt.version>0.0.2-SNAPSHOT</che.ls.jdt.version>
<che.version>6.14.0-SNAPSHOT</che.version>
<specification.version>1.0-beta2</specification.version>
</properties>
Expand Down

0 comments on commit 052f719

Please sign in to comment.