|
| 1 | +package org.gemoc.execution.sequential.javaxdsml.ide.ui.editor; |
| 2 | + |
| 3 | +import java.util.Set; |
| 4 | + |
| 5 | +import org.eclipse.core.resources.IProject; |
| 6 | +import org.eclipse.core.resources.IResource; |
| 7 | +import org.eclipse.emf.common.util.URI; |
| 8 | +import org.eclipse.jface.dialogs.Dialog; |
| 9 | +import org.eclipse.ui.PlatformUI; |
| 10 | +import org.gemoc.commons.eclipse.ui.dialogs.SelectAnyIProjectDialog; |
| 11 | +import org.gemoc.execution.sequential.javaxdsml.ide.ui.editor.SelectEcoreProposal.SelectEcoreIFileDialog; |
| 12 | +import org.gemoc.execution.sequential.javaxdsml.ide.ui.templates.SequentialTemplate; |
| 13 | + |
| 14 | +import fr.inria.diverse.melange.ui.contentassist.IProposal; |
| 15 | + |
| 16 | +public class SelectDsaProposal implements IProposal{ |
| 17 | + |
| 18 | + @Override |
| 19 | + public String getDisplayText() { |
| 20 | + return "Import existing DSA project"; |
| 21 | + } |
| 22 | + |
| 23 | + @Override |
| 24 | + public String getReplacementText() { |
| 25 | + SelectAnyIProjectDialog dialog = new SelectAnyIProjectDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); |
| 26 | + if (dialog.open() == Dialog.OK) { |
| 27 | + Object[] selections = dialog.getResult(); |
| 28 | + if(selections != null |
| 29 | + && selections.length != 0 |
| 30 | + && selections[0] instanceof IProject |
| 31 | + ){ |
| 32 | + IProject project = (IProject) selections[0]; |
| 33 | + Set<String> aspects = SequentialTemplate.getAspectClassesList(project); |
| 34 | + final StringBuilder insertion = new StringBuilder(); |
| 35 | + for (String asp : aspects) { |
| 36 | + insertion.append("\twith " + asp + "\n"); |
| 37 | + } |
| 38 | + insertion.replace(0, 1, "");//remove the first \t |
| 39 | + return insertion.toString(); |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + return "with qualified.class.name"; |
| 44 | + } |
| 45 | + |
| 46 | +} |
0 commit comments