Search in sources :

Example 36 with PropertyEditor

use of com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor in project mdw-designer by CenturyLinkCloud.

the class TaskTemplateEditor method addPage.

private void addPage(String section) {
    ScrolledComposite scrolledComposite = new ScrolledComposite(getContainer(), SWT.V_SCROLL);
    scrolledComposite.setLayout(new GridLayout());
    scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    scrolledComposite.setAlwaysShowScrollBars(true);
    Composite composite = new Composite(scrolledComposite, SWT.NONE);
    composite.setLayout(new FillLayout());
    // create the grid layout
    GridLayout gl = new GridLayout();
    gl.numColumns = PropertyEditor.COLUMNS;
    gl.marginTop = 6;
    gl.marginLeft = 3;
    composite.setLayout(gl);
    for (PropertyEditor propertyEditor : propertyEditors) {
        boolean belongs;
        if (section == null)
            belongs = propertyEditor.getSection() == null;
        else
            belongs = section.equals(propertyEditor.getSection());
        if (belongs) {
            if ("Notices".equals(propertyEditor.getName())) {
                // special handling for notices
                String attrVal = taskTemplate.getAttribute(TaskAttributeConstant.NOTICES);
                if (StringHelper.isEmpty(attrVal) || attrVal.equals("$DefaultNotices"))
                    taskTemplate.setAttribute(TaskAttributeConstant.NOTICES, TaskVO.getDefaultNotices());
                if (noticesValueChangeListener != null)
                    taskTemplate.removeAttributeValueChangeListener(noticesValueChangeListener);
                noticesValueChangeListener = new NoticesValueChangeListener(propertyEditor);
                taskTemplate.addAttributeValueChangeListener(noticesValueChangeListener);
                propertyEditor.render(composite);
            } else if ("Variables".equals(propertyEditor.getName())) {
                // special handling for variables
                TableEditor tableEditor = (TableEditor) propertyEditor;
                // support for value expressions
                tableEditor.setCellModifier(tableEditor.new DefaultCellModifier() {

                    @Override
                    public boolean canModify(Object element, String property) {
                        boolean editable = super.canModify(element, property);
                        if (editable && getColumnIndex(property) == 1) {
                            for (VariableVO var : getProcessVariables()) {
                                if (var.getName().equals(getValue(element, property)))
                                    // can't edit process var rows
                                    return false;
                            }
                        }
                        return editable;
                    }
                });
                tableEditor.setHorizontalSpan(4);
                propertyEditor.render(composite);
                tableEditor.getAddButton().setText("Expression");
                GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
                gridData.widthHint = 80;
                tableEditor.getAddButton().setLayoutData(gridData);
                final Button deleteBtn = tableEditor.getDeleteButton();
                tableEditor.getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() {

                    public void selectionChanged(SelectionChangedEvent event) {
                        IStructuredSelection sel = (IStructuredSelection) event.getSelection();
                        if (sel.getFirstElement() instanceof DefaultRowImpl) {
                            DefaultRowImpl row = (DefaultRowImpl) sel.getFirstElement();
                            for (VariableVO var : getProcessVariables()) {
                                if (var.getName().equals(row.getColumnValue(1))) {
                                    deleteBtn.setEnabled(false);
                                    return;
                                }
                            }
                            deleteBtn.setEnabled(true);
                        } else {
                            deleteBtn.setEnabled(false);
                        }
                    }
                });
            } else {
                propertyEditor.render(composite);
            }
            propertyEditor.setValue(taskTemplate);
            if (!propertyEditor.getType().equals(PropertyEditor.TYPE_LINK)) {
                propertyEditor.setEditable(!(propertyEditor.isReadOnly() || taskTemplate.isReadOnly()));
            }
        }
    }
    scrolledComposite.setContent(composite);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    String pageName = section == null ? "General" : section;
    setPageText(addPage(scrolledComposite), pageName);
    pages.put(pageName, scrolledComposite);
}
Also used : DefaultRowImpl(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor.DefaultRowImpl) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FillLayout(org.eclipse.swt.layout.FillLayout) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TableEditor(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) JSONObject(org.json.JSONObject)

Example 37 with PropertyEditor

use of com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor in project mdw-designer by CenturyLinkCloud.

the class TaskTemplateEditor method reconcileVariables.

private void reconcileVariables() {
    if (process == null) {
    // TODO: find process with AutoFormManualTask activity which
    // references this template
    // (so that new variables population does not rely on opening from
    // process editor)
    }
    if (process != null) {
        processVariables = process.getVariables();
        // reflect newly-added process variables
        String attrVal = taskTemplate.getAttribute("Variables");
        attrVal = TaskVO.updateVariableInString(attrVal, getProcessVariables());
        taskTemplate.setAttribute("Variables", attrVal);
        for (PropertyEditor propertyEditor : propertyEditors) {
            if ("Variables".equals(propertyEditor.getName())) {
                propertyEditor.setValue(taskTemplate);
                break;
            }
        }
    }
}
Also used : PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)

Example 38 with PropertyEditor

use of com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor in project mdw-designer by CenturyLinkCloud.

the class ProjectPermissionsSection method drawWidgets.

public void drawWidgets(Composite composite, WorkflowElement selection) {
    project = (WorkflowProject) selection;
    // user text field
    userEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
    userEditor.setLabel("Current User");
    userEditor.setWidth(150);
    userEditor.setReadOnly(true);
    userEditor.render(composite);
    // edit processes checkbox
    editProcessesEditor = new PropertyEditor(project, PropertyEditor.TYPE_CHECKBOX);
    editProcessesEditor.setLabel("Design/Edit Processes");
    editProcessesEditor.setReadOnly(true);
    editProcessesEditor.render(composite);
    // run processes checkbox
    runProcessesEditor = new PropertyEditor(project, PropertyEditor.TYPE_CHECKBOX);
    runProcessesEditor.setLabel("Execute Processes");
    runProcessesEditor.setReadOnly(true);
    runProcessesEditor.render(composite);
    // admin checkbox
    adminPermissionsEditor = new PropertyEditor(project, PropertyEditor.TYPE_CHECKBOX);
    adminPermissionsEditor.setLabel("Administrator Privileges");
    adminPermissionsEditor.setReadOnly(true);
    adminPermissionsEditor.render(composite);
    // sys admin checkbox
    sysAdminPermissionsEditor = new PropertyEditor(project, PropertyEditor.TYPE_CHECKBOX);
    sysAdminPermissionsEditor.setLabel("System Admin Privileges");
    sysAdminPermissionsEditor.setReadOnly(true);
    sysAdminPermissionsEditor.render(composite);
    // task manager link
    taskManagerLinkEditor = new PropertyEditor(project, PropertyEditor.TYPE_LINK);
    taskManagerLinkEditor.setLabel("Launch Task Manager to Change Role Assignments");
    taskManagerLinkEditor.setIndent(-100);
    taskManagerLinkEditor.setHeight(20);
    taskManagerLinkEditor.setWidth(500);
    taskManagerLinkEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            launchTaskManager();
        }
    });
    taskManagerLinkEditor.render(composite);
    // reload button
    reloadButtonEditor = new PropertyEditor(project, PropertyEditor.TYPE_BUTTON);
    reloadButtonEditor.setLabel("Reload");
    reloadButtonEditor.setIndent(-100);
    reloadButtonEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            reloadPermissions();
        }
    });
    reloadButtonEditor.render(composite);
}
Also used : ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)

Example 39 with PropertyEditor

use of com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor in project mdw-designer by CenturyLinkCloud.

the class ProjectVcsSection method setSelection.

public void setSelection(WorkflowElement selection) {
    if (project != null)
        project.removeElementChangeListener(this);
    project = (WorkflowProject) selection;
    project.addElementChangeListener(this);
    // dispose controls to render dynamically
    if (gitRepoUrlEditor != null)
        gitRepoUrlEditor.dispose();
    if (gitBranchEditor != null)
        gitBranchEditor.dispose();
    if (assetLocalPathEditor != null)
        assetLocalPathEditor.dispose();
    if (gitSyncEditor != null)
        gitSyncEditor.dispose();
    if (includeArchiveEditor != null)
        includeArchiveEditor.dispose();
    // repository url text field
    gitRepoUrlEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
    gitRepoUrlEditor.setLabel("Git Repository URL");
    gitRepoUrlEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            project.getMdwVcsRepository().setRepositoryUrlWithCredentials(((String) newValue).trim());
            project.getMdwVcsRepository().setEntrySource("projectSection");
            WorkflowProjectManager.updateProject(project);
            project.fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, project.getMdwVcsRepository());
        }
    });
    gitRepoUrlEditor.render(composite);
    gitRepoUrlEditor.setValue(project.getMdwVcsRepository().getRepositoryUrlWithMaskedCredentials());
    gitRepoUrlEditor.setEditable(!project.isReadOnly());
    // git branch text field
    gitBranchEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
    gitBranchEditor.setLabel("Git Branch");
    gitBranchEditor.setWidth(200);
    gitBranchEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            project.getMdwVcsRepository().setBranch(((String) newValue).trim());
            project.getMdwVcsRepository().setEntrySource("projectSection");
            WorkflowProjectManager.updateProject(project);
            project.fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, project.getMdwVcsRepository());
        }
    });
    gitBranchEditor.render(composite);
    gitBranchEditor.setValue(project.getMdwVcsRepository().getBranch());
    gitBranchEditor.setEditable(!project.isReadOnly());
    // asset local path text field
    assetLocalPathEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
    assetLocalPathEditor.setLabel("Asset Local Path");
    assetLocalPathEditor.setWidth(200);
    assetLocalPathEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            project.getMdwVcsRepository().setLocalPath(((String) newValue).trim());
            project.getMdwVcsRepository().setEntrySource("projectSection");
            WorkflowProjectManager.updateProject(project);
            project.fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, project.getMdwVcsRepository());
        }
    });
    assetLocalPathEditor.render(composite);
    assetLocalPathEditor.setValue(project.getMdwVcsRepository().getLocalPath());
    assetLocalPathEditor.setEditable(!project.isReadOnly());
    if (project.isRemote()) {
        if (project.isGitVcs()) {
            // for git: sync switch
            gitSyncEditor = new PropertyEditor(project, PropertyEditor.TYPE_SWITCH);
            gitSyncEditor.setLabel("");
            // gitSyncEditor.setComment("(Unlock to enable asset editing)");
            gitSyncEditor.addValueChangeListener(new ValueChangeListener() {

                public void propertyValueChanged(Object newValue) {
                    boolean unlocked = Boolean.parseBoolean(newValue.toString());
                    if (unlocked) {
                        WorkflowProjectManager.getInstance().makeLocal(project);
                        project.fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, project.getMdwVcsRepository());
                        MessageDialog.openInformation(getShell(), "Remote Project Unlocked", project.getName() + " has been unlocked.  Please close any open assets and refresh.");
                    }
                }
            });
            gitSyncEditor.render(composite);
            SwitchButton switchBtn = (SwitchButton) gitSyncEditor.getWidget();
            switchBtn.setTextForSelect("Synced");
            switchBtn.setTextForUnselect("Unlocked");
            gitSyncEditor.setValue(false);
        }
        // include archive checkbox
        includeArchiveEditor = new PropertyEditor(project, PropertyEditor.TYPE_CHECKBOX);
        includeArchiveEditor.setLabel("Sync Asset Archive");
        includeArchiveEditor.addValueChangeListener(new ValueChangeListener() {

            public void propertyValueChanged(Object newValue) {
                project.getMdwVcsRepository().setSyncAssetArchive(Boolean.parseBoolean(newValue.toString()));
                WorkflowProjectManager.updateProject(project);
                project.fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, project.getMdwVcsRepository());
            }
        });
        includeArchiveEditor.render(composite);
        includeArchiveEditor.setValue(project.getMdwVcsRepository().isSyncAssetArchive());
        includeArchiveEditor.setEditable(true);
    }
    composite.layout(true);
}
Also used : ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor) SwitchButton(com.centurylink.mdw.plugin.designer.properties.editor.SwitchButton)

Example 40 with PropertyEditor

use of com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor in project mdw-designer by CenturyLinkCloud.

the class PropertySection method createSaveButton.

/**
 * For override attributes.
 */
protected PropertyEditor createSaveButton() {
    savePropertyEditor = new PropertyEditor(selection, PropertyEditor.TYPE_BUTTON);
    savePropertyEditor.setLabel("Save");
    savePropertyEditor.setWidth(65);
    savePropertyEditor.setComment(" ");
    savePropertyEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            saveOverrideAttributes();
        }
    });
    savePropertyEditor.render(composite);
    savePropertyEditor.setEnabled(selection.isOverrideAttributeDirty(getOverrideAttributePrefix()));
    return savePropertyEditor;
}
Also used : ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)

Aggregations

PropertyEditor (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)51 ValueChangeListener (com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener)36 PropertyEditorList (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList)11 Activity (com.centurylink.mdw.plugin.designer.model.Activity)7 ArrayList (java.util.ArrayList)6 Label (org.eclipse.swt.widgets.Label)6 ArtifactEditor (com.centurylink.mdw.plugin.designer.properties.editor.ArtifactEditor)5 TableEditor (com.centurylink.mdw.plugin.designer.properties.editor.TableEditor)5 DateConverter (com.centurylink.mdw.plugin.designer.properties.convert.DateConverter)4 WorkflowAssetEditor (com.centurylink.mdw.plugin.designer.properties.editor.WorkflowAssetEditor)4 CustomAttributeVO (com.centurylink.mdw.model.value.attribute.CustomAttributeVO)3 FontData (org.eclipse.swt.graphics.FontData)3 TimeInterval (com.centurylink.mdw.plugin.designer.properties.editor.TimeInterval)2 GridData (org.eclipse.swt.layout.GridData)2 Button (org.eclipse.swt.widgets.Button)2 Composite (org.eclipse.swt.widgets.Composite)2 MarkdownRenderer (com.centurylink.mdw.designer.utils.MarkdownRenderer)1 ActivityImplementorVO (com.centurylink.mdw.model.value.activity.ActivityImplementorVO)1 BamMessageDefinition (com.centurylink.mdw.model.value.event.BamMessageDefinition)1 VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)1