List of usage examples for javax.swing Box createHorizontalStrut
public static Component createHorizontalStrut(int width)
From source file:es.emergya.ui.gis.CustomMapView.java
@Override public void addLayer(Layer layer, boolean showOnButtonList, String icon) { if (layer instanceof MapViewerLayer) { minZoom = Math.max(((MapViewerLayer) layer).getMinZoomLevel(), getMinZoom()); maxZoom = Math.min(((MapViewerLayer) layer).getMaxZoomLevel(), getMaxZoom()); if (zoomFactor > maxZoom || zoomFactor < minZoom) { zoomFactor = (maxZoom + minZoom) / 2; }//from ww w. ja v a 2 s.c o m zoomTo(center, zoom2Scale(zoomFactor)); } if (showOnButtonList) { JToggleButton b = new JToggleButton(layer.name, LogicConstants.getIcon(icon), layer.visible); // b.setVerticalTextPosition(SwingConstants.BOTTOM); // b.setHorizontalTextPosition(SwingConstants.CENTER); b.setActionCommand(layer.name); b.addActionListener(layerControlListener); layerControls.add(b); layerControlPanel.removeAll(); layerControlPanel.add(Box.createHorizontalStrut(10)); for (JToggleButton bt : layerControls) { layerControlPanel.add(bt); layerControlPanel.add(Box.createHorizontalGlue()); } layerControlPanel.updateUI(); } super.addLayer(layer); }
From source file:com.intuit.tank.proxy.ProxyApp.java
private JToolBar createToolBar() { JToolBar ret = new JToolBar(); // ret.setBackground(new Color(111,167,209)); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(openAction));// w w w.java2 s. com ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(saveAction)); ret.addSeparator(); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(startAction)); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(stopAction)); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(pauseAction)); ret.add(Box.createHorizontalStrut(5)); ret.addSeparator(); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(filterAction)); ret.add(createButton(settingsAction)); ret.addSeparator(); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(showHostsAction)); ret.add(Box.createHorizontalGlue()); return ret; }
From source file:com.diversityarrays.kdxplore.trials.AddScoringSetDialog.java
public AddScoringSetDialog(Window owner, KdxploreDatabase kdxdb, Trial trial, Map<Trait, List<TraitInstance>> instancesByTrait, SampleGroup curatedSampleGroup) { super(owner, Msg.TITLE_ADD_SCORING_SET(), ModalityType.APPLICATION_MODAL); setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.kdxploreDatabase = kdxdb; this.trial = trial; this.curatedSampleGroupId = curatedSampleGroup == null ? 0 : curatedSampleGroup.getSampleGroupId(); Map<Trait, List<TraitInstance>> noCalcs = instancesByTrait.entrySet().stream() .filter(e -> TraitDataType.CALC != e.getKey().getTraitDataType()) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); Map<Trait, List<TraitInstance>> noCalcsSorted = new TreeMap<>(TRAIT_COMPARATOR); noCalcsSorted.putAll(noCalcs);// w ww. j a v a2 s . co m BiFunction<Trait, TraitInstance, String> parentNameProvider = new BiFunction<Trait, TraitInstance, String>() { @Override public String apply(Trait t, TraitInstance ti) { if (ti == null) { List<TraitInstance> list = noCalcsSorted.get(t); if (list == null || list.size() != 1) { OptionalInt opt = traitInstanceChoiceTreeModel.getChildChosenCountIfNotAllChosen(t); StringBuilder sb = new StringBuilder(t.getTraitName()); if (opt.isPresent()) { // only some of the children are chosen int childChosenCount = opt.getAsInt(); if (childChosenCount > 0) { sb.append(" (").append(childChosenCount).append(" of ").append(list.size()) .append(")"); } } else { // all of the children are chosen if (list != null) { sb.append(" (").append(list.size()).append(")"); } } return sb.toString(); } } return t.getTraitName(); } }; Optional<List<TraitInstance>> opt = noCalcsSorted.values().stream().filter(list -> list.size() > 1) .findFirst(); String heading1 = opt.isPresent() ? "Trait/Instance" : "Trait"; traitInstanceChoiceTreeModel = new ChoiceTreeTableModel<>(heading1, "Use?", //$NON-NLS-1$ noCalcsSorted, parentNameProvider, childNameProvider); // traitInstanceChoiceTreeModel = new TTChoiceTreeTableModel(instancesByTrait); traitInstanceChoiceTreeModel.addChoiceChangedListener(new ChoiceChangedListener() { @Override public void choiceChanged(Object source, ChoiceNode[] changedNodes) { updateCreateAction("choiceChanged"); treeTable.repaint(); } }); traitInstanceChoiceTreeModel.addTreeModelListener(new TreeModelListener() { @Override public void treeStructureChanged(TreeModelEvent e) { } @Override public void treeNodesRemoved(TreeModelEvent e) { } @Override public void treeNodesInserted(TreeModelEvent e) { } @Override public void treeNodesChanged(TreeModelEvent e) { updateCreateAction("treeNodesChanged"); } }); warningMsg.setText(PLEASE_PROVIDE_A_DESCRIPTION); warningMsg.setForeground(Color.RED); Container cp = getContentPane(); Box sampleButtons = null; if (curatedSampleGroup != null && curatedSampleGroup.getAnyScoredSamples()) { sampleButtons = createWantSampleButtons(curatedSampleGroup); } Box top = Box.createVerticalBox(); if (sampleButtons == null) { top.add(new JLabel(Msg.MSG_THERE_ARE_NO_CURATED_SAMPLES())); } else { top.add(sampleButtons); } top.add(descriptionField); cp.add(top, BorderLayout.NORTH); descriptionField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { updateCreateAction("documentListener"); } @Override public void insertUpdate(DocumentEvent e) { updateCreateAction("documentListener"); } @Override public void changedUpdate(DocumentEvent e) { updateCreateAction("documentListener"); } }); updateCreateAction("init"); // KDClientUtils.initAction(ImageId.`CHECK_ALL, useAllAction, "Click to Use All"); treeTable = new JXTreeTable(traitInstanceChoiceTreeModel); treeTable.setAutoResizeMode(JXTreeTable.AUTO_RESIZE_ALL_COLUMNS); TableCellRenderer renderer = treeTable.getDefaultRenderer(Integer.class); if (renderer instanceof JLabel) { ((JLabel) renderer).setHorizontalAlignment(JLabel.CENTER); } Box buttons = Box.createHorizontalBox(); buttons.add(new JButton(useAllAction)); buttons.add(new JButton(useNoneAction)); buttons.add(Box.createHorizontalGlue()); buttons.add(warningMsg); buttons.add(new JButton(cancelAction)); buttons.add(Box.createHorizontalStrut(10)); buttons.add(new JButton(createAction)); cp.add(new JScrollPane(treeTable), BorderLayout.CENTER); cp.add(buttons, BorderLayout.SOUTH); pack(); }
From source file:com.diversityarrays.kdxplore.importdata.ImportSourceChoiceDialog.java
public ImportSourceChoiceDialog(SourceChoice sc, Window owner, KdxploreDatabase kdxdb, MessagePrinter mp, Closure<List<Trial>> onTrialsLoaded, BackgroundRunner backgroundRunner) throws IOException, KdxploreConfigException { super(owner, "Load Trial Data", ModalityType.APPLICATION_MODAL); this.sourceChoice = sc; this.kdxDatabase = kdxdb; this.databaseDeviceIdentifier = kdxDatabase.getDatabaseDeviceIdentifier(); this.database = kdxDatabase.getKDXploreKSmartDatabase(); this.backgroundRunner = backgroundRunner; this.messagePrinter = new CompoundMessagePrinter(mp, messagePanel); this.onTrialsLoaded = onTrialsLoaded; DevicesAndOperators devsAndOps = new DevicesAndOperators(System.getProperty("user.name")); //$NON-NLS-1$ devAndOpPanel = new DeviceAndOperatorPanel(kdxdb, devsAndOps, true); devAndOpPanel.addChangeListener(devAndOpChangeListener); // Note: devAndOpPanel.initialise() is done in WindowListener.windowOpened() below StringBuilder sb = new StringBuilder("Drag/Drop "); ImportType[] tmp = null;//from www.j av a 2 s . c o m switch (sourceChoice) { case CSV: predicate = new Predicate<DeviceIdentifier>() { @Override public boolean evaluate(DeviceIdentifier devid) { return devid != null && DeviceIdentifier.PLEASE_SELECT_DEVICE_TYPE != devid.getDeviceType(); } }; sb.append("CSV"); tmp = new ImportType[] { ImportType.CSV }; break; case KDX: predicate = new Predicate<DeviceIdentifier>() { @Override public boolean evaluate(DeviceIdentifier devid) { if (devid == null || DeviceIdentifier.PLEASE_SELECT_DEVICE_TYPE == devid.getDeviceType()) { return false; } return DeviceType.KDSMART.equals(devid.getDeviceType()); } }; sb.append(".KDX"); tmp = new ImportType[] { ImportType.KDX }; break; case XLS: devAndOpPanel.disableAddDevice(); predicate = new Predicate<DeviceIdentifier>() { @Override public boolean evaluate(DeviceIdentifier devid) { if (devid == null || DeviceIdentifier.PLEASE_SELECT_DEVICE_TYPE == devid.getDeviceType()) { return false; } return DeviceType.DATABASE.equals(devid.getDeviceType()); } }; sb.append("Excel"); tmp = new ImportType[] { ImportType.KDXPLORE_EXCEL, ImportType.BMS_EXCEL }; break; case DATABASE: default: throw new IllegalStateException("sourceChoice=" + sourceChoice.name()); } importTypes = tmp; if (importTypes == null) { throw new IllegalArgumentException(sourceChoice.name()); } sb.append(" files here"); String prompt = sb.toString(); setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); Container cp = getContentPane(); PromptScrollPane pscrollPane = new PromptScrollPane(fileImportTable, prompt); pscrollPane.setTransferHandler(flth); fileImportTable.setTransferHandler(flth); fileImportTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // fileImportTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); fileImportTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { updateImportAction(); } } }); final JSplitPane vSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pscrollPane, messagePanel); updateImportAction(); Box buttons = Box.createHorizontalBox(); buttons.add(Box.createHorizontalStrut(4)); buttons.add(new JButton(importAction)); buttons.add(Box.createHorizontalGlue()); buttons.add(errorMessage); buttons.add(Box.createHorizontalGlue()); buttons.add(new JButton(browseAction)); buttons.add(Box.createHorizontalStrut(4)); errorMessage.setForeground(Color.RED); JPanel top = new JPanel(); GBH gbh = new GBH(top, 2, 2, 2, 2); int y = 0; gbh.add(0, y, 1, 1, GBH.BOTH, 1, 1, GBH.CENTER, devAndOpPanel); ++y; if (RunMode.getRunMode().isDeveloper()) { // Only Developer gets to see the Excel options panel (for now). gbh.add(0, y, 3, 1, GBH.BOTH, 2, 2, GBH.CENTER, bmsOptionsPanel); ++y; } gbh.add(0, y, 3, 1, GBH.HORZ, 1, 1, GBH.CENTER, buttons); ++y; cp.add(top, BorderLayout.NORTH); cp.add(vSplit, BorderLayout.CENTER); pack(); GuiUtil.centreOnOwner(ImportSourceChoiceDialog.this); addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { vSplit.setDividerLocation(0.5); // NO_BMS bmsOptionsPanel.setVisible(false /* SourceChoice.XLS == sourceChoice */); List<Pair<String, Exception>> errors = devAndOpPanel.initialise(predicate); if (errors.isEmpty()) { List<String> kdxFileNamesWithoutSuffix = new ArrayList<>(); for (int rowIndex = fileImportTableModel.getRowCount(); --rowIndex >= 0;) { File file = fileImportTableModel.getFileAt(rowIndex); String fname = file.getName(); int dotpos = fname.lastIndexOf('.'); if (dotpos > 0) { String sfx = fname.substring(dotpos); if (ExportFor.KDX_SUFFIX.equalsIgnoreCase(sfx)) { kdxFileNamesWithoutSuffix.add(fname.substring(0, dotpos)); } } } if (!kdxFileNamesWithoutSuffix.isEmpty()) { devAndOpPanel.selectInitialDeviceIdentifier(kdxFileNamesWithoutSuffix); } } else { for (Pair<String, Exception> pair : errors) { messagePrinter.println(pair.first + ":"); messagePrinter.println(pair.second.getMessage()); } } } @Override public void windowClosing(WindowEvent e) { if (busy) { GuiUtil.beep(); } else { dispose(); } } }); }
From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPUrlConfigGui.java
protected JPanel getProtocolAndMethodPanel() { // Implementation if (showImplementation) { httpImplementation = new JLabeledChoice(UPMPConstant.upmp_implementation, // $NON-NLS-1$ UPMPSamplerFactory.getImplementations()); httpImplementation.addValue(""); }//from www . j av a 2s .co m // PROTOCOL protocol = new JTextField(4); JLabel protocolLabel = new JLabel(JMeterUtils.getResString("protocol")); // $NON-NLS-1$ protocolLabel.setLabelFor(protocol); // CONTENT_ENCODING contentEncoding = new JTextField(10); JLabel contentEncodingLabel = new JLabel(JMeterUtils.getResString("content_encoding")); // $NON-NLS-1$ contentEncodingLabel.setLabelFor(contentEncoding); if (notConfigOnly) { method = new JLabeledChoice(JMeterUtils.getResString("method"), // $NON-NLS-1$ UPMPSamplerBase.getValidMethodsAsArray()); } JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); if (showImplementation) { panel.add(httpImplementation); } panel.add(protocolLabel); panel.add(protocol); panel.add(Box.createHorizontalStrut(5)); if (notConfigOnly) { panel.add(method); } panel.setMinimumSize(panel.getPreferredSize()); panel.add(Box.createHorizontalStrut(5)); panel.add(contentEncodingLabel); panel.add(contentEncoding); panel.setMinimumSize(panel.getPreferredSize()); return panel; }
From source file:Converter.java
ConversionPanel(Converter myController, String myTitle, Unit[] myUnits, ConverterRangeModel myModel) { if (MULTICOLORED) { setOpaque(true);//from ww w .j av a 2s . com setBackground(new Color(0, 255, 255)); } setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(myTitle), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Save arguments in instance variables. controller = myController; units = myUnits; title = myTitle; sliderModel = myModel; // Create the text field format, and then the text field. numberFormat = NumberFormat.getNumberInstance(); numberFormat.setMaximumFractionDigits(2); NumberFormatter formatter = new NumberFormatter(numberFormat); formatter.setAllowsInvalid(false); formatter.setCommitsOnValidEdit(true);// seems to be a no-op -- // aha -- it changes the value property but doesn't cause the result to // be parsed (that happens on focus loss/return, I think). // textField = new JFormattedTextField(formatter); textField.setColumns(10); textField.setValue(new Double(sliderModel.getDoubleValue())); textField.addPropertyChangeListener(this); // Add the combo box. unitChooser = new JComboBox(); for (int i = 0; i < units.length; i++) { // Populate it. unitChooser.addItem(units[i].description); } unitChooser.setSelectedIndex(0); sliderModel.setMultiplier(units[0].multiplier); unitChooser.addActionListener(this); // Add the slider. slider = new JSlider(sliderModel); sliderModel.addChangeListener(this); // Make the text field/slider group a fixed size // to make stacked ConversionPanels nicely aligned. JPanel unitGroup = new JPanel() { public Dimension getMinimumSize() { return getPreferredSize(); } public Dimension getPreferredSize() { return new Dimension(150, super.getPreferredSize().height); } public Dimension getMaximumSize() { return getPreferredSize(); } }; unitGroup.setLayout(new BoxLayout(unitGroup, BoxLayout.PAGE_AXIS)); if (MULTICOLORED) { unitGroup.setOpaque(true); unitGroup.setBackground(new Color(0, 0, 255)); } unitGroup.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); unitGroup.add(textField); unitGroup.add(slider); // Create a subpanel so the combo box isn't too tall // and is sufficiently wide. JPanel chooserPanel = new JPanel(); chooserPanel.setLayout(new BoxLayout(chooserPanel, BoxLayout.PAGE_AXIS)); if (MULTICOLORED) { chooserPanel.setOpaque(true); chooserPanel.setBackground(new Color(255, 0, 255)); } chooserPanel.add(unitChooser); chooserPanel.add(Box.createHorizontalStrut(100)); // Put everything together. setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); add(unitGroup); add(chooserPanel); unitGroup.setAlignmentY(TOP_ALIGNMENT); chooserPanel.setAlignmentY(TOP_ALIGNMENT); }
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 .j av a 2 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:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_multicastDemand.java
private static void createMulticastDemandGUI(final NetworkElementType networkElementType, final IVisualizationCallback callback) { final NetPlan netPlan = callback.getDesign(); JTextField textFieldIngressNodeId = new JTextField(20); JTextField textFieldEgressNodeIds = new JTextField(20); JPanel pane = new JPanel(); pane.add(new JLabel("Ingress node id: ")); pane.add(textFieldIngressNodeId);//from w ww.j a va 2 s . co m pane.add(Box.createHorizontalStrut(15)); pane.add(new JLabel("Egress node ids (space separated): ")); pane.add(textFieldEgressNodeIds); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please enter multicast demand ingress node and set of egress nodes", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { if (textFieldIngressNodeId.getText().isEmpty()) throw new Exception("Please, insert the ingress node id"); if (textFieldEgressNodeIds.getText().isEmpty()) throw new Exception("Please, insert the set of egress node ids"); String ingressNodeId_st = textFieldIngressNodeId.getText(); String egressNodeId_st = textFieldEgressNodeIds.getText(); final long ingressNode = Long.parseLong(ingressNodeId_st); if (netPlan.getNodeFromId(ingressNode) == null) throw new Exception("Not a valid ingress node id: " + ingressNodeId_st); Set<Node> egressNodes = new HashSet<Node>(); for (String egressNodeIdString : StringUtils.split(egressNodeId_st)) { final long nodeId = Long.parseLong(egressNodeIdString); final Node node = netPlan.getNodeFromId(nodeId); if (node == null) throw new Exception("Not a valid egress node id: " + egressNodeIdString); egressNodes.add(node); } netPlan.addMulticastDemand(netPlan.getNodeFromId(ingressNode), egressNodes, 0, null); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges( Collections.singleton(NetworkElementType.MULTICAST_DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.addErrorOrException(ex, AdvancedJTable_multicastDemand.class); ErrorHandling.showErrorDialog("Error adding the multicast demand"); } } }
From source file:io.heming.accountbook.ui.MainFrame.java
private void initToolBar() { toolbar = new JToolBar("ToolBar", JToolBar.HORIZONTAL); // Add Button addButton = new JButton(); addButton.setActionCommand(""); addButton.setToolTipText(""); addButton.setIcon(new ImageIcon(getClass().getResource("edit-add-3.png"))); // Search date range radio buttons ButtonGroup group = new ButtonGroup(); yearToggleButton = new JToggleButton(); yearToggleButton.setToolTipText(""); yearToggleButton.setIcon(new ImageIcon(getClass().getResource("year-s.png"))); group.add(yearToggleButton);/*from ww w . j a v a 2 s .com*/ monthToggleButton = new JToggleButton(); monthToggleButton.setToolTipText(""); monthToggleButton.setIcon(new ImageIcon(getClass().getResource("month-s.png"))); group.add(monthToggleButton); dayToggleButton = new JToggleButton(); dayToggleButton.setToolTipText(""); dayToggleButton.setIcon(new ImageIcon(getClass().getResource("day-s.png"))); group.add(dayToggleButton); customToggleButton = new JToggleButton(); customToggleButton.setToolTipText(""); customToggleButton.setIcon(new ImageIcon(getClass().getResource("all-s.png"))); group.add(customToggleButton); // ??Checkbox monthToggleButton.setSelected(true); Calendar earliestCalendar = Calendar.getInstance(); earliestCalendar.add(Calendar.YEAR, -100); java.util.Date earliestDate = earliestCalendar.getTime(); Calendar latestCalendar = Calendar.getInstance(); latestCalendar.add(Calendar.YEAR, 100); java.util.Date latestDate = latestCalendar.getTime(); // 3? Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.MONTH, -1); calendar.add(Calendar.DAY_OF_MONTH, 1); java.util.Date initDate = calendar.getTime(); SpinnerDateModel startDateModel = new SpinnerDateModel(DateUtil.getStartOfWeek(), earliestDate, latestDate, Calendar.MONTH); startDateSpinner = new JSpinner(startDateModel); JSpinner.DateEditor startDateEditor = new JSpinner.DateEditor(startDateSpinner, "yyyy-MM-dd"); startDateSpinner.setEditor(startDateEditor); calendar.add(Calendar.MONTH, 1); calendar.add(Calendar.DAY_OF_MONTH, -1); initDate = calendar.getTime(); SpinnerDateModel endDateModel = new SpinnerDateModel(initDate, earliestDate, latestDate, Calendar.MONTH); endDateSpinner = new JSpinner(endDateModel); JSpinner.DateEditor endDateEditor = new JSpinner.DateEditor(endDateSpinner, "yyyy-MM-dd"); endDateSpinner.setEditor(endDateEditor); // Keyword text field keywordTextField = new JTextField(); keywordTextField.setPreferredSize(new Dimension(250, 20)); keywordTextField.setMaximumSize(keywordTextField.getPreferredSize()); // Search Button searchButton = new JButton(); searchButton.setActionCommand("?"); searchButton.setToolTipText("?"); searchButton.setIcon(new ImageIcon(getClass().getResource("edit-find-5.png"))); // Layout cards = new JPanel(); cards.setLayout(new CardLayout()); Box box = Box.createHorizontalBox(); box.add(Box.createHorizontalGlue()); startDateSpinner.setPreferredSize(new Dimension(90, 20)); startDateSpinner.setMaximumSize(startDateSpinner.getPreferredSize()); box.add(startDateSpinner); box.add(Box.createHorizontalStrut(6)); endDateSpinner.setPreferredSize(new Dimension(90, 20)); endDateSpinner.setMaximumSize(endDateSpinner.getPreferredSize()); box.add(endDateSpinner); cards.add(new JPanel(), HIDE_DATE_CHOOSER); cards.add(box, SHOW_DATE_CHOOSER); Box dateRangeBox = Box.createHorizontalBox(); dateRangeBox.add(Box.createHorizontalGlue()); dateRangeBox.add(cards); toolbar.add(addButton); toolbar.add(dateRangeBox); toolbar.add(customToggleButton); toolbar.add(yearToggleButton); toolbar.add(monthToggleButton); toolbar.add(dayToggleButton); toolbar.add(keywordTextField); toolbar.add(searchButton); add(toolbar, BorderLayout.NORTH); // Event listener addButton.addActionListener(e -> showAddRecordDialog()); ActionListener listener = e -> searchRecords(); yearToggleButton.addActionListener(listener); monthToggleButton.addActionListener(listener); dayToggleButton.addActionListener(listener); customToggleButton.addActionListener(listener); keywordTextField.addActionListener(listener); searchButton.addActionListener(listener); customToggleButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { chooseDateRange(); } } }); }
From source file:com.diversityarrays.kdxplore.trials.TrialViewPanel.java
public TrialViewPanel(WindowOpener<JFrame> windowOpener, OfflineData od, Transformer<Trial, Boolean> checkIfEditorActive, Consumer<Trial> onTraitInstancesRemoved, MessagePrinter mp) {//w w w.ja v a 2 s .c o m super(new BorderLayout()); this.windowOpener = windowOpener; this.checkIfEditorActive = checkIfEditorActive; this.onTraitInstancesRemoved = onTraitInstancesRemoved; this.messagePrinter = mp; this.offlineData = od; this.offlineData.addOfflineDataChangeListener(offlineDataChangeListener); KdxploreDatabase db = offlineData.getKdxploreDatabase(); if (db != null) { db.addEntityChangeListener(trialChangeListener); } trialDataTable.setTransferHandler(TableTransferHandler.initialiseForCopySelectAll(trialDataTable, true)); trialPropertiesTable .setTransferHandler(TableTransferHandler.initialiseForCopySelectAll(trialPropertiesTable, true)); // Note: Can't use renderers because the TM always returns String.class // for getColumnClass() // trialPropertiesTable.setDefaultRenderer(TrialLayout.class, new // TrialLayoutRenderer(trialPropertiesTableModel)); // trialPropertiesTable.setDefaultRenderer(PlotIdentOption.class, new // PlotIdentOptionRenderer(trialPropertiesTableModel)); trialPropertiesTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { if (trialPropertiesTableModel.getRowCount() > 0) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { GuiUtil.initialiseTableColumnWidths(trialPropertiesTable); } }); trialPropertiesTableModel.removeTableModelListener(this); } } }); // int tnsColumnIndex = -1; // for (int col = trialPropertiesTableModel.getColumnCount(); --col >= 0; ) { // if (TraitNameStyle.class == trialPropertiesTableModel.getColumnClass(col)) { // tnsColumnIndex = col; // break; // } // } editAction.setEnabled(false); trialPropertiesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int vrow = trialPropertiesTable.getSelectedRow(); editAction.setEnabled(vrow >= 0 && trialPropertiesTableModel.isCellEditable(vrow, 1)); } } }); errorMessage.setForeground(Color.RED); Box top = Box.createHorizontalBox(); top.add(errorMessage); top.add(Box.createHorizontalGlue()); top.add(new JButton(editAction)); JPanel main = new JPanel(new BorderLayout()); main.add(new JScrollPane(trialPropertiesTable), BorderLayout.CENTER); main.add(legendPanel, BorderLayout.SOUTH); JScrollPane trialDataTableScrollPane = new JScrollPane(trialDataTable); // The preferred height of the viewport is determined // by whether or not we need to use hh:mm:ss in the name of any of // the scoring data sets. JViewport viewPort = new JViewport() { @Override public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.height = 32; TableModel model = trialDataTable.getModel(); if (model instanceof TrialData) { if (((TrialData) model).isUsingHMSformat()) { d.height = 48; } } return d; } }; trialDataTableScrollPane.setColumnHeader(viewPort); JTableHeader th = trialDataTable.getTableHeader(); th.setDefaultRenderer(trialDataTableHeaderRenderer); th.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int column = th.columnAtPoint(e.getPoint()); trialDataTableHeaderRenderer.columnSelected = column; boolean shifted = 0 != (MouseEvent.SHIFT_MASK & e.getModifiers()); boolean right = SwingUtilities.isRightMouseButton(e); updateDeleteSamplesAction(shifted, right); e.consume(); } }); trialDataTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { removeTraitInstancesAction.setEnabled(trialDataTable.getSelectedRowCount() > 0); } } }); removeTraitInstancesAction.setEnabled(false); KDClientUtils.initAction(ImageId.PLUS_BLUE_24, addSampleGroupAction, Msg.TOOLTIP_ADD_SAMPLES_FOR_SCORING()); KDClientUtils.initAction(ImageId.TRASH_24, deleteSamplesAction, Msg.TOOLTIP_DELETE_COLLECTED_SAMPLES()); KDClientUtils.initAction(ImageId.EXPORT_24, exportSamplesAction, Msg.TOOLTIP_EXPORT_SAMPLES_OR_TRAITS()); KDClientUtils.initAction(ImageId.MINUS_GOLD_24, removeTraitInstancesAction, Msg.TOOLTIP_REMOVE_TRAIT_INSTANCES_WITH_NO_DATA()); JPanel trialDataPanel = new JPanel(new BorderLayout()); Box buttons = Box.createHorizontalBox(); buttons.add(new JButton(removeTraitInstancesAction)); buttons.add(Box.createHorizontalGlue()); buttons.add(new JButton(exportSamplesAction)); buttons.add(Box.createHorizontalGlue()); buttons.add(new JButton(addSampleGroupAction)); buttons.add(Box.createHorizontalStrut(8)); buttons.add(new JButton(deleteSamplesAction)); trialDataPanel.add(GuiUtil.createLabelSeparator("Measurements by Source", buttons), BorderLayout.NORTH); trialDataPanel.add(trialDataTableScrollPane, BorderLayout.CENTER); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, main, trialDataPanel); splitPane.setResizeWeight(0.5); add(top, BorderLayout.NORTH); add(splitPane, BorderLayout.CENTER); trialDataTable.setDefaultRenderer(Object.class, new TrialDataCellRenderer()); trialDataTable.addPropertyChangeListener("model", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { trialDataTableHeaderRenderer.columnSelected = -1; updateDeleteSamplesAction(false, false); } }); }