Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge branch 'integration/master' into fix_dashboard_redirection
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Aug 8, 2013
2 parents 3078393 + bc14ea9 commit 32c4bbb
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 85 deletions.
20 changes: 12 additions & 8 deletions zanata-war/src/main/java/org/zanata/ApplicationConfiguration.java
@@ -1,5 +1,5 @@
/*
* Copyright 2010, Red Hat, Inc. and individual contributors as indicated by the
* Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
* @author tags. See the copyright.txt file in the distribution for a full
* listing of individual contributors.
*
Expand Down Expand Up @@ -51,7 +51,6 @@
import org.zanata.log4j.ZanataHTMLLayout;
import org.zanata.log4j.ZanataSMTPAppender;
import org.zanata.security.AuthenticationType;

import com.google.common.base.Objects;

@Name("applicationConfiguration")
Expand All @@ -66,7 +65,7 @@ public class ApplicationConfiguration implements Serializable

private static final String EMAIL_APPENDER_NAME = "zanata.log.appender.email";
public static final String EVENT_CONFIGURATION_CHANGED = "zanata.configuration.changed";

private static final String STYLESHEET_LOCAL_PATH = "/assets/css/style.css";

private DatabaseBackedConfig databaseBackedConfig;
Expand All @@ -88,7 +87,6 @@ public class ApplicationConfiguration implements Serializable
// set by component.xml
private String webAssetsVersion = "";

@Observer({ EVENT_CONFIGURATION_CHANGED })
@Create
public void load()
{
Expand All @@ -101,6 +99,14 @@ public void load()
this.applyLoggingConfiguration();
}

@Observer({ EVENT_CONFIGURATION_CHANGED })
public void resetConfigValue(String configName)
{
// Remove the value from all stores
databaseBackedConfig.reset(configName);
jndiBackedConfig.reset(configName);
}

/**
* Loads the accepted login module (JAAS) names from the underlying configuration
*/
Expand Down Expand Up @@ -185,8 +191,7 @@ public String getServerPath()
if (request != null)
{
configuredValue =
request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ request.getContextPath();
request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
}
}
return configuredValue;
Expand Down Expand Up @@ -229,8 +234,7 @@ public String getFromEmailAddr()
// Finally, just throw an Exception
if (emailAddr == null)
{
throw new RuntimeException(
"'From' email address has not been defined in either zanata.properties or Zanata setup");
throw new RuntimeException("'From' email address has not been defined in either zanata.properties or Zanata setup");
}
return emailAddr;
}
Expand Down
Expand Up @@ -130,56 +130,20 @@ public void setEmailDomain(String emailDomain)
public String updateHomeContent()
{
HApplicationConfiguration var = applicationConfigurationDAO.findByKey(HApplicationConfiguration.KEY_HOME_CONTENT);
if (var != null)
{
if (homeContent == null || homeContent.isEmpty())
{
applicationConfigurationDAO.makeTransient(var);
}
else
{
var.setValue(homeContent);
}
}
else if (homeContent != null && !homeContent.isEmpty())
{
HApplicationConfiguration op = new HApplicationConfiguration(HApplicationConfiguration.KEY_HOME_CONTENT, homeContent);
applicationConfigurationDAO.makePersistent(op);
}
persistApplicationConfig(HApplicationConfiguration.KEY_HOME_CONTENT, var, homeContent);
applicationConfigurationDAO.flush();

FacesMessages.instance().add("Home content was successfully updated.");
if (Events.exists())
{
Events.instance().raiseTransactionSuccessEvent(ApplicationConfiguration.EVENT_CONFIGURATION_CHANGED);
}
return "/home.xhtml";
}

public String updateHelpContent()
{
HApplicationConfiguration var = applicationConfigurationDAO.findByKey(HApplicationConfiguration.KEY_HELP_CONTENT);
if (var != null)
{
if (helpContent == null || helpContent.isEmpty())
{
applicationConfigurationDAO.makeTransient(var);
}
else
{
var.setValue(helpContent);
}
}
else if (helpContent != null && !helpContent.isEmpty())
{
HApplicationConfiguration op = new HApplicationConfiguration(HApplicationConfiguration.KEY_HELP_CONTENT, helpContent);
applicationConfigurationDAO.makePersistent(op);
}
persistApplicationConfig(HApplicationConfiguration.KEY_HELP_CONTENT, var, helpContent);
applicationConfigurationDAO.flush();

FacesMessages.instance().add("Help page content was successfully updated.");
if (Events.exists())
{
Events.instance().raiseTransactionSuccessEvent(ApplicationConfiguration.EVENT_CONFIGURATION_CHANGED);
}
return "/help/view.xhtml";
}

Expand Down Expand Up @@ -354,10 +318,6 @@ public void update()

applicationConfigurationDAO.flush();
FacesMessages.instance().add("Configuration was successfully updated.");
if (Events.exists())
{
Events.instance().raiseTransactionSuccessEvent(ApplicationConfiguration.EVENT_CONFIGURATION_CHANGED);
}
}

private void persistApplicationConfig(String key, HApplicationConfiguration appConfig, String newValue)
Expand All @@ -378,6 +338,11 @@ else if (newValue != null && !newValue.isEmpty())
appConfig = new HApplicationConfiguration(key, newValue);
applicationConfigurationDAO.makePersistent(appConfig);
}

if (Events.exists())
{
Events.instance().raiseTransactionSuccessEvent(ApplicationConfiguration.EVENT_CONFIGURATION_CHANGED, key);
}
}

public String cancel()
Expand Down
Expand Up @@ -61,6 +61,16 @@ public void reset()
configurationValues = new HashMap<String, String>();
}

/**
* Resets a single value of the configuration. This value will be reloaded from the
* configuration store the next time it's requested.
* @param key Configuration key to reset.
*/
public void reset(String key)
{
configurationValues.remove(key);
}

private String getConfigValue(String key)
{
if( !configurationValues.containsKey(key) )
Expand Down Expand Up @@ -117,6 +127,12 @@ public String getHelpContent()
return getConfigValue(HApplicationConfiguration.KEY_HELP_CONTENT);
}

//invalidate key will force reload of that value from db
public void invalidateHomeContent()
{
configurationValues.remove(HApplicationConfiguration.KEY_HOME_CONTENT);
}

public String getHomeContent()
{
return getConfigValue(HApplicationConfiguration.KEY_HOME_CONTENT);
Expand Down Expand Up @@ -146,4 +162,6 @@ public String getPiwikSiteId()
{
return getConfigValue(HApplicationConfiguration.KEY_PIWIK_IDSITE);
}


}
10 changes: 10 additions & 0 deletions zanata-war/src/main/java/org/zanata/config/JndiBackedConfig.java
Expand Up @@ -106,6 +106,16 @@ public void reset()
configurationValues = new HashMap<String, String>();
}

/**
* Resets a single value of the configuration. This value will be reloaded from the
* configuration store the next time it's requested.
* @param key Configuration key to reset.
*/
public void reset(String key)
{
configurationValues.remove(key);
}

/**
* Specific to Directory-based configuration, this method returns a set of sub-keys available for the given
* "parent" key. For example, if there are two Jndi properties called 'org/zanata/prop1' and 'org/zanata/prop2',
Expand Down
Expand Up @@ -16,8 +16,8 @@
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.SplitLayoutPanel;
Expand Down Expand Up @@ -126,9 +126,9 @@ public void onChatInputBlur(BlurEvent event)
@Override
public void appendChat(String user, String timestamp, String msg, MESSAGE_TYPE messageType)
{
Label timestampLabel = new Label("[" + timestamp + "]");
InlineLabel timestampLabel = new InlineLabel("[" + timestamp + "]");
timestampLabel.setStylePrimaryName(style.timeStamp());
Label msgLabel = new Label(msg);
InlineLabel msgLabel = new InlineLabel(msg);
if (messageType == MESSAGE_TYPE.SYSTEM_MSG)
{
msgLabel.setStyleName(style.systemMsg());
Expand All @@ -142,16 +142,15 @@ else if (messageType == MESSAGE_TYPE.SYSTEM_WARNING)
msgLabel.setStyleName(style.msg());
}

HorizontalPanel hp = new HorizontalPanel();
FlowPanel hp = new FlowPanel();

if (!Strings.isNullOrEmpty(timestamp))
{
hp.add(timestampLabel);
hp.setCellWidth(timestampLabel, "107px");
}
if (!Strings.isNullOrEmpty(user))
{
Label userLabel = new Label(user + ":");
InlineLabel userLabel = new InlineLabel(user + ":");
userLabel.setStyleName(style.userName());
hp.add(userLabel);
}
Expand Down
Expand Up @@ -18,7 +18,10 @@

.chatRoomScrollPanel
{
height:100%;
top:0;
bottom:25px;
width:100%;
position:absolute !important;
}

.chatRoom
Expand All @@ -28,21 +31,21 @@

.chatInput
{
border:1px solid #FFFFFF;
width:100%;
border-radius:3px;
height:18px;
font-size:12px;
border:none;
border-radius:2px;
height:1.4em;
width:75%;
}

.sendButton
{
font-size:11px;
border-radius:5px;
font-size:0.85em;
border-radius:3px;
outline:none;
width:40px;
text-align:center;
margin-left:3px;
margin:0 3px;
display:inline-block;
}

.timeStamp
Expand Down Expand Up @@ -80,6 +83,12 @@
font-weight:bold;
font-size:12px;
}

.bottomPanel {
position:absolute;
bottom:0;
width:100%;
}
</ui:style>

<g:SplitLayoutPanel ui:field="mainPanel" styleName="{style.mainPanel}">
Expand All @@ -89,23 +98,15 @@
</g:ScrollPanel>
</g:north>
<g:center>
<g:LayoutPanel height="100%" width="100%">
<g:layer top="0px" bottom="24px">
<g:ScrollPanel styleName="{style.chatRoomScrollPanel}" ui:field="chatRoomScrollPanel">
<g:VerticalPanel ui:field="chatRoom" styleName="{style.chatRoom}"/>
</g:ScrollPanel>
</g:layer>
<g:layer bottom="2px" height="25px">
<g:HorizontalPanel width="100%" spacing="3">
<g:cell>
<g:TextBox styleName="{style.chatInput}" ui:field="chatInput"/>
</g:cell>
<g:cell width="40px">
<g:PushButton addStyleNames="{style.sendButton}" ui:field="sendButton"/>
</g:cell>
</g:HorizontalPanel>
</g:layer>
</g:LayoutPanel>
<g:HTMLPanel>
<g:ScrollPanel styleName="{style.chatRoomScrollPanel}" ui:field="chatRoomScrollPanel">
<g:VerticalPanel ui:field="chatRoom" styleName="{style.chatRoom}"/>
</g:ScrollPanel>
<g:HTMLPanel styleName="{style.bottomPanel}">
<g:TextBox styleName="{style.chatInput}" ui:field="chatInput"/>
<g:PushButton addStyleNames="{style.sendButton}" ui:field="sendButton"/>
</g:HTMLPanel>
</g:HTMLPanel>
</g:center>
</g:SplitLayoutPanel>

Expand Down

0 comments on commit 32c4bbb

Please sign in to comment.