Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 19 package org.openharmonise.him.editors; 20 21 import java.net.URI ; 22 23 import org.openharmonise.him.*; 24 import org.openharmonise.vfs.context.*; 25 import org.openharmonise.vfs.servers.*; 26 27 import com.sq.xmetal.api.*; 28 import com.sq.types.*; 29 30 38 public class XMetaLController implements ContextListener { 39 40 43 private static XMetaLController m_instance = null; 44 45 48 private Application m_xmApplication = null; 49 50 53 private boolean isXMetaLRunning = false; 54 55 public XMetaLController() { 56 ContextHandler.getInstance().addListener(ContextType.CONTEXT_SHUTDOWN, this); 57 } 58 59 65 public static XMetaLController getInstance() throws Exception { 66 if (m_instance == null) { 67 m_instance = new XMetaLController(); 68 } 69 70 return m_instance; 71 } 72 73 78 public synchronized void openFile( String sPath ) { 79 try { 80 this.startXMetaL(); 81 this.m_xmApplication.getDocuments().Open(sPath); 82 this.m_xmApplication.getActiveDocument().setStructureViewVisible(false); 83 } catch (Exception e) { 84 e.printStackTrace( System.out ); 85 } 86 } 87 88 93 public synchronized void openContents( String sContents ) { 94 try { 95 this.startXMetaL(); 96 this.m_xmApplication.getDocuments().OpenString(sContents); 97 98 } catch (Exception e) { 99 e.printStackTrace( System.out ); 100 } 101 } 102 103 107 private synchronized void startXMetaL() { 108 if( !isXMetaLRunning ) { 109 try { 110 m_xmApplication = new Application(); 111 m_xmApplication.PreventExit("ExplorerApp", 112 "XMetaL will shutdown when you have closed Harmonise Information Manager."); 113 114 115 SQDispatch dispatch = m_xmApplication.getResourceManager().getAssets().getWebBrowser(); 116 117 m_xmApplication.getResourceManager().setVisible(true); 118 m_xmApplication.getResourceManager().SelectTab("Assets"); 119 120 SQWebBrowser browser = new SQWebBrowser(dispatch); 121 Server server = ServerList.getInstance().getHarmoniseServer(); 122 URI uri = server.getURI(); 123 String sURL = "http://" + uri.getHost() + ":" + uri.getPort() + "/webdav/servlet/HarmoniseServlet?Page/@id=3000"; 124 System.out.println("Asset URL=[" + sURL + "]"); 125 SQVariant url = new SQVariant(sURL); 126 browser.Navigate2(url); 127 128 m_xmApplication.getResourceManager().setVisible(true); 129 m_xmApplication.getResourceManager().SelectTab("Assets"); 130 131 m_xmApplication.DisablePlainTextView(); 132 } catch (Exception e2) { 133 e2.printStackTrace(System.err); 134 } 135 136 isXMetaLRunning=true; 137 } 138 } 139 140 144 public void shutdown() { 145 if (isXMetaLRunning) { 146 m_xmApplication.AllowExit("ExplorerApp"); 147 m_xmApplication.getDocuments().Close(); 148 149 try { 150 m_xmApplication.Quit(); 151 } catch (Exception e) { 152 e.printStackTrace(System.out); 153 } finally { 154 m_xmApplication=null; 155 } 156 157 System.gc(); 158 SQRuntime.releaseAll(); 159 160 isXMetaLRunning = false; 161 } 162 } 163 164 167 public void contextMessage(ContextEvent ce) { 168 this.shutdown(); 169 } 170 } 171
| Popular Tags
|