use of org.freeplane.core.ui.IUserInputListenerFactory in project freeplane by freeplane.
the class SaveAcceleratorPresetsAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final String keyset = JOptionPane.showInputDialog(TextUtils.getText("enter_keyset_name"));
if (keyset == null || keyset.equals("")) {
return;
}
final File acceleratorsUserDirectory = LoadAcceleratorPresetsAction.getAcceleratorsUserDirectory();
final File keysetFile = new File(acceleratorsUserDirectory, keyset + ".properties");
if (keysetFile.exists()) {
final int confirm = JOptionPane.showConfirmDialog(UITools.getMenuComponent(), TextUtils.getText("overwrite_keyset_question"), "Freeplane", JOptionPane.YES_NO_OPTION);
if (confirm != JOptionPane.YES_OPTION) {
return;
}
}
try {
acceleratorsUserDirectory.mkdirs();
final OutputStream output = new BufferedOutputStream(new FileOutputStream(keysetFile));
final IUserInputListenerFactory userInputListenerFactory = Controller.getCurrentModeController().getUserInputListenerFactory();
ResourceController.getResourceController().getAcceleratorManager().storeAcceleratorPreset(output);
output.close();
userInputListenerFactory.rebuildMenus("load_accelerator_presets");
} catch (final IOException e1) {
UITools.errorMessage(TextUtils.getText("can_not_save_key_set"));
}
}
use of org.freeplane.core.ui.IUserInputListenerFactory in project freeplane by freeplane.
the class NodeView method setMainView.
void setMainView(final MainView newMainView) {
if (contentPane != null) {
assert (contentPane.getParent() == this);
if (mainView != null)
removeContent(MAIN_VIEWER_POSITION);
addContent(newMainView, MAIN_VIEWER_POSITION);
assert (contentPane.getParent() == this);
} else if (mainView != null) {
final Container c = mainView.getParent();
int i;
for (i = c.getComponentCount() - 1; i >= 0 && mainView != c.getComponent(i); i--) {
;
}
c.remove(i);
c.add(newMainView, i);
} else {
add(newMainView);
}
mainView = newMainView;
ModeController modeController = getMap().getModeController();
if (modeController.canEdit(getModel())) {
final IUserInputListenerFactory userInputListenerFactory = modeController.getUserInputListenerFactory();
mainView.addMouseListener(userInputListenerFactory.getNodeMouseMotionListener());
mainView.addMouseMotionListener(userInputListenerFactory.getNodeMouseMotionListener());
mainView.addMouseWheelListener(userInputListenerFactory.getNodeMouseWheelListener());
mainView.addKeyListener(userInputListenerFactory.getNodeKeyListener());
addDragListener(userInputListenerFactory.getNodeDragListener());
addDropListener(userInputListenerFactory.getNodeDropTargetListener());
}
}
use of org.freeplane.core.ui.IUserInputListenerFactory in project freeplane by freeplane.
the class LastOpenedList method updateMenus.
private void updateMenus() {
final IUserInputListenerFactory userInputListenerFactory = Controller.getCurrentModeController().getUserInputListenerFactory();
userInputListenerFactory.rebuildMenus("lastOpenedMaps");
}
use of org.freeplane.core.ui.IUserInputListenerFactory in project freeplane by freeplane.
the class MenuBuilderAcceptanceTest method setup.
@BeforeClass
public static void setup() {
final IUserInputListenerFactory userInputListenerFactory = mock(IUserInputListenerFactory.class);
when(userInputListenerFactory.getToolBar("/main_toolbar")).thenReturn(new JToolBar());
when(userInputListenerFactory.getNodePopupMenu()).thenReturn(new JPopupMenu());
when(userInputListenerFactory.getMapPopup()).thenReturn(new JPopupMenu());
when(userInputListenerFactory.getMenuBar()).thenReturn(TestMenuBarFactory.createFreeplaneMenuBar());
final PhaseProcessor buildProcessor = new MenuBuildProcessFactory(userInputListenerFactory, Controller.getCurrentModeController(), new FreeplaneResourceAccessor(), mock(IAcceleratorMap.class), new EntriesForAction(), Collections.<BuildPhaseListener>emptyList()).getBuildProcessor();
final String menuResource = "/xml/mindmapmodemenu.xml";
final InputStream resource = MenuBuilderAcceptanceTest.class.getResourceAsStream(menuResource);
final BufferedReader reader = new BufferedReader(new InputStreamReader(resource));
menuStructure = XmlEntryStructureBuilder.buildMenuStructure(reader);
buildProcessor.build(menuStructure);
}
use of org.freeplane.core.ui.IUserInputListenerFactory in project freeplane by freeplane.
the class MLogicalStyleController method initM.
public void initM() {
final ModeController modeController = Controller.getCurrentModeController();
modeController.getMapController().addNodeChangeListener(new StyleRemover());
modeController.registerExtensionCopier(new ExtensionCopier());
modeController.addAction(new RedefineStyleAction());
modeController.addAction(new NewUserStyleAction());
modeController.addAction(new ManageMapConditionalStylesAction());
modeController.addAction(new ManageNodeConditionalStylesAction());
modeController.addAction(new CopyStyleExtensionsAction());
if (modeController.getModeName().equals("MindMap")) {
modeController.addAction(new MapBackgroundColorAction());
modeController.addAction(new MapBackgroundImageAction());
modeController.addAction(new MapBackgroundClearAction());
modeController.addAction(new SetBooleanMapPropertyAction(MapStyle.FIT_TO_VIEWPORT));
modeController.addAction(new CopyMapStylesAction());
}
if (!modeController.getController().getViewController().isHeadless()) {
modeController.addUiBuilder(Phase.ACTIONS, "style_actions", new StyleMenuBuilder(modeController), new ChildActionEntryRemover(modeController));
final IUserInputListenerFactory userInputListenerFactory = modeController.getUserInputListenerFactory();
Controller.getCurrentController().getMapViewManager().addMapSelectionListener(new IMapSelectionListener() {
public void beforeMapChange(final MapModel oldMap, final MapModel newMap) {
}
public void afterMapChange(final MapModel oldMap, final MapModel newMap) {
userInputListenerFactory.rebuildMenus(STYLE_ACTIONS);
}
});
final MapController mapController = modeController.getMapController();
mapController.addMapChangeListener(new IMapChangeListener() {
public void onPreNodeMoved(NodeMoveEvent nodeMoveEvent) {
}
public void onPreNodeDelete(NodeDeletionEvent nodeDeletionEvent) {
}
public void onNodeMoved(NodeMoveEvent nodeMoveEvent) {
}
public void onNodeInserted(final NodeModel parent, final NodeModel child, final int newIndex) {
}
public void onNodeDeleted(NodeDeletionEvent nodeDeletionEvent) {
}
public void mapChanged(final MapChangeEvent event) {
if (event.getProperty().equals(MapStyle.MAP_STYLES)) {
userInputListenerFactory.rebuildMenus(STYLE_ACTIONS);
}
}
});
mapController.addNodeSelectionListener(new INodeSelectionListener() {
public void onSelect(final NodeModel node) {
selectActions();
}
public void onDeselect(final NodeModel node) {
}
});
}
}
Aggregations