Search in sources :

Example 1 with AT

use of org.palladiosimulator.architecturaltemplates.AT in project Palladio-Editors-Sirius by PalladioSimulator.

the class AddATAction method execute.

/**
 * Creates an {@link ArchitecturalTemplateSelectEObjectDialog} that queries the user for an
 * {@link AT} and applies the corresponding {@link Stereotype} to the selected {@link System}.
 */
@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
    final ArchitecturalTemplateSelectionDialog profileSelectionDialog = new ArchitecturalTemplateSelectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
    profileSelectionDialog.setElements(ArchitecturalTemplateAPI.getRegisteredArchitecturalTemplates().toArray(new AT[ArchitecturalTemplateAPI.getRegisteredArchitecturalTemplates().size()]));
    profileSelectionDialog.setMessage(DIALOG_MESSAGE);
    if (profileSelectionDialog.open() != Dialog.OK) {
        return;
    }
    final AT at = profileSelectionDialog.getResultArchitecturalTemplate();
    final EObject eObject = selections.iterator().next();
    if (eObject instanceof System) {
        final System system = (System) eObject;
        ArchitecturalTemplateAPI.applyArchitecturalTemplate(system, at);
    } else if (eObject instanceof ResourceEnvironment) {
        final ResourceEnvironment resourceenvironment = (ResourceEnvironment) eObject;
        ArchitecturalTemplateAPI.applyArchitecturalTemplate(resourceenvironment, at);
    } else {
        throw new RuntimeException("Unsupported eObject: " + eObject);
    }
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) AT(org.palladiosimulator.architecturaltemplates.AT) ArchitecturalTemplateSelectionDialog(org.palladiosimulator.architecturaltemplates.ui.dialogs.ArchitecturalTemplateSelectionDialog) EObject(org.eclipse.emf.ecore.EObject) System(org.palladiosimulator.pcm.system.System)

Example 2 with AT

use of org.palladiosimulator.architecturaltemplates.AT in project Palladio-Editors-Sirius by PalladioSimulator.

the class NewPalladioTemplateWizardPage method selectionChanged.

@SuppressWarnings("rawtypes")
@Override
public void selectionChanged(final SelectionChangedEvent event) {
    setErrorMessage(null);
    final IStructuredSelection selection = (IStructuredSelection) event.getSelection();
    AT currentTemplateSelection = null;
    final Iterator iter = selection.iterator();
    if (iter.hasNext()) {
        currentTemplateSelection = (AT) iter.next();
    }
    if (currentTemplateSelection == null) {
        setSelectedTemplate(null);
        return;
    }
    setSelectedTemplate(currentTemplateSelection);
    getContainer().updateButtons();
}
Also used : AT(org.palladiosimulator.architecturaltemplates.AT) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

AT (org.palladiosimulator.architecturaltemplates.AT)2 Iterator (java.util.Iterator)1 EObject (org.eclipse.emf.ecore.EObject)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 ArchitecturalTemplateSelectionDialog (org.palladiosimulator.architecturaltemplates.ui.dialogs.ArchitecturalTemplateSelectionDialog)1 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)1 System (org.palladiosimulator.pcm.system.System)1