1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
|
package cadtest20060320;
import com.cadviewer.*;
import sun.misc.BASE64Encoder;
import sun.misc.BASE64Decoder;
import javax.swing.*;
import javax.swing.filechooser.*;
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.Button;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.image.*;
import java.io.*;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.zip.*;
import java.util.StringTokenizer;
import java.util.Vector;
import java.beans.*;
import java.beans.PropertyChangeSupport;
import java.net.*;
import oracle.forms.properties.ID;
import oracle.forms.handler.IHandler;
import oracle.forms.ui.VBean;
import oracle.forms.ui.CustomEvent;
import oracle.forms.handler.IHandler;
import oracle.forms.properties.ID;
import oracle.ewt.meter.ProgressBar;
import oracle.ewt.meter.BoundedRangeModelImpl;
import oracle.ewt.thread.TaskScheduler;
import oracle.ewt.thread.Task;
import oracle.ewt.thread.TaskEvent;
import oracle.ewt.lwAWT.lwWindow.LWWindow;
import oracle.ewt.lwAWT.lwWindow.DesktopContainer;
public class CADViewerWrapper2 extends VBean
implements ComponentListener,
ContainerListener
{
//------------------------------------------------------------------------
// Public methods
//------------------------------------------------------------------------
/*
* Accessor method to get the bean's Container.
*/
public final Container getContainer()
{
return mContainer;
}
//------------------------------------------------------------------------
// ComponentListener interface
//------------------------------------------------------------------------
public void componentResized(ComponentEvent event)
{
System.out.println("componentResized");
}
public void componentMoved(ComponentEvent event)
{
System.out.println("componentMoved");
}
public void componentShown(ComponentEvent event)
{
System.out.println("componentShown");
}
public void componentHidden(ComponentEvent event)
{
System.out.println("componentHidden");
}
//------------------------------------------------------------------------
// ContainerListener interface
//------------------------------------------------------------------------
public void componentAdded(ContainerEvent event)
{
System.out.println("componentAdded");
event.getChild().addComponentListener(this);
}
public void componentRemoved(ContainerEvent event)
{
System.out.println("componentRemoved");
event.getChild().removeComponentListener(this);
}
//------------------------------------------------------------------------
// Protected methods
//------------------------------------------------------------------------
//------------------------------------------------------------------------
// Private methods
//------------------------------------------------------------------------
/*
* Call all update methods.
*/
private void updateAll()
{
System.out.println("updateAll");
}
/*
* Create an array of parents and register listeners
*/
private void updateParents()
{
System.out.println("updateParents");
}
/*
* Update the location of the bean. The location of the bean doesn't
* really change - its always 0,0 relative to its parent but we have to
* set it back to 0,0 so that it physically moves to the correct position.
*
* Component has some optimization code that we have to circumvent by
* moving the bean to 1,0 and then back to 0,0!
*
* Once the location has been updated, we recalculate the clipping
* rectangle.
*
* Hide the component during this whole operation, so that it doesn't look
* quite so ugly.
*/
private void updateLocation()
{
System.out.println("updateLocation");
}
/*
* The heavyweight Component isn't hidden automatically when a lightweight
* parent is invisible, we scan up the Component tree, looking for any
* parent that is not visibile. The bean is only visible if all of its
* parents are visible.
*/
private void updateVisibility()
{
System.out.println("updateVisibility");
}
/*
* clip the bean to its parents and other LWWindows.
*/
private void updateClipping()
{
System.out.println("updateClipping");
}
//------------------------------------------------------------------------
// Private members
//------------------------------------------------------------------------
private Container mParents[];
private Component mBean;
private Container mContainer;
public class CADViewer3 extends Panel {
private ViewerAWT viewerAWT = null;
public CADViewer3() {
try {
viewerAWT = new ViewerAWT("D:\\CV_AWT_SNCB2006_03_15\\");
URL url = new URL("file:///d:/acad_B/es/cat/STIP/Extract/410009.dwf");
byte[] arr = viewerAWT.getData(url);
viewerAWT.OpenFile(arr);
//this.setSize( 150, 100 );
System.out.println("this.add( viewerAWT.GetViewerPanel() )");
viewerAWT.SetTheFileName(url.toString());
this.add( viewerAWT.GetViewerPanel(),BorderLayout.CENTER );
this.setEnabled(true);
this.setVisible(true);
}
catch (Exception e) {
System.out.println("__EXCEPTION CadViewer3");
e.printStackTrace();
}
}
public Component GetViewerPanel() {
return viewerAWT.GetViewerPanel();
}
}
private IHandler mHandler = null;
private CADViewer3 viewerAWT3 = null;
public void init(IHandler handler) {
try {
System.out.println("__START CadWrapper public void init");
mHandler = handler;
super.init(handler);
System.out.println("__END CadWrapper public void init");
}
catch (Exception e) {
System.out.println("__EXCEPTION CadWrapper public void init");
e.printStackTrace();
}
}
public CADViewerWrapper2() {
super();
try {
System.out.println("_____START CADViewerWrapper() constructor_____");
viewerAWT3 = new CADViewer3();
this.add( viewerAWT3.GetViewerPanel(),BorderLayout.CENTER );
this.setEnabled(true);
this.setVisible(true);
mBean = this;
mContainer = getBean().getParent();
/*
getContainer().setLayout(null);
getContainer().removeAll();
getContainer().add(viewerAWT3.GetViewerPanel());
*/
getContainer().addComponentListener(this);
// getPanel().setVisible(false);
updateAll();
/*
viewerAWT = new ViewerAWT("D:\\CV_AWT_SNCB2006_03_15\\");
URL url = new URL("file:///d:/acad_B/es/cat/STIP/Extract/410009.dwf");
byte[] arr = viewerAWT.getData(url);
viewerAWT.OpenFile(arr);
this.setSize( 150, 100 );
System.out.println("this.add( viewerAWT.GetViewerPanel() )");
this.add( viewerAWT.GetViewerPanel() );
this.setEnabled(true);
this.setVisible(true);
*/
/*
f.add( viewerAWT.GetViewerPanel() ,BorderLayout.CENTER);
f.setSize(300,200);
f.show();
// Add a listener for the close event
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
Frame frame = (Frame)evt.getSource();
// Hide the frame
frame.setVisible(false);
// If the frame is no longer needed, call dispose
frame.dispose();
}
});
*/
System.out.println("_____END CADViewerWrapper() constructor_____");
}
catch (Exception e) {
e.printStackTrace();
}
}
//set the delay time for the timer
public boolean setProperty(ID pid, Object value) {
return super.setProperty(pid, value);
}
//if the value change, send a msg
public Object getProperty(ID pid) {
return null;
}
public void Msg( String s ) {
System.out.println(s);
}
public void InfoSystem() {
Msg("------------------------ InfoSystem ------------------------");
Msg("File separator:"+System.getProperty("file.separator"));
Msg("Java classpath:"+System.getProperty("java.class.path"));
Msg("Java class version number:"+System.getProperty("java.class.version"));
Msg("Java installation directory:"+System.getProperty("java.home"));
Msg("Java vendor-specific string:"+System.getProperty("java.vendor"));
Msg("Java vendor URL:"+System.getProperty("java.vendor.url"));
Msg("Java version number:"+System.getProperty("java.version"));
Msg("Line separator:"+System.getProperty("line.separator"));
Msg("Operating system architecture:"+System.getProperty("os.arch"));
Msg("Operating system name:"+System.getProperty("os.name"));
Msg("Operating system version:"+System.getProperty("os.version"));
Msg("Path separator:"+System.getProperty("path.separator"));
Msg("User's current working directory:"+System.getProperty("user.dir"));
Msg("User home directory:"+System.getProperty("user.home"));
Msg("User account name:"+System.getProperty("user.name"));
Msg("------------------------------------------------------------");
}
} |
Partager