ccm-shortcuts: Some reformatting of sources
Foundry: Added an additional selector for selecting the template for a portlet git-svn-id: https://svn.libreccm.org/ccm/trunk@3704 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
e998131935
commit
375b78c3bd
|
|
@ -139,6 +139,9 @@
|
|||
<xsl:variable name="classname">
|
||||
<xsl:value-of select="./@bebop:classname"/>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="title">
|
||||
<xsl:value-of select="./@title"/>
|
||||
</xsl:variable>
|
||||
|
||||
<!--<pre>
|
||||
<xsl:value-of select="concat('portlet-class = ', ./@bebop:classname)"/>
|
||||
|
|
@ -151,6 +154,11 @@
|
|||
</pre>-->
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$template-map/portlet[@class=$classname and @workspace = $workspace and @title=$title]">
|
||||
<xsl:apply-templates select="document(foundry:gen-path(concat('templates/', normalize-space($template-map/portlet[@class=$classname and @workspace=$workspace and @title=$title]))))/*">
|
||||
<xsl:with-param name="portlet-data-tree" tunnel="yes" select="current()"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:when test="$template-map/portlet[@class=$classname and @workspace = $workspace]">
|
||||
<xsl:apply-templates select="document(foundry:gen-path(concat('templates/', normalize-space($template-map/portlet[@class=$classname and @workspace=$workspace]))))/*">
|
||||
<xsl:with-param name="portlet-data-tree" tunnel="yes" select="current()"/>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
* rights and limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.arsdigita.shortcuts.ui;
|
||||
|
||||
import org.apache.log4j.Category;
|
||||
|
|
@ -24,22 +23,22 @@ import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
|||
|
||||
public class AdminPanel extends SimpleContainer {
|
||||
|
||||
private ACSObjectSelectionModel m_shortcut = new ACSObjectSelectionModel(
|
||||
new BigDecimalParameter("shortcutID"));
|
||||
private ACSObjectSelectionModel m_shortcut = new ACSObjectSelectionModel(
|
||||
new BigDecimalParameter("shortcutID"));
|
||||
|
||||
private static final Category log = Category.getInstance(AdminPanel.class
|
||||
.getName());
|
||||
private static final Category log = Category.getInstance(AdminPanel.class
|
||||
.getName());
|
||||
|
||||
public AdminPanel() {
|
||||
add(new ShortcutForm(m_shortcut));
|
||||
add(new ShortcutsTable(m_shortcut));
|
||||
}
|
||||
public AdminPanel() {
|
||||
add(new ShortcutForm(m_shortcut));
|
||||
add(new ShortcutsTable(m_shortcut));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(Page p) {
|
||||
super.register(p);
|
||||
public void register(Page p) {
|
||||
super.register(p);
|
||||
|
||||
p.addGlobalStateParam(m_shortcut.getStateParameter());
|
||||
}
|
||||
p.addGlobalStateParam(m_shortcut.getStateParameter());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
package com.arsdigita.shortcuts.ui;
|
||||
|
||||
import com.arsdigita.bebop.Table;
|
||||
|
|
@ -43,112 +42,123 @@ import com.arsdigita.domain.DataObjectNotFoundException;
|
|||
import com.arsdigita.bebop.ExternalLink;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ShortcutsTable extends Table {
|
||||
private static final Category log =
|
||||
Category.getInstance(ShortcutsTable.class.getName());
|
||||
|
||||
public static final String headers[] = { "URL Key", "Redirect", "", "" };
|
||||
private static final Category log = Category.getInstance(
|
||||
ShortcutsTable.class.getName());
|
||||
|
||||
public ShortcutsTable(final ACSObjectSelectionModel selected_shortcut) {
|
||||
super(new ShortcutsModelBuilder(), headers);
|
||||
public static final String headers[] = {"URL Key", "Redirect", "", ""};
|
||||
|
||||
setDefaultCellRenderer(new ShortcutsCellRenderer());
|
||||
public ShortcutsTable(final ACSObjectSelectionModel selected_shortcut) {
|
||||
super(new ShortcutsModelBuilder(), headers);
|
||||
|
||||
addTableActionListener(new TableActionListener() {
|
||||
public void cellSelected(TableActionEvent e) {
|
||||
selected_shortcut.clearSelection(e.getPageState());
|
||||
String row = (String) e.getRowKey();
|
||||
if (e.getColumn().intValue() == 2) {
|
||||
// edit selected
|
||||
log.debug("selected edit shortcut " + row);
|
||||
try {
|
||||
selected_shortcut.setSelectedKey(e.getPageState(), new BigDecimal(row));
|
||||
} catch (DataObjectNotFoundException ex) {
|
||||
throw new UncheckedWrapperException(
|
||||
"cannot find shortcut", ex);
|
||||
}
|
||||
} else if (e.getColumn().intValue() == 3) {
|
||||
// delete selected
|
||||
log.fatal("selected delete shortcut " + row);
|
||||
try {
|
||||
Shortcut shortcut = new Shortcut(new BigDecimal(row));
|
||||
log.info("delete shortcut " + shortcut.getUrlKey());
|
||||
shortcut.delete();
|
||||
ShortcutUtil.repopulateShortcuts();
|
||||
} catch (DataObjectNotFoundException ex) {
|
||||
throw new UncheckedWrapperException(
|
||||
"cannot find shortcut", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
setDefaultCellRenderer(new ShortcutsCellRenderer());
|
||||
|
||||
public void headSelected(TableActionEvent e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
addTableActionListener(new TableActionListener() {
|
||||
|
||||
protected static class ShortcutsModelBuilder extends LockableImpl implements
|
||||
TableModelBuilder {
|
||||
public void cellSelected(TableActionEvent e) {
|
||||
selected_shortcut.clearSelection(e.getPageState());
|
||||
String row = (String) e.getRowKey();
|
||||
if (e.getColumn().intValue() == 2) {
|
||||
// edit selected
|
||||
log.debug("selected edit shortcut " + row);
|
||||
try {
|
||||
selected_shortcut.setSelectedKey(e.getPageState(),
|
||||
new BigDecimal(row));
|
||||
} catch (DataObjectNotFoundException ex) {
|
||||
throw new UncheckedWrapperException(
|
||||
"cannot find shortcut", ex);
|
||||
}
|
||||
} else if (e.getColumn().intValue() == 3) {
|
||||
// delete selected
|
||||
log.fatal("selected delete shortcut " + row);
|
||||
try {
|
||||
Shortcut shortcut = new Shortcut(new BigDecimal(row));
|
||||
log.info("delete shortcut " + shortcut.getUrlKey());
|
||||
shortcut.delete();
|
||||
ShortcutUtil.repopulateShortcuts();
|
||||
} catch (DataObjectNotFoundException ex) {
|
||||
throw new UncheckedWrapperException(
|
||||
"cannot find shortcut", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TableModel makeModel(Table table, PageState ps) {
|
||||
return new ShortcutsModel();
|
||||
}
|
||||
public void headSelected(TableActionEvent e) {
|
||||
}
|
||||
|
||||
protected class ShortcutsModel implements TableModel {
|
||||
private ShortcutCollection m_shortcuts;
|
||||
});
|
||||
}
|
||||
|
||||
private Shortcut m_shortcut;
|
||||
protected static class ShortcutsModelBuilder extends LockableImpl implements
|
||||
TableModelBuilder {
|
||||
|
||||
public ShortcutsModel() {
|
||||
m_shortcuts = Shortcut.retrieveAll();
|
||||
}
|
||||
public TableModel makeModel(Table table, PageState ps) {
|
||||
return new ShortcutsModel();
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return headers.length;
|
||||
}
|
||||
protected class ShortcutsModel implements TableModel {
|
||||
|
||||
public boolean nextRow() {
|
||||
if (m_shortcuts.next()) {
|
||||
m_shortcut = m_shortcuts.getShortcut();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private ShortcutCollection m_shortcuts;
|
||||
|
||||
public Object getElementAt(int col) {
|
||||
return m_shortcut;
|
||||
}
|
||||
private Shortcut m_shortcut;
|
||||
|
||||
public Object getKeyAt(int col) {
|
||||
BigDecimal id = m_shortcut.getID();
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
public ShortcutsModel() {
|
||||
m_shortcuts = Shortcut.retrieveAll();
|
||||
}
|
||||
|
||||
protected static class ShortcutsCellRenderer implements TableCellRenderer {
|
||||
public Component getComponent(Table table, PageState state,
|
||||
Object value, boolean isSelected, Object key, int row,
|
||||
int column) {
|
||||
Shortcut shortcut = (Shortcut) value;
|
||||
public int getColumnCount() {
|
||||
return headers.length;
|
||||
}
|
||||
|
||||
public boolean nextRow() {
|
||||
if (m_shortcuts.next()) {
|
||||
m_shortcut = m_shortcuts.getShortcut();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object getElementAt(int col) {
|
||||
return m_shortcut;
|
||||
}
|
||||
|
||||
public Object getKeyAt(int col) {
|
||||
BigDecimal id = m_shortcut.getID();
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected static class ShortcutsCellRenderer implements TableCellRenderer {
|
||||
|
||||
public Component getComponent(Table table, PageState state,
|
||||
Object value, boolean isSelected,
|
||||
Object key, int row,
|
||||
int column) {
|
||||
Shortcut shortcut = (Shortcut) value;
|
||||
|
||||
switch (column) {
|
||||
case 0:
|
||||
return new ExternalLink(shortcut.getUrlKey(), shortcut
|
||||
.getUrlKey());
|
||||
case 1:
|
||||
return new ExternalLink(shortcut.getRedirect(), shortcut
|
||||
.getRedirect());
|
||||
case 2:
|
||||
return new ControlLink(" edit ");
|
||||
case 3:
|
||||
return new ControlLink(" delete ");
|
||||
default:
|
||||
throw new UncheckedWrapperException("Column out of bounds");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
switch (column) {
|
||||
case 0:
|
||||
return new ExternalLink(shortcut.getUrlKey(), shortcut
|
||||
.getUrlKey());
|
||||
case 1:
|
||||
return new ExternalLink(shortcut.getRedirect(), shortcut
|
||||
.getRedirect());
|
||||
case 2:
|
||||
return new ControlLink(" edit ");
|
||||
case 3:
|
||||
return new ControlLink(" delete ");
|
||||
default:
|
||||
throw new UncheckedWrapperException("Column out of bounds");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue