List of usage examples for javax.swing AbstractAction AbstractAction
public AbstractAction()
From source file:org.apache.log4j.chainsaw.LogUI.java
/** * Initialises the menu's and toolbars, but does not actually create any of * the main panel components.//from w ww . j a v a 2 s. c om * */ private void initGUI() { setupHelpSystem(); statusBar = new ChainsawStatusBar(this); setupReceiverPanel(); setToolBarAndMenus(new ChainsawToolBarAndMenus(this)); toolbar = getToolBarAndMenus().getToolbar(); setJMenuBar(getToolBarAndMenus().getMenubar()); setTabbedPane(new ChainsawTabbedPane()); getSettingsManager().addSettingsListener(getTabbedPane()); getSettingsManager().configure(getTabbedPane()); /** * This adds Drag & Drop capability to Chainsaw */ FileDnDTarget dnDTarget = new FileDnDTarget(tabbedPane); dnDTarget.addPropertyChangeListener("fileList", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { final List fileList = (List) evt.getNewValue(); Thread thread = new Thread(new Runnable() { public void run() { logger.debug("Loading files: " + fileList); for (Iterator iter = fileList.iterator(); iter.hasNext();) { File file = (File) iter.next(); final Decoder decoder = new XMLDecoder(); try { getStatusBar().setMessage("Loading " + file.getAbsolutePath() + "..."); FileLoadAction.importURL(handler, decoder, file.getName(), file.toURI().toURL()); } catch (Exception e) { String errorMsg = "Failed to import a file"; logger.error(errorMsg, e); getStatusBar().setMessage(errorMsg); } } } }); thread.setPriority(Thread.MIN_PRIORITY); thread.start(); } }); applicationPreferenceModelPanel = new ApplicationPreferenceModelPanel(applicationPreferenceModel); applicationPreferenceModelPanel.setOkCancelActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { preferencesFrame.setVisible(false); } }); KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false); Action closeAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { preferencesFrame.setVisible(false); } }; preferencesFrame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE"); preferencesFrame.getRootPane().getActionMap().put("ESCAPE", closeAction); OSXIntegration.init(this); }
From source file:org.nuclos.client.main.MainController.java
void init() throws CommonPermissionException, BackingStoreException { debugFrame = new SwingDebugFrame(this); try {/*ww w . j a va 2 s.c o m*/ // force to load real permission (tp) SecurityCache.getInstance().revalidate(); cmdExecuteRport = createEntityAction(NuclosEntity.REPORTEXECUTION); /** @todo this is a workaround - because Main.getMainController() is called to get the user name */ Main.getInstance().setMainController(this); LOG.debug(">>> read user rights..."); loginController.increaseLoginProgressBar(StartUp.PROGRESS_INIT_SECURITYCACHE); if (!getSecurityCache().isActionAllowed(Actions.ACTION_SYSTEMSTART)) { throw new CommonPermissionException(getSpringLocaleDelegate().getMessage("MainController.23", "Sie haben nicht das Recht, {0} zu benutzen.", ApplicationProperties.getInstance().getName())); } loginController.increaseLoginProgressBar(StartUp.PROGRESS_READ_ATTRIBUTES); // DefaultCollectableEntityProvider.setInstance(NuclosCollectableEntityProvider.getInstance()); Thread threadGenericObjectMetaDataCache = new Thread("MainController.readMetaData") { @Override public void run() { LOG.debug(">>> read metadata..."); // GenericObjectMetaDataCache.getInstance(); SpringApplicationContextHolder.getBean(GenericObjectMetaDataCache.class); } }; loginController.increaseLoginProgressBar(StartUp.PROGRESS_READ_LOMETA); Thread threadSearchFilterCache = new Thread("MainController.readSearchFilter") { @Override public void run() { LOG.debug(">>> read searchfilter..."); // SearchFilterCache.getInstance(); SpringApplicationContextHolder.getBean(SearchFilterCache.class); } }; loginController.increaseLoginProgressBar(StartUp.PROGRESS_READ_SEARCHFILTER); Thread threadRuleCache = new Thread("MainController.readRules") { @Override public void run() { LOG.debug(">>> read rules..."); // RuleCache.getInstance(); SpringApplicationContextHolder.getBean(RuleCache.class); } }; loginController.increaseLoginProgressBar(StartUp.PROGRESS_READ_RULES); List<Thread> lstCacheThreads = new ArrayList<Thread>(); lstCacheThreads.add(threadGenericObjectMetaDataCache); lstCacheThreads.add(threadSearchFilterCache); lstCacheThreads.add(threadRuleCache); threadGenericObjectMetaDataCache.start(); threadSearchFilterCache.start(); threadRuleCache.start(); for (Thread t : lstCacheThreads) { try { t.join(); } catch (InterruptedException e) { // do noting here LOG.warn("MainController: " + e); } } // !!! init messagelisteners here. // initialzing chaches in these threads will cause an deadlock situation at realSubscribe in TopicNotificationReceiver. // genericObjectMetaDataCache.initMessageListener(); // searchFilterCache.initMessageListener(); // ruleCache.initMessageListener(); SpringApplicationContextHolder.getBean(GenericObjectMetaDataCache.class).initMessageListener(); SpringApplicationContextHolder.getBean(SearchFilterCache.class).initMessageListener(); SpringApplicationContextHolder.getBean(RuleCache.class).initMessageListener(); LOG.debug(">>> create mainframe..."); // this.frm = new MainFrame(this.getUserName(), this.getNuclosServerName()); setMainFrame(SpringApplicationContextHolder.getBean(MainFrameSpringComponent.class).getMainFrame()); final MainFrame frm = getMainFrame(); frm.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); // Attention: Do not use ListenerUtil here! (tp) frm.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent ev) { cmdWindowClosing(new ResultListener<Boolean>() { @Override public void done(Boolean result) { } }); } }); loginController.increaseLoginProgressBar(StartUp.PROGRESS_CREATE_MAINFRAME); LOG.debug(">>> init client communication..."); this.notificationdlg = new NuclosNotificationDialog(frm); getTopicNotificationReceiver().subscribe(JMSConstants.TOPICNAME_RULENOTIFICATION, messagelistener); loginController.increaseLoginProgressBar(StartUp.PROGRESS_INIT_NOTIFICATION); LOG.debug(">>> setup menus..."); this.setupMenus(); loginController.increaseLoginProgressBar(StartUp.PROGRESS_CREATE_MAINMENU); LOG.debug(">>> create explorer controller..."); this.ctlExplorer = new ExplorerController(); LOG.debug(">>> create task controller..."); this.ctlTasks = new TaskController(getUserName()); this.ctlTasks.setExplorerController(ctlExplorer); this.ctlExplorer.setTaskController(ctlTasks); initActions(); LOG.debug(">>> restore last workspace..."); try { Main.getInstance().getMainFrame().readMainFramePreferences(prefs); getRestoreUtils().restoreWorkspaceThreaded(MainFrame.getLastWorkspaceIdFromPreferences(), MainFrame.getLastWorkspaceFromPreferences(), MainFrame.getLastAlwaysOpenWorkspaceIdFromPreferences(), MainFrame.getLastAlwaysOpenWorkspaceFromPreferences()); } catch (Exception ex) { final String sMessage = getSpringLocaleDelegate().getMessage("MainController.4", "Die in der letzten Sitzung ge\u00f6ffneten Fenster konnten nicht wiederhergestellt werden."); Errors.getInstance().showExceptionDialog(null, sMessage, ex); } finally { loginController.increaseLoginProgressBar(StartUp.PROGRESS_RESTORE_WORKSPACE); } LOG.debug(">>> show mainFrame..."); frm.setVisible(true); try { LOG.debug(">>> restore last controllers (for migration only)..."); reopenAllControllers(ClientPreferences.getUserPreferences()); } catch (Exception ex) { final String sMessage = getSpringLocaleDelegate().getMessage("MainController.4", "Die in der letzten Sitzung ge\u00f6ffneten Fenster konnten nicht wiederhergestellt werden."); Errors.getInstance().showExceptionDialog(null, sMessage, ex); } LOG.debug(">>> restore task views (for migration only)..."); try { ctlTasks.restoreGenericObjectTaskViewsFromPreferences(); } catch (Exception ex) { final String sMessage = getSpringLocaleDelegate().getMessage("tasklist.error.restore", "Die Aufgabenlisten konnten nicht wiederhergestellt werden."); LOG.error(sMessage, ex); Errors.getInstance().showExceptionDialog(null, sMessage, ex); } Thread theadTaskController = new Thread("MainController.refreshTasks") { @Override public void run() { LOG.debug(">>> refresh tasks..."); ctlTasks.run(); } }; theadTaskController.start(); /* Release note HACK: Caused by: java.lang.NullPointerException at org.nuclos.client.help.releasenotes.ReleaseNotesController.showNuclosReleaseNotesNotice(ReleaseNotesController.java:148) at org.nuclos.client.help.releasenotes.ReleaseNotesController.showReleaseNotesIfNewVersion(ReleaseNotesController.java:161) at org.nuclos.client.main.MainController.showReleaseNotesIfNewVersion(MainController.java:1752) at org.nuclos.client.main.MainController.<init>(MainController.java:382) */ while (getHomePane() == null) { Thread.sleep(200); } // Show the release notes for this version, if the user hasn't seen it yet. showReleaseNotesIfNewVersion(); // Debug purposes final String sKeyWindowShow = "CtlShiftF11"; frm.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( KeyStroke.getKeyStroke(KeyEvent.VK_F11, (KeyEvent.SHIFT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK)), sKeyWindowShow); frm.getRootPane().getActionMap().put(sKeyWindowShow, new AbstractAction() { @Override public void actionPerformed(ActionEvent ev) { debugFrame.showComponentDetails(frm.findComponentAt(frm.getMousePosition())); } }); //Call wikipage final String sKeyWikiShow = "CtlShiftF1"; frm.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( KeyStroke.getKeyStroke(KeyEvent.VK_F1, (KeyEvent.SHIFT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK)), sKeyWikiShow); frm.getRootPane().getActionMap().put(sKeyWikiShow, new AbstractAction() { @Override public void actionPerformed(ActionEvent ev) { Component fundComponent = frm.getFocusOwner() != null ? frm.getFocusOwner() : frm.findComponentAt(frm.getMousePosition()); CollectController<?> clctctrl = getControllerForTab(UIUtils.getTabForComponent(fundComponent)); WikiController wikiCtrl = WikiController.getInstance(); wikiCtrl.openURLinBrowser(wikiCtrl.getWikiPageForComponent(fundComponent, clctctrl)); } }); } catch (Throwable e) { LOG.fatal("Creating MainController failed, this is fatal: " + e.toString(), e); throw new ExceptionInInitializerError(e); } }
From source file:org.freeplane.view.swing.features.time.mindmapmode.NodeList.java
public void startup() { if (dialog != null) { dialog.toFront();//from www . j av a 2 s .co m return; } NodeList.COLUMN_MODIFIED = TextUtils.getText(PLUGINS_TIME_LIST_XML_MODIFIED); NodeList.COLUMN_CREATED = TextUtils.getText(PLUGINS_TIME_LIST_XML_CREATED); NodeList.COLUMN_ICONS = TextUtils.getText(PLUGINS_TIME_LIST_XML_ICONS); NodeList.COLUMN_TEXT = TextUtils.getText(PLUGINS_TIME_LIST_XML_TEXT); NodeList.COLUMN_DATE = TextUtils.getText(PLUGINS_TIME_LIST_XML_DATE); NodeList.COLUMN_NOTES = TextUtils.getText(PLUGINS_TIME_LIST_XML_NOTES); dialog = new JDialog(Controller.getCurrentController().getViewController().getFrame(), modal /* modal */); String windowTitle; if (showAllNodes) { windowTitle = PLUGINS_TIME_MANAGEMENT_XML_WINDOW_TITLE_ALL_NODES; } else { windowTitle = PLUGINS_TIME_MANAGEMENT_XML_WINDOW_TITLE; } dialog.setTitle(TextUtils.getText(windowTitle)); dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); final WindowAdapter windowListener = new WindowAdapter() { @Override public void windowGainedFocus(WindowEvent e) { mFilterTextSearchField.getEditor().selectAll(); } @Override public void windowClosing(final WindowEvent event) { disposeDialog(); } }; dialog.addWindowListener(windowListener); dialog.addWindowFocusListener(windowListener); UITools.addEscapeActionToDialog(dialog, new AbstractAction() { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { disposeDialog(); } }); final Container contentPane = dialog.getContentPane(); final GridBagLayout gbl = new GridBagLayout(); contentPane.setLayout(gbl); final GridBagConstraints layoutConstraints = new GridBagConstraints(); layoutConstraints.gridx = 0; layoutConstraints.gridy = 0; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.weightx = 0.0; layoutConstraints.weighty = 0.0; layoutConstraints.anchor = GridBagConstraints.WEST; layoutConstraints.fill = GridBagConstraints.HORIZONTAL; contentPane.add(new JLabel(TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_FIND)), layoutConstraints); layoutConstraints.gridwidth = 1; layoutConstraints.gridx++; contentPane.add(Box.createHorizontalStrut(40), layoutConstraints); layoutConstraints.gridx++; contentPane.add(new JLabel(TextUtils.getText("filter_match_case")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(matchCase, layoutConstraints); layoutConstraints.gridx++; contentPane.add(Box.createHorizontalStrut(40), layoutConstraints); layoutConstraints.gridx++; contentPane.add(new JLabel(TextUtils.getText("regular_expressions")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(useRegexInFind, layoutConstraints); layoutConstraints.gridx = 0; layoutConstraints.weightx = 1.0; layoutConstraints.gridwidth = GridBagConstraints.REMAINDER; layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(mFilterTextSearchField), layoutConstraints); layoutConstraints.gridy++; layoutConstraints.weightx = 0.0; layoutConstraints.gridwidth = 1; contentPane.add(new JLabel(TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_REPLACE)), layoutConstraints); layoutConstraints.gridx = 5; contentPane.add(new JLabel(TextUtils.getText("regular_expressions")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(useRegexInReplace, layoutConstraints); layoutConstraints.gridx = 0; layoutConstraints.weightx = 1.0; layoutConstraints.gridwidth = GridBagConstraints.REMAINDER; layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(mFilterTextReplaceField), layoutConstraints); dateRenderer = new DateRenderer(); nodeRenderer = new NodeRenderer(); notesRenderer = new NotesRenderer(); iconsRenderer = new IconsRenderer(); timeTable = new FlatNodeTable(); timeTable.addKeyListener(new FlatNodeTableKeyListener()); timeTable.addMouseListener(new FlatNodeTableMouseAdapter()); timeTable.getTableHeader().setReorderingAllowed(false); timeTableModel = updateModel(); mFlatNodeTableFilterModel = new FlatNodeTableFilterModel(timeTableModel, NodeList.NODE_TEXT_COLUMN); sorter = new TableSorter(mFlatNodeTableFilterModel); timeTable.setModel(sorter); sorter.setTableHeader(timeTable.getTableHeader()); sorter.setColumnComparator(Date.class, TableSorter.COMPARABLE_COMPARATOR); sorter.setColumnComparator(NodeModel.class, TableSorter.LEXICAL_COMPARATOR); sorter.setColumnComparator(IconsHolder.class, TableSorter.COMPARABLE_COMPARATOR); sorter.setSortingStatus(NodeList.DATE_COLUMN, TableSorter.ASCENDING); final JScrollPane pane = new JScrollPane(timeTable); UITools.setScrollbarIncrement(pane); layoutConstraints.gridy++; GridBagConstraints tableConstraints = (GridBagConstraints) layoutConstraints.clone(); tableConstraints.weightx = 1; tableConstraints.weighty = 10; tableConstraints.fill = GridBagConstraints.BOTH; contentPane.add(pane, tableConstraints); mTreeLabel = new JLabel(); layoutConstraints.gridy++; GridBagConstraints treeConstraints = (GridBagConstraints) layoutConstraints.clone(); treeConstraints.fill = GridBagConstraints.BOTH; @SuppressWarnings("serial") JScrollPane scrollPane = new JScrollPane(mTreeLabel) { @Override public boolean isValidateRoot() { return false; } }; contentPane.add(scrollPane, treeConstraints); final AbstractAction exportAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Export")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { exportSelectedRowsAndClose(); } }; final JButton exportButton = new JButton(exportAction); final AbstractAction replaceAllAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Replace_All")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { replace(new ReplaceAllInfo()); } }; final JButton replaceAllButton = new JButton(replaceAllAction); final AbstractAction replaceSelectedAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Replace_Selected")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { replace(new ReplaceSelectedInfo()); } }; final JButton replaceSelectedButton = new JButton(replaceSelectedAction); final AbstractAction gotoAction = new AbstractAction(TextUtils.getText("plugins/TimeManagement.xml_Goto")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { selectSelectedRows(); } }; final JButton gotoButton = new JButton(gotoAction); final AbstractAction disposeAction = new AbstractAction( TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_CLOSE)) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { disposeDialog(); } }; final JButton cancelButton = new JButton(disposeAction); /* Initial State */ gotoAction.setEnabled(false); exportAction.setEnabled(false); replaceSelectedAction.setEnabled(false); final Box bar = Box.createHorizontalBox(); bar.add(Box.createHorizontalGlue()); bar.add(cancelButton); bar.add(exportButton); bar.add(replaceAllButton); bar.add(replaceSelectedButton); bar.add(gotoButton); bar.add(Box.createHorizontalGlue()); layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(bar), layoutConstraints); final JMenuBar menuBar = new JMenuBar(); final JMenu menu = new JMenu(TextUtils.getText("plugins/TimeManagement.xml_menu_actions")); final AbstractAction[] actionList = new AbstractAction[] { gotoAction, replaceSelectedAction, replaceAllAction, exportAction, disposeAction }; for (int i = 0; i < actionList.length; i++) { final AbstractAction action = actionList[i]; final JMenuItem item = menu.add(action); item.setIcon(new BlindIcon(UIBuilder.ICON_SIZE)); } menuBar.add(menu); dialog.setJMenuBar(menuBar); final ListSelectionModel rowSM = timeTable.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(final ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } final ListSelectionModel lsm = (ListSelectionModel) e.getSource(); final boolean enable = !(lsm.isSelectionEmpty()); replaceSelectedAction.setEnabled(enable); gotoAction.setEnabled(enable); exportAction.setEnabled(enable); } }); rowSM.addListSelectionListener(new ListSelectionListener() { String getNodeText(final NodeModel node) { return TextController.getController().getShortText(node) + ((node.isRoot()) ? "" : (" <- " + getNodeText(node.getParentNode()))); } public void valueChanged(final ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } final ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { mTreeLabel.setText(""); return; } final int selectedRow = lsm.getLeadSelectionIndex(); final NodeModel mindMapNode = getMindMapNode(selectedRow); mTreeLabel.setText(getNodeText(mindMapNode)); } }); final String marshalled = ResourceController.getResourceController() .getProperty(NodeList.WINDOW_PREFERENCE_STORAGE_PROPERTY); final WindowConfigurationStorage result = TimeWindowConfigurationStorage.decorateDialog(marshalled, dialog); final WindowConfigurationStorage storage = result; if (storage != null) { timeTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); int column = 0; for (final TimeWindowColumnSetting setting : ((TimeWindowConfigurationStorage) storage) .getListTimeWindowColumnSettingList()) { timeTable.getColumnModel().getColumn(column).setPreferredWidth(setting.getColumnWidth()); sorter.setSortingStatus(column, setting.getColumnSorting()); column++; } } mFlatNodeTableFilterModel.setFilter((String) mFilterTextSearchField.getSelectedItem(), matchCase.isSelected(), useRegexInFind.isSelected()); dialog.setVisible(true); }
From source file:de.codesourcery.eve.skills.ui.components.impl.planning.ShoppingListComponent.java
@Override protected JPanel createPanel() { table.setFillsViewportHeight(true);/*from w w w .java 2s . c om*/ table.setRowSorter(tableModel.getRowSorter()); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { final int[] selectedViewRows = table.getSelectedRows(); final int[] selectedModelRows = new int[selectedViewRows.length]; int i = 0; for (int viewRow : selectedViewRows) { selectedModelRows[i++] = viewRow; } List<TableRow> selection = new ArrayList<TableRow>(); for (int modelRow : selectedModelRows) { selection.add(tableModel.getRow(modelRow)); } totalValue.setItems(selection); totalVolume.setItems(selection); } }); FixedBooleanTableCellRenderer.attach(table); final JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); final JPanel controlsPanel = new JPanel(); controlsPanel.setLayout(new GridBagLayout()); controlsPanel.add(this.tableViewModePanel, constraints(0, 0).useRemainingWidth().end()); final JPanel totalsPanel = new JPanel(); totalsPanel.setLayout(new GridBagLayout()); totalsPanel.add(totalValue.getPanel(), constraints(0, 0).weightX(0.2).width(1).weightY(0).anchorWest().end()); totalsPanel.add(totalVolume.getPanel(), constraints(1, 0).weightX(0.2).width(1).weightY(0).anchorWest().end()); final JPanel rest = new JPanel(); rest.setLayout(new GridBagLayout()); rest.add(componentPanel, constraints(0, 0).weightX(0.2).width(1).weightY(0.3).anchorWest().end()); rest.add(totalsPanel, constraints(0, 1).weightX(0.2).width(1).weightY(0).resizeHorizontally().anchorWest().end()); rest.add(controlsPanel, constraints(0, 2).weightX(0.2).width(1).weightY(0).resizeHorizontally().anchorWest().end()); rest.add(new JScrollPane(table), constraints(0, 3).weightX(0.2).width(1).weightY(0.7).resizeBoth().anchorWest().end()); // new GridLayoutBuilder().add( // new VerticalGroup( new Cell( componentPanel ), // new FixedCell( controlsPanel ), // new FixedCell( totalsPanel ), // new Cell( new JScrollPane( table ) ) ) ).addTo( rest ); final ImprovedSplitPane splitPane = new ImprovedSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(tree), rest); panel.add(splitPane, constraints(0, 0).resizeBoth().end()); tree.setRootVisible(false); tree.setCellRenderer(cellRenderer); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { final TreePath selection = e.getPath(); selectedNodeChanged((ITreeNode) (selection != null ? selection.getLastPathComponent() : null)); } }); final PopupMenuBuilder menuBuilder = new PopupMenuBuilder(); menuBuilder.addItem("New shopping list...", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { final ShoppingListEditorComponent comp = new ShoppingListEditorComponent("New list", "", new ArrayList<ItemWithQuantity>()); comp.setModal(true); ComponentWrapper.wrapComponent("Create new shopping list", comp).setVisible(true); if (!comp.wasCancelled()) { manager.addShoppingList(comp.getShoppingList()); } } }); menuBuilder.addItem("Edit list...", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { final ITreeNode node = getSelectedTreeNode(); if (node == null) { return; } final ShoppingList list = (ShoppingList) node.getValue(); final ShoppingListEditorComponent comp = new ShoppingListEditorComponent(list); comp.setModal(true); ComponentWrapper.wrapComponent(list.getTitle(), comp).setVisible(true); if (!comp.wasCancelled() && comp.isExistingEntryEdited()) { manager.shoppingListChanged(comp.getShoppingList()); } } @Override public boolean isEnabled() { final ITreeNode node = getSelectedTreeNode(); return node != null && node.getValue() instanceof ShoppingList; } }); menuBuilder.addItem("Delete item", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { final ITreeNode node = getSelectedTreeNode(); if (node != null && node.getValue() instanceof ShoppingListEntry) { final ShoppingListEntry entry = (ShoppingListEntry) node.getValue(); final ShoppingList list = entry.getShoppingList(); manager.removeEntry(list, entry); selectedNodeChanged(null); } } @Override public boolean isEnabled() { final ITreeNode node = getSelectedTreeNode(); return node != null && node.getValue() instanceof ShoppingListEntry; } }); menuBuilder.addItem("Delete list", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { final ShoppingList list = getSelectedShoppingList(); if (list != null) { manager.removeShoppingList(list); selectedNodeChanged(null); } } @Override public boolean isEnabled() { final ITreeNode node = getSelectedTreeNode(); return node.getValue() instanceof ShoppingList; } }); menuBuilder.addItem("Copy this list to clipboard (text)", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { putSelectedShoppingListOnClipboard(); } @Override public boolean isEnabled() { return getSelectedShoppingList() != null; } }); menuBuilder.attach(tree); return panel; }
From source file:org.nuclos.client.main.MainController.java
private void initActions() { try {/*from w ww . ja va 2 s. c o m*/ dha = new DirectHelpActionListener(); // init Actions cmdDirectHelp = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dha.actionPerformed(e); } }; cmdShowTimelimitTasks = new AbstractAction( getSpringLocaleDelegate().getMessage("miShowTimelimitTasks", "Fristen anzeigen"), Icons.getInstance().getIconTabTimtlimit()) { @Override public void actionPerformed(ActionEvent e) { MainController.this.getTaskController().getTimelimitTaskController().cmdShowTimelimitTasks(); } @Override public boolean isEnabled() { return getSecurityCache().isActionAllowed(Actions.ACTION_TIMELIMIT_LIST); } }; cmdShowPersonalTasks = new AbstractAction( getSpringLocaleDelegate().getMessage("miShowPersonalTasks", "Meine Aufgaben anzeigen"), Icons.getInstance().getIconTabTask()) { @Override public void actionPerformed(ActionEvent e) { MainController.this.getTaskController().getPersonalTaskController().cmdShowPersonalTasks(); } @Override public boolean isEnabled() { return getSecurityCache().isActionAllowed(Actions.ACTION_TASKLIST); } }; cmdShowPersonalSearchFilters = new AbstractAction( getSpringLocaleDelegate().getMessage("ExplorerPanel.3", "Meine Suchfilter anzeigen"), Icons.getInstance().getIconFilter16()) { @Override public void actionPerformed(ActionEvent e) { MainController.this.getExplorerController().cmdShowPersonalSearchFilters(); } }; cmdChangePassword = new AbstractAction() { private Boolean enabled; @Override public void actionPerformed(ActionEvent evt) { ChangePasswordPanel cpp = new ChangePasswordPanel(true, "", false); boolean result = cpp.showInDialog(getFrame(), new ChangePasswordPanel.ChangePasswordDelegate() { @Override public void changePassword(String oldPw, String newPw) throws CommonBusinessException { RemoteAuthenticationManager ram = SpringApplicationContextHolder .getBean(RemoteAuthenticationManager.class); ram.changePassword(sUserName, oldPw, newPw); getNuclosRemoteServerSession().relogin(sUserName, newPw); try { MainController.this.prefs.flush(); } catch (BackingStoreException e) { LOG.fatal("actionPerformed failed: " + e, e); } LocalUserProperties props = LocalUserProperties.getInstance(); props.setUserPasswd(""); props.store(); } }); } @Override public synchronized boolean isEnabled() { if (enabled == null) { enabled = !SecurityDelegate.getInstance().isLdapAuthenticationActive() || SecurityDelegate.getInstance().isSuperUser(); } return LangUtils.defaultIfNull(enabled, Boolean.FALSE); } }; cmdOpenManagementConsole = new AbstractAction( getSpringLocaleDelegate().getMessage("miManagementConsole", "Management Console"), MainFrame.resizeAndCacheTabIcon(NuclosResourceCache.getNuclosResourceIcon( "org.nuclos.client.resource.icon.glyphish-blue.158-wrench-2.png"))) { @Override public void actionPerformed(ActionEvent evt) { UIUtils.runCommand(getMainFrame(), new Runnable() { @Override public void run() { try { NuclosConsoleGui.showInFrame(getMainFrame().getHomePane().getComponentPanel()); } catch (Exception e) { LOG.error("showInFrame failed: " + e, e); } } }); } }; cmdOpenEntityWizard = new AbstractAction( getSpringLocaleDelegate().getMessage("miEntityWizard", "Entity Wizard"), MainFrame.resizeAndCacheTabIcon(NuclosResourceCache.getNuclosResourceIcon( "org.nuclos.client.resource.icon.glyphish-blue.81-dashboard.png"))) { @Override public void actionPerformed(ActionEvent evt) { final MainFrameTabbedPane desktopPane = MainController.this.getHomePane(); UIUtils.runCommand(getMainFrame(), new ShowNuclosWizard.NuclosWizardRoRunnable(desktopPane)); } }; cmdOpenEventSupportManagement = new AbstractAction( getSpringLocaleDelegate().getMessage("miEventSupportManagement", "Regelmanagement"), MainFrame.resizeAndCacheTabIcon(NuclosResourceCache.getNuclosResourceIcon( "org.nuclos.client.resource.icon.glyphish-blue.34-coffee.png"))) { @Override public void actionPerformed(ActionEvent evt) { final MainFrameTabbedPane desktopPane = MainController.this.getHomePane(); UIUtils.runCommand(getMainFrame(), new EventSupportManagementController.NuclosESMRunnable(desktopPane)); } }; cmdOpenCustomComponentWizard = new AbstractAction( getSpringLocaleDelegate().getMessage("miResPlanWizard", "Ressourcenplanung"), MainFrame.resizeAndCacheTabIcon(NuclosResourceCache.getNuclosResourceIcon( "org.nuclos.client.resource.icon.glyphish-blue.83-calendar.png"))) { @Override public void actionPerformed(final ActionEvent evt) { UIUtils.runCommand(getMainFrame(), new Runnable() { @Override public void run() { try { CustomComponentWizard.run(); } catch (Exception e) { LOG.error("CustomComponentWizard failed: " + e, e); } } }); } }; cmdOpenRelationEditor = new AbstractAction( getSpringLocaleDelegate().getMessage("miRelationEditor", "Relationeneditor"), MainFrame.resizeAndCacheTabIcon(NuclosResourceCache.getNuclosResourceIcon( "org.nuclos.client.resource.icon.glyphish-blue.55-network.png"))) { @Override public void actionPerformed(final ActionEvent evt) { UIUtils.runCommand(getMainFrame(), new Runnable() { @Override public void run() { try { final CollectControllerFactorySingleton factory = CollectControllerFactorySingleton .getInstance(); Collection<MasterDataVO> colRelation = MasterDataDelegate.getInstance() .getMasterData(NuclosEntity.ENTITYRELATION.getEntityName()); EntityRelationShipCollectController result = factory .newEntityRelationShipCollectController(MainController.this.getFrame(), null); if (colRelation.size() > 0) { MasterDataVO vo = colRelation.iterator().next(); result.runViewSingleCollectableWithId(vo.getId()); } else { result.runNew(); } } catch (/* CommonBusiness */ Exception e1) { LOG.error("actionPerformed " + evt + ": " + e1); } } }); } }; cmdOpenRelationEditor = new AbstractAction( getSpringLocaleDelegate().getMessage("miRelationEditor", "Relationeneditor"), MainFrame.resizeAndCacheTabIcon(NuclosResourceCache.getNuclosResourceIcon( "org.nuclos.client.resource.icon.glyphish-blue.55-network.png"))) { @Override public void actionPerformed(final ActionEvent evt) { UIUtils.runCommand(getMainFrame(), new Runnable() { @Override public void run() { try { final CollectControllerFactorySingleton factory = CollectControllerFactorySingleton .getInstance(); Collection<MasterDataVO> colRelation = MasterDataDelegate.getInstance() .getMasterData(NuclosEntity.ENTITYRELATION.getEntityName()); EntityRelationShipCollectController result = factory .newEntityRelationShipCollectController(MainController.this.getFrame(), null); if (colRelation.size() > 0) { MasterDataVO vo = colRelation.iterator().next(); result.runViewSingleCollectableWithId(vo.getId()); } else { result.runNew(); } } catch (/* CommonBusiness */ Exception e1) { LOG.error("actionPerformed " + evt + ": " + e1); } } }); } }; cmdOpenSettings = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { cmdOpenSettings(); } }; cmdRefreshClientCaches = new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { UIUtils.runCommandLater(getFrame(), new CommonRunnable() { @Override public void run() throws CommonBusinessException { invalidateAllClientCaches(); JOptionPane.showMessageDialog(getFrame(), getSpringLocaleDelegate().getMessage( "MainController.3", "Die folgenden Aktionen wurden erfolgreich durchgef\u00fchrt:\n" + "Caches aktualisiert: MasterDataCache, SecurityCache, AttributeCache, GenericObjectLayoutCache, GeneratorCache, MetaDataCache, ResourceCache, SearchFilterCache.\n" + "Men\u00fcs aktualisiert.")); } }); } }; cmdSelectAll = new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { // select all rows in the Result panel of the current CollectController (if any): final MainFrameTab ifrm = (MainFrameTab) MainController.this.frm.getHomePane() .getSelectedComponent(); if (ifrm != null) { final CollectController<?> ctl = getControllerForTab(ifrm); if (ctl != null && ctl.getCollectState().getOuterState() == CollectStateModel.OUTERSTATE_RESULT) { ctl.getResultTable().selectAll(); } else if (ctl != null && ((ctl.getCollectState().getOuterState() == CollectStateModel.OUTERSTATE_DETAILS) || ctl.getCollectState() .getOuterState() == CollectStateModel.OUTERSTATE_SEARCH)) { Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager() .getPermanentFocusOwner(); if (focusOwner instanceof JTextComponent) { ((JTextComponent) focusOwner).selectAll(); } } } } }; cmdHelpContents = new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { WikiController.getInstance().openURLinBrowser(ClientParameterProvider.getInstance() .getValue(ClientParameterProvider.KEY_WIKI_STARTPAGE)); } }; cmdShowAboutDialog = new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { cmdShowAboutDialog(); } }; cmdShowProjectReleaseNotes = new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { new ReleaseNotesController().showReleaseNotes(ApplicationProperties.getInstance().getName()); } }; cmdShowNuclosReleaseNotes = new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { ReleaseNotesController.openReleaseNotesInBrowser(); } }; cmdWindowClosing = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { cmdWindowClosing(new ResultListener<Boolean>() { @Override public void done(Boolean result) { } }); } }; cmdLogoutExit = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { cmdLogoutExit(); } }; cmdExecuteRport = createEntityAction(NuclosEntity.REPORTEXECUTION); } catch (Throwable e) { LOG.fatal("Creating MainController failed, this is fatal: " + e.toString(), e); throw new ExceptionInInitializerError(e); } }
From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java
/** * create the query builder UI./* w w w .j a v a 2 s . c o m*/ */ protected void createUI() { removeAll(); JMenuItem saveItem = new JMenuItem(UIRegistry.getResourceString("QB_SAVE")); Action saveActionListener = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (saveQuery(false)) { try { String selId = null; if (selectedQFP != null && selectedQFP.getQueryField() != null) { selId = selectedQFP.getQueryField().getStringId(); } final String selectedFldId = selId; setupUI(true); SwingUtilities.invokeLater(new Runnable() { /* (non-Javadoc) * @see java.lang.Runnable#run() */ @Override public void run() { if (selectedFldId != null) { for (QueryFieldPanel qfp : queryFieldItems) { if (qfp.getQueryField() != null && selectedFldId.equals(qfp.getQueryField().getStringId())) { selectQFP(qfp); return; } } selectQFP(queryFieldItems.get(0)); } } }); } catch (Exception ex) { } setSaveBtnEnabled(false); } } }; saveItem.addActionListener(saveActionListener); JMenuItem saveAsItem = new JMenuItem(UIRegistry.getResourceString("QB_SAVE_AS")); Action saveAsActionListener = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (saveQuery(true)) { setSaveBtnEnabled(false); } } }; saveAsItem.addActionListener(saveAsActionListener); JComponent[] itemSample = { saveItem, saveAsItem }; saveBtn = new DropDownButton(UIRegistry.getResourceString("QB_SAVE"), null, 1, java.util.Arrays.asList(itemSample)); saveBtn.addActionListener(saveActionListener); String ACTION_KEY = "SAVE"; KeyStroke ctrlS = KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); InputMap inputMap = saveBtn.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(ctrlS, ACTION_KEY); ActionMap actionMap = saveBtn.getActionMap(); actionMap.put(ACTION_KEY, saveActionListener); ACTION_KEY = "SAVE_AS"; KeyStroke ctrlA = KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); inputMap.put(ctrlA, ACTION_KEY); actionMap.put(ACTION_KEY, saveAsActionListener); saveBtn.setActionMap(actionMap); UIHelper.setControlSize(saveBtn); //saveBtn.setOverrideBorder(true, BasicBorders.getButtonBorder()); listBoxPanel = new JPanel(new HorzLayoutManager(2, 2)); Vector<TableQRI> list = new Vector<TableQRI>(); for (int k = 0; k < tableTree.getKids(); k++) { list.add(tableTree.getKid(k).getTableQRI()); } Collections.sort(list); DefaultListModel model = new DefaultListModel(); for (TableQRI qri : list) { model.addElement(qri); } tableList = new JList(model); QryListRenderer qr = new QryListRenderer(IconManager.IconSize.Std16); qr.setDisplayKidIndicator(false); tableList.setCellRenderer(qr); JScrollPane spt = new JScrollPane(tableList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); Dimension pSize = spt.getPreferredSize(); pSize.height = 200; spt.setPreferredSize(pSize); JPanel topPanel = new JPanel(new BorderLayout()); scrollPane = new JScrollPane(listBoxPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); tableList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int inx = tableList.getSelectedIndex(); if (inx > -1) { fillNextList(tableList); } else { listBoxPanel.removeAll(); } } } }); addBtn = new JButton(IconManager.getImage("PlusSign", IconManager.IconSize.Std16)); addBtn.setEnabled(false); addBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { BaseQRI qri = (BaseQRI) listBoxList.get(currentInx).getSelectedValue(); if (qri.isInUse) { return; } try { FieldQRI fieldQRI = buildFieldQRI(qri); if (fieldQRI == null) { throw new Exception("null FieldQRI"); } SpQueryField qf = new SpQueryField(); qf.initialize(); qf.setFieldName(fieldQRI.getFieldName()); qf.setStringId(fieldQRI.getStringId()); query.addReference(qf, "fields"); if (!isExportMapping) { addQueryFieldItem(fieldQRI, qf, false); } else { addNewMapping(fieldQRI, qf, null, false); } } catch (Exception ex) { log.error(ex); UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(QueryBldrPane.class, ex); return; } } }); contextPanel = new JPanel(new BorderLayout()); contextPanel.add(createLabel("Search Context", SwingConstants.CENTER), BorderLayout.NORTH); // I18N contextPanel.add(spt, BorderLayout.CENTER); contextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); JPanel schemaPanel = new JPanel(new BorderLayout()); schemaPanel.add(scrollPane, BorderLayout.CENTER); topPanel.add(contextPanel, BorderLayout.WEST); topPanel.add(schemaPanel, BorderLayout.CENTER); add(topPanel, BorderLayout.NORTH); queryFieldsPanel = new JPanel(); queryFieldsPanel.setLayout(new NavBoxLayoutManager(0, 2)); queryFieldsScroll = new JScrollPane(queryFieldsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); queryFieldsScroll.setBorder(null); add(queryFieldsScroll); //if (!isExportMapping) //{ final JPanel mover = buildMoverPanel(false); add(mover, BorderLayout.EAST); // } String searchLbl = schemaMapping == null ? getResourceString("QB_SEARCH") : getResourceString("QB_EXPORT_PREVIEW"); searchBtn = createButton(searchLbl); searchBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { // int m = ae.getModifiers(); // boolean ors = (m & ActionEvent.ALT_MASK) > 0 && (m & ActionEvent.CTRL_MASK) > 0 && (m & ActionEvent.SHIFT_MASK) > 0; // if (ors) // { // System.out.println("Disjunctional conjoinment desire gesture detected"); // } // doSearch(ors); doSearch(false); } }); distinctChk = createCheckBox(UIRegistry.getResourceString("QB_DISTINCT")); distinctChk.setVisible(schemaMapping == null); if (schemaMapping == null) { distinctChk.setSelected(false); distinctChk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new SwingWorker() { /* (non-Javadoc) * @see edu.ku.brc.helpers.SwingWorker#construct() */ @Override public Object construct() { if (distinctChk.isSelected()) { UsageTracker.incrUsageCount("QB.DistinctOn"); } else { UsageTracker.incrUsageCount("QB.DistinctOff"); } if ((isTreeLevelSelected() || isAggFieldSelected()) && countOnly && distinctChk.isSelected()) { countOnlyChk.setSelected(false); countOnly = false; } query.setCountOnly(countOnly); query.setSelectDistinct(distinctChk.isSelected()); setSaveBtnEnabled(thereAreItems()); return null; } }.start(); } }); } countOnlyChk = createCheckBox(UIRegistry.getResourceString("QB_COUNT_ONLY")); countOnlyChk.setSelected(false); countOnlyChk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new SwingWorker() { /* (non-Javadoc) * @see edu.ku.brc.helpers.SwingWorker#construct() */ @Override public Object construct() { //Don't allow change while query is running. if (runningResults.get() == null) { countOnly = !countOnly; if (countOnly) { UsageTracker.incrUsageCount("QB.CountOnlyOn"); } else { UsageTracker.incrUsageCount("QB.CountOnlyOff"); } if ((isTreeLevelSelected() || isAggFieldSelected()) && countOnly && (distinctChk.isSelected() || searchSynonymyChk.isSelected())) { distinctChk.setSelected(false); searchSynonymyChk.setSelected(false); } } else { //This might be awkward and/or klunky... countOnlyChk.setSelected(countOnly); } query.setCountOnly(countOnly); query.setSelectDistinct(distinctChk.isSelected()); setSaveBtnEnabled(thereAreItems()); return null; } }.start(); } }); searchSynonymyChk = createCheckBox(UIRegistry.getResourceString("QB_SRCH_SYNONYMS")); searchSynonymyChk.setSelected(searchSynonymy); searchSynonymyChk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new SwingWorker() { /* (non-Javadoc) * @see edu.ku.brc.helpers.SwingWorker#construct() */ @Override public Object construct() { searchSynonymy = !searchSynonymy; if (!searchSynonymy) { UsageTracker.incrUsageCount("QB.SearchSynonymyOff"); } else { UsageTracker.incrUsageCount("QB.SearchSynonymyOn"); } if (isTreeLevelSelected() && countOnly && searchSynonymyChk.isSelected()) { countOnlyChk.setSelected(false); countOnly = false; } query.setSearchSynonymy(searchSynonymy); setSaveBtnEnabled(thereAreItems()); return null; } }.start(); } }); smushedChk = createCheckBox(UIRegistry.getResourceString("QB_SMUSH_RESULTS")); smushedChk.setVisible(isSmushableContext()); if (isSmushableContext()) { smushedChk.setSelected(smushed); smushedChk.setToolTipText( String.format(UIRegistry.getResourceString("QB_SMUSH_RESULTS_HINT"), getCatalogNumberTitle())); smushedChk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new SwingWorker() { /* * (non-Javadoc) * * @see edu.ku.brc.helpers.SwingWorker#construct() */ @Override public Object construct() { smushed = !smushed; if (!smushed) { UsageTracker.incrUsageCount("QB.SmushedOff"); } else { UsageTracker.incrUsageCount("QB.SmushedOn"); } query.setSmushed(smushed); setSaveBtnEnabled(thereAreItems()); return null; } }.start(); } }); } PanelBuilder outer = new PanelBuilder( new FormLayout("p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 6dlu, p", "p")); CellConstraints cc = new CellConstraints(); outer.add(smushedChk, cc.xy(1, 1)); outer.add(searchSynonymyChk, cc.xy(3, 1)); outer.add(distinctChk, cc.xy(5, 1)); outer.add(countOnlyChk, cc.xy(7, 1)); outer.add(searchBtn, cc.xy(9, 1)); outer.add(saveBtn, cc.xy(11, 1)); JPanel bottom = new JPanel(new BorderLayout()); bottom.add(outer.getPanel(), BorderLayout.EAST); JButton helpBtn = UIHelper.createHelpIconButton(getHelpBtnContext()); bottom.add(helpBtn, BorderLayout.WEST); add(bottom, BorderLayout.SOUTH); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); }
From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java
@SuppressWarnings("serial") private JPanel createParamsweepGUI() { // left//w w w. j ava 2 s .com parameterList = new JList(); parameterList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); new ListAction(parameterList, new AbstractAction() { public void actionPerformed(final ActionEvent event) { final AvailableParameter selectedParameter = (AvailableParameter) parameterList.getSelectedValue(); addParameterToTree(new AvailableParameter[] { selectedParameter }, parameterTreeBranches.get(0)); enableDisableParameterCombinationButtons(); } }); parameterList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!parameterList.isSelectionEmpty()) { boolean success = true; if (editedNode != null) success = modify(); if (success) { cancelAllSelectionBut(parameterList); resetSettings(); updateDescriptionField(parameterList.getSelectedValues()); enableDisableParameterCombinationButtons(); } else parameterList.clearSelection(); } } }); final JScrollPane parameterListPane = new JScrollPane(parameterList); parameterListPane.setBorder(BorderFactory.createTitledBorder("")); // for rounded border parameterListPane.setPreferredSize(new Dimension(300, 300)); final JPanel parametersPanel = FormsUtils.build("p ' p:g", "[DialogBorder]00||" + "12||" + "34||" + // "56||" + "55||" + "66 f:p:g", new FormsUtils.Separator("<html><b>General parameters</b></html>"), NUMBER_OF_TURNS_LABEL_TEXT, numberOfTurnsFieldPSW, NUMBER_OF_TIMESTEPS_TO_IGNORE_LABEL_TEXT, numberTimestepsIgnoredPSW, // UPDATE_CHARTS_LABEL_TEXT,onLineChartsCheckBoxPSW, new FormsUtils.Separator("<html><b>Model parameters</b></html>"), parameterListPane).getPanel(); combinationsPanel = new JPanel(new GridLayout(0, 1, 5, 5)); combinationsScrPane = new JScrollPane(combinationsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); combinationsScrPane.setBorder(null); combinationsScrPane.setPreferredSize(new Dimension(550, 500)); parameterDescriptionLabel = new JXLabel(); parameterDescriptionLabel.setLineWrap(true); parameterDescriptionLabel.setVerticalAlignment(SwingConstants.TOP); final JScrollPane descriptionScrollPane = new JScrollPane(parameterDescriptionLabel); descriptionScrollPane.setBorder(BorderFactory.createTitledBorder(null, "Description", TitledBorder.LEADING, TitledBorder.BELOW_TOP)); descriptionScrollPane.setPreferredSize( new Dimension(PARAMETER_DESCRIPTION_LABEL_WIDTH, PARAMETER_DESCRIPTION_LABEL_HEIGHT)); descriptionScrollPane.setViewportBorder(null); final JButton addNewBoxButton = new JButton("Add new combination"); addNewBoxButton.setActionCommand(ACTIONCOMMAND_ADD_BOX); final JPanel left = FormsUtils.build("p ~ f:p:g ~ p", "011 f:p:g ||" + "0_2 p", parametersPanel, combinationsScrPane, addNewBoxButton).getPanel(); left.setBorder(BorderFactory.createTitledBorder(null, "Specify parameter combinations", TitledBorder.LEADING, TitledBorder.BELOW_TOP)); Style.registerCssClasses(left, Dashboard.CSS_CLASS_COMMON_PANEL); final JPanel leftAndDesc = new JPanel(new BorderLayout()); leftAndDesc.add(left, BorderLayout.CENTER); leftAndDesc.add(descriptionScrollPane, BorderLayout.SOUTH); Style.registerCssClasses(leftAndDesc, Dashboard.CSS_CLASS_COMMON_PANEL); // right editedParameterText = new JLabel(ORIGINAL_TEXT); editedParameterText.setPreferredSize(new Dimension(280, 40)); constDef = new JRadioButton("Constant"); listDef = new JRadioButton("List"); incrDef = new JRadioButton("Increment"); final JPanel rightTop = FormsUtils.build("p:g", "[DialogBorder]0||" + "1||" + "2||" + "3", editedParameterText, constDef, listDef, incrDef).getPanel(); Style.registerCssClasses(rightTop, Dashboard.CSS_CLASS_COMMON_PANEL); constDefField = new JTextField(); final JPanel constDefPanel = FormsUtils .build("p ~ p:g", "[DialogBorder]01 p", "Constant value: ", CellConstraints.TOP, constDefField) .getPanel(); listDefArea = new JTextArea(); final JScrollPane listDefScr = new JScrollPane(listDefArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); final JPanel listDefPanel = FormsUtils.build("p ~ p:g", "[DialogBorder]01|" + "_1 f:p:g||" + "_2 p", "Value list: ", listDefScr, "(Separate values with spaces!)").getPanel(); incrStartValueField = new JTextField(); incrEndValueField = new JTextField(); incrStepField = new JTextField(); final JPanel incrDefPanel = FormsUtils.build("p ~ p:g", "[DialogBorder]01||" + "23||" + "45", "Start value: ", incrStartValueField, "End value: ", incrEndValueField, "Step: ", incrStepField) .getPanel(); enumDefBox = new JComboBox(new DefaultComboBoxModel()); final JPanel enumDefPanel = FormsUtils .build("p ~ p:g", "[DialogBorder]01 p", "Constant value:", CellConstraints.TOP, enumDefBox) .getPanel(); submodelTypeBox = new JComboBox(); final JPanel submodelTypePanel = FormsUtils .build("p ~ p:g", "[DialogBorder]01", "Constant value:", CellConstraints.TOP, submodelTypeBox) .getPanel(); fileTextField = new JTextField(); fileTextField.addKeyListener(new KeyAdapter() { public void keyTyped(final KeyEvent e) { final char character = e.getKeyChar(); final File file = new File(Character.isISOControl(character) ? fileTextField.getText() : fileTextField.getText() + character); fileTextField.setToolTipText(file.getAbsolutePath()); } }); fileBrowseButton = new JButton(BROWSE_BUTTON_TEXT); fileBrowseButton.setActionCommand(ACTIONCOMMAND_BROWSE); final JPanel fileDefPanel = FormsUtils .build("p ~ p:g ~p", "[DialogBorder]012", "File:", fileTextField, fileBrowseButton).getPanel(); constDefPanel.setName("CONST"); listDefPanel.setName("LIST"); incrDefPanel.setName("INCREMENT"); enumDefPanel.setName("ENUM"); submodelTypePanel.setName("SUBMODEL"); fileDefPanel.setName("FILE"); Style.registerCssClasses(constDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL); Style.registerCssClasses(listDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL); Style.registerCssClasses(incrDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL); Style.registerCssClasses(enumDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL); Style.registerCssClasses(submodelTypePanel, Dashboard.CSS_CLASS_COMMON_PANEL); Style.registerCssClasses(fileDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL); rightMiddle = new JPanel(new CardLayout()); Style.registerCssClasses(rightMiddle, Dashboard.CSS_CLASS_COMMON_PANEL); rightMiddle.add(constDefPanel, constDefPanel.getName()); rightMiddle.add(listDefPanel, listDefPanel.getName()); rightMiddle.add(incrDefPanel, incrDefPanel.getName()); rightMiddle.add(enumDefPanel, enumDefPanel.getName()); rightMiddle.add(submodelTypePanel, submodelTypePanel.getName()); rightMiddle.add(fileDefPanel, fileDefPanel.getName()); modifyButton = new JButton("Modify"); cancelButton = new JButton("Cancel"); final JPanel rightBottom = FormsUtils .build("p:g p ~ p ~ p:g", "[DialogBorder]_01_ p", modifyButton, cancelButton).getPanel(); Style.registerCssClasses(rightBottom, Dashboard.CSS_CLASS_COMMON_PANEL); final JPanel right = new JPanel(new BorderLayout()); right.add(rightTop, BorderLayout.NORTH); right.add(rightMiddle, BorderLayout.CENTER); right.add(rightBottom, BorderLayout.SOUTH); right.setBorder(BorderFactory.createTitledBorder(null, "Parameter settings", TitledBorder.LEADING, TitledBorder.BELOW_TOP)); Style.registerCssClasses(right, Dashboard.CSS_CLASS_COMMON_PANEL); // the whole paramsweep panel final JPanel content = FormsUtils.build("p:g p", "01 f:p:g", leftAndDesc, right).getPanel(); Style.registerCssClasses(content, Dashboard.CSS_CLASS_COMMON_PANEL); sweepPanel = new JPanel(); Style.registerCssClasses(sweepPanel, Dashboard.CSS_CLASS_COMMON_PANEL); sweepPanel.setLayout(new BorderLayout()); final JScrollPane sp = new JScrollPane(content); sp.setBorder(null); sp.setViewportBorder(null); sweepPanel.add(sp, BorderLayout.CENTER); GUIUtils.createButtonGroup(constDef, listDef, incrDef); constDef.setSelected(true); constDef.setActionCommand("CONST"); listDef.setActionCommand("LIST"); incrDef.setActionCommand("INCREMENT"); constDefField.setActionCommand("CONST_FIELD"); incrStartValueField.setActionCommand("START_FIELD"); incrEndValueField.setActionCommand("END_FIELD"); incrStepField.setActionCommand("STEP_FIELD"); modifyButton.setActionCommand("EDIT"); cancelButton.setActionCommand("CANCEL"); listDefArea.setLineWrap(true); listDefArea.setWrapStyleWord(true); listDefScr.setPreferredSize(new Dimension(100, 200)); GUIUtils.addActionListener(this, modifyButton, cancelButton, constDef, listDef, incrDef, constDefField, incrStartValueField, incrEndValueField, incrStepField, addNewBoxButton, submodelTypeBox, fileBrowseButton); return sweepPanel; }
From source file:edu.ku.brc.af.ui.forms.FormViewObj.java
/** * Register the KeyBinding short cut for the Save control * @param saveComp the save control/*from w w w. j av a 2 s .c o m*/ */ private void addSaveActionMap(final JComponent saveComp) { UIHelper.addSaveKeyBinding(saveComp, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { saveOnThread(saveAndNew); } }); }
From source file:de.ipk_gatersleben.ag_nw.graffiti.services.GUIhelper.java
private void myInit() { super.dialogInit(); setTitle(title);/*from w w w . java 2 s.com*/ double[][] size = { { border, TableLayoutConstants.PREFERRED, border }, // Columns { border, TableLayoutConstants.PREFERRED, border } }; // Rows setLayout(new TableLayout(size)); JButton[] commandButtons = new JButton[buttons.length]; ArrayList<JComponent> buttonArr = new ArrayList<JComponent>(); for (int i = 0; i < buttons.length; i++) { JButton button = new JButton(buttons[i]); final int fi = i; button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); returnValue = fi; dispose(); } }); commandButtons[i] = button; buttonArr.add(button); } // final JScrollPane sp = new JScrollPane(mainView); // SwingUtilities.invokeLater(new Runnable() { // public void run() { // sp.getVerticalScrollBar().setValue(0); // }}); add(TableLayout.getSplitVertical(mainView, TableLayout.getMultiSplit(buttonArr, TableLayoutConstants.PREFERRED, 5, 0, 5, 3), TableLayoutConstants.FILL, TableLayoutConstants.PREFERRED), "1,1"); validate(); setResizable(false); // setSize(getPreferredSize()); setModal(true); getRootPane().setDefaultButton(commandButtons[0]); setDefaultCloseOperation(DISPOSE_ON_CLOSE); final String ESC_ACTION_KEY = "ESC_ACTION_KEY"; getRootPane().getActionMap().put(ESC_ACTION_KEY, new AbstractAction() { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { setVisible(false); dispose(); } }); getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ESC_ACTION_KEY); pack(); }
From source file:it.unibo.alchemist.boundary.monitors.Generic2DDisplay.java
private void bindKey(final int key, final Runnable fun) { final Object binder = "Key: " + key; getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(key, 0), binder); getActionMap().put(binder, new AbstractAction() { private static final long serialVersionUID = 7927420406960259675L; @Override// w ww . j av a 2 s .c o m public void actionPerformed(final ActionEvent e) { fun.run(); } }); }