如何在 Pharo 9 中制作带有子组的包

发布于 2025-01-15 16:24:49 字数 528 浏览 1 评论 0原文

在 Pharo 9 中,如何创建一个具有子包层次结构的包,就像“Announcements-Core”中那样,其中有一个展开和折叠箭头?

Pharo 9包公告-核心显示层次结构

我认为它可能基于包的名称,但是当我尝试使用以下消息创建两个类时,它们只是显示为单独的包。我想要的是有一个包“T-base”,它有子包“type1”和“type2”?

Object subclass: #T1 instanceVariableNames: '' classVariableNames: '' package: 'T-base-type1'
Object subclass: #T2 instanceVariableNames: '' classVariableNames: '' package: 'T-base-type2'

In Pharo 9, how do I create a package that has a hierarchy of sub-packages like in "Announcements-Core" where there is an expanding and collapsing arrow?

Pharo 9 package Announcements-Core showing hierarchy

I thought that it might be based on the names of the packages but when I tried with the following messages to create two classes they just show up as separate packages. What I want is for there to be a package "T-base" that has sub packages "type1" and "type2"?

Object subclass: #T1 instanceVariableNames: '' classVariableNames: '' package: 'T-base-type1'
Object subclass: #T2 instanceVariableNames: '' classVariableNames: '' package: 'T-base-type2'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

久伴你 2025-01-22 16:24:49

要创建新包和其中的(所谓的)标签,请使用右键单击菜单项New packageNew tag。包是 RPackage 的实例和 ClyTaggedClassGroup 的标签。

输入图片此处描述

To create a new package and a (so called) tag inside it use the right-click menu items New package and New tag. Packages are instances of RPackage and tags of ClyTaggedClassGroup.

enter image description here

情绪失控 2025-01-22 16:24:49

要添加到 Leandro 的答案,要在 Smalltalk 代码中执行此操作,您可以执行以下操作:

t1 := Object subclass: #T1 
             instanceVariableNames: '' 
             classVariableNames: '' 
             package: 'T-base-type1'.

t2 := Object subclass: #T2 
             instanceVariableNames: '' 
             classVariableNames: '' 
             package: 'T-base-type2'.

t1 class package addClassDefinition: t1 toClassTag: #type1.
t2 class package addClassDefinition: t2 toClassTag: #type2.

t1 class package 为您提供 RPackage 实例,然后您可以将该类添加到标记中。我还发现你需要让包名称的最后部分(例如type1)与标签名称相同,否则会出现该类“未分类”的错误。

还有另一种方法:您可以创建没有包名称最后部分的类,然后将 category: 消息发送到该类以将其添加到

t1 := Object subclass: #T1 
             instanceVariableNames: '' 
             classVariableNames: '' 
             package: 'T-base'.

t1 category: 'T-base-type1'.

To add to Leandro's answer, to do this in smalltalk code you can do this:

t1 := Object subclass: #T1 
             instanceVariableNames: '' 
             classVariableNames: '' 
             package: 'T-base-type1'.

t2 := Object subclass: #T2 
             instanceVariableNames: '' 
             classVariableNames: '' 
             package: 'T-base-type2'.

t1 class package addClassDefinition: t1 toClassTag: #type1.
t2 class package addClassDefinition: t2 toClassTag: #type2.

t1 class package gives you the RPackage instance and you can then add the class to a tag. I also found that you need to have the final part of the package name (eg. type1) be the same as the tag name, otherwise there is an error that the class is "uncategorized".

There is another way as well: You can create the class without the final part of the package name and then send the category: message to the class to add it on

t1 := Object subclass: #T1 
             instanceVariableNames: '' 
             classVariableNames: '' 
             package: 'T-base'.

t1 category: 'T-base-type1'.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文