this.unassigned = unassigned;
}
@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);
}