/** * The Method will be called if detected some error. * @param text text message * @param error error object * * @since 1.0 */ @Weight (Weight.Unit.LIGHT) void onDetectedError (@Nullable String text, @Nonnull Throwable error); }
@Weight(Weight.Unit.NORMAL) @Nonnull TabTitle getTabTitle();
@Weight(Weight.Unit.LIGHT) @Nonnull JComponent getMainComponent();
/** * Cancel all defer actions globally. * * @since 1.0 */ @Weight(Weight.Unit.NORMAL) public static void cancelAllDeferredActionsGlobally() { final List<Deferred> list = REGISTRY.get(); list.clear(); REGISTRY.remove(); }
/** * Get the stack call depth for the caller. * @return the caller method stack depth. * @since 1.0 */ @Weight (Weight.Unit.VARIABLE) public static int stackDepth () { return Thread.currentThread().getStackTrace().length - 1; } }
@Weight(Weight.Unit.NORMAL) void onDeleteTopic(@Nonnull final MindMapPanel panel, @Nonnull final Topic topic);
/** * Cancel all time watchers and time points globally for the current thread. * * @see #cancel() * @since 1.0 */ @Weight(Weight.Unit.NORMAL) public static void cancelAll() { final List<TimeData> list = REGISTRY.get(); list.clear(); REGISTRY.remove(); }
/** * Get the stack element of the method caller. * @return the stack trace element for the calling method. * @since 1.0 */ @Weight (Weight.Unit.VARIABLE) @Nonnull public static StackTraceElement stackElement () { final StackTraceElement[] allElements = Thread.currentThread().getStackTrace(); return allElements[2]; }
/** * Check that the thread local for the current thread contains time points or watchers. * * @return true if the thread local storage is empty, false otherwise */ @Weight(value = Weight.Unit.NORMAL, comment = "May create list in thread local storage") public static boolean isEmpty() { final boolean result = REGISTRY.get().isEmpty(); if (result) { REGISTRY.remove(); } return result; } }
/** * Check that presented defer actions for the current thread. * * @return true if presented, false otherwise * @since 1.0 */ @Weight(Weight.Unit.NORMAL) public static boolean isEmpty() { final boolean result = REGISTRY.get().isEmpty(); if (result) { REGISTRY.remove(); } return result; } }
/** * Defer some action. * * @param deferred action to be defer. * @return the same object from arguments * @since 1.0 */ @Weight(Weight.Unit.NORMAL) public static Deferred defer(@Nonnull final Deferred deferred) { REGISTRY.get().add(assertNotNull(deferred)); return deferred; }
@Weight(Weight.Unit.LIGHT) @Nullable JMenuItem makeMenuItem( @Nonnull MindMapPanel panel, @Nonnull DialogProvider dialogProvider, @Nullable Topic topic, @Nullable @MustNotContainNull Topic[] selectedTopics, @Nullable CustomJob customProcessor);
/** * Send notifications to all listeners. * @param text message text * @param error error object * @since 1.0 */ @Weight(Weight.Unit.VARIABLE) public static void fireError (@Nonnull final String text, @Nonnull final Throwable error) { for(final MetaErrorListener p : ERROR_LISTENERS){ p.onDetectedError(text, error); } } }
/** * The Constructor. * * @since 1.0 */ @Weight(value = Weight.Unit.VARIABLE, comment = "Depends on the current call stack depth@") public Deferred() { this.stackDepth = ThreadUtils.stackDepth() - 1; }
/** * Get name of attribute key associated with the plug-in. * * @return the array of language names (case sensitive) */ @Nonnull @MustNotContainNull @Weight(Weight.Unit.EXTRALIGHT) String[] getProcessingLanguageNames(); }
/** * Closing quetly any closeable object. Any exception will be caught (but global error listeners will be notified) * * @param closeable object to be closed quetly * @return the same object provided in args * @since 1.0 */ @Weight(Weight.Unit.LIGHT) @Nullable public static Closeable closeQuetly(@Nullable final Closeable closeable) { if (closeable != null) { try { closeable.close(); } catch (Exception ex) { MetaErrorListeners.fireError("Exception in closeQuetly", ex); } } return closeable; } }
/** * Cancel all defer actions for the current stack depth. * * @since 1.0 */ @Weight(value = Weight.Unit.VARIABLE, comment = "Depends on the current call stack depth") public static void cancelDeferredActions() { final int stackDepth = ThreadUtils.stackDepth(); final List<Deferred> list = REGISTRY.get(); final Iterator<Deferred> iterator = list.iterator(); while (iterator.hasNext()) { final Deferred deferred = iterator.next(); if (deferred.getStackDepth() >= stackDepth) { iterator.remove(); } } if (list.isEmpty()) { REGISTRY.remove(); } }
/** * The Constructor * * @param stackDepth stack depth * @param alertMessage alert message for time violation * @param maxAllowedDelayInMilliseconds max allowed time gap in milliseconds * @param violationListener listener for the violation alert * @since 1.0 */ @Weight(Weight.Unit.LIGHT) public TimeData(@Constraint("X>1") final int stackDepth, @Nonnull final String alertMessage, final long maxAllowedDelayInMilliseconds, @Nullable final TimeAlertListener violationListener) { this.stackDepth = stackDepth; this.maxAllowedDelayInMilliseconds = maxAllowedDelayInMilliseconds; this.creationTimeInMilliseconds = System.currentTimeMillis(); this.alertMessage = alertMessage; this.alertListener = GetUtils.ensureNonNull(violationListener, NULL_TIME_ALERT_LISTENER); }
/** * Add a named time point. * * @param timePointName name for the time point * @param listener listener to be notified * @see #checkPoint(java.lang.String) * @since 1.0 */ @Weight(value = Weight.Unit.VARIABLE, comment = "Depends on the current call stack depth") // WARNING! Don't make a call from methods of the class to not break stack depth! public static void addPoint(@Nonnull final String timePointName, @Nonnull final TimeAlertListener listener) { final List<TimeData> list = REGISTRY.get(); list.add(new TimeData(ThreadUtils.stackDepth(), timePointName, -1L, assertNotNull(listener))); }
/** * Add a time watcher. As target of notification meta error listeners will be used. * * @param alertMessage message for time violation * @param maxAllowedDelayInMilliseconds max allowed delay in milliseconds for executing block * @see #check() * @see #cancelAll() * @see MetaErrorListeners * @since 1.0 */ @Weight(value = Weight.Unit.VARIABLE, comment = "Depends on the current call stack depth") // WARNING! Don't make a call from methods of the class to not break stack depth! public static void addGuard(@Nullable final String alertMessage, @Constraint("X>0") final long maxAllowedDelayInMilliseconds) { final List<TimeData> list = REGISTRY.get(); list.add(new TimeData(ThreadUtils.stackDepth(), alertMessage, maxAllowedDelayInMilliseconds, null)); }