/**
 * Copyright (C) 2011 eZuce Inc. All rights reserved.
 *
 * 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.jivesoftware.spark;

import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.spark.component.RolloverButton;
import org.jivesoftware.spark.ui.ChatRoomButton;
import org.jivesoftware.sparkimpl.plugin.emoticons.Emoticon;
import org.jivesoftware.sparkimpl.plugin.emoticons.EmoticonManager;

import static org.jivesoftware.spark.util.ResourceUtils.stripMnemonic;

public class ButtonFactory {

    private static final ButtonFactory instance = new ButtonFactory();

	protected ButtonFactory() {
		// nothing
	}

	public static ButtonFactory getInstance() {
		return instance;
	}

	public ChatRoomButton createChatTranscriptButton() {
		return new ChatRoomButton(SparkRes.getImageIcon(SparkRes.Icon.HISTORY_24x24_IMAGE));
	}

	public ChatRoomButton createSendFileButton() {
		return new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.Icon.SEND_FILE_24x24));
	}

	public ChatRoomButton createScreenshotButton() {
		return new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.Icon.PHOTO_IMAGE));
	}

	public ChatRoomButton createInviteConferenceButton() {
		return new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.Icon.CONFERENCE_IMAGE_24x24));
	}

	public RolloverButton createBuzzButton() {
		return new RolloverButton(SparkRes.getImageIcon(SparkRes.Icon.BUZZ_IMAGE));
	}

    public RolloverButton createEmoticonButton() {
        final EmoticonManager emoticonManager = EmoticonManager.getInstance();
        ImageIcon icon = emoticonManager.getEmoticonImage(":)");
        if (icon != null) {
            return new RolloverButton(icon);
        }
        return new RolloverButton(":)");
    }

	public JLabel createDivider() {
		return new JLabel(SparkRes.getImageIcon(SparkRes.Icon.DIVIDER_IMAGE));
	}
	
    public RolloverButton createSettingsButton() {
        RolloverButton settings = new RolloverButton(SparkRes.getImageIcon(SparkRes.Icon.SETTINGS_IMAGE_16x16));
        settings.setToolTipText(Res.getString("title.configure.room"));
        return settings;
    }

    public RolloverButton createTemaButton() {
        RolloverButton thema = new RolloverButton(SparkRes.getImageIcon(SparkRes.Icon.TYPING_TRAY));
        thema.setToolTipText(Res.getString("menuitem.change.subject"));
        return thema;
    }

    public RolloverButton createRegisterButton() {
        RolloverButton register = new RolloverButton(SparkRes.getImageIcon(SparkRes.Icon.PEOPLE_IMAGE));
        register.setToolTipText(stripMnemonic(Res.getString("button.register")));
        return register;
    }

    public RolloverButton createAlwaysOnTop(boolean isAlwaysOnTopActive) {
        RolloverButton alwaysOnTopItem = new RolloverButton();
        alwaysOnTopItem.setIcon(SparkRes.getImageIcon(isAlwaysOnTopActive ? SparkRes.Icon.FRAME_ALWAYS_ON_TOP_ACTIVE : SparkRes.Icon.FRAME_ALWAYS_ON_TOP_DEACTIVE));
        alwaysOnTopItem.setToolTipText(Res.getString("menuitem.always.on.top"));
        return alwaysOnTopItem;

    }
    
    public ChatRoomButton createOtrButton() {
    	return new ChatRoomButton();
    }    
}
