blob: 79f3e6616497724647470d6e3aa4970d66b77407 [file] [log] [blame]
/*****************************************************************************
* Copyright (c) 2010 - 2014 University of Padova.
*
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alessandro Zovi
*
*****************************************************************************/
package org.polarsys.chess.discovery.ui.wizards;
import java.io.IOException;
import java.util.Collections;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.papyrus.infra.discovery.DiscoveryDefinition;
import org.eclipse.papyrus.infra.discovery.ui.viewer.DiscoveryContentProvider;
import org.eclipse.papyrus.infra.discovery.ui.wizards.DiscoveryWizard;
import org.eclipse.papyrus.infra.discovery.ui.wizards.Messages;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
public class DiscoveryComponent {
/** URI of the model where all extra component features to be installed are referenced */
public static final String DISCOVERY_URI = "http://www.math.unipd.it/~azovi/CHESS/CHESS_Polarsys_Extra/chess-extra.xmi";
public static final Object execute() {
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
DiscoveryContentProvider provider = new DiscoveryContentProvider() {
@Override
protected DiscoveryDefinition load() {
Resource res = new XMIResourceImpl(URI.createURI(DISCOVERY_URI));
try {
res.load(Collections.EMPTY_MAP);
} catch (IOException e) {
MessageDialog.openError(window.getShell(), Messages.DiscoveryComponent_CannotConnectToSource_title, Messages.DiscoveryComponent_CannotConnectToSource_label);
throw new RuntimeException(e);
}
return (DiscoveryDefinition)res.getContents().get(0);
}
@Override
public String getDescription() {
return Messages.DiscoveryComponent_description;
}
@Override
public String getTitle() {
return Messages.DiscoveryComponent_title;
}
};
DiscoveryWizard wizard = new DiscoveryWizard(provider);
WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
return dialog.open();
}
}