rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
Class expCls; try { | public RemoteStub exportObject(Remote obj) throws RemoteException { if (myself == null) { myself = obj; // Save it to server manager, to let client calls in the same VM to issue // local call manager.serverobj = obj; // Find and install the stub Class cls = obj.getClass(); Class expCls; try { // where ist the _Stub? (check superclasses also) expCls = findStubSkelClass(cls); } catch (Exception ex) { throw new RemoteException("can not find stubs for class: " + cls, ex); } stub = (RemoteStub)getHelperClass(expCls, "_Stub"); if (stub == null) { throw new RemoteException("failed to export: " + cls); } // Find and install the skeleton (if there is one) skel = (Skeleton)getHelperClass(expCls, "_Skel"); // Build hash of methods which may be called. buildMethodHash(obj.getClass(), true); // Export it. UnicastServer.exportObject(this); } return (stub);} |
|
expCls = findStubSkelClass(cls); } catch (Exception ex) { throw new RemoteException("can not find stubs for class: " + cls, ex); | Class expCls = expCls = findStubSkelClass(cls); if (expCls != null) { stub = (RemoteStub) getHelperClass(expCls, "_Stub"); skel = (Skeleton) getHelperClass(expCls, "_Skel"); } | public RemoteStub exportObject(Remote obj) throws RemoteException { if (myself == null) { myself = obj; // Save it to server manager, to let client calls in the same VM to issue // local call manager.serverobj = obj; // Find and install the stub Class cls = obj.getClass(); Class expCls; try { // where ist the _Stub? (check superclasses also) expCls = findStubSkelClass(cls); } catch (Exception ex) { throw new RemoteException("can not find stubs for class: " + cls, ex); } stub = (RemoteStub)getHelperClass(expCls, "_Stub"); if (stub == null) { throw new RemoteException("failed to export: " + cls); } // Find and install the skeleton (if there is one) skel = (Skeleton)getHelperClass(expCls, "_Skel"); // Build hash of methods which may be called. buildMethodHash(obj.getClass(), true); // Export it. UnicastServer.exportObject(this); } return (stub);} |
stub = (RemoteStub)getHelperClass(expCls, "_Stub"); if (stub == null) { throw new RemoteException("failed to export: " + cls); } skel = (Skeleton)getHelperClass(expCls, "_Skel"); | if (stub == null) stub = createProxyStub(obj.getClass(), this); | public RemoteStub exportObject(Remote obj) throws RemoteException { if (myself == null) { myself = obj; // Save it to server manager, to let client calls in the same VM to issue // local call manager.serverobj = obj; // Find and install the stub Class cls = obj.getClass(); Class expCls; try { // where ist the _Stub? (check superclasses also) expCls = findStubSkelClass(cls); } catch (Exception ex) { throw new RemoteException("can not find stubs for class: " + cls, ex); } stub = (RemoteStub)getHelperClass(expCls, "_Stub"); if (stub == null) { throw new RemoteException("failed to export: " + cls); } // Find and install the skeleton (if there is one) skel = (Skeleton)getHelperClass(expCls, "_Skel"); // Build hash of methods which may be called. buildMethodHash(obj.getClass(), true); // Export it. UnicastServer.exportObject(this); } return (stub);} |
return (stub); } | return stub; } | public RemoteStub exportObject(Remote obj) throws RemoteException { if (myself == null) { myself = obj; // Save it to server manager, to let client calls in the same VM to issue // local call manager.serverobj = obj; // Find and install the stub Class cls = obj.getClass(); Class expCls; try { // where ist the _Stub? (check superclasses also) expCls = findStubSkelClass(cls); } catch (Exception ex) { throw new RemoteException("can not find stubs for class: " + cls, ex); } stub = (RemoteStub)getHelperClass(expCls, "_Stub"); if (stub == null) { throw new RemoteException("failed to export: " + cls); } // Find and install the skeleton (if there is one) skel = (Skeleton)getHelperClass(expCls, "_Skel"); // Build hash of methods which may be called. buildMethodHash(obj.getClass(), true); // Export it. UnicastServer.exportObject(this); } return (stub);} |
private Class findStubSkelClass(Class startCls) throws Exception { | private Class findStubSkelClass(Class startCls) { | private Class findStubSkelClass(Class startCls) throws Exception { Class cls = startCls; while (true) { try { String stubClassname = cls.getName() + "_Stub"; ClassLoader cl = cls.getClassLoader(); Class scls = cl == null ? Class.forName(stubClassname) : cl.loadClass(stubClassname); return cls; // found it } catch (ClassNotFoundException e) { Class superCls = cls.getSuperclass(); if (superCls == null || superCls == java.rmi.server.UnicastRemoteObject.class) { throw new Exception("Neither " + startCls + " nor one of their superclasses (like" + cls + ")" + " has a _Stub"); } cls = superCls; } }} |
throw new Exception("Neither " + startCls + " nor one of their superclasses (like" + cls + ")" + " has a _Stub"); | return null; | private Class findStubSkelClass(Class startCls) throws Exception { Class cls = startCls; while (true) { try { String stubClassname = cls.getName() + "_Stub"; ClassLoader cl = cls.getClassLoader(); Class scls = cl == null ? Class.forName(stubClassname) : cl.loadClass(stubClassname); return cls; // found it } catch (ClassNotFoundException e) { Class superCls = cls.getSuperclass(); if (superCls == null || superCls == java.rmi.server.UnicastRemoteObject.class) { throw new Exception("Neither " + startCls + " nor one of their superclasses (like" + cls + ")" + " has a _Stub"); } cls = superCls; } }} |
public RemoteStub getStub(){ | public Remote getStub() { | public RemoteStub getStub(){ return stub;} |
* For debugging purposes - we don't handle CodeBases * quite right so we don't always find the stubs. This * lets us know that. | * For debugging purposes - we don't handle CodeBases quite right so * we don't always find the stubs. This lets us know that. | public Object incomingMessageCall(UnicastConnection conn, int method, long hash) throws Exception {//System.out.println("method = " + method + ", hash = " + hash); // If method is -1 then this is JDK 1.2 RMI - so use the hash // to locate the method if (method == -1) { Method meth = (Method)methods.get(new Long (hash));//System.out.println("class = " + myself.getClass() + ", meth = " + meth); if (meth == null) { throw new NoSuchMethodException(); } ObjectInputStream in = conn.getObjectInputStream(); int nrargs = meth.getParameterTypes().length; Object[] args = new Object[nrargs]; for (int i = 0; i < nrargs; i++) { /** * For debugging purposes - we don't handle CodeBases * quite right so we don't always find the stubs. This * lets us know that. */ try { // need to handle primitive types args[i] = ((RMIObjectInputStream)in).readValue(meth.getParameterTypes()[i]); } catch (Exception t) { t.printStackTrace(); throw t; } } //We must reinterpret the exception thrown by meth.invoke() //return (meth.invoke(myself, args)); Object ret = null; try{ ret = meth.invoke(myself, args); }catch(InvocationTargetException e){ Throwable cause = e.getTargetException(); if (cause instanceof Exception) { throw (Exception)cause; } else if (cause instanceof Error) { throw (Error)cause; } else { throw new Error("The remote method threw a java.lang.Throwable that is neither java.lang.Exception nor java.lang.Error.", e); } } return ret; } // Otherwise this is JDK 1.1 style RMI - we find the skeleton // and invoke it using the method number. We wrap up our // connection system in a UnicastRemoteCall so it appears in a // way the Skeleton can handle. else { if (skel == null) { throw new NoSuchMethodException(); } UnicastRemoteCall call = new UnicastRemoteCall(conn); skel.dispatch(myself, call, method, hash); if (!call.isReturnValue()) return RMIVoidValue.INSTANCE; else return (call.returnValue()); }} |
else { throw new Error("The remote method threw a java.lang.Throwable that is neither java.lang.Exception nor java.lang.Error.", e); | else { throw new Error( "The remote method threw a java.lang.Throwable that"+ " is neither java.lang.Exception nor java.lang.Error.", e); | public Object incomingMessageCall(UnicastConnection conn, int method, long hash) throws Exception {//System.out.println("method = " + method + ", hash = " + hash); // If method is -1 then this is JDK 1.2 RMI - so use the hash // to locate the method if (method == -1) { Method meth = (Method)methods.get(new Long (hash));//System.out.println("class = " + myself.getClass() + ", meth = " + meth); if (meth == null) { throw new NoSuchMethodException(); } ObjectInputStream in = conn.getObjectInputStream(); int nrargs = meth.getParameterTypes().length; Object[] args = new Object[nrargs]; for (int i = 0; i < nrargs; i++) { /** * For debugging purposes - we don't handle CodeBases * quite right so we don't always find the stubs. This * lets us know that. */ try { // need to handle primitive types args[i] = ((RMIObjectInputStream)in).readValue(meth.getParameterTypes()[i]); } catch (Exception t) { t.printStackTrace(); throw t; } } //We must reinterpret the exception thrown by meth.invoke() //return (meth.invoke(myself, args)); Object ret = null; try{ ret = meth.invoke(myself, args); }catch(InvocationTargetException e){ Throwable cause = e.getTargetException(); if (cause instanceof Exception) { throw (Exception)cause; } else if (cause instanceof Error) { throw (Error)cause; } else { throw new Error("The remote method threw a java.lang.Throwable that is neither java.lang.Exception nor java.lang.Error.", e); } } return ret; } // Otherwise this is JDK 1.1 style RMI - we find the skeleton // and invoke it using the method number. We wrap up our // connection system in a UnicastRemoteCall so it appears in a // way the Skeleton can handle. else { if (skel == null) { throw new NoSuchMethodException(); } UnicastRemoteCall call = new UnicastRemoteCall(conn); skel.dispatch(myself, call, method, hash); if (!call.isReturnValue()) return RMIVoidValue.INSTANCE; else return (call.returnValue()); }} |
(screenSize.height - frameSize.height) / 2); | (screenSize.height - frameSize.height) / 3); | private void jbInit() throws Exception { try { setIconImage(GUIGraphicsUtils.getApplicationIcon().getImage()); // set title setTitle(LangTool.getString("xtfr.wizardTitle")); // Load the JDBC driver. Driver driver2 = (Driver)Class.forName("com.ibm.as400.access.AS400JDBCDriver").newInstance(); DriverManager.registerDriver(driver2); // Get a connection to the database. Since we do not // provide a user id or password, a prompt will appear. connection = new SQLConnection("jdbc:as400://" + host, name, password); // Create an SQLQueryBuilderPane // object. Assume that "connection" // is an SQLConnection object that is // created and initialized elsewhere. queryBuilder = new SQLQueryBuilderPane(connection); queryBuilder.setTableSchemas(new String[] {"*USRLIBL"}); // Load the data needed for the query // builder. queryBuilder.load(); JButton done = new JButton(LangTool.getString("xtfr.tableDone")); done.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { fillQueryTextArea(); } }); JPanel panel = new JPanel(); panel.add(done); getContentPane().add(queryBuilder, BorderLayout.CENTER); getContentPane().add(panel, BorderLayout.SOUTH); Dimension max = new Dimension(OperatingSystem.getScreenBounds().width, OperatingSystem.getScreenBounds().height); pack(); if (getSize().width > max.width) setSize(max.width,getSize().height); if (getSize().height > max.height) setSize(getSize().width,max.height); //Center the window Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = getSize(); if (frameSize.height > screenSize.height) frameSize.height = screenSize.height; if (frameSize.width > screenSize.width) frameSize.width = screenSize.width; setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); setVisible(true); } catch (ClassNotFoundException cnfe) { JOptionPane.showMessageDialog(null,"Error loading AS400 JDBC Driver", "Error", JOptionPane.ERROR_MESSAGE); } } |
if (!ck.toByteArray ().equals (toByteArray ())) | if (! Arrays.equals (ck.toByteArray (), toByteArray ())) | public boolean equals (Object obj) { if (! (obj instanceof CollationKey)) return false; CollationKey ck = (CollationKey) obj; if (ck.collator != collator) return false; if (!ck.getSourceString ().equals (getSourceString ())) return false; if (!ck.toByteArray ().equals (toByteArray ())) return false; return true; } |
synchronized (axesIOList) { | if (axesIOList == null) return parentArray.getAxes(); else | public List getIOAxesOrder() { synchronized (axesIOList) { return axesIOList; } } |
} | public List getIOAxesOrder() { synchronized (axesIOList) { return axesIOList; } } |
|
for (int i = 0, size = axesIOList.size(); i < size; i++) { | for (int i = 0, size = axisOrderList.size(); i < size; i++) { | private void privateSetIOAxesOrder (List axisOrderList) { synchronized (axesIOList) { axesIOList = Collections.synchronizedList(new ArrayList()); for (int i = 0, size = axesIOList.size(); i < size; i++) { axesIOList.add(axisOrderList.get(i)); } } } |
Log.debug("in Locator(Array)"); | public Locator(Array array) { Log.debug("in Locator(Array)"); parentArray = array; List axisList = parentArray.getAxisList(); /**now, since we KNOW _parentArray is defined * (has to be instanciated via Array ONLY) * we can proceed to initialize the axis, index positions * to the origin (ie index 0 for each axis). * We choose the parent Array axisList ordering for our * default location ordering. */ locations = new Hashtable(axisList.size()); int stop = axisList.size(); for (int i = 0; i < stop; i++) { Object axisObj = axisList.get(i); axisOrderList.add(axisObj); locations.put(axisObj, new Integer(0)); } } |
|
return null; | if (accessibleContext == null) accessibleContext = new AccessibleJWindow(); return accessibleContext; | public AccessibleContext getAccessibleContext() { return null; } |
public PrinterThread (char[] sc, Font font, int cols, int rows, | public PrinterThread (Screen5250 scr, Font font, int cols, int rows, | public PrinterThread (char[] sc, Font font, int cols, int rows, Color colorBg, boolean toDefaultPrinter, Session ses) { setPriority(1); session = ses; session.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); config = ses.getConfiguration(); screen = new char[sc.length]; System.arraycopy(sc, 0, screen, 0, sc.length); toDefault = toDefaultPrinter; int len = sc.length; // we need to fix this to use the access methods to planes// for (int x = 0; x < len; x++) {// screen[x] = new ScreenChar(sc[x].s);// screen[x].setCharAndAttr(sc[x].getChar(),sc[x].getCharAttr(),sc[x].isAttributePlace());// } numCols = cols; numRows = rows; this.colorBg = colorBg; this.font = font; } |
screen = new char[sc.length]; System.arraycopy(sc, 0, screen, 0, sc.length); | int len = scr.getScreenLength(); screen = new char[len]; screenAttr = new char[len]; int ret = scr.GetScreen(screen, len, PLANE_TEXT); ret = scr.GetScreen(screenAttr, len, PLANE_EXTENDED); | public PrinterThread (char[] sc, Font font, int cols, int rows, Color colorBg, boolean toDefaultPrinter, Session ses) { setPriority(1); session = ses; session.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); config = ses.getConfiguration(); screen = new char[sc.length]; System.arraycopy(sc, 0, screen, 0, sc.length); toDefault = toDefaultPrinter; int len = sc.length; // we need to fix this to use the access methods to planes// for (int x = 0; x < len; x++) {// screen[x] = new ScreenChar(sc[x].s);// screen[x].setCharAndAttr(sc[x].getChar(),sc[x].getCharAttr(),sc[x].isAttributePlace());// } numCols = cols; numRows = rows; this.colorBg = colorBg; this.font = font; } |
int len = sc.length; | public PrinterThread (char[] sc, Font font, int cols, int rows, Color colorBg, boolean toDefaultPrinter, Session ses) { setPriority(1); session = ses; session.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); config = ses.getConfiguration(); screen = new char[sc.length]; System.arraycopy(sc, 0, screen, 0, sc.length); toDefault = toDefaultPrinter; int len = sc.length; // we need to fix this to use the access methods to planes// for (int x = 0; x < len; x++) {// screen[x] = new ScreenChar(sc[x].s);// screen[x].setCharAndAttr(sc[x].getChar(),sc[x].getCharAttr(),sc[x].isAttributePlace());// } numCols = cols; numRows = rows; this.colorBg = colorBg; this.font = font; } |
|
if (screen[getPos(m,i)] >= ' ') { | if (screen[getPos(m,i)] >= ' ' && ((screen[getPos(m,i)] & EXTENDED_5250_NON_DSP) == 0)) { | public int print (Graphics g, PageFormat pageFormat, int page) { Graphics2D g2; //--- Validate the page number, we only print the first page if (page == 0) { //--- Create a graphic2D object and set the default parameters g2 = (Graphics2D) g; g2.setColor (Color.black); //--- Translate the origin to be (0,0) g2.translate (pageFormat.getImageableX (), pageFormat.getImageableY ()); int w = (int)pageFormat.getImageableWidth() / numCols; // proposed width int h = (int)pageFormat.getImageableHeight() / numRows; // proposed height Font k = font; LineMetrics l; FontRenderContext f = null; float j = 1; for (; j < 50; j++) { // derive the font and obtain the relevent information to compute // the width and height k = font.deriveFont(j); f = new FontRenderContext(k.getTransform(),true,true); l = k.getLineMetrics("Wy",f); if ( (w < (int)k.getStringBounds("W",f).getWidth()) || h < (int)(k.getStringBounds("y",f).getHeight() + l.getDescent() + l.getLeading()) ) break; } // since we were looking for an overrun of the width or height we need // to adjust the font one down to get the last one that fit. k = font.deriveFont(--j); f = new FontRenderContext(k.getTransform(),true,true); l = k.getLineMetrics("Wy",f); // set the font of the print job g2.setFont(k); // get the width and height of the character bounds int w1 = (int)k.getStringBounds("W",f).getWidth(); int h1 = (int)(k.getStringBounds("y",f).getHeight() + l.getDescent() + l.getLeading()); int x; int y; // loop through all the screen characters and print them out. for (int m = 0;m < numRows; m++) for (int i = 0; i < numCols; i++) { x = w1 * i; y = h1 * (m + 1); // only draw printable characters (in this case >= ' ')// if (screen[getPos(m,i)].getChar() >= ' ' && !screen[getPos(m,i)].nonDisplay) { // TODO: Fix me for detecting non display if (screen[getPos(m,i)] >= ' ') { // && !screen[getPos(m,i)].nonDisplay) {// g2.drawChars(screen[getPos(m,i)], 0, 1,x , (int)(y + h1 - (l.getDescent() + l.getLeading())-2)); g2.drawChars(screen, getPos(m,i), 1,x , (int)(y + h1 - (l.getDescent() + l.getLeading())-2)); } // TODO: Fix me for detecting non display // if it is underlined then underline the character// if (screen[getPos(m,i)].underLine && !screen[getPos(m,i)].attributePlace)// g.drawLine(x, (int)(y + (h1 - l.getLeading()-3)), (int)(x + w1), (int)(y + (h1 - l.getLeading())-3)); } return (PAGE_EXISTS); } else return (NO_SUCH_PAGE); } |
if ((screenAttr[getPos(m,i)] & EXTENDED_5250_UNDERLINE) == 1) g.drawLine(x, (int)(y + (h1 - l.getLeading()-3)), (int)(x + w1), (int)(y + (h1 - l.getLeading())-3)); | public int print (Graphics g, PageFormat pageFormat, int page) { Graphics2D g2; //--- Validate the page number, we only print the first page if (page == 0) { //--- Create a graphic2D object and set the default parameters g2 = (Graphics2D) g; g2.setColor (Color.black); //--- Translate the origin to be (0,0) g2.translate (pageFormat.getImageableX (), pageFormat.getImageableY ()); int w = (int)pageFormat.getImageableWidth() / numCols; // proposed width int h = (int)pageFormat.getImageableHeight() / numRows; // proposed height Font k = font; LineMetrics l; FontRenderContext f = null; float j = 1; for (; j < 50; j++) { // derive the font and obtain the relevent information to compute // the width and height k = font.deriveFont(j); f = new FontRenderContext(k.getTransform(),true,true); l = k.getLineMetrics("Wy",f); if ( (w < (int)k.getStringBounds("W",f).getWidth()) || h < (int)(k.getStringBounds("y",f).getHeight() + l.getDescent() + l.getLeading()) ) break; } // since we were looking for an overrun of the width or height we need // to adjust the font one down to get the last one that fit. k = font.deriveFont(--j); f = new FontRenderContext(k.getTransform(),true,true); l = k.getLineMetrics("Wy",f); // set the font of the print job g2.setFont(k); // get the width and height of the character bounds int w1 = (int)k.getStringBounds("W",f).getWidth(); int h1 = (int)(k.getStringBounds("y",f).getHeight() + l.getDescent() + l.getLeading()); int x; int y; // loop through all the screen characters and print them out. for (int m = 0;m < numRows; m++) for (int i = 0; i < numCols; i++) { x = w1 * i; y = h1 * (m + 1); // only draw printable characters (in this case >= ' ')// if (screen[getPos(m,i)].getChar() >= ' ' && !screen[getPos(m,i)].nonDisplay) { // TODO: Fix me for detecting non display if (screen[getPos(m,i)] >= ' ') { // && !screen[getPos(m,i)].nonDisplay) {// g2.drawChars(screen[getPos(m,i)], 0, 1,x , (int)(y + h1 - (l.getDescent() + l.getLeading())-2)); g2.drawChars(screen, getPos(m,i), 1,x , (int)(y + h1 - (l.getDescent() + l.getLeading())-2)); } // TODO: Fix me for detecting non display // if it is underlined then underline the character// if (screen[getPos(m,i)].underLine && !screen[getPos(m,i)].attributePlace)// g.drawLine(x, (int)(y + (h1 - l.getLeading()-3)), (int)(x + w1), (int)(y + (h1 - l.getLeading())-3)); } return (PAGE_EXISTS); } else return (NO_SUCH_PAGE); } |
|
screen = null; screenAttr = null; | public void run () {// Toolkit tk = Toolkit.getDefaultToolkit();//int [][] range = new int[][] {//new int[] { 1, 1 }//};// JobAttributes jobAttributes = new JobAttributes(1, JobAttributes.DefaultSelectionType.ALL, JobAttributes.DestinationType.PRINTER, JobAttributes.DialogType.NONE, "file", 1, 1, JobAttributes.MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_COLLATED_COPIES, range, "HP LaserJet", JobAttributes.SidesType.ONE_SIDED);//PrintJob job = tk.getPrintJob(null, "Print", jobAttributes, null);//if (job != null) { //--- Create a printerJob object PrinterJob printJob = PrinterJob.getPrinterJob (); printJob.setJobName("tn5250j"); // will have to remember this for the next time. // Always set a page format before call setPrintable to // set the orientation. PageFormat pf = printJob.defaultPage(); if (numCols == 132) pf.setOrientation(PageFormat.LANDSCAPE); else pf.setOrientation(PageFormat.PORTRAIT); if (numCols != 132) { if (config.getStringProperty("print.portWidth").length() != 0 && config.getStringProperty("print.portHeight").length() != 0 && config.getStringProperty("print.portImageWidth").length() != 0 && config.getStringProperty("print.portImageHeight").length() != 0 && config.getStringProperty("print.portImage.X").length() != 0 && config.getStringProperty("print.portImage.Y").length() != 0) { Paper paper = pf.getPaper(); paper.setSize( Double.parseDouble(config.getStringProperty("print.portWidth")), Double.parseDouble(config.getStringProperty("print.portHeight"))); paper.setImageableArea( Double.parseDouble(config.getStringProperty("print.portImage.X")), Double.parseDouble(config.getStringProperty("print.portImage.Y")), Double.parseDouble(config.getStringProperty("print.portImageWidth")), Double.parseDouble(config.getStringProperty("print.portImageHeight"))); pf.setPaper(paper); } } else { if (config.getStringProperty("print.landWidth").length() != 0 && config.getStringProperty("print.landHeight").length() != 0 && config.getStringProperty("print.landImageWidth").length() != 0 && config.getStringProperty("print.landImageHeight").length() != 0 && config.getStringProperty("print.landImage.X").length() != 0 && config.getStringProperty("print.landImage.Y").length() != 0) { Paper paper = pf.getPaper(); paper.setSize( Double.parseDouble(config.getStringProperty("print.landWidth")), Double.parseDouble(config.getStringProperty("print.landHeight"))); paper.setImageableArea( Double.parseDouble(config.getStringProperty("print.landImage.X")), Double.parseDouble(config.getStringProperty("print.landImage.Y")), Double.parseDouble(config.getStringProperty("print.landImageWidth")), Double.parseDouble(config.getStringProperty("print.landImageHeight"))); } } if (config.getStringProperty("print.font").length() > 0) { font = new Font(config.getStringProperty("print.font"), Font.PLAIN, 8); } //--- Set the printable class to this one since we //--- are implementing the Printable interface printJob.setPrintable (this,pf); // set the cursor back session.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); //--- Show a print dialog to the user. If the user //--- clicks the print button, then print, otherwise //--- cancel the print job if (printJob.printDialog()) { try { // we do this because of loosing focus with jdk 1.4.0 session.requestFocus(); printJob.print(); } catch (Exception PrintException) { PrintException.printStackTrace(); } } else { // we do this because of loosing focus with jdk 1.4.0 session.requestFocus(); } session = null;// int len = screen.length;//// for (int x = 0; x < len; x++) {// screen[x] = null;// }//// screen = null; } |
|
bad.minor = Minor.Any; | public static NoServant extract(Any any) { try { EmptyExceptionHolder h = (EmptyExceptionHolder) any.extract_Streamable(); return (NoServant) h.value; } catch (ClassCastException cex) { BAD_OPERATION bad = new BAD_OPERATION("NoServant expected"); bad.initCause(cex); throw bad; } } |
|
descr = new PluginDescriptorModel(root); | if (root.getName().equals("plugin")) { descr = new PluginDescriptorModel(root); } else if (root.getName().equals("fragment")) { descr = new FragmentDescriptorModel(root); } else { throw new BuildException("Unknown root tag " + root.getName()); } | protected PluginDescriptorModel readDescriptor(File descriptor) { final PluginDescriptorModel descr; try { final XMLElement root = new XMLElement(new Hashtable(), true, false); try { final FileReader r = new FileReader(descriptor); try { root.parseFromReader(r); } finally { r.close(); } } catch (IOException ex) { throw new BuildException("Building " + descriptor + " failed", ex); } catch (XMLParseException ex) { throw new BuildException("Building " + descriptor + " failed", ex); } descr = new PluginDescriptorModel(root); } catch (PluginException ex) { ex.printStackTrace(); throw new BuildException("Building " + descriptor + " failed", ex); } return descr; } |
pendingUnlock =false; | public final boolean disconnect() { if (me != null && me.isAlive()) { me.interrupt(); keepTrucking = false; pthread.interrupt(); } screen52.setStatus(screen52.STATUS_SYSTEM,screen52.STATUS_VALUE_ON,"X - Disconnected"); screen52.setKeyboardLocked(false); try { if (bin != null) bin.close(); if (bout != null) bout.close(); if (sock != null) { System.out.println("Closing socket"); sock.close(); } connected = false; controller.fireSessionChanged(TN5250jConstants.STATE_DISCONNECTED); } catch(Exception exception) { System.out.println(exception.getMessage()); connected = false; devSeq = -1; return false; } devSeq = -1; return true; } |
|
screen52.setKeyboardLocked(false); | pendingUnlock = true; | private void parseIncoming() { boolean controlChars = false; byte control0; byte control1; boolean done = false; boolean error = false; try { while (bk.hasNext() && !done) { byte b = bk.getNextByte(); switch (b) { case 0: case 1: break; case CMD_SAVE_SCREEN: // 0x02 2 Save Screen case 3: // 0x03 3 Save Partial Screen saveScreen(); break; case ESC: // ESCAPE break; case 7: // audible bell Toolkit.getDefaultToolkit().beep(); bk.getNextByte(); bk.getNextByte(); break; case CMD_WRITE_TO_DISPLAY: // 0x11 17 write to display error = writeToDisplay(true); break; case CMD_RESTORE_SCREEN: // 0x12 18 Restore Screen case 13: // 0x13 19 Restore Partial Screen restoreScreen(); break; case CMD_CLEAR_UNIT_ALTERNATE: // 0x20 32 clear unit alternate int param = bk.getNextByte(); if (param != 0) {// System.out.println(" clear unit alternate error " + Integer.toHexString(param)); sendNegResponse(NR_REQUEST_ERROR,03,01,05, " clear unit alternate not supported"); done = true; } else { if (screen52.getRows() != 27) screen52.setRowsCols(27,132); screen52.clearAll(); } break; case CMD_WRITE_ERROR_CODE: // 0x21 33 Write Error Code writeErrorCode(); error = writeToDisplay(false); break; case CMD_WRITE_ERROR_CODE_TO_WINDOW: // 0x22 34 // Write Error Code to window writeErrorCodeToWindow(); error = writeToDisplay(false); break; case CMD_READ_SCREEN_IMMEDIATE: // 0x62 98 case CMD_READ_SCREEN_TO_PRINT: // 0x66 102 read screen to print readScreen(); break; case CMD_CLEAR_UNIT: // 64 0x40 clear unit if (screen52.getRows() != 24) screen52.setRowsCols(24,80); screen52.clearAll(); break; case CMD_CLEAR_FORMAT_TABLE: // 80 0x50 Clear format table screen52.clearTable(); break; case CMD_READ_INPUT_FIELDS: //0x42 66 read input fields case CMD_READ_MDT_FIELDS: // 0x52 82 read MDT Fields bk.getNextByte(); bk.getNextByte(); readType = b; screen52.goHome();// screen52.setCursorOn(); waitingForInput = true; screen52.setKeyboardLocked(false); break; case CMD_READ_MDT_IMMEDIATE_ALT: // 0x53 83 readType = b;// screen52.goHome();// waitingForInput = true;// screen52.setKeyboardLocked(false); readImmediate(readType); break; case CMD_WRITE_STRUCTURED_FIELD: // 243 0xF3 -13 Write structured field writeStructuredField(); break; default: done = true; sendNegResponse(NR_REQUEST_ERROR,03,01,01,"parseIncoming"); break; } if (error) done = true; } } catch (Exception exc) {System.out.println("incoming " + exc.getMessage());}; } |
else pendingUnlock =false; | private void processCC0 (byte byte0) {// System.out.println(" Control byte0 " + Integer.toBinaryString(byte0 & 0xff)); boolean lockKeyboard = true; boolean resetMDT=false; boolean resetMDTAll = false; boolean nullMDT = false; boolean nullAll = false; // Bits 3 to 6 are reserved and should be set to '0000' // 0xE0 = '11100000' - only the first 3 bits are tested if ((byte0 & 0xE0) == 0x00) { lockKeyboard = false; } // '00100000' = 0x20 /32 -- just lock keyboard // '01000000' = 0x40 /64 // '01100000' = 0x60 /96 // '10000000' = 0x80 /128 // '10100000' = 0xA0 /160 // '11000000' = 0xC0 /192 // '11100000' = 0xE0 /224 switch (byte0 & 0xE0) { case 0x40: resetMDT = true; break; case 0x60: resetMDTAll = true; break; case 0x80: nullMDT = true; break; case 0xA0: resetMDT = true; nullAll = true; break; case 0xC0: resetMDT = true; nullMDT = true; break; case 0xE0: resetMDTAll = true; nullAll = true; break; } if (lockKeyboard) { screen52.setKeyboardLocked(true); } if (resetMDT || resetMDTAll || nullMDT || nullAll) { ScreenField sf; int f = screen52.getScreenFields().getSize(); for (int x = 0; x < f; x++) { sf = screen52.getScreenFields().getField(x); if (!sf.isBypassField()) { if ((nullMDT && sf.mdt) || nullAll ) { sf.setFieldChar((char)0x0); screen52.drawField(sf); } } if (resetMDTAll || (resetMDT && !sf.isBypassField())) sf.resetMDT(); } sf = null; } } |
|
pendingUnlock = false; | private final void readImmediate(int readType) { if (screen52.isStatusErrorCode()) { screen52.restoreErrorLine(); screen52.setStatus(screen52.STATUS_ERROR_CODE,screen52.STATUS_VALUE_OFF,null); } if (!enhanced) { screen52.setCursorOff(); } screen52.setStatus(screen52.STATUS_SYSTEM,screen52.STATUS_VALUE_ON,null); screen52.setKeyboardLocked(true); invited = false; screen52.getScreenFields().readFormatTable(baosp,readType,codePage); try { writeGDS(0, 3, baosp.toByteArray()); } catch (IOException ioe) { System.out.println(ioe.getMessage()); baosp.reset(); } baosp.reset(); } |
|
screen52.setKeyboardLocked(false); | pendingUnlock = true; | public void run () { while (keepTrucking) { try { bk = (Stream5250)dsq.get(); } catch (InterruptedException ie) { System.out.println(" vt thread interrupted and stopping "); keepTrucking = false; continue; } // lets play nicely with the others on the playground// me.yield(); pthread.yield(); invited = false; screen52.setCursorOff();// System.out.println("operation code: " + bk.getOpCode()); if (bk == null) continue; switch (bk.getOpCode()) { case 00:// System.out.println("No operation"); break; case 1:// System.out.println("Invite Operation"); parseIncoming(); screen52.setKeyboardLocked(false); cursorOn = true; setInvited(); break; case 2:// System.out.println("Output Only"); parseIncoming();// System.out.println(screen52.dirty); screen52.updateDirty(); // invited = true; break; case 3:// System.out.println("Put/Get Operation"); parseIncoming();// inviteIt =true; setInvited(); break; case 4:// System.out.println("Save Screen Operation"); parseIncoming(); break; case 5:// System.out.println("Restore Screen Operation"); parseIncoming(); break; case 6:// System.out.println("Read Immediate"); sendAidKey(0); break; case 7:// System.out.println("Reserved"); break; case 8:// System.out.println("Read Screen Operation"); try { readScreen(); } catch (IOException ex) { } break; case 9:// System.out.println("Reserved"); break; case 10:// System.out.println("Cancel Invite Operation"); cancelInvite(); break; case 11:// System.out.println("Turn on message light"); screen52.setMessageLightOn(); screen52.setCursorOn(); break; case 12:// System.out.println("Turn off Message light"); screen52.setMessageLightOff(); screen52.setCursorOn(); break; default: break; } if (screen52.isUsingGuiInterface()) screen52.drawFields();// if (screen52.screen[0][1].getChar() == '#' &&// screen52.screen[0][2].getChar() == '!')// execCmd();// else { if (screen52.isHotSpots()) { screen52.checkHotSpots(); } try { screen52.updateDirty(); } catch (Exception exd ) { System.out.println(" tnvt.run: " + exd.getMessage()); } if (cursorOn && !screen52.isKeyboardLocked()) { screen52.setCursorOn(); cursorOn = false; } // lets play nicely with the others on the playground// me.yield(); pthread.yield(); } } |
if (pendingUnlock) screen52.setKeyboardLocked(false); | public void run () { while (keepTrucking) { try { bk = (Stream5250)dsq.get(); } catch (InterruptedException ie) { System.out.println(" vt thread interrupted and stopping "); keepTrucking = false; continue; } // lets play nicely with the others on the playground// me.yield(); pthread.yield(); invited = false; screen52.setCursorOff();// System.out.println("operation code: " + bk.getOpCode()); if (bk == null) continue; switch (bk.getOpCode()) { case 00:// System.out.println("No operation"); break; case 1:// System.out.println("Invite Operation"); parseIncoming(); screen52.setKeyboardLocked(false); cursorOn = true; setInvited(); break; case 2:// System.out.println("Output Only"); parseIncoming();// System.out.println(screen52.dirty); screen52.updateDirty(); // invited = true; break; case 3:// System.out.println("Put/Get Operation"); parseIncoming();// inviteIt =true; setInvited(); break; case 4:// System.out.println("Save Screen Operation"); parseIncoming(); break; case 5:// System.out.println("Restore Screen Operation"); parseIncoming(); break; case 6:// System.out.println("Read Immediate"); sendAidKey(0); break; case 7:// System.out.println("Reserved"); break; case 8:// System.out.println("Read Screen Operation"); try { readScreen(); } catch (IOException ex) { } break; case 9:// System.out.println("Reserved"); break; case 10:// System.out.println("Cancel Invite Operation"); cancelInvite(); break; case 11:// System.out.println("Turn on message light"); screen52.setMessageLightOn(); screen52.setCursorOn(); break; case 12:// System.out.println("Turn off Message light"); screen52.setMessageLightOff(); screen52.setCursorOn(); break; default: break; } if (screen52.isUsingGuiInterface()) screen52.drawFields();// if (screen52.screen[0][1].getChar() == '#' &&// screen52.screen[0][2].getChar() == '!')// execCmd();// else { if (screen52.isHotSpots()) { screen52.checkHotSpots(); } try { screen52.updateDirty(); } catch (Exception exd ) { System.out.println(" tnvt.run: " + exd.getMessage()); } if (cursorOn && !screen52.isKeyboardLocked()) { screen52.setCursorOn(); cursorOn = false; } // lets play nicely with the others on the playground// me.yield(); pthread.yield(); } } |
|
pendingUnlock = false; | public final boolean sendAidKey(int aid) { if (screen52.isStatusErrorCode()) { screen52.restoreErrorLine(); screen52.setStatus(screen52.STATUS_ERROR_CODE,screen52.STATUS_VALUE_OFF,null); } if (!enhanced) { screen52.setCursorOff(); } screen52.setStatus(screen52.STATUS_SYSTEM,screen52.STATUS_VALUE_ON,null); screen52.setKeyboardLocked(true); invited = false; baosp.write(screen52.getCurrentRow()); baosp.write(screen52.getCurrentCol()); baosp.write(aid); if (dataIncluded(aid)) screen52.getScreenFields().readFormatTable(baosp,readType,codePage); try { writeGDS(0, 3, baosp.toByteArray()); } catch (IOException ioe) { System.out.println(ioe.getMessage()); baosp.reset(); return false; } baosp.reset(); return true; } |
|
super("ttf"); | public TTFontProvider() { log.debug("new TTFontProvider"); } |
|
final String renderer = (String)AccessController.doPrivileged(new GetPropertyAction("jnode.font.renderer", "simple")); | protected TextRenderer createTextRenderer(RenderCache renderCache, Font font) { final String renderer = (String)AccessController.doPrivileged(new GetPropertyAction("jnode.font.renderer", "simple")); TextRenderer r; if (false || renderer.equals("new")) { r = new TTFTextRenderer(renderCache, getFontMetrics(font), getFontData(font)); } else { r = new TTFSimpleTextRenderer(getFontData(font), font.getSize()); } log.debug("created TextRenderer for TTF"); return r; } |
|
if (false || renderer.equals("new")) { | protected TextRenderer createTextRenderer(RenderCache renderCache, Font font) { final String renderer = (String)AccessController.doPrivileged(new GetPropertyAction("jnode.font.renderer", "simple")); TextRenderer r; if (false || renderer.equals("new")) { r = new TTFTextRenderer(renderCache, getFontMetrics(font), getFontData(font)); } else { r = new TTFSimpleTextRenderer(getFontData(font), font.getSize()); } log.debug("created TextRenderer for TTF"); return r; } |
|
} else { r = new TTFSimpleTextRenderer(getFontData(font), font.getSize()); } | protected TextRenderer createTextRenderer(RenderCache renderCache, Font font) { final String renderer = (String)AccessController.doPrivileged(new GetPropertyAction("jnode.font.renderer", "simple")); TextRenderer r; if (false || renderer.equals("new")) { r = new TTFTextRenderer(renderCache, getFontMetrics(font), getFontData(font)); } else { r = new TTFSimpleTextRenderer(getFontData(font), font.getSize()); } log.debug("created TextRenderer for TTF"); return r; } |
|
this(10); | this(DEFAULT_BUFSIZE); | public GapContent() { this(10); } |
txt.array = new char[len]; | int length = length(); if (where >= length) throw new BadLocationException("the where argument cannot be greater" + " than the content length", where); if ((where + len) > length) throw new BadLocationException("len plus where cannot be greater" + " than the content length", len + where); | public void getChars(int where, int len, Segment txt) throws BadLocationException { txt.array = new char[len]; System.arraycopy(buf.toString().toCharArray(), where, txt.array, 0, len); txt.count = len; txt.offset = 0; } |
System.arraycopy(buf.toString().toCharArray(), where, txt.array, 0, len); txt.count = len; | if ((where < gapStart) && ((gapStart - where) < len)) { char[] copy = new char[len]; int lenFirst = gapStart - where; System.arraycopy(buffer, where, copy, 0, lenFirst); System.arraycopy(buffer, gapEnd, copy, lenFirst, len - lenFirst); txt.array = copy; | public void getChars(int where, int len, Segment txt) throws BadLocationException { txt.array = new char[len]; System.arraycopy(buf.toString().toCharArray(), where, txt.array, 0, len); txt.count = len; txt.offset = 0; } |
} | txt.count = len; } else { txt.array = buffer; if (where < gapStart) txt.offset = where; else txt.offset = where + (gapEnd - gapStart); txt.count = len; } } | public void getChars(int where, int len, Segment txt) throws BadLocationException { txt.array = new char[len]; System.arraycopy(buf.toString().toCharArray(), where, txt.array, 0, len); txt.count = len; txt.offset = 0; } |
return buf.substring(where, where+len); | Segment seg = new Segment(); getChars(where, len, seg); return new String(seg.array, seg.offset, seg.count); | public String getString(int where, int len) throws BadLocationException { return buf.substring(where, where+len); } |
buf.insert(where, str); | int length = length(); int strLen = str.length(); if (where >= length) throw new BadLocationException("the where argument cannot be greater" + " than the content length", where); if ((gapEnd - gapStart) < strLen) shiftEnd(strLen + DEFAULT_BUFSIZE); if (where != gapStart) shiftGap(where); System.arraycopy(str.toCharArray(), 0, buffer, gapStart, strLen); gapStart += strLen; | public UndoableEdit insertString(int where, String str) throws BadLocationException { buf.insert(where, str); return null; } |
return buf.length(); | return buffer.length - (gapEnd - gapStart); | public int length() { return buf.length(); } |
buf.delete(where, where + nitems); | int length = length(); if (where >= length) throw new BadLocationException("the where argument cannot be greater" + " than the content length", where); if ((where + nitems) > length) throw new BadLocationException("where + nitems cannot be greater" + " than the content length", where + nitems); if (where != gapStart) shiftGap(where); gapEnd += nitems; | public UndoableEdit remove(int where, int nitems) throws BadLocationException { buf.delete(where, where + nitems); return null; } |
super.setPropertiesFromAttributes(); | protected void setPropertiesFromAttributes() { // FIXME: Implement this. } |
|
TreeNode last = null; | Object last = null; | public void keyPressed(KeyEvent e) { TreePath start = BasicTreeUI.this.tree.getLeadSelectionPath(); TreeNode last = null; if (start != null) last = (TreeNode) start.getLastPathComponent(); if (last != null) { // DOWN, KP_DOWN if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_KP_DOWN) { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) { TreePath newPath = new TreePath(getPathToRoot(next, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, newPath); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!next.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // UP, KP_UP else if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_KP_UP) { TreeNode prev = (TreeNode) BasicTreeUI.this. getPreviousVisibleNode(last); if (prev != null) { TreePath newPath = new TreePath(getPathToRoot(prev, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(prev, 0))); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!prev.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // LEFT, KP_LEFT else if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_KP_LEFT) { TreePath path = new TreePath(getPathToRoot(last, 0)); TreeNode p = last.getParent(); if (!last.isLeaf() && BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else if (p != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(p, 0))); } // RIGHT, KP_RIGHT else if (e.getKeyCode() == KeyEvent.VK_RIGHT || e.getKeyCode() == KeyEvent.VK_KP_RIGHT) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf() && BasicTreeUI.this.tree.isCollapsed(path)) { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } else { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(next, 0))); } } // Enter else if (e.getKeyCode() == KeyEvent.VK_ENTER) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf()) { if (BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } } } } } |
last = (TreeNode) start.getLastPathComponent(); | last = start.getLastPathComponent(); | public void keyPressed(KeyEvent e) { TreePath start = BasicTreeUI.this.tree.getLeadSelectionPath(); TreeNode last = null; if (start != null) last = (TreeNode) start.getLastPathComponent(); if (last != null) { // DOWN, KP_DOWN if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_KP_DOWN) { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) { TreePath newPath = new TreePath(getPathToRoot(next, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, newPath); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!next.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // UP, KP_UP else if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_KP_UP) { TreeNode prev = (TreeNode) BasicTreeUI.this. getPreviousVisibleNode(last); if (prev != null) { TreePath newPath = new TreePath(getPathToRoot(prev, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(prev, 0))); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!prev.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // LEFT, KP_LEFT else if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_KP_LEFT) { TreePath path = new TreePath(getPathToRoot(last, 0)); TreeNode p = last.getParent(); if (!last.isLeaf() && BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else if (p != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(p, 0))); } // RIGHT, KP_RIGHT else if (e.getKeyCode() == KeyEvent.VK_RIGHT || e.getKeyCode() == KeyEvent.VK_KP_RIGHT) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf() && BasicTreeUI.this.tree.isCollapsed(path)) { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } else { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(next, 0))); } } // Enter else if (e.getKeyCode() == KeyEvent.VK_ENTER) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf()) { if (BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } } } } } |
TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); | Object next = BasicTreeUI.this.getNextVisibleNode(last); | public void keyPressed(KeyEvent e) { TreePath start = BasicTreeUI.this.tree.getLeadSelectionPath(); TreeNode last = null; if (start != null) last = (TreeNode) start.getLastPathComponent(); if (last != null) { // DOWN, KP_DOWN if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_KP_DOWN) { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) { TreePath newPath = new TreePath(getPathToRoot(next, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, newPath); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!next.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // UP, KP_UP else if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_KP_UP) { TreeNode prev = (TreeNode) BasicTreeUI.this. getPreviousVisibleNode(last); if (prev != null) { TreePath newPath = new TreePath(getPathToRoot(prev, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(prev, 0))); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!prev.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // LEFT, KP_LEFT else if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_KP_LEFT) { TreePath path = new TreePath(getPathToRoot(last, 0)); TreeNode p = last.getParent(); if (!last.isLeaf() && BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else if (p != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(p, 0))); } // RIGHT, KP_RIGHT else if (e.getKeyCode() == KeyEvent.VK_RIGHT || e.getKeyCode() == KeyEvent.VK_KP_RIGHT) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf() && BasicTreeUI.this.tree.isCollapsed(path)) { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } else { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(next, 0))); } } // Enter else if (e.getKeyCode() == KeyEvent.VK_ENTER) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf()) { if (BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } } } } } |
else if (!next.isLeaf() && e.isShiftDown()) | else if (!mod.isLeaf(next) && e.isShiftDown()) | public void keyPressed(KeyEvent e) { TreePath start = BasicTreeUI.this.tree.getLeadSelectionPath(); TreeNode last = null; if (start != null) last = (TreeNode) start.getLastPathComponent(); if (last != null) { // DOWN, KP_DOWN if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_KP_DOWN) { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) { TreePath newPath = new TreePath(getPathToRoot(next, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, newPath); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!next.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // UP, KP_UP else if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_KP_UP) { TreeNode prev = (TreeNode) BasicTreeUI.this. getPreviousVisibleNode(last); if (prev != null) { TreePath newPath = new TreePath(getPathToRoot(prev, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(prev, 0))); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!prev.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // LEFT, KP_LEFT else if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_KP_LEFT) { TreePath path = new TreePath(getPathToRoot(last, 0)); TreeNode p = last.getParent(); if (!last.isLeaf() && BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else if (p != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(p, 0))); } // RIGHT, KP_RIGHT else if (e.getKeyCode() == KeyEvent.VK_RIGHT || e.getKeyCode() == KeyEvent.VK_KP_RIGHT) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf() && BasicTreeUI.this.tree.isCollapsed(path)) { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } else { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(next, 0))); } } // Enter else if (e.getKeyCode() == KeyEvent.VK_ENTER) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf()) { if (BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } } } } } |
TreeNode prev = (TreeNode) BasicTreeUI.this. getPreviousVisibleNode(last); | Object prev = BasicTreeUI.this.getPreviousVisibleNode(last); | public void keyPressed(KeyEvent e) { TreePath start = BasicTreeUI.this.tree.getLeadSelectionPath(); TreeNode last = null; if (start != null) last = (TreeNode) start.getLastPathComponent(); if (last != null) { // DOWN, KP_DOWN if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_KP_DOWN) { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) { TreePath newPath = new TreePath(getPathToRoot(next, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, newPath); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!next.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // UP, KP_UP else if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_KP_UP) { TreeNode prev = (TreeNode) BasicTreeUI.this. getPreviousVisibleNode(last); if (prev != null) { TreePath newPath = new TreePath(getPathToRoot(prev, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(prev, 0))); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!prev.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // LEFT, KP_LEFT else if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_KP_LEFT) { TreePath path = new TreePath(getPathToRoot(last, 0)); TreeNode p = last.getParent(); if (!last.isLeaf() && BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else if (p != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(p, 0))); } // RIGHT, KP_RIGHT else if (e.getKeyCode() == KeyEvent.VK_RIGHT || e.getKeyCode() == KeyEvent.VK_KP_RIGHT) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf() && BasicTreeUI.this.tree.isCollapsed(path)) { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } else { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(next, 0))); } } // Enter else if (e.getKeyCode() == KeyEvent.VK_ENTER) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf()) { if (BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } } } } } |
else if (!prev.isLeaf() && e.isShiftDown()) | else if (!mod.isLeaf(prev) && e.isShiftDown()) | public void keyPressed(KeyEvent e) { TreePath start = BasicTreeUI.this.tree.getLeadSelectionPath(); TreeNode last = null; if (start != null) last = (TreeNode) start.getLastPathComponent(); if (last != null) { // DOWN, KP_DOWN if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_KP_DOWN) { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) { TreePath newPath = new TreePath(getPathToRoot(next, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, newPath); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!next.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // UP, KP_UP else if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_KP_UP) { TreeNode prev = (TreeNode) BasicTreeUI.this. getPreviousVisibleNode(last); if (prev != null) { TreePath newPath = new TreePath(getPathToRoot(prev, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(prev, 0))); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!prev.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // LEFT, KP_LEFT else if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_KP_LEFT) { TreePath path = new TreePath(getPathToRoot(last, 0)); TreeNode p = last.getParent(); if (!last.isLeaf() && BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else if (p != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(p, 0))); } // RIGHT, KP_RIGHT else if (e.getKeyCode() == KeyEvent.VK_RIGHT || e.getKeyCode() == KeyEvent.VK_KP_RIGHT) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf() && BasicTreeUI.this.tree.isCollapsed(path)) { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } else { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(next, 0))); } } // Enter else if (e.getKeyCode() == KeyEvent.VK_ENTER) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf()) { if (BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } } } } } |
TreeNode p = last.getParent(); | Object p = getParent(mod.getRoot(), last); | public void keyPressed(KeyEvent e) { TreePath start = BasicTreeUI.this.tree.getLeadSelectionPath(); TreeNode last = null; if (start != null) last = (TreeNode) start.getLastPathComponent(); if (last != null) { // DOWN, KP_DOWN if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_KP_DOWN) { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) { TreePath newPath = new TreePath(getPathToRoot(next, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, newPath); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!next.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // UP, KP_UP else if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_KP_UP) { TreeNode prev = (TreeNode) BasicTreeUI.this. getPreviousVisibleNode(last); if (prev != null) { TreePath newPath = new TreePath(getPathToRoot(prev, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(prev, 0))); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!prev.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // LEFT, KP_LEFT else if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_KP_LEFT) { TreePath path = new TreePath(getPathToRoot(last, 0)); TreeNode p = last.getParent(); if (!last.isLeaf() && BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else if (p != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(p, 0))); } // RIGHT, KP_RIGHT else if (e.getKeyCode() == KeyEvent.VK_RIGHT || e.getKeyCode() == KeyEvent.VK_KP_RIGHT) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf() && BasicTreeUI.this.tree.isCollapsed(path)) { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } else { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(next, 0))); } } // Enter else if (e.getKeyCode() == KeyEvent.VK_ENTER) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf()) { if (BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } } } } } |
if (!last.isLeaf() && BasicTreeUI.this.tree.isExpanded(path)) | if (!mod.isLeaf(last) && BasicTreeUI.this.tree.isExpanded(path)) | public void keyPressed(KeyEvent e) { TreePath start = BasicTreeUI.this.tree.getLeadSelectionPath(); TreeNode last = null; if (start != null) last = (TreeNode) start.getLastPathComponent(); if (last != null) { // DOWN, KP_DOWN if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_KP_DOWN) { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) { TreePath newPath = new TreePath(getPathToRoot(next, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, newPath); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!next.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // UP, KP_UP else if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_KP_UP) { TreeNode prev = (TreeNode) BasicTreeUI.this. getPreviousVisibleNode(last); if (prev != null) { TreePath newPath = new TreePath(getPathToRoot(prev, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(prev, 0))); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!prev.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // LEFT, KP_LEFT else if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_KP_LEFT) { TreePath path = new TreePath(getPathToRoot(last, 0)); TreeNode p = last.getParent(); if (!last.isLeaf() && BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else if (p != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(p, 0))); } // RIGHT, KP_RIGHT else if (e.getKeyCode() == KeyEvent.VK_RIGHT || e.getKeyCode() == KeyEvent.VK_KP_RIGHT) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf() && BasicTreeUI.this.tree.isCollapsed(path)) { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } else { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(next, 0))); } } // Enter else if (e.getKeyCode() == KeyEvent.VK_ENTER) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf()) { if (BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } } } } } |
if (!last.isLeaf() && BasicTreeUI.this.tree.isCollapsed(path)) | if (!mod.isLeaf(last) && BasicTreeUI.this.tree.isCollapsed(path)) | public void keyPressed(KeyEvent e) { TreePath start = BasicTreeUI.this.tree.getLeadSelectionPath(); TreeNode last = null; if (start != null) last = (TreeNode) start.getLastPathComponent(); if (last != null) { // DOWN, KP_DOWN if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_KP_DOWN) { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) { TreePath newPath = new TreePath(getPathToRoot(next, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, newPath); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!next.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // UP, KP_UP else if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_KP_UP) { TreeNode prev = (TreeNode) BasicTreeUI.this. getPreviousVisibleNode(last); if (prev != null) { TreePath newPath = new TreePath(getPathToRoot(prev, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(prev, 0))); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!prev.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // LEFT, KP_LEFT else if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_KP_LEFT) { TreePath path = new TreePath(getPathToRoot(last, 0)); TreeNode p = last.getParent(); if (!last.isLeaf() && BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else if (p != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(p, 0))); } // RIGHT, KP_RIGHT else if (e.getKeyCode() == KeyEvent.VK_RIGHT || e.getKeyCode() == KeyEvent.VK_KP_RIGHT) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf() && BasicTreeUI.this.tree.isCollapsed(path)) { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } else { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(next, 0))); } } // Enter else if (e.getKeyCode() == KeyEvent.VK_ENTER) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf()) { if (BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } } } } } |
if (!last.isLeaf()) | if (!mod.isLeaf(last)) | public void keyPressed(KeyEvent e) { TreePath start = BasicTreeUI.this.tree.getLeadSelectionPath(); TreeNode last = null; if (start != null) last = (TreeNode) start.getLastPathComponent(); if (last != null) { // DOWN, KP_DOWN if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_KP_DOWN) { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) { TreePath newPath = new TreePath(getPathToRoot(next, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, newPath); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!next.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // UP, KP_UP else if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_KP_UP) { TreeNode prev = (TreeNode) BasicTreeUI.this. getPreviousVisibleNode(last); if (prev != null) { TreePath newPath = new TreePath(getPathToRoot(prev, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(prev, 0))); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!prev.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // LEFT, KP_LEFT else if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_KP_LEFT) { TreePath path = new TreePath(getPathToRoot(last, 0)); TreeNode p = last.getParent(); if (!last.isLeaf() && BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else if (p != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(p, 0))); } // RIGHT, KP_RIGHT else if (e.getKeyCode() == KeyEvent.VK_RIGHT || e.getKeyCode() == KeyEvent.VK_KP_RIGHT) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf() && BasicTreeUI.this.tree.isCollapsed(path)) { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } else { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(next, 0))); } } // Enter else if (e.getKeyCode() == KeyEvent.VK_ENTER) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf()) { if (BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } } } } } |
try { BasicTreeUI.this.tree.fireTreeWillExpand(path); } catch (ExpandVetoException ev) { } | public void keyPressed(KeyEvent e) { TreePath start = BasicTreeUI.this.tree.getLeadSelectionPath(); TreeNode last = null; if (start != null) last = (TreeNode) start.getLastPathComponent(); if (last != null) { // DOWN, KP_DOWN if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_KP_DOWN) { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) { TreePath newPath = new TreePath(getPathToRoot(next, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, newPath); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!next.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // UP, KP_UP else if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_KP_UP) { TreeNode prev = (TreeNode) BasicTreeUI.this. getPreviousVisibleNode(last); if (prev != null) { TreePath newPath = new TreePath(getPathToRoot(prev, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(prev, 0))); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!prev.isLeaf() && e.isShiftDown()) { BasicTreeUI.this.tree.expandPath(newPath); BasicTreeUI.this.tree.fireTreeExpanded(newPath); } } } // LEFT, KP_LEFT else if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_KP_LEFT) { TreePath path = new TreePath(getPathToRoot(last, 0)); TreeNode p = last.getParent(); if (!last.isLeaf() && BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else if (p != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(p, 0))); } // RIGHT, KP_RIGHT else if (e.getKeyCode() == KeyEvent.VK_RIGHT || e.getKeyCode() == KeyEvent.VK_KP_RIGHT) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf() && BasicTreeUI.this.tree.isCollapsed(path)) { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } else { TreeNode next = (TreeNode) BasicTreeUI.this. getNextVisibleNode(last); if (next != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, new TreePath(getPathToRoot(next, 0))); } } // Enter else if (e.getKeyCode() == KeyEvent.VK_ENTER) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf()) { if (BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } } } } } |
|
try { BasicTreeUI.this.tree.fireTreeWillExpand(path); } catch (ExpandVetoException ev) { } | public void mouseClicked(MouseEvent e) { Point click = e.getPoint(); int row = Math.round(click.y / BasicTreeUI.this.getRowHeight()); TreePath path = BasicTreeUI.this.getClosestPathForLocation(tree, click.x, click.y); if (path != null) { boolean inBounds = false; boolean cntlClick = false; Rectangle bounds = BasicTreeUI.this.getPathBounds( BasicTreeUI.this.tree, path); bounds.x -= rightChildIndent - 4; bounds.width += rightChildIndent + 4; if (bounds.contains(click.x, click.y)) inBounds = true; else if (BasicTreeUI.this.hasControlIcons() && (click.x < (bounds.x - rightChildIndent + 5) && click.x > (bounds.x - rightChildIndent - 5))) cntlClick = true; if ((inBounds || cntlClick) && BasicTreeUI.this.tree.isVisible(path)) { if (!cntlClick && !BasicTreeUI.this.isLeaf(row)) { Object cell = path.getLastPathComponent(); if (lastClicked != null && lastClicked.equals(cell)) clickCount = 2; else { lastClicked = cell; clickCount = 1; } } if (clickCount == 2 || cntlClick == true) { clickCount = 0; lastClicked = null; BasicTreeUI.this.tree.getSelectionModel().clearSelection(); if (BasicTreeUI.this.tree.isExpanded(path)) { BasicTreeUI.this.tree.collapsePath(path); BasicTreeUI.this.tree.fireTreeCollapsed(path); } else { BasicTreeUI.this.tree.expandPath(path); BasicTreeUI.this.tree.fireTreeExpanded(path); } } BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, path); } } } |
|
if (!tree.isRootVisible() && tree.isExpanded(new TreePath(mod.getRoot()))) return new Point(x + ((getLevel((TreeNode) node)) * rightChildIndent), y); | if (!tree.isRootVisible() && tree.isExpanded(new TreePath(mod.getRoot()))) return new Point(x + ((getLevel(node)) * rightChildIndent), y); | Point getCellLocation(int x, int y, JTree tree, TreeModel mod, Object node, Object startNode) { int rowHeight = getRowHeight(); if (startNode == null || startNode.equals(node)) { if (!tree.isRootVisible() && tree.isExpanded(new TreePath(mod.getRoot()))) return new Point(x + ((getLevel((TreeNode) node)) * rightChildIndent), y); return new Point(x + ((getLevel((TreeNode) node) + 1) * rightChildIndent), y); } if (!mod.isLeaf(startNode) && tree.isExpanded(new TreePath(getPathToRoot(((TreeNode) startNode), 0)))) { Object child = mod.getChild(startNode, 0); if (child != null) return getCellLocation(x, y + rowHeight, tree, mod, node, child); } return getCellLocation(x, y + rowHeight, tree, mod, node, getNextVisibleNode((TreeNode) startNode)); } |
return new Point(x + ((getLevel((TreeNode) node) + 1) * rightChildIndent), y); | return new Point(x + ((getLevel(node) + 1) * rightChildIndent), y); | Point getCellLocation(int x, int y, JTree tree, TreeModel mod, Object node, Object startNode) { int rowHeight = getRowHeight(); if (startNode == null || startNode.equals(node)) { if (!tree.isRootVisible() && tree.isExpanded(new TreePath(mod.getRoot()))) return new Point(x + ((getLevel((TreeNode) node)) * rightChildIndent), y); return new Point(x + ((getLevel((TreeNode) node) + 1) * rightChildIndent), y); } if (!mod.isLeaf(startNode) && tree.isExpanded(new TreePath(getPathToRoot(((TreeNode) startNode), 0)))) { Object child = mod.getChild(startNode, 0); if (child != null) return getCellLocation(x, y + rowHeight, tree, mod, node, child); } return getCellLocation(x, y + rowHeight, tree, mod, node, getNextVisibleNode((TreeNode) startNode)); } |
&& tree.isExpanded(new TreePath(getPathToRoot(((TreeNode) startNode), 0)))) | && tree.isExpanded(new TreePath(getPathToRoot(startNode, 0))) && mod.getChildCount(startNode) > 0) | Point getCellLocation(int x, int y, JTree tree, TreeModel mod, Object node, Object startNode) { int rowHeight = getRowHeight(); if (startNode == null || startNode.equals(node)) { if (!tree.isRootVisible() && tree.isExpanded(new TreePath(mod.getRoot()))) return new Point(x + ((getLevel((TreeNode) node)) * rightChildIndent), y); return new Point(x + ((getLevel((TreeNode) node) + 1) * rightChildIndent), y); } if (!mod.isLeaf(startNode) && tree.isExpanded(new TreePath(getPathToRoot(((TreeNode) startNode), 0)))) { Object child = mod.getChild(startNode, 0); if (child != null) return getCellLocation(x, y + rowHeight, tree, mod, node, child); } return getCellLocation(x, y + rowHeight, tree, mod, node, getNextVisibleNode((TreeNode) startNode)); } |
getNextVisibleNode((TreeNode) startNode)); | getNextVisibleNode(startNode)); | Point getCellLocation(int x, int y, JTree tree, TreeModel mod, Object node, Object startNode) { int rowHeight = getRowHeight(); if (startNode == null || startNode.equals(node)) { if (!tree.isRootVisible() && tree.isExpanded(new TreePath(mod.getRoot()))) return new Point(x + ((getLevel((TreeNode) node)) * rightChildIndent), y); return new Point(x + ((getLevel((TreeNode) node) + 1) * rightChildIndent), y); } if (!mod.isLeaf(startNode) && tree.isExpanded(new TreePath(getPathToRoot(((TreeNode) startNode), 0)))) { Object child = mod.getChild(startNode, 0); if (child != null) return getCellLocation(x, y + rowHeight, tree, mod, node, child); } return getCellLocation(x, y + rowHeight, tree, mod, node, getNextVisibleNode((TreeNode) startNode)); } |
public int getLevel(TreeNode node) | int getLevel(Object node) | public int getLevel(TreeNode node) { int count = -1; TreeNode current = node; do { current = current.getParent(); count++; } while (current != null); return count; } |
TreeNode current = node; | Object current = node; | public int getLevel(TreeNode node) { int count = -1; TreeNode current = node; do { current = current.getParent(); count++; } while (current != null); return count; } |
current = current.getParent(); | current = getParent(tree.getModel().getRoot(), current); | public int getLevel(TreeNode node) { int count = -1; TreeNode current = node; do { current = current.getParent(); count++; } while (current != null); return count; } |
TreeNode getNextNode(TreeNode curr) | Object getNextNode(Object curr) | TreeNode getNextNode(TreeNode curr) { if (curr.getChildCount() != 0) return curr.getChildAt(0); TreeNode node = curr; TreeNode sibling; do { sibling = getNextSibling(node); node = node.getParent(); } while (sibling == null && node != null); return sibling; } |
if (curr.getChildCount() != 0) return curr.getChildAt(0); | TreeModel mod = tree.getModel(); if (mod.getChildCount(curr) > 0) return mod.getChild(curr, 0); | TreeNode getNextNode(TreeNode curr) { if (curr.getChildCount() != 0) return curr.getChildAt(0); TreeNode node = curr; TreeNode sibling; do { sibling = getNextSibling(node); node = node.getParent(); } while (sibling == null && node != null); return sibling; } |
TreeNode node = curr; TreeNode sibling; | Object node = curr; Object sibling = null; | TreeNode getNextNode(TreeNode curr) { if (curr.getChildCount() != 0) return curr.getChildAt(0); TreeNode node = curr; TreeNode sibling; do { sibling = getNextSibling(node); node = node.getParent(); } while (sibling == null && node != null); return sibling; } |
node = node.getParent(); | node = getParent(mod.getRoot(), node); | TreeNode getNextNode(TreeNode curr) { if (curr.getChildCount() != 0) return curr.getChildAt(0); TreeNode node = curr; TreeNode sibling; do { sibling = getNextSibling(node); node = node.getParent(); } while (sibling == null && node != null); return sibling; } |
TreeNode getNextSibling(TreeNode node) | Object getNextSibling(Object node) | TreeNode getNextSibling(TreeNode node) { TreeNode parent = node.getParent(); if (parent == null) return null; int index = parent.getIndex(node) + 1; if (index == parent.getChildCount()) return null; return parent.getChildAt(index); } |
TreeNode parent = node.getParent(); | TreeModel mod = tree.getModel(); Object parent = getParent(mod.getRoot(), node); | TreeNode getNextSibling(TreeNode node) { TreeNode parent = node.getParent(); if (parent == null) return null; int index = parent.getIndex(node) + 1; if (index == parent.getChildCount()) return null; return parent.getChildAt(index); } |
int index = parent.getIndex(node) + 1; | int index = mod.getIndexOfChild(parent, node) + 1; | TreeNode getNextSibling(TreeNode node) { TreeNode parent = node.getParent(); if (parent == null) return null; int index = parent.getIndex(node) + 1; if (index == parent.getChildCount()) return null; return parent.getChildAt(index); } |
if (index == parent.getChildCount()) | if (index == 0 || index >= mod.getChildCount(parent)) | TreeNode getNextSibling(TreeNode node) { TreeNode parent = node.getParent(); if (parent == null) return null; int index = parent.getIndex(node) + 1; if (index == parent.getChildCount()) return null; return parent.getChildAt(index); } |
return parent.getChildAt(index); | return mod.getChild(parent, index); | TreeNode getNextSibling(TreeNode node) { TreeNode parent = node.getParent(); if (parent == null) return null; int index = parent.getIndex(node) + 1; if (index == parent.getChildCount()) return null; return parent.getChildAt(index); } |
TreeNode getNextVisibleNode(TreeNode node) | Object getNextVisibleNode(Object node) | TreeNode getNextVisibleNode(TreeNode node) { TreeNode next = null; TreePath current = null; if (node != null) next = getNextNode(node); if (next != null) { current = new TreePath(getPathToRoot(next, 0)); if (tree.isVisible(current)) return next; while (next != null && !tree.isVisible(current)) { next = getNextNode(next); if (next != null) current = new TreePath(getPathToRoot(next, 0)); } } return next; } |
TreeNode next = null; | Object next = null; | TreeNode getNextVisibleNode(TreeNode node) { TreeNode next = null; TreePath current = null; if (node != null) next = getNextNode(node); if (next != null) { current = new TreePath(getPathToRoot(next, 0)); if (tree.isVisible(current)) return next; while (next != null && !tree.isVisible(current)) { next = getNextNode(next); if (next != null) current = new TreePath(getPathToRoot(next, 0)); } } return next; } |
TreeNode root = (TreeNode) mod.getRoot(); if (!tree.isRootVisible() && tree.isExpanded(new TreePath(root))) | if (mod != null) { Object root = mod.getRoot(); if (!tree.isRootVisible() && tree.isExpanded(new TreePath(root))) | public Rectangle getPathBounds(JTree tree, TreePath path) { if (path != null) { Object cell = path.getLastPathComponent(); TreeModel mod = tree.getModel(); TreeNode root = (TreeNode) mod.getRoot(); if (!tree.isRootVisible() && tree.isExpanded(new TreePath(root))) root = getNextNode(root); Point loc = getCellLocation(0, 0, tree, mod, cell, root); return getCellBounds(loc.x, loc.y, cell); } return null; } |
} | public Rectangle getPathBounds(JTree tree, TreePath path) { if (path != null) { Object cell = path.getLastPathComponent(); TreeModel mod = tree.getModel(); TreeNode root = (TreeNode) mod.getRoot(); if (!tree.isRootVisible() && tree.isExpanded(new TreePath(root))) root = getNextNode(root); Point loc = getCellLocation(0, 0, tree, mod, cell, root); return getCellBounds(loc.x, loc.y, cell); } return null; } |
|
TreeNode node = ((TreeNode) (tree.getModel()).getRoot()); | TreeModel mod = tree.getModel(); if (mod != null) { Object node = mod.getRoot(); | public TreePath getPathForRow(JTree tree, int row) { TreeNode node = ((TreeNode) (tree.getModel()).getRoot()); if (!tree.isRootVisible() && tree.isExpanded(new TreePath(getPathToRoot(node, 0)))) node = getNextNode(node); for (int i = 0; i < row; i++) node = getNextVisibleNode(node); // in case nothing was found if (node == null) return null; // something was found return new TreePath(getPathToRoot(node, 0)); } |
return null; } | public TreePath getPathForRow(JTree tree, int row) { TreeNode node = ((TreeNode) (tree.getModel()).getRoot()); if (!tree.isRootVisible() && tree.isExpanded(new TreePath(getPathToRoot(node, 0)))) node = getNextNode(node); for (int i = 0; i < row; i++) node = getNextVisibleNode(node); // in case nothing was found if (node == null) return null; // something was found return new TreePath(getPathToRoot(node, 0)); } |
|
TreeNode[] getPathToRoot(TreeNode node, int depth) | Object[] getPathToRoot(Object node, int depth) | TreeNode[] getPathToRoot(TreeNode node, int depth) { if (node == null) { if (depth == 0) return null; return new TreeNode[depth]; } TreeNode[] path = getPathToRoot(node.getParent(), depth + 1); path[path.length - depth - 1] = node; return path; } |
return new TreeNode[depth]; | return new Object[depth]; | TreeNode[] getPathToRoot(TreeNode node, int depth) { if (node == null) { if (depth == 0) return null; return new TreeNode[depth]; } TreeNode[] path = getPathToRoot(node.getParent(), depth + 1); path[path.length - depth - 1] = node; return path; } |
TreeNode[] path = getPathToRoot(node.getParent(), depth + 1); | Object[] path = getPathToRoot(getParent(mod.getRoot(), node), depth + 1); | TreeNode[] getPathToRoot(TreeNode node, int depth) { if (node == null) { if (depth == 0) return null; return new TreeNode[depth]; } TreeNode[] path = getPathToRoot(node.getParent(), depth + 1); path[path.length - depth - 1] = node; return path; } |
TreeNode getPreviousNode(TreeNode node) | Object getPreviousNode(Object node) | TreeNode getPreviousNode(TreeNode node) { TreeNode parent = node.getParent(); if (parent == null) return null; TreeNode sibling = getPreviousSibling(node); if (sibling == null) return parent; int size = sibling.getChildCount(); while (size > 0) { sibling = sibling.getChildAt(size - 1); size = sibling.getChildCount(); } return sibling; } |
TreeNode parent = node.getParent(); | TreeModel mod = tree.getModel(); Object parent = getParent(mod.getRoot(), node); | TreeNode getPreviousNode(TreeNode node) { TreeNode parent = node.getParent(); if (parent == null) return null; TreeNode sibling = getPreviousSibling(node); if (sibling == null) return parent; int size = sibling.getChildCount(); while (size > 0) { sibling = sibling.getChildAt(size - 1); size = sibling.getChildCount(); } return sibling; } |
TreeNode sibling = getPreviousSibling(node); | Object sibling = getPreviousSibling(node); | TreeNode getPreviousNode(TreeNode node) { TreeNode parent = node.getParent(); if (parent == null) return null; TreeNode sibling = getPreviousSibling(node); if (sibling == null) return parent; int size = sibling.getChildCount(); while (size > 0) { sibling = sibling.getChildAt(size - 1); size = sibling.getChildCount(); } return sibling; } |
int size = sibling.getChildCount(); | int size = mod.getChildCount(sibling); | TreeNode getPreviousNode(TreeNode node) { TreeNode parent = node.getParent(); if (parent == null) return null; TreeNode sibling = getPreviousSibling(node); if (sibling == null) return parent; int size = sibling.getChildCount(); while (size > 0) { sibling = sibling.getChildAt(size - 1); size = sibling.getChildCount(); } return sibling; } |
sibling = sibling.getChildAt(size - 1); size = sibling.getChildCount(); | sibling = mod.getChild(sibling, size - 1); size = mod.getChildCount(sibling); | TreeNode getPreviousNode(TreeNode node) { TreeNode parent = node.getParent(); if (parent == null) return null; TreeNode sibling = getPreviousSibling(node); if (sibling == null) return parent; int size = sibling.getChildCount(); while (size > 0) { sibling = sibling.getChildAt(size - 1); size = sibling.getChildCount(); } return sibling; } |
TreeNode getPreviousSibling(TreeNode node) | Object getPreviousSibling(Object node) | TreeNode getPreviousSibling(TreeNode node) { TreeNode parent = node.getParent(); if (parent == null) return null; int index = parent.getIndex(node) - 1; if (index < 0) return null; return parent.getChildAt(index); } |
TreeNode parent = node.getParent(); | TreeModel mod = tree.getModel(); Object parent = getParent(mod.getRoot(), node); | TreeNode getPreviousSibling(TreeNode node) { TreeNode parent = node.getParent(); if (parent == null) return null; int index = parent.getIndex(node) - 1; if (index < 0) return null; return parent.getChildAt(index); } |
int index = parent.getIndex(node) - 1; | int index = mod.getIndexOfChild(parent, node) - 1; | TreeNode getPreviousSibling(TreeNode node) { TreeNode parent = node.getParent(); if (parent == null) return null; int index = parent.getIndex(node) - 1; if (index < 0) return null; return parent.getChildAt(index); } |
if (index < 0) | if (index < 0 || index >= mod.getChildCount(parent)) | TreeNode getPreviousSibling(TreeNode node) { TreeNode parent = node.getParent(); if (parent == null) return null; int index = parent.getIndex(node) - 1; if (index < 0) return null; return parent.getChildAt(index); } |
return parent.getChildAt(index); | return mod.getChild(parent, index); | TreeNode getPreviousSibling(TreeNode node) { TreeNode parent = node.getParent(); if (parent == null) return null; int index = parent.getIndex(node) - 1; if (index < 0) return null; return parent.getChildAt(index); } |
TreeNode getPreviousVisibleNode(TreeNode node) | Object getPreviousVisibleNode(Object node) | TreeNode getPreviousVisibleNode(TreeNode node) { TreeNode prev = null; TreePath current = null; if (node != null) prev = getPreviousNode(node); if (prev != null) { current = new TreePath(getPathToRoot(prev, 0)); if (tree.isVisible(current)) return prev; while (prev != null && !tree.isVisible(current)) { prev = getPreviousNode(prev); if (prev != null) current = new TreePath(getPathToRoot(prev, 0)); } } return prev; } |
TreeNode prev = null; | Object prev = null; | TreeNode getPreviousVisibleNode(TreeNode node) { TreeNode prev = null; TreePath current = null; if (node != null) prev = getPreviousNode(node); if (prev != null) { current = new TreePath(getPathToRoot(prev, 0)); if (tree.isVisible(current)) return prev; while (prev != null && !tree.isVisible(current)) { prev = getPreviousNode(prev); if (prev != null) current = new TreePath(getPathToRoot(prev, 0)); } } return prev; } |
TreeNode node = ((TreeNode) (tree.getModel()) .getRoot()); | TreeModel mod = tree.getModel(); int count = 0; if (mod != null) { Object node = mod.getRoot(); | public int getRowCount(JTree tree) { TreeNode node = ((TreeNode) (tree.getModel()) .getRoot()); if (!tree.isRootVisible() && tree.isExpanded(new TreePath((getPathToRoot(node, 0))))) node = getNextNode(node); int count = 0; while (node != null) { count++; node = getNextVisibleNode(node); } return count; } |
int count = 0; | public int getRowCount(JTree tree) { TreeNode node = ((TreeNode) (tree.getModel()) .getRoot()); if (!tree.isRootVisible() && tree.isExpanded(new TreePath((getPathToRoot(node, 0))))) node = getNextNode(node); int count = 0; while (node != null) { count++; node = getNextVisibleNode(node); } return count; } |
|
} | public int getRowCount(JTree tree) { TreeNode node = ((TreeNode) (tree.getModel()) .getRoot()); if (!tree.isRootVisible() && tree.isExpanded(new TreePath((getPathToRoot(node, 0))))) node = getNextNode(node); int count = 0; while (node != null) { count++; node = getNextVisibleNode(node); } return count; } |
|
if (treeModel != null) | protected void installListeners() { tree.addPropertyChangeListener(propertyChangeListener); tree.addFocusListener(focusListener); tree.addTreeSelectionListener(treeSelectionListener); tree.addMouseListener(mouseInputListener); tree.addKeyListener(keyListener); tree.addPropertyChangeListener(selectionModelPropertyChangeListener); tree.addComponentListener(componentListener); cellEditor.addCellEditorListener(cellEditorListener); tree.addTreeExpansionListener(treeExpansionListener); treeModel.addTreeModelListener(treeModelListener); } |
|
setModel(tree.getModel()); | TreeModel mod = tree.getModel(); setModel(mod); | public void installUI(JComponent c) { super.installUI(c); installDefaults((JTree) c); tree = (JTree) c; setModel(tree.getModel()); tree.setRootVisible(true); tree.expandPath(new TreePath(tree.getModel().getRoot())); treeSelectionModel = tree.getSelectionModel(); installListeners(); installKeyboardActions(); completeUIInstall(); } |
tree.expandPath(new TreePath(tree.getModel().getRoot())); | if (mod != null) tree.expandPath(new TreePath(mod.getRoot())); | public void installUI(JComponent c) { super.installUI(c); installDefaults((JTree) c); tree = (JTree) c; setModel(tree.getModel()); tree.setRootVisible(true); tree.expandPath(new TreePath(tree.getModel().getRoot())); treeSelectionModel = tree.getSelectionModel(); installListeners(); installKeyboardActions(); completeUIInstall(); } |
if (node instanceof TreeNode) return ((TreeNode) node).isLeaf(); else return true; | return tree.getModel().isLeaf(node); | protected boolean isLeaf(int row) { TreePath pathForRow = getPathForRow(tree, row); if (pathForRow == null) return true; Object node = pathForRow.getLastPathComponent(); if (node instanceof TreeNode) return ((TreeNode) node).isLeaf(); else return true; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.