List of usage examples for java.awt.event MouseAdapter MouseAdapter
MouseAdapter
From source file:com.diversityarrays.kdxplore.trials.TrialOverviewPanel.java
public TrialOverviewPanel(String title, OfflineData offdata, TrialExplorerManager manager, FileListTransferHandler flth, MessagePrinter mp, final Closure<List<Trial>> onTrialSelected) { super(new BorderLayout()); offlineData = offdata;//from w w w.jav a2 s. c o m KdxploreDatabase kdxdb = offlineData.getKdxploreDatabase(); if (kdxdb != null) { kdxdb.addEntityChangeListener(trialChangeListener); kdxdb.addEntityChangeListener(traitChangeListener); } this.messagePrinter = mp; TableTransferHandler tth = TableTransferHandler.initialiseForCopySelectAll(trialsTable, true); trialsTable.setTransferHandler(new ChainingTransferHandler(flth, tth)); trialsTable.setAutoCreateRowSorter(true); trialsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { List<Trial> selectedTrials = getSelectedTrials(); if (selectedTrials.size() == 1) { trialTraitsTableModel.setSelectedTrial(selectedTrials.get(0)); } else { trialTraitsTableModel.setSelectedTrial(null); } onTrialSelected.execute(selectedTrials); } } }); trialsTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(e)) { fireEditCommand(e); } } }); GuiUtil.setVisibleRowCount(trialsTable, MAX_INITIAL_VISIBLE_TRIAL_ROWS); offlineData.addOfflineDataChangeListener(offlineDataChangeListener); trialTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { updateRefreshAction(); } }); trialTraitsTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { updateAddTraitAction(); updateRemoveTraitAction(); updateScoringOrderAction(); } }); trialTraitsTable.addMouseListener(new MouseAdapter() { List<Trait> selectedTraits; JPopupMenu popupMenu; Action showTraitsAction = new AbstractAction("Select in Trait Explorer") { @Override public void actionPerformed(ActionEvent e) { manager.showTraitsInTraitExplorer(selectedTraits); } }; @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) && 2 == e.getClickCount()) { // Start editing the Trait e.consume(); int vrow = trialTraitsTable.rowAtPoint(e.getPoint()); if (vrow >= 0) { int mrow = trialTraitsTable.convertRowIndexToModel(vrow); if (mrow >= 0) { Trait trait = trialTraitsTableModel.getTraitAt(mrow); if (trait != null) { traitExplorer.startEditing(trait); ; } } } } else if (SwingUtilities.isRightMouseButton(e) && 1 == e.getClickCount()) { // Select the traits in the traitExplorer e.consume(); List<Integer> modelRows = GuiUtil.getSelectedModelRows(trialTraitsTable); if (!modelRows.isEmpty()) { selectedTraits = modelRows.stream().map(trialTraitsTableModel::getTraitAt) .collect(Collectors.toList()); if (popupMenu == null) { popupMenu = new JPopupMenu(); popupMenu.add(showTraitsAction); } Point pt = e.getPoint(); popupMenu.show(trialTraitsTable, pt.x, pt.y); } } } }); trialTraitsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { updateRemoveTraitAction(); } } }); updateAddTraitAction(); updateRemoveTraitAction(); updateScoringOrderAction(); updateRefreshAction(); KDClientUtils.initAction(ImageId.REFRESH_24, refreshTrialTraitsAction, "Refresh"); KDClientUtils.initAction(ImageId.MINUS_GOLD_24, removeTraitAction, "Remove selected Traits"); KDClientUtils.initAction(ImageId.PLUS_BLUE_24, addTraitAction, "Add Traits to Trial"); KDClientUtils.initAction(ImageId.TRAIT_ORDER_24, setScoringOrderAction, "Define Trait Scoring Order"); Box buttons = Box.createHorizontalBox(); buttons.add(new JButton(setScoringOrderAction)); buttons.add(Box.createHorizontalGlue()); buttons.add(new JButton(addTraitAction)); buttons.add(new JButton(removeTraitAction)); buttons.add(Box.createHorizontalStrut(10)); buttons.add(refreshTrialTraitsButton); JPanel traitsPanel = new JPanel(new BorderLayout()); traitsPanel.add(GuiUtil.createLabelSeparator("Uses Traits", buttons), BorderLayout.NORTH); traitsPanel.add(new PromptScrollPane(trialTraitsTable, "If the (single) selected Trial has Traits they will appear here"), BorderLayout.CENTER); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(trialsTable), traitsPanel); splitPane.setResizeWeight(0.5); add(splitPane, BorderLayout.CENTER); }
From source file:edu.ku.brc.specify.tasks.subpane.ESResultsTablePanel.java
/** * // w w w . ja v a2 s . c om */ protected void addContextMenu() { MouseAdapter mouseAdapter = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { super.mousePressed(e); if (e.isPopupTrigger()) { if (table.getSelectedColumnCount() > 0) { if (popupMenu != null && popupMenu.isVisible()) { popupMenu.setVisible(false); } if (popupMenu == null) { popupMenu = new JPopupMenu(); JMenuItem mi = popupMenu.add(new JMenuItem(UIRegistry.getResourceString("Remove"))); mi.addActionListener(createRemoveItemAL()); } Point p = table.getLocationOnScreen(); popupMenu.setLocation(p.x + e.getX() + 1, p.y + e.getY() + 1); popupMenu.setVisible(true); } } } }; table.addMouseListener(mouseAdapter); }
From source file:de.huxhorn.lilith.swing.MainFrame.java
public MainFrame(ApplicationPreferences applicationPreferences, SplashScreen splashScreen, String appName, boolean enableBonjour) { super(appName); this.applicationPreferences = applicationPreferences; this.coloringWholeRow = this.applicationPreferences.isColoringWholeRow(); this.splashScreen = splashScreen; setSplashStatusText("Creating main frame."); groovyFormatter = new GroovyEventWrapperHtmlFormatter(applicationPreferences); thymeleafFormatter = new ThymeleafEventWrapperHtmlFormatter(applicationPreferences); smallProgressIcon = new ImageIcon(MainFrame.class.getResource("/otherGraphics/Progress16.gif")); ImageIcon frameIcon = new ImageIcon(MainFrame.class.getResource("/otherGraphics/Lilith16.jpg")); setIconImage(frameIcon.getImage());//from w w w. java 2s . c om //colorsReferenceQueue=new ReferenceQueue<Colors>(); //colorsCache=new ConcurrentHashMap<EventIdentifier, SoftColorsReference>(); application = new DefaultApplication(); autostartProcesses = new ArrayList<AutostartRunnable>(); addWindowListener(new MainWindowListener()); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); // fixes ticket #79 Runtime runtime = Runtime.getRuntime(); Thread shutdownHook = new Thread(new ShutdownRunnable()); runtime.addShutdownHook(shutdownHook); senderService = new SenderService(this); this.enableBonjour = enableBonjour; /* if(application.isMac()) { setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); } else { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } */ longTaskManager = new TaskManager<Long>(); longTaskManager.setUsingEventQueue(true); longTaskManager.startUp(); longTaskManager.addTaskListener(new MainTaskListener()); startupApplicationPath = this.applicationPreferences.getStartupApplicationPath(); loggingFileFactory = new LogFileFactoryImpl(new File(startupApplicationPath, LOGGING_FILE_SUBDIRECTORY)); accessFileFactory = new LogFileFactoryImpl(new File(startupApplicationPath, ACCESS_FILE_SUBDIRECTORY)); Map<String, String> loggingMetaData = new HashMap<String, String>(); loggingMetaData.put(FileConstants.CONTENT_TYPE_KEY, FileConstants.CONTENT_TYPE_VALUE_LOGGING); loggingMetaData.put(FileConstants.CONTENT_FORMAT_KEY, FileConstants.CONTENT_FORMAT_VALUE_PROTOBUF); loggingMetaData.put(FileConstants.COMPRESSION_KEY, FileConstants.COMPRESSION_VALUE_GZIP); // TODO: configurable format and compressed loggingFileBufferFactory = new LoggingFileBufferFactory(loggingFileFactory, loggingMetaData); Map<String, String> accessMetaData = new HashMap<String, String>(); accessMetaData.put(FileConstants.CONTENT_TYPE_KEY, FileConstants.CONTENT_TYPE_VALUE_ACCESS); accessMetaData.put(FileConstants.CONTENT_FORMAT_KEY, FileConstants.CONTENT_FORMAT_VALUE_PROTOBUF); accessMetaData.put(FileConstants.COMPRESSION_KEY, FileConstants.COMPRESSION_VALUE_GZIP); // TODO: configurable format and compressed accessFileBufferFactory = new AccessFileBufferFactory(accessFileFactory, accessMetaData); rrdFileFilter = new RrdFileFilter(); loggingEventViewManager = new LoggingEventViewManager(this); accessEventViewManager = new AccessEventViewManager(this); this.applicationPreferences.addPropertyChangeListener(new PreferencesChangeListener()); loggingSourceListener = new LoggingEventSourceListener(); accessSourceListener = new AccessEventSourceListener(); // this.cleanupWindowChangeListener = new CleanupWindowChangeListener(); desktop = new JDesktopPane(); statusBar = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); statusLabel = new JLabel(); statusLabel.setText("Starting..."); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 0.0; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 0, 0); statusBar.add(statusLabel, gbc); taskStatusLabel = new JLabel(); taskStatusLabel.setText(""); taskStatusLabel.setForeground(Color.BLUE); taskStatusLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent mouseEvent) { showTaskManager(); } @Override public void mouseEntered(MouseEvent mouseEvent) { taskStatusLabel.setForeground(Color.RED); } @Override public void mouseExited(MouseEvent mouseEvent) { taskStatusLabel.setForeground(Color.BLUE); } }); gbc.gridx = 1; gbc.gridy = 0; gbc.weightx = 1.0; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 0, 0); statusBar.add(taskStatusLabel, gbc); MemoryStatus memoryStatus = new MemoryStatus(); memoryStatus.setBackground(Color.WHITE); memoryStatus.setOpaque(true); memoryStatus.setUsingBinaryUnits(true); memoryStatus.setUsingTotal(false); memoryStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); gbc.fill = GridBagConstraints.NONE; gbc.gridx = 2; gbc.gridy = 0; gbc.weightx = 0.0; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 0, 0, 0); statusBar.add(memoryStatus, gbc); add(desktop, BorderLayout.CENTER); add(statusBar, BorderLayout.SOUTH); if (SystemUtils.IS_JAVA_1_6) { setSplashStatusText("Creating statistics dialog."); if (logger.isDebugEnabled()) logger.debug("Before creation of statistics-dialog..."); statisticsDialog = new StatisticsDialog(this); if (logger.isDebugEnabled()) logger.debug("After creation of statistics-dialog..."); } setSplashStatusText("Creating about dialog."); aboutDialog = new AboutDialog(this, "About " + appName + "...", appName); setSplashStatusText("Creating update dialog."); checkForUpdateDialog = new CheckForUpdateDialog(this); setSplashStatusText("Creating debug dialog."); debugDialog = new DebugDialog(this, this); setSplashStatusText("Creating preferences dialog."); if (logger.isDebugEnabled()) logger.debug("Before creation of preferences-dialog..."); preferencesDialog = new PreferencesDialog(this); if (logger.isDebugEnabled()) logger.debug("After creation of preferences-dialog..."); setSplashStatusText("Creating \"Open inactive\" dialog."); openInactiveLogsDialog = new OpenPreviousDialog(MainFrame.this); setSplashStatusText("Creating help frame."); helpFrame = new HelpFrame(this); helpFrame.setTitle("Help Topics"); openFileChooser = new JFileChooser(); openFileChooser.setFileFilter(new LilithFileFilter()); openFileChooser.setFileHidingEnabled(false); openFileChooser.setCurrentDirectory(this.applicationPreferences.getPreviousOpenPath()); importFileChooser = new JFileChooser(); importFileChooser.setFileFilter(new XmlImportFileFilter()); importFileChooser.setFileHidingEnabled(false); importFileChooser.setCurrentDirectory(this.applicationPreferences.getPreviousImportPath()); exportFileChooser = new JFileChooser(); exportFileChooser.setFileFilter(new LilithFileFilter()); exportFileChooser.setFileHidingEnabled(false); exportFileChooser.setCurrentDirectory(this.applicationPreferences.getPreviousExportPath()); setSplashStatusText("Creating task manager frame."); taskManagerFrame = new TaskManagerInternalFrame(this); taskManagerFrame.setTitle("Task Manager"); taskManagerFrame.setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE); taskManagerFrame.setBounds(0, 0, 320, 240); desktop.add(taskManagerFrame); desktop.validate(); // the following code must be executed after desktop has been initialized... try { // try to use the 1.6 transfer handler... new MainFrameTransferHandler16(this).attach(); } catch (Throwable t) { // ... and use the basic 1.5 transfer handler if this fails. new MainFrameTransferHandler(this).attach(); } setSplashStatusText("Creating Tip of the Day dialog."); tipOfTheDayDialog = new TipOfTheDayDialog(this); setSplashStatusText("Creating actions and menus."); viewActions = new ViewActions(this, null); viewActions.getPopupMenu(); // initialize popup once in main frame only. JMenuBar menuBar = viewActions.getMenuBar(); toolbar = viewActions.getToolbar(); add(toolbar, BorderLayout.NORTH); setJMenuBar(menuBar); setShowingToolbar(applicationPreferences.isShowingToolbar()); setShowingStatusbar(applicationPreferences.isShowingStatusbar()); }
From source file:gtu._work.ui.PropertyEditUI.java
private void initGUI() { try {// w w w . j a va2 s. c o m setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); BorderLayout thisLayout = new BorderLayout(); this.setTitle("PropertyEditUI"); getContentPane().setLayout(thisLayout); { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu1 = new JMenu(); jMenuBar1.add(jMenu1); jMenu1.setText("File"); { jMenuItem1 = new JMenuItem(); jMenu1.add(jMenuItem1); jMenuItem1.setText("open directory"); jMenuItem1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JCommonUtil._jFileChooser_selectDirectoryOnly(); loadCurrentFile(file); } }); } { openDirectoryAndChildren = new JMenuItem(); jMenu1.add(openDirectoryAndChildren); openDirectoryAndChildren.setText("open directory and children"); openDirectoryAndChildren.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out.println("openDirectoryAndChildren.actionPerformed, event=" + evt); File file = JCommonUtil._jFileChooser_selectDirectoryOnly(); if (file == null) { // file = // PropertiesUtil.getJarCurrentPath(getClass());//XXX file = new File("D:\\my_tool\\english"); JCommonUtil._jOptionPane_showMessageDialog_info("load C:\\L-CONFIG !"); } DefaultListModel model = new DefaultListModel(); List<File> list = new ArrayList<File>(); FileUtil.searchFileMatchs(file, ".*\\.properties", list); for (File f : list) { File_ ff = new File_(); ff.file = f; model.addElement(ff); } backupFileList = list; fileList.setModel(model); } }); } { jMenuItem2 = new JMenuItem(); jMenu1.add(jMenuItem2); jMenuItem2.setText("save"); jMenuItem2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out.println("jMenu3.actionPerformed, event=" + evt); if (currentFile == null) { return; } if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "save to " + currentFile.getName(), "SAVE")) { try { Properties prop = new Properties(); // try { // prop.load(new // FileInputStream(currentFile)); // } catch (Exception e) { // e.printStackTrace(); // JCommonUtil.handleException(e); // return; // } loadModelToProperties(prop); prop.store(new FileOutputStream(currentFile), getTitle()); } catch (Exception e) { e.printStackTrace(); JCommonUtil.handleException(e); } } } }); } { jMenuItem3 = new JMenuItem(); jMenu1.add(jMenuItem3); jMenuItem3.setText("save to target"); jMenuItem3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JFileChooserUtil.newInstance().selectFileOnly().showSaveDialog() .getApproveSelectedFile(); if (file == null) { JCommonUtil._jOptionPane_showMessageDialog_error("file name is not correct!"); return; } if (!file.getName().contains(".properties")) { file = new File(file.getParent(), file.getName() + ".properties"); } try { Properties prop = new Properties(); // try { // prop.load(new // FileInputStream(currentFile)); // } catch (Exception e) { // e.printStackTrace(); // JCommonUtil.handleException(e); // return; // } loadModelToProperties(prop); prop.store(new FileOutputStream(file), getTitle()); } catch (Exception e) { e.printStackTrace(); JCommonUtil.handleException(e); } } }); } { jMenuItem4 = new JMenuItem(); jMenu1.add(jMenuItem4); jMenuItem4.setText("save file(sorted)"); jMenuItem4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (currentFile == null) { return; } try { BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(currentFile))); List<String> sortList = new ArrayList<String>(); for (String line = null; (line = reader.readLine()) != null;) { sortList.add(line); } reader.close(); Collections.sort(sortList); StringBuilder sb = new StringBuilder(); for (String line : sortList) { sb.append(line + "\n"); } FileUtil.saveToFile(currentFile, sb.toString(), "UTF8"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }); } { jMenuItem5 = new JMenuItem(); jMenu1.add(jMenuItem5); jMenuItem5.setText(""); jMenuItem5.addActionListener(new ActionListener() { private void setMeaning(String meaning, int rowPos) { propTable.getRowSorter().getModel().setValueAt(meaning, rowPos, 2); } private void setMeaningEn1(String english, int rowPos, List<String> errSb) { EnglishTester_Diectory eng = new EnglishTester_Diectory(); try { WordInfo wordInfo = eng.parseToWordInfo(english); String meaning = getChs2Big5(wordInfo.getMeaning()); if (hasChinese(meaning)) { setMeaning(meaning, rowPos); } else { setMeaningEn2(english, rowPos, errSb); } } catch (Exception e) { errSb.add(english); e.printStackTrace(); } } private void setMeaningEn2(String english, int rowPos, List<String> errSb) { EnglishTester_Diectory2 eng2 = new EnglishTester_Diectory2(); try { WordInfo2 wordInfo = eng2.parseToWordInfo(english); String meaning = getChs2Big5(StringUtils.join(wordInfo.getMeaningList(), ";")); setMeaning(meaning, rowPos); } catch (Exception e) { errSb.add(english); e.printStackTrace(); } } private boolean hasChinese(String val) { return new StringUtil_().getChineseWord(val, true).length() > 0; } private Properties loadFromMemoryBank() { try { Properties prop = new Properties(); File f1 = new File( "D:/gtu001_dropbox/Dropbox/Apps/gtu001_test/etc_config/EnglishSearchUI_MemoryBank.properties"); File f2 = new File( "e:/gtu001_dropbox/Dropbox/Apps/gtu001_test/etc_config/EnglishSearchUI_MemoryBank.properties"); for (File f : new File[] { f1, f2 }) { if (f.exists()) { HermannEbbinghaus_Memory memory = new HermannEbbinghaus_Memory(); memory.init(f); List<MemData> memLst = memory.getAllMemData(true); for (MemData d : memLst) { prop.setProperty(d.getKey(), getChs2Big5(d.getRemark())); } break; } } return prop; } catch (Exception ex) { throw new RuntimeException(ex); } } public void actionPerformed(ActionEvent evt) { if (currentFile == null) { return; } // Properties memoryProp = loadFromMemoryBank(); Properties memoryProp = new Properties(); List<String> errSb = new ArrayList<String>(); for (int row = 0; row < propTable.getModel().getRowCount(); row++) { int rowPos = propTable.getRowSorter().convertRowIndexToModel(row); String english = StringUtils.trimToEmpty( (String) propTable.getRowSorter().getModel().getValueAt(rowPos, 1)) .toLowerCase(); String desc = (String) propTable.getRowSorter().getModel().getValueAt(rowPos, 2); if (memoryProp.containsKey(english) && StringUtils.isNotBlank(memoryProp.getProperty(english))) { setMeaning(memoryProp.getProperty(english), rowPos); } else { if (StringUtils.isBlank(desc) || !hasChinese(desc)) { if (!english.contains(" ")) { setMeaningEn1(english, rowPos, errSb); } else { setMeaningEn2(english, rowPos, errSb); } } } if (StringUtils.trimToEmpty(desc).contains("?")) { setMeaning("", rowPos); } } if (!errSb.isEmpty()) { JCommonUtil._jOptionPane_showMessageDialog_error(":\n" + errSb); } } }); } { JMenuItem jMenuItem6 = new JMenuItem(); jMenu1.add(jMenuItem6); jMenuItem6.setText(""); jMenuItem6.addActionListener(new ActionListener() { private void setMeaning(String meaning, int rowPos) { propTable.getRowSorter().getModel().setValueAt(meaning, rowPos, 2); } public void actionPerformed(ActionEvent evt) { for (int row = 0; row < propTable.getModel().getRowCount(); row++) { int rowPos = propTable.getRowSorter().convertRowIndexToModel(row); String english = StringUtils.trimToEmpty( (String) propTable.getRowSorter().getModel().getValueAt(rowPos, 1)) .toLowerCase(); String desc = (String) propTable.getRowSorter().getModel().getValueAt(rowPos, 2); if (StringUtils.trimToEmpty(desc).contains("?")) { setMeaning("", rowPos); } } } }); } } } { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("editor", null, jPanel2, null); { jScrollPane1 = new JScrollPane(); jPanel2.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(550, 314)); { TableModel propTableModel = new DefaultTableModel( new String[][] { { "", "", "" }, { "", "", "" } }, new String[] { "index", "Key", "value" }); propTable = new JTable(); JTableUtil.defaultSetting_AutoResize(propTable); jScrollPane1.setViewportView(propTable); propTable.setModel(propTableModel); propTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { JTableUtil xxxxxx = JTableUtil.newInstance(propTable); int[] rows = xxxxxx.getSelectedRows(); for (int ii : rows) { System.out.println(xxxxxx.getModel().getValueAt(ii, 1)); } JPopupMenuUtil.newInstance(propTable).applyEvent(evt) .addJMenuItem(JTableUtil.newInstance(propTable).getDefaultJMenuItems()) .show(); } }); } } { queryText = new JTextField(); jPanel2.add(queryText, BorderLayout.NORTH); queryText.getDocument() .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() { @Override public void process(DocumentEvent event) { if (currentFile == null) { return; } Properties prop = new Properties(); try { prop.load(new FileInputStream(currentFile)); } catch (Exception e) { e.printStackTrace(); JCommonUtil.handleException(e); return; } loadPropertiesToModel(prop); String text = JCommonUtil.getDocumentText(event); Pattern pattern = null; try { pattern = Pattern.compile(text); } catch (Exception ex) { } DefaultTableModel model = JTableUtil.newInstance(propTable).getModel(); for (int ii = 0; ii < model.getRowCount(); ii++) { String key = (String) model.getValueAt(ii, 1); String value = (String) model.getValueAt(ii, 2); if (key.contains(text)) { continue; } if (value.contains(text)) { continue; } if (pattern != null) { if (pattern.matcher(key).find()) { continue; } if (pattern.matcher(value).find()) { continue; } } model.removeRow(propTable.convertRowIndexToModel(ii)); ii--; } } })); } } { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jTabbedPane1.addTab("folder", null, jPanel3, null); { jScrollPane2 = new JScrollPane(); jPanel3.add(jScrollPane2, BorderLayout.CENTER); jScrollPane2.setPreferredSize(new java.awt.Dimension(550, 314)); { fileList = new JList(); jScrollPane2.setViewportView(fileList); fileList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(fileList).defaultJListKeyPressed(evt); } }); fileList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { final File_ file = JListUtil.getLeadSelectionObject(fileList); if (evt.getButton() == MouseEvent.BUTTON1) { Properties prop = new Properties(); currentFile = file.file; setTitle(currentFile.getName()); try { prop.load(new FileInputStream(file.file)); } catch (Exception e) { e.printStackTrace(); } loadPropertiesToModel(prop); } if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) { try { Runtime.getRuntime().exec(String.format("cmd /c \"%s\"", file.file)); } catch (IOException e1) { e1.printStackTrace(); } } final File parent = file.file.getParentFile(); JMenuItem openTargetDir = new JMenuItem(); openTargetDir.setText("open : " + parent); openTargetDir.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Desktop.getDesktop().open(parent); } catch (IOException e1) { JCommonUtil.handleException(e1); } } }); JPopupMenuUtil.newInstance(fileList).addJMenuItem(openTargetDir).applyEvent(evt) .show(); } }); } } { fileQueryText = new JTextField(); jPanel3.add(fileQueryText, BorderLayout.NORTH); fileQueryText.getDocument() .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() { @Override public void process(DocumentEvent event) { String text = JCommonUtil.getDocumentText(event); DefaultListModel model = new DefaultListModel(); for (File f : backupFileList) { if (f.getName().contains(text)) { File_ ff = new File_(); ff.file = f; model.addElement(ff); } } fileList.setModel(model); } })); } { contentQueryText = new JTextField(); jPanel3.add(contentQueryText, BorderLayout.SOUTH); contentQueryText.addActionListener(new ActionListener() { void addModel(File f, DefaultListModel model) { File_ ff = new File_(); ff.file = f; model.addElement(ff); } public void actionPerformed(ActionEvent evt) { DefaultListModel model = new DefaultListModel(); String text = contentQueryText.getText(); if (StringUtils.isEmpty(contentQueryText.getText())) { return; } Pattern pattern = Pattern.compile(text); Properties pp = null; for (File f : backupFileList) { pp = new Properties(); try { pp.load(new FileInputStream(f)); for (String key : pp.stringPropertyNames()) { if (key.isEmpty()) { continue; } if (pp.getProperty(key) == null || pp.getProperty(key).isEmpty()) { continue; } if (key.contains(text)) { addModel(f, model); break; } if (pp.getProperty(key).contains(text)) { addModel(f, model); break; } if (pattern.matcher(key).find()) { addModel(f, model); break; } if (pattern.matcher(pp.getProperty(key)).find()) { addModel(f, model); break; } } } catch (Exception e) { e.printStackTrace(); } } fileList.setModel(model); } }); } } } JCommonUtil.setJFrameIcon(this, "resource/images/ico/english.ico"); JCommonUtil.setJFrameCenter(this); pack(); this.setSize(571, 408); loadCurrentFile(null); } catch (Exception e) { e.printStackTrace(); } }
From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java
private void buildMenu() { ///////filter pane JXTaskPane filterPane = new JXTaskPane(); filterPane.setTitle("Filtern"); //filter by strength JXButton filterTroopsByStrength = new JXButton( new ImageIcon(TribeTribeAttackFrame.class.getResource("/res/ui/filter_strength.png"))); filterTroopsByStrength.setToolTipText( "<html>Filtert Herkunftsdörfer nach der Anzahl der Truppen im Dorf<br/>Hierfür werden die Truppenzahlen verwendet, die aus dem Spiel<br/>importiert wurden. Achte daher darauf, dass diese Daten immer aktuell sind.</html>"); filterTroopsByStrength.addMouseListener(new MouseAdapter() { @Override/*from www .j a va2 s.co m*/ public void mouseReleased(MouseEvent e) { filterByTroopStrength(); } }); filterPane.getContentPane().add(filterTroopsByStrength); //filter by attack plan JXButton filterByAttackPlan = new JXButton( new ImageIcon(TribeTribeAttackFrame.class.getResource("/res/ui/filter_off.png"))); filterByAttackPlan.setToolTipText( "Entfernt alle Herkunfts- oder Zieldrfer, die bereits in einem vorhandenen Angriffsplan auftauchen"); filterByAttackPlan.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { filterByUsage(); } }); filterPane.getContentPane().add(filterByAttackPlan); ///////edit pane JXTaskPane editPane = new JXTaskPane(); editPane.setTitle("Bearbeiten"); //adapt unit snobs JXButton editUnit = new JXButton( new ImageIcon(TribeTribeAttackFrame.class.getResource("/res/ui/standard_attacks.png"))); editUnit.setToolTipText( "<html>Setzt die langsamste Einheit in den gewählten Herkunftsdörfern auf die Einheit,<br/>die im unteren Einstellungsbereich aktiv ist</html>"); editUnit.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { editUnit(); } }); editPane.getContentPane().add(editUnit); //use snobs JXButton editUseSnobs = new JXButton( new ImageIcon(TribeTribeAttackFrame.class.getResource("/res/ui/use_snob.png"))); editUseSnobs.setToolTipText( "<html>Setzt in Dörfern, in denen sich laut Truppeninformationen AGs befinden, die langsamste Einheit auf AG<br/>Taucht ein Dorf mehrfach auf werden so oft AGs verwendet wie sich AGs im Dorf befinden.<br/>Hierfür werden die Truppenzahlen verwendet, die aus dem Spiel<br/>importiert wurden. Achte daher darauf, dass diese Daten immer aktuell sind.</html>"); editUseSnobs.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { editUseSnobs(); } }); editPane.getContentPane().add(editUseSnobs); //set fake JXButton setFake = new JXButton(new ImageIcon(TribeTribeAttackFrame.class.getResource("/res/ui/fake.png"))); setFake.setToolTipText("Setzt den Angriffstyp fr die markierten Drfer auf 'Fake'"); setFake.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { editSetFake(true); } }); setFake.setSize(editUseSnobs.getSize()); setFake.setPreferredSize(editUseSnobs.getPreferredSize()); setFake.setMinimumSize(editUseSnobs.getMinimumSize()); setFake.setMaximumSize(editUseSnobs.getMaximumSize()); editPane.getContentPane().add(setFake); //set fake JXButton setNoFake = new JXButton( new ImageIcon(TribeTribeAttackFrame.class.getResource("/res/ui/no_fake.png"))); setNoFake.setToolTipText("Setzt den Angriffstyp fr die markierten Drfer auf 'Kein Fake'"); setNoFake.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { editSetFake(false); } }); setNoFake.setSize(editUseSnobs.getSize()); setNoFake.setPreferredSize(editUseSnobs.getPreferredSize()); setNoFake.setMinimumSize(editUseSnobs.getMinimumSize()); setNoFake.setMaximumSize(editUseSnobs.getMaximumSize()); editPane.getContentPane().add(setNoFake); //increase attack count JXButton incAttacks = new JXButton( new ImageIcon(TribeTribeAttackFrame.class.getResource("/res/ui/add_attack.png"))); incAttacks.setToolTipText("Erhht die Anzahl der Angriffe auf die markierten Ziele um 1"); incAttacks.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { editChangeAttacks(1); } }); editPane.getContentPane().add(incAttacks); //decrease attack count JXButton decAttacks = new JXButton( new ImageIcon(TribeTribeAttackFrame.class.getResource("/res/ui/remove_attack.png"))); decAttacks.setToolTipText("Verringert die Anzahl der Angriffe auf die markierten Ziele um 1"); decAttacks.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { editChangeAttacks(-1); } }); editPane.getContentPane().add(decAttacks); //reset attack count JXButton resetAttacks = new JXButton( new ImageIcon(TribeTribeAttackFrame.class.getResource("/res/ui/reset_attacks.png"))); resetAttacks.setToolTipText( "Setzt die Anzahl der Angriffe auf die markierten Ziele auf den Wert, der im Feld 'Max. Angriffe pro Dorf' steht"); resetAttacks.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { editChangeAttacks(0); } }); editPane.getContentPane().add(resetAttacks); ///////edit pane JXTaskPane miscPane = new JXTaskPane(); miscPane.setTitle("Sonstiges"); //troop split JXButton splitTroops = new JXButton( new ImageIcon(TribeTribeAttackFrame.class.getResource("/res/ui/branch.png"))); splitTroops.setToolTipText( "<html>Markierte Herkunftsdörfer nach Truppenzahlen aufsplitten<br/>Hierfür werden die Truppenzahlen verwendet, die aus dem Spiel<br/>importiert wurden. Achte daher darauf, dass diese Daten immer aktuell sind.<br/>Für mehr Informationen zu diesem Feature schau bitte in der Hilfe (F1) nach.</html>"); splitTroops.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { miscSplit(); } }); miscPane.getContentPane().add(splitTroops); //refresh possible attacks JXButton refreshAttackPossibility = new JXButton( new ImageIcon(TribeTribeAttackFrame.class.getResource("/res/ui/replace2.png"))); refreshAttackPossibility.setToolTipText( "Aktualisiert die Werte fr die Anzahl der mglichen Angriffe aus Herkunftsdrfern und auf Zieldrfer, abhngig von den aktuellen Zeiteinstellungen"); refreshAttackPossibility.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { miscRefreshPossibleAttacks(); } }); miscPane.getContentPane().add(refreshAttackPossibility); centerPanel.setupTaskPane(filterPane, editPane, miscPane, jCalculateButton); }
From source file:org.drugis.addis.gui.builder.NetworkMetaAnalysisView.java
private MouseAdapter treatmentCategorizationListener(final NetworkRelativeEffectTableCellRenderer renderer) { return new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) { JTable table = (JTable) e.getComponent(); int row = table.convertRowIndexToModel(table.rowAtPoint(e.getPoint())); int col = table.convertColumnIndexToModel(table.columnAtPoint(e.getPoint())); if (col == row) { Treatment treatment = renderer.getTreatment(table.getModel(), col); TreatmentDefinition treatmentDefinition = d_pm.getTreatmentDefinition(treatment); Category category = treatmentDefinition.getContents().first(); if (category != null && !category.isTrivial()) { d_mainWindow.leftTreeFocus(category.getCategorization()); }//from ww w .jav a2 s. c om } } } }; }
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static SafeNumberField<Integer> createNumericTextField(Integer max, DocumentListener... docListeners) { final SafeNumberField<Integer> field = new SafeNumberField<Integer>(new DecimalFormat("###"), 0, false, max, false);//from ww w .ja v a2s .c om // only positive integer field.setValidChars(UIConstants.DIGITS); if (docListeners != null) { for (DocumentListener docListener : docListeners) { field.getDocument().addDocumentListener(docListener); } } // Add a mouse listener to clear out the field before the user types field.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { try { JTextComponent tc = (JTextComponent) e.getSource(); String txt = tc.getText(); if (!txt.isEmpty()) { field.getFormatter().stringToValue(txt); } } catch (Exception ex) { field.setText(""); } } }); return field; }
From source file:ca.uhn.hl7v2.testpanel.ui.editor.Hl7V2MessageEditorPanel.java
/** * Create the panel./* w w w . j av a2 s .co m*/ */ public Hl7V2MessageEditorPanel(final Controller theController) { setBorder(null); myController = theController; ButtonGroup encGrp = new ButtonGroup(); setLayout(new BorderLayout(0, 0)); mysplitPane = new JSplitPane(); mysplitPane.setResizeWeight(0.5); mysplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); add(mysplitPane); mysplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent theEvt) { double ratio = (double) mysplitPane.getDividerLocation() / mysplitPane.getHeight(); ourLog.debug("Resizing split to ratio: {}", ratio); Prefs.getInstance().setHl7EditorSplit(ratio); } }); EventQueue.invokeLater(new Runnable() { public void run() { mysplitPane.setDividerLocation(Prefs.getInstance().getHl7EditorSplit()); } }); messageEditorContainerPanel = new JPanel(); messageEditorContainerPanel.setBorder(null); mysplitPane.setRightComponent(messageEditorContainerPanel); messageEditorContainerPanel.setLayout(new BorderLayout(0, 0)); myMessageEditor = new JEditorPane(); Highlighter h = new UnderlineHighlighter(); myMessageEditor.setHighlighter(h); // myMessageEditor.setFont(Prefs.getHl7EditorFont()); myMessageEditor.setSelectedTextColor(Color.black); myMessageEditor.setCaret(new EditorCaret()); myMessageScrollPane = new JScrollPane(myMessageEditor); messageEditorContainerPanel.add(myMessageScrollPane); JToolBar toolBar = new JToolBar(); messageEditorContainerPanel.add(toolBar, BorderLayout.NORTH); toolBar.setFloatable(false); toolBar.setRollover(true); myFollowToggle = new JToggleButton("Follow"); myFollowToggle.setToolTipText("Keep the message tree (above) and the message editor (below) in sync"); myFollowToggle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { theController.setMessageEditorInFollowMode(myFollowToggle.isSelected()); } }); myFollowToggle.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/updown.png"))); myFollowToggle.setSelected(theController.isMessageEditorInFollowMode()); toolBar.add(myFollowToggle); myhorizontalStrut = Box.createHorizontalStrut(20); toolBar.add(myhorizontalStrut); mylabel_4 = new JLabel("Encoding"); toolBar.add(mylabel_4); myRdbtnEr7 = new JRadioButton("ER7"); myRdbtnEr7.setMargin(new Insets(1, 2, 0, 1)); toolBar.add(myRdbtnEr7); myRdbtnXml = new JRadioButton("XML"); myRdbtnXml.setMargin(new Insets(1, 5, 0, 1)); toolBar.add(myRdbtnXml); encGrp.add(myRdbtnEr7); encGrp.add(myRdbtnXml); treeContainerPanel = new JPanel(); mysplitPane.setLeftComponent(treeContainerPanel); treeContainerPanel.setLayout(new BorderLayout(0, 0)); mySpinnerIconOn = new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/spinner.gif")); mySpinnerIconOff = new ImageIcon(); myTreePanel = new Hl7V2MessageTree(theController); myTreePanel.setWorkingListener(new IWorkingListener() { public void startedWorking() { mySpinner.setText(""); mySpinner.setIcon(mySpinnerIconOn); mySpinnerIconOn.setImageObserver(mySpinner); } public void finishedWorking(String theStatus) { mySpinner.setText(theStatus); mySpinner.setIcon(mySpinnerIconOff); mySpinnerIconOn.setImageObserver(null); } }); myTreeScrollPane = new JScrollPane(myTreePanel); myTopTabBar = new JTabbedPane(); treeContainerPanel.add(myTopTabBar); myTopTabBar.setBorder(null); JPanel treeContainer = new JPanel(); treeContainer.setLayout(new BorderLayout(0, 0)); treeContainer.add(myTreeScrollPane); myTopTabBar.add("Message Tree", treeContainer); mytoolBar_1 = new JToolBar(); mytoolBar_1.setFloatable(false); treeContainer.add(mytoolBar_1, BorderLayout.NORTH); mylabel_3 = new JLabel("Show"); mytoolBar_1.add(mylabel_3); myShowCombo = new JComboBox(); mytoolBar_1.add(myShowCombo); myShowCombo.setPreferredSize(new Dimension(130, 27)); myShowCombo.setMinimumSize(new Dimension(130, 27)); myShowCombo.setMaximumSize(new Dimension(130, 32767)); collapseAllButton = new JButton(); collapseAllButton.setBorderPainted(false); collapseAllButton.addMouseListener(new HoverButtonMouseAdapter(collapseAllButton)); collapseAllButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myTreePanel.collapseAll(); } }); collapseAllButton.setToolTipText("Collapse All"); collapseAllButton.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/collapse_all.png"))); mytoolBar_1.add(collapseAllButton); expandAllButton = new JButton(); expandAllButton.setBorderPainted(false); expandAllButton.addMouseListener(new HoverButtonMouseAdapter(expandAllButton)); expandAllButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myTreePanel.expandAll(); } }); expandAllButton.setToolTipText("Expand All"); expandAllButton.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/expand_all.png"))); mytoolBar_1.add(expandAllButton); myhorizontalGlue = Box.createHorizontalGlue(); mytoolBar_1.add(myhorizontalGlue); mySpinner = new JButton(""); mySpinner.setForeground(Color.DARK_GRAY); mySpinner.setHorizontalAlignment(SwingConstants.RIGHT); mySpinner.setMaximumSize(new Dimension(200, 15)); mySpinner.setPreferredSize(new Dimension(200, 15)); mySpinner.setMinimumSize(new Dimension(200, 15)); mySpinner.setBorderPainted(false); mySpinner.setSize(new Dimension(16, 16)); mytoolBar_1.add(mySpinner); myProfileComboboxModel = new ProfileComboModel(); myTablesComboModel = new TablesComboModel(myController); mytoolBar = new JToolBar(); mytoolBar.setFloatable(false); mytoolBar.setRollover(true); treeContainerPanel.add(mytoolBar, BorderLayout.NORTH); myOutboundInterfaceCombo = new JComboBox(); myOutboundInterfaceComboModel = new DefaultComboBoxModel(); mylabel_1 = new JLabel("Send"); mytoolBar.add(mylabel_1); myOutboundInterfaceCombo.setModel(myOutboundInterfaceComboModel); myOutboundInterfaceCombo.setMaximumSize(new Dimension(200, 32767)); mytoolBar.add(myOutboundInterfaceCombo); mySendButton = new JButton("Send"); mySendButton.addMouseListener(new HoverButtonMouseAdapter(mySendButton)); mySendButton.setBorderPainted(false); mySendButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // int selectedIndex = // myOutboundInterfaceComboModel.getIndexOf(myOutboundInterfaceComboModel.getSelectedItem()); int selectedIndex = myOutboundInterfaceCombo.getSelectedIndex(); OutboundConnection connection = myController.getOutboundConnectionList().getConnections() .get(selectedIndex); activateSendingActivityTabForConnection(connection); myController.sendMessages(connection, myMessage, mySendingActivityTable.provideTransmissionCallback()); } }); myhorizontalStrut_2 = Box.createHorizontalStrut(20); myhorizontalStrut_2.setPreferredSize(new Dimension(2, 0)); myhorizontalStrut_2.setMinimumSize(new Dimension(2, 0)); myhorizontalStrut_2.setMaximumSize(new Dimension(2, 32767)); mytoolBar.add(myhorizontalStrut_2); mySendOptionsButton = new JButton("Options"); mySendOptionsButton.setBorderPainted(false); final HoverButtonMouseAdapter sendOptionsHoverAdaptor = new HoverButtonMouseAdapter(mySendOptionsButton); mySendOptionsButton.addMouseListener(sendOptionsHoverAdaptor); mySendOptionsButton.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/sendoptions.png"))); mytoolBar.add(mySendOptionsButton); mySendOptionsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent theE) { if (mySendOptionsPopupDialog != null) { mySendOptionsPopupDialog.doHide(); mySendOptionsPopupDialog = null; return; } mySendOptionsPopupDialog = new SendOptionsPopupDialog(Hl7V2MessageEditorPanel.this, myMessage, mySendOptionsButton, sendOptionsHoverAdaptor); Point los = mySendOptionsButton.getLocationOnScreen(); mySendOptionsPopupDialog.setLocation(los.x, los.y + mySendOptionsButton.getHeight()); mySendOptionsPopupDialog.setVisible(true); } }); mySendButton.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/button_execute.png"))); mytoolBar.add(mySendButton); myhorizontalStrut_1 = Box.createHorizontalStrut(20); mytoolBar.add(myhorizontalStrut_1); mylabel_2 = new JLabel("Validate"); mytoolBar.add(mylabel_2); myProfileCombobox = new JComboBox(); mytoolBar.add(myProfileCombobox); myProfileCombobox.setPreferredSize(new Dimension(200, 27)); myProfileCombobox.setMinimumSize(new Dimension(200, 27)); myProfileCombobox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myHandlingProfileComboboxChange) { return; } myHandlingProfileComboboxChange = true; try { if (myProfileCombobox.getSelectedIndex() == 0) { myMessage.setValidationContext(null); } else if (myProfileCombobox.getSelectedIndex() == 1) { myMessage.setValidationContext(new DefaultValidation()); } else if (myProfileCombobox.getSelectedIndex() > 0) { ProfileGroup profile = myProfileComboboxModel.myProfileGroups .get(myProfileCombobox.getSelectedIndex()); myMessage.setRuntimeProfile(profile); // } else if (myProfileCombobox.getSelectedItem() == // ProfileComboModel.APPLY_CONFORMANCE_PROFILE) { // IOkCancelCallback<Void> callback = new // IOkCancelCallback<Void>() { // public void ok(Void theArg) { // myProfileComboboxModel.update(); // } // // public void cancel(Void theArg) { // myProfileCombobox.setSelectedIndex(0); // } // }; // myController.chooseAndLoadConformanceProfileForMessage(myMessage, // callback); } } catch (ProfileException e2) { ourLog.error("Failed to load profile", e2); } finally { myHandlingProfileComboboxChange = false; } } }); myProfileCombobox.setMaximumSize(new Dimension(300, 32767)); myProfileCombobox.setModel(myProfileComboboxModel); myhorizontalStrut_4 = Box.createHorizontalStrut(20); myhorizontalStrut_4.setPreferredSize(new Dimension(2, 0)); myhorizontalStrut_4.setMinimumSize(new Dimension(2, 0)); myhorizontalStrut_4.setMaximumSize(new Dimension(2, 32767)); mytoolBar.add(myhorizontalStrut_4); // mySendingPanel = new JPanel(); // mySendingPanel.setBorder(null); // myTopTabBar.addTab("Sending", null, mySendingPanel, null); // mySendingPanel.setLayout(new BorderLayout(0, 0)); mySendingActivityTable = new ActivityTable(); mySendingActivityTable.setController(myController); myTopTabBar.addTab("Sending", null, mySendingActivityTable, null); // mySendingPanelScrollPanel = new JScrollPane(); // mySendingPanelScrollPanel.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); // mySendingPanelScrollPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); // mySendingPanelScrollPanel.setColumnHeaderView(mySendingActivityTable); // // mySendingPanel.add(mySendingPanelScrollPanel, BorderLayout.CENTER); bottomPanel = new JPanel(); bottomPanel.setPreferredSize(new Dimension(10, 20)); bottomPanel.setMinimumSize(new Dimension(10, 20)); add(bottomPanel, BorderLayout.SOUTH); GridBagLayout gbl_bottomPanel = new GridBagLayout(); gbl_bottomPanel.columnWidths = new int[] { 98, 74, 0 }; gbl_bottomPanel.rowHeights = new int[] { 16, 0 }; gbl_bottomPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gbl_bottomPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; bottomPanel.setLayout(gbl_bottomPanel); mylabel = new JLabel("Terser Path:"); mylabel.setHorizontalTextPosition(SwingConstants.LEFT); mylabel.setHorizontalAlignment(SwingConstants.LEFT); GridBagConstraints gbc_label = new GridBagConstraints(); gbc_label.fill = GridBagConstraints.VERTICAL; gbc_label.weighty = 1.0; gbc_label.anchor = GridBagConstraints.NORTHWEST; gbc_label.gridx = 0; gbc_label.gridy = 0; bottomPanel.add(mylabel, gbc_label); myTerserPathTextField = new JLabel(); myTerserPathTextField.setForeground(Color.BLUE); myTerserPathTextField.setFont(new Font("Lucida Console", Font.PLAIN, 13)); myTerserPathTextField.setBorder(null); myTerserPathTextField.setBackground(SystemColor.control); myTerserPathTextField.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (StringUtils.isNotEmpty(myTerserPathTextField.getText())) { myTerserPathPopupMenu.show(myTerserPathTextField, 0, 0); } } }); GridBagConstraints gbc_TerserPathTextField = new GridBagConstraints(); gbc_TerserPathTextField.weightx = 1.0; gbc_TerserPathTextField.fill = GridBagConstraints.HORIZONTAL; gbc_TerserPathTextField.gridx = 1; gbc_TerserPathTextField.gridy = 0; bottomPanel.add(myTerserPathTextField, gbc_TerserPathTextField); initLocal(); }
From source file:edu.ku.brc.specify.ui.AppBase.java
/** * Shows the About dialog./*from www .j a v a 2 s . c om*/ */ public void doAbout() { AppContextMgr acm = AppContextMgr.getInstance(); boolean hasContext = acm.hasContext(); int baseNumRows = 9; String serverName = AppPreferences.getLocalPrefs().get("login.servers_selected", null); if (serverName != null) { baseNumRows++; } CellConstraints cc = new CellConstraints(); PanelBuilder infoPB = new PanelBuilder(new FormLayout("p,6px,f:p:g", "p,4px,p,4px," + UIHelper.createDuplicateJGoodiesDef("p", "2px", baseNumRows))); JLabel iconLabel = new JLabel(IconManager.getIcon("SpecifyLargeIcon"), SwingConstants.CENTER); //$NON-NLS-1$ PanelBuilder iconPB = new PanelBuilder(new FormLayout("p", "20px,t:p,f:p:g")); iconPB.add(iconLabel, cc.xy(1, 2)); if (hasContext) { DBTableIdMgr tableMgr = DBTableIdMgr.getInstance(); boolean hasReged = !RegisterSpecify.isAnonymous() && RegisterSpecify.hasInstitutionRegistered(); int y = 1; infoPB.addSeparator(getResourceString("Specify.SYS_INFO"), cc.xyw(1, y, 3)); y += 2; JLabel lbl = UIHelper.createLabel(databaseName); infoPB.add(UIHelper.createI18NFormLabel("Specify.DB"), cc.xy(1, y)); infoPB.add(lbl, cc.xy(3, y)); y += 2; lbl.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openLocalPrefs(); } } }); infoPB.add(UIHelper.createFormLabel(tableMgr.getTitleForId(Institution.getClassTableId())), cc.xy(1, y)); infoPB.add(lbl = UIHelper.createLabel(acm.getClassObject(Institution.class).getName()), cc.xy(3, y)); y += 2; lbl.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openRemotePrefs(); } } }); infoPB.add(UIHelper.createFormLabel(tableMgr.getTitleForId(Division.getClassTableId())), cc.xy(1, y)); infoPB.add(UIHelper.createLabel(acm.getClassObject(Division.class).getName()), cc.xy(3, y)); y += 2; infoPB.add(UIHelper.createFormLabel(tableMgr.getTitleForId(Discipline.getClassTableId())), cc.xy(1, y)); infoPB.add(UIHelper.createLabel(acm.getClassObject(Discipline.class).getName()), cc.xy(3, y)); y += 2; infoPB.add(UIHelper.createFormLabel(tableMgr.getTitleForId(Collection.getClassTableId())), cc.xy(1, y)); infoPB.add(UIHelper.createLabel(acm.getClassObject(Collection.class).getCollectionName()), cc.xy(3, y)); y += 2; infoPB.add(UIHelper.createI18NFormLabel("Specify.BLD"), cc.xy(1, y)); infoPB.add(UIHelper.createLabel(appBuildVersion), cc.xy(3, y)); y += 2; infoPB.add(UIHelper.createI18NFormLabel("Specify.REG"), cc.xy(1, y)); infoPB.add(UIHelper.createI18NLabel(hasReged ? "Specify.HASREG" : "Specify.NOTREG"), cc.xy(3, y)); y += 2; String isaNumber = RegisterSpecify.getISANumber(); infoPB.add(UIHelper.createI18NFormLabel("Specify.ISANUM"), cc.xy(1, y)); infoPB.add(UIHelper.createLabel(StringUtils.isNotEmpty(isaNumber) ? isaNumber : ""), cc.xy(3, y)); y += 2; if (serverName != null) { infoPB.add(UIHelper.createI18NFormLabel("Specify.SERVER"), cc.xy(1, y)); infoPB.add(UIHelper.createLabel(StringUtils.isNotEmpty(serverName) ? serverName : ""), cc.xy(3, y)); y += 2; } if (StringUtils.contains(DBConnection.getInstance().getConnectionStr(), "mysql")) { Vector<Object[]> list = BasicSQLUtils.query("select version() as ve"); if (list != null && list.size() > 0) { infoPB.add(UIHelper.createFormLabel("MySQL Version"), cc.xy(1, y)); infoPB.add(UIHelper.createLabel(list.get(0)[0].toString()), cc.xy(3, y)); y += 2; } } infoPB.add(UIHelper.createFormLabel("Java Version"), cc.xy(1, y)); infoPB.add(UIHelper.createLabel(System.getProperty("java.version")), cc.xy(3, y)); y += 2; } String txt = getAboutText(appName, appVersion); JLabel txtLbl = createLabel(txt); txtLbl.setFont(UIRegistry.getDefaultFont()); final JEditorPane txtPane = new JEditorPane("text/html", txt); txtPane.setEditable(false); txtPane.setBackground(new JPanel().getBackground()); PanelBuilder pb = new PanelBuilder(new FormLayout("p,20px,f:min(400px;p):g,10px,8px,10px,p:g", "f:p:g")); pb.add(iconPB.getPanel(), cc.xy(1, 1)); pb.add(txtPane, cc.xy(3, 1)); Color bg = getBackground(); if (hasContext) { pb.add(new VerticalSeparator(bg.darker(), bg.brighter()), cc.xy(5, 1)); pb.add(infoPB.getPanel(), cc.xy(7, 1)); } pb.setDefaultDialogBorder(); String title = getResourceString("Specify.ABOUT");//$NON-NLS-1$ CustomDialog aboutDlg = new CustomDialog(topFrame, title + " " + appName, true, CustomDialog.OK_BTN, //$NON-NLS-1$ pb.getPanel()); String okLabel = getResourceString("Specify.CLOSE");//$NON-NLS-1$ aboutDlg.setOkLabel(okLabel); aboutDlg.createUI(); aboutDlg.pack(); // for some strange reason I can't get the dialog to size itself correctly Dimension size = aboutDlg.getSize(); size.height += 120; aboutDlg.setSize(size); txtPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { AttachmentUtils.openURI(event.getURL().toURI()); } catch (Exception e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); } } } }); UIHelper.centerAndShow(aboutDlg); }
From source file:cool.pandora.modeller.ui.jpanel.base.BagView.java
/** * createBagTagButtonPanel./*from w w w . jav a2s .com*/ * * @return buttonPanel */ private JPanel createBagTagButtonPanel() { final JPanel buttonPanel = new JPanel(); final ShowTagFilesHandler showTageFileHandler = new ShowTagFilesHandler(this); addTagFileHandler = new AddTagFileHandler(this); removeTagFileHandler = new RemoveTagFileHandler(this); buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 2, 2)); viewTagFilesToolbarAction = new JLabel(""); viewTagFilesToolbarAction.setEnabled(false); viewTagFilesToolbarAction.setHorizontalAlignment(SwingConstants.CENTER); viewTagFilesToolbarAction.setBorder(new LineBorder(viewTagFilesToolbarAction.getBackground(), 1)); viewTagFilesToolbarAction.setIcon(getPropertyImage("Bag_ViewTagFile.icon")); viewTagFilesToolbarAction.setToolTipText(getMessage("bagView.TagFilesTree.viewfile" + ".tooltip")); viewTagFilesToolbarAction.addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { if (viewTagFilesToolbarAction.isEnabled()) { showTageFileHandler.actionPerformed(null); } } @Override public void mouseExited(final MouseEvent e) { viewTagFilesToolbarAction.setBorder(new LineBorder(viewTagFilesToolbarAction.getBackground(), 1)); } @Override public void mouseEntered(final MouseEvent e) { if (viewTagFilesToolbarAction.isEnabled()) { viewTagFilesToolbarAction.setBorder(new LineBorder(Color.GRAY, 1)); } } }); buttonPanel.add(viewTagFilesToolbarAction); addTagFileToolBarAction = new JLabel(""); addTagFileToolBarAction.setEnabled(false); addTagFileToolBarAction.setHorizontalAlignment(SwingConstants.CENTER); addTagFileToolBarAction.setBorder(new LineBorder(addTagFileToolBarAction.getBackground(), 1)); addTagFileToolBarAction.setIcon(getPropertyImage("Bag_Content.add.icon")); addTagFileToolBarAction.setToolTipText(getMessage("bagView.TagFilesTree.addbutton" + ".tooltip")); addTagFileToolBarAction.addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { if (addTagFileToolBarAction.isEnabled()) { addTagFileHandler.actionPerformed(null); } } @Override public void mouseExited(final MouseEvent e) { addTagFileToolBarAction.setBorder(new LineBorder(addTagFileToolBarAction.getBackground(), 1)); } @Override public void mouseEntered(final MouseEvent e) { if (addTagFileToolBarAction.isEnabled()) { addTagFileToolBarAction.setBorder(new LineBorder(Color.GRAY, 1)); } } }); buttonPanel.add(addTagFileToolBarAction); removeTagFileToolbarAction = new JLabel(""); removeTagFileToolbarAction.setEnabled(false); removeTagFileToolbarAction.setHorizontalAlignment(SwingConstants.CENTER); removeTagFileToolbarAction.setBorder(new LineBorder(removeTagFileToolbarAction.getBackground(), 1)); removeTagFileToolbarAction.setIcon(getPropertyImage("Bag_Content.minus.icon")); removeTagFileToolbarAction.setToolTipText(getMessage("bagView.TagFilesTree.remove" + ".tooltip")); buttonPanel.add(removeTagFileToolbarAction); removeTagFileToolbarAction.addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { if (removeTagFileToolbarAction.isEnabled()) { removeTagFileHandler.actionPerformed(null); } } @Override public void mouseExited(final MouseEvent e) { removeTagFileToolbarAction.setBorder(new LineBorder(removeTagFileToolbarAction.getBackground(), 1)); } @Override public void mouseEntered(final MouseEvent e) { if (removeTagFileToolbarAction.isEnabled()) { removeTagFileToolbarAction.setBorder(new LineBorder(Color.GRAY, 1)); } } }); final JLabel spacerLabel = new JLabel(" "); buttonPanel.add(spacerLabel); addTagFileHandler = new AddTagFileHandler(this); removeTagFileHandler = new RemoveTagFileHandler(this); return buttonPanel; }