|
From: Benjamin B. <bg...@us...> - 2005-06-23 08:17:17
|
Update of /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/rsa/ui/internal/wizards In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5526/Plugin/com/ibm/ecute/rsa/ui/internal/wizards Modified Files: WizardsResources.properties Added Files: GenerateCMPIProvidersWizard.java GenerateCMPIProvidersWizardPage.java Log Message: Version 2.1 beta 1e: CMPI provider generator support --- NEW FILE: GenerateCMPIProvidersWizard.java --- /* * Created on Jun 22, 2005 */ package com.ibm.ecute.rsa.ui.internal.wizards; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; import org.eclipse.ui.IExportWizard; import org.eclipse.ui.IWorkbench; import com.ibm.ecute.EcuteEclipsePlugin; import com.ibm.ecute.utils.Constants; import com.ibm.ecute.utils.License; import com.ibm.xtools.msl.core.internal.services.model.ApplicationConfiguration; /** * Copyright (c) 2003, International Business Machines * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES * RECIPIENTS ACCEPTANCE OF THE AGREEMENT. * * You can obtain a current copy of the Common Public License from * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html * * @author Benjamin Bender <be...@de...> */ public class GenerateCMPIProvidersWizard extends Wizard implements IExportWizard{ // Copyright private static final String COPYRIGHT = License.COPYRIGHT; //private static final String MOF_EXTENSION = EcuteBundle.getResourceString("MOF.extension"); private static final String PAGE_DESCRIPTION = EcuteBundle.getResourceString("GenerateCMPI.description"); private static final String PAGE_TITLE = EcuteBundle.getResourceString("GenerateCMPI.title") + " (" + Constants.toolName + " " + Constants.pluginVersion + ")"; private final String MODEL_EXTENSION = ApplicationConfiguration.getFileExtensionForType("Model"); private IStructuredSelection selection; private GenerateCMPIProvidersWizardPage mainPage; /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) */ public void init(IWorkbench workbench, IStructuredSelection sel) { selection = sel; setWindowTitle(PAGE_TITLE); setDefaultPageImageDescriptor(EcuteEclipsePlugin.imageDescriptorFromPlugin("com.ibm.ecute","icons/wizards/cimMOFExport.gif")); } public void addPages() { super.addPages(); mainPage = new GenerateCMPIProvidersWizardPage("Main", selection, new String[] {MODEL_EXTENSION}); mainPage.setTitle(PAGE_TITLE); mainPage.setDescription(PAGE_DESCRIPTION); addPage(mainPage); } /* (non-Javadoc) * @see org.eclipse.jface.wizard.IWizard#performFinish() */ public boolean performFinish() { return mainPage.performFinish(); } } --- NEW FILE: GenerateCMPIProvidersWizardPage.java --- /* * Created on Jun 22, 2005 */ package com.ibm.ecute.rsa.ui.internal.wizards; import java.awt.event.KeyEvent; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.Hashtable; import java.util.Iterator; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.emf.common.util.EList; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.WizardDataTransferPage; import org.eclipse.uml2.Model; import org.eclipse.uml2.Package; import com.ibm.ecute.EcuteEclipsePlugin; import com.ibm.ecute.EntryPoint; import com.ibm.ecute.rsa.core.internal.dialogs.PackageSelectionDialog; import com.ibm.ecute.rsa.core.internal.dialogs.ProgressLogDialog; import com.ibm.ecute.rsa.ui.internal.wizards.command.ModelLabelProvider; import com.ibm.ecute.rsa.ui.internal.wizards.command.ModelPackageContentProvider; import com.ibm.ecute.utils.Constants; import com.ibm.ecute.utils.PropertyList; import com.ibm.xtools.emf.msl.internal.EObjectUtil; import com.ibm.xtools.modeler.UMLModeler; import com.ibm.xtools.modeler.ui.wizards.internal.utils.FilteredFileSelectionDialog; import com.ibm.xtools.msl.core.internal.util.EObjectResourceUtil; /** * Copyright (c) 2003, International Business Machines * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES * RECIPIENTS ACCEPTANCE OF THE AGREEMENT. * * You can obtain a current copy of the Common Public License from * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html * * @author Benjamin Bender <be...@de...> */ public class GenerateCMPIProvidersWizardPage extends WizardDataTransferPage { private static final String FILE_EXT_MODEL = EcuteBundle.getResourceString("MODEL.extension"); private static final String CMPI_GROUP = EcuteBundle.getResourceString("CMPI.provider.groupTitle"); private static final String CMPI_PATH = EcuteBundle.getResourceString("CMPI.provider.pathLabel"); private static final String CMPI_BROWSE = EcuteBundle.getResourceString("CMPI.provider.browse"); private static final String CMPI_CODE = EcuteBundle.getResourceString("CMPI.provider.codeNS"); private static final String CMPI_REP = EcuteBundle.getResourceString("CMPI.provider.repositoryNS"); private static final String CMPI_CIMMOM = EcuteBundle.getResourceString("CMPI.provider.cimmomNS"); private static final String SOURCE_GROUP = EcuteBundle.getResourceString("CMPI.source.groupTitle"); private static final String SOURCE_MODEL = EcuteBundle.getResourceString("CMPI.source.label"); private static final String SOURCE_BROWSE = EcuteBundle.getResourceString("CMPI.source.browse"); private static final String SOURCE_BROWSE_TIP = EcuteBundle.getResourceString("CMPI.source.browseToolTip"); private static final String SOURCE_ADD = EcuteBundle.getResourceString("CMPI.source.add"); private static final String SOURCE_ADD_TIP = EcuteBundle.getResourceString("CMPI.source.addToolTip"); private static final String SOURCE_REMOVE = EcuteBundle.getResourceString("CMPI.source.remove"); private static final String SOURCE_REMOVE_TIP = EcuteBundle.getResourceString("CMPI.source.removeToolTip"); private static final String SOURCE_CLEAR = EcuteBundle.getResourceString("CMPI.source.clear"); private static final String SOURCE_CLEAR_TIP = EcuteBundle.getResourceString("CMPI.source.clearToolTip"); private static final String SOURCE_ALL_PACKAGES = EcuteBundle.getResourceString("CMPI.source.allPackages"); private static final String SOURCE_SELECTED_PACKAGES = EcuteBundle.getResourceString("CMPI.source.selectedPackages"); private static final String SOURCE_MISSING_PACKAGES = EcuteBundle.getResourceString("CMPI.source.missingPackages"); private static final String SOURCE_CHECKB_QUALIFIERS = EcuteBundle.getResourceString("CMPI.source.checkBoxQualifiers"); private static final String SOURCE_DIALOG_TITLE = EcuteBundle.getResourceString("CMPI.sourceDialog.title"); private static final String SOURCE_DIALOG_MESSAGE = EcuteBundle.getResourceString("CMPI.sourceDialog.message"); private static final String SOURCE_PACKAGES_DIALOG_TITLE = EcuteBundle.getResourceString("CMPI.sourcePackageDialog.title"); private static final String SOURCE_PACKAGES_DIALOG_MESSAGE = EcuteBundle.getResourceString("CMPI.sourcePackageDialog.message"); private static final String SOURCE_PACKAGES_INFO_TITLE = EcuteBundle.getResourceString("CMPI.source.packages.info.title"); private static final String SOURCE_PACKAGES_INFO_MESSAGE = EcuteBundle.getResourceString("CMPI.source.packages.info.message"); private static final String SOURCE_PATH_ERROR1 = EcuteBundle.getResourceString("CMPI.sourcePath.error1"); private static final String DESTINATION_DIALOG_TITLE = EcuteBundle.getResourceString("CMPI.destinationDialog.title"); private static final String DESTINATION_DIALOG_MESSAGE = EcuteBundle.getResourceString("CMPI.destinationDialog.message"); private static final String DESTINATION_PATH_ERROR1 = EcuteBundle.getResourceString("CMPI.destinationPath.error1"); private static final String DESTINATION_PATH_ERROR2 = EcuteBundle.getResourceString("CMPI.destinationPath.error2"); private static final String DESTINATION_CODE_NS_ERROR = EcuteBundle.getResourceString("CMPI.codeNamespace.error"); private static final String DESTINATION_REPOSITORY_NS_ERROR = EcuteBundle.getResourceString("CMPI.repositoryNamespace.error"); private static final String DESTINATION_CIMMOM_NS_ERROR = EcuteBundle.getResourceString("CMPI.cimmimNamespace.error"); private Label modelLabel; private Text sourcePathField; private Button sourceBrowseButton; private Button sourceAllPackagesButton; private Button sourceSelectedPackagesButton; private Label sourcePackageLabel; private List sourceSelectedPackagesList; private Button sourceAddPackages; private Button sourceRemovePackages; private Button sourceClearPackages; private Button sourceQualifiersButton; private Label pathLabel; private Text destinationPathField; private Button destinationBrowseButton; private Label codeLabel; private Text codeField; private Label repositoryLabel; private Text repositoryField; private Label cimmomLabel; private Text cimmomField; private String selectedPackages[]; private Hashtable packageTable; private final String sourceFileExtensions[]; private boolean validSyntax; private static final String SOURCE_FILE_DELIMETER = "\""; private ProgressLogDialog progressLog; private String selectedModel; public GenerateCMPIProvidersWizardPage(String s, IStructuredSelection selection, String as[]) { super(s); selectedPackages = null; validSyntax = true; sourceFileExtensions = as; modelLabel = null; sourcePathField = null; sourceBrowseButton = null; sourceAllPackagesButton = null; sourceSelectedPackagesButton= null; sourcePackageLabel = null; sourceSelectedPackagesList = null; pathLabel = null; destinationPathField = null; destinationBrowseButton = null; codeLabel = null; codeField = null; repositoryLabel = null; repositoryField = null; cimmomLabel = null; cimmomField = null; selectedModel = null; packageTable = new Hashtable(); IResource currentResourceSelection = null; Object firstElement = selection.getFirstElement(); if (firstElement instanceof IAdaptable) { Object resource = ((IAdaptable) firstElement).getAdapter(org.eclipse.core.resources.IResource.class); if (resource != null) { currentResourceSelection = (IResource) resource; if (currentResourceSelection.getType() == 1) { if(currentResourceSelection.getFileExtension()!= null){ if(currentResourceSelection.getFileExtension().equalsIgnoreCase(FILE_EXT_MODEL)){ selectedModel = currentResourceSelection.getFullPath().toString(); } } } } }else{ Model model = null; ArrayList packageList = new ArrayList(); java.util.List list = UMLModeler.getUMLUIHelper().getSelectedElements(); Iterator it = list.iterator(); while(it.hasNext()){ Object obj = it.next(); if(obj instanceof Package && !(obj instanceof Model)){ Package package_ = (Package)obj; if(model == null) model = package_.getModel(); if(package_.getModel().equals(model)){ packageList.add(package_.getQualifiedName()); packageTable.put(package_.getQualifiedName(), package_); } }else{ model = (Model)obj; } } for(int i = 0; i< packageList.size(); i++){ Package package_ = (Package)packageTable.get(packageList.get(i)); EList subP = package_.getNestedPackages(); for(int j=0; j< subP.size(); j++){ String subPName = ((Package)subP.get(j)).getQualifiedName(); packageList.remove(subPName); packageTable.remove(subPName); } } if(packageList.size()>0){ selectedPackages = new String[packageList.size()]; for(int i=0; i<packageList.size(); i++){ selectedPackages[i] = (String) packageList.get(i); } } if(model!= null) selectedModel = EObjectResourceUtil.getFile(model).getProject().toString().substring(1)+"/"+model.getName()+"."+FILE_EXT_MODEL; } } public void createControl(Composite parent) { initializeDialogUnits(parent); Composite composite = new Composite(parent, 0); composite.setLayout(new GridLayout()); composite.setLayoutData(new GridData(272)); composite.setSize(composite.computeSize(-1, -1)); composite.setFont(parent.getFont()); createSourceGroup(composite); createDestinationGroup(composite); setPageComplete(checkPageCompletion()); setControl(composite); } private void createSourceGroup(Composite composite) { // create source group Group group = new Group(composite, 0); group.setLayoutData(new GridData(768)); group.setLayout(new FormLayout()); group.setText(SOURCE_GROUP); // create model label modelLabel = new Label(group, 0); modelLabel.setText(SOURCE_MODEL); // create model path field sourcePathField = new Text(group, SWT.BORDER); sourcePathField.setFocus(); if(selectedModel != null) sourcePathField.setText(selectedModel); // Create Browse Button sourceBrowseButton = new Button(group, SWT.PUSH); sourceBrowseButton.setText(SOURCE_BROWSE); sourceBrowseButton.setToolTipText(SOURCE_BROWSE_TIP); sourceBrowseButton.addListener(SWT.Selection, this); //Create All Packages Buttons sourceAllPackagesButton = new Button(group, SWT.RADIO); sourceAllPackagesButton.setText(SOURCE_ALL_PACKAGES); sourceAllPackagesButton.setSelection(true); sourceAllPackagesButton.addListener(SWT.Selection, this); //Create Selected Packages Button sourceSelectedPackagesButton = new Button(group, SWT.RADIO); sourceSelectedPackagesButton.setText(SOURCE_SELECTED_PACKAGES); sourceSelectedPackagesButton.addListener(SWT.Selection, this); //Create Selected Packages List sourcePackageLabel = new Label(group, 0); sourcePackageLabel.setText("Selected packages:"); sourcePackageLabel.setEnabled(false); sourceSelectedPackagesList = new List(group, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI); sourceSelectedPackagesList.addListener(SWT.KeyDown, this); sourceSelectedPackagesList.setEnabled(false); //Create Add Button sourceAddPackages = new Button(group, SWT.PUSH); sourceAddPackages.setText(SOURCE_ADD); sourceAddPackages.setToolTipText(SOURCE_ADD_TIP); sourceAddPackages.addListener(SWT.Selection, this); sourceAddPackages.setEnabled(false); //Create Remove Button sourceRemovePackages = new Button(group, SWT.PUSH); sourceRemovePackages.setText(SOURCE_REMOVE); sourceRemovePackages.setToolTipText(SOURCE_REMOVE_TIP); sourceRemovePackages.addListener(SWT.Selection, this); sourceRemovePackages.setEnabled(false); //Create Clear Button sourceClearPackages = new Button(group, SWT.PUSH); sourceClearPackages.setText(SOURCE_CLEAR); sourceClearPackages.setToolTipText(SOURCE_CLEAR_TIP); sourceClearPackages.addListener(SWT.Selection, this); sourceClearPackages.setEnabled(false); //Create Qualifiers CheckBox sourceQualifiersButton = new Button(group, SWT.CHECK); sourceQualifiersButton.setText(SOURCE_CHECKB_QUALIFIERS); sourceQualifiersButton.addListener(SWT.Selection, this); sourceQualifiersButton.setSelection(true); layoutSourceGroup(); if(selectedPackages!=null && selectedPackages.length > 0){ handleSelectedPackagesButtonPressed(); sourceSelectedPackagesList.setItems(selectedPackages); } } private void layoutSourceGroup(){ FormData formdata = new FormData(); formdata.top = new FormAttachment(0, 13); formdata.left = new FormAttachment(0, 5); modelLabel.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(0, 11); formdata.left = new FormAttachment(modelLabel, 5); formdata.right = new FormAttachment(sourceBrowseButton, -5); sourcePathField.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(0, 10); formdata.right = new FormAttachment(100, -5); sourceBrowseButton.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(sourcePathField, 8); formdata.left = new FormAttachment(0, 5); formdata.right = new FormAttachment(100, -5); sourceAllPackagesButton.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(sourceAllPackagesButton, 5); formdata.left = new FormAttachment(0, 5); formdata.right = new FormAttachment(100, -5); sourceSelectedPackagesButton.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(sourceSelectedPackagesButton, 10); formdata.left = new FormAttachment(0, 5); sourcePackageLabel.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(sourcePackageLabel, 5); formdata.left = new FormAttachment(0, 5); formdata.width = 300; formdata.height = 70; sourceSelectedPackagesList.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(sourcePackageLabel, 5); formdata.left = new FormAttachment(sourceSelectedPackagesList, 5); formdata.right = new FormAttachment(100, -5); sourceAddPackages.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(sourceAddPackages, 5); formdata.left = new FormAttachment(sourceSelectedPackagesList, 5); formdata.right = new FormAttachment(100, -5); sourceRemovePackages.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(sourceRemovePackages, 5); formdata.left = new FormAttachment(sourceSelectedPackagesList, 5); formdata.right = new FormAttachment(100, -5); sourceClearPackages.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(sourceSelectedPackagesList, 10); formdata.bottom = new FormAttachment(100, -5); formdata.left = new FormAttachment(0, 5); sourceQualifiersButton.setLayoutData(formdata); } protected void createDestinationGroup(Composite composite) { Group group = new Group(composite, 0); group.setLayoutData(new GridData(768)); group.setText(CMPI_GROUP); group.setLayout(new FormLayout()); pathLabel = new Label(group, 0); pathLabel.setText(CMPI_PATH); destinationPathField = new Text(group, SWT.BORDER); destinationPathField.addListener(SWT.Modify, this); destinationBrowseButton = new Button(group, SWT.PUSH); destinationBrowseButton.setText(CMPI_BROWSE); destinationBrowseButton.addListener(SWT.Selection, this); codeLabel = new Label(group, 0); codeLabel.setText(CMPI_CODE); codeField = new Text(group, SWT.BORDER); codeField.addListener(SWT.Modify, this); repositoryLabel = new Label(group, 0); repositoryLabel.setText(CMPI_REP); repositoryField = new Text(group, SWT.BORDER); repositoryField.addListener(SWT.Modify, this); cimmomLabel = new Label(group, 0); cimmomLabel.setText(CMPI_CIMMOM); cimmomField = new Text(group, SWT.BORDER); cimmomField.addListener(SWT.Modify, this); layoutDestinationGroup(); } private void layoutDestinationGroup(){ FormData formdata = new FormData(); formdata.top = new FormAttachment(0, 13); formdata.left = new FormAttachment(0, 5); pathLabel.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(0, 11); formdata.left = new FormAttachment(repositoryLabel, 5); formdata.right = new FormAttachment(destinationBrowseButton, -5); destinationPathField.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(0, 10); formdata.right = new FormAttachment(100, -5); destinationBrowseButton.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(destinationPathField, 12); formdata.left = new FormAttachment(0, 5); codeLabel.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(destinationPathField, 10); formdata.left = new FormAttachment(repositoryLabel, 5); formdata.right = new FormAttachment(100, -5); codeField.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(codeField, 12); formdata.left = new FormAttachment(0, 5); repositoryLabel.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(codeField, 10); formdata.left = new FormAttachment(repositoryLabel, 5); formdata.right = new FormAttachment(100, -5); repositoryField.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(repositoryField, 12); formdata.left = new FormAttachment(0, 5); cimmomLabel.setLayoutData(formdata); formdata = new FormData(); formdata.top = new FormAttachment(repositoryField, 10); formdata.bottom = new FormAttachment(100, -5); formdata.left = new FormAttachment(repositoryLabel, 5); formdata.right = new FormAttachment(100, -5); cimmomField.setLayoutData(formdata); } private boolean checkPageCompletion() { boolean complete = validateSourceGroup() && validateDestinationGroup(); if (complete) { setErrorMessage(null); setMessage(null); } return complete; } protected boolean validateSourceGroup() { if(!isControlCreated()) return false; boolean sourceVal = true; String errorMsg = ""; if(isValidSourcePath()){ if(sourceSelectedPackagesButton.getSelection()){ if (sourceSelectedPackagesList.getItemCount() == 0) { setMessage(SOURCE_MISSING_PACKAGES); sourceVal = false; } } }else{ setErrorMessage(SOURCE_PATH_ERROR1); sourceVal = false; } if (sourceVal) { setErrorMessage(null); setMessage(null); } return sourceVal; } protected boolean validateDestinationGroup() { if(!isControlCreated()) return false; String s = destinationPathField.getText(); if(s.length() == 0) { setMessage(DESTINATION_PATH_ERROR1); setErrorMessage(null); return false; } String b = codeField.getText(); if(b.length() == 0) { setMessage(DESTINATION_CODE_NS_ERROR); setErrorMessage(null); return false; } b = repositoryField.getText(); if(b.length() == 0) { setMessage(DESTINATION_REPOSITORY_NS_ERROR); setErrorMessage(null); return false; } b = cimmomField.getText(); if(b.length() == 0) { setMessage(DESTINATION_CIMMOM_NS_ERROR); setErrorMessage(null); return false; } File file = new File(s); if(file.isDirectory()) { setErrorMessage(null); setMessage(null); return true; } else { setErrorMessage(DESTINATION_PATH_ERROR2); return false; } } private boolean isValidSourcePath(){ boolean result = false; if(sourcePathField.getText().trim().length() > 0){ IPath modelPath = new Path(sourcePathField.getText().trim()); IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot workspaceRoot = workspace.getRoot(); IResource resource = workspaceRoot.getFile(modelPath); if (resource != null && resource.exists() && resource.isAccessible()) { result = true; } } return result; } public void handleEvent(Event event) { org.eclipse.swt.widgets.Widget source = event.widget; if(source == sourcePathField){ if(isControlCreated()) handleClearPackagesButtonPressed(); } if (source == sourceBrowseButton) { handleBrowseSourceButtonPressed(); } if(source == sourceAllPackagesButton){ handleAllPackagesButtonPressed(); } if(source == sourceSelectedPackagesButton){ handleSelectedPackagesButtonPressed(); } if(source == sourceAddPackages){ handleAddPackagesButtonPressed(); } if(source == sourceRemovePackages){ handleRemovePackagesButtonPressed(); } if(source == sourceClearPackages){ handleClearPackagesButtonPressed(); } if (source == sourceSelectedPackagesList && event.keyCode == KeyEvent.VK_DELETE) { handleRemovePackagesButtonPressed(); } if (source == destinationBrowseButton) { handleBrowseDestinationButtonPressed(); } setPageComplete(checkPageCompletion()); } private void handleBrowseSourceButtonPressed() { FilteredFileSelectionDialog filteredfileselectiondialog = new FilteredFileSelectionDialog(getShell(), sourceFileExtensions); filteredfileselectiondialog.setTitle(SOURCE_DIALOG_TITLE); filteredfileselectiondialog.setMessage(SOURCE_DIALOG_MESSAGE); filteredfileselectiondialog.setAllowMultiple(false); filteredfileselectiondialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); filteredfileselectiondialog.setBlockOnOpen(true); if(filteredfileselectiondialog.open() != 0) { return; } Object aobj[] = filteredfileselectiondialog.getResult(); if(aobj != null && aobj.length > 0) { IPath ipath = ((IResource)aobj[0]).getFullPath(); String s = ipath.toString(); sourcePathField.setText(s); selectedModel = s; } } private void handleAllPackagesButtonPressed(){ sourceAllPackagesButton.setSelection(true); sourceSelectedPackagesButton.setSelection(false); sourcePackageLabel.setEnabled(false); sourceSelectedPackagesList.setEnabled(false); sourceAddPackages.setEnabled(false); sourceRemovePackages.setEnabled(false); sourceClearPackages.setEnabled(false); } private void handleSelectedPackagesButtonPressed(){ sourceSelectedPackagesButton.setSelection(true); sourceAllPackagesButton.setSelection(false); sourcePackageLabel.setEnabled(true); sourceSelectedPackagesList.setEnabled(true); sourceAddPackages.setEnabled(true); sourceRemovePackages.setEnabled(true); sourceClearPackages.setEnabled(true); } private void handleAddPackagesButtonPressed(){ if(isValidSourcePath()){ Model root = getModel(); ModelLabelProvider labelProvider = new ModelLabelProvider(); ITreeContentProvider contentProvider = new ModelPackageContentProvider(); Object[] elements = null; if(sourceSelectedPackagesList.getItems().length > 0){ elements = new Object[sourceSelectedPackagesList.getItems().length]; for(int i = 0; i<sourceSelectedPackagesList.getItems().length; i++){ elements[i] = packageTable.get(sourceSelectedPackagesList.getItem(i)); } } PackageSelectionDialog packageDialog = new PackageSelectionDialog(getShell(), labelProvider, contentProvider); packageDialog.setInput(root); if(elements != null && elements.length > 0) packageDialog.setInitialSelections(elements); packageDialog.setTitle(SOURCE_PACKAGES_DIALOG_TITLE); packageDialog.setMessage(SOURCE_PACKAGES_DIALOG_MESSAGE); packageDialog.setBlockOnOpen(true); packageDialog.setContainerMode(true); packageDialog.setSorter(new ViewerSorter()); if(packageDialog.open() != 0) { return; } Object[] packages = packageDialog.getResult(); sourceSelectedPackagesList.removeAll(); packageTable.clear(); for(int i=0; i<packages.length; i++){ sourceSelectedPackagesList.add(((Package)packages[i]).getQualifiedName()); packageTable.put(((Package)packages[i]).getQualifiedName(), (Package)packages[i]); } selectedPackages = sourceSelectedPackagesList.getItems(); }else{ MessageDialog.openInformation(getShell(), SOURCE_PACKAGES_INFO_TITLE, SOURCE_PACKAGES_INFO_MESSAGE); } } private void handleRemovePackagesButtonPressed(){ String selected[] = sourceSelectedPackagesList.getSelection(); for (int i = 0; i < selected.length; i++) { sourceSelectedPackagesList.remove(selected[i]); } } private void handleClearPackagesButtonPressed(){ sourceSelectedPackagesList.removeAll(); packageTable.clear(); } private void handleBrowseDestinationButtonPressed() { DirectoryDialog directorydialog = new DirectoryDialog(getShell(), 8192); directorydialog.setMessage(DESTINATION_DIALOG_MESSAGE); directorydialog.setText(DESTINATION_DIALOG_TITLE); directorydialog.setFilterPath(destinationPathField.getText()); String s = directorydialog.open(); if(s != null) { destinationPathField.setText(s); updatePageCompletion(); } } public boolean performFinish() { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); Shell shell = window.getShell(); progressLog = new ProgressLogDialog(shell); //String mofOutpuConfig=""; String cmpiOutputConfig=""; try { cmpiOutputConfig = EcuteEclipsePlugin.getDefault().getConfigFileDestination(Constants.cmpiOutputRSAConfig); } catch (Exception e) { progressLog.updateImage(progressLog.getErrorImage()); progressLog.addLine2Log(e.getMessage()); return false; } writeConfiguration(cmpiOutputConfig); EntryPoint entryPoint = new EntryPoint(cmpiOutputConfig, progressLog); boolean result = entryPoint.returnResult(); if(result){ progressLog.allTasksDone(); }else{ progressLog.updateImage(progressLog.getErrorImage()); progressLog.setTitle("Error"); } return true; } protected boolean allowNewContainerName() { return false; } public String[] getSelectedPackages() { return selectedPackages; } public String getSelectedDestinationPath() { return destinationPathField.getText(); } private Model getModel(){ Model model = null; IPath modelPath = new Path(sourcePathField.getText()); String modelDestination = getFullPath(modelPath); try { model = UMLModeler.openModel(modelDestination); } catch (IOException e) { e.printStackTrace(); } return model; } private String getFullPath(IPath path) { String fullPath = ""; IWorkspace workspace = ResourcesPlugin.getWorkspace(); IFile file = (IFile) workspace.getRoot().getFile(path); if (file != null) { fullPath = file.getLocation().toOSString(); } return fullPath; } private void writeConfiguration(String configFile){ String includeCMPIQualifiers = "false"; if(sourceQualifiersButton.getSelection()) includeCMPIQualifiers = "true"; String sourcePath = getFullPath(new Path(sourcePathField.getText())); String allPackages = "false"; if(sourceAllPackagesButton.getSelection()) allPackages = "true"; String selPackages = ""; if(sourceSelectedPackagesButton.getSelection()){ for (int i = 0; i < selectedPackages.length; i++) { if (selPackages.length() > 0) selPackages += "|"; selPackages += EObjectUtil.getID((Package)packageTable.get(selectedPackages[i])); } } try { String selectionPath = getSelectedDestinationPath(); String osname = System.getProperty("os.name"); //System.out.println(osname); // Windows system if(osname.indexOf("win") > -1 || osname.indexOf("Win") > -1){ if(!selectionPath.endsWith("\\")){ selectionPath = selectionPath.concat("\\"); } System.out.println(selectionPath); } else { // other system if(!selectionPath.endsWith("/")){ selectionPath = selectionPath.concat("/"); } System.out.println(selectionPath); } String codeNameS = codeField.getText(); String repositoryNameS = repositoryField.getText(); String cimmomNameS = cimmomField.getText(); PropertyList propertyList = new PropertyList(configFile, Constants.toolName); //Set configuration propertyList.setProperty(Constants.cmpiProvidersOutputPackageName, "path", selectionPath); propertyList.setProperty(Constants.cmpiProvidersOutputPackageName, "namespaceC", codeNameS); propertyList.setProperty(Constants.cmpiProvidersOutputPackageName, "nameSpaceShadow", repositoryNameS); propertyList.setProperty(Constants.cmpiProvidersOutputPackageName, "namespaceCommon", cimmomNameS); propertyList.setProperty(Constants.rsaInputPackageName, "Model", sourcePath); propertyList.setProperty(Constants.rsaInputPackageName, "AllPackages", allPackages); propertyList.setProperty(Constants.rsaInputPackageName, "SelectedPackages", selPackages); propertyList.setProperty(Constants.rsaInputPackageName, "includeQualifiers", includeCMPIQualifiers); propertyList.close(configFile); } catch (Exception e) { if(e instanceof FileNotFoundException){ //TODO make new config file instead of an exception progressLog.updateImage(progressLog.getErrorImage()); progressLog.addLine2Log(e.getMessage()); e.printStackTrace(); } else if(e instanceof IOException){ progressLog.updateImage(progressLog.getErrorImage()); progressLog.addLine2Log(e.getMessage()); e.printStackTrace(); } } } } Index: WizardsResources.properties =================================================================== RCS file: /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/rsa/ui/internal/wizards/WizardsResources.properties,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- WizardsResources.properties 21 Dec 2004 17:08:32 -0000 1.9 +++ WizardsResources.properties 23 Jun 2005 08:16:59 -0000 1.10 @@ -7,6 +7,9 @@ ExportMOF.title=Export CIM MOF files ExportMOF.description=Select the model and the packages you want to export. Then, specify the output directory. +# --- The Generate CMPI Providers Wizard ---- +GenerateCMPI.title=Generate CMPI Providers +GenerateCMPI.description=Specify the model and the CMPI providers settings @@ -110,4 +113,49 @@ Export.destinationPath.error2=The specified destination directory does not exist. +# --- The Generate CMPI Providers Wizard Page --- +CMPI.model.groupTitle=Model settings +CMPI.model.topLabel=Top packages to export: +CMPI.model.allPackages=All packages of the model +CMPI.model.selectedPackages=Selected packages +CMPI.model.includeLabel=Packages to include in top packages +CMPI.model.subPackages=Sub packages in package tree (standard) +CMPI.model.referencedPackages=Packages referenced in Main view +CMPI.model.includeQualifiers=Include qualifiers + +CMPI.source.groupTitle=Model settings +CMPI.source.label=Model +CMPI.source.browse=Browse... +CMPI.source.browseToolTip=Opens a dialog to select model from the workspace. +CMPI.source.add=Select Packages... +CMPI.source.addToolTip=Opens a dialog to select packages from the model. +CMPI.source.remove=Remove +CMPI.source.removeToolTip=Remove the selected packages from the list. +CMPI.source.clear=Clear List +CMPI.source.clearToolTip=Empty the packages list. +CMPI.source.checkBoxQualifiers=Include Qualifiers +CMPI.sourceDialog.title=Select Model +CMPI.sourceDialog.message=Select model to generate CMPI providers for. +CMPI.source.allPackages=Export all packages from model +CMPI.source.selectedPackages=Export selected packages from model +CMPI.source.missingPackages=Select the model and the packages you want to export. Then, specify the generation settings. +CMPI.source.packages.info.title=Information +CMPI.source.packages.info.message=Please select first a valid model. +CMPI.sourcePackageDialog.title=Select Packages +CMPI.sourcePackageDialog.message=Select packages to generate CMPI providers for: +CMPI.sourcePath.error1=The specified source model must exist. + +CMPI.provider.groupTitle=CMPI providers generation settings +CMPI.provider.pathLabel=Output path +CMPI.provider.browse=Browse... +CMPI.provider.codeNS=C++ code namespace +CMPI.provider.repositoryNS=Repository data namespace +CMPI.provider.cimmomNS=CIMMOM namespace +CMPI.destinationDialog.message=Export to directory +CMPI.destinationDialog.title=Directory to generate to +CMPI.destinationPath.error1=Select the destination directory to generate the model. +CMPI.destinationPath.error2=The specified destination directory does not exist. +CMPI.codeNamespace.error=Missing C++ namespace. +CMPI.repositoryNamespace.error=Missing repository data namespace. +CMPI.cimmomNamespace.error=Missing CIMMOM namespace. |