[MAGNOLIA-538] Make it easier to extend AdminTreeMVCHandler.java and Tree.java Created: 01/Sep/05  Updated: 17/Mar/09  Resolved: 02/Sep/05

Status: Closed
Project: Magnolia
Component/s: core
Affects Version/s: 2.1 Final
Fix Version/s: 2.1 Final

Type: Improvement Priority: Major
Reporter: Michael Aemisegger Assignee: Philipp Bärfuss
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

all


Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:

 Description   

the private member tree should be accessed only through its getter. If not, it's impossible to extend AdminTreeMVCHandler.java and use a specialization of Tree.java.

patch for revision 1437 of tagged version /magnolia2.1 :

diff -uBbPr /home/maem/workspace/Pagnolia2.1/src/originals/magnolia-2.1/src/main/info/magnolia/module/admininterface/AdminTreeMVCHandler.java /home/maem/workspace/Pagnolia2.1/src/patched/magnolia-2.1/src/main/info/magnolia/module/admininterface/AdminTreeMVCHandler.java
— /home/maem/workspace/Pagnolia2.1/src/originals/magnolia-2.1/src/main/info/magnolia/module/admininterface/AdminTreeMVCHandler.java 2005-08-31 11:29:28.000000000 +0200
+++ /home/maem/workspace/Pagnolia2.1/src/patched/magnolia-2.1/src/main/info/magnolia/module/admininterface/AdminTreeMVCHandler.java 2005-08-31 17:42:14.000000000 +0200
@@ -107,6 +107,7 @@

tree = new Tree(name, getRepository(), request);
path = request.getParameter("path"); //$NON-NLS-1$
+ tree.setName( name );
if (StringUtils.isEmpty(path))

{ path = "/"; //$NON-NLS-1$ }

@@ -180,8 +181,8 @@
createItemType = request.getParameter("createItemType"); //$NON-NLS-1$
}

  • tree.setPath(path);
  • tree.createNode(createItemType);
    + getTree().setPath(path);
    + getTree().createNode(createItemType);
    return VIEW_TREE;
    }

@@ -207,7 +208,7 @@
String pathClipboard = request.getParameter("pathClipboard"); //$NON-NLS-1$
int pasteType = Integer.parseInt(request.getParameter("pasteType")); //$NON-NLS-1$

  • newPath = tree.pasteNode(pathClipboard, pathSelected, pasteType, action);
    + newPath = getTree().pasteNode(pathClipboard, pathSelected, pasteType, action);
    if (pasteType == Tree.PASTETYPE_SUB) { pathOpen = pathSelected; }

    @@ -222,18 +223,18 @@

public String delete()

{ String deleteNode = request.getParameter("deleteNode"); //$NON-NLS-1$ - tree.deleteNode(path, deleteNode); + getTree().deleteNode(path, deleteNode); return VIEW_TREE; }

public String activate()

{ boolean recursive = (request.getParameter("recursive") != null); //$NON-NLS-1$ - tree.activateNode(pathSelected, recursive); + getTree().activateNode(pathSelected, recursive); return VIEW_TREE; }

public String deactivate()

{ - tree.deActivateNode(pathSelected); + getTree().deActivateNode(pathSelected); return VIEW_TREE; }

@@ -258,12 +259,12 @@
boolean isLabel = "true".equals(request.getParameter("isLabel")); //$NON-NLS-1$ //$NON-NLS-2$

if (isNodeDataValue || isNodeDataType)

{ - tree.setPath(StringUtils.substringBeforeLast(path, "/")); //$NON-NLS-1$ + getTree().setPath(StringUtils.substringBeforeLast(path, "/")); //$NON-NLS-1$ saveName = StringUtils.substringAfterLast(path, "/"); //$NON-NLS-1$ }

else

{ // "/modules/templating/Templates/x" - tree.setPath(path); + getTree().setPath(path); }

if (isLabel)

{ @@ -271,10 +272,10 @@ }

else if (isNodeDataType)

{ int type = Integer.valueOf(value).intValue(); - displayValue = tree.saveNodeDataType(saveName, type); + displayValue = getTree().saveNodeDataType(saveName, type); }

else

{ - displayValue = tree.saveNodeData(saveName, value, isMeta); + displayValue = getTree().saveNodeData(saveName, value, isMeta); }

// if there was a displayValue passed show it instead of the written value
@@ -297,7 +298,7 @@

  • @return return the new name (can change if there were not allowed characters passed)
    */
    protected String rename(String value) { - return tree.renameNode(value); + return getTree().renameNode(value); }

/**
@@ -312,8 +313,8 @@
if (VIEW_TREE.equals(view) || VIEW_CREATE.equals(view) || VIEW_COPY_MOVE.equals(view)) {
// if there was a node created we have not to set the pathes
if (view != VIEW_CREATE)

{ - tree.setPathOpen(pathOpen); - tree.setPathSelected(pathSelected); + getTree().setPathOpen(pathOpen); + getTree().setPathSelected(pathSelected); }

// after moving or copying
@@ -355,8 +356,8 @@
String mode = StringUtils.defaultString(request.getParameter("treeMode")); //$NON-NLS-1$
boolean snippetMode = mode.equals("snippet"); //$NON-NLS-1$

  • tree.setJavascriptTree("mgnlTreeControl"); //$NON-NLS-1$
  • tree.setBrowseMode(this.isBrowseMode());
    + getTree().setJavascriptTree("mgnlTreeControl"); //$NON-NLS-1$
    + getTree().setBrowseMode(this.isBrowseMode());

if (!snippetMode)

{ html.append("<html><head>"); //$NON-NLS-1$ @@ -364,22 +365,22 @@ renderHeaderIncludes(html); html.append("<title>Magnolia</title>"); //$NON-NLS-1$ html.append("</head>"); //$NON-NLS-1$ - html.append("<body class=\"mgnlBgDark\" onload=\"" + tree.getJavascriptTree() + ".resizeOnload();\" >"); //$NON-NLS-1$ //$NON-NLS-2$ + html.append("<body class=\"mgnlBgDark\" onload=\"" + getTree().getJavascriptTree() + ".resizeOnload();\" >"); //$NON-NLS-1$ //$NON-NLS-2$ html.append(Spacer.getHtml(20, 20)); }
  • tree.setSnippetMode(snippetMode);
  • tree.setHeight(50);
    + getTree().setSnippetMode(snippetMode);
    + getTree().setHeight(50);
  • tree.setPath(path);
    + getTree().setPath(path);
  • prepareTree(tree, request);
  • prepareContextMenu(tree, request);
    + prepareTree(getTree(), request);
    + prepareContextMenu(getTree(), request);

if (!snippetMode)

{ - html.append("<div id=\"" + tree.getJavascriptTree() + "_DivSuper\" style=\"display:block;\">"); //$NON-NLS-1$ //$NON-NLS-2$ + html.append("<div id=\"" + getTree().getJavascriptTree() + "_DivSuper\" style=\"display:block;\">"); //$NON-NLS-1$ //$NON-NLS-2$ }
  • html.append(tree.getHtml());
    + html.append(getTree().getHtml());
    if (!snippetMode) { html.append("</div>"); //$NON-NLS-1$ }


 Comments   
Comment by Philipp Bracher [ 02/Sep/05 ]

I used eclipse encapsulate field to change the code.

will commit to 2.1 branch and merge with 2.2 turnk later

Generated at Mon Feb 12 03:18:25 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.