rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
VMCompiler.enable();
public static void enable() { }
if (!(sigSpi instanceof Cloneable)) throw new CloneNotSupportedException();
public Object clone() throws CloneNotSupportedException { if (!(sigSpi instanceof Cloneable)) throw new CloneNotSupportedException(); Signature result = new DummySignature ((SignatureSpi) sigSpi.clone(), this.getAlgorithm()); result.provider = this.getProvider(); return result; }
if (layerNum.intValue() == layer.intValue())
int layerInt = layerNum.intValue(); if (layerInt == layer.intValue())
private int[] layerToRange (Integer layer) { int[] ret = new int[2]; ret[1] = getComponents ().length; Iterator i = layers.entrySet ().iterator (); while (i.hasNext()) { Map.Entry pair = (Map.Entry) i.next(); Integer layerNum = (Integer) pair.getKey (); Integer layerSz = (Integer) pair.getValue (); if (layerNum.intValue() == layer.intValue()) { ret[0] = ret[1] - layerSz.intValue (); return ret; } else { ret[1] -= layerSz.intValue (); } } // should have found the layer during iteration throw new IllegalArgumentException (); }
return ret;
break; } else if (layerInt > layer.intValue()) { ret[1] = ret[0]; break;
private int[] layerToRange (Integer layer) { int[] ret = new int[2]; ret[1] = getComponents ().length; Iterator i = layers.entrySet ().iterator (); while (i.hasNext()) { Map.Entry pair = (Map.Entry) i.next(); Integer layerNum = (Integer) pair.getKey (); Integer layerSz = (Integer) pair.getValue (); if (layerNum.intValue() == layer.intValue()) { ret[0] = ret[1] - layerSz.intValue (); return ret; } else { ret[1] -= layerSz.intValue (); } } // should have found the layer during iteration throw new IllegalArgumentException (); }
throw new IllegalArgumentException ();
return ret;
private int[] layerToRange (Integer layer) { int[] ret = new int[2]; ret[1] = getComponents ().length; Iterator i = layers.entrySet ().iterator (); while (i.hasNext()) { Map.Entry pair = (Map.Entry) i.next(); Integer layerNum = (Integer) pair.getKey (); Integer layerSz = (Integer) pair.getValue (); if (layerNum.intValue() == layer.intValue()) { ret[0] = ret[1] - layerSz.intValue (); return ret; } else { ret[1] -= layerSz.intValue (); } } // should have found the layer during iteration throw new IllegalArgumentException (); }
mapper.removeKeyStroke((String)functions.getSelectedValue());
mapper.removeKeyStroke(k);
private void removeIt() { if (!macros && !special) { mapper.removeKeyStroke(mnemonicData[functions.getSelectedIndex()]); strokeDesc.setText(mapper.getKeyStrokeDesc( mnemonicData[functions.getSelectedIndex()])); } else { if (macros) { mapper.removeKeyStroke((String)functions.getSelectedValue()); strokeDesc.setText(mapper.getKeyStrokeDesc( (String)functions.getSelectedValue())); } if (special) { String k = ""; k += ((String)functions.getSelectedValue()).charAt(7); mapper.removeKeyStroke((String)functions.getSelectedValue()); strokeDesc.setText(mapper.getKeyStrokeDesc( (String)functions.getSelectedValue())); } } mods = true; }
valueClass = getFormattedTextField().getValue().getClass();
{ JFormattedTextField jft = getFormattedTextField(); if (jft != null) valueClass = jft.getValue().getClass(); }
public Object stringToValue(String string) throws ParseException { Object value = string; Class valueClass = getValueClass(); if (valueClass == null) valueClass = getFormattedTextField().getValue().getClass(); if (valueClass != null) try { Constructor constr = valueClass.getConstructor (new Class[]{String.class}); value = constr.newInstance(new Object[]{ string }); } catch (NoSuchMethodException ex) { // leave value as string } catch (Exception ex) { throw new ParseException(string, 0); } return value; }
return super.clone();
return new MacAdapter((IMac) mac.clone(), new HashMap(attributes));
public Object clone() throws CloneNotSupportedException { return super.clone(); }
lm.addElement(macrosList[x]);
macrosVector.add(macrosList[x]);
private void loadList(String which) { lm.clear(); lm.removeAllElements(); if (which.equals(LangTool.getString("key.labelKeys"))) { Vector lk = new Vector(mnemonicData.length); for (int x = 0; x < mnemonicData.length; x++) { lk.addElement(new KeyDescription(LangTool.getString("key."+mnemonicData[x]),x)); } Collections.sort(lk,new KeyDescriptionCompare()); for (int x = 0; x < mnemonicData.length; x++) {// lm.addElement(LangTool.getString("key."+mnemonicData[x])); lm.addElement(lk.get(x)); } macros = false; special = false; } else { if (which.equals(LangTool.getString("key.labelMacros"))) { if (macrosList != null) for (int x = 0; x < macrosList.length; x++) { lm.addElement(macrosList[x]); } macros = true; special = false; } else { // we will use a collator here so that we can take advantage of the locales Collator collator = Collator.getInstance(); CollationKey key = null; StringBuffer sb = new StringBuffer(); Set set = new TreeSet(); for (int x =0;x < 256; x++) { char c = codePage.ebcdic2uni(x); char ac = codePage.getASCIIChar(x); if (!Character.isISOControl(c)) { sb.setLength(0); if (Integer.toHexString(ac).length() == 1){ sb.append("0x0" + Integer.toHexString(ac).toUpperCase()); } else { sb.append("0x" + Integer.toHexString(ac).toUpperCase()); } sb.append(" - " + c + " - " + getUnicodeString(c)); key = collator.getCollationKey(sb.toString()); set.add(key); } } Iterator iterator = set.iterator(); while (iterator.hasNext()) { CollationKey keyc = (CollationKey)iterator.next(); lm.addElement(keyc.getSourceString()); } macros = false; special = true; } } if (!lm.isEmpty()) functions.setSelectedIndex(0); }
scriptDir("scripts",macrosVector); loadListModel(lm,macrosVector,null,0);
private void loadList(String which) { lm.clear(); lm.removeAllElements(); if (which.equals(LangTool.getString("key.labelKeys"))) { Vector lk = new Vector(mnemonicData.length); for (int x = 0; x < mnemonicData.length; x++) { lk.addElement(new KeyDescription(LangTool.getString("key."+mnemonicData[x]),x)); } Collections.sort(lk,new KeyDescriptionCompare()); for (int x = 0; x < mnemonicData.length; x++) {// lm.addElement(LangTool.getString("key."+mnemonicData[x])); lm.addElement(lk.get(x)); } macros = false; special = false; } else { if (which.equals(LangTool.getString("key.labelMacros"))) { if (macrosList != null) for (int x = 0; x < macrosList.length; x++) { lm.addElement(macrosList[x]); } macros = true; special = false; } else { // we will use a collator here so that we can take advantage of the locales Collator collator = Collator.getInstance(); CollationKey key = null; StringBuffer sb = new StringBuffer(); Set set = new TreeSet(); for (int x =0;x < 256; x++) { char c = codePage.ebcdic2uni(x); char ac = codePage.getASCIIChar(x); if (!Character.isISOControl(c)) { sb.setLength(0); if (Integer.toHexString(ac).length() == 1){ sb.append("0x0" + Integer.toHexString(ac).toUpperCase()); } else { sb.append("0x" + Integer.toHexString(ac).toUpperCase()); } sb.append(" - " + c + " - " + getUnicodeString(c)); key = collator.getCollationKey(sb.toString()); set.add(key); } } Iterator iterator = set.iterator(); while (iterator.hasNext()) { CollationKey keyc = (CollationKey)iterator.next(); lm.addElement(keyc.getSourceString()); } macros = false; special = true; } } if (!lm.isEmpty()) functions.setSelectedIndex(0); }
function = ((KeyDescription)functions.getSelectedValue()).toString();
if (functions.getSelectedValue() instanceof Macro) { function = ((Macro)functions.getSelectedValue()).toString(); } else function = ((KeyDescription)functions.getSelectedValue()).toString();
private void mapIt() { Object[] message = new Object[1]; JPanel kgp = new JPanel(); final KeyGetter kg = new KeyGetter(); kg.setForeground(Color.blue); message[0] = kgp; String function; if (functions.getSelectedValue() instanceof String) function = (String)functions.getSelectedValue(); else function = ((KeyDescription)functions.getSelectedValue()).toString(); kg.setText(LangTool.getString("key.labelMessage") + function); kgp.add(kg); String[] options = new String[1]; options[0] = LangTool.getString("key.labelClose"); JPanel kp = new JPanel(); JOptionPane opain = new JOptionPane(message, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, // option type null, options, options[0]); dialog = opain.createDialog(this, getTitle()); // add window listener to the dialog so that we can place focus on the // key getter label instead of default and set the new key value when // the window is closed. dialog.addWindowListener(new WindowAdapter() { boolean gotFocus = false; public void windowClosed(WindowEvent we) { setNewKeyStrokes(kg.keyevent); } public void windowActivated(WindowEvent we) { // Once window gets focus, set initial focus to our KeyGetter // component if (!gotFocus) { kg.grabFocus(); gotFocus = true; } } }); dialog.setVisible(true); }
mapper.removeKeyStroke((String)functions.getSelectedValue());
Object o = functions.getSelectedValue(); String name; if (o instanceof Macro) { name = ((Macro)o).getFullName(); } else { name = (String)o; } mapper.removeKeyStroke(name);
private void removeIt() { if (!macros && !special) { int index = ((KeyDescription)functions.getSelectedValue()).getIndex(); mapper.removeKeyStroke(mnemonicData[index]); strokeDesc.setText(mapper.getKeyStrokeDesc( mnemonicData[index])); } else { if (macros) { mapper.removeKeyStroke((String)functions.getSelectedValue()); strokeDesc.setText(mapper.getKeyStrokeDesc( (String)functions.getSelectedValue())); } if (special) { String k = ""; k += ((String)functions.getSelectedValue()).charAt(7); mapper.removeKeyStroke(k); strokeDesc.setText(mapper.getKeyStrokeDesc( (String)functions.getSelectedValue())); } } mods = true; }
(String)functions.getSelectedValue()));
name));
private void removeIt() { if (!macros && !special) { int index = ((KeyDescription)functions.getSelectedValue()).getIndex(); mapper.removeKeyStroke(mnemonicData[index]); strokeDesc.setText(mapper.getKeyStrokeDesc( mnemonicData[index])); } else { if (macros) { mapper.removeKeyStroke((String)functions.getSelectedValue()); strokeDesc.setText(mapper.getKeyStrokeDesc( (String)functions.getSelectedValue())); } if (special) { String k = ""; k += ((String)functions.getSelectedValue()).charAt(7); mapper.removeKeyStroke(k); strokeDesc.setText(mapper.getKeyStrokeDesc( (String)functions.getSelectedValue())); } } mods = true; }
System.out.println((String)lm.getElementAt(index)); strokeDesc.setText(mapper.getKeyStrokeDesc((String)lm.getElementAt(index)));
Object o = lm.getElementAt(index); if (o instanceof String) { System.out.println((String)o); strokeDesc.setText(mapper.getKeyStrokeDesc((String)o)); } else if (o instanceof Macro) { Macro m = (Macro)o; strokeDesc.setText(mapper.getKeyStrokeDesc(m.getFullName())); }
private void setKeyDescription(int index) { // This try and catch is to fix a problem in JDK1.4-betas try { if (!macros && !special) { KeyDescription kd = (KeyDescription)lm.getElementAt(index); strokeDesc.setText(mapper.getKeyStrokeDesc(mnemonicData[kd.getIndex()])); } else { if (macros) { System.out.println((String)lm.getElementAt(index)); strokeDesc.setText(mapper.getKeyStrokeDesc((String)lm.getElementAt(index))); } if (special) { System.out.println((String)lm.getElementAt(index)); String k = ""; k += ((String)lm.getElementAt(index)).charAt(7); strokeDesc.setText(mapper.getKeyStrokeDesc(k)); } } } catch (ArrayIndexOutOfBoundsException ar) { System.out.println("ar at index " + index + " - " + ar.getMessage()); } }
System.out.println((String)functions.getSelectedValue());
Object o = functions.getSelectedValue(); String macro; if (o instanceof Macro) macro = ((Macro)o).getFullName(); else macro = (String)o; System.out.println(macro);
private void setNewKeyStrokes(KeyEvent ke) { if (!macros && !special) { int index = ((KeyDescription)functions.getSelectedValue()).getIndex(); if (isLinux) mapper.setKeyStroke(mnemonicData[index],ke,isAltGr); else mapper.setKeyStroke(mnemonicData[index],ke); strokeDesc.setText(mapper.getKeyStrokeDesc( mnemonicData[index])); } else { if (macros) { System.out.println((String)functions.getSelectedValue()); if (isLinux) mapper.setKeyStroke((String)functions.getSelectedValue(),ke,isAltGr); else mapper.setKeyStroke((String)functions.getSelectedValue(),ke); strokeDesc.setText(mapper.getKeyStrokeDesc( (String)functions.getSelectedValue())); } if (special) { System.out.println((String)functions.getSelectedValue()); String k = ""; k += ((String)functions.getSelectedValue()).charAt(7); mapper.removeKeyStroke(k); if (isLinux) { mapper.setKeyStroke(k,ke,isAltGr); } else { mapper.setKeyStroke(k,ke); } strokeDesc.setText(mapper.getKeyStrokeDesc(k)); } } mods = true; }
mapper.setKeyStroke((String)functions.getSelectedValue(),ke,isAltGr);
mapper.setKeyStroke(macro,ke,isAltGr);
private void setNewKeyStrokes(KeyEvent ke) { if (!macros && !special) { int index = ((KeyDescription)functions.getSelectedValue()).getIndex(); if (isLinux) mapper.setKeyStroke(mnemonicData[index],ke,isAltGr); else mapper.setKeyStroke(mnemonicData[index],ke); strokeDesc.setText(mapper.getKeyStrokeDesc( mnemonicData[index])); } else { if (macros) { System.out.println((String)functions.getSelectedValue()); if (isLinux) mapper.setKeyStroke((String)functions.getSelectedValue(),ke,isAltGr); else mapper.setKeyStroke((String)functions.getSelectedValue(),ke); strokeDesc.setText(mapper.getKeyStrokeDesc( (String)functions.getSelectedValue())); } if (special) { System.out.println((String)functions.getSelectedValue()); String k = ""; k += ((String)functions.getSelectedValue()).charAt(7); mapper.removeKeyStroke(k); if (isLinux) { mapper.setKeyStroke(k,ke,isAltGr); } else { mapper.setKeyStroke(k,ke); } strokeDesc.setText(mapper.getKeyStrokeDesc(k)); } } mods = true; }
mapper.setKeyStroke((String)functions.getSelectedValue(),ke);
mapper.setKeyStroke(macro,ke);
private void setNewKeyStrokes(KeyEvent ke) { if (!macros && !special) { int index = ((KeyDescription)functions.getSelectedValue()).getIndex(); if (isLinux) mapper.setKeyStroke(mnemonicData[index],ke,isAltGr); else mapper.setKeyStroke(mnemonicData[index],ke); strokeDesc.setText(mapper.getKeyStrokeDesc( mnemonicData[index])); } else { if (macros) { System.out.println((String)functions.getSelectedValue()); if (isLinux) mapper.setKeyStroke((String)functions.getSelectedValue(),ke,isAltGr); else mapper.setKeyStroke((String)functions.getSelectedValue(),ke); strokeDesc.setText(mapper.getKeyStrokeDesc( (String)functions.getSelectedValue())); } if (special) { System.out.println((String)functions.getSelectedValue()); String k = ""; k += ((String)functions.getSelectedValue()).charAt(7); mapper.removeKeyStroke(k); if (isLinux) { mapper.setKeyStroke(k,ke,isAltGr); } else { mapper.setKeyStroke(k,ke); } strokeDesc.setText(mapper.getKeyStrokeDesc(k)); } } mods = true; }
(String)functions.getSelectedValue()));
macro));
private void setNewKeyStrokes(KeyEvent ke) { if (!macros && !special) { int index = ((KeyDescription)functions.getSelectedValue()).getIndex(); if (isLinux) mapper.setKeyStroke(mnemonicData[index],ke,isAltGr); else mapper.setKeyStroke(mnemonicData[index],ke); strokeDesc.setText(mapper.getKeyStrokeDesc( mnemonicData[index])); } else { if (macros) { System.out.println((String)functions.getSelectedValue()); if (isLinux) mapper.setKeyStroke((String)functions.getSelectedValue(),ke,isAltGr); else mapper.setKeyStroke((String)functions.getSelectedValue(),ke); strokeDesc.setText(mapper.getKeyStrokeDesc( (String)functions.getSelectedValue())); } if (special) { System.out.println((String)functions.getSelectedValue()); String k = ""; k += ((String)functions.getSelectedValue()).charAt(7); mapper.removeKeyStroke(k); if (isLinux) { mapper.setKeyStroke(k,ke,isAltGr); } else { mapper.setKeyStroke(k,ke); } strokeDesc.setText(mapper.getKeyStrokeDesc(k)); } } mods = true; }
public DataFormat getDatatype()
public String getDatatype()
public DataFormat getDatatype() { return (DataFormat) ((XMLAttribute) attribHash.get("axisDatatype")).getAttribValue(); }
return (DataFormat) ((XMLAttribute) attribHash.get("axisDatatype")).getAttribValue();
return (String) ((XMLAttribute) attribHash.get("axisDatatype")).getAttribValue();
public DataFormat getDatatype() { return (DataFormat) ((XMLAttribute) attribHash.get("axisDatatype")).getAttribValue(); }
attribHash.put("axisDatatype",new XMLAttribute(new StringDataFormat(), Constants.STRING_TYPE));
attribHash.put("axisDatatype",new XMLAttribute(null, Constants.STRING_TYPE));
private void init() { classXDFNodeName = "axis"; // order matters! these are in *reverse* order of their // occurence in the XDF DTD attribOrder.add(0,"valueList"); attribOrder.add(0,"axisIdRef"); attribOrder.add(0,"axisId"); attribOrder.add(0,"align"); //not sure what it is??? attribOrder.add(0,"axisUnits"); attribOrder.add(0,"axisDatatype"); attribOrder.add(0,"description"); attribOrder.add(0,"name"); //set up the attribute hashtable key with the default initial value //set the minimum array size(essentially the size of the axis) attribHash.put("valueList", new XMLAttribute(Collections.synchronizedList(new ArrayList(super.sDefaultDataArraySize)), Constants.LIST_TYPE)); attribHash.put("axisIdRef", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("axisId", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("aligh", new XMLAttribute(null, Constants.STRING_TYPE)); //double check??? //set up the axisUnits attribute Units unitsObj = new Units(); attribHash.put("axisUnits", new XMLAttribute(unitsObj, Constants.OBJECT_TYPE)); unitsObj.setXDFNodeName("axisUnits"); attribHash.put("axisDatatype",new XMLAttribute(new StringDataFormat(), Constants.STRING_TYPE)); attribHash.put("description", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("name", new XMLAttribute(null, Constants.STRING_TYPE)); length = 0; }
public DataFormat setDatatype(DataFormat datatype)
public String setDatatype(String strDatatype)
public DataFormat setDatatype(DataFormat datatype) { return (DataFormat) ((XMLAttribute) attribHash.get("axisDatatype")).setAttribValue(datatype); }
return (DataFormat) ((XMLAttribute) attribHash.get("axisDatatype")).setAttribValue(datatype);
if (Utility.isValidDatatype(strDatatype)) return (String) ((XMLAttribute) attribHash.get("axisDatatype")).setAttribValue(strDatatype); else return null;
public DataFormat setDatatype(DataFormat datatype) { return (DataFormat) ((XMLAttribute) attribHash.get("axisDatatype")).setAttribValue(datatype); }
public QName(String namespaceURI, String localPart, String prefix)
public QName(String namespaceURI, String localPart)
public QName(String namespaceURI, String localPart, String prefix) { if (namespaceURI == null) { namespaceURI = XMLConstants.NULL_NS_URI; } if (localPart == null) { throw new IllegalArgumentException(); } if (prefix == null) { prefix = XMLConstants.DEFAULT_NS_PREFIX; } this.namespaceURI = namespaceURI; this.localPart = localPart; this.prefix = prefix; StringBuffer buf = new StringBuffer(); if (namespaceURI != null && namespaceURI.length() > 0) { buf.append('{'); buf.append(namespaceURI); buf.append('}'); } if (prefix != null && prefix.length() > 0) { buf.append(prefix); buf.append(':'); } buf.append(localPart); qName = buf.toString(); }
if (namespaceURI == null) { namespaceURI = XMLConstants.NULL_NS_URI; } if (localPart == null) { throw new IllegalArgumentException(); } if (prefix == null) { prefix = XMLConstants.DEFAULT_NS_PREFIX; } this.namespaceURI = namespaceURI; this.localPart = localPart; this.prefix = prefix; StringBuffer buf = new StringBuffer(); if (namespaceURI != null && namespaceURI.length() > 0) { buf.append('{'); buf.append(namespaceURI); buf.append('}'); } if (prefix != null && prefix.length() > 0) { buf.append(prefix); buf.append(':'); } buf.append(localPart); qName = buf.toString();
this(namespaceURI, localPart, null);
public QName(String namespaceURI, String localPart, String prefix) { if (namespaceURI == null) { namespaceURI = XMLConstants.NULL_NS_URI; } if (localPart == null) { throw new IllegalArgumentException(); } if (prefix == null) { prefix = XMLConstants.DEFAULT_NS_PREFIX; } this.namespaceURI = namespaceURI; this.localPart = localPart; this.prefix = prefix; StringBuffer buf = new StringBuffer(); if (namespaceURI != null && namespaceURI.length() > 0) { buf.append('{'); buf.append(namespaceURI); buf.append('}'); } if (prefix != null && prefix.length() > 0) { buf.append(prefix); buf.append(':'); } buf.append(localPart); qName = buf.toString(); }
int numberFileCopyed = 0;
int numberFileCopied = 0;
private int copyDir() throws Exception { final File dstDir = new File(_fileDst.getAbsoluteFile() + File.separator);//+_fileSrc.getName()+File.separator); final File[] subFile = _fileSrc.listFiles(); int numberFileCopyed = 0; if (!dstDir.exists()) { if (!dstDir.mkdir()) { System.err.println(_fileDst.getParentFile().getAbsolutePath() + " cannot create "); return 0; } } for (int i = 0; i < subFile.length; i++) { final String name = subFile[ i].getName(); if (name.equals(".") || name.equals("..")) continue; File subDstDir = new File(dstDir.getAbsoluteFile() + File.separator + name); CpCommand cp = new CpCommand(subFile[ i], subDstDir, _mode, _recursive, _verbose); numberFileCopyed += cp.copy(); } return numberFileCopyed; }
numberFileCopyed += cp.copy();
numberFileCopied += cp.copy();
private int copyDir() throws Exception { final File dstDir = new File(_fileDst.getAbsoluteFile() + File.separator);//+_fileSrc.getName()+File.separator); final File[] subFile = _fileSrc.listFiles(); int numberFileCopyed = 0; if (!dstDir.exists()) { if (!dstDir.mkdir()) { System.err.println(_fileDst.getParentFile().getAbsolutePath() + " cannot create "); return 0; } } for (int i = 0; i < subFile.length; i++) { final String name = subFile[ i].getName(); if (name.equals(".") || name.equals("..")) continue; File subDstDir = new File(dstDir.getAbsoluteFile() + File.separator + name); CpCommand cp = new CpCommand(subFile[ i], subDstDir, _mode, _recursive, _verbose); numberFileCopyed += cp.copy(); } return numberFileCopyed; }
return numberFileCopyed;
return numberFileCopied;
private int copyDir() throws Exception { final File dstDir = new File(_fileDst.getAbsoluteFile() + File.separator);//+_fileSrc.getName()+File.separator); final File[] subFile = _fileSrc.listFiles(); int numberFileCopyed = 0; if (!dstDir.exists()) { if (!dstDir.mkdir()) { System.err.println(_fileDst.getParentFile().getAbsolutePath() + " cannot create "); return 0; } } for (int i = 0; i < subFile.length; i++) { final String name = subFile[ i].getName(); if (name.equals(".") || name.equals("..")) continue; File subDstDir = new File(dstDir.getAbsoluteFile() + File.separator + name); CpCommand cp = new CpCommand(subFile[ i], subDstDir, _mode, _recursive, _verbose); numberFileCopyed += cp.copy(); } return numberFileCopyed; }
int nbCopyedFile = cpCommand.copy(); System.out.println(nbCopyedFile + " file(s) copied");
int nbCopiedFile = cpCommand.copy(); System.out.println(nbCopiedFile + " file(s) copied");
public static void main(String[] args) throws Exception { CpCommand cpCommand = new CpCommand(args); int nbCopyedFile = cpCommand.copy(); System.out.println(nbCopyedFile + " file(s) copied"); }
if (providers == null)
if (providers != null)
public static Enumeration getSaslClientFactories() { Vector result = new Vector(); HashSet names = new HashSet(); Provider[] providers = Security.getProviders(); Iterator it; if (providers == null) { Provider p; String key; for (int i = 0; i < providers.length; i++) { p = providers[i]; for (it = p.keySet().iterator(); it.hasNext(); ) { key = (String) it.next(); // add key's binding (a) it is a class of a client factory, // and (b) the key does not include blanks if (key.startsWith(CLIENT_FACTORY_SVC) && key.indexOf(" ") == -1) { names.add(p.getProperty(key)); break; } } } } // we have the factory class names in names; instantiate and enumerate String c; for (it = names.iterator(); it.hasNext(); ) { c = (String) it.next(); try { SaslClientFactory f = (SaslClientFactory) Class.forName(c).newInstance(); if (f != null) result.add(f); } catch (ClassCastException ignored) { // ignore instantiation exceptions } catch (ClassNotFoundException ignored) { } catch (InstantiationException ignored) { } catch (IllegalAccessException ignored) { } } return result.elements(); }
if (providers == null)
if (providers != null)
public static Enumeration getSaslServerFactories() { Vector result = new Vector(); HashSet names = new HashSet(); Provider[] providers = Security.getProviders(); Iterator it; if (providers == null) { Provider p; String key; for (int i = 0; i < providers.length; i++) { p = providers[i]; for (it = p.keySet().iterator(); it.hasNext(); ) { key = (String) it.next(); // add key's binding (a) it is a class of a server factory, // and (b) the key does not include blanks if (key.startsWith(SERVER_FACTORY_SVC) && key.indexOf(" ") == -1) { names.add(p.getProperty(key)); break; } } } } // we have the factory class names in names; instantiate and enumerate String c; for (it = names.iterator(); it.hasNext(); ) { c = (String) it.next(); try { SaslServerFactory f = (SaslServerFactory) Class.forName(c).newInstance(); if (f != null) result.add(f); } catch (ClassCastException ignored) // ignore instantiation exceptions { } catch (ClassNotFoundException ignored) { } catch (InstantiationException ignored) { } catch (IllegalAccessException ignored) { } } return result.elements(); }
public void connect(Remote remote, Remote remote1)
public void connect(Remote a_target, Remote a_source)
public void connect(Remote remote, Remote remote1) throws RemoteException { throw new Error("Not implemented for PortableRemoteObjectDelegateImpl"); }
throw new Error("Not implemented for PortableRemoteObjectDelegateImpl");
ORB orb = null; POA poa = null; boolean ok = false; try { if (a_source instanceof Servant) { Servant s = (Servant) a_source; orb = s._orb(); poa = s._poa(); ok = true;
public void connect(Remote remote, Remote remote1) throws RemoteException { throw new Error("Not implemented for PortableRemoteObjectDelegateImpl"); }
if (!ok && a_source instanceof ObjectImpl) { ObjectImpl o = (ObjectImpl) a_source; orb = o._orb(); ok = true; try { if (orb instanceof ORB_1_4) { ORB_1_4 xorb = (ORB_1_4) orb; Delegate d = o._get_delegate(); if (d instanceof LocalDelegate) { LocalDelegate l = (LocalDelegate) d; poa = l.poa; } else if (d instanceof Simple_delegate) { byte[] ior_key = ((Simple_delegate) d).getIor().key; activeObjectMap.Obj ref = xorb.rootPOA.findIorKey(ior_key); if (ref != null) poa = ref.poa; } } } catch (Exception ex) { } } } catch (Exception ex) { RuntimeException rex = new RuntimeException("Unable to get info from " + a_source); rex.initCause(ex); throw rex; } if (!ok && a_source instanceof Tie) { Tie t = (Tie) a_source; orb = t.orb(); poa = null; ok = true; } if (orb == null) throw new RemoteException("Unable to determine ORB from " + a_source); if (a_target instanceof Stub) { StubDelegateImpl.connect((Stub) a_target, orb, poa); } else if (a_target instanceof Servant) { try { if (poa == null) { poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); if (poa.the_POAManager().get_state().value() == State._HOLDING) poa.the_POAManager().activate(); } poa.servant_to_reference((Servant) a_target); } catch (Exception ex) { throw new Unexpected(ex); } } else if (a_target instanceof org.omg.CORBA.Object) { orb.connect((org.omg.CORBA.Object) a_target); } else if (a_target instanceof Tie) { ((Tie) a_target).orb(orb); } }
public void connect(Remote remote, Remote remote1) throws RemoteException { throw new Error("Not implemented for PortableRemoteObjectDelegateImpl"); }
PortableServer.exportObject(obj);
if (obj instanceof Stub) Util.registerTarget(StubDelegateImpl.getTieFromStub((Stub) obj), obj); else if (obj instanceof Tie) { Tie t = (Tie) obj; Util.registerTarget(t, null); }
public void exportObject(Remote obj) throws RemoteException { PortableServer.exportObject(obj); }
if (narrowFrom == null)
else if (narrowFrom == null)
public Object narrow(Object narrowFrom, Class narrowTo) throws ClassCastException { if (narrowTo == null) throw new ClassCastException("Can't narrow to null class"); if (narrowFrom == null) return null; Class fromClass = narrowFrom.getClass(); Object result = null; try { if (narrowTo.isAssignableFrom(fromClass)) result = narrowFrom; else { System.out.println("We still haven't implement this case: narrow " + narrowFrom + " of type " + fromClass + " to " + narrowTo); Class[] cs = fromClass.getInterfaces(); for (int i = 0; i < cs.length; i++) System.out.println(cs[i]); Exception e1 = new Exception(); try { throw e1; } catch(Exception ee) { ee.printStackTrace(); } System.exit(2); //throw new Error("We still haven't implement this case: narrow " // + narrowFrom + " of type " + fromClass + " to " // + narrowTo); /* ObjectImpl objimpl = (ObjectImpl)narrowFrom; if(objimpl._is_a(PortableServer.getTypeName(narrowTo))) result = PortableServer.getStubFromObjectImpl(objimpl, narrowTo); */ } } catch(Exception e) { result = null; } if (result == null) throw new ClassCastException("Can't narrow from " + fromClass + " to " + narrowTo); return result; }
Class fromClass = narrowFrom.getClass(); Object result = null;
String interf = narrowTo.getName(); String stubClassName; stubClassName = getStubClassName(interf);
public Object narrow(Object narrowFrom, Class narrowTo) throws ClassCastException { if (narrowTo == null) throw new ClassCastException("Can't narrow to null class"); if (narrowFrom == null) return null; Class fromClass = narrowFrom.getClass(); Object result = null; try { if (narrowTo.isAssignableFrom(fromClass)) result = narrowFrom; else { System.out.println("We still haven't implement this case: narrow " + narrowFrom + " of type " + fromClass + " to " + narrowTo); Class[] cs = fromClass.getInterfaces(); for (int i = 0; i < cs.length; i++) System.out.println(cs[i]); Exception e1 = new Exception(); try { throw e1; } catch(Exception ee) { ee.printStackTrace(); } System.exit(2); //throw new Error("We still haven't implement this case: narrow " // + narrowFrom + " of type " + fromClass + " to " // + narrowTo); /* ObjectImpl objimpl = (ObjectImpl)narrowFrom; if(objimpl._is_a(PortableServer.getTypeName(narrowTo))) result = PortableServer.getStubFromObjectImpl(objimpl, narrowTo); */ } } catch(Exception e) { result = null; } if (result == null) throw new ClassCastException("Can't narrow from " + fromClass + " to " + narrowTo); return result; }
if (narrowTo.isAssignableFrom(fromClass)) result = narrowFrom; else
narrowTo = Util.loadClass(stubClassName, null, narrowTo.getClassLoader()); } catch (ClassNotFoundException e)
public Object narrow(Object narrowFrom, Class narrowTo) throws ClassCastException { if (narrowTo == null) throw new ClassCastException("Can't narrow to null class"); if (narrowFrom == null) return null; Class fromClass = narrowFrom.getClass(); Object result = null; try { if (narrowTo.isAssignableFrom(fromClass)) result = narrowFrom; else { System.out.println("We still haven't implement this case: narrow " + narrowFrom + " of type " + fromClass + " to " + narrowTo); Class[] cs = fromClass.getInterfaces(); for (int i = 0; i < cs.length; i++) System.out.println(cs[i]); Exception e1 = new Exception(); try { throw e1; } catch(Exception ee) { ee.printStackTrace(); } System.exit(2); //throw new Error("We still haven't implement this case: narrow " // + narrowFrom + " of type " + fromClass + " to " // + narrowTo); /* ObjectImpl objimpl = (ObjectImpl)narrowFrom; if(objimpl._is_a(PortableServer.getTypeName(narrowTo))) result = PortableServer.getStubFromObjectImpl(objimpl, narrowTo); */ } } catch(Exception e) { result = null; } if (result == null) throw new ClassCastException("Can't narrow from " + fromClass + " to " + narrowTo); return result; }
System.out.println("We still haven't implement this case: narrow " + narrowFrom + " of type " + fromClass + " to " + narrowTo); Class[] cs = fromClass.getInterfaces(); for (int i = 0; i < cs.length; i++) System.out.println(cs[i]); Exception e1 = new Exception(); try { throw e1; } catch(Exception ee) { ee.printStackTrace(); } System.exit(2);
ClassCastException cex = new ClassCastException("Class not found: " + stubClassName); cex.initCause(e); throw cex;
public Object narrow(Object narrowFrom, Class narrowTo) throws ClassCastException { if (narrowTo == null) throw new ClassCastException("Can't narrow to null class"); if (narrowFrom == null) return null; Class fromClass = narrowFrom.getClass(); Object result = null; try { if (narrowTo.isAssignableFrom(fromClass)) result = narrowFrom; else { System.out.println("We still haven't implement this case: narrow " + narrowFrom + " of type " + fromClass + " to " + narrowTo); Class[] cs = fromClass.getInterfaces(); for (int i = 0; i < cs.length; i++) System.out.println(cs[i]); Exception e1 = new Exception(); try { throw e1; } catch(Exception ee) { ee.printStackTrace(); } System.exit(2); //throw new Error("We still haven't implement this case: narrow " // + narrowFrom + " of type " + fromClass + " to " // + narrowTo); /* ObjectImpl objimpl = (ObjectImpl)narrowFrom; if(objimpl._is_a(PortableServer.getTypeName(narrowTo))) result = PortableServer.getStubFromObjectImpl(objimpl, narrowTo); */ } } catch(Exception e) { result = null; } if (result == null) throw new ClassCastException("Can't narrow from " + fromClass + " to " + narrowTo); return result; }
result = null;
ClassCastException cex = new ClassCastException("Cannot instantiate " + narrowTo.getName()); cex.initCause(e); throw cex;
public Object narrow(Object narrowFrom, Class narrowTo) throws ClassCastException { if (narrowTo == null) throw new ClassCastException("Can't narrow to null class"); if (narrowFrom == null) return null; Class fromClass = narrowFrom.getClass(); Object result = null; try { if (narrowTo.isAssignableFrom(fromClass)) result = narrowFrom; else { System.out.println("We still haven't implement this case: narrow " + narrowFrom + " of type " + fromClass + " to " + narrowTo); Class[] cs = fromClass.getInterfaces(); for (int i = 0; i < cs.length; i++) System.out.println(cs[i]); Exception e1 = new Exception(); try { throw e1; } catch(Exception ee) { ee.printStackTrace(); } System.exit(2); //throw new Error("We still haven't implement this case: narrow " // + narrowFrom + " of type " + fromClass + " to " // + narrowTo); /* ObjectImpl objimpl = (ObjectImpl)narrowFrom; if(objimpl._is_a(PortableServer.getTypeName(narrowTo))) result = PortableServer.getStubFromObjectImpl(objimpl, narrowTo); */ } } catch(Exception e) { result = null; } if (result == null) throw new ClassCastException("Can't narrow from " + fromClass + " to " + narrowTo); return result; }
if (result == null) throw new ClassCastException("Can't narrow from " + fromClass + " to " + narrowTo); return result;
if (narrowed instanceof ObjectImpl) { ObjectImpl target = (ObjectImpl) narrowed; target._set_delegate(((ObjectImpl) narrowFrom)._get_delegate()); } else if (narrowed instanceof Tie && narrowFrom instanceof Remote) { ((Tie) narrowed).setTarget((Remote) narrowFrom); } else throw new ClassCastException("Narrowing of " + narrowFrom.getClass() + " to " + narrowTo + " is either not possible or not implemented."); return narrowed;
public Object narrow(Object narrowFrom, Class narrowTo) throws ClassCastException { if (narrowTo == null) throw new ClassCastException("Can't narrow to null class"); if (narrowFrom == null) return null; Class fromClass = narrowFrom.getClass(); Object result = null; try { if (narrowTo.isAssignableFrom(fromClass)) result = narrowFrom; else { System.out.println("We still haven't implement this case: narrow " + narrowFrom + " of type " + fromClass + " to " + narrowTo); Class[] cs = fromClass.getInterfaces(); for (int i = 0; i < cs.length; i++) System.out.println(cs[i]); Exception e1 = new Exception(); try { throw e1; } catch(Exception ee) { ee.printStackTrace(); } System.exit(2); //throw new Error("We still haven't implement this case: narrow " // + narrowFrom + " of type " + fromClass + " to " // + narrowTo); /* ObjectImpl objimpl = (ObjectImpl)narrowFrom; if(objimpl._is_a(PortableServer.getTypeName(narrowTo))) result = PortableServer.getStubFromObjectImpl(objimpl, narrowTo); */ } } catch(Exception e) { result = null; } if (result == null) throw new ClassCastException("Can't narrow from " + fromClass + " to " + narrowTo); return result; }
public Remote toStub(Remote obj)
public Remote toStub(Remote ObjImpl)
public Remote toStub(Remote obj) throws NoSuchObjectException { return PortableServer.toStub(obj); }
return PortableServer.toStub(obj);
String icn = ObjImpl.getClass().getName(); if (!icn.endsWith("Impl")) throw new BAD_PARAM("Invalid class name '" + icn + "', must end with 'Impl'"); String sn = "_" + icn.substring(0, icn.length() - "Impl".length()) + "_Stub"; Class stubClass; Object o_stub; try { stubClass = RMIClassLoader.loadClass(sn); o_stub = stubClass.newInstance(); } catch (Exception e) { NoSuchObjectException n = new NoSuchObjectException(sn); n.initCause(e); throw n; } if (!Remote.class.isAssignableFrom(stubClass)) throw new ClassCastException(stubClass.getName() + " exists but cannot be returned as it does not inherit from " + Remote.class.getName()); return (Remote) o_stub;
public Remote toStub(Remote obj) throws NoSuchObjectException { return PortableServer.toStub(obj); }
PortableServer.unexportObject(obj);
Util.unexportObject(obj);
public void unexportObject(Remote obj) throws NoSuchObjectException { PortableServer.unexportObject(obj); }
scroll(bar, delta);
scroll(bar, wheel > 0 ? delta : -delta);
public void mouseWheelMoved(MouseWheelEvent e) { if (scrollpane.getViewport().getComponentCount() == 0) return; Component target = scrollpane.getViewport().getComponent(0); JScrollBar bar = scrollpane.getVerticalScrollBar(); Scrollable scrollable = (target instanceof Scrollable) ? (Scrollable) target : null; boolean tracksHeight = scrollable != null && scrollable.getScrollableTracksViewportHeight(); int wheel = e.getWheelRotation() * ROWS_PER_WHEEL_CLICK; int delta; // If possible, scroll vertically. if (bar != null && ! tracksHeight) { if (scrollable != null) { bounds(target); delta = scrollable.getScrollableUnitIncrement( rect, SwingConstants.VERTICAL, wheel); } else { // Scroll non scrollables. delta = wheel * SCROLL_NON_SCROLLABLES; } scroll(bar, delta); } // If not, try to scroll horizontally else { bar = scrollpane.getHorizontalScrollBar(); boolean tracksWidth = scrollable != null && scrollable.getScrollableTracksViewportWidth(); if (bar != null && ! tracksWidth) { if (scrollable != null) { bounds(target); delta = scrollable.getScrollableUnitIncrement( rect, SwingConstants.HORIZONTAL, wheel); } else { // Scroll non scrollables. delta = wheel * SCROLL_NON_SCROLLABLES; } scroll(bar, delta); } } }
Border vpBorder = p.getViewportBorder(); if (vpBorder == null || vpBorder instanceof UIResource) { vpBorder = UIManager.getBorder("ScrollPane.viewportBorder"); p.setViewportBorder(vpBorder); }
protected void installDefaults(JScrollPane p) { scrollpane = p; LookAndFeel.installColorsAndFont(p, "ScrollPane.background", "ScrollPane.foreground", "ScrollPane.font"); LookAndFeel.installBorder(p, "ScrollPane.border"); p.setOpaque(true); }
Border vpBorder = scrollpane.getViewportBorder(); if (vpBorder != null) { Rectangle r = scrollpane.getViewportBorderBounds(); vpBorder.paintBorder(scrollpane, g, r.x, r.y, r.width, r.height); }
public void paint(Graphics g, JComponent c) { // do nothing; the normal painting-of-children algorithm, along with // ScrollPaneLayout, does all the relevant work. }
p.setForeground(null); p.setBackground(null); p.setFont(null); p.setBorder(null); scrollpane = null;
LookAndFeel.uninstallBorder(p); Border vpBorder = p.getViewportBorder(); if (vpBorder != null && vpBorder instanceof UIResource) p.setViewportBorder(null);
protected void uninstallDefaults(JScrollPane p) { p.setForeground(null); p.setBackground(null); p.setFont(null); p.setBorder(null); scrollpane = null; }
handleEvent(e);
public void mouseClicked(MouseEvent e) { }
handleEvent(e);
public void mouseDragged(MouseEvent e) { }
handleEvent(e);
public void mouseEntered(MouseEvent e) { }
handleEvent(e);
public void mouseExited(MouseEvent e) { }
handleEvent(e);
public void mouseMoved(MouseEvent e) { }
handleEvent(e);
public void mousePressed(MouseEvent e) { }
handleEvent(e);
public void mouseReleased(MouseEvent e) { }
Container rootContainer = (Container) SwingUtilities.getRoot(invoker); rootContainer.removeComponentListener(topWindowListener);
RootPaneContainer rootContainer = (RootPaneContainer) SwingUtilities .getRoot(invoker); ((Container) rootContainer).removeComponentListener(topWindowListener); boolean topLevelMenu = (popupMenu.getInvoker() instanceof JMenu) && ((JMenu) popupMenu.getInvoker()) .isTopLevelMenu(); if (topLevelMenu || ! (popupMenu.getInvoker() instanceof MenuElement)) { Container glassPane = (Container) rootContainer.getGlassPane(); glassPane.setVisible(false); glassPane.removeMouseListener(mouseInputListener); mouseInputListener = null; }
public void popupMenuWillBecomeInvisible(PopupMenuEvent event) { // remove listener that listens to component events fired // by the top - level window that this popup belongs to. Component invoker = popupMenu.getInvoker(); Container rootContainer = (Container) SwingUtilities.getRoot(invoker); rootContainer.removeComponentListener(topWindowListener); }
Container rootContainer = (Container) SwingUtilities.getRoot(invoker); rootContainer.addComponentListener(topWindowListener);
RootPaneContainer rootContainer = (RootPaneContainer) SwingUtilities .getRoot(invoker); ((Container) rootContainer).addComponentListener(topWindowListener); if (mouseInputListener == null) { Container glassPane = (Container) rootContainer.getGlassPane(); glassPane.setVisible(true); mouseInputListener = new MouseInputHandler(rootContainer); glassPane.addMouseListener(mouseInputListener); glassPane.addMouseMotionListener(mouseInputListener); }
public void popupMenuWillBecomeVisible(PopupMenuEvent event) { // Adds topWindowListener to top-level window to listener to // ComponentEvents fired by it. We need to cancel this popup menu // if topWindow to which this popup belongs was resized or moved. Component invoker = popupMenu.getInvoker(); Container rootContainer = (Container) SwingUtilities.getRoot(invoker); rootContainer.addComponentListener(topWindowListener); // if this popup menu is a free floating popup menu, // then by default its first element should be always selected when // this popup menu becomes visible. MenuSelectionManager manager = MenuSelectionManager.defaultManager(); if (manager.getSelectedPath().length == 0) { // Set selected path to point to the first item in the popup menu MenuElement[] path = new MenuElement[2]; path[0] = popupMenu; Component[] comps = popupMenu.getComponents(); if (comps.length != 0 && comps[0] instanceof MenuElement) { path[1] = (MenuElement) comps[0]; manager.setSelectedPath(path); } } }
mouseInputListener = new MouseInputHandler();
public BasicPopupMenuUI() { popupMenuListener = new PopupMenuHandler(); mouseInputListener = new MouseInputHandler(); topWindowListener = new TopWindowListener(); }
popupMenu.addMouseListener(mouseInputListener); popupMenu.addMouseMotionListener(mouseInputListener);
protected void installListeners() { popupMenu.addMouseListener(mouseInputListener); popupMenu.addMouseMotionListener(mouseInputListener); popupMenu.addPopupMenuListener(popupMenuListener); }
popupMenu.removeMouseListener(mouseInputListener); popupMenu.removeMouseMotionListener(mouseInputListener);
protected void uninstallListeners() { popupMenu.removeMouseListener(mouseInputListener); popupMenu.removeMouseMotionListener(mouseInputListener); popupMenu.removePopupMenuListener(popupMenuListener); }
menu = m; this.ui = ui;
public ChangeHandler(JMenu m, BasicMenuUI ui) { // Not used. }
MenuSelectionManager manager = MenuSelectionManager.defaultManager(); manager.setSelectedPath(e.getPath());
if (menuItem.isEnabled()) { MenuSelectionManager manager = e.getMenuSelectionManager(); MenuElement path[] = e.getPath(); Point p = e.getPoint(); if(p.x >= 0 && p.x < menuItem.getWidth() && p.y >= 0 && p.y < menuItem.getHeight()) { JMenu menu = (JMenu) menuItem; MenuElement[] selectedPath = manager.getSelectedPath(); if(! (selectedPath.length > 0 && selectedPath[selectedPath.length-1] == menu.getPopupMenu())) { if(menu.isTopLevelMenu() || menu.getDelay() == 0 || e.getID() == MouseEvent.MOUSE_DRAGGED) { MenuElement[] newPath = new MenuElement[path.length + 1]; System.arraycopy(path, 0, newPath, 0, path.length); newPath[path.length] = menu.getPopupMenu(); manager.setSelectedPath(newPath); } else { manager.setSelectedPath(path); setupPostTimer(menu); } } } else if (e.getID() == MouseEvent.MOUSE_RELEASED) { Component comp = manager.componentForPoint(e.getComponent(), e.getPoint()); if (comp == null) manager.clearSelectedPath(); } }
public void menuDragMouseDragged(MenuDragMouseEvent e) { MenuSelectionManager manager = MenuSelectionManager.defaultManager(); manager.setSelectedPath(e.getPath()); }
MenuSelectionManager manager = MenuSelectionManager.defaultManager(); manager.setSelectedPath(e.getPath());
public void menuDragMouseEntered(MenuDragMouseEvent e) { MenuSelectionManager manager = MenuSelectionManager.defaultManager(); manager.setSelectedPath(e.getPath()); }
throws NotImplementedException
public void menuKeyTyped(MenuKeyEvent e) { // TODO: What should be done here, if anything? }
MenuSelectionManager manager = MenuSelectionManager.defaultManager(); manager.processMouseEvent(e);
public void mouseClicked(MouseEvent e) { MenuSelectionManager manager = MenuSelectionManager.defaultManager(); manager.processMouseEvent(e); }
if (! menu.isTopLevelMenu() || popupVisible())
if (menu.isEnabled())
public void mouseEntered(MouseEvent e) { /* When mouse enters menu item, it should be considered selected if (i) if this menu is a submenu in some other menu (ii) or if this menu is in a menu bar and some other menu in a menu bar was just selected and has its popup menu visible. (If nothing was selected, menu should be pressed before it will be selected) */ JMenu menu = (JMenu) menuItem; // NOTE: the following if used to require !menu.isArmed but I could find // no reason for this and it was preventing some JDK-compatible behaviour. // Specifically, if a menu is selected but its popup menu not visible, // and then another menu is selected whose popup menu IS visible, when // the mouse is moved over the first menu, its popup menu should become // visible. if (! menu.isTopLevelMenu() || popupVisible()) { // set new selection and forward this event to MenuSelectionManager MenuSelectionManager manager = MenuSelectionManager.defaultManager(); manager.setSelectedPath(getPath()); manager.processMouseEvent(e); } }
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
MenuSelectionManager manager = MenuSelectionManager.defaultManager(); MenuElement[] selectedPath = manager.getSelectedPath(); if (! menu.isTopLevelMenu()) { if(! (selectedPath.length > 0 && selectedPath[selectedPath.length - 1] == menu.getPopupMenu())) { if(menu.getDelay() == 0) { MenuElement[] path = getPath(); MenuElement[] newPath = new MenuElement[path.length + 1]; System.arraycopy(path, 0, newPath, 0, path.length); newPath[path.length] = menu.getPopupMenu(); manager.setSelectedPath(newPath); } else {
public void mouseEntered(MouseEvent e) { /* When mouse enters menu item, it should be considered selected if (i) if this menu is a submenu in some other menu (ii) or if this menu is in a menu bar and some other menu in a menu bar was just selected and has its popup menu visible. (If nothing was selected, menu should be pressed before it will be selected) */ JMenu menu = (JMenu) menuItem; // NOTE: the following if used to require !menu.isArmed but I could find // no reason for this and it was preventing some JDK-compatible behaviour. // Specifically, if a menu is selected but its popup menu not visible, // and then another menu is selected whose popup menu IS visible, when // the mouse is moved over the first menu, its popup menu should become // visible. if (! menu.isTopLevelMenu() || popupVisible()) { // set new selection and forward this event to MenuSelectionManager MenuSelectionManager manager = MenuSelectionManager.defaultManager(); manager.setSelectedPath(getPath()); manager.processMouseEvent(e); } }
manager.processMouseEvent(e);
setupPostTimer(menu); } } } else { if(selectedPath.length > 0 && selectedPath[0] == menu.getParent()) { MenuElement[] newPath = new MenuElement[3]; newPath[0] = (MenuElement) menu.getParent(); newPath[1] = menu; newPath[2] = menu.getPopupMenu(); manager.setSelectedPath(newPath); } }
public void mouseEntered(MouseEvent e) { /* When mouse enters menu item, it should be considered selected if (i) if this menu is a submenu in some other menu (ii) or if this menu is in a menu bar and some other menu in a menu bar was just selected and has its popup menu visible. (If nothing was selected, menu should be pressed before it will be selected) */ JMenu menu = (JMenu) menuItem; // NOTE: the following if used to require !menu.isArmed but I could find // no reason for this and it was preventing some JDK-compatible behaviour. // Specifically, if a menu is selected but its popup menu not visible, // and then another menu is selected whose popup menu IS visible, when // the mouse is moved over the first menu, its popup menu should become // visible. if (! menu.isTopLevelMenu() || popupVisible()) { // set new selection and forward this event to MenuSelectionManager MenuSelectionManager manager = MenuSelectionManager.defaultManager(); manager.setSelectedPath(getPath()); manager.processMouseEvent(e); } }
manager.processMouseEvent(e);
if (menu.isEnabled()) {
public void mousePressed(MouseEvent e) { MenuSelectionManager manager = MenuSelectionManager.defaultManager(); JMenu menu = (JMenu) menuItem; manager.processMouseEvent(e); // Menu should be displayed when the menu is pressed only if // it is top-level menu if (menu.isTopLevelMenu()) { if (menu.getPopupMenu().isVisible()) // If menu is visible and menu button was pressed.. // then need to cancel the menu manager.clearSelectedPath(); else { // Display the menu int x = 0; int y = menu.getHeight(); manager.setSelectedPath(getPath()); JMenuBar mb = (JMenuBar) menu.getParent(); // set selectedIndex of the selectionModel of a menuBar mb.getSelectionModel().setSelectedIndex(mb.getComponentIndex(menu)); } } }
if (menu.getPopupMenu().isVisible())
if (menu.isSelected())
public void mousePressed(MouseEvent e) { MenuSelectionManager manager = MenuSelectionManager.defaultManager(); JMenu menu = (JMenu) menuItem; manager.processMouseEvent(e); // Menu should be displayed when the menu is pressed only if // it is top-level menu if (menu.isTopLevelMenu()) { if (menu.getPopupMenu().isVisible()) // If menu is visible and menu button was pressed.. // then need to cancel the menu manager.clearSelectedPath(); else { // Display the menu int x = 0; int y = menu.getHeight(); manager.setSelectedPath(getPath()); JMenuBar mb = (JMenuBar) menu.getParent(); // set selectedIndex of the selectionModel of a menuBar mb.getSelectionModel().setSelectedIndex(mb.getComponentIndex(menu)); } } }
int x = 0; int y = menu.getHeight();
Container cnt = menu.getParent(); if (cnt != null && cnt instanceof JMenuBar) { MenuElement[] me = new MenuElement[2]; me[0] = (MenuElement) cnt; me[1] = menu; manager.setSelectedPath(me); } } }
public void mousePressed(MouseEvent e) { MenuSelectionManager manager = MenuSelectionManager.defaultManager(); JMenu menu = (JMenu) menuItem; manager.processMouseEvent(e); // Menu should be displayed when the menu is pressed only if // it is top-level menu if (menu.isTopLevelMenu()) { if (menu.getPopupMenu().isVisible()) // If menu is visible and menu button was pressed.. // then need to cancel the menu manager.clearSelectedPath(); else { // Display the menu int x = 0; int y = menu.getHeight(); manager.setSelectedPath(getPath()); JMenuBar mb = (JMenuBar) menu.getParent(); // set selectedIndex of the selectionModel of a menuBar mb.getSelectionModel().setSelectedIndex(mb.getComponentIndex(menu)); } } }
manager.setSelectedPath(getPath());
MenuElement[] selectedPath = manager.getSelectedPath(); if (selectedPath.length > 0 && selectedPath[selectedPath.length - 1] != menu.getPopupMenu()) { if(menu.isTopLevelMenu() || menu.getDelay() == 0) { MenuElement[] newPath = new MenuElement[selectedPath.length + 1]; System.arraycopy(selectedPath, 0, newPath, 0, selectedPath.length); newPath[selectedPath.length] = menu.getPopupMenu(); manager.setSelectedPath(newPath); } else { setupPostTimer(menu); } }
public void mousePressed(MouseEvent e) { MenuSelectionManager manager = MenuSelectionManager.defaultManager(); JMenu menu = (JMenu) menuItem; manager.processMouseEvent(e); // Menu should be displayed when the menu is pressed only if // it is top-level menu if (menu.isTopLevelMenu()) { if (menu.getPopupMenu().isVisible()) // If menu is visible and menu button was pressed.. // then need to cancel the menu manager.clearSelectedPath(); else { // Display the menu int x = 0; int y = menu.getHeight(); manager.setSelectedPath(getPath()); JMenuBar mb = (JMenuBar) menu.getParent(); // set selectedIndex of the selectionModel of a menuBar mb.getSelectionModel().setSelectedIndex(mb.getComponentIndex(menu)); } } }
JMenuBar mb = (JMenuBar) menu.getParent(); mb.getSelectionModel().setSelectedIndex(mb.getComponentIndex(menu)); }
public void mousePressed(MouseEvent e) { MenuSelectionManager manager = MenuSelectionManager.defaultManager(); JMenu menu = (JMenu) menuItem; manager.processMouseEvent(e); // Menu should be displayed when the menu is pressed only if // it is top-level menu if (menu.isTopLevelMenu()) { if (menu.getPopupMenu().isVisible()) // If menu is visible and menu button was pressed.. // then need to cancel the menu manager.clearSelectedPath(); else { // Display the menu int x = 0; int y = menu.getHeight(); manager.setSelectedPath(getPath()); JMenuBar mb = (JMenuBar) menu.getParent(); // set selectedIndex of the selectionModel of a menuBar mb.getSelectionModel().setSelectedIndex(mb.getComponentIndex(menu)); } } }
((JMenu) menuItem).setDelay(200);
protected void installDefaults() { LookAndFeel.installBorder(menuItem, "Menu.border"); LookAndFeel.installColorsAndFont(menuItem, "Menu.background", "Menu.foreground", "Menu.font"); menuItem.setMargin(UIManager.getInsets("Menu.margin")); acceleratorFont = UIManager.getFont("Menu.acceleratorFont"); acceleratorForeground = UIManager.getColor("Menu.acceleratorForeground"); acceleratorSelectionForeground = UIManager.getColor("Menu.acceleratorSelectionForeground"); selectionBackground = UIManager.getColor("Menu.selectionBackground"); selectionForeground = UIManager.getColor("Menu.selectionForeground"); arrowIcon = UIManager.getIcon("Menu.arrowIcon"); oldBorderPainted = UIManager.getBoolean("Menu.borderPainted"); }
throws NotImplementedException
protected void installKeyboardActions() throws NotImplementedException { // FIXME: Need to implement }
super.installKeyboardActions();
protected void installKeyboardActions() throws NotImplementedException { // FIXME: Need to implement }
((JMenu) menuItem).addMouseListener(mouseInputListener); ((JMenu) menuItem).addMouseMotionListener(mouseInputListener);
super.installListeners();
protected void installListeners() { ((JMenu) menuItem).addMouseListener(mouseInputListener); ((JMenu) menuItem).addMouseMotionListener(mouseInputListener); ((JMenu) menuItem).addMenuListener(menuListener); ((JMenu) menuItem).addMenuDragMouseListener(menuDragMouseListener); }
((JMenu) menuItem).addMenuDragMouseListener(menuDragMouseListener);
protected void installListeners() { ((JMenu) menuItem).addMouseListener(mouseInputListener); ((JMenu) menuItem).addMouseMotionListener(mouseInputListener); ((JMenu) menuItem).addMenuListener(menuListener); ((JMenu) menuItem).addMenuDragMouseListener(menuDragMouseListener); }
Timer timer = new Timer(menu.getDelay(), new SelectMenuAction()); timer.setRepeats(false); timer.start();
protected void setupPostTimer(JMenu menu) { // TODO: Implement this properly. }
throws NotImplementedException
protected void uninstallKeyboardActions() throws NotImplementedException { // FIXME: Need to implement }
super.installKeyboardActions();
protected void uninstallKeyboardActions() throws NotImplementedException { // FIXME: Need to implement }
((JMenu) menuItem).removeMouseListener(mouseInputListener);
super.uninstallListeners();
protected void uninstallListeners() { ((JMenu) menuItem).removeMouseListener(mouseInputListener); ((JMenu) menuItem).removeMenuListener(menuListener); ((JMenu) menuItem).removePropertyChangeListener(propertyChangeListener); }
((JMenu) menuItem).removePropertyChangeListener(propertyChangeListener);
protected void uninstallListeners() { ((JMenu) menuItem).removeMouseListener(mouseInputListener); ((JMenu) menuItem).removeMenuListener(menuListener); ((JMenu) menuItem).removePropertyChangeListener(propertyChangeListener); }
static String absolutize(String base, String href)
public static String absolutize(String base, String href) throws MalformedURLException
static String absolutize(String base, String href) { if (href == null) return null; int ci = href.indexOf(':'); if (ci > 1 && isLowercaseAscii(href.substring(0, ci))) { // href is absolute already return href; } if (base == null) base = ""; else { int i = base.lastIndexOf('/'); if (i != -1) base = base.substring(0, i + 1); else base = ""; } if ("".equals(base)) { // assume file URL relative to current directory base = System.getProperty("user.dir"); if (base.charAt(0) == '/') base = base.substring(1); base = "file:///" + base.replace(File.separatorChar, '/'); if (!base.endsWith("/")) base += "/"; } if (href.startsWith("/")) { if (base.startsWith("file:")) return "file://" + href; int i = base.indexOf("://"); if (i != -1) { i = base.indexOf('/', i + 3); if (i != -1) base = base.substring(0, i); } } else { while (href.startsWith("..")) { int i = base.lastIndexOf('/', base.length() - 2); if (i != -1) base = base.substring(0, i + 1); href = href.substring(2); if (href.startsWith("/")) href = href.substring(1); } } return base + href; }
if (ci > 1 && isLowercaseAscii(href.substring(0, ci)))
if (ci > 1 && isURLScheme(href.substring(0, ci)))
static String absolutize(String base, String href) { if (href == null) return null; int ci = href.indexOf(':'); if (ci > 1 && isLowercaseAscii(href.substring(0, ci))) { // href is absolute already return href; } if (base == null) base = ""; else { int i = base.lastIndexOf('/'); if (i != -1) base = base.substring(0, i + 1); else base = ""; } if ("".equals(base)) { // assume file URL relative to current directory base = System.getProperty("user.dir"); if (base.charAt(0) == '/') base = base.substring(1); base = "file:///" + base.replace(File.separatorChar, '/'); if (!base.endsWith("/")) base += "/"; } if (href.startsWith("/")) { if (base.startsWith("file:")) return "file://" + href; int i = base.indexOf("://"); if (i != -1) { i = base.indexOf('/', i + 3); if (i != -1) base = base.substring(0, i); } } else { while (href.startsWith("..")) { int i = base.lastIndexOf('/', base.length() - 2); if (i != -1) base = base.substring(0, i + 1); href = href.substring(2); if (href.startsWith("/")) href = href.substring(1); } } return base + href; }
if (href.startsWith("/")) { if (base.startsWith("file:")) return "file: int i = base.indexOf(": if (i != -1) { i = base.indexOf('/', i + 3); if (i != -1) base = base.substring(0, i); } } else { while (href.startsWith("..")) { int i = base.lastIndexOf('/', base.length() - 2); if (i != -1) base = base.substring(0, i + 1); href = href.substring(2); if (href.startsWith("/")) href = href.substring(1); } } return base + href;
return new URL(new URL(base), href).toString();
static String absolutize(String base, String href) { if (href == null) return null; int ci = href.indexOf(':'); if (ci > 1 && isLowercaseAscii(href.substring(0, ci))) { // href is absolute already return href; } if (base == null) base = ""; else { int i = base.lastIndexOf('/'); if (i != -1) base = base.substring(0, i + 1); else base = ""; } if ("".equals(base)) { // assume file URL relative to current directory base = System.getProperty("user.dir"); if (base.charAt(0) == '/') base = base.substring(1); base = "file:///" + base.replace(File.separatorChar, '/'); if (!base.endsWith("/")) base += "/"; } if (href.startsWith("/")) { if (base.startsWith("file:")) return "file://" + href; int i = base.indexOf("://"); if (i != -1) { i = base.indexOf('/', i + 3); if (i != -1) base = base.substring(0, i); } } else { while (href.startsWith("..")) { int i = base.lastIndexOf('/', base.length() - 2); if (i != -1) base = base.substring(0, i + 1); href = href.substring(2); if (href.startsWith("/")) href = href.substring(1); } } return base + href; }
private InputStream resolve(String url)
static InputStream resolve(String url)
private InputStream resolve(String url) throws IOException { try { return new URL(url).openStream(); } catch (MalformedURLException e) { return null; } }
catch (IOException e) { IOException e2 = new IOException("error resolving " + url); e2.initCause(e); throw e2; }
private InputStream resolve(String url) throws IOException { try { return new URL(url).openStream(); } catch (MalformedURLException e) { return null; } }
} catch (MalformedURLException e) { RuntimeException e2 = new RuntimeException("unsupported URL: " + systemId); e2.initCause(e); throw e2; }
XIncludeFilter(XMLStreamReader reader, String systemId, boolean namespaceAware, boolean validating, boolean expandERefs) { super(reader); this.systemId = XMLParser.absolutize(null, systemId); this.namespaceAware = namespaceAware; this.validating = validating; this.expandERefs = expandERefs; }
d.width = d.width + rect.width + defaultAcceleratorLabelGap;
d.width += rect.width + defaultAcceleratorLabelGap;
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width = d.width + rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent());
if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); }
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && !text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); } }
}
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && !text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); } }
try {
public void run() { try { synchronized (queueLock) { try { queueLock.wait(initialDelay); } catch (InterruptedException e) { // Ignored } if (!running) return; queueEvent(); if (repeats) while (running) { try { queueLock.wait(delay); } catch (InterruptedException e) { // Ignored } if (!running) break; queueEvent(); if (logTimers) System.out.println("javax.swing.Timer -> clocktick"); if ( ! repeats) break; } running = false; } } finally { // The timer is no longer running. running = false; } }
running = false; }
public void run() { try { synchronized (queueLock) { try { queueLock.wait(initialDelay); } catch (InterruptedException e) { // Ignored } if (!running) return; queueEvent(); if (repeats) while (running) { try { queueLock.wait(delay); } catch (InterruptedException e) { // Ignored } if (!running) break; queueEvent(); if (logTimers) System.out.println("javax.swing.Timer -> clocktick"); if ( ! repeats) break; } running = false; } } finally { // The timer is no longer running. running = false; } }
}
public void run() { try { synchronized (queueLock) { try { queueLock.wait(initialDelay); } catch (InterruptedException e) { // Ignored } if (!running) return; queueEvent(); if (repeats) while (running) { try { queueLock.wait(delay); } catch (InterruptedException e) { // Ignored } if (!running) break; queueEvent(); if (logTimers) System.out.println("javax.swing.Timer -> clocktick"); if ( ! repeats) break; } running = false; } } finally { // The timer is no longer running. running = false; } }
synchronized (queueLock) {
void queueEvent() { synchronized (queueLock) { queue++; if (queue == 1) SwingUtilities.invokeLater(drainer); } }
}
void queueEvent() { synchronized (queueLock) { queue++; if (queue == 1) SwingUtilities.invokeLater(drainer); } }
if (waker != null) return;
if (!running) { running = true;
public void start() { synchronized (queueLock) { if (waker != null) return; waker = new Waker(); waker.start(); } }
}
public void start() { synchronized (queueLock) { if (waker != null) return; waker = new Waker(); waker.start(); } }
if (waker != null)
public void stop() { synchronized (queueLock) { running = false; queue = 0; if (waker != null) queueLock.notifyAll(); waker = null; } }