Search in sources :

Example 1 with PopUpMenuItemPlugin

use of com.igormaznitsa.mindmap.plugins.api.PopUpMenuItemPlugin in project netbeans-mmd-plugin by raydac.

the class MindMapPanelControllerImpl method getCustomProcessors.

private Map<Class<? extends PopUpMenuItemPlugin>, CustomJob> getCustomProcessors() {
    if (this.customProcessors == null) {
        this.customProcessors = new HashMap<Class<? extends PopUpMenuItemPlugin>, CustomJob>();
        this.customProcessors.put(ExtraNotePlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nullable @MustNotContainNull final Topic[] selectedTopics) {
                editTextForTopic(topic);
                panel.requestFocus();
            }
        });
        this.customProcessors.put(ExtraFilePlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nullable @MustNotContainNull final Topic[] selectedTopics) {
                editFileLinkForTopic(topic);
                panel.requestFocus();
            }
        });
        this.customProcessors.put(ExtraURIPlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nullable @MustNotContainNull final Topic[] selectedTopics) {
                editLinkForTopic(topic);
                panel.requestFocus();
            }
        });
        this.customProcessors.put(ExtraJumpPlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nullable @MustNotContainNull final Topic[] selectedTopics) {
                editTopicLinkForTopic(topic);
                panel.requestFocus();
            }
        });
        this.customProcessors.put(ChangeColorPlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nullable @MustNotContainNull final Topic[] selectedTopics) {
                processColorDialogForTopics(panel, selectedTopics.length > 0 ? selectedTopics : new Topic[] { topic });
            }
        });
        this.customProcessors.put(AboutPlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nullable @MustNotContainNull final Topic[] selectedTopics) {
                showAbout();
            }
        });
        this.customProcessors.put(OptionsPlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nullable @MustNotContainNull final Topic[] selectedTopics) {
                startOptionsEdit();
            }
        });
    }
    return this.customProcessors;
}
Also used : PopUpMenuItemPlugin(com.igormaznitsa.mindmap.plugins.api.PopUpMenuItemPlugin) CustomJob(com.igormaznitsa.mindmap.plugins.api.CustomJob)

Example 2 with PopUpMenuItemPlugin

use of com.igormaznitsa.mindmap.plugins.api.PopUpMenuItemPlugin in project netbeans-mmd-plugin by raydac.

the class Utils method findPopupMenuItems.

@Nonnull
@MustNotContainNull
private static List<JMenuItem> findPopupMenuItems(@Nonnull final MindMapPanel panel, @Nonnull final PopUpSection section, final boolean fullScreenModeActive, @Nonnull @MayContainNull final List<JMenuItem> list, @Nonnull DialogProvider dialogProvider, @Nullable final Topic topicUnderMouse, @Nonnull @MustNotContainNull final Topic[] selectedTopics, @Nonnull @MustNotContainNull final List<PopUpMenuItemPlugin> pluginMenuItems, @Nonnull Map<Class<? extends PopUpMenuItemPlugin>, CustomJob> customProcessors) {
    list.clear();
    for (final PopUpMenuItemPlugin p : pluginMenuItems) {
        if (fullScreenModeActive && !p.isCompatibleWithFullScreenMode()) {
            continue;
        }
        if (p.getSection() == section) {
            if (!(p.needsTopicUnderMouse() || p.needsSelectedTopics()) || (p.needsTopicUnderMouse() && topicUnderMouse != null) || (p.needsSelectedTopics() && selectedTopics.length > 0)) {
                final JMenuItem item = p.makeMenuItem(panel, dialogProvider, topicUnderMouse, selectedTopics, customProcessors.get(p.getClass()));
                if (item != null) {
                    item.setEnabled(p.isEnabled(panel, topicUnderMouse, selectedTopics));
                    list.add(item);
                }
            }
        }
    }
    return list;
}
Also used : PopUpMenuItemPlugin(com.igormaznitsa.mindmap.plugins.api.PopUpMenuItemPlugin) Nonnull(javax.annotation.Nonnull) MustNotContainNull(com.igormaznitsa.meta.annotation.MustNotContainNull)

Example 3 with PopUpMenuItemPlugin

use of com.igormaznitsa.mindmap.plugins.api.PopUpMenuItemPlugin in project netbeans-mmd-plugin by raydac.

the class MMDEditor method getCustomProcessors.

@Nonnull
private Map<Class<? extends PopUpMenuItemPlugin>, CustomJob> getCustomProcessors() {
    if (this.customProcessors == null) {
        this.customProcessors = new HashMap<>();
        this.customProcessors.put(ExtraNotePlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nonnull @MustNotContainNull final Topic[] selectedTopics) {
                if (topic != null) {
                    editTextForTopic(topic);
                    panel.requestFocus();
                }
            }
        });
        this.customProcessors.put(ExtraFilePlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nonnull @MustNotContainNull final Topic[] selectedTopics) {
                editFileLinkForTopic(topic);
                panel.requestFocus();
            }
        });
        this.customProcessors.put(ExtraURIPlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nonnull @MustNotContainNull final Topic[] selectedTopics) {
                editLinkForTopic(topic);
                panel.requestFocus();
            }
        });
        this.customProcessors.put(ExtraJumpPlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nonnull @MustNotContainNull final Topic[] selectedTopics) {
                editTopicLinkForTopic(topic);
                panel.requestFocus();
            }
        });
        this.customProcessors.put(ChangeColorPlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nonnull @MustNotContainNull final Topic[] selectedTopics) {
                processColorDialogForTopics(panel, selectedTopics.length > 0 ? selectedTopics : new Topic[] { topic });
            }
        });
    }
    return this.customProcessors;
}
Also used : CustomJob(com.igormaznitsa.mindmap.plugins.api.CustomJob) PopUpMenuItemPlugin(com.igormaznitsa.mindmap.plugins.api.PopUpMenuItemPlugin) Nonnull(javax.annotation.Nonnull)

Example 4 with PopUpMenuItemPlugin

use of com.igormaznitsa.mindmap.plugins.api.PopUpMenuItemPlugin in project netbeans-mmd-plugin by raydac.

the class MMDGraphEditor method getCustomProcessors.

private Map<Class<? extends PopUpMenuItemPlugin>, CustomJob> getCustomProcessors() {
    if (this.customProcessors == null) {
        this.customProcessors = new HashMap<Class<? extends PopUpMenuItemPlugin>, CustomJob>();
        this.customProcessors.put(ExtraNotePlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nonnull @MustNotContainNull final Topic[] selectedTopics) {
                editTextForTopic(topic);
                panel.requestFocus();
            }
        });
        this.customProcessors.put(ExtraFilePlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nonnull @MustNotContainNull final Topic[] selectedTopics) {
                editFileLinkForTopic(topic);
                panel.requestFocus();
            }
        });
        this.customProcessors.put(ExtraURIPlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nonnull @MustNotContainNull final Topic[] selectedTopics) {
                editLinkForTopic(topic);
                panel.requestFocus();
            }
        });
        this.customProcessors.put(ExtraJumpPlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nonnull @MustNotContainNull final Topic[] selectedTopics) {
                editTopicLinkForTopic(topic);
                panel.requestFocus();
            }
        });
        this.customProcessors.put(ChangeColorPlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nonnull @MustNotContainNull final Topic[] selectedTopics) {
                processColorDialogForTopics(panel, selectedTopics.length > 0 ? selectedTopics : new Topic[] { topic });
            }
        });
        this.customProcessors.put(AboutPlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nonnull @MustNotContainNull final Topic[] selectedTopics) {
                // NOI18N
                NbUtils.plainMessageOk(null, BUNDLE.getString("MMDGraphEditor.makePopUp.msgAboutTitle"), new AboutPanel());
            }
        });
        this.customProcessors.put(OptionsPlugin.class, new CustomJob() {

            @Override
            public void doJob(@Nonnull final PopUpMenuItemPlugin plugin, @Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nonnull @MustNotContainNull final Topic[] selectedTopics) {
                // NOI18N
                OptionsDisplayer.getDefault().open("nb-mmd-config-main");
            }
        });
    }
    return this.customProcessors;
}
Also used : PopUpMenuItemPlugin(com.igormaznitsa.mindmap.plugins.api.PopUpMenuItemPlugin) CustomJob(com.igormaznitsa.mindmap.plugins.api.CustomJob)

Aggregations

PopUpMenuItemPlugin (com.igormaznitsa.mindmap.plugins.api.PopUpMenuItemPlugin)4 CustomJob (com.igormaznitsa.mindmap.plugins.api.CustomJob)3 Nonnull (javax.annotation.Nonnull)2 MustNotContainNull (com.igormaznitsa.meta.annotation.MustNotContainNull)1