1 /*
2 * Copyright 2004-2008 the Seasar Foundation and the Others.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 * either express or implied. See the License for the specific language
14 * governing permissions and limitations under the License.
15 */
16 package org.seasar.uruma.rcp.configuration.extension;
17
18 import org.seasar.uruma.core.UrumaConstants;
19 import org.seasar.uruma.rcp.UrumaService;
20 import org.seasar.uruma.rcp.configuration.ExtensionBuilder;
21 import org.seasar.uruma.rcp.util.RcpResourceUtil;
22 import org.seasar.uruma.rcp.util.UrumaServiceUtil;
23
24 /**
25 * {@link ExtensionBuilder} のための基底クラスです。<br />
26 *
27 * @author y-komori
28 */
29 public abstract class AbstractExtensionBuilder implements ExtensionBuilder,
30 UrumaConstants {
31 protected UrumaService service;
32
33 /**
34 * {@link AbstractExtensionBuilder} を構築します。<br />
35 */
36 public AbstractExtensionBuilder() {
37 this.service = UrumaServiceUtil.getService();
38 }
39
40 /**
41 * イメージパスを取得します。<br />
42 * 画面定義 XML に記述されたイメージパスを、RCP 環境で利用できるパスに変換します。<br />
43 * 実際には、以下の変換を行います。<br />
44 * <ol>
45 * <li><code>urumaImages.properties</code> に記述されたキーである場合、実際のパスに変換します。<br />
46 * <li>パスを Uruma アプリケーションバンドル中の相対パスに変換します。<br />
47 * </ol>
48 *
49 * @param path
50 * イメージパス
51 * @return 変換されたパス
52 */
53 protected String getRcpImagePath(final String path) {
54 if (path == null) {
55 return null;
56 }
57
58 String imagePath = service.getImageBundle().getString(path);
59 if (imagePath != null) {
60 return RcpResourceUtil.getBundleRelativePath(service.getBundle(),
61 imagePath);
62 } else {
63 return path;
64 }
65 }
66 }