在 Adob​​e Flex 中编辑 XML 文档?

发布于 2024-08-12 07:55:54 字数 429 浏览 4 评论 0原文

我正在 Flex 中为 XML 文档构建自定义结构化编辑器。我需要的是一种在 XMLList 上以最少的麻烦进行列表操作的方法,使用可编辑的数据网格或弹出表单(UI 方面,哪个并不重要。请不要关注这一点)。这样做的好习惯是什么?

这是一个示例结构,其中包含我可能想要执行的操作:

<itemList>
    <item id="1"/>
    <item id="2"/>
</itemList>

我可能想要:

  • 在列表末尾添加一个新项目。
  • 删除现有项目
  • 以能够取消编辑的方式编辑项目(大概,这意味着制作该项目的副本,对其进行编辑,然后用编辑后的副本替换其源?)
  • 重新排序项目

如何我应该这样做吗?

I am building a custom structured editor for an XML document in Flex. What I need is a way to do list operations on an XMLList with a minimum of fuss, using either an editable datagrid or a popup form (UI-wise, it doesn't matter which. Please don't focus on that). What is a good idiom for doing this?

Here is an example structure, with operations that I may want to do:

<itemList>
    <item id="1"/>
    <item id="2"/>
</itemList>

I might want to:

  • add a new item at the end of the list.
  • remove an existing item
  • edit an item in such a way as to be able to cancel the edit (presumably, this means making a copy of the item, editing it, and replacing its source with the edited copy?)
  • re-order the items

How should I go about doing this?

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

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

发布评论

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

评论(3

如日中天 2024-08-19 07:55:54

我们刚刚在我工作的地方构建了一个相当复杂的 XML 编辑器,我的第一个建议是,如果您可以避免它,请不要按照 Flex 的方式进行操作,除非您直接使用 XMLListCollection。 Flex 的 XMLListCollection 是 XMLListAdapter 的容器,虽然它确实有效,但如果您使用 XMLList 的父节点并使用本机 XML 函数,效果会更好。如果你试图重复他们的努力,那将是漫长而噩梦般的。

那是说:
XMLListCollection 是您的朋友,但如果您有大量数据绑定,请确保您有多个层。我们最初总是从 XML 文档的根部使用 ex4 搜索,这花费了我们大量的时间和精力。我们意识到我们可以将其分成三个子列表,并且每次编辑的速度都要快得多。

至于实际的 UI,有多种方法可以做到这一点,这取决于 XML 的整体结构。

如果您有多个 itemList,您可能希望使用树组件以及此处示例的一些代码: http://livedocs.adobe.com/flex/3/html/help.html?content=about_dataproviders_6.html

另一方面,如果只有一个itemList,那么我就会有一个简单的列表。这将允许您拖动项目并重新排序。如果您使用 labelFunction,则可以让它返回项目的 @id。您可以添加一个文本字段和一个用于添加节点的提交按钮。也许还有一个用于删除的附加按钮,但这并不难。

取消编辑将特别容易——只需等待点击“提交”,然后再将更改实际提交到 XML 即可。

We just built a rather complicated XML editor where I work, and my first suggestion is, if you can possibly avoid it, DO NOT DO THINGS THE WAY THAT FLEX DOES THEM UNLESS YOU ARE USING AN XMLListCollection DIRECTLY. Flex's XMLListCollection is a container for XMLListAdapter, and while it does work, it is much better if you use the parent node of an XMLList and use the native XML functions. If you try to duplicate their efforts it is long and nightmarish.

That said:
XMLListCollection is your friend, but make sure that you have multiple layers if you have a lot of data binding. We originally always used ex4 searches from the root of our XML document, and that cost us a LOT of time and energy. We realized that we could break it up into three sub-lists, and each edit was a good deal faster.

As to the actual UI, well, there are a number of ways to do this and it depends on how your XML is structured overall.

If you have multiple itemLists, you could wish to use the tree component along with some of the code exemplified here: http://livedocs.adobe.com/flex/3/html/help.html?content=about_dataproviders_6.html

On the other hand, if there is only one itemList, then I would have a simple List. That will allow you to drag items and re-order them. If you used a labelFunction, you could have it return the item's @id. You'd be able to add a TextField and a submit button for adding nodes. Perhaps an additional button for deleting, but it would not be that hard.

Cancelling an edit would be particularly easy -- simply wait until "Submit" has been hit before actually committing the change to the XML.

青春有你 2024-08-19 07:55:54

我个人会将 XML 结构抽象为对象图,并在事后将对象序列化为 XML。这样,您就不会在编辑期间处理 XML(在实时序列化显示或其他内容之外),并且您可以通过处理对象而不是解析/操作 XML 节点来获得易用性。

I'd personally abstract the XML structure to an object-graph and serialize the objects to XML after the fact. Then you aren't dealing with the XML during editing (outside of a real-time serialized display or whatever) and you get the ease of use that comes from dealing with Objects instead of parsing/manipulating XML nodes.

成熟的代价 2024-08-19 07:55:54

是的,因为 flex builder 是一个基于 eclipse 的 IDE,使用 Web 工具平台。我还没有在straight flex builder上安装它,但是你可以下载Eclipse J2EE版本,它包含WTP。然后只需安装 Flex Builder 作为插件即可。我认为您应该能够找到 Ganymede 版本的 J2EE IDE。但是,如果您不能,请研究一下在 Galileo 中获取 Flex 的解决方法,然后您就可以开始了!

yeah, since flex builder is an eclipse based IDE use Web Tools Platform. I haven't installed it on straight flex builder, but you can download the Eclipse J2EE version and it includes WTP. Then just install flex builder as a plug-in. I think you should be able to find a Ganymede version of the J2EE IDE. However, if you cant, look into the workaround for getting Flex in Galileo and you're good to go!

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