2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2015 - Marcos CARDINOT
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
13 package org.scilab.modules.xcos.palette.actions;
15 import java.awt.Dimension;
16 import java.awt.FlowLayout;
17 import java.awt.event.ActionEvent;
18 import java.lang.reflect.InvocationTargetException;
20 import javax.swing.ImageIcon;
21 import javax.swing.JButton;
22 import javax.swing.JPanel;
23 import javax.swing.JTextField;
25 import org.scilab.modules.commons.gui.FindIconHelper;
26 import org.scilab.modules.commons.gui.ScilabLAF;
27 import org.scilab.modules.gui.events.callback.CommonCallBack;
28 import org.scilab.modules.xcos.utils.XcosMessages;
31 * Search Palettes Action
32 * @author Marcos CARDINOT <mcardinot@gmail.com>
34 public class SearchAction extends CommonCallBack {
36 private static final long serialVersionUID = 1L;
38 private static final String LABEL_SEARCH = XcosMessages.SEARCH;
39 private static final String ICON_SEARCH = FindIconHelper.findIcon("system-search");
41 private static JButton btnSearch;
42 private static JTextField txtSearch;
43 private static JPanel searchBar;
48 public SearchAction() {
53 * Create the search bar
56 public static JPanel createSearchBar() {
57 searchBar = new JPanel();
58 searchBar.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
60 txtSearch = new JTextField();
61 txtSearch.setPreferredSize(new Dimension(150, 22));
62 searchBar.add(txtSearch);
64 btnSearch = new JButton();
65 ScilabLAF.setDefaultProperties(btnSearch);
66 btnSearch.setIcon(new ImageIcon(ICON_SEARCH));
67 btnSearch.setToolTipText(LABEL_SEARCH);
68 btnSearch.addActionListener(getCallBack());
69 btnSearch.setFocusable(true);
70 btnSearch.setBorderPainted(false);
71 searchBar.add(btnSearch);
77 * Create a new class instance
78 * @return the instance
80 private static CommonCallBack getCallBack() {
81 CommonCallBack callback = null;
83 callback = SearchAction.class.getConstructor().newInstance();
84 } catch (IllegalArgumentException e) {
86 } catch (SecurityException e) {
88 } catch (InstantiationException e) {
90 } catch (IllegalAccessException e) {
92 } catch (InvocationTargetException e) {
94 } catch (NoSuchMethodException e) {
102 * @param e ActionEvent
104 public void actionPerformed(ActionEvent e) {
109 public void callBack() {