Skip to content

Commit

Permalink
eclipse-archived#190 In progress TqCL-syntax and library services
Browse files Browse the repository at this point in the history
  • Loading branch information
rtotaro committed Jan 4, 2017
1 parent 01305c1 commit e5a5ed9
Showing 1 changed file with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Map.Entry;

import org.apache.commons.lang.StringUtils;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.graphiti.features.ICreateFeature;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
Expand All @@ -31,6 +32,8 @@
import org.eclipse.triquetrum.commands.api.services.TqCLLibraryProvider;
import org.eclipse.triquetrum.commands.tqcl.Category;
import org.eclipse.triquetrum.commands.tqcl.Insert;
import org.eclipse.triquetrum.commands.tqcl.Library;
import org.eclipse.triquetrum.commands.tqcl.TriquetrumScript;
import org.eclipse.triquetrum.workflow.editor.TriqDiagramTypeProvider;
import org.eclipse.triquetrum.workflow.editor.TriqFeatureProvider;
import org.eclipse.triquetrum.workflow.editor.features.ModelElementCreateFeature;
Expand Down Expand Up @@ -70,29 +73,37 @@ private void initFeatureMap() {
}
}

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void completeInsert_Obj(EObject model, Assignment assignment, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {

try {
Insert insert = (Insert) model;
TriquetrumScript triquetrumScript = (TriquetrumScript) insert.eContainer();
EList<Library> libraries = triquetrumScript.getLibraries();
TqCLLibraryProvider tcqlLibraryProvider = TqCLServices.getInstance().getTcqlLibraryProvider();
Category category = insert.getCategory();
List<? extends EntityDescriptor> descriptors = new ArrayList<>();
if (libraries == null) {
return;
}
if (insert.getCategory() == null) {
category = Category.ACTOR;
}
List<? extends EntityDescriptor> descriptors = new ArrayList<>();
switch (category) {
case ACTOR:
descriptors = tcqlLibraryProvider.getActors("Triquetrum");
break;

case DIRECTOR:
descriptors = tcqlLibraryProvider.getDirectors("Triquetrum");
break;

default:
break;
for (Library library : libraries) {
switch (category) {
case ACTOR:
descriptors.addAll((List) tcqlLibraryProvider.getActors(library.getName()));
break;

case DIRECTOR:
descriptors.addAll((List) tcqlLibraryProvider.getDirectors(library.getName()));
break;

default:
break;
}
}
for (EntityDescriptor key : descriptors) {
ICompletionProposal completionProposal = createCompletionProposal(key.getClazz(), context);
Expand Down

0 comments on commit e5a5ed9

Please sign in to comment.