boolean doPlatformMenuAction(@Nonnull PlatformMenuEvent event, @Nullable @MayContainNull Object ... args); }
@Nullable protected static File findExisting(@Nonnull @MayContainNull final File... files) { File result = null; for (final File f : files) { if (f != null && f.isFile()) { result = f; break; } } return result; }
@Nullable public abstract MindMap doImport(@Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic actionTopic, @Nonnull @MayContainNull final Topic[] selectedTopics) throws Exception;
public Topic(@Nonnull final MindMap map, @Nullable final Topic parent, @Nonnull final String text, @Nonnull @MayContainNull final Extra<?>... extras) { this(map, text, extras); this.parent = parent; if (parent != null) { if (parent.getMap() != map) { throw new IllegalArgumentException("Parent must belong to the same mind map"); } parent.children.add(this); } }
/** * Append elements to the end of an array * * @param <T> type of array elements * @param array target array * @param elements elements to be added to the end of the target array * @return new array where elements are placed in the end * @since 1.1.3 */ @Nonnull @MayContainNull @Weight(Weight.Unit.NORMAL) public static <T> T[] append(@MayContainNull @Nonnull final T[] array, @MayContainNull final T... elements) { @SuppressWarnings("unchecked") final T[] result = (T[]) Array.newInstance(array.getClass().getComponentType(), array.length + elements.length); System.arraycopy(array, 0, result, 0, array.length); int index = array.length; for (final T element : elements) { result[index++] = element; } return result; }
/** * Append element to the start of an array. * * @param <T> type of array elements * @param element element to be added into start of array, can be null * @param array target array * @return new array where the element on the first position * @since 1.1.3 */ @Nonnull @MayContainNull @Weight(Weight.Unit.NORMAL) public static <T> T[] append(@Nullable final T element, @MayContainNull @Nonnull final T[] array) { @SuppressWarnings("unchecked") final T[] result = (T[]) Array.newInstance(array.getClass().getComponentType(), array.length + 1); System.arraycopy(array, 0, result, 1, array.length); result[0] = element; return result; }
/** * Make file path from provided strings * @param paths path elements * @return joined file path with OS file separator * @since 2.1.7 */ @Nonnull public static String makeOsFilePathWithoutDuplications(@Nonnull @MayContainNull final String... paths) { final StringBuilder result = new StringBuilder(); final Set<String> alreadyAdded = new HashSet<>(); for (final String s : paths) { if (s != null && !s.isEmpty() && !alreadyAdded.contains(s)) { alreadyAdded.add(s); if (result.length() > 0) { result.append(File.pathSeparatorChar); } result.append(s); } } return result.toString(); }
/** * Make file path appropriate for current OS. * * @param files files which will be added in the path * @return joined file path with OS file separator * @since 2.1.7 */ @Nonnull public static String makeOsFilePathWithoutDuplications(@Nonnull @MayContainNull final File[] files) { final StringBuilder result = new StringBuilder(); final Set<File> alreadyAdded = new HashSet<>(); for (final File f : files) { if (f == null || alreadyAdded.contains(f)) { continue; } alreadyAdded.add(f); if (result.length() > 0) { result.append(File.pathSeparatorChar); } result.append(f.getAbsolutePath()); } return result.toString(); }
private Topic(@Nonnull final MindMap map, @Nonnull final String text, @Nonnull @MayContainNull final Extra<?>... extras) { this.map = Assertions.assertNotNull(map); this.text = Assertions.assertNotNull(text); for (final Extra<?> e : extras) { if (e != null) { this.extras.put(e.getType(), e); } } }
/** * Join arrays provided as parameters, all arrays must be the same type, null * values allowed. * * @param <T> type of array * @param arrays array of arrays to be joined * @return all joined arrays as single array * @since 1.0 */ @Nonnull @MayContainNull @Weight(Weight.Unit.NORMAL) public static <T> T[] joinArrays(@MayContainNull final T[]... arrays) { int commonLength = 0; for (final T[] array : arrays) { if (array != null) { commonLength += array.length; } } @SuppressWarnings("unchecked") final T[] result = (T[]) Array.newInstance(arrays.getClass().getComponentType().getComponentType(), commonLength); int position = 0; for (final T[] array : arrays) { if (array != null) { System.arraycopy(array, 0, result, position, array.length); position += array.length; } } return result; }
private boolean processMenuEvent(@Nonnull final PlatformMenuEvent event, @Nullable @MayContainNull final Object... args) { final PlatformMenuAction action = this.actions.get(event); boolean handled = false; if (action == null) { LOGGER.info("No registered menu event handler : " + event);//NOI18N } else { handled = action.doPlatformMenuAction(event, args); LOGGER.info("Processed menu event : " + event); //NOI18N } return handled; }
private boolean processMenuEvent(@Nonnull final PlatformMenuEvent event, @Nullable @MayContainNull final Object... args) { final PlatformMenuAction action = this.actions.get(event); boolean handled = false; if (action == null) { LOGGER.info("No registered menu event handler : " + event);//NOI18N } else { handled = action.doPlatformMenuAction(event, args); LOGGER.info("Processed menu event : " + event); //NOI18N } return handled; }
/** * Check that object is presented among provided elements and replace the object by equal element from the list. * * @param <T> type of object * @param obj object to be checked * @param list list of elements for checking * @return equal element provided in the list * @throws AssertionError if object is not found among defined ones * @since 1.0.2 */ @Nullable public static <T> T assertAmong(@Nullable T obj, @MayContainNull @Nonnull final T... list) { if (obj == null) { for (final T i : assertNotNull(list)) { if (i == null) { return i; } } } else { final int objHash = obj.hashCode(); for (final T i : assertNotNull(list)) { if (obj == i || (i!=null && objHash == i.hashCode() && obj.equals(i))) { return i; } } } final AssertionError error = new AssertionError("Object is not found among elements"); MetaErrorListeners.fireError("Asserion error", error); throw error; }
@Nonnull final DialogProvider dialogProvider, @Nullable final Topic actionTopic, @Nonnull @MayContainNull final Topic[] selectedTopics, @Nullable final CustomJob processor) { final JMenuItem result = UI_COMPO_FACTORY.makeMenuItem(getName(panel, actionTopic, selectedTopics), getIcon(panel, actionTopic, selectedTopics));
@Nonnull final DialogProvider dialogProvider, @Nullable final Topic actionTopic, @Nonnull @MayContainNull final Topic[] selectedTopics, @Nullable final CustomJob processor) { final JMenuItem result = UI_COMPO_FACTORY.makeMenuItem(getName(panel, actionTopic, selectedTopics), getIcon(panel, actionTopic, selectedTopics));
@Nonnull final PopUpSection section, final boolean fullScreenModeActive, @Nonnull @MayContainNull final List<JMenuItem> list, @Nonnull DialogProvider dialogProvider, @Nullable final Topic topicUnderMouse,
@Override public boolean doPlatformMenuAction(@Nonnull final PlatformMenuEvent event, @Nullable @MayContainNull final Object... args) { boolean handled = false; switch (event) { case ABOUT: { this.menuAboutActionPerformed(new ActionEvent(this, 0, "about")); //NOI18N handled = true; } break; case QUIT: { handled = doClosing(); if (handled) { dispose(); } } break; case REOPEN_APPLICATION: { this.setVisible(true); handled = true; } break; case PREFERENCES: { editPreferences(); handled = true; } break; } return handled; }
public void removeExtras(@Nullable @MayContainNull final Extra<?>... extras) { this.map.lock(); try { if (extras == null || extras.length == 0) { this.extras.clear(); } else { for (final Extra<?> e : extras) { if (e != null) { this.extras.remove(e.getType()); } } } } finally { this.map.unlock(); } }