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:variable name="classname">
|
||||||
<xsl:value-of select="./@bebop:classname"/>
|
<xsl:value-of select="./@bebop:classname"/>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
|
<xsl:variable name="title">
|
||||||
|
<xsl:value-of select="./@title"/>
|
||||||
|
</xsl:variable>
|
||||||
|
|
||||||
<!--<pre>
|
<!--<pre>
|
||||||
<xsl:value-of select="concat('portlet-class = ', ./@bebop:classname)"/>
|
<xsl:value-of select="concat('portlet-class = ', ./@bebop:classname)"/>
|
||||||
|
|
@ -151,6 +154,11 @@
|
||||||
</pre>-->
|
</pre>-->
|
||||||
|
|
||||||
<xsl:choose>
|
<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: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: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()"/>
|
<xsl:with-param name="portlet-data-tree" tunnel="yes" select="current()"/>
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
* rights and limitations under the License.
|
* rights and limitations under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.arsdigita.shortcuts.ui;
|
package com.arsdigita.shortcuts.ui;
|
||||||
|
|
||||||
import org.apache.log4j.Category;
|
import org.apache.log4j.Category;
|
||||||
|
|
@ -24,22 +23,22 @@ import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||||
|
|
||||||
public class AdminPanel extends SimpleContainer {
|
public class AdminPanel extends SimpleContainer {
|
||||||
|
|
||||||
private ACSObjectSelectionModel m_shortcut = new ACSObjectSelectionModel(
|
private ACSObjectSelectionModel m_shortcut = new ACSObjectSelectionModel(
|
||||||
new BigDecimalParameter("shortcutID"));
|
new BigDecimalParameter("shortcutID"));
|
||||||
|
|
||||||
private static final Category log = Category.getInstance(AdminPanel.class
|
private static final Category log = Category.getInstance(AdminPanel.class
|
||||||
.getName());
|
.getName());
|
||||||
|
|
||||||
public AdminPanel() {
|
public AdminPanel() {
|
||||||
add(new ShortcutForm(m_shortcut));
|
add(new ShortcutForm(m_shortcut));
|
||||||
add(new ShortcutsTable(m_shortcut));
|
add(new ShortcutsTable(m_shortcut));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(Page p) {
|
public void register(Page p) {
|
||||||
super.register(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
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.arsdigita.shortcuts.ui;
|
package com.arsdigita.shortcuts.ui;
|
||||||
|
|
||||||
import com.arsdigita.bebop.Table;
|
import com.arsdigita.bebop.Table;
|
||||||
|
|
@ -43,112 +42,123 @@ import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
import com.arsdigita.bebop.ExternalLink;
|
import com.arsdigita.bebop.ExternalLink;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ShortcutsTable extends Table {
|
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) {
|
public static final String headers[] = {"URL Key", "Redirect", "", ""};
|
||||||
super(new ShortcutsModelBuilder(), headers);
|
|
||||||
|
|
||||||
setDefaultCellRenderer(new ShortcutsCellRenderer());
|
public ShortcutsTable(final ACSObjectSelectionModel selected_shortcut) {
|
||||||
|
super(new ShortcutsModelBuilder(), headers);
|
||||||
|
|
||||||
addTableActionListener(new TableActionListener() {
|
setDefaultCellRenderer(new ShortcutsCellRenderer());
|
||||||
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 void headSelected(TableActionEvent e) {
|
addTableActionListener(new TableActionListener() {
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static class ShortcutsModelBuilder extends LockableImpl implements
|
public void cellSelected(TableActionEvent e) {
|
||||||
TableModelBuilder {
|
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) {
|
public void headSelected(TableActionEvent e) {
|
||||||
return new ShortcutsModel();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected class ShortcutsModel implements TableModel {
|
});
|
||||||
private ShortcutCollection m_shortcuts;
|
}
|
||||||
|
|
||||||
private Shortcut m_shortcut;
|
protected static class ShortcutsModelBuilder extends LockableImpl implements
|
||||||
|
TableModelBuilder {
|
||||||
|
|
||||||
public ShortcutsModel() {
|
public TableModel makeModel(Table table, PageState ps) {
|
||||||
m_shortcuts = Shortcut.retrieveAll();
|
return new ShortcutsModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColumnCount() {
|
protected class ShortcutsModel implements TableModel {
|
||||||
return headers.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean nextRow() {
|
private ShortcutCollection m_shortcuts;
|
||||||
if (m_shortcuts.next()) {
|
|
||||||
m_shortcut = m_shortcuts.getShortcut();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getElementAt(int col) {
|
private Shortcut m_shortcut;
|
||||||
return m_shortcut;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getKeyAt(int col) {
|
public ShortcutsModel() {
|
||||||
BigDecimal id = m_shortcut.getID();
|
m_shortcuts = Shortcut.retrieveAll();
|
||||||
return id;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static class ShortcutsCellRenderer implements TableCellRenderer {
|
public int getColumnCount() {
|
||||||
public Component getComponent(Table table, PageState state,
|
return headers.length;
|
||||||
Object value, boolean isSelected, Object key, int row,
|
}
|
||||||
int column) {
|
|
||||||
Shortcut shortcut = (Shortcut) value;
|
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