Adds read only property to the account properties, when enabled the account settings cannot be modified.

cusax-fix 4920
Damian Minkov 12 years ago
parent 0178ea0e99
commit c067eef9b2

@ -95,7 +95,7 @@ public class Wizard
private WizardController wizardController;
private TransparentPanel cardPanel;
protected TransparentPanel cardPanel;
private CardLayout cardLayout;

@ -36,6 +36,11 @@ public class AccountRegSummaryPage
private final AccountRegWizardContainerImpl wizardContainer;
/**
* In case of modification the modified protocol provider is supplied.
*/
private ProtocolProviderService protocolProviderService;
/**
* Creates an <tt>AccountRegSummaryPage</tt>.
*
@ -144,6 +149,14 @@ public void pageShowing()
this.valuesPanel.removeAll();
this.init(wizard.getSummary());
if(protocolProviderService != null
&& protocolProviderService.getAccountID().isReadOnly())
{
// disable commit button as the account is readonly
// we will just show its values
wizardContainer.setNextFinishButtonEnabled(false);
}
}
/**
@ -156,6 +169,12 @@ public void commitPage()
AccountRegistrationWizard wizard =
this.wizardContainer.getCurrentWizard();
if(this.protocolProviderService != null)
{
// we do not need it anymore
protocolProviderService = null;
}
try
{
ProtocolProviderService protocolProvider = wizard.signin();
@ -217,4 +236,28 @@ public void pageHiding()
public void pageShown()
{
}
/**
* Sets the modification property to indicate if this wizard is opened for
* a modification.
*
* @param protocolProvider indicates that this wizard is opened for
* modification.
*/
public void setModification(ProtocolProviderService protocolProvider)
{
this.protocolProviderService = protocolProvider;
}
@Override
public void dispose()
{
super.dispose();
if(this.protocolProviderService != null)
{
// we do not need it anymore
protocolProviderService = null;
}
}
}

@ -5,10 +5,15 @@
*/
package net.java.sip.communicator.impl.gui.main.account;
import java.awt.*;
import java.awt.Container;
import java.io.*;
import java.util.*;
import java.util.List;
import javax.imageio.*;
import javax.swing.*;
import javax.swing.text.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.wizard.*;
@ -146,10 +151,39 @@ public void modifyAccount(ProtocolProviderService protocolProvider)
this.setCurrentWizard(wizard);
wizard.setModification(true);
this.summaryPage.setModification(protocolProvider);
if(protocolProvider != null
&& protocolProvider.getAccountID().isReadOnly())
{
// cardPanel is the main panel of the wizard pages
setDisabled(cardPanel.getComponents());
}
wizard.loadAccount(protocolProvider);
}
/**
* Disables all editable components. Used to enable readonly accounts
* to only show their values and forbid the user to edit.
*
* @param components the components to disable
*/
private void setDisabled(Component[] components)
{
for(Component c : components)
{
if(c instanceof JTextComponent)
((JTextComponent)c).setEditable(false);
else if(c instanceof JComboBox
|| c instanceof AbstractButton)
c.setEnabled(false);
if(c instanceof Container)
setDisabled(((Container)c).getComponents());
}
}
/**
* Returns the wizard corresponding to the given protocol provider.
*

@ -719,6 +719,17 @@ public boolean isConfigHidden()
ProtocolProviderFactory.IS_ACCOUNT_CONFIG_HIDDEN) != null;
}
/**
* Checks if the account is marked as readonly.
* @return <tt>true</tt> if the account is marked as readonly or
* <tt>false</tt> otherwise.
*/
public boolean isReadOnly()
{
return getAccountPropertyString(
ProtocolProviderFactory.IS_ACCOUNT_READ_ONLY) != null;
}
/**
* Returns the first <tt>ProtocolProviderService</tt> implementation
* corresponding to the preferred protocol

@ -313,6 +313,12 @@ public abstract class ProtocolProviderFactory
*/
public static final String IS_ACCOUNT_CONFIG_HIDDEN = "IS_CONFIG_HIDDEN";
/**
* The name of the property that would indicate if a given account
* configuration is read only.
*/
public static final String IS_ACCOUNT_READ_ONLY = "IS_READ_ONLY";
/**
* The name of the property that would indicate if a given account
* groups are readonly, values can be all or a comma separated

Loading…
Cancel
Save