• R/O
  • SSH
  • HTTPS

maskat: Commit


Commit MetaInfo

Révision117 (tree)
l'heure2009-03-03 12:34:08
Auteurkazatoh

Message de Log

マスカットIDE 2.0.0 のソースフォルダに合わせてリソースを移動

Change Summary

Modification

--- maskat-ide/trunk/org.maskat.ui/src/org/maskat/ui/editors/layout/MaskatResources.java (nonexistent)
+++ maskat-ide/trunk/org.maskat.ui/src/org/maskat/ui/editors/layout/MaskatResources.java (revision 117)
@@ -0,0 +1,107 @@
1+/*
2+ * Copyright 2006 Maskat Project.
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, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+package org.maskat.ui.editors.layout;
17+
18+import java.io.IOException;
19+import java.io.InputStream;
20+import java.io.Writer;
21+import java.util.Collections;
22+import java.util.Iterator;
23+
24+import javax.xml.stream.XMLStreamException;
25+
26+import org.eclipse.core.resources.IFile;
27+import org.maskat.core.event.IEventDefSource;
28+import org.maskat.core.layout.Layout;
29+import org.maskat.core.layout.LayoutDef;
30+import org.maskat.core.layout.xml.LayoutDefParser;
31+import org.maskat.core.layout.xml.LayoutDefXmlSerializer;
32+import org.maskat.ui.editors.linkeventsrc.LinkEventDefSource;
33+import org.maskat.xml.DefXmlSerializer;
34+
35+/**
36+ * The state of layout and event definition. MaskatDef and IEventDefSource's
37+ * state.
38+ *
39+ * @author shengshen
40+ *
41+ */
42+public class MaskatResources {
43+
44+ MaskatResources(IFile layoutXmlFile) {
45+ this.layoutXmlFile = layoutXmlFile;
46+ }
47+
48+ protected LayoutDef maskatDef = null;
49+
50+ /** The index of the layoutDef currently showed */
51+ protected int layoutIdx = 0;
52+
53+ IEventDefSource eventDefSource;
54+
55+ /** ���C�A�E�g��`XML */
56+ private IFile layoutXmlFile;
57+
58+ Layout getCurrentLayoutDef() {
59+ return (Layout) maskatDef.getChildByTypeIdx(Layout.class, this.layoutIdx);
60+ }
61+
62+ void switchLayout(int theIdx) {
63+ layoutIdx = theIdx;
64+ connectLayoutEvent();
65+ }
66+
67+ void connectLayoutEvent() {
68+ Layout layoutDef = getCurrentLayoutDef();
69+ layoutDef.setLayoutEvtDefSrc(eventDefSource);
70+ }
71+
72+ void loadLayout() throws Exception {
73+ InputStream inputS = null;
74+ try {
75+ if (layoutXmlFile.exists()) {
76+ inputS = layoutXmlFile.getContents();// contents����f�[�^��ǂݍ���
77+ maskatDef = LayoutDefParser.parse(inputS);
78+ }
79+ } finally {
80+ try {
81+ if (inputS != null)
82+ inputS.close();
83+ } catch (IOException e) {
84+ }
85+ }
86+ }
87+
88+ void loadEvent() throws Exception {
89+ eventDefSource = new LinkEventDefSource(this.layoutXmlFile);
90+ eventDefSource.load();
91+ }
92+
93+ public Iterator getLayouts() {
94+ if (maskatDef == null)
95+ return Collections.EMPTY_LIST.iterator();
96+ return maskatDef.getTypedChildren(Layout.class);
97+ }
98+
99+ void writeLayout(Writer writer) throws XMLStreamException {
100+ DefXmlSerializer serializer = new LayoutDefXmlSerializer(maskatDef, writer);
101+ serializer.write();
102+ }
103+
104+ String[] writeEvent() throws Exception {
105+ return this.eventDefSource.save();
106+ }
107+}
Afficher sur ancien navigateur de dépôt.