Search in sources :

Example 1 with LayoutSettings

use of org.jivesoftware.sparkimpl.plugin.layout.LayoutSettings in project Spark by igniterealtime.

the class LoginDialog method startSpark.

/**
 * Initializes Spark and initializes all plugins.
 */
private void startSpark() {
    // Invoke the MainWindow.
    try {
        EventQueue.invokeLater(() -> {
            final MainWindow mainWindow = MainWindow.getInstance();
            /*
             if (tray != null) {
                 // Remove trayIcon
                 tray.removeTrayIcon(trayIcon);
             }
             */
            // Creates the Spark  Workspace and add to MainWindow
            Workspace workspace = Workspace.getInstance();
            LayoutSettings settings = LayoutSettingsManager.getLayoutSettings();
            LocalPreferences pref = SettingsManager.getLocalPreferences();
            if (pref.isDockingEnabled()) {
                JSplitPane splitPane = mainWindow.getSplitPane();
                workspace.getCardPanel().setMinimumSize(null);
                splitPane.setLeftComponent(workspace.getCardPanel());
                SparkManager.getChatManager().getChatContainer().setMinimumSize(null);
                splitPane.setRightComponent(SparkManager.getChatManager().getChatContainer());
                int dividerLoc = settings.getSplitPaneDividerLocation();
                if (dividerLoc != -1) {
                    mainWindow.getSplitPane().setDividerLocation(dividerLoc);
                } else {
                    mainWindow.getSplitPane().setDividerLocation(240);
                }
                mainWindow.getContentPane().add(splitPane, BorderLayout.CENTER);
            } else {
                mainWindow.getContentPane().add(workspace.getCardPanel(), BorderLayout.CENTER);
            }
            final Rectangle mainWindowBounds = settings.getMainWindowBounds();
            if (mainWindowBounds == null || mainWindowBounds.width <= 0 || mainWindowBounds.height <= 0) {
                // Use Default size
                mainWindow.setSize(310, 520);
                // Center Window on Screen
                GraphicUtils.centerWindowOnScreen(mainWindow);
            } else {
                mainWindow.setBounds(mainWindowBounds);
            }
            if (loginDialog.isVisible()) {
                mainWindow.setVisible(true);
            }
            loginDialog.setVisible(false);
            // Build the layout in the workspace
            workspace.buildLayout();
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : LayoutSettings(org.jivesoftware.sparkimpl.plugin.layout.LayoutSettings) LocalPreferences(org.jivesoftware.sparkimpl.settings.local.LocalPreferences) LoginException(javax.security.auth.login.LoginException) NamingException(javax.naming.NamingException) KeyStoreException(java.security.KeyStoreException) KeyManagementException(java.security.KeyManagementException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) DocumentException(org.dom4j.DocumentException) UnrecoverableKeyException(java.security.UnrecoverableKeyException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) NoSuchProviderException(java.security.NoSuchProviderException) Workspace(org.jivesoftware.spark.Workspace)

Example 2 with LayoutSettings

use of org.jivesoftware.sparkimpl.plugin.layout.LayoutSettings in project Spark by igniterealtime.

the class ContactItem method setDisplayName.

/**
 * Updates the displayed name for the contact. This method tries to use an
 * alias first. If that's not set, the nickname will be used instead. If
 * that's not set either, the JID of the user will be used.
 */
protected void setDisplayName() {
    final String displayName = getDisplayName();
    int nickLength = displayName.length();
    LayoutSettings settings = LayoutSettingsManager.getLayoutSettings();
    int windowWidth = settings.getMainWindowBounds() != null ? settings.getMainWindowBounds().width : 50;
    if (nickLength > windowWidth) {
        // FIXME comparing pixel-width with character count - that can't be good.
        displayNameLabel.setText(XmppStringUtils.unescapeLocalpart(displayName).substring(0, windowWidth) + "...");
    } else {
        displayNameLabel.setText(XmppStringUtils.unescapeLocalpart(displayName));
    }
}
Also used : LayoutSettings(org.jivesoftware.sparkimpl.plugin.layout.LayoutSettings)

Aggregations

LayoutSettings (org.jivesoftware.sparkimpl.plugin.layout.LayoutSettings)2 IOException (java.io.IOException)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 Workspace (org.jivesoftware.spark.Workspace)1 LocalPreferences (org.jivesoftware.sparkimpl.settings.local.LocalPreferences)1