List of usage examples for com.jgoodies.binding.beans PropertyConnector connect
public static PropertyConnector connect(Object bean1, String property1Name, Object bean2, String property2Name)
From source file:net.sf.mpxj.explorer.HexDumpView.java
License:Open Source License
/** * Constructor.//from w w w . j a v a 2 s . c o m * * @param model HexDump model */ public HexDumpView(final HexDumpModel model) { NumberFormatter integerFormat = new NumberFormatter(NumberFormat.getIntegerInstance()); integerFormat.setValueClass(Integer.class); SpringLayout springLayout = new SpringLayout(); setLayout(springLayout); // // Controls panel // JPanel controlsPanel = new JPanel(); springLayout.putConstraint(SpringLayout.NORTH, controlsPanel, 0, SpringLayout.NORTH, this); springLayout.putConstraint(SpringLayout.WEST, controlsPanel, 0, SpringLayout.WEST, this); springLayout.putConstraint(SpringLayout.EAST, controlsPanel, 0, SpringLayout.EAST, this); FlowLayout flowLayout = (FlowLayout) controlsPanel.getLayout(); flowLayout.setAlignment(FlowLayout.LEFT); add(controlsPanel); JLabel columnsLabel = new JLabel("Columns"); controlsPanel.add(columnsLabel); JFormattedTextField columns = new JFormattedTextField(integerFormat); controlsPanel.add(columns); columns.setBorder(new LineBorder(new Color(171, 173, 179))); columns.setColumns(10); JLabel offsetLabel = new JLabel("Offset"); controlsPanel.add(offsetLabel); JFormattedTextField offset = new JFormattedTextField(integerFormat); controlsPanel.add(offset); offset.setBorder(new LineBorder(new Color(171, 173, 179))); offset.setColumns(10); // // Table panel // JTablePanel tablePanel = new JTablePanel(); JPanel infoPanel = new JPanel(); FlowLayout infoPanelLayout = new FlowLayout(FlowLayout.LEFT, 5, 5); infoPanel.setLayout(infoPanelLayout); infoPanel.setBorder(null); // // Selection data // JPanel infoPanelSelection = new JPanel(); infoPanel.add(infoPanelSelection); infoPanelSelection.setLayout(new BoxLayout(infoPanelSelection, BoxLayout.Y_AXIS)); JLabelledValue sizeValueLabel = new JLabelledValue("Size:"); infoPanelSelection.add(sizeValueLabel); JLabelledValue currentSelectionValueLabel = new JLabelledValue("Current Selection:"); infoPanelSelection.add(currentSelectionValueLabel); JLabelledValue previousSelectionValueLabel = new JLabelledValue("Previous Selection:"); infoPanelSelection.add(previousSelectionValueLabel); JLabelledValue differenceValueLabel = new JLabelledValue("Difference:"); infoPanelSelection.add(differenceValueLabel); // // Numeric data // JPanel infoPanelNumeric = new JPanel(); infoPanel.add(infoPanelNumeric); infoPanelNumeric.setLayout(new BoxLayout(infoPanelNumeric, BoxLayout.Y_AXIS)); JLabelledValue shortValueLabel = new JLabelledValue("Short:"); infoPanelNumeric.add(shortValueLabel); JLabelledValue longSixValueLabel = new JLabelledValue("Long6:"); infoPanelNumeric.add(longSixValueLabel); JLabelledValue longValueLabel = new JLabelledValue("Long:"); infoPanelNumeric.add(longValueLabel); JLabelledValue doubleValueLabel = new JLabelledValue("Double:"); infoPanelNumeric.add(doubleValueLabel); // // Duration data // JPanel infoPanelDuration = new JPanel(); infoPanel.add(infoPanelDuration); infoPanelDuration.setLayout(new BoxLayout(infoPanelDuration, BoxLayout.Y_AXIS)); JLabelledValue durationValueLabel = new JLabelledValue("Duration:"); infoPanelDuration.add(durationValueLabel); JLabelledValue timeUnitsValueLabel = new JLabelledValue("TmeUnit:"); infoPanelDuration.add(timeUnitsValueLabel); JLabelledValue workUnitsValueLabel = new JLabelledValue("Work Units:"); infoPanelDuration.add(workUnitsValueLabel); // // Date and time data // JPanel infoPanelDate = new JPanel(); infoPanel.add(infoPanelDate); infoPanelDate.setLayout(new BoxLayout(infoPanelDate, BoxLayout.Y_AXIS)); JLabelledValue dateValueLabel = new JLabelledValue("Date:"); infoPanelDate.add(dateValueLabel); JLabelledValue timeValueLabel = new JLabelledValue("Time:"); infoPanelDate.add(timeValueLabel); JLabelledValue timestampValueLabel = new JLabelledValue("Timestamp:"); infoPanelDate.add(timestampValueLabel); // // Misc // JPanel infoPanelMisc = new JPanel(); infoPanel.add(infoPanelMisc); infoPanelMisc.setLayout(new BoxLayout(infoPanelMisc, BoxLayout.Y_AXIS)); JLabelledValue guidValueLabel = new JLabelledValue("GUID:"); infoPanelMisc.add(guidValueLabel); JLabelledValue percentageValueLabel = new JLabelledValue("Percentage:"); infoPanelMisc.add(percentageValueLabel); // // Split pane // final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); springLayout.putConstraint(SpringLayout.NORTH, splitPane, 0, SpringLayout.SOUTH, controlsPanel); springLayout.putConstraint(SpringLayout.WEST, splitPane, 0, SpringLayout.WEST, this); springLayout.putConstraint(SpringLayout.SOUTH, splitPane, 0, SpringLayout.SOUTH, this); springLayout.putConstraint(SpringLayout.EAST, splitPane, 0, SpringLayout.EAST, this); add(splitPane); splitPane.setLeftComponent(tablePanel); splitPane.setRightComponent(infoPanel); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { splitPane.setDividerLocation(0.85); splitPane.setResizeWeight(0.85); } }); // // Bindings // BeanAdapter<HexDumpModel> modelAdapter = new BeanAdapter<HexDumpModel>(model, true); Bindings.bind(columns, modelAdapter.getValueModel("columns")); Bindings.bind(offset, modelAdapter.getValueModel("offset")); Bindings.bind(sizeValueLabel, "value", modelAdapter.getValueModel("sizeValueLabel")); Bindings.bind(currentSelectionValueLabel, "value", modelAdapter.getValueModel("currentSelectionValueLabel")); Bindings.bind(previousSelectionValueLabel, "value", modelAdapter.getValueModel("previousSelectionValueLabel")); Bindings.bind(differenceValueLabel, "value", modelAdapter.getValueModel("selectionDifferenceValueLabel")); Bindings.bind(shortValueLabel, "value", modelAdapter.getValueModel("shortValueLabel")); Bindings.bind(longSixValueLabel, "value", modelAdapter.getValueModel("longSixValueLabel")); Bindings.bind(longValueLabel, "value", modelAdapter.getValueModel("longValueLabel")); Bindings.bind(doubleValueLabel, "value", modelAdapter.getValueModel("doubleValueLabel")); Bindings.bind(durationValueLabel, "value", modelAdapter.getValueModel("durationValueLabel")); Bindings.bind(timeUnitsValueLabel, "value", modelAdapter.getValueModel("timeUnitsValueLabel")); Bindings.bind(guidValueLabel, "value", modelAdapter.getValueModel("guidValueLabel")); Bindings.bind(percentageValueLabel, "value", modelAdapter.getValueModel("percentageValueLabel")); Bindings.bind(dateValueLabel, "value", modelAdapter.getValueModel("dateValueLabel")); Bindings.bind(timeValueLabel, "value", modelAdapter.getValueModel("timeValueLabel")); Bindings.bind(timestampValueLabel, "value", modelAdapter.getValueModel("timestampValueLabel")); Bindings.bind(workUnitsValueLabel, "value", modelAdapter.getValueModel("workUnitsValueLabel")); PropertyConnector.connect(tablePanel, "leftTableModel", model, "hexTableModel"); PropertyConnector.connect(tablePanel, "rightTableModel", model, "asciiTableModel"); PropertyConnector.connect(tablePanel, "selectedCell", model, "selectedCell"); }
From source file:net.sf.mpxj.explorer.ObjectPropertiesView.java
License:Open Source License
/** * Constructor./*from w w w .j av a 2 s .c o m*/ * * @param model model used by this view */ public ObjectPropertiesView(ObjectPropertiesModel model) { SpringLayout springLayout = new SpringLayout(); setLayout(springLayout); JTable table = new JTable(); JScrollPane scrollPane = new JScrollPane(table); springLayout.putConstraint(SpringLayout.NORTH, scrollPane, 0, SpringLayout.NORTH, this); springLayout.putConstraint(SpringLayout.WEST, scrollPane, 0, SpringLayout.WEST, this); springLayout.putConstraint(SpringLayout.SOUTH, scrollPane, 0, SpringLayout.SOUTH, this); springLayout.putConstraint(SpringLayout.EAST, scrollPane, 0, SpringLayout.EAST, this); add(scrollPane); PropertyConnector.connect(table, "model", model, "tableModel"); }
From source file:org.photovault.swingui.PhotoInfoEditor.java
License:Open Source License
protected void createUI() { setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); tabPane = new JTabbedPane(); add(tabPane, BorderLayout.CENTER); // General pane JPanel generalPane = new JPanel(); tabPane.addTab("General", generalPane); // Create the fields & their labels // Photographer field JLabel photographerLabel = new JLabel("Photographer"); photographerField = createMvTextField("photographer", 30); photographerDoc = photographerField.getDocument(); // "Fuzzy time" field JLabel fuzzyDateLabel = new JLabel("Shooting date"); fuzzyDateField = new JTextField(30); fuzzyDateDoc = fuzzyDateField.getDocument(); fuzzyDateDoc.putProperty(FIELD, PhotoInfoFields.FUZZY_SHOOT_TIME); fuzzyDateDoc.addDocumentListener(this); JLabel qualityLabel = new JLabel("Quality"); qualityField = new JComboBox(qualityStrings); qualityField.addActionListener(this); StarRating qualityStars = new StarRating(5); FieldController<Integer> qfCtrl = ctrl.getFieldController("quality"); ValueModel qualityFieldValue = new PropertyAdapter(qfCtrl, "value", true); ValueModel starCount = new PropertyAdapter(qualityStars, "selection", true); PropertyConnector.connect(qualityFieldValue, "value", starCount, "value"); // Shooting place field JLabel shootingPlaceLabel = new JLabel("Shooting place"); shootingPlaceField = createMvTextField("shotLocation.description", 30); shootingPlaceDoc = shootingPlaceField.getDocument(); JLabel shotLocRoadLabel = new JLabel("Road"); JTextField shotLocRoadField = createMvTextField("shotLocation.road", 30); JLabel shotLocSuburbLabel = new JLabel("Suburb"); JTextField shotLocSuburbField = createMvTextField("shotLocation.suburb", 30); JLabel shotLocCityLabel = new JLabel("City"); JTextField shotLocCityField = createMvTextField("shotLocation.city", 30); JLabel shotLocCountryLabel = new JLabel("Country"); JTextField shotLocCountryField = createMvTextField("shotLocation.country", 30); JLabel shotLocGeohashLabel = new JLabel("Geohash code"); JTextField shotLocGeohashField = createMvTextField("shotLocation.geoHashString", 30); shotLocGeohashField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "fillAddress"); shotLocGeohashField.getActionMap().put("fillAddress", new FindAddressAction(ctrl)); // Tags/* w w w. ja v a 2 s . co m*/ JLabel tagLabel = new JLabel("Tags"); tagList = new TagList2(ctrl.getTagController()); tagList.setBackground(generalPane.getBackground()); // Description text JLabel descLabel = new JLabel("Description"); descriptionTextArea = new JTextArea(5, 40); descriptionTextArea.setLineWrap(true); descriptionTextArea.setWrapStyleWord(true); JScrollPane descScrollPane = new JScrollPane(descriptionTextArea); descScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); Border descBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); descBorder = BorderFactory.createTitledBorder(descBorder, "Description"); descScrollPane.setBorder(descBorder); descriptionDoc = descriptionTextArea.getDocument(); descriptionDoc.putProperty(FIELD, PhotoInfoFields.DESCRIPTION); descriptionDoc.addDocumentListener(this); // Lay out the created controls GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); generalPane.setLayout(layout); JLabel[] labels = { photographerLabel, fuzzyDateLabel, shootingPlaceLabel, shotLocGeohashLabel, shotLocRoadLabel, shotLocSuburbLabel, shotLocCityLabel, shotLocCountryLabel, qualityLabel, tagLabel }; JComponent[] fields = { photographerField, fuzzyDateField, shootingPlaceField, shotLocGeohashField, shotLocRoadField, shotLocSuburbField, shotLocCityField, shotLocCountryField, qualityStars, tagList }; addLabelTextRows(labels, fields, layout, generalPane); c = layout.getConstraints(tagList); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.0; c.weighty = 1.0; layout.setConstraints(tagList, c); generalPane.add(descScrollPane); c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; layout.setConstraints(descScrollPane, c); c = new GridBagConstraints(); c.gridwidth = 1; c.weighty = 0; c.fill = GridBagConstraints.NONE; c.gridy = GridBagConstraints.RELATIVE; c.gridy = GridBagConstraints.RELATIVE; createTechDataUI(); createFolderPaneUI(); createRightsUI(); }
From source file:org.photovault.swingui.PhotoInfoEditor.java
License:Open Source License
/** * Helper function to create a text field for editing a property and * connecting it to selection model.//w w w . jav a2 s . c o m * @param propName Property to be edited * @param length Length of the text field * @return The created text field */ private JTextField createMvTextField(String propName, int length) { JTextField fld = new JTextField(length); FieldController tfc = ctrl.getFieldController(propName); Bindings.bind(fld, new PropertyAdapter(tfc, "value", true), true); ValueModel mvValueModel = new PropertyAdapter(tfc, "multivalued", true); ValueModel fieldColorModel = new MultivalueColorConverter(mvValueModel); PropertyConnector.connect(fieldColorModel, "value", fld, "background"); return fld; }
From source file:org.photovault.swingui.PhotoInfoEditor.java
License:Open Source License
/** * Helper function to create a text area for editing a property and * connecting it to selection model./*from w w w . ja v a 2s . co m*/ * @param propName Property to be edited * @param rows Number of rows in the text area * @param cols Number of columns in the text area * @return The created text area */ private JTextArea createMvTextArea(String propName, int rows, int cols) { JTextArea fld = new JTextArea(rows, cols); FieldController tfc = ctrl.getFieldController(propName); Bindings.bind(fld, new PropertyAdapter(tfc, "value", true), true); ValueModel mvValueModel = new PropertyAdapter(tfc, "multivalued", true); ValueModel fieldColorModel = new MultivalueColorConverter(mvValueModel); PropertyConnector.connect(fieldColorModel, "value", fld, "background"); return fld; }