Search in sources :

Example 1 with SwitchButton

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

the class ProjectSettingsPropertyPage method createGitRepositoryControls.

private void createGitRepositoryControls(Composite parent) {
    addHeading(parent, "Git Repository");
    Composite composite = createComposite(parent, 2);
    new Label(composite, SWT.NONE).setText("Repository URL:");
    new Label(composite, SWT.NONE);
    gitRepositoryUrlTextField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    GridData gd = new GridData(GridData.BEGINNING);
    gd.widthHint = 450;
    gd.horizontalSpan = 2;
    gitRepositoryUrlTextField.setLayoutData(gd);
    gitRepositoryUrlTextField.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            boolean success = getProject().getMdwVcsRepository().setRepositoryUrlWithCredentials(gitRepositoryUrlTextField.getText().trim());
            setValid(success);
            setErrorMessage(success ? null : "Invalid Repository URL");
        }
    });
    String repoUrl = getProject().getMdwVcsRepository().getRepositoryUrlWithMaskedCredentials();
    if (repoUrl != null) {
        gitRepositoryUrlTextField.setText(repoUrl);
        originalGitRepositoryUrl = repoUrl;
    }
    // branch
    new Label(composite, SWT.NONE).setText("Branch:");
    gitBranchTextField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    gd = new GridData(GridData.BEGINNING);
    gd.widthHint = 200;
    gitBranchTextField.setLayoutData(gd);
    gitBranchTextField.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            getProject().getMdwVcsRepository().setBranch(gitBranchTextField.getText().trim());
        }
    });
    String branch = getProject().getMdwVcsRepository().getBranch();
    if (branch != null)
        gitBranchTextField.setText(branch);
    originalGitBranch = branch;
    // local path
    new Label(composite, SWT.NONE).setText("Local Asset Path:");
    assetLocalPathTextField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    gd = new GridData(GridData.BEGINNING);
    gd.widthHint = 300;
    assetLocalPathTextField.setLayoutData(gd);
    assetLocalPathTextField.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            getProject().getMdwVcsRepository().setLocalPath(assetLocalPathTextField.getText().trim());
        }
    });
    String localPath = getProject().getMdwVcsRepository().getLocalPath();
    if (localPath != null)
        assetLocalPathTextField.setText(localPath);
    originalAssetLocalPath = localPath;
    if (getProject().isRemote()) {
        if (getProject().isGitVcs()) {
            // git: sync project
            syncSwitch = new SwitchButton(composite, SWT.NONE);
            syncSwitch.setTextForSelect("Synced");
            syncSwitch.setTextForUnselect("Unlocked");
            syncSwitch.setSelection(false);
            originalSync = true;
        }
        // non-git: include archive checkbox
        includeArchiveCheckbox = new Button(composite, SWT.CHECK | SWT.LEFT);
        includeArchiveCheckbox.setText("Include asset archive when synchronizing");
        gd = new GridData(GridData.BEGINNING);
        gd.horizontalSpan = 2;
        includeArchiveCheckbox.setLayoutData(gd);
        includeArchiveCheckbox.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                getProject().getMdwVcsRepository().setSyncAssetArchive(includeArchiveCheckbox.getSelection());
            }
        });
        boolean includeArchive = getProject().getMdwVcsRepository().isSyncAssetArchive();
        includeArchiveCheckbox.setSelection(includeArchive);
        originalIncludeArchive = includeArchive;
    }
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Button(org.eclipse.swt.widgets.Button) SwitchButton(com.centurylink.mdw.plugin.designer.properties.editor.SwitchButton) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) SwitchButton(com.centurylink.mdw.plugin.designer.properties.editor.SwitchButton)

Example 2 with SwitchButton

use of com.centurylink.mdw.plugin.designer.properties.editor.SwitchButton 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)

Aggregations

SwitchButton (com.centurylink.mdw.plugin.designer.properties.editor.SwitchButton)2 PropertyEditor (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)1 ValueChangeListener (com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1