Search in sources :

Example 16 with LocalPreferences

use of org.jivesoftware.sparkimpl.settings.local.LocalPreferences in project Spark by igniterealtime.

the class ChatTranscriptPlugin method chatRoomOpened.

@Override
public void chatRoomOpened(final ChatRoom room) {
    LocalPreferences pref = SettingsManager.getLocalPreferences();
    if (!pref.isChatHistoryEnabled()) {
        return;
    }
    final EntityBareJid jid = room.getBareJid();
    File transcriptFile = ChatTranscripts.getTranscriptFile(jid);
    if (!transcriptFile.exists()) {
        return;
    }
    if (room instanceof ChatRoomImpl) {
        new ChatRoomDecorator(room);
    }
}
Also used : LocalPreferences(org.jivesoftware.sparkimpl.settings.local.LocalPreferences) EntityBareJid(org.jxmpp.jid.EntityBareJid) File(java.io.File) ChatRoomImpl(org.jivesoftware.spark.ui.rooms.ChatRoomImpl)

Example 17 with LocalPreferences

use of org.jivesoftware.sparkimpl.settings.local.LocalPreferences in project Spark by igniterealtime.

the class ChatPreferencePanel method createUI.

private void createUI() {
    setLayout(new VerticalFlowLayout());
    timeFormat.add(format24);
    timeFormat.add(format24s);
    timeFormat.add(format12);
    timeFormat.add(format12s);
    final LocalPreferences pref = SettingsManager.getLocalPreferences();
    switch(pref.getTimeFormat()) {
        case "HH:mm":
            format24.setSelected(true);
            break;
        case "HH:mm:ss":
            format24s.setSelected(true);
            break;
        case "h:mm a":
            format12.setSelected(true);
            break;
        default:
            format12s.setSelected(true);
            break;
    }
    // Setup Mnemonics
    ResourceUtils.resButton(showTimeBox, Res.getString("checkbox.show.time.in.chat.window"));
    ResourceUtils.resLabel(passwordLabel, passwordField, Res.getString("label.change.password.to") + ":");
    ResourceUtils.resLabel(confirmationPasswordLabel, confirmationPasswordField, Res.getString("label.confirm.password") + ":");
    ResourceUtils.resButton(groupChatNotificationBox, Res.getString("checkbox.show.notifications.in.conference"));
    ResourceUtils.resButton(hideChatHistory, Res.getString("checkbox.disable.chat.history"));
    ResourceUtils.resButton(hidePrevChatHistory, Res.getString("checkbox.disable.prev.chat.history"));
    ResourceUtils.resButton(sortChatHistoryAscending, Res.getString("checkbox.sort.asc.history"));
    ResourceUtils.resButton(tabsOnTopBox, Res.getString("checkbox.tabs.on.top"));
    ResourceUtils.resButton(buzzBox, Res.getString("checkbox.allow.buzz"));
    generalPanel.setBorder(BorderFactory.createTitledBorder(Res.getString("group.general.information")));
    chatWindowPanel.setBorder(BorderFactory.createTitledBorder(Res.getString("group.chat.window.information")));
    if (!Default.getBoolean(Default.CHANGE_PASSWORD_DISABLED) && Enterprise.containsFeature(Enterprise.PASSWORD_CHANGE_FEATURE))
        add(generalPanel);
    add(chatWindowPanel);
    generalPanel.setLayout(new GridBagLayout());
    chatWindowPanel.setLayout(new GridBagLayout());
    // Chat Window Panel settings
    chatWindowPanel.add(showTimeBox, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    chatWindowPanel.add(format24, new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    chatWindowPanel.add(format24s, new GridBagConstraints(1, 1, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    chatWindowPanel.add(format12, new GridBagConstraints(2, 0, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    chatWindowPanel.add(format12s, new GridBagConstraints(2, 1, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    chatWindowPanel.add(groupChatNotificationBox, new GridBagConstraints(0, 2, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    if (!Default.getBoolean(Default.HISTORY_DISABLED) && !Default.getBoolean(Default.HIDE_HISTORY_SETTINGS) && Enterprise.containsFeature(Enterprise.HISTORY_SETTINGS_FEATURE) && Enterprise.containsFeature(Enterprise.HISTORY_TRANSCRIPTS_FEATURE)) {
        chatWindowPanel.add(hideChatHistory, new GridBagConstraints(0, 3, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
        chatWindowPanel.add(hidePrevChatHistory, new GridBagConstraints(0, 4, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    }
    chatWindowPanel.add(sortChatHistoryAscending, new GridBagConstraints(0, 5, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    chatWindowPanel.add(tabsOnTopBox, new GridBagConstraints(0, 6, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    chatWindowPanel.add(buzzBox, new GridBagConstraints(0, 7, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    JLabel chatTimeoutLabel = new JLabel();
    ResourceUtils.resLabel(chatTimeoutLabel, chatTimeoutField, Res.getString("label.minutes.before.stale.chat") + ":");
    chatWindowPanel.add(chatTimeoutLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    chatWindowPanel.add(chatTimeoutField, new GridBagConstraints(1, 8, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0));
    generalPanel.add(passwordLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    generalPanel.add(passwordField, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 100, 0));
    generalPanel.add(confirmationPasswordLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    generalPanel.add(confirmationPasswordField, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 100, 0));
    showTimeBox.addActionListener(e -> {
        if (showTimeBox.isSelected()) {
            format12.setEnabled(true);
            format24.setEnabled(true);
            format12s.setEnabled(true);
            format24s.setEnabled(true);
        } else {
            format12.setEnabled(false);
            format24.setEnabled(false);
            format12s.setEnabled(false);
            format24s.setEnabled(false);
        }
    });
    hideChatHistory.addActionListener(this);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) LocalPreferences(org.jivesoftware.sparkimpl.settings.local.LocalPreferences) VerticalFlowLayout(org.jivesoftware.spark.component.VerticalFlowLayout)

Example 18 with LocalPreferences

use of org.jivesoftware.sparkimpl.settings.local.LocalPreferences in project Spark by igniterealtime.

the class NotificationsPreference method load.

@Override
public void load() {
    SwingWorker thread = new SwingWorker() {

        LocalPreferences localPreferences;

        @Override
        public Object construct() {
            localPreferences = SettingsManager.getLocalPreferences();
            return localPreferences;
        }

        @Override
        public void finished() {
            boolean toaster = localPreferences.getShowToasterPopup();
            boolean asteriskToaster = localPreferences.getDisableAsteriskToasterPopup();
            boolean windowFocus = localPreferences.getWindowTakesFocus();
            boolean offlineNotification = localPreferences.isOfflineNotificationsOn();
            boolean onlineNotification = localPreferences.isOnlineNotificationsOn();
            boolean betaChecking = localPreferences.isBetaCheckingEnabled();
            int DisplayTime = localPreferences.getNotificationsDisplayTime();
            boolean typingNotification = localPreferences.isTypingNotificationShown();
            boolean systemTrayNotification = localPreferences.isSystemTrayNotificationEnabled();
            panel.setShowToaster(toaster);
            panel.setDisableAsteriskToaster(asteriskToaster);
            panel.setShowWindowPopup(windowFocus);
            panel.setOfflineNotification(offlineNotification);
            panel.setOnlineNotification(onlineNotification);
            panel.setCheckForBeta(betaChecking);
            panel.setNotificationsDisplayTime(DisplayTime / 1000);
            panel.setTypingNotification(typingNotification);
            panel.setSystemTrayNotification(systemTrayNotification);
            // when windowFocus is selected the systemtraynotification doesn't work --> disable it
            if (windowFocus) {
                panel.setSystemTrayNotification(false);
                panel.setSystemTrayNotificationEnabled(false);
            } else
                panel.setSystemTrayNotificationEnabled(true);
            if (systemTrayNotification) {
                panel.setShowWindowPopup(false);
                panel.setShowWindowPopupEnabled(false);
            } else
                panel.setShowWindowPopupEnabled(true);
        }
    };
    thread.start();
}
Also used : SwingWorker(org.jivesoftware.spark.util.SwingWorker) LocalPreferences(org.jivesoftware.sparkimpl.settings.local.LocalPreferences)

Example 19 with LocalPreferences

use of org.jivesoftware.sparkimpl.settings.local.LocalPreferences in project Spark by igniterealtime.

the class ChatPreference method load.

@Override
public void load() {
    SwingWorker thread = new SwingWorker() {

        LocalPreferences localPreferences;

        @Override
        public Object construct() {
            localPreferences = SettingsManager.getLocalPreferences();
            return localPreferences;
        }

        @Override
        public void finished() {
            boolean showTime = localPreferences.isTimeDisplayedInChat();
            boolean notificationsOn = localPreferences.isChatRoomNotificationsOn();
            boolean chatHistoryHidden = !localPreferences.isChatHistoryEnabled();
            boolean prevChatHistoryHidden = !localPreferences.isPrevChatHistoryEnabled();
            boolean tabsOnTop = localPreferences.isTabTopPosition();
            boolean buzzAllowed = localPreferences.isBuzzEnabled();
            boolean isChatHistoryAscending = localPreferences.getChatHistoryAscending();
            panel.setShowTime(showTime);
            panel.setGroupChatNotificationsOn(notificationsOn);
            panel.setChatHistoryHidden(chatHistoryHidden);
            panel.setPrevChatHistoryHidden(prevChatHistoryHidden);
            panel.setChatTimeoutTime(localPreferences.getChatLengthDefaultTimeout());
            panel.setTabsOnTop(tabsOnTop);
            panel.setBuzzEnabled(buzzAllowed);
            panel.setSortChatHistoryAscending(isChatHistoryAscending);
        }
    };
    thread.start();
}
Also used : SwingWorker(org.jivesoftware.spark.util.SwingWorker) LocalPreferences(org.jivesoftware.sparkimpl.settings.local.LocalPreferences)

Example 20 with LocalPreferences

use of org.jivesoftware.sparkimpl.settings.local.LocalPreferences in project Spark by igniterealtime.

the class GroupChatPreference method load.

@Override
public void load() {
    SwingWorker thread = new SwingWorker() {

        LocalPreferences localPreferences;

        @Override
        public Object construct() {
            localPreferences = SettingsManager.getLocalPreferences();
            return localPreferences;
        }

        @Override
        public void finished() {
            boolean highlightMyName = localPreferences.isMucHighNameEnabled();
            boolean highlightMyText = localPreferences.isMucHighTextEnabled();
            boolean highlightPopName = localPreferences.isMucHighToastEnabled();
            boolean showjoinleavemessage = localPreferences.isShowJoinLeaveMessagesEnabled();
            boolean showroleicons = localPreferences.isShowingRoleIcons();
            boolean autoAcceptMucInvite = localPreferences.isAutoAcceptMucInvite();
            boolean randomColors = localPreferences.isMucRandomColors();
            boolean inviteToBookmark = !localPreferences.isUseAdHocRoom();
            panel.setMucHighNameEnabled(highlightMyName);
            panel.setMucHighTextEnabled(highlightMyText);
            panel.setMuchHighToastEnabled(highlightPopName);
            panel.setShowJoinLeaveMessagesEnabled(showjoinleavemessage);
            panel.setShowRoleIconInsteadStatusIcon(showroleicons);
            panel.setAutoAcceptMuc(autoAcceptMucInvite);
            panel.setRandomColors(randomColors);
            panel.setInviteToBookmark(inviteToBookmark);
        }
    };
    thread.start();
}
Also used : SwingWorker(org.jivesoftware.spark.util.SwingWorker) LocalPreferences(org.jivesoftware.sparkimpl.settings.local.LocalPreferences)

Aggregations

LocalPreferences (org.jivesoftware.sparkimpl.settings.local.LocalPreferences)55 SmackException (org.jivesoftware.smack.SmackException)12 XMPPException (org.jivesoftware.smack.XMPPException)11 SwingWorker (org.jivesoftware.spark.util.SwingWorker)9 EntityBareJid (org.jxmpp.jid.EntityBareJid)9 File (java.io.File)8 GroupChatRoom (org.jivesoftware.spark.ui.rooms.GroupChatRoom)8 MultiUserChat (org.jivesoftware.smackx.muc.MultiUserChat)7 Message (org.jivesoftware.smack.packet.Message)6 ChatRoomNotFoundException (org.jivesoftware.spark.ui.ChatRoomNotFoundException)6 Resourcepart (org.jxmpp.jid.parts.Resourcepart)6 ActionEvent (java.awt.event.ActionEvent)5 FillableForm (org.jivesoftware.smackx.xdata.form.FillableForm)4 ChatManager (org.jivesoftware.spark.ChatManager)4 GridBagConstraints (java.awt.GridBagConstraints)3 GridBagLayout (java.awt.GridBagLayout)3 Insets (java.awt.Insets)3 IOException (java.io.IOException)3 KeyManagementException (java.security.KeyManagementException)3 AbstractAction (javax.swing.AbstractAction)3