List of usage examples for java.beans EventHandler create
public static <T> T create(Class<T> listenerInterface, Object target, String action)
From source file:org.orbisgis.groovy.GroovyConsolePanel.java
@Override public void setEditableElement(EditableElement editableElement) { if (editableElement instanceof GroovyElement) { this.groovyElement = (GroovyElement) editableElement; groovyElement.setDocument(scriptPanel); groovyElement.addPropertyChangeListener(GroovyElement.PROP_DOCUMENT_PATH, EventHandler.create(PropertyChangeListener.class, this, "onPathChanged")); onPathChanged();/*w ww .j ava2 s . c o m*/ LoadScript loadScript = new LoadScript(groovyElement); if (executorService != null) { executorService.execute(loadScript); } else { loadScript.execute(); } } }
From source file:org.orbisgis.mapeditor.map.MapEditor.java
@Activate public void activate() { this.mapsManager = new MapsManager(viewWorkspace.getMapContextPath(), dataManager, editorManager); dockingPanelParameters = new DockingPanelParameters(); dockingPanelParameters.setName("map_editor"); updateMapLabel();//from www .j a v a 2s . com dockingPanelParameters.setTitleIcon(MapEditorIcons.getIcon("map")); dockingPanelParameters.setMinimizable(false); dockingPanelParameters.setExternalizable(false); dockingPanelParameters.setCloseable(false); dockingPanelParameters.setLayout(mapEditorPersistence); dockingPanelParameters.setVisible(true); layeredPane.add(mapControl, 1); layeredPane.add(mapsManager, 0); mapsManager.setVisible(false); mapsManager.setMapsManagerPersistence(mapEditorPersistence.getMapsManagerPersistence()); // when the layout is loaded, this editor will load the map element linked with this layout mapEditorPersistence.addPropertyChangeListener(MapEditorPersistence.PROP_DEFAULTMAPCONTEXT, EventHandler.create(PropertyChangeListener.class, this, "onSerialisationMapChange")); add(layeredPane, BorderLayout.CENTER); add(mapStatusBar, BorderLayout.PAGE_END); //Declare Tools of Map Editors //Add the tools in the docking Panel title createActions(); dockingPanelParameters.setDockActions(actions.getActions()); // Tools that will be created later will also be set in the docking panel // thanks to this listener actions.addPropertyChangeListener(new ActionDockingListener(dockingPanelParameters)); //Set the Drop target dragDropHandler = new MapTransferHandler(); this.setTransferHandler(dragDropHandler); }
From source file:org.orbisgis.mapeditor.map.MapEditor.java
/** * MapEditor tools declaration/* w w w. j a v a 2s . co m*/ */ private void createActions() { // Cache control actions.addAction(new DefaultAction(MapEditorAction.A_MAP_CLEAR_CACHE, I18N.tr("Refresh"), MapEditorIcons.getIcon("refresh"), EventHandler.create(ActionListener.class, this, "onClearCache"))); // Navigation tools actions.addAction(new ActionAutomaton(MapEditorAction.A_ZOOM_IN, new ZoomInTool(), this) .setLogicalGroup("navigation")); actions.addAction(new ActionAutomaton(MapEditorAction.A_ZOOM_OUT, new ZoomOutTool(), this) .setLogicalGroup("navigation")); actions.addAction(new DefaultAction(MapEditorAction.A_FULL_EXTENT, I18N.tr("Full extent"), MapEditorIcons.getIcon("zoom_extent"), EventHandler.create(ActionListener.class, this, "onFullExtent")) .setToolTipText(I18N.tr("Zoom to show all geometries")).setLogicalGroup("navigation")); actions.addAction( new ActionAutomaton(MapEditorAction.A_PAN, new PanTool(), this).setLogicalGroup("navigation")); // Selection tools actions.addAction(new ActionAutomaton(MapEditorAction.A_INFO_TOOL, new InfoTool(), this) .addTrackedMapContextProperty(MapContext.PROP_SELECTEDLAYERS) .addTrackedMapContextProperty(MapContext.PROP_SELECTEDSTYLES).setLogicalGroup("selection")); actions.addAction(new ActionAutomaton(MapEditorAction.A_SELECTION, new SelectionTool(), this) .addTrackedMapContextProperty(MapContext.PROP_SELECTEDLAYERS) .addTrackedMapContextProperty(MapContext.PROP_SELECTEDSTYLES).setLogicalGroup("selection")); //Clear selection group actions.addAction( new DefaultAction(MapEditorAction.A_CLEAR_SELECTION_GROUP, I18N.tr("Clear selection tools")) .setMenuGroup(true)); actions.addAction(new DefaultAction(MapEditorAction.A_CLEAR_ALL_SELECTION, I18N.tr("Clear all selection"), MapEditorIcons.getIcon("edit-clear_all"), EventHandler.create(ActionListener.class, this, "onClearAllSelection")) .setToolTipText(I18N.tr("Clear all selected geometries of all layers")) .setParent(MapEditorAction.A_CLEAR_SELECTION_GROUP)); actions.addAction(new DefaultAction(MapEditorAction.A_CLEAR_LAYER_SELECTION, I18N.tr("Clear selected layers"), MapEditorIcons.getIcon("edit-clear"), EventHandler.create(ActionListener.class, this, "onClearLayerSelection")) .setToolTipText(I18N.tr("Clear all selected geometries of the selected layers")) .setParent(MapEditorAction.A_CLEAR_SELECTION_GROUP)); //Zoom to selection group actions.addAction(new DefaultAction(MapEditorAction.A_ZOOM_SELECTION_GROUP, I18N.tr("Zoom to tools")) .setMenuGroup(true)); actions.addAction(new DefaultAction(MapEditorAction.A_ZOOM_ALL_SELECTION, I18N.tr("Zoom to all selection"), MapEditorIcons.getIcon("zoom_selected_all"), EventHandler.create(ActionListener.class, this, "onZoomToAllSelection")) .setToolTipText(I18N.tr("Zoom to all selected geometries")) .setParent(MapEditorAction.A_ZOOM_SELECTION_GROUP)); actions.addAction(new DefaultAction(MapEditorAction.A_ZOOM_LAYER_SELECTION, I18N.tr("Zoom to layer selection"), MapEditorIcons.getIcon("zoom_selected"), EventHandler.create(ActionListener.class, this, "onZoomToLayerSelection")) .setToolTipText(I18N.tr("Zoom to selected geometries of the selected layers")) .setParent(MapEditorAction.A_ZOOM_SELECTION_GROUP)); actions.addAction(new DefaultAction(MapEditorAction.A_DATA_SOURCE_FROM_SELECTION, I18N.tr("Create datasource from selection"), MapEditorIcons.getIcon("table_go"), EventHandler.create(ActionListener.class, this, "onCreateDataSourceFromSelection")) .setToolTipText(I18N.tr("Create a datasource from the current selection")) .setLogicalGroup("selection")); // Measure tools actions.addAction( new DefaultAction(MapEditorAction.A_MEASURE_GROUP, I18N.tr("Mesure tools")).setMenuGroup(true)); actions.addAction(new ActionAutomaton(MapEditorAction.A_MEASURE_LINE, new MesureLineTool(), this) .setParent(MapEditorAction.A_MEASURE_GROUP)); actions.addAction(new ActionAutomaton(MapEditorAction.A_MEASURE_POLYGON, new MesurePolygonTool(), this) .setParent(MapEditorAction.A_MEASURE_GROUP)); actions.addAction(new ActionAutomaton(MapEditorAction.A_COMPASS, new CompassTool(), this) .setParent(MapEditorAction.A_MEASURE_GROUP)); // Drawing tools actions.addAction( new DefaultAction(MapEditorAction.A_DRAWING_GROUP, I18N.tr("Graphic tools")).setMenuGroup(true)); actions.addAction(new ActionAutomaton(MapEditorAction.A_FENCE, new FencePolygonTool(), this) .setParent(MapEditorAction.A_DRAWING_GROUP)); actions.addAction( new ActionAutomaton(MapEditorAction.A_PICK_COORDINATES, new PickCoordinatesPointTool(), this) .setParent(MapEditorAction.A_DRAWING_GROUP)); // Maps manager actions.addAction(new DefaultAction(MapEditorAction.A_MAP_TREE, I18N.tr("Maps manager"), MapEditorIcons.getIcon("map_manager"), EventHandler.create(ActionListener.class, this, "onShowHideMapsTree")) .setToolTipText(I18N.tr("Show/Hide Maps Manager"))); actions.addAction(new DefaultAction(MapEditorAction.A_MAP_EXPORT_IMAGE, I18N.tr("Export map as image"), MapEditorIcons.getIcon("export_image"), EventHandler.create(ActionListener.class, this, "onExportMapRendering")) .setToolTipText(I18N.tr("Export image as file"))); // Parameters //actions.addAction(new DefaultAction(MapEditorAction.A_PARAMETERS,I18N.tr("Configuration"), // MapEditorIcons.getIcon("config")).setMenuGroup(true)); //actions.addAction(new DefaultAction(MapEditorAction.A_DATA_PROVIDERS,I18N.tr("Data query"), // MapEditorIcons.getIcon("table_go")).setMenuGroup(true).setParent(MapEditorAction.A_PARAMETERS)); }
From source file:org.orbisgis.mapeditor.map.mapsManager.TreeLeafMapContextFile.java
@Override public void feedPopupMenu(JPopupMenu menu) { super.feedPopupMenu(menu); if (!isLoaded()) { JMenuItem folderRemove = new JMenuItem(I18N.tr("Delete"), MapEditorIcons.getIcon("remove")); folderRemove.setToolTipText(I18N.tr("Remove permanently the map")); folderRemove.setActionCommand("delete"); folderRemove.addActionListener(EventHandler.create(ActionListener.class, this, "onDeleteFile")); MenuCommonFunctions.updateOrInsertMenuItem(menu, folderRemove); }/*from www .ja v a 2s. c om*/ }
From source file:org.orbisgis.r.RConsolePanel.java
/** * The main panel to write and execute a groovy script. * * @return//ww w. j a v a2s . co m */ private RTextScrollPane getCenterPanel() { if (centerPanel == null) { initActions(); scriptPanel = new RSyntaxTextArea(); scriptPanel.setLineWrap(true); scriptPanel .addCaretListener(EventHandler.create(CaretListener.class, this, "onScriptPanelCaretUpdate")); scriptPanel.getDocument().addDocumentListener( EventHandler.create(DocumentListener.class, this, "onUserSelectionChange")); scriptPanel.clearParsers(); scriptPanel.setTabsEmulated(true); actions.setAccelerators(scriptPanel); // Actions will be set on the scriptPanel PopupMenu scriptPanel.getPopupMenu().addSeparator(); actions.registerContainer(scriptPanel.getPopupMenu()); centerPanel = new RTextScrollPane(scriptPanel); onUserSelectionChange(); } return centerPanel; }
From source file:org.orbisgis.r.RConsolePanel.java
/** * Create actions instances/*from www .j a v a 2 s. co m*/ * * Each action is put in the Popup menu and the tool bar Their shortcuts are * registered also in the editor */ private void initActions() { //Execute action executeAction = new DefaultAction(RConsoleActions.A_EXECUTE, I18N.tr("Execute"), I18N.tr("Execute the R script"), RIcon.getIcon("execute"), EventHandler.create(ActionListener.class, this, "onExecute"), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK)); actions.addAction(executeAction); //Execute Selected SQL executeSelectedAction = new DefaultAction(RConsoleActions.A_EXECUTE_SELECTION, I18N.tr("Execute selected"), I18N.tr("Run selected code"), RIcon.getIcon("execute_selection"), EventHandler.create(ActionListener.class, this, "onExecuteSelected"), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.ALT_DOWN_MASK)).setLogicalGroup("custom") .setAfter(RConsoleActions.A_EXECUTE); actions.addAction(executeSelectedAction); //Clear action clearAction = new DefaultAction(RConsoleActions.A_CLEAR, I18N.tr("Clear"), I18N.tr("Erase the content of the editor"), RIcon.getIcon("erase"), EventHandler.create(ActionListener.class, this, "onClear"), null); actions.addAction(clearAction); //Open action actions.addAction( new DefaultAction(RConsoleActions.A_OPEN, I18N.tr("Open"), I18N.tr("Load a file in this editor"), RIcon.getIcon("open"), EventHandler.create(ActionListener.class, this, "onOpenFile"), KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK))); //Save saveAction = new DefaultAction(RConsoleActions.A_SAVE, I18N.tr("Save"), I18N.tr("Save the editor content into a file"), RIcon.getIcon("save"), EventHandler.create(ActionListener.class, this, "onSaveFile"), KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)); actions.addAction(saveAction); // Save As saveAsAction = new DefaultAction(RConsoleActions.A_SAVE, I18N.tr("Save As"), I18N.tr("Save the editor content into a new file"), RIcon.getIcon("page_white_save"), EventHandler.create(ActionListener.class, this, "onSaveAsNewFile"), KeyStroke.getKeyStroke("ctrl maj s")); actions.addAction(saveAsAction); //Find action findAction = new DefaultAction(RConsoleActions.A_SEARCH, I18N.tr("Search.."), I18N.tr("Search text in the document"), RIcon.getIcon("find"), EventHandler.create(ActionListener.class, this, "openFindReplaceDialog"), KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK)) .addStroke(KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK)); actions.addAction(findAction); // Comment/Uncomment commentAction = new DefaultAction(RConsoleActions.A_COMMENT, I18N.tr("(Un)comment"), I18N.tr("(Un)comment the selected text"), null, EventHandler.create(ActionListener.class, this, "onComment"), KeyStroke.getKeyStroke("alt C")) .setLogicalGroup("format"); actions.addAction(commentAction); }
From source file:org.orbisgis.r.RConsolePanel.java
@Override public void setEditableElement(EditableElement editableElement) { if (editableElement instanceof RElement) { this.rElement = (RElement) editableElement; rElement.setDocument(scriptPanel); rElement.addPropertyChangeListener(RElement.PROP_DOCUMENT_PATH, EventHandler.create(PropertyChangeListener.class, this, "onPathChanged")); onPathChanged();//from w w w . ja va 2 s. c o m LoadScript loadScript = new LoadScript(rElement); if (executorService != null) { executorService.execute(loadScript); } else { loadScript.execute(); } } }
From source file:org.orbisgis.sif.components.fstree.FileTree.java
@Override public void addNotify() { super.addNotify(); if (!initialized.getAndSet(true)) { setTransferHandler(new FileTreeTransferHandler()); setDragEnabled(true);// w w w . j a v a 2 s. c om setCellRenderer(new CustomTreeCellRenderer(this)); addMouseListener(treeMouse); getSelectionModel().addTreeSelectionListener( EventHandler.create(TreeSelectionListener.class, this, "onSelectionChange")); javax.swing.ToolTipManager.sharedInstance().registerComponent(this); } }
From source file:org.orbisgis.sif.components.fstree.FileTree.java
/** * Fetch all selected items to make a pop-up menu * @return /* w w w . j a va 2 s. co m*/ */ private JPopupMenu makePopupMenu() { JPopupMenu menu = new JPopupMenu(); TreePath[] paths = getSelectionPaths(); if (paths != null) { // Generic action on single TreeNode if (paths.length == 1) { Object component = paths[0].getLastPathComponent(); if (component instanceof AbstractTreeNode) { AbstractTreeNode aTreeNode = (AbstractTreeNode) component; if (aTreeNode.isEditable()) { JMenuItem editMenu = new JMenuItem(I18N.tr("Rename")); editMenu.addActionListener(EventHandler.create(ActionListener.class, this, "onRenameItem")); editMenu.setActionCommand("rename"); menu.add(editMenu); } } } for (TreePath treePath : paths) { Object component = treePath.getLastPathComponent(); // All nodes if (component instanceof MutableTreeNode) { MutableTreeNode node = (MutableTreeNode) component; for (TreeNodeFileFactory fact : getFactories()) { fact.feedTreeNodePopupMenu(node, menu); } } // Specific nodes if (component instanceof PopupTreeNode) { PopupTreeNode treeNode = (PopupTreeNode) component; treeNode.feedPopupMenu(menu); } } } return menu; }
From source file:org.orbisgis.sif.components.fstree.TreeNodeFolder.java
@Override public void feedPopupMenu(JPopupMenu menu) { if (menu.getComponentCount() > 0) { menu.addSeparator();/*from w w w . ja v a2 s.com*/ } // Open the folder JMenuItem copyPathMenu = new JMenuItem(I18N.tr("Copy the path")); copyPathMenu.setToolTipText(I18N.tr("Copy the folder path in the clipboard")); copyPathMenu.setActionCommand("TreeNodeFolder:CopyPath"); copyPathMenu.addActionListener(EventHandler.create(ActionListener.class, this, "onCopyPath")); MenuCommonFunctions.updateOrInsertMenuItem(menu, copyPathMenu); // Read the file system to update the tree JMenuItem updateMenu = new JMenuItem(I18N.tr("Update"), SifIcon.getIcon("refresh")); updateMenu.setToolTipText(I18N.tr("Update the content of this folder from the file system")); updateMenu.setActionCommand("Update"); updateMenu.addActionListener(EventHandler.create(ActionListener.class, this, "updateTree")); MenuCommonFunctions.updateOrInsertMenuItem(menu, updateMenu); // Add a new Sub Folder JMenuItem newSubFolder = new JMenuItem(I18N.tr("New folder"), SifIcon.getIcon("folder_add")); newSubFolder.setToolTipText(I18N.tr("Create a sub-folder")); newSubFolder.setActionCommand("TreeNodeFolder:newSubFolder"); newSubFolder.addActionListener(EventHandler.create(ActionListener.class, this, "onNewSubFolder")); MenuCommonFunctions.updateOrInsertMenuItem(menu, newSubFolder); // Remove the folder //The root folder cannot be removed if (parent instanceof TreeNodeFolder) { JMenuItem folderRemove = new JMenuItem(I18N.tr("Delete"), SifIcon.getIcon("remove")); folderRemove.setToolTipText(I18N.tr("Remove permanently the folder")); folderRemove.setActionCommand("delete"); folderRemove.addActionListener(EventHandler.create(ActionListener.class, this, "onDeleteFolder")); MenuCommonFunctions.updateOrInsertMenuItem(menu, folderRemove, true); } }