List of usage examples for javax.swing AbstractAction AbstractAction
public AbstractAction(String name, Icon icon)
From source file:com.intuit.tank.tools.debugger.ActionProducer.java
/** * // ww w . ja va 2 s. com * @return */ public Action getOpenScriptAction() { Action ret = actionMap.get(ACTION_CHOOSE_SCRIPT); if (ret == null) { ret = new AbstractAction(ACTION_CHOOSE_SCRIPT, getIcon("script_lightning.png", IconSize.SMALL)) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { try { ScriptDescriptionContainer scriptDescriptions = scriptServiceClient.getScriptDescriptions(); List<ScriptDescription> scripts = scriptDescriptions.getScripts(); Collections.sort(scripts, new Comparator<ScriptDescription>() { @Override public int compare(ScriptDescription o1, ScriptDescription o2) { return o2.getCreated().compareTo(o1.getCreated()); } }); SelectDialog<ScriptDescription> selectDialog = new SelectDialog<ScriptDescription>( debuggerFrame, scripts, "script"); selectDialog.setVisible(true); final ScriptDescription scriptSelected = selectDialog.getSelectedObject(); if (scriptSelected != null) { debuggerFrame.startWaiting(); setFromString(null); // get script in thread new Thread(new Runnable() { public void run() { try { String scriptXml = scriptServiceClient .downloadHarnessXml(scriptSelected.getId()); setFromString(scriptXml); debuggerFrame .setCurrentTitle("Selected Script: " + scriptSelected.getName()); debuggerFrame.setScriptSource(new ScriptSource( scriptSelected.getId().toString(), SourceType.script)); } catch (Exception e1) { debuggerFrame.stopWaiting(); showError("Error downloading script: " + e1); } finally { debuggerFrame.stopWaiting(); } } }).start(); } } catch (Exception e1) { showError("Error downloading script: " + e1); } } }; ret.putValue(Action.SHORT_DESCRIPTION, "Choose Script from Tank."); actionMap.put(ACTION_CHOOSE_SCRIPT, ret); } return ret; }
From source file:com.intuit.tank.tools.debugger.ActionProducer.java
/** * /* w w w . jav a 2 s .c o m*/ * @return */ public Action getSelectDataFileAction() { Action ret = actionMap.get(ACTION_CHOOSE_DATAFILE); if (ret == null) { ret = new AbstractAction(ACTION_CHOOSE_DATAFILE, getIcon("table_lightning.png", IconSize.SMALL)) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { try { List<DataFileDescriptor> dataFiles = dataFileClient.getDataFiles(); Collections.sort(dataFiles, new Comparator<DataFileDescriptor>() { public int compare(DataFileDescriptor o1, DataFileDescriptor o2) { return o2.getName().compareTo(o1.getName()); } }); SelectDialog<DataFileDescriptor> selectDialog = new SelectDialog<DataFileDescriptor>( debuggerFrame, dataFiles, "datafiles", false); selectDialog.setVisible(true); List<DataFileDescriptor> selectedObjects = selectDialog.getSelectedObjects(); if (!selectedObjects.isEmpty()) { debuggerFrame.setDataFiles(selectedObjects); } } catch (Exception e1) { showError("Error downloading datafiles: " + e1); } } }; ret.putValue(Action.SHORT_DESCRIPTION, "Choose Datafiles from Tank."); actionMap.put(ACTION_CHOOSE_DATAFILE, ret); } return ret; }
From source file:com.intuit.tank.tools.debugger.ActionProducer.java
/** * //ww w . j a v a 2 s .c o m * @return */ public Action getShowVariablesAction() { Action ret = actionMap.get(ACTION_SHOW_VARIABLES); if (ret == null) { ret = new AbstractAction(ACTION_SHOW_VARIABLES, getIcon("data_grid.png", IconSize.SMALL)) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { try { new VariableDialog(debuggerFrame, debuggerFrame.getProjectVariables()).setVisible(true); } catch (Exception e1) { showError("Error downloading datafiles: " + e1); } } }; ret.putValue(Action.SHORT_DESCRIPTION, "Display and edit project variables."); actionMap.put(ACTION_SHOW_VARIABLES, ret); } return ret; }
From source file:it.cnr.icar.eric.client.ui.swing.RegistryBrowser.java
/** * DOCUMENT ME!//from w ww . ja va2s.c o m * * @return DOCUMENT ME! */ public JToolBar createDiscoveryToolBar() { JToolBar toolBar = new JToolBar(); toolBar.setFloatable(true); // Find URL findUrl = getClass().getClassLoader().getResource("icons/find.gif"); ImageIcon findIcon = new ImageIcon(findUrl); findButton = toolBar.add(new AbstractAction("", findIcon) { /** * */ private static final long serialVersionUID = 3307493586585435411L; public void actionPerformed(ActionEvent e) { findAction(); } }); findButton.setToolTipText(resourceBundle.getString("button.find")); // showSchemes URL showSchemesUrl = getClass().getClassLoader().getResource("icons/schemeViewer.gif"); ImageIcon showSchemesIcon = new ImageIcon(showSchemesUrl); showSchemesButton = toolBar.add(new AbstractAction("", showSchemesIcon) { /** * */ private static final long serialVersionUID = 1899451223510883277L; public void actionPerformed(ActionEvent e) { if (RegistryBrowser.client.connection == null) { displayUnconnectedError(); } else { ConceptsTreeDialog.showSchemes(RegistryBrowser.getInstance(), false, isAuthenticated()); } } }); showSchemesButton.setToolTipText(resourceBundle.getString("button.showSchemes")); // Re-authenticate URL authenticateUrl = getClass().getClassLoader().getResource("icons/authenticate.gif"); ImageIcon authenticateIcon = new ImageIcon(authenticateUrl); authenticateButton = toolBar.add(new AbstractAction("", authenticateIcon) { /** * */ private static final long serialVersionUID = 3469608949024981381L; public void actionPerformed(ActionEvent e) { authenticate(); } }); authenticateButton.setToolTipText(resourceBundle.getString("button.authenticate")); // Logout URL logoutUrl = getClass().getClassLoader().getResource("icons/logoff.gif"); ImageIcon logoutIcon = new ImageIcon(logoutUrl); logoutButton = toolBar.add(new AbstractAction("", logoutIcon) { /** * */ private static final long serialVersionUID = -293987897100997408L; public void actionPerformed(ActionEvent e) { logout(); } }); logoutButton.setToolTipText(resourceBundle.getString("button.logout")); logoutButton.setEnabled(false); // key registration URL keyRegUrl = getClass().getClassLoader().getResource("icons/keyReg.gif"); ImageIcon keyRegIcon = new ImageIcon(keyRegUrl); keyRegButton = toolBar.add(new AbstractAction("", keyRegIcon) { /** * */ private static final long serialVersionUID = -8988435962749097387L; public void actionPerformed(ActionEvent e) { RegistryBrowser.setWaitCursor(); // showKeyRegistrationWizard(); KeyManager keyMgr = KeyManager.getInstance(); try { keyMgr.registerNewKey(); } catch (Exception er) { RegistryBrowser.displayError(er); } RegistryBrowser.setDefaultCursor(); } }); keyRegButton.setToolTipText(resourceBundle.getString("button.keyReg")); // user registration URL userRegUrl = getClass().getClassLoader().getResource("icons/userReg.gif"); ImageIcon userRegIcon = new ImageIcon(userRegUrl); userRegButton = toolBar.add(new AbstractAction("", userRegIcon) { /** * */ private static final long serialVersionUID = 8890984621456210702L; public void actionPerformed(ActionEvent e) { RegistryBrowser.setWaitCursor(); // showUserRegistrationWizard(); if (RegistryBrowser.client.connection == null) { displayUnconnectedError(); } else { UserManager userMgr = UserManager.getInstance(); try { // Make sure you are logged off when registering new // user so new user is not owned by old user. logout(); userMgr.registerNewUser(); logout(); } catch (Exception er) { RegistryBrowser.displayError(er); } } RegistryBrowser.setDefaultCursor(); } }); userRegButton.setToolTipText(resourceBundle.getString("button.userReg")); // locale selection URL localeSelUrl = getClass().getClassLoader().getResource("icons/localeSel.gif"); ImageIcon localeSelIcon = new ImageIcon(localeSelUrl); localeSelButton = toolBar.add(new AbstractAction("", localeSelIcon) { /** * */ private static final long serialVersionUID = 6304340858289330717L; public void actionPerformed(ActionEvent e) { RegistryBrowser.setWaitCursor(); LocaleSelectorDialog dialog = getLocaleSelectorDialog(); @SuppressWarnings("unused") Locale oldSelectedLocale = getSelectedLocale(); dialog.setVisible(true); Locale selectedLocale = getSelectedLocale(); System.out.println(getLocale()); setLocale(selectedLocale); RegistryBrowser.setDefaultCursor(); } }); localeSelButton.setToolTipText(resourceBundle.getString("button.localeSel")); return toolBar; }
From source file:com.intuit.tank.tools.debugger.ActionProducer.java
/** * // ww w. ja va 2s . co m * @return */ public Action getOpenProjectAction() { Action ret = actionMap.get(ACTION_CHOOSE_PROJECT); if (ret == null) { ret = new AbstractAction(ACTION_CHOOSE_PROJECT, getIcon("application_lightning.png", IconSize.SMALL)) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { try { List<ProjectTO> projects = projectServiceClient.getProjects(); Collections.sort(projects, new Comparator<ProjectTO>() { @Override public int compare(ProjectTO o1, ProjectTO o2) { return o2.getCreated().compareTo(o1.getCreated()); } }); SelectDialog<ProjectTO> selectDialog = new SelectDialog<ProjectTO>(debuggerFrame, projects, "project"); selectDialog.setVisible(true); final ProjectTO selected = selectDialog.getSelectedObject(); if (selected != null) { debuggerFrame.startWaiting(); setFromString(null); // get script in thread new Thread(new Runnable() { public void run() { try { String scriptXml = projectServiceClient .downloadTestScriptForProject(selected.getId()); debuggerFrame.setDataFromProject(selected); setFromString(scriptXml); debuggerFrame.setCurrentTitle("Selected Project: " + selected.getName()); debuggerFrame.setScriptSource( new ScriptSource(selected.getId().toString(), SourceType.project)); debuggerFrame.stopWaiting(); } catch (Exception e1) { e1.printStackTrace(); debuggerFrame.stopWaiting(); showError("Error opening projects: " + e1); } finally { debuggerFrame.stopWaiting(); } } }).start(); } } catch (Exception e1) { showError("Error opening projects: " + e1); } } }; ret.putValue(Action.SHORT_DESCRIPTION, "Choose Project from Tank."); actionMap.put(ACTION_CHOOSE_PROJECT, ret); } return ret; }
From source file:org.apache.log4j.chainsaw.LogUI.java
/** * Initialises the Help system and the WelcomePanel * */// w ww. j a va 2 s. com private void setupHelpSystem() { welcomePanel = new WelcomePanel(); JToolBar tb = welcomePanel.getToolbar(); tb.add(new SmallButton(new AbstractAction("Tutorial", new ImageIcon(ChainsawIcons.HELP)) { public void actionPerformed(ActionEvent e) { setupTutorial(); } })); tb.addSeparator(); final Action exampleConfigAction = new AbstractAction("View example Receiver configuration") { public void actionPerformed(ActionEvent e) { HelpManager.getInstance().setHelpURL(ChainsawConstants.EXAMPLE_CONFIG_URL); } }; exampleConfigAction.putValue(Action.SHORT_DESCRIPTION, "Displays an example Log4j configuration file with several Receivers defined."); JButton exampleButton = new SmallButton(exampleConfigAction); tb.add(exampleButton); tb.add(Box.createHorizontalGlue()); /** * Setup a listener on the HelpURL property and automatically change the WelcomePages URL * to it. */ HelpManager.getInstance().addPropertyChangeListener("helpURL", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { URL newURL = (URL) evt.getNewValue(); if (newURL != null) { welcomePanel.setURL(newURL); ensureWelcomePanelVisible(); } } }); }
From source file:com.intuit.tank.tools.debugger.ActionProducer.java
/** * /*w w w .j a v a2 s . c om*/ * @return */ public Action getStartAction() { Action ret = actionMap.get(ACTION_START); if (ret == null) { ret = new AbstractAction(ACTION_START, getIcon("bug_go.png", IconSize.SMALL)) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { debuggerFrame.start(); } }; ret.putValue(Action.SHORT_DESCRIPTION, "Start debugging script."); actionMap.put(ACTION_START, ret); } return ret; }
From source file:es.emergya.ui.plugins.admin.AdminLayers.java
protected Action subeCapaAction(final CapaInformacion capa) { Action a = new AbstractAction("", LogicConstants.getIcon("button_up")) { private static final long serialVersionUID = 912391796510206341L; @Override/*from w ww. j av a 2s . c o m*/ public void actionPerformed(ActionEvent e) { log.debug("subeCapaAction(" + capa + ")"); SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { CapaInformacionAdmin.sube(capa); return null; } @Override protected void done() { super.done(); AdminLayers.this.refresh(null); } }; sw.execute(); } }; return a; }
From source file:com.intuit.tank.tools.debugger.ActionProducer.java
/** * /* w w w.jav a2 s . c o m*/ * @return */ public Action getNextStepAction() { Action ret = actionMap.get(ACTION_NEXT); if (ret == null) { ret = new AbstractAction(ACTION_NEXT, getIcon("control_play_blue.png", IconSize.SMALL)) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { debuggerFrame.next(); } }; ret.putValue(Action.SHORT_DESCRIPTION, "Execute the next step."); actionMap.put(ACTION_NEXT, ret); } return ret; }
From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java
private JPanel buildPanelFilter(final String topLabel, final int textfieldSize, final Dimension dimension, final JList list, final boolean left) { JPanel left_filtro = new JPanel(new GridBagLayout()); left_filtro.setPreferredSize(dimension); left_filtro.setOpaque(false);/*w ww . j a v a 2 s . co m*/ final GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.BASELINE_LEADING; left_filtro.add(new JLabel(topLabel, JLabel.LEFT), gbc); final JTextField filtro = new JTextField(textfieldSize); gbc.gridy++; left_filtro.add(filtro, gbc); AbstractAction actionStartFilter = new AbstractAction(null, getIcon("Buttons.noFiltrar")) { private static final long serialVersionUID = -4737487889360372801L; @Override public void actionPerformed(ActionEvent e) { ((DefaultListModel) list.getModel()).removeAllElements(); filtro.setText(null); if (left) { for (Object obj : leftItems) { ((DefaultListModel) list.getModel()).addElement(obj); } } else { for (Object obj : rightItems) { ((DefaultListModel) list.getModel()).addElement(obj); } } } }; AbstractAction actionStopFilter = new AbstractAction(null, getIcon("Buttons.filtrar")) { private static final long serialVersionUID = 6570608476764008290L; @Override public void actionPerformed(ActionEvent e) { ((DefaultListModel) list.getModel()).removeAllElements(); if (left) { for (Object obj : leftItems) { if (compare(filtro, obj)) { ((DefaultListModel) list.getModel()).addElement(obj); } } } else { for (Object obj : rightItems) { if (compare(filtro, obj)) { ((DefaultListModel) list.getModel()).addElement(obj); } } } } private boolean compare(final JTextField filtro, Object obj) { final String elemento = obj.toString().toUpperCase().trim(); final String text = filtro.getText().toUpperCase().trim(); final String pattern = text.replace("*", ".*"); boolean res = Pattern.matches(pattern, elemento); return res;// || elemento.indexOf(text) >= 0; } }; JButton jButton = new JButton(actionStartFilter); JButton jButton2 = new JButton(actionStopFilter); jButton.setBorderPainted(false); jButton2.setBorderPainted(false); jButton.setContentAreaFilled(false); jButton2.setContentAreaFilled(false); jButton.setPreferredSize( new Dimension(jButton.getIcon().getIconWidth(), jButton.getIcon().getIconHeight())); jButton2.setPreferredSize( new Dimension(jButton2.getIcon().getIconWidth(), jButton2.getIcon().getIconHeight())); gbc.gridx++; left_filtro.add(jButton2, gbc); gbc.gridx++; left_filtro.add(jButton, gbc); return left_filtro; }