List of usage examples for javax.swing.event ListSelectionListener ListSelectionListener
ListSelectionListener
From source file:edu.ku.brc.specify.tasks.subpane.VisualQueryPanel.java
/** * Creates the UI.// w w w . ja v a 2 s. co m */ protected void createUI() { CellConstraints cc = new CellConstraints(); lineLayer = new RenderableLayer(); upBtn = UIHelper.createIconBtn("Green Arrow Up", "", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { moveItems(recSetList, botIdHash, dbObjList, topIdHash); } }); dwnBtn = UIHelper.createIconBtn("Green Arrow Down", "", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { moveItems(dbObjList, topIdHash, recSetList, botIdHash); boolean hasItems = recSetList.getModel().getSize() > 0; rsBtn.setEnabled(hasItems); fmBtn.setEnabled(hasItems); } }); selectAllBtn = UIHelper.createI18NButton("SELECTALL"); selectAllBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dbObjList.clearSelection(); dbObjList.getSelectionModel().setSelectionInterval(0, dbObjList.getModel().getSize()); } }); deselectAllBtn = UIHelper.createI18NButton("DESELECTALL"); deselectAllBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dbObjList.clearSelection(); } }); PanelBuilder upDwnPB = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g,p,10px,p,f:p:g,p,f:p:g", "p")); //upDwnPB.add(selectAllBtn, cc.xy(2,1)); upDwnPB.add(dwnBtn, cc.xy(4, 1)); upDwnPB.add(upBtn, cc.xy(6, 1)); //upDwnPB.add(deselectAllBtn, cc.xy(7,1)); dbObjList = new JList(new DefaultListModel()); dbObjList.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); //wpList.setCellRenderer(new WPListCellRenderer()); dbObjList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { upBtn.setEnabled(false); dwnBtn.setEnabled(dbObjList.getSelectedIndex() != -1); } }); recSetList = new JList(new DefaultListModel()); recSetList.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); //trkList.setCellRenderer(new TrkListCellRenderer()); recSetList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { boolean isSel = recSetList.getSelectedIndex() != -1; dwnBtn.setEnabled(false); upBtn.setEnabled(isSel); } }); rsBtn = UIHelper.createIconBtn("Record_Set", IconManager.IconSize.Std24, "", null); fmBtn = UIHelper.createIconBtn("FormEdit", IconManager.IconSize.Std24, "", null); PanelBuilder toolsBtnPB = new PanelBuilder(new FormLayout("f:p:g,2px,p,2px,p", "p")); toolsBtnPB.add(fmBtn, cc.xy(3, 1)); toolsBtnPB.add(rsBtn, cc.xy(5, 1)); PanelBuilder leftPB = new PanelBuilder( new FormLayout("min(p;250px),10px,f:p:g", "p,2px,f:p:g, 4px,p,4px, p,2px,f:p:g, 2px,p")); int y = 1; leftPB.add(topLbl = UIHelper.createLabel("Available Points"), cc.xy(1, y)); y += 2; // I18N leftPB.add(UIHelper.createScrollPane(dbObjList, true), cc.xy(1, y)); y += 2; leftPB.add(upDwnPB.getPanel(), cc.xy(1, y)); y += 2; leftPB.add(UIHelper.createLabel("Selected Objects"), cc.xy(1, y)); y += 2; leftPB.add(UIHelper.createScrollPane(recSetList, true), cc.xy(1, y)); y += 2; leftPB.add(toolsBtnPB.getPanel(), cc.xy(1, y)); y += 2; wwPanel = new WorldWindPanel(); wwPanel.setPreferredSize(new Dimension(MAP_WIDTH, MAP_HEIGHT)); wwPanel.getWorld().addSelectListener(new ClickAndGoSelectListener(wwPanel.getWorld(), MarkerLayer.class)); //wwPanel.getWorld().addSelectListener(getWWSelectListener()); //wwPanel.getWorld().getInputHandler().addMouseListener(getWWMouseAdapter()); PanelBuilder rightPB = new PanelBuilder(new FormLayout("f:p:g", "f:p:g")); // ZZZ lineBuilder = new LineBuilder(wwPanel.getWorld(), lineLayer, polyline); rightPB.add(wwPanel, cc.xy(1, 1)); y += 2; polyline.setAntiAliasHint(Polyline.ANTIALIAS_NICEST); polyline.setLineWidth(1.5); polyline.setFollowTerrain(true); startBtn = UIHelper.createI18NButton("Start"); endBtn = UIHelper.createI18NButton("End"); searchBtn = UIHelper.createI18NButton("SEARCH"); clearAllBtn = UIHelper.createI18NButton("Clear All"); clearSearchBtn = UIHelper.createI18NButton("Clear Search"); typeCBX = UIHelper.createComboBox(TABLE_INFO); PanelBuilder btnPB = new PanelBuilder( new FormLayout("f:p:g,p,f:p:g,p,f:p:g,p,f:p:g,p,f:p:g,p,f:p:g,p,f:p:g", "p")); btnPB.add(typeCBX, cc.xy(2, 1)); btnPB.add(startBtn, cc.xy(4, 1)); btnPB.add(endBtn, cc.xy(6, 1)); btnPB.add(searchBtn, cc.xy(8, 1)); btnPB.add(clearSearchBtn, cc.xy(10, 1)); btnPB.add(clearAllBtn, cc.xy(12, 1)); PanelBuilder pb = new PanelBuilder(new FormLayout("p,10px,f:p:g", "f:p:g, 4px, p"), this); pb.add(leftPB.getPanel(), cc.xy(1, 1)); pb.add(rightPB.getPanel(), cc.xy(3, 1)); pb.add(btnPB.getPanel(), cc.xyw(1, 3, 3)); pb.setDefaultDialogBorder(); startBtn.setEnabled(true); endBtn.setEnabled(false); searchBtn.setEnabled(false); clearAllBtn.setEnabled(false); clearSearchBtn.setEnabled(false); rsBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { RecordSetIFace rs = createRecordSet(); if (rs != null) { CommandDispatcher.dispatch(new CommandAction(RecordSetTask.RECORD_SET, "Save", null, null, rs)); } } }); fmBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { RecordSetIFace rs = createRecordSet(); if (rs != null) { CommandDispatcher .dispatch(new CommandAction(DataEntryTask.DATA_ENTRY, DataEntryTask.EDIT_DATA, rs)); } } }); searchBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { doSearch(); } catch (IOException e1) { e1.printStackTrace(); } } }); startBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (true) { //doSearch(); //return; } /* double lat = 37.24517; double lon = -100.99083; double[] p = new double[] {-100.90805562872109,37.24714676134192, -101.1442623355922,37.15441022126542, -100.78757107464702,37.1712467680786, -100.90570697458969,37.24401619379327, -100.90805562872109,37.24714676134192}; ArrayList<Position> list = new ArrayList<Position>(); for (int i=0;i<p.length;i++) { Position pos = Position.fromDegrees(p[i+1], p[i], 0); list.add(pos); i++; } polygon = new Polyline(list); polygon.setClosed(true); Position pos = Position.fromDegrees(lat, lon, 0.0); System.out.println("isLocationInside: "+GeometryMath.isLocationInside(pos, polygon.getPositions())); */ //polygonWWPoints.clear(); isCreatingPolygon = true; searchBtn.setEnabled(false); endBtn.setEnabled(true); startBtn.setEnabled(false); // ZZZ lineBuilder.setArmed(true); } }); endBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { polyline.setClosed(true); isCreatingPolygon = false; searchBtn.setEnabled(true); endBtn.setEnabled(false); startBtn.setEnabled(false); searchBtn.setEnabled(true); clearAllBtn.setEnabled(true); clearSearchBtn.setEnabled(true); //polygonWWPoints.add(polygonWWPoints.get(0)); //createPolyline(); // ZZZ lineBuilder.setArmed(false); } }); clearAllBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doClearAll(true); } }); clearSearchBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doClearAll(false); } }); typeCBX.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doPickedNewObjType(); } }); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { typeCBX.setSelectedIndex(0); } }); }
From source file:edu.ku.brc.af.ui.forms.formatters.UIFormatterListEdtDlg.java
/** * //from w w w. jav a2 s.c o m */ private void hookFormatListSelectionListener() { if (formatListSelectionListener == null) { formatListSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } updateUIEnabled(); } }; } formatList.addListSelectionListener(formatListSelectionListener); }
From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowserAdvancedFilter.java
private void initMetaDataSearchTable() { metaDataSearchTable.setModel(new DefaultTableModel(new Object[][] {}, new String[] { "Metadata", "Operator", "Value", "Ignore Case" }) { public boolean isCellEditable(int rowIndex, int columnIndex) { if (columnIndex == 3 && cachedMetaDataColumns.get(getValueAt(rowIndex, 0)) .getType() != MetaDataColumnType.STRING) { return false; }// ww w. j a va 2 s .c o m return true; } @Override public void setValueAt(Object value, int row, int column) { int metaDataColumnIndex = findColumn("Metadata"); int operatorColumnIndex = findColumn("Operator"); int valueColumnIndex = findColumn("Value"); int ignoreCaseColumnIndex = findColumn("Ignore Case"); if (column == valueColumnIndex) { MetaDataColumn metaDataColumn = cachedMetaDataColumns.get(getValueAt(row, metaDataColumnIndex)); if (StringUtils.isNotEmpty((String) value)) { try { metaDataColumn.getType().castValue(value); } catch (MetaDataColumnException e) { parent.alertError(parent, "Invalid value for column type " + metaDataColumn.getType().toString()); return; } } } else if (column == metaDataColumnIndex) { if (!value.equals(getValueAt(row, metaDataColumnIndex))) { MetaDataSearchOperator operator = MetaDataSearchOperator.EQUAL; super.setValueAt(operator, row, operatorColumnIndex); MetaDataColumn metaDataColumn = cachedMetaDataColumns.get(value); if (metaDataColumn.getType() != MetaDataColumnType.STRING) { super.setValueAt(Boolean.FALSE, row, ignoreCaseColumnIndex); } } super.setValueAt("", row, valueColumnIndex); } super.setValueAt(value, row, column); } }); metaDataSearchTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); metaDataSearchTable.setDragEnabled(false); metaDataSearchTable.setSortable(false); metaDataSearchTable.getTableHeader().setReorderingAllowed(false); addMetaDataSearchButton.setEnabled(!messageBrowser.getMetaDataColumns().isEmpty()); metaDataSearchTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { deleteMetaDataSearchButton.setEnabled(getSelectedRow(metaDataSearchTable) != -1); } }); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { metaDataSearchTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } List<MetaDataColumn> metaDataColumns = messageBrowser.getMetaDataColumns(); cachedMetaDataColumns.clear(); String[] metaDataNames = new String[metaDataColumns.size()]; for (int i = 0; i < metaDataColumns.size(); i++) { String columnName = metaDataColumns.get(i).getName(); metaDataNames[i] = columnName; cachedMetaDataColumns.put(columnName, metaDataColumns.get(i)); } MirthComboBoxTableCellEditor metaDataEditor = new MirthComboBoxTableCellEditor(metaDataSearchTable, metaDataNames, 1, false, null); metaDataEditor.getComboBox().setAutoResizeDropdown(true); TableColumn metaDataColumn = metaDataSearchTable.getColumnModel().getColumn(0); metaDataColumn.setCellRenderer(new MirthComboBoxTableCellRenderer(metaDataNames)); metaDataColumn.setCellEditor(metaDataEditor); metaDataColumn.setMinWidth(METADATA_NAME_COLUMN_WIDTH); metaDataColumn.setMaxWidth(METADATA_NAME_COLUMN_WIDTH * 2); metaDataColumn.setPreferredWidth(METADATA_NAME_COLUMN_WIDTH); // Need to create this custom editor since the combo box values are dynamic based on metadata column type. MirthComboBoxTableCellEditor operatorEditor = new MirthComboBoxTableCellEditor(metaDataSearchTable, MetaDataSearchOperator.values(), 1, false, null) { public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { MetaDataColumn metaDataColumn = cachedMetaDataColumns.get(table.getValueAt(row, 0)); comboBox.setModel(new DefaultComboBoxModel( MetaDataSearchOperator.valuesForColumnType(metaDataColumn.getType()))); return super.getTableCellEditorComponent(table, value, isSelected, row, column); } }; TableColumn operatorColumn = metaDataSearchTable.getColumnModel().getColumn(1); operatorColumn.setCellRenderer(new MirthComboBoxTableCellRenderer(MetaDataSearchOperator.values())); operatorColumn.setCellEditor(operatorEditor); operatorColumn.setMinWidth(METADATA_OPERATOR_COLUMN_WIDTH); operatorColumn.setMaxWidth(METADATA_OPERATOR_COLUMN_WIDTH); TableColumn caseColumn = metaDataSearchTable.getColumnModel().getColumn(3); caseColumn.setMinWidth(METADATA_CASE_COLUMN_WIDTH); caseColumn.setMaxWidth(METADATA_CASE_COLUMN_WIDTH); deleteMetaDataSearchButton.setEnabled(false); }
From source file:net.sf.taverna.t2.workbench.cagrid.CaGridComponent.java
private void addResultPanel() { GridBagConstraints c = new GridBagConstraints(); c.gridx = 0;/* w w w . j a v a 2 s.com*/ c.gridy = ++row; c.fill = GridBagConstraints.BOTH; c.weightx = 0.01; c.weighty = 0.01; c.anchor = GridBagConstraints.SOUTHEAST; c.gridwidth = GridBagConstraints.REMAINDER; resultPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); resultPanel.setDividerLocation(200); resultPanel.setBorder(null); runListModel = new DefaultListModel(); runList = new JList(runListModel); runList.setBorder(new EmptyBorder(5, 5, 5, 5)); runList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); runListPanel = new JPanel(new BorderLayout()); runListPanel.setBorder(LineBorder.createGrayLineBorder()); JLabel worklflowRunsLabel = new JLabel("Workflow Runs"); worklflowRunsLabel.setBorder(new EmptyBorder(5, 5, 5, 5)); removeCaGridRunsButton = new JButton("Remove"); // button to remove previous workflow runs removeCaGridRunsButton.setAlignmentX(JComponent.RIGHT_ALIGNMENT); removeCaGridRunsButton.setEnabled(false); removeCaGridRunsButton.setToolTipText("Remove caGrid run(s)"); removeCaGridRunsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int[] selected = runList.getSelectedIndices(); for (int i = selected.length - 1; i >= 0; i--) { CaGridRun cr = (CaGridRun) runListModel.get(selected[i]); //delete the EPR file File file = new File(new File(System.getProperty("user.home")), cr.workflowid + ".epr"); file.delete(); System.out.println(cr.workflowid + ".epr deleted"); runListModel.remove(selected[i]); } // Set the first item as selected - if there is one if (runListModel.size() > 0) { runList.setSelectedIndex(0); } else { resultText.setText(""); resultText.revalidate(); } } }); runListPanel.add(worklflowRunsLabel, BorderLayout.NORTH); runListPanel.add(removeCaGridRunsButton, BorderLayout.BEFORE_FIRST_LINE); JScrollPane scrollPane = new JScrollPane(runList); scrollPane.setBorder(null); runListPanel.add(scrollPane, BorderLayout.CENTER); // loadWorkflowRunsFromStoredEPRFiles(): add CaGridRun to runList for each EPR // add two buttons: remove and refresh status runList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { Object selection = runList.getSelectedValue(); if (selection instanceof CaGridRun) { removeCaGridRunsButton.setEnabled(true); CaGridRun dataflowRun = (CaGridRun) selection; // update status and refresh outputPanel String resultDisplayString = updateResultDisplayString(dataflowRun); resultText.setText(resultDisplayString); resultText.setLineWrap(true); resultText.setEditable(false); outputPanel.revalidate(); revalidate(); } else { removeCaGridRunsButton.setEnabled(false); revalidate(); } } } }); resultPanel.setTopComponent(runListPanel); //each output should be a (xml) string outputPanel = new JScrollPane(); resultText = new JTextArea(); outputPanel = new JScrollPane(resultText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); //outputPanel = new JPanel(new BorderLayout()); outputPanel.setBorder(LineBorder.createGrayLineBorder()); outputPanel.setBackground(Color.WHITE); //outputPanel.add(new JLabel("Workflow Execution Outputs shows here.", JLabel.CENTER), null); resultPanel.setBottomComponent(outputPanel); add(resultPanel, c); //add runComponent to the GUI ArrayList<CaGridRun> loadedRunList = loadWorkflowRunsFromStoredEPRFiles(null, (String) services.getSelectedItem()); if (loadedRunList != null) { for (int m = 0; m < loadedRunList.size(); m++) { CaGridRun cr = (CaGridRun) loadedRunList.get(m); runListModel.add(0, cr); } System.out.println(loadedRunList.size() + " EPR loaded."); runList.setSelectedIndex(0); } }
From source file:com.mirth.connect.client.ui.editors.RuleBuilderPanel.java
public void setValues(ArrayList<String> values) { Object[][] tableData = new Object[values.size()][1]; valuesTable = new MirthTable(); for (int i = 0; i < values.size(); i++) { tableData[i][VALUE_COLUMN] = values.get(i); }/*from w w w. j a va 2s .c om*/ valuesTable .setModel(new javax.swing.table.DefaultTableModel(tableData, new String[] { VALUE_COLUMN_NAME }) { boolean[] canEdit = new boolean[] { true }; public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); valuesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (getSelectedRow() != -1) { lastIndex = getSelectedRow(); deleteButton.setEnabled(true); } else { deleteButton.setEnabled(false); } rulePlugin.updateName(); } }); class RegExTableCellEditor extends TextFieldCellEditor { public boolean stopCellEditing() { parent.modified = true; deleteButton.setEnabled(true); boolean result = super.stopCellEditing(); /* * HACK: Cannot move this logic into valueChanged. We need to * update the name after stopping cell editing, because the * swingx update caused the ListSelectionListener to stop being * called when there was only one row and it was edited. */ rulePlugin.updateName(); return result; } @Override public boolean isCellEditable(EventObject evt) { boolean editable = super.isCellEditable(evt); if (editable) { deleteButton.setEnabled(false); } return editable; } @Override protected boolean valueChanged(String value) { return true; } } // Set the custom cell editor for the Destination Name column. valuesTable.getColumnModel().getColumn(valuesTable.getColumnModel().getColumnIndex(VALUE_COLUMN_NAME)) .setCellEditor(new RegExTableCellEditor()); valuesTable.setCustomEditorControls(true); valuesTable.setSelectionMode(0); valuesTable.setRowSelectionAllowed(true); valuesTable.setRowHeight(UIConstants.ROW_HEIGHT); valuesTable.setDragEnabled(false); valuesTable.setOpaque(true); valuesTable.setSortable(false); valuesTable.getTableHeader().setReorderingAllowed(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); valuesTable.setHighlighters(highlighter); } valuesScrollPane.setViewportView(valuesTable); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.ImageFrame.java
/** * Constructor. //from w w w . j a v a2s . c o m */ public ImageFrame(final int mapSize, final WorkbenchPaneSS wbPane, final Workbench workbench, final Taskable task, final boolean isReadOnly) { this.wbPane = wbPane; this.workbench = workbench; try { this.workbenchTask = (WorkbenchTask) task; } catch (ClassCastException e) { this.workbenchTask = null; } this.allowCloseWindow = true; this.defaultThumbIcon = IconManager.getIcon("image", IconSize.Std32); setIconImage(IconManager.getImage("AppIcon").getImage()); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { if (allowCloseWindow) { wbPane.toggleImageFrameVisible(); } } }); Dimension minSize = new Dimension(mapSize, mapSize); cardImageLabel.setHorizontalTextPosition(SwingConstants.CENTER); PanelBuilder builder = new PanelBuilder(new FormLayout("f:p:g,c:p,f:p:g", "f:p:g,p,5px,p,f:p:g")); CellConstraints cc = new CellConstraints(); loadImgBtn = createButton(getResourceString("WB_LOAD_NEW_IMAGE")); builder.add(createLabel(getResourceString("WB_NO_IMAGE_ROW"), SwingConstants.CENTER), cc.xy(2, 2)); builder.add(loadImgBtn, cc.xy(2, 4)); loadImgBtn.setVisible(!isReadOnly); noCardImageMessagePanel = builder.getPanel(); noCardImageMessagePanel.setPreferredSize(minSize); noCardImageMessagePanel.setSize(minSize); builder = new PanelBuilder(new FormLayout("f:p:g,c:p,f:p:g", "f:p:g,c:p,f:p:g")); builder.add(createLabel(getResourceString("WB_NO_ROW_SELECTED"), SwingConstants.CENTER), cc.xy(2, 2)); noRowSelectedMessagePanel = builder.getPanel(); noRowSelectedMessagePanel.setPreferredSize(minSize); noRowSelectedMessagePanel.setSize(minSize); mainPane = new JPanel(new BorderLayout()); mainPane.setSize(minSize); mainPane.setPreferredSize(minSize); mainPane.setMinimumSize(minSize); mainPane.add(cardImageLabel, BorderLayout.CENTER); scrollPane = new JScrollPane(mainPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); statusBar = new JStatusBar(); thumbnailer = new ImageThumbnailGenerator(); thumbnailer.setMaxSize(256, 256); thumbnailer.setQuality(1); tray = new ThumbnailTray(); tray.getModel().removeAllElements(); tray.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } setImageIndex(tray.getSelectedIndex()); } }); JPanel southPanel = new JPanel(); southPanel.setLayout(new BorderLayout()); //southPanel.add(indexSlider,BorderLayout.NORTH); southPanel.add(tray, BorderLayout.CENTER); southPanel.add(statusBar, BorderLayout.SOUTH); JPanel basePanel = new JPanel(); basePanel.setLayout(new BorderLayout()); basePanel.add(scrollPane, BorderLayout.CENTER); basePanel.add(southPanel, BorderLayout.SOUTH); setContentPane(basePanel); JMenuBar menuBar = new JMenuBar(); String title = "FileMenu"; String mneu = "FileMneu"; JMenu fileMenu = UIHelper.createLocalizedMenu(menuBar, title, mneu); title = "WB_IMPORT_CARDS_TO_DATASET"; mneu = "WB_IMPORT_CARDS_MNEU"; if (!isReadOnly) { JMenuItem importImagesMI = UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, null); importImagesMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { importImages(); } }); } /* title = "ImageFrame.CLOSE"; mneu = "ImageFrame.CloseMneu"; closeMI = UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, null); closeMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { ImageFrame.this.setVisible(false); } });*/ title = "ImageFrame.View"; mneu = "ImageFrame.ViewMneu"; viewMenu = UIHelper.createLocalizedMenu(menuBar, title, mneu); reduceMI = UIHelper.createRadioButtonMenuItem(viewMenu, "WB_REDUCED_SIZE", "ImageFrame.ReducedSizeMneu", "", true, null); reduceMI.setSelected(true); reduceMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (row == null) { return; } // simply 'remember' that we want to show reduced images for this row rowToImageSizeHash.put(row.hashCode(), REDUCED_SIZE); // then 'reshow' the current image showImage(); } }); origMI = UIHelper.createRadioButtonMenuItem(viewMenu, "WB_ORIG_SIZE", "ImageFrame.OrigMneu", "", true, null); origMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (row == null) { return; } // simply 'remember' that we want to show fill size images for this row rowToImageSizeHash.put(row.hashCode(), FULL_SIZE); // then 'reshow' the current image showImage(); } }); ButtonGroup btnGrp = new ButtonGroup(); btnGrp.add(reduceMI); btnGrp.add(origMI); viewMenu.addSeparator(); alwaysOnTopMI = UIHelper.createCheckBoxMenuItem(viewMenu, "WB_ALWAYS_ON_TOP", null, "", true, null); alwaysOnTopMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { ImageFrame.this.setAlwaysOnTop(alwaysOnTopMI.isSelected()); } }); addPropertyChangeListener("alwaysOnTop", this); if (!isReadOnly) { ActionListener deleteImg = new ActionListener() { public void actionPerformed(ActionEvent ae) { deleteImage(); } }; ActionListener replaceImg = new ActionListener() { public void actionPerformed(ActionEvent ae) { replaceImage(); } }; ActionListener addImg = new ActionListener() { public void actionPerformed(ActionEvent ae) { addImages(); } }; title = "ImageFrame.Image"; mneu = "ImageFrame.ImageMneu"; imageMenu = UIHelper.createLocalizedMenu(menuBar, title, mneu); title = "WB_ADD_IMG"; mneu = "WB_ADD_IMG_MNEM"; addMI = UIHelper.createLocalizedMenuItem(imageMenu, title, mneu, "", true, addImg); title = "WB_REPLACE_IMG"; mneu = "WB_REPLACE_IMG_MNEU"; replaceMI = UIHelper.createLocalizedMenuItem(imageMenu, title, mneu, "", true, replaceImg); title = "WB_DEL_IMG_LINK"; mneu = "WB_DEL_IMG_LINK_MNEU"; deleteMI = UIHelper.createLocalizedMenuItem(imageMenu, title, mneu, "", true, deleteImg); loadImgBtn.addActionListener(addImg); } JMenu helpMenu = new JMenu(getResourceString("HELP")); menuBar.add(HelpMgr.createHelpMenuItem(helpMenu, getResourceString("WB_IMAGE_WINDOW"))); enableMenus(false); setJMenuBar(menuBar); pack(); HelpMgr.setHelpID(this, "WorkbenchWorkingWithImages"); }
From source file:boundary.ReportProduce.java
public void setTable() { DefaultTableModel model = new DefaultTableModel(); jTable1.setModel(model);//from w ww .j a v a 2 s . co m model.addColumn("No."); model.addColumn("Title"); model.addColumn("Status"); model.addColumn("Recording Session No."); model.addColumn("Recording Date"); for (Map.Entry<Integer, ArrayList<Object>> entry : ReportProduceControl .getRecordings(String.valueOf(jComboBox1.getSelectedItem())).entrySet()) { Integer key = entry.getKey(); ArrayList<Object> value = entry.getValue(); value.add(0, key); model.addRow(value.toArray()); } jTable1.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (jTable1.getSelectedRow() > -1) { setSoundmanTbl((String) jTable1.getValueAt(jTable1.getSelectedRow(), 3)); setMusicianTbl((String) jTable1.getValueAt(jTable1.getSelectedRow(), 3)); } } }); }
From source file:com.mirth.connect.client.ui.attachments.RegexAttachmentDialog.java
private void initComponents() { regularExpressionPanel = new JPanel(new MigLayout("novisualpadding, hidemode 3, fill, insets 0")); regularExpressionPanel.setBackground(UIConstants.BACKGROUND_COLOR); regularExpressionPanel.setBorder(BorderFactory.createTitledBorder("Regular Expressions")); regexExampleTextField = new JTextField(); regexExampleTextField.setText("(?:OBX\\|(?:[^|]*\\|){4}(?:[^|^]*\\^){4})([^|^\\r\\n]*)(?:[|^\\r\\n]|$)"); regexExampleTextField.setEditable(false); regexExampleTextField.setBorder(null); regexExampleTextField.setOpaque(false); regexTable = new MirthTable(); regexTable.setModel(new RefreshTableModel(new Object[] { "Regular Expression", "MIME Type" }, 0)); regexTable.setDragEnabled(false);// w ww . j a va 2s . c o m regexTable.setRowSelectionAllowed(true); regexTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); regexTable.setRowHeight(UIConstants.ROW_HEIGHT); regexTable.setFocusable(true); regexTable.setOpaque(true); regexTable.getTableHeader().setReorderingAllowed(false); regexTable.setEditable(true); regexTable.setSortable(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { regexTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } regexTable.getColumnExt(0).setMinWidth(105); regexTable.getColumnExt(0).setPreferredWidth(350); regexTable.getColumnExt(0).setToolTipText( "<html>The regular expression that will be used to match and extract attachments.<br>If capturing groups are used, only the last group will be extracted.</html>"); regexTable.getColumnExt(1).setMinWidth(63); regexTable.getColumnExt(1).setToolTipText( "The MIME type of the extracted attachment data. Source map variables may be used here."); regexTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { regexDeleteButton.setEnabled(regexTable.getSelectedRow() >= 0); } }); regexTableScrollPane = new JScrollPane(regexTable); regexNewButton = new JButton("New"); regexNewButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { regexNewButtonActionPerformed(); } }); regexDeleteButton = new JButton("Delete"); regexDeleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { regexDeleteButtonActionPerformed(); } }); regexDeleteButton.setEnabled(false); stringReplacementPanel = new JPanel(new MigLayout("novisualpadding, hidemode 3, insets 0")); stringReplacementPanel.setBackground(UIConstants.BACKGROUND_COLOR); stringReplacementPanel.setBorder(BorderFactory.createTitledBorder("String Replacement")); stringReplacementLabel = new JLabel(); stringReplacementLabel.setText( "<html>Replace strings on the matched data before storing. Do not use regular expressions in these fields or surround with quotes.<br>\nExample: Use <b>\\\\X0D0A\\\\</b> and <b>\\r\\n</b> to replace \\X0D0A\\ with actual CRLF characters. </html>"); inboundReplacementTable = new MirthTable(); inboundScrollPane = new JScrollPane(); inboundScrollPane.setViewportView(inboundReplacementTable); outboundReplacementTable = new MirthTable(); outboundScrollPane = new JScrollPane(); outboundScrollPane.setViewportView(outboundReplacementTable); inboundButtonPanel = new JPanel(new MigLayout("novisualpadding, hidemode 3, insets 0", "", "")); inboundButtonPanel.setBackground(UIConstants.BACKGROUND_COLOR); inboundNewButton = new JButton("New"); inboundNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { inboundNewButtonActionPerformed(evt); } }); inboundDeleteButton = new JButton("Delete"); inboundDeleteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { inboundDeleteButtonActionPerformed(evt); } }); outboundButtonPanel = new JPanel(new MigLayout("novisualpadding, hidemode 3, insets 0", "", "")); outboundButtonPanel.setBackground(UIConstants.BACKGROUND_COLOR); outboundNewButton = new JButton("New"); outboundNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { outboundNewButtonActionPerformed(evt); } }); outboundDeleteButton = new JButton("Delete"); outboundDeleteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { outboundDeleteButtonActionPerformed(evt); } }); separator = new JSeparator(); closeButton = new JButton("Close"); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { closeButtonActionPerformed(evt); } }); }
From source file:de.codesourcery.eve.skills.ui.components.impl.RefiningComponent.java
@Override protected JPanel createPanel() { refinedItemsTable.setRowSorter(refinedItemsModel.getRowSorter()); refinedItemsTable.setFillsViewportHeight(true); refinedItemsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override/*from w w w . j a v a 2 s .c o m*/ public void valueChanged(ListSelectionEvent e) { updateSelectedTotalValues(getSelectedRows(refinedItemsTable)); } }); final TableCellRenderer refinedItemsRenderer = new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); setHorizontalAlignment(JLabel.TRAILING); if (value instanceof ISKAmount) { setText(AmountHelper.formatISKAmount((ISKAmount) value) + " ISK"); } else { setText("0.0 ISK"); } return this; } }; FixedBooleanTableCellRenderer.attach(refinedItemsTable); refinedItemsTable.setDefaultRenderer(ISKAmount.class, refinedItemsRenderer); refiningResultsTable.setRowSorter(refiningResultsModel.getRowSorter()); refiningResultsTable.setFillsViewportHeight(true); final PopupMenuBuilder menuBuilder = new PopupMenuBuilder(); menuBuilder.addItem("Copy to clipboard (text)", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { putRefiningResultsOnClipboard(); } @Override public boolean isEnabled() { return refiningResultsModel.getRowCount() > 0; } }); menuBuilder.attach(refiningResultsTable); final PopupMenuBuilder menuBuilder2 = new PopupMenuBuilder(); menuBuilder2.addItem("Remove", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { final int[] viewRows = refinedItemsTable.getSelectedRows(); final int[] modelRows = new int[viewRows.length]; for (int i = 0; i < viewRows.length; i++) { modelRows[i] = refinedItemsTable.convertRowIndexToModel(viewRows[i]); } refinedItemsModel.removeRows(modelRows); } @Override public boolean isEnabled() { return !ArrayUtils.isEmpty(refinedItemsTable.getSelectedRows()); } }); menuBuilder2.attach(refinedItemsTable); refiningResultsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { updateSelectedTotalValues(getSelectedRows(refiningResultsTable)); } }); final DefaultTableCellRenderer resultsRenderer = new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (column != 0) { setHorizontalAlignment(JLabel.TRAILING); } else { setHorizontalAlignment(JLabel.LEADING); } if (value instanceof ISKAmount) { setText(AmountHelper.formatISKAmount((ISKAmount) value) + " ISK"); } else if (value == null) { setText("<price unavailable>"); } return this; } }; refiningResultsTable.setDefaultRenderer(String.class, resultsRenderer); refiningResultsTable.setDefaultRenderer(Integer.class, resultsRenderer); refiningResultsTable.setDefaultRenderer(ISKAmount.class, resultsRenderer); final ImprovedSplitPane splitPane = new ImprovedSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(refinedItemsTable), new JScrollPane(refiningResultsTable)); splitPane.setDividerLocation(0.3); /* * Button panel */ final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridBagLayout()); buttonPanel.add(addButton, constraints(0, 0).anchorWest().useRelativeWidth().noResizing().end()); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final ItemChooserComponent comp = new ItemChooserComponent( ItemChooserComponent.SelectionMode.MULTIPLE_SELECTION); comp.setModal(true); ComponentWrapper.wrapComponent("Add item to refine", comp).setVisible(true); if (!comp.wasCancelled() && !comp.getSelectedItems().isEmpty()) { final List<ItemWithQuantity> currentItems = refinedItemsModel.getItemsWithQuantity(); for (InventoryType t : comp.getSelectedItems()) { currentItems.add(new ItemWithQuantity(t, 1)); } refinedItemsModel.setItemsToRefine(currentItems); } } }); /* * Create result panel. */ final JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); panel.add(createSelectionPanel(), constraints(0, 0).weightX(0.8).useRelativeWidth().anchorSouth().weightY(0) .resizeHorizontally().end()); panel.add(selectedISKValue.getPanel(), constraints(1, 0).weightX(0.2).weightY(0).resizeHorizontally().anchorNorth().end()); panel.add(buttonPanel, constraints(0, 1).weightX(0.8).width(1).weightY(0).anchorWest().end()); panel.add(selectedVolume.getPanel(), constraints(1, 1).weightX(0.2).width(1).weightY(0).anchorWest().end()); panel.add(splitPane, constraints(0, 2).width(2).resizeBoth().end()); this.refiningResultsModel.update(); return panel; }
From source file:org.gumtree.vis.plot1d.Plot1DChartEditor.java
private JPanel createHelpPanel(JFreeChart chart) { JPanel wrap = new JPanel(new GridLayout(1, 1)); JPanel helpPanel = new JPanel(new GridLayout(1, 1)); helpPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // helpPanel.setBorder(BorderFactory.createTitledBorder( // BorderFactory.createEtchedBorder(), "Help Topics")); SpringLayout spring = new SpringLayout(); JPanel inner = new JPanel(spring); inner.setBorder(BorderFactory.createEmptyBorder()); final IHelpProvider provider = new Plot1DHelpProvider(); final JList list = new JList(provider.getHelpMap().keySet().toArray()); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // list.setBorder(BorderFactory.createEtchedBorder()); JScrollPane listPane1 = new JScrollPane(list); inner.add(listPane1);//from w ww .j a v a2 s .c o m listPane1.setMaximumSize(new Dimension(140, 0)); listPane1.setMinimumSize(new Dimension(70, 0)); // JPanel contentPanel = new JPanel(new GridLayout(2, 1)); // inner.add(list); final JTextField keyField = new JTextField(); keyField.setMaximumSize(new Dimension(400, 20)); keyField.setEditable(false); // keyField.setMaximumSize(); // keyArea.setLineWrap(true); // keyArea.setWrapStyleWord(true); // keyArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(keyField); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); final JTextArea helpArea = new JTextArea(); JScrollPane areaPane = new JScrollPane(helpArea); helpArea.setEditable(false); helpArea.setLineWrap(true); helpArea.setWrapStyleWord(true); // helpArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(areaPane); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); // inner.add(contentPanel); spring.putConstraint(SpringLayout.WEST, listPane1, 2, SpringLayout.WEST, inner); spring.putConstraint(SpringLayout.NORTH, listPane1, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.WEST, keyField, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, keyField, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.EAST, inner, 2, SpringLayout.EAST, keyField); spring.putConstraint(SpringLayout.WEST, areaPane, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, areaPane, 4, SpringLayout.SOUTH, keyField); spring.putConstraint(SpringLayout.EAST, areaPane, -2, SpringLayout.EAST, inner); spring.putConstraint(SpringLayout.SOUTH, inner, 2, SpringLayout.SOUTH, areaPane); spring.putConstraint(SpringLayout.SOUTH, listPane1, -2, SpringLayout.SOUTH, inner); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { Object[] selected = list.getSelectedValues(); if (selected.length >= 0) { HelpObject help = provider.getHelpMap().get(selected[0]); if (help != null) { keyField.setText(help.getKey()); helpArea.setText(help.getDiscription()); } } } }); helpPanel.add(inner, BorderLayout.NORTH); wrap.setName("Help"); wrap.add(helpPanel, BorderLayout.NORTH); return wrap; }