aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbveliev2011-10-23 04:53:57 (EDT)
committerbveliev2011-10-23 04:53:57 (EDT)
commit655d0515dce1c444a2bb1ff545da4399666b4e6e (patch)
tree723d4cfd938f8d197f03545052d4321f60660d68
parent8f128927fe1d93a0e32c3cfd7c8a4553a2b77139 (diff)
downloadorg.eclipse.rtp-655d0515dce1c444a2bb1ff545da4399666b4e6e.zip
org.eclipse.rtp-655d0515dce1c444a2bb1ff545da4399666b4e6e.tar.gz
org.eclipse.rtp-655d0515dce1c444a2bb1ff545da4399666b4e6e.tar.bz2
NEW - bug 361741: [Configurator] "list" command should mark installed
features https://bugs.eclipse.org/bugs/show_bug.cgi?id=361741
-rw-r--r--bundles/org.eclipse.rtp.configurator.console/src/org/eclipse/rtp/configurator/console/CommandDelegateImpl.java1
-rw-r--r--bundles/org.eclipse.rtp.core.model/src/org/eclipse/rtp/core/model/Source.java32
-rw-r--r--bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/RTPDefaultService.java40
-rw-r--r--bundles/org.eclipse.rtp.core/src/org/eclipse/rtp/core/util/ModelUtil.java13
4 files changed, 61 insertions, 25 deletions
diff --git a/bundles/org.eclipse.rtp.configurator.console/src/org/eclipse/rtp/configurator/console/CommandDelegateImpl.java b/bundles/org.eclipse.rtp.configurator.console/src/org/eclipse/rtp/configurator/console/CommandDelegateImpl.java
index 47d85ac..53abe08 100644
--- a/bundles/org.eclipse.rtp.configurator.console/src/org/eclipse/rtp/configurator/console/CommandDelegateImpl.java
+++ b/bundles/org.eclipse.rtp.configurator.console/src/org/eclipse/rtp/configurator/console/CommandDelegateImpl.java
@@ -24,6 +24,7 @@ public class CommandDelegateImpl implements CommandDelegate {
public static void setUp( IRTPService service ) {
CommandDelegateImpl.configurationService = service;
+ commandUtil = new CommandUtil();
}
public static void shutDown( IRTPService service ) {
diff --git a/bundles/org.eclipse.rtp.core.model/src/org/eclipse/rtp/core/model/Source.java b/bundles/org.eclipse.rtp.core.model/src/org/eclipse/rtp/core/model/Source.java
index 01e1e77..0c82c8b 100644
--- a/bundles/org.eclipse.rtp.core.model/src/org/eclipse/rtp/core/model/Source.java
+++ b/bundles/org.eclipse.rtp.core.model/src/org/eclipse/rtp/core/model/Source.java
@@ -1,19 +1,15 @@
-/*******************************************************************************
-* Copyright (c) 2011 EclipseSource and others. All rights reserved. This
-* program and the accompanying materials are made available under the terms of
-* the Eclipse Public License v1.0 which accompanies this distribution, and is
-* available at http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* EclipseSource - initial API and implementation
-*******************************************************************************/
+/*******************************************************************************
+ * Copyright (c) 2011 EclipseSource and others. All rights reserved. This program and the
+ * accompanying materials are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html Contributors: EclipseSource - initial API and
+ * implementation
+ *******************************************************************************/
package org.eclipse.rtp.core.model;
import java.util.ArrayList;
import java.util.List;
-
-
public class Source {
private String name;
@@ -21,7 +17,6 @@ public class Source {
private String infoUrl;
private List<SourceVersion> versions;
-
Source() {
// only for Gson
}
@@ -44,7 +39,7 @@ public class Source {
public List<SourceVersion> getVersions() {
return new ArrayList<SourceVersion>( versions );
}
-
+
public String getDescription() {
return description;
}
@@ -52,16 +47,13 @@ public class Source {
public String getInfoUrl() {
return infoUrl;
}
-
+
@Override
public String toString() {
StringBuilder result = new StringBuilder();
- result.append( "Name: " + name + "\n");
- result.append( "Description: " + description + "\n");
- result.append( "Information URL: " + infoUrl + "\n");
- for( SourceVersion version : versions ) {
- result.append( version.toString() + "\n" );
- }
+ result.append( "Name: " + name + "\n" );
+ result.append( "Description: " + description + "\n" );
+ result.append( "Information URL: " + infoUrl + "\n" );
return result.toString();
}
}
diff --git a/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/RTPDefaultService.java b/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/RTPDefaultService.java
index 8e1b852..f2f9911 100644
--- a/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/RTPDefaultService.java
+++ b/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/RTPDefaultService.java
@@ -117,7 +117,7 @@ public class RTPDefaultService implements IRTPService {
public List<String> search( List<String> anyListOf ) {
List<Source> sources = ModelUtil.getSourceProvider().getSources();
List<Source> result = searchSources( sources, anyListOf );
- return getSortedSources( result );
+ return sourcesToStringSorted( result, false );
}
@Override
@@ -126,13 +126,13 @@ public class RTPDefaultService implements IRTPService {
List<String> showSource = new ArrayList<String>();
showSource.add( anyListOf.get( 0 ) );
List<Source> result = searchSources( sources, showSource );
- return getSortedSources( result );
+ return sourcesToStringSorted( result, false );
}
@Override
public List<String> list() throws CoreException {
List<Source> sources = ModelUtil.getSourceProvider().getSources();
- List<String> sourcesAsString = getSortedSources( sources );
+ List<String> sourcesAsString = sourcesToStringSorted( sources, true );
return sourcesAsString;
}
@@ -182,12 +182,42 @@ public class RTPDefaultService implements IRTPService {
return result;
}
- private List<String> getSortedSources( List<Source> sources ) {
+ private List<String> sourcesToStringSorted( List<Source> sources, boolean addInstalledInfo ) {
+ List<String> sourcesAsString = sourcesToString( sources, addInstalledInfo );
+ return sourcesAsString;
+ }
+
+ private List<String> sourcesToString( List<Source> sources, boolean addInstalledInfo ) {
+ Collections.sort( sources, new ModelUtil().getSourceComparator() );
List<String> sourcesAsString = new ArrayList<String>();
for( Source source : sources ) {
sourcesAsString.add( source.toString() );
+ List<String> versionsToString = versionsToString( source, addInstalledInfo );
+ sourcesAsString.addAll( versionsToString );
}
- Collections.sort( sourcesAsString );
return sourcesAsString;
}
+
+ private List<String> versionsToString( Source source, boolean addInstalledInfo ) {
+ List<SourceVersion> versions = source.getVersions();
+ Collections.sort( versions, new ModelUtil().getSourceVersionComparator() );
+ List<String> result = new ArrayList<String>();
+ for( SourceVersion sourceVersion : versions ) {
+ if( addInstalledInfo ) {
+ String installedInfo = getInstallInfor( sourceVersion );
+ result.add( installedInfo );
+ }
+ result.add( sourceVersion.toString() );
+ }
+ return result;
+ }
+
+ private String getInstallInfor( SourceVersion sourceVersion ) {
+ FeatureManager featureManager = p2Util.getFeatureManager();
+ boolean installed = featureManager.isInstalled( sourceVersion );
+ String installedInfo = installed
+ ? "[installed]"
+ : "[not installed]";
+ return installedInfo;
+ }
}
diff --git a/bundles/org.eclipse.rtp.core/src/org/eclipse/rtp/core/util/ModelUtil.java b/bundles/org.eclipse.rtp.core/src/org/eclipse/rtp/core/util/ModelUtil.java
index bf054ae..cdd19b6 100644
--- a/bundles/org.eclipse.rtp.core/src/org/eclipse/rtp/core/util/ModelUtil.java
+++ b/bundles/org.eclipse.rtp.core/src/org/eclipse/rtp/core/util/ModelUtil.java
@@ -98,6 +98,19 @@ public class ModelUtil {
return comparator;
}
+ public Comparator<Source> getSourceComparator() {
+ Comparator<Source> comparator = new Comparator<Source>() {
+
+ @Override
+ public int compare( Source arg0, Source arg1 ) {
+ String name = arg0.getName();
+ String name2 = arg1.getName();
+ return name.compareTo( name2 );
+ }
+ };
+ return comparator;
+ }
+
public List<Source> searchSources( List<String> anyListOf, List<Source> sources ) {
List<Source> result = new ArrayList<Source>();
for( Source source : sources ) {