<commit_before>/*
 * Copyright 2002-2004 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.springframework.richclient.dialog;

import java.awt.BorderLayout;
import java.awt.Image;
import java.awt.Window;
import java.beans.PropertyChangeListener;

import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JSeparator;

import org.springframework.richclient.core.DescriptionConfigurable;
import org.springframework.richclient.core.Message;
import org.springframework.richclient.image.config.ImageConfigurable;
import org.springframework.richclient.util.GuiStandardUtils;
import org.springframework.util.ObjectUtils;

public abstract class TitledApplicationDialog extends ApplicationDialog implements Messagable, ImageConfigurable,
        DescriptionConfigurable {
    private TitlePane titlePane = new TitlePane();

    private Message description = new Message("Title pane description");

    private JComponent pageControl;

    private JComponent contentPane;

    public TitledApplicationDialog() {
        super();
    }

    public TitledApplicationDialog(String title, Window parent) {
        super(title, parent);
    }

    public TitledApplicationDialog(String title, Window parent, CloseAction closeAction) {
        super(title, parent, closeAction);
    }

    public void setCaption(String shortDescription) {
        throw new UnsupportedOperationException("What can I do with a caption?");
    }

    public void setDescription(String description) {
        Message old = this.description;
        Message message = new Message(description);
        if (!ObjectUtils.nullSafeEquals(old, message)) {
            this.description = message;
            if (titlePane.getMessage().equals(old)) {
                titlePane.setMessage(this.description);
            }
        }
    }

    public void setTitlePaneTitle(String titleAreaText) {
        titlePane.setTitle(titleAreaText);
    }

    public void setTitlePaneImage(Image image) {
        titlePane.setImage(image);
    }

    public void setImage(Image image) {
        setTitlePaneImage(image);
    }

    public Message getMessage() {
        return titlePane.getMessage();
    }

    public void setMessage(Message message) {
        if (message == null) {
            message = Message.EMPTY_MESSAGE;
        }
        if (!message.isEmpty()) {
            titlePane.setMessage(message);
        }
        else {
            titlePane.setMessage(getDescription());
        }<commit_msg>Fix setDescription - it was only updating the title if the new message was the SAME, not different.<commit_after>/*
 * Copyright 2002-2004 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.springframework.richclient.dialog;

import java.awt.BorderLayout;
import java.awt.Image;
import java.awt.Window;
import java.beans.PropertyChangeListener;

import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JSeparator;

import org.springframework.richclient.core.DescriptionConfigurable;
import org.springframework.richclient.core.Message;
import org.springframework.richclient.image.config.ImageConfigurable;
import org.springframework.richclient.util.GuiStandardUtils;
import org.springframework.util.ObjectUtils;

public abstract class TitledApplicationDialog extends ApplicationDialog implements Messagable, ImageConfigurable,
        DescriptionConfigurable {
    private TitlePane titlePane = new TitlePane();

    private Message description = new Message("Title pane description");

    private JComponent pageControl;

    private JComponent contentPane;

    public TitledApplicationDialog() {
        super();
    }

    public TitledApplicationDialog(String title, Window parent) {
        super(title, parent);
    }

    public TitledApplicationDialog(String title, Window parent, CloseAction closeAction) {
        super(title, parent, closeAction);
    }

    public void setCaption(String shortDescription) {
        throw new UnsupportedOperationException("What can I do with a caption?");
    }

    public void setDescription(String description) {
        Message old = this.description;
        Message message = new Message(description);
        if (!ObjectUtils.nullSafeEquals(old, message)) {
            this.description = message;
            if (!titlePane.getMessage().equals(old)) {
                titlePane.setMessage(this.description);
            }
        }
    }

    public void setTitlePaneTitle(String titleAreaText) {
        titlePane.setTitle(titleAreaText);
    }

    public void setTitlePaneImage(Image image) {
        titlePane.setImage(image);
    }

    public void setImage(Image image) {
        setTitlePaneImage(image);
    }

    public Message getMessage() {
        return titlePane.getMessage();
    }

    public void setMessage(Message message) {
        if (message == null) {
            message = Message.EMPTY_MESSAGE;
        }
        if (!message.isEmpty()) {
            titlePane.setMessage(message);
        }
        else {
            titlePane.setMessage(getDescription());
        }
{'fraction_non_alphanumeric': 0.08148027917545853, 'fraction_numerical': 0.003895471514364551, 'mean_word_length': 3.2851182197496525, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5564680', 'n_tokens_mistral': 1553, 'n_tokens_neox': 1504, 'n_words': 468}