use of org.talend.designer.core.ui.editor.cmd.MavenDeploymentValueChangeCommand 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);
}
}
}
});
}
Aggregations