private static CompactCharSequence createFromBytes(byte[] b, int n) { if (n < 8) { return new Fixed_0_7(b, n); } else if (n < 16) { return new Fixed_8_15(b, n); } else if (n < 24) { return new Fixed_16_23(b, n); } return new ByteBasedSequence(b); }
/** * Creates disabled (color saturation lowered) icon. * Icon image conversion is performed lazily. * @param icon original icon used for conversion * @return less saturated Icon * @since 7.28 */ public static Icon createDisabledIcon(Icon icon) { Parameters.notNull("icon", icon); return new LazyDisabledIcon(icon2Image(icon)); }
/** * Returns the root preference node. * * @return the root preference node. */ public static Preferences root() { if (PREFS_IMPL == null) { PREFS_IMPL = getPreferencesProvider(); } return PREFS_IMPL.preferencesRoot(); }
public DelegateAction(CallbackSystemAction a, Lookup actionContext) { this.delegate = a; this.weakL = org.openide.util.WeakListeners.propertyChange(this, null); this.enabled = a.getActionPerformer() != null; this.result = actionContext.lookup(new Lookup.Template<ActionMap>(ActionMap.class)); this.result.addLookupListener(WeakListeners.create(LookupListener.class, this, this.result)); resultChanged(null); }
private GlobalManager() { result = Utilities.actionsGlobalContext().lookup(new Lookup.Template<ActionMap>(ActionMap.class)); result.addLookupListener(this); resultChanged(null); }
/** * Displays the help page in a supported viewer, if any. * @return true if this help was displayed successfully * @since 8.21 * @see org.openide.util.HelpCtx.Displayer#display */ public boolean display() { for (Displayer d : Lookup.getDefault().lookupAll(Displayer.class)) { if (d.display(this)) { return true; } } return false; }
/** * Find a result corresponding to a given class. * Equivalent to calling {@link #lookup(Lookup.Template)} but slightly more convenient. * Subclasses may override this method to produce the same semantics more efficiently. * @param clazz the supertype of the result * @return a live object representing instances of that type * @since org.openide.util 6.10 */ public <T> Lookup.Result<T> lookupResult(Class<T> clazz) { return lookup(new Lookup.Template<T>(clazz)); }
private void start() { detach(); if (initTask == null) { initTask = RequestProcessor.getDefault().post(this); } }
/** * Creates disabled (color saturation lowered) image. * @param image original image used for conversion * @return less saturated Image * @since 7.28 */ public static Image createDisabledImage(Image image) { Parameters.notNull("image", image); return LazyDisabledIcon.createDisabledImage(image); }
/** @param privileged can enter privileged states of this Mutex * This helps avoid creating of custom Runnables. */ public Mutex(Privileged privileged) { if (privileged == null) { throw new IllegalArgumentException("privileged == null"); //NOI18N } else { this.LOCK = init(new InternalLock()); privileged.setParent(this); } this.wrapper = null; }
final int getPriority() { final Task t = getTask(); return t == null ? 0 : t.getPriority(); }
/** Default constructor. */ public Mutex() { this.LOCK = init(new InternalLock()); this.wrapper = null; }
/** See #20467. */ private static void doNotify(RequestProcessor.Task todo, Throwable ex) { if (SLOW) { Item item = todo.item; if (item != null && item.message == null) { item.message = "task failed due to: " + ex; item.initCause(ex); ex = item; } } logger().log(Level.SEVERE, "Error in RequestProcessor " + todo.debug(), ex); }
@Override public void run() { while (TICK == this) { try { Item first = obtainFirst(); if (first != null) { first.owner.enqueue(first); } } catch (InterruptedException ex) { continue; } } }
/** * Convenience method to get a property as a string. * Same as {@link #get}; only here because of pre-generic code. * @param key a property name; cannot be null nor empty * @return the property value, or null if it was not defined */ public String getProperty(String key) { return get(key); }
@Override public int compareTo(CharSequence o) { return Comparator.compare(this, o); } }