Search in sources :

Example 6 with File

use of com.centurylink.mdw.plugin.designer.model.File in project mdw-designer by CenturyLinkCloud.

the class ProcessExplorerActionGroup method renameApplies.

public boolean renameApplies(IStructuredSelection selection) {
    if (selection.size() != 1)
        return false;
    Object element = selection.getFirstElement();
    if (!(element instanceof WorkflowElement) || ((WorkflowElement) element).isArchived())
        return false;
    WorkflowElement workflowElement = (WorkflowElement) element;
    if (element instanceof Folder || element instanceof AutomatedTestSuite)
        return false;
    if (element instanceof AutomatedTestCase)
        return !((AutomatedTestCase) element).isLegacy();
    if (element instanceof File || element instanceof LegacyExpectedResults)
        return false;
    return workflowElement.isUserAuthorized(UserRoleVO.ASSET_DESIGN);
}
Also used : LegacyExpectedResults(com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) Folder(com.centurylink.mdw.plugin.designer.model.Folder) IFile(org.eclipse.core.resources.IFile) TestFile(com.centurylink.mdw.designer.testing.TestFile) File(com.centurylink.mdw.plugin.designer.model.File) JarFile(com.centurylink.mdw.plugin.designer.model.JarFile) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)

Example 7 with File

use of com.centurylink.mdw.plugin.designer.model.File in project mdw-designer by CenturyLinkCloud.

the class ProcessExplorerActionGroup method createOpenInstanceAction.

private IAction createOpenInstanceAction() {
    IAction action = new Action() {

        @Override
        public void run() {
            if (openInstanceApplies(getSelection())) {
                WorkflowProject project = ((WorkflowElement) getSelection().getFirstElement()).getProject();
                try {
                    Long procInstId = null;
                    if (getSelection().getFirstElement() instanceof AutomatedTestResults) {
                        AutomatedTestResults expectedResults = (AutomatedTestResults) getSelection().getFirstElement();
                        procInstId = expectedResults.getActualProcessInstanceId();
                    } else if (getSelection().getFirstElement() instanceof LegacyExpectedResults) {
                        LegacyExpectedResults expectedResult = (LegacyExpectedResults) getSelection().getFirstElement();
                        java.io.File resultsFile = expectedResult.getActualResultFile();
                        TestFile testFile = new TestFile(null, resultsFile.getPath());
                        testFile.load();
                        TestFileLine line1 = testFile.getLines().get(0);
                        procInstId = new Long(line1.getWord(3));
                    }
                    if (procInstId == null) {
                        MessageDialog.openWarning(view.getSite().getShell(), "No Results", "Unable to locate results file.");
                        return;
                    }
                    ProcessInstanceVO procInst = project.getDataAccess().getProcessInstance(procInstId);
                    Long processId = procInst.getProcessId();
                    ProcessVO procVO = project.getProcess(processId).getProcessVO();
                    if (procVO == null)
                        PluginMessages.uiError("Unable to locate process: " + processId, OPEN_PROCESS_INSTANCE, project);
                    WorkflowProcess instance = new WorkflowProcess(project, procVO);
                    instance.setProcessInstance(procInst);
                    actionHandler.open(instance);
                } catch (Exception ex) {
                    PluginMessages.uiError(ex, OPEN_PROCESS_INSTANCE, project);
                }
            }
        }
    };
    action.setText(OPEN_PROCESS_INSTANCE);
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + OPEN_PROCESS_INSTANCE);
    ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor(ICON_PROCESS_GIF);
    action.setImageDescriptor(imageDesc);
    return action;
}
Also used : WebLaunchAction(com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction) IAction(org.eclipse.jface.action.IAction) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) TestFileLine(com.centurylink.mdw.designer.testing.TestFileLine) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) AutomatedTestResults(com.centurylink.mdw.plugin.designer.model.AutomatedTestResults) PartInitException(org.eclipse.ui.PartInitException) ConnectException(java.net.ConnectException) NamingException(javax.naming.NamingException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) RemoteException(java.rmi.RemoteException) TestFile(com.centurylink.mdw.designer.testing.TestFile) LegacyExpectedResults(com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IFile(org.eclipse.core.resources.IFile) TestFile(com.centurylink.mdw.designer.testing.TestFile) File(com.centurylink.mdw.plugin.designer.model.File) JarFile(com.centurylink.mdw.plugin.designer.model.JarFile) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Example 8 with File

use of com.centurylink.mdw.plugin.designer.model.File in project mdw-designer by CenturyLinkCloud.

the class ImportPackageSelectPage method initialize.

/**
 * Populate the tree.
 */
public void initialize(WorkflowElement preselected) {
    if (preselected instanceof File)
        selectedPackages.add((File) preselected);
    else if (preselected instanceof Folder) {
        for (WorkflowElement element : ((Folder) preselected).getChildren()) selectedPackages.add((File) element);
    }
    Folder topFolder = ((ImportPackageWizard) getWizard()).getTopFolder();
    treeViewer.setInput(topFolder.getChildren());
    treeViewer.expandToLevel(2);
}
Also used : Folder(com.centurylink.mdw.plugin.designer.model.Folder) File(com.centurylink.mdw.plugin.designer.model.File) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 9 with File

use of com.centurylink.mdw.plugin.designer.model.File in project mdw-designer by CenturyLinkCloud.

the class ImportPackageSelectPage method createAssetTree.

private void createAssetTree(Composite parent) {
    treeViewer = new CheckboxTreeViewer(parent, SWT.CHECK | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    treeViewer.setContentProvider(new ViewContentProvider());
    treeViewer.setLabelProvider(new ViewLabelProvider());
    treeViewer.setCheckStateProvider(new ViewCheckStateProvider());
    GridData data = new GridData(GridData.FILL_BOTH);
    treeViewer.getTree().setLayoutData(data);
    treeViewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            boolean checked = event.getChecked();
            if (event.getElement() instanceof File) {
                File file = (File) event.getElement();
                if (checked && !selectedPackages.contains(file))
                    selectedPackages.add(file);
                else if (!checked && selectedPackages.contains(file))
                    selectedPackages.remove(file);
                treeViewer.refresh();
                handleFieldChanged();
            } else if (event.getElement() instanceof Folder) {
                FileCollector collector = new FileCollector((Folder) event.getElement());
                for (File file : collector.getDescendantFiles()) {
                    if (checked && !selectedPackages.contains(file))
                        selectedPackages.add(file);
                    else if (!checked && selectedPackages.contains(file))
                        selectedPackages.remove(file);
                }
                treeViewer.refresh();
                handleFieldChanged();
            }
        }
    });
    ColumnViewerToolTipSupport.enableFor(treeViewer);
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) GridData(org.eclipse.swt.layout.GridData) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) Folder(com.centurylink.mdw.plugin.designer.model.Folder) File(com.centurylink.mdw.plugin.designer.model.File)

Example 10 with File

use of com.centurylink.mdw.plugin.designer.model.File in project mdw-designer by CenturyLinkCloud.

the class Discoverer method parseJsonPacakges.

private void parseJsonPacakges(Folder parent, String content) throws DiscoveryException {
    try {
        JSONArray jsonArray = (JSONArray) (new JSONObject(content)).get("packages");
        TreeMap<String, String> sortedPackages = new TreeMap<>();
        for (int i = 0; i < jsonArray.length(); i++) {
            JSONObject jsonObj = new JSONObject(jsonArray.get(i).toString());
            sortedPackages.put(jsonObj.getString("name"), jsonObj.getString("version"));
        }
        for (Map.Entry<String, String> entry : sortedPackages.entrySet()) {
            File child = new File(parent, entry.getKey() + " v" + entry.getValue());
            parent.addChild(child);
        }
    } catch (Exception ex) {
        throw new DiscoveryException("Error parsing the pacakges: ", ex);
    }
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) TreeMap(java.util.TreeMap) Map(java.util.Map) TreeMap(java.util.TreeMap) File(com.centurylink.mdw.plugin.designer.model.File) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Aggregations

File (com.centurylink.mdw.plugin.designer.model.File)11 Folder (com.centurylink.mdw.plugin.designer.model.Folder)6 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)4 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)4 ArrayList (java.util.ArrayList)4 TestFile (com.centurylink.mdw.designer.testing.TestFile)3 JarFile (com.centurylink.mdw.plugin.designer.model.JarFile)3 IOException (java.io.IOException)3 URL (java.net.URL)3 IFile (org.eclipse.core.resources.IFile)3 JSONObject (org.json.JSONObject)3 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)2 HttpHelper (com.centurylink.mdw.common.utilities.HttpHelper)2 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)2 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)2 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)2 AutomatedTestSuite (com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)2 LegacyExpectedResults (com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults)2 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)2 HashMap (java.util.HashMap)2