Search in sources :

Example 1 with StatusConfirmSettingDialog

use of org.talend.repository.ui.dialog.StatusConfirmSettingDialog in project tdi-studio-se by Talend.

the class StatusManagerSettingPage method okPressed.

protected void okPressed() {
    if (statusCombo == null) {
        return;
    }
    boolean modified = false;
    String newStatus = null;
    if (getModifiedVersionItems().size() > 0) {
        newStatus = statusHelper.getStatusCode(statusCombo.getText());
    }
    for (RepositoryObject object : getModifiedVersionItems()) {
        if (!isFixedstatus()) {
            newStatus = object.getStatusCode();
        }
        if (object != null && object.getProperty() != null) {
            if (!newStatus.equals(object.getProperty().getOldStatusCode())) {
                isApplied = false;
                modified = true;
                break;
            }
        }
    }
    if (modified) {
        boolean confirm = false;
        if (isFixedstatus()) {
            confirm = //$NON-NLS-1$
            MessageDialog.openConfirm(//$NON-NLS-1$
            getShell(), //$NON-NLS-1$
            Messages.getString("VersionManagementDialog.ConfirmTitle"), //$NON-NLS-1$
            Messages.getString("VersionManagementDialog.ConfirmMessage", newStatus));
            if (confirm) {
                // set all items for new version
                for (RepositoryObject object : getModifiedVersionItems()) {
                    if (techinalButton.getSelection()) {
                        ERepositoryObjectType type = object.getRepositoryNode().getContentType();
                        if (!type.equals(ERepositoryObjectType.DOCUMENTATION) && !type.equals(ERepositoryObjectType.BUSINESS_PROCESS)) {
                            object.setStatusCode(newStatus);
                        }
                    } else {
                        ERepositoryObjectType type = object.getRepositoryNode().getContentType();
                        if (type.equals(ERepositoryObjectType.DOCUMENTATION) || type.equals(ERepositoryObjectType.BUSINESS_PROCESS)) {
                            object.setStatusCode(newStatus);
                        }
                    }
                }
            }
        } else {
            StatusConfirmSettingDialog chanedDialog = new StatusConfirmSettingDialog(getShell(), getModifiedVersionItems(), statusHelper);
            confirm = (chanedDialog.open() == Window.OK);
        }
        if (confirm) {
            updateItemsVersion();
        }
    } else {
        if (!getModifiedVersionItems().isEmpty() && !isApplied) {
            //$NON-NLS-1$
            MessageDialog.openWarning(//$NON-NLS-1$
            getShell(), //$NON-NLS-1$
            Messages.getString("VersionManagementDialog.WarningTitle"), //$NON-NLS-1$
            Messages.getString("VersionManagementDialog.WarningMessages"));
        }
    }
}
Also used : RepositoryObject(org.talend.core.model.repository.RepositoryObject) StatusConfirmSettingDialog(org.talend.repository.ui.dialog.StatusConfirmSettingDialog) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Aggregations

ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)1 RepositoryObject (org.talend.core.model.repository.RepositoryObject)1 StatusConfirmSettingDialog (org.talend.repository.ui.dialog.StatusConfirmSettingDialog)1