Search in sources :

Example 6 with Workspace

use of org.jivesoftware.spark.Workspace in project Spark by igniterealtime.

the class ContactList method addContactListToWorkspace.

private void addContactListToWorkspace() {
    Workspace workspace = SparkManager.getWorkspace();
    workspace.getWorkspacePane().addTab(Res.getString("tab.contacts"), SparkRes.getImageIcon(SparkRes.SMALL_ALL_CHATS_IMAGE), this);
    // Add To Contacts Menu
    final JMenu contactsMenu = SparkManager.getMainWindow().getMenuByName(Res.getString("menuitem.contacts"));
    JMenuItem addContactsMenu = new JMenuItem("", SparkRes.getImageIcon(SparkRes.USER1_ADD_16x16));
    ResourceUtils.resButton(addContactsMenu, Res.getString("menuitem.add.contact"));
    ResourceUtils.resButton(addContactGroupMenu, Res.getString("menuitem.add.contact.group"));
    if (!Default.getBoolean("ADD_CONTACT_DISABLED") && Enterprise.containsFeature(Enterprise.ADD_CONTACTS_FEATURE))
        contactsMenu.add(addContactsMenu);
    if (!Default.getBoolean("ADD_CONTACT_GROUP_DISABLED") && Enterprise.containsFeature(Enterprise.ADD_GROUPS_FEATURE))
        contactsMenu.add(addContactGroupMenu);
    addContactsMenu.addActionListener(e -> new RosterDialog().showRosterDialog());
    addContactGroupMenu.addActionListener(e -> {
        String groupName = JOptionPane.showInputDialog(getGUI(), Res.getString("message.name.of.group") + ":", Res.getString("title.add.new.group"), JOptionPane.QUESTION_MESSAGE);
        if (ModelUtil.hasLength(groupName)) {
            ContactGroup contactGroup = getContactGroup(groupName);
            if (contactGroup == null) {
                contactGroup = addContactGroup(groupName);
                contactGroup.setVisible(true);
                // validateTree();
                repaint();
            }
        }
    });
    // Add Toggle Contacts Menu
    ResourceUtils.resButton(showHideMenu, Res.getString("menuitem.show.empty.groups"));
    contactsMenu.add(showHideMenu);
    showHideMenu.addActionListener(e -> showEmptyGroups(showHideMenu.isSelected()));
    ResourceUtils.resButton(showOfflineGroupMenu, Res.getString("menuitem.show.offline.group"));
    contactsMenu.add(showOfflineGroupMenu);
    showOfflineGroupMenu.addActionListener(actionEvent -> showOfflineGroup(showOfflineGroupMenu.isSelected()));
    ResourceUtils.resButton(showOfflineUsersMenu, Res.getString("menuitem.show.offline.users"));
    contactsMenu.add(showOfflineUsersMenu);
    showOfflineUsersMenu.addActionListener(actionEvent -> showOfflineUsers(showOfflineUsersMenu.isSelected()));
    // Show or Hide Offline Group
    showOfflineGroupMenu.setSelected(localPreferences.isOfflineGroupVisible());
    showOfflineGroup(localPreferences.isOfflineGroupVisible());
    // sets showOfflineUsersMenu selected or not selected
    showOfflineUsersMenu.setSelected(localPreferences.isOfflineUsersShown());
    // Initialize vcard support
    SparkManager.getVCardManager();
}
Also used : Workspace(org.jivesoftware.spark.Workspace)

Example 7 with Workspace

use of org.jivesoftware.spark.Workspace in project Spark by igniterealtime.

the class ApplePlugin method setAvailableIfActive.

private void setAvailableIfActive() {
    if (!unavailable) {
        return;
    }
    // Handle if spark is not connected to the server.
    if (SparkManager.getConnection() == null || !SparkManager.getConnection().isConnected()) {
        return;
    }
    // Change Status
    Workspace workspace = SparkManager.getWorkspace();
    if (workspace != null) {
        Presence presence = workspace.getStatusBar().getStatusItem(Res.getString("available")).getPresence();
        if (previousPriority != -1) {
            presence.setPriority(previousPriority);
        }
        SparkManager.getSessionManager().changePresence(presence);
        unavailable = false;
        lastActive = System.currentTimeMillis();
    }
}
Also used : Presence(org.jivesoftware.smack.packet.Presence) Workspace(org.jivesoftware.spark.Workspace)

Example 8 with Workspace

use of org.jivesoftware.spark.Workspace in project Spark by igniterealtime.

the class ApplePlugin method sparkIsIdle.

private void sparkIsIdle() {
    LocalPreferences localPref = SettingsManager.getLocalPreferences();
    if (!localPref.isIdleOn()) {
        return;
    }
    try {
        // Handle if spark is not connected to the server.
        if (SparkManager.getConnection() == null || !SparkManager.getConnection().isConnected()) {
            return;
        }
        // Change Status
        Workspace workspace = SparkManager.getWorkspace();
        if (workspace != null) {
            Presence presence = workspace.getStatusBar().getPresence();
            long diff = System.currentTimeMillis() - lastActive;
            boolean idle = diff > 60000 * 60;
            if (presence.getMode() == Presence.Mode.available && idle) {
                unavailable = true;
                StatusItem away = workspace.getStatusBar().getStatusItem("Away");
                Presence p = away.getPresence();
                p.setStatus(Res.getString("message.away.idle"));
                previousPriority = presence.getPriority();
                p.setPriority(0);
                SparkManager.getSessionManager().changePresence(p);
            }
        }
    } catch (Exception e) {
        Log.error("Error with IDLE status.", e);
    }
}
Also used : StatusItem(org.jivesoftware.spark.ui.status.StatusItem) Presence(org.jivesoftware.smack.packet.Presence) LocalPreferences(org.jivesoftware.sparkimpl.settings.local.LocalPreferences) IOException(java.io.IOException) Workspace(org.jivesoftware.spark.Workspace)

Example 9 with Workspace

use of org.jivesoftware.spark.Workspace in project Spark by igniterealtime.

the class FastpathPlugin method showSelection.

private void showSelection(Collection<String> col) {
    if (col.size() == 0) {
        return;
    }
    mainPanel.setLayout(new GridBagLayout());
    mainPanel.setBorder(BorderFactory.createLineBorder(Color.lightGray, 1));
    workgroupLabel.setFont(new Font("Dialog", Font.BOLD, 11));
    logoutButton.setVisible(false);
    // Add workgroups to combobox
    Iterator<String> workgroups = col.iterator();
    while (workgroups.hasNext()) {
        String workgroup = (String) workgroups.next();
        String componentAddress = XmppStringUtils.parseDomain(workgroup);
        setComponentAddress(componentAddress);
        comboBox.addItem(XmppStringUtils.parseLocalpart(workgroup));
    }
    mainPanel.add(workgroupLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    mainPanel.add(logoutButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    mainPanel.add(comboBox, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    mainPanel.add(joinButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    container.getTopPanel().add(mainPanel, BorderLayout.CENTER);
    final Workspace workspace = SparkManager.getWorkspace();
    workspace.getWorkspacePane().addTab(FpRes.getString("tab.fastpath"), FastpathRes.getImageIcon(FastpathRes.FASTPATH_IMAGE_16x16), container);
    Action joinAction = new AbstractAction() {

        private static final long serialVersionUID = 4476966137732930493L;

        public void actionPerformed(ActionEvent actionEvent) {
            joinWorkgroup();
        }
    };
    Action leaveAction = new AbstractAction() {

        private static final long serialVersionUID = -264964340889335732L;

        public void actionPerformed(ActionEvent actionEvent) {
            leaveWorkgroup();
        }
    };
    if (col.size() == 1) {
        joinAction.actionPerformed(null);
    }
    logoutButton.addActionListener(leaveAction);
    joinButton.addActionListener(joinAction);
    // Load services immeditaly.
    Thread loadServicesThread = new Thread(new Runnable() {

        public void run() {
            SparkManager.getChatManager().getDefaultConferenceService();
        }
    });
    loadServicesThread.start();
}
Also used : ActionEvent(java.awt.event.ActionEvent) Workspace(org.jivesoftware.spark.Workspace)

Aggregations

Workspace (org.jivesoftware.spark.Workspace)9 Presence (org.jivesoftware.smack.packet.Presence)3 StatusItem (org.jivesoftware.spark.ui.status.StatusItem)3 IOException (java.io.IOException)2 StatusBar (org.jivesoftware.spark.ui.status.StatusBar)2 LocalPreferences (org.jivesoftware.sparkimpl.settings.local.LocalPreferences)2 MenuItem (java.awt.MenuItem)1 ActionEvent (java.awt.event.ActionEvent)1 UnknownHostException (java.net.UnknownHostException)1 KeyManagementException (java.security.KeyManagementException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 NoSuchProviderException (java.security.NoSuchProviderException)1 UnrecoverableKeyException (java.security.UnrecoverableKeyException)1 NamingException (javax.naming.NamingException)1 LoginException (javax.security.auth.login.LoginException)1 DocumentException (org.dom4j.DocumentException)1 LayoutSettings (org.jivesoftware.sparkimpl.plugin.layout.LayoutSettings)1