Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
Good day
I would like to add another column in the Folders table (left pane) not the Folder Contents table (Right pane)
Currently the only column is "name" and i can only sort by name.
I need a description column that displays the description of the folder.
See attached picture
Solved! Go to Solution.
Hi @Markh74
You can rewrite OOTB java class to add the description. After restart you can see the Description in the Folder tree
I just added two rows to the code
var5 = this.getComponentConfigFactory().newColumnConfig("description", "Description", false);
var3.addComponent(var5);
class folder place
WindchillFolder\codebase\com\ptc\windchill\enterprise\folder\mvc\builders
Windchill 12.0.2.3
package com.ptc.windchill.enterprise.folder.mvc.builders;
import com.ptc.core.components.descriptor.ComponentDescriptor;
import com.ptc.jca.mvc.components.JcaColumnConfig;
import com.ptc.jca.mvc.components.JcaComponentParams;
import com.ptc.jca.mvc.components.JcaTreeConfig;
import com.ptc.mvc.components.AbstractComponentConfigBuilder;
import com.ptc.mvc.components.ColumnConfig;
import com.ptc.mvc.components.ComponentBuilder;
import com.ptc.mvc.components.ComponentConfig;
import com.ptc.mvc.components.ComponentParams;
import com.ptc.mvc.components.ComponentResultProcessor;
import com.ptc.mvc.components.ExpansionStateManager;
import com.ptc.mvc.components.FindInTableMode;
import com.ptc.mvc.components.TreeDataBuilderAsync;
import com.ptc.mvc.components.TreeNode;
import com.ptc.mvc.components.ds.DataSourceMode;
import com.ptc.mvc.util.ClientMessageSource;
import com.ptc.windchill.enterprise.folder.FolderBrowserUtilities;
import com.ptc.windchill.enterprise.folder.FolderPageContext;
import com.ptc.windchill.enterprise.folder.query.FolderQuery;
import org.apache.logging.log4j.Logger;
import wt.folder.Cabinet;
import wt.folder.Folder;
import wt.folder.SubFolder;
import wt.folder.SubFolderReference;
import wt.log4j.LogR;
import wt.util.WTException;
@ComponentBuilder({"folderbrowser_tree"})
@ExpansionStateManager(FolderTreeExpansionStateHandler.class)
public class FolderTreeBuilder extends AbstractComponentConfigBuilder implements TreeDataBuilderAsync {
protected static final Logger log = LogR.getLoggerInternal(FolderTreeBuilder.class.getName());
protected static final String TREE_EXPANSION_HANDLER = "treeExpansionHandler";
protected final ClientMessageSource folderMsgs = this.getMessageSource("com.ptc.windchill.enterprise.folder.folderResource");
protected final ClientMessageSource componentMsgs = this.getMessageSource("com.ptc.core.ui.componentRB");
static final String EXPANSION_LEVEL = "one";
static final String DISPLAY_LENGTH_IN_TABLES = "0";
static final String SHOW_ICON = "showIcon";
static final String COMPOSITE_PATH = "COMPOSITE_PATH";
public FolderTreeBuilder() {
}
public ComponentConfig buildComponentConfig(ComponentParams var1) throws WTException {
log.debug("buildComponentConfig(): invoked");
JcaComponentParams var2 = (JcaComponentParams)var1;
JcaTreeConfig var3 = (JcaTreeConfig)this.getComponentConfigFactory().newTreeConfig();
boolean var4 = FolderBrowserUtilities.isFolderTreeDisplayEnabled(var2.getHelperBean().getNmCommandBean());
if (!var4) {
var3.setView("/folder/notree.jsp");
return var3;
} else {
var3.setDataSourceMode(DataSourceMode.ASYNCHRONOUS);
var3.setConfigurable(false);
var3.setExpansionLevel("one");
var3.setLabel(this.folderMsgs.getMessage("FOLDERS_LEFTPANE_TABLE_TITLE"));
var3.setFindInTableMode(FindInTableMode.DISABLED);
ColumnConfig var5 = this.getComponentConfigFactory().newColumnConfig("folderName", this.componentMsgs.getMessage("NAME"), false);
JcaColumnConfig var6 = (JcaColumnConfig)var5;
var6.setInfoPageLink(true);
var6.setDisplayLengthInTables("0");
var6.setNeed("name");
var6.setDescriptorProperty("showIcon", Boolean.toString(true));
var6.setDescriptorProperty("COMPOSITE_PATH", FolderBrowserUtilities.compositePathBeanMap(var2));
var6.setSortable(true);
var6.setAscending(true);
var6.setDefaultSort(true);
var6.setWidth(200);
var3.addComponent(var5);
var5 = this.getComponentConfigFactory().newColumnConfig("description", "Description", false);
var3.addComponent(var5);
var3.setView("/folder/folderTreeView.jsp");
return var3;
}
}
public void buildNodeData(Object var1, ComponentResultProcessor var2) throws Exception {
log.debug("buildNodeData(): node = '" + var1 + "'");
Folder var3 = null;
String var4;
if (var1 == null) {
var4 = "Object is null!";
log.error("buildNodeData(): " + var4);
throw new WTException(var4);
} else if (var2 == null) {
var4 = "resultProcessor null!";
log.error("buildNodeData(): " + var4);
throw new WTException(var4);
} else if (!var2.isOpen()) {
var4 = "resultProcessor is not open!";
log.error("buildNodeData(): " + var4);
throw new WTException(var4);
} else {
var4 = var2.getConfig().getId();
String var7;
if (var4 == null) {
var7 = "Unable to obtain folder content table tableId!";
log.error("buildNodeData(): " + var7);
throw new WTException(var7);
} else if (!"folderbrowser_tree".equals(var4)) {
var7 = "Improper folder content table tableId: " + var4;
log.error("buildNodeData(): " + var7);
throw new WTException(var7);
} else if (var1 instanceof TreeNode && ((TreeNode)var1).name().equals("RootNode")) {
FolderPageContext var8 = new FolderPageContext((JcaComponentParams)var2.getParams());
Cabinet var6 = var8.getCabinet();
var2.addElement(var6);
} else {
if (!(var1 instanceof SubFolder) && !(var1 instanceof Cabinet)) {
if (!(var1 instanceof SubFolderReference)) {
var7 = "node is not 'RootNode' or a Folder! node = '" + var1 + "'";
log.error("buildNodeData(): " + var7);
throw new WTException(var7);
}
var3 = (Folder)((SubFolderReference)var1).getObject();
} else {
var3 = (Folder)var1;
}
FolderQuery var5 = FolderQuery.newFolderQuery(var3, var4, (ComponentDescriptor)null, var2);
var5.retrieveFolderContents();
}
}
}
}
Do not forget to backup original class file
PetrH
Hi @Markh74
You can rewrite OOTB java class to add the description. After restart you can see the Description in the Folder tree
I just added two rows to the code
var5 = this.getComponentConfigFactory().newColumnConfig("description", "Description", false);
var3.addComponent(var5);
class folder place
WindchillFolder\codebase\com\ptc\windchill\enterprise\folder\mvc\builders
Windchill 12.0.2.3
package com.ptc.windchill.enterprise.folder.mvc.builders;
import com.ptc.core.components.descriptor.ComponentDescriptor;
import com.ptc.jca.mvc.components.JcaColumnConfig;
import com.ptc.jca.mvc.components.JcaComponentParams;
import com.ptc.jca.mvc.components.JcaTreeConfig;
import com.ptc.mvc.components.AbstractComponentConfigBuilder;
import com.ptc.mvc.components.ColumnConfig;
import com.ptc.mvc.components.ComponentBuilder;
import com.ptc.mvc.components.ComponentConfig;
import com.ptc.mvc.components.ComponentParams;
import com.ptc.mvc.components.ComponentResultProcessor;
import com.ptc.mvc.components.ExpansionStateManager;
import com.ptc.mvc.components.FindInTableMode;
import com.ptc.mvc.components.TreeDataBuilderAsync;
import com.ptc.mvc.components.TreeNode;
import com.ptc.mvc.components.ds.DataSourceMode;
import com.ptc.mvc.util.ClientMessageSource;
import com.ptc.windchill.enterprise.folder.FolderBrowserUtilities;
import com.ptc.windchill.enterprise.folder.FolderPageContext;
import com.ptc.windchill.enterprise.folder.query.FolderQuery;
import org.apache.logging.log4j.Logger;
import wt.folder.Cabinet;
import wt.folder.Folder;
import wt.folder.SubFolder;
import wt.folder.SubFolderReference;
import wt.log4j.LogR;
import wt.util.WTException;
@ComponentBuilder({"folderbrowser_tree"})
@ExpansionStateManager(FolderTreeExpansionStateHandler.class)
public class FolderTreeBuilder extends AbstractComponentConfigBuilder implements TreeDataBuilderAsync {
protected static final Logger log = LogR.getLoggerInternal(FolderTreeBuilder.class.getName());
protected static final String TREE_EXPANSION_HANDLER = "treeExpansionHandler";
protected final ClientMessageSource folderMsgs = this.getMessageSource("com.ptc.windchill.enterprise.folder.folderResource");
protected final ClientMessageSource componentMsgs = this.getMessageSource("com.ptc.core.ui.componentRB");
static final String EXPANSION_LEVEL = "one";
static final String DISPLAY_LENGTH_IN_TABLES = "0";
static final String SHOW_ICON = "showIcon";
static final String COMPOSITE_PATH = "COMPOSITE_PATH";
public FolderTreeBuilder() {
}
public ComponentConfig buildComponentConfig(ComponentParams var1) throws WTException {
log.debug("buildComponentConfig(): invoked");
JcaComponentParams var2 = (JcaComponentParams)var1;
JcaTreeConfig var3 = (JcaTreeConfig)this.getComponentConfigFactory().newTreeConfig();
boolean var4 = FolderBrowserUtilities.isFolderTreeDisplayEnabled(var2.getHelperBean().getNmCommandBean());
if (!var4) {
var3.setView("/folder/notree.jsp");
return var3;
} else {
var3.setDataSourceMode(DataSourceMode.ASYNCHRONOUS);
var3.setConfigurable(false);
var3.setExpansionLevel("one");
var3.setLabel(this.folderMsgs.getMessage("FOLDERS_LEFTPANE_TABLE_TITLE"));
var3.setFindInTableMode(FindInTableMode.DISABLED);
ColumnConfig var5 = this.getComponentConfigFactory().newColumnConfig("folderName", this.componentMsgs.getMessage("NAME"), false);
JcaColumnConfig var6 = (JcaColumnConfig)var5;
var6.setInfoPageLink(true);
var6.setDisplayLengthInTables("0");
var6.setNeed("name");
var6.setDescriptorProperty("showIcon", Boolean.toString(true));
var6.setDescriptorProperty("COMPOSITE_PATH", FolderBrowserUtilities.compositePathBeanMap(var2));
var6.setSortable(true);
var6.setAscending(true);
var6.setDefaultSort(true);
var6.setWidth(200);
var3.addComponent(var5);
var5 = this.getComponentConfigFactory().newColumnConfig("description", "Description", false);
var3.addComponent(var5);
var3.setView("/folder/folderTreeView.jsp");
return var3;
}
}
public void buildNodeData(Object var1, ComponentResultProcessor var2) throws Exception {
log.debug("buildNodeData(): node = '" + var1 + "'");
Folder var3 = null;
String var4;
if (var1 == null) {
var4 = "Object is null!";
log.error("buildNodeData(): " + var4);
throw new WTException(var4);
} else if (var2 == null) {
var4 = "resultProcessor null!";
log.error("buildNodeData(): " + var4);
throw new WTException(var4);
} else if (!var2.isOpen()) {
var4 = "resultProcessor is not open!";
log.error("buildNodeData(): " + var4);
throw new WTException(var4);
} else {
var4 = var2.getConfig().getId();
String var7;
if (var4 == null) {
var7 = "Unable to obtain folder content table tableId!";
log.error("buildNodeData(): " + var7);
throw new WTException(var7);
} else if (!"folderbrowser_tree".equals(var4)) {
var7 = "Improper folder content table tableId: " + var4;
log.error("buildNodeData(): " + var7);
throw new WTException(var7);
} else if (var1 instanceof TreeNode && ((TreeNode)var1).name().equals("RootNode")) {
FolderPageContext var8 = new FolderPageContext((JcaComponentParams)var2.getParams());
Cabinet var6 = var8.getCabinet();
var2.addElement(var6);
} else {
if (!(var1 instanceof SubFolder) && !(var1 instanceof Cabinet)) {
if (!(var1 instanceof SubFolderReference)) {
var7 = "node is not 'RootNode' or a Folder! node = '" + var1 + "'";
log.error("buildNodeData(): " + var7);
throw new WTException(var7);
}
var3 = (Folder)((SubFolderReference)var1).getObject();
} else {
var3 = (Folder)var1;
}
FolderQuery var5 = FolderQuery.newFolderQuery(var3, var4, (ComponentDescriptor)null, var2);
var5.retrieveFolderContents();
}
}
}
}
Do not forget to backup original class file
PetrH