use of org.apache.karaf.shell.console.completer.StringsCompleter in project cytoscape-impl by cytoscape.
the class CommandCompleter method complete.
/**
* @param buffer
* the beginning string typed by the user
* @param cursor
* the position of the cursor
* @param candidates
* the list of completions proposed to the user
*/
public int complete(String buffer, int cursor, List candidates) {
StringsCompleter delegate = new StringsCompleter();
final List<ScriptEngineFactory> engines = manager.getEngineFactories();
for (final ScriptEngineFactory engine : engines) {
final List<String> names = engine.getNames();
for (final String name : names) delegate.getStrings().add(name);
}
return delegate.complete(buffer, cursor, candidates);
}
use of org.apache.karaf.shell.console.completer.StringsCompleter in project fabric8 by jboss-fuse.
the class ProfileCompleter method complete.
@Override
public int complete(String buffer, int cursor, List<String> candidates) {
StringsCompleter delegate = new StringsCompleter();
try {
Version version = fabricService.getRequiredDefaultVersion();
List<Profile> profiles = version.getProfiles();
for (Profile profile : profiles) {
delegate.getStrings().add(profile.getId());
}
} catch (Exception ex) {
// Ignore Exceptions
}
return delegate.complete(buffer, cursor, candidates);
}
use of org.apache.karaf.shell.console.completer.StringsCompleter in project fabric8 by jboss-fuse.
the class VersionCompleter method complete.
@Override
public int complete(String buffer, int cursor, List<String> candidates) {
StringsCompleter delegate = new StringsCompleter();
ProfileService profileService = fabricService.adapt(ProfileService.class);
List<String> versions = profileService.getVersions();
for (String version : versions) {
delegate.getStrings().add(version);
}
return delegate.complete(buffer, cursor, candidates);
}
use of org.apache.karaf.shell.console.completer.StringsCompleter in project fabric8 by jboss-fuse.
the class AbstractProfileCompleter method complete.
@Override
public int complete(String buffer, int cursor, List<String> candidates) {
StringsCompleter delegate = new StringsCompleter();
try {
Version version = getFabricService().getRequiredDefaultVersion();
Container container = getFabricService().getCurrentContainer();
try {
container = getFabricService().getContainer(getContainer(CommandSessionHolder.getSession(), containerArgumentIndex));
} catch (Exception ex) {
// Ignore and use current container.
}
Profile[] containerProfiles = container.getProfiles();
List<String> containerProfileNames = new LinkedList<String>();
if (containerProfiles != null) {
for (Profile p : containerProfiles) {
containerProfileNames.add(p.getId());
}
}
List<Profile> profiles = version.getProfiles();
List<String> allProfileNames = new LinkedList<String>();
if (containerProfiles != null) {
for (Profile p : profiles) {
allProfileNames.add(p.getId());
}
}
if (assigned && unassigned) {
delegate.getStrings().addAll(allProfileNames);
} else if (assigned) {
delegate.getStrings().addAll(containerProfileNames);
} else if (unassigned) {
allProfileNames.removeAll(containerProfileNames);
delegate.getStrings().addAll(allProfileNames);
}
} catch (Exception ex) {
// Ignore Exceptions
}
return delegate.complete(buffer, cursor, candidates);
}
use of org.apache.karaf.shell.console.completer.StringsCompleter in project karaf by apache.
the class ArgumentCompleter method getDefaultCompleter.
private Completer getDefaultCompleter(Field field) {
Completer completer = null;
Class<?> type = field.getType();
if (type.isAssignableFrom(File.class)) {
completer = new FileCompleter(null);
} else if (type.isAssignableFrom(Boolean.class) || type.isAssignableFrom(boolean.class)) {
completer = new StringsCompleter(new String[] { "false", "true" }, false);
} else if (type.isAssignableFrom(Enum.class)) {
Set<String> values = new HashSet<>();
for (Object o : EnumSet.allOf((Class<Enum>) type)) {
values.add(o.toString());
}
completer = new StringsCompleter(values, false);
} else {
// TODO any other completers we can add?
}
return completer;
}
Aggregations