Search in sources :

Example 1 with BuildType

use of org.talend.core.runtime.repository.build.BuildType in project tdi-studio-se by Talend.

the class DeploymentComposite method addListeners.

private void addListeners() {
    groupIdCheckbox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (groupIdCheckbox.getSelection()) {
                groupIdText.setEnabled(true);
                groupIdText.setText(groupId);
            } else {
                groupIdText.setEnabled(false);
                groupIdText.setText(defaultGroupId);
                // remove key, so will be default groupId
                Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_GROUP_ID, null);
                getCommandStack().execute(cmd);
            }
        }
    });
    groupIdText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            String currentGroupId = groupIdText.getText();
            if (currentGroupId != null && !currentGroupId.trim().equals("")) {
                //$NON-NLS-1$
                groupIdText.setBackground(getBackground());
                //$NON-NLS-1$
                groupIdText.setToolTipText("");
                if (!defaultGroupId.equals(currentGroupId)) {
                    groupId = currentGroupId;
                } else {
                    currentGroupId = null;
                }
                Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_GROUP_ID, currentGroupId);
                getCommandStack().execute(cmd);
            } else {
                groupIdText.setBackground(COLOR_RED);
                //$NON-NLS-1$
                groupIdText.setToolTipText(Messages.getString("DeploymentComposite.valueWarning"));
            }
        }
    });
    versionCheckbox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (versionCheckbox.getSelection()) {
                versionText.setEnabled(true);
                versionText.setText(version);
            } else {
                versionText.setEnabled(false);
                versionText.setText(defaultVersion);
                // remove key, so will be default version
                Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_USER_VERSION, null);
                getCommandStack().execute(cmd);
            }
        }
    });
    versionText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            String currentVersion = versionText.getText();
            if (//$NON-NLS-1$
            currentVersion != null && !currentVersion.trim().equals("") && !MavenVersionUtils.isValidMavenVersion(currentVersion)) {
                //$NON-NLS-1$
                versionText.setToolTipText(Messages.getString("DeploymentComposite.valueWarning"));
                versionText.setBackground(COLOR_RED);
            } else {
                //$NON-NLS-1$
                versionText.setToolTipText("");
                versionText.setBackground(getBackground());
                if (!defaultVersion.equals(currentVersion)) {
                    version = currentVersion;
                } else {
                    currentVersion = null;
                }
                // if empty, remove it from job, else will set the new value
                Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_USER_VERSION, currentVersion);
                getCommandStack().execute(cmd);
            }
        }
    });
    buildTypeCombo.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            final ISelection selection = event.getSelection();
            if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
                final Object elem = ((IStructuredSelection) selection).getFirstElement();
                if (elem instanceof BuildType) {
                    Command cmd = new MavenDeploymentValueChangeCommand(process, TalendProcessArgumentConstant.ARG_BUILD_TYPE, ((BuildType) elem).getName());
                    getCommandStack().execute(cmd);
                }
            }
        }
    });
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ModifyEvent(org.eclipse.swt.events.ModifyEvent) MavenDeploymentValueChangeCommand(org.talend.designer.core.ui.editor.cmd.MavenDeploymentValueChangeCommand) Command(org.eclipse.gef.commands.Command) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) MavenDeploymentValueChangeCommand(org.talend.designer.core.ui.editor.cmd.MavenDeploymentValueChangeCommand) BuildType(org.talend.core.runtime.repository.build.BuildType) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 2 with BuildType

use of org.talend.core.runtime.repository.build.BuildType in project tdi-studio-se by Talend.

the class DeploymentComposite method createControl.

private void createControl() {
    setLayout(new GridLayout());
    setBackground(getParent().getBackground());
    Composite composite = new Composite(this, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.horizontalSpacing = 10;
    layout.verticalSpacing = 10;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    groupIdCheckbox = //$NON-NLS-1$
    widgetFactory.createButton(//$NON-NLS-1$
    composite, //$NON-NLS-1$
    Messages.getString("DeploymentComposite.gourpIdLabel"), SWT.CHECK);
    groupIdCheckbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    groupIdText = new Text(composite, SWT.BORDER);
    GridData groupIdTextData = new GridData(GridData.FILL_HORIZONTAL);
    groupIdTextData.widthHint = 200;
    groupIdText.setLayoutData(groupIdTextData);
    versionCheckbox = //$NON-NLS-1$
    widgetFactory.createButton(//$NON-NLS-1$
    composite, //$NON-NLS-1$
    Messages.getString("DeploymentComposite.versionLabel"), SWT.CHECK);
    versionCheckbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    versionText = new Text(composite, SWT.BORDER);
    GridData versionTextData = new GridData(GridData.FILL_HORIZONTAL);
    versionTextData.widthHint = 200;
    versionText.setLayoutData(versionTextData);
    //$NON-NLS-1$
    buildTypeLabel = widgetFactory.createLabel(composite, Messages.getString("DeploymentComposite.buildTypeLabel"));
    buildTypeLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    buildTypeCombo = new ComboViewer(widgetFactory.createCCombo(composite, SWT.READ_ONLY | SWT.BORDER));
    final Control buildTypeControl = buildTypeCombo.getControl();
    GridData buildTypeComboData = new GridData(GridData.FILL_HORIZONTAL);
    buildTypeComboData.widthHint = 200;
    buildTypeControl.setLayoutData(buildTypeComboData);
    buildTypeCombo.setContentProvider(ArrayContentProvider.getInstance());
    buildTypeCombo.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof BuildType) {
                return ((BuildType) element).getLabel();
            }
            return super.getText(element);
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) BuildType(org.talend.core.runtime.repository.build.BuildType) Text(org.eclipse.swt.widgets.Text) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 3 with BuildType

use of org.talend.core.runtime.repository.build.BuildType in project tdi-studio-se by Talend.

the class DeploymentComposite method initialize.

private void initialize() {
    Map<Object, Object> processAdditionalProperties = this.process.getAdditionalProperties();
    if (processAdditionalProperties != null) {
        // TODO get from PublishPlugin.getDefault().getPreferenceStore();
        // $NON-NLS-1$
        defaultGroupId = "org.example";
        if (groupId == null) {
            groupId = (String) processAdditionalProperties.get(MavenConstants.NAME_GROUP_ID);
            if (groupId == null) {
                groupId = defaultGroupId;
            }
        }
        if (groupId != null) {
            boolean isDefaultGroupId = groupId.equals(defaultGroupId);
            groupIdCheckbox.setSelection(!isDefaultGroupId);
            groupIdText.setEnabled(!isDefaultGroupId);
            groupIdText.setText(groupId);
        } else {
            groupIdText.setText(defaultGroupId);
            groupIdCheckbox.setSelection(false);
            groupIdText.setEnabled(false);
        }
        if (version == null) {
            version = (String) processAdditionalProperties.get(MavenConstants.NAME_USER_VERSION);
            if (version == null) {
                version = defaultVersion;
            }
        }
        if (version != null) {
            boolean isDefaultVersion = version.equals(defaultVersion);
            versionCheckbox.setSelection(!isDefaultVersion);
            versionText.setEnabled(!isDefaultVersion);
            versionText.setText(version);
            //$NON-NLS-1$
            versionText.setToolTipText("");
        } else {
            versionCheckbox.setSelection(false);
            versionText.setEnabled(false);
            versionText.setText(defaultVersion);
            //$NON-NLS-1$ ;
            versionText.setToolTipText(Messages.getString("DeploymentComposite.valueWarning"));
        }
        final boolean showBuildType = isShowBuildType();
        final Control buildTypeControl = buildTypeCombo.getControl();
        buildTypeControl.setVisible(showBuildType);
        buildTypeLabel.setVisible(showBuildType);
        if (showBuildType) {
            Map<String, Object> parameters = new HashMap<String, Object>();
            parameters.put(IBuildParametes.PROCESS, this.process);
            final BuildType[] validBuildTypes = BuildExportManager.getInstance().getValidBuildTypes(parameters);
            buildTypeCombo.setInput(validBuildTypes);
            buildTypeControl.setEnabled(true);
            String buildType = (String) processAdditionalProperties.get(TalendProcessArgumentConstant.ARG_BUILD_TYPE);
            BuildType foundType = null;
            if (buildType != null) {
                for (BuildType t : validBuildTypes) {
                    if (t.getName().equals(buildType)) {
                        foundType = t;
                        break;
                    }
                }
            }
            if (foundType == null) {
                // set the first one by default
                foundType = validBuildTypes[0];
            }
            buildTypeCombo.setSelection(new StructuredSelection(foundType));
        }
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) HashMap(java.util.HashMap) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) BuildType(org.talend.core.runtime.repository.build.BuildType) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Aggregations

IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 BuildType (org.talend.core.runtime.repository.build.BuildType)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Control (org.eclipse.swt.widgets.Control)2 HashMap (java.util.HashMap)1 Command (org.eclipse.gef.commands.Command)1 ComboViewer (org.eclipse.jface.viewers.ComboViewer)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)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 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Text (org.eclipse.swt.widgets.Text)1