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.sqlconsole.ui.SQLConsolePanel.java
/** * Create actions instances/*from w w w .j ava 2 s. c o 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(SQLAction.A_EXECUTE, I18N.tr("Execute"), I18N.tr("Run SQL statements"), SQLConsoleIcon.getIcon("execute"), EventHandler.create(ActionListener.class, this, "onExecute"), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom"); actions.addAction(executeAction); //Execute Selected SQL executeSelectedAction = new DefaultAction(SQLAction.A_EXECUTE_SELECTION, I18N.tr("Execute selected"), I18N.tr("Run selected SQL statements"), SQLConsoleIcon.getIcon("execute_selection"), EventHandler.create(ActionListener.class, this, "onExecuteSelected"), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.ALT_DOWN_MASK)).setLogicalGroup("custom") .setAfter(SQLAction.A_EXECUTE); actions.addAction(executeSelectedAction); //Clear action clearAction = new DefaultAction(SQLAction.A_CLEAR, I18N.tr("Clear"), I18N.tr("Erase the content of the editor"), SQLConsoleIcon.getIcon("erase"), EventHandler.create(ActionListener.class, this, "onClear"), null).setLogicalGroup("custom") .setAfter(SQLAction.A_EXECUTE_SELECTION); actions.addAction(clearAction); //Find action findAction = new DefaultAction(SQLAction.A_SEARCH, I18N.tr("Search.."), I18N.tr("Search text in the document"), SQLConsoleIcon.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)) .setLogicalGroup("custom"); actions.addAction(findAction); //Quote quoteAction = new DefaultAction(SQLAction.A_QUOTE, I18N.tr("Quote"), I18N.tr("Quote selected text"), null, EventHandler.create(ActionListener.class, this, "onQuote"), KeyStroke.getKeyStroke(KeyEvent.VK_SLASH, InputEvent.SHIFT_DOWN_MASK)).setLogicalGroup("format"); actions.addAction(quoteAction); //unQuote unQuoteAction = new DefaultAction(SQLAction.A_UNQUOTE, I18N.tr("Un Quote"), I18N.tr("Un Quote selected text"), null, EventHandler.create(ActionListener.class, this, "onUnQuote"), KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SLASH, InputEvent.SHIFT_DOWN_MASK)) .setLogicalGroup("format"); actions.addAction(unQuoteAction); // Comment/Uncomment commentAction = new DefaultAction(SQLAction.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); // Block Comment/Uncomment blockCommentAction = new DefaultAction(SQLAction.A_BLOCKCOMMENT, I18N.tr("Block (un)comment"), I18N.tr("Block (un)comment the selected text."), null, EventHandler.create(ActionListener.class, this, "onBlockComment"), KeyStroke.getKeyStroke("alt shift C")).setLogicalGroup("format"); actions.addAction(blockCommentAction); //Format SQL formatSQLAction = new DefaultAction(SQLAction.A_FORMAT, I18N.tr("Format"), I18N.tr("Format editor content"), null, EventHandler.create(ActionListener.class, this, "onFormatCode"), KeyStroke.getKeyStroke("alt shift F")).setLogicalGroup("format"); actions.addAction(formatSQLAction); //Save saveAction = new DefaultAction(SQLAction.A_SAVE, I18N.tr("Save"), I18N.tr("Save the editor content into a file"), SQLConsoleIcon.getIcon("save"), EventHandler.create(ActionListener.class, this, "onSaveFile"), KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom"); actions.addAction(saveAction); // Save As saveAsAction = new DefaultAction(SQLAction.A_SAVE, I18N.tr("Save As"), I18N.tr("Save the editor content into a new file"), SQLConsoleIcon.getIcon("page_white_save"), EventHandler.create(ActionListener.class, this, "onSaveAsNewFile"), KeyStroke.getKeyStroke("ctrl maj s")).setLogicalGroup("custom"); actions.addAction(saveAsAction); //Open action actions.addAction(new DefaultAction(SQLAction.A_OPEN, I18N.tr("Open"), I18N.tr("Load a file in this editor"), SQLConsoleIcon.getIcon("open"), EventHandler.create(ActionListener.class, this, "onOpenFile"), KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom")); //ShowHide function list actions.addAction(new DefaultAction(SQLAction.A_SQL_LIST, I18N.tr("SQL list"), I18N.tr("Show/Hide SQL function list"), SQLConsoleIcon.getIcon("builtinfunctionmap"), EventHandler.create(ActionListener.class, this, "onShowHideFunctionPanel"), null) .setLogicalGroup("custom")); //Time out action actions.addAction(new DefaultAction(SQLAction.A_SQL_TIMEOUT, I18N.tr("Timeout"), I18N.tr("Custom a time out to execute the SQL statement"), SQLConsoleIcon.getIcon("timeout_sql"), EventHandler.create(ActionListener.class, this, "onSQLTimeOut"), KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom")); }
From source file:org.orbisgis.sqlconsole.ui.SQLConsolePanel.java
private RTextScrollPane getCenterPanel() { if (centerPanel == null) { scriptPanel = new RSyntaxTextArea(); scriptPanel.setSyntaxEditingStyle(RSyntaxTextArea.SYNTAX_STYLE_SQL); scriptPanel.setLineWrap(true);//from w ww .j av a 2s. com scriptPanel.setClearWhitespaceLinesEnabled(true); scriptPanel.setMarkOccurrences(false); scriptPanel.setTabsEmulated(true); scriptPanel.setTabSize(4); actions.setAccelerators(scriptPanel); //TODO track language support bundles codeReformator = new CodeReformator(";", COMMENT_SPECS); scriptPanel .addCaretListener(EventHandler.create(CaretListener.class, this, "onScriptPanelCaretUpdate")); scriptPanel.getDocument().addDocumentListener( EventHandler.create(DocumentListener.class, this, "onUserSelectionChange")); //Add custom actions scriptPanel.getPopupMenu().addSeparator(); actions.registerContainer(scriptPanel.getPopupMenu()); centerPanel = new RTextScrollPane(scriptPanel); onUserSelectionChange(); } return centerPanel; }
From source file:org.orbisgis.view.beanshell.BshConsolePanel.java
/** * Create actions instances//from www. j av a 2s. c om * * 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(BeanShellAction.A_EXECUTE, I18N.tr("Execute"), I18N.tr("Execute the java script"), OrbisGISIcon.getIcon("execute"), EventHandler.create(ActionListener.class, this, "onExecute"), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK)); actions.addAction(executeAction); //Clear action clearAction = new DefaultAction(BeanShellAction.A_CLEAR, I18N.tr("Clear"), I18N.tr("Erase the content of the editor"), OrbisGISIcon.getIcon("erase"), EventHandler.create(ActionListener.class, this, "onClear"), null); actions.addAction(clearAction); //Open action actions.addAction( new DefaultAction(BeanShellAction.A_OPEN, I18N.tr("Open"), I18N.tr("Load a file in this editor"), OrbisGISIcon.getIcon("open"), EventHandler.create(ActionListener.class, this, "onOpenFile"), KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK))); //Save saveAction = new DefaultAction(BeanShellAction.A_SAVE, I18N.tr("Save"), I18N.tr("Save the editor content into a file"), OrbisGISIcon.getIcon("save"), EventHandler.create(ActionListener.class, this, "onSaveFile"), KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)); actions.addAction(saveAction); //Find action findAction = new DefaultAction(BeanShellAction.A_SEARCH, I18N.tr("Search.."), I18N.tr("Search text in the document"), OrbisGISIcon.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); }
From source file:org.orbisgis.view.beanshell.BshConsolePanel.java
private RTextScrollPane getCenterPanel() { if (centerPanel == null) { initActions();//from w ww .ja v a2 s .co m LanguageSupportFactory lsf = LanguageSupportFactory.get(); jls = (JavaLanguageSupport) lsf.getSupportFor(SyntaxConstants.SYNTAX_STYLE_JAVA); try { setCurrentLibraryInfos(jls.getJarManager()); } catch (IOException ioe) { throw new RuntimeException(ioe); } scriptPanel = new RSyntaxTextArea(); scriptPanel.setLineWrap(true); lsf.register(scriptPanel); scriptPanel.setSyntaxEditingStyle(RSyntaxTextArea.SYNTAX_STYLE_JAVA); scriptPanel .addCaretListener(EventHandler.create(CaretListener.class, this, "onScriptPanelCaretUpdate")); scriptPanel.getDocument().addDocumentListener( EventHandler.create(DocumentListener.class, this, "onUserSelectionChange")); scriptPanel.clearParsers(); 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.view.beanshell.BshConsolePanel.java
private void setStatusMessage(String message) { currentStatusMessage = message;/*from w w w .j a v a 2 s.co m*/ if (messageClearTimer == null) { messageClearTimer = new Timer(MESSAGE_CLEAR_INTERVAL, EventHandler.create(ActionListener.class, this, "onClearMessage")); messageClearTimer.setRepeats(false); } if (!message.isEmpty()) { messageClearTimer.restart(); } statusMessage.setText(String.format(MESSAGEBASE, line, character, message)); }
From source file:org.orbisgis.view.components.fstree.TreeNodeFolder.java
@Override public void feedPopupMenu(JPopupMenu menu) { if (menu.getComponentCount() > 0) { menu.addSeparator();/* w w w. jav a2 s. c om*/ } // 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"), OrbisGISIcon.getIcon("arrow_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"), OrbisGISIcon.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"), OrbisGISIcon.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); } }
From source file:org.orbisgis.view.geocatalog.Catalog.java
private void createPopupActions() { //Popup:Add// w w w . j a v a 2 s . co m popupActions.addAction(new DefaultAction(PopupMenu.M_ADD, I18N.tr("Add")).setMenuGroup(true) .setLogicalGroup(PopupMenu.GROUP_ADD)); //Popup:Add:File popupActions.addAction(new DefaultAction(PopupMenu.M_ADD_FILE, I18N.tr("File"), I18N.tr("Add a file from hard drive."), OrbisGISIcon.getIcon("page_white_add"), EventHandler.create(ActionListener.class, this, "onMenuAddFile"), null).setParent(PopupMenu.M_ADD)); //Popup:Add:Folder popupActions.addAction(new DefaultAction(PopupMenu.M_ADD_FOLDER, I18N.tr("Folder"), I18N.tr("Add a set of file from an hard drive folder."), OrbisGISIcon.getIcon("folder_add"), EventHandler.create(ActionListener.class, this, "onMenuAddFilesFromFolder"), null) .setParent(PopupMenu.M_ADD)); //Popup:Add:DataBase popupActions.addAction(new DefaultAction(PopupMenu.M_ADD_DB, I18N.tr("DataBase"), I18N.tr("Add one or more tables from a DataBase"), OrbisGISIcon.getIcon("database_add"), EventHandler.create(ActionListener.class, this, "onMenuAddFromDataBase"), null) .setParent(PopupMenu.M_ADD)); //Popup:Add:WMS popupActions.addAction(new DefaultAction(PopupMenu.M_ADD_WMS, I18N.tr("WMS server"), I18N.tr("Add a WebMapService"), OrbisGISIcon.getIcon("server_connect"), EventHandler.create(ActionListener.class, this, "onMenuAddWMSServer"), null) .setParent(PopupMenu.M_ADD)); //Popup:Save popupActions .addAction(new ActionOnSelection(PopupMenu.M_SAVE, I18N.tr("Save"), true, getListSelectionModel()) .setLogicalGroup(PopupMenu.GROUP_ADD)); //Popup:Save:File popupActions.addAction(new ActionOnSelection(PopupMenu.M_SAVE_FILE, I18N.tr("File"), I18N.tr("Save selected sources in files"), OrbisGISIcon.getIcon("page_white_save"), EventHandler.create(ActionListener.class, this, "onMenuSaveInfile"), getListSelectionModel()) .setParent(PopupMenu.M_SAVE)); //Popup:Save:Db popupActions.addAction(new ActionOnSelection(PopupMenu.M_SAVE_DB, I18N.tr("Database"), I18N.tr("Save selected sources in a data base"), OrbisGISIcon.getIcon("database_save"), EventHandler.create(ActionListener.class, this, "onMenuSaveInDB"), getListSelectionModel()) .setParent(PopupMenu.M_SAVE)); //Popup:Open attributes popupActions.addAction(new ActionOnSelection(PopupMenu.M_OPEN_ATTRIBUTES, I18N.tr("Open the attributes"), I18N.tr("Open the data source table"), OrbisGISIcon.getIcon("openattributes"), EventHandler.create(ActionListener.class, this, "onMenuShowTable"), getListSelectionModel()) .setLogicalGroup(PopupMenu.GROUP_OPEN)); //Popup:Remove sources popupActions.addAction(new ActionOnSelection(PopupMenu.M_REMOVE, I18N.tr("Remove the source"), I18N.tr("Remove from this list the selected sources."), OrbisGISIcon.getIcon("remove"), EventHandler.create(ActionListener.class, this, "onMenuRemoveSource"), getListSelectionModel()) .setLogicalGroup(PopupMenu.GROUP_CLOSE)); //Clear Geo-catalog popupActions.addAction( new ActionOnNonEmptySourceList(PopupMenu.M_CLEAR_CATALOG, I18N.tr("Clear the GeoCatalog"), I18N.tr("Remove all sources in this list"), OrbisGISIcon.getIcon("bin_closed"), EventHandler.create(ActionListener.class, this, "onMenuClearGeoCatalog")) .setLogicalGroup(PopupMenu.GROUP_CLOSE)); }
From source file:org.orbisgis.view.geocatalog.SourceListModel.java
/** * Install listener(s) on SourceManager//from www.j a va2 s. co m */ public void setListeners() { sourceListener = EventHandler.create(SourceListener.class, this, "onDataManagerChange"); getDataManager().getSourceManager().addSourceListener(sourceListener); }
From source file:org.orbisgis.view.map.MapEditor.java
/** * Constructor/*from www . j a v a2 s. com*/ */ public MapEditor() { super(new BorderLayout()); dockingPanelParameters = new DockingPanelParameters(); dockingPanelParameters.setName("map_editor"); updateMapLabel(); dockingPanelParameters.setTitleIcon(OrbisGISIcon.getIcon("map")); dockingPanelParameters.setMinimizable(false); dockingPanelParameters.setExternalizable(false); dockingPanelParameters.setCloseable(false); dockingPanelParameters.setLayout(mapEditorPersistence); 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.view.map.MapEditor.java
/** * MapEditor tools declaration/*from www . ja va2 s. c o m*/ */ private void createActions() { // 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 ActionAutomaton(MapEditorAction.A_PAN, new PanTool(), this).setLogicalGroup("navigation")); actions.addAction(new DefaultAction(MapEditorAction.A_FULL_EXTENT, I18N.tr("Full extent"), OrbisGISIcon.getIcon("world"), EventHandler.create(ActionListener.class, this, "onFullExtent")) .setToolTipText(I18N.tr("Zoom to show all geometries")).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")); actions.addAction(new DefaultAction(MapEditorAction.A_CLEAR_SELECTION, I18N.tr("Clear selection"), OrbisGISIcon.getIcon("edit-clear"), EventHandler.create(ActionListener.class, this, "onClearSelection")) .setToolTipText(I18N.tr("Clear all selected geometries of all layers")) .setLogicalGroup("selection")); actions.addAction(new DefaultAction(MapEditorAction.A_ZOOM_SELECTION, I18N.tr("Zoom to selection"), OrbisGISIcon.getIcon("zoom_selected"), EventHandler.create(ActionListener.class, this, "onZoomToSelection")) .setToolTipText(I18N.tr("Zoom to visible selected geometries")) .setLogicalGroup("selection")); actions.addAction(new DefaultAction(MapEditorAction.A_DATA_SOURCE_FROM_SELECTION, I18N.tr("Create datasource from selection"), OrbisGISIcon.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 tree"), OrbisGISIcon.getIcon("map"), EventHandler.create(ActionListener.class, this, "onShowHideMapsTree")) .setToolTipText(I18N.tr("Show/Hide maps tree"))); actions.addAction(new DefaultAction(MapEditorAction.A_MAP_EXPORT_IMAGE, I18N.tr("Export map as image"), OrbisGISIcon.getIcon("export_image"), EventHandler.create(ActionListener.class, this, "onExportMapRendering")) .setToolTipText(I18N.tr("Export image as file"))); }