/******************************************************************************* | |
* Copyright (c) 2011 BSI Business Systems Integration AG. | |
* 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: | |
* Daniel Wiehl (BSI Business Systems Integration AG) - initial API and implementation | |
******************************************************************************/ | |
package org.eclipse.scout.sdk.ws.jaxws.swt.wizard; | |
import java.util.LinkedList; | |
import java.util.List; | |
import org.eclipse.core.runtime.CoreException; | |
import org.eclipse.core.runtime.IProgressMonitor; | |
import org.eclipse.jdt.core.IType; | |
import org.eclipse.scout.sdk.jobs.OperationJob; | |
import org.eclipse.scout.sdk.ui.internal.ScoutSdkUi; | |
import org.eclipse.scout.sdk.ui.wizard.AbstractWorkspaceWizard; | |
import org.eclipse.scout.sdk.util.type.TypeUtility; | |
import org.eclipse.scout.sdk.util.typecache.IWorkingCopyManager; | |
import org.eclipse.scout.sdk.workspace.IScoutBundle; | |
import org.eclipse.scout.sdk.ws.jaxws.JaxWsIcons; | |
import org.eclipse.scout.sdk.ws.jaxws.JaxWsSdk; | |
import org.eclipse.scout.sdk.ws.jaxws.Texts; | |
import org.eclipse.scout.sdk.ws.jaxws.operation.WsProviderCodeFirstDeleteOperation; | |
import org.eclipse.scout.sdk.ws.jaxws.operation.WsProviderDeleteOperation; | |
import org.eclipse.scout.sdk.ws.jaxws.swt.model.SunJaxWsBean; | |
import org.eclipse.scout.sdk.ws.jaxws.swt.wizard.page.ElementBean; | |
import org.eclipse.scout.sdk.ws.jaxws.swt.wizard.page.ResourceSelectionWizardPage; | |
public class WsProviderCodeFirstDeleteWizard extends AbstractWorkspaceWizard { | |
private ResourceSelectionWizardPage m_wizardPage; | |
private IScoutBundle m_bundle; | |
private SunJaxWsBean m_sunJaxWsBean; | |
private WsProviderCodeFirstDeleteOperation m_operation; | |
public WsProviderCodeFirstDeleteWizard() { | |
setWindowTitle(Texts.get("DeleteWebServiceProvider")); | |
} | |
@Override | |
public void addPages() { | |
m_wizardPage = new ResourceSelectionWizardPage(Texts.get("DeleteWebServiceProvider"), Texts.get("QuestionDeletion")); | |
m_wizardPage.setElements(getElementsToBeDeleted()); | |
addPage(m_wizardPage); | |
} | |
private List<ElementBean> getElementsToBeDeleted() { | |
List<ElementBean> elements = new LinkedList<ElementBean>(); | |
// registration | |
elements.add(new ElementBean(WsProviderDeleteOperation.ID_REGISTRATION, "Registration entry in sun-jaxws.xml and build-jaxws.xml", JaxWsSdk.getImageDescriptor(JaxWsIcons.SunJaxWsXmlFile), true)); | |
// port type | |
String fqn = m_sunJaxWsBean.getImplementation(); | |
if (TypeUtility.existsType(fqn)) { | |
IType portType = TypeUtility.getType(fqn); | |
elements.add(new ElementBean(WsProviderDeleteOperation.ID_IMPL_TYPE, "Port type '" + portType.getFullyQualifiedName() + "'", ScoutSdkUi.getImageDescriptor(ScoutSdkUi.Class), portType, false)); | |
} | |
return elements; | |
} | |
@Override | |
protected boolean beforeFinish() throws CoreException { | |
m_operation = new WsProviderCodeFirstDeleteOperation(); | |
m_operation.setBundle(m_bundle); | |
m_operation.setSunJaxWsBean(m_sunJaxWsBean); | |
List<ElementBean> elements = new LinkedList<ElementBean>(); | |
for (ElementBean element : m_wizardPage.getElements()) { | |
if (element.isChecked() || element.isMandatory()) { | |
elements.add(element); | |
} | |
} | |
m_operation.setElements(elements); | |
return true; | |
} | |
@Override | |
protected boolean performFinish(IProgressMonitor monitor, IWorkingCopyManager workingCopyManager) throws CoreException, IllegalArgumentException { | |
OperationJob job = new OperationJob(m_operation); | |
job.schedule(); | |
return true; | |
} | |
public IScoutBundle getBundle() { | |
return m_bundle; | |
} | |
public void setBundle(IScoutBundle bundle) { | |
m_bundle = bundle; | |
} | |
public SunJaxWsBean getSunJaxWsBean() { | |
return m_sunJaxWsBean; | |
} | |
public void setSunJaxWsBean(SunJaxWsBean sunJaxWsBean) { | |
m_sunJaxWsBean = sunJaxWsBean; | |
} | |
} |