List of usage examples for java.awt FlowLayout RIGHT
int RIGHT
To view the source code for java.awt FlowLayout RIGHT.
Click Source Link
From source file:edu.snu.leader.discrete.simulator.SimulatorLauncherGUI.java
/** * Create the frame.//from w ww . ja va 2 s .c o m */ public SimulatorLauncherGUI() { NumberFormat countFormat = NumberFormat.getNumberInstance(); countFormat.setParseIntegerOnly(true); NumberFormat doubleFormat = NumberFormat.getNumberInstance(); doubleFormat.setMinimumIntegerDigits(1); doubleFormat.setMaximumFractionDigits(10); setTitle("Simulator"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 515, 340); setResizable(false); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); tabbedPane = new JTabbedPane(JTabbedPane.TOP); contentPane.add(tabbedPane, BorderLayout.CENTER); JPanel panelTab1 = new JPanel(); tabbedPane.addTab("Simulator", null, panelTab1, null); JPanel panelAgentCount = new JPanel(); panelTab1.add(panelAgentCount); JLabel lblNewLabel = new JLabel("Agent Count"); panelAgentCount.add(lblNewLabel); sliderAgent = new JSlider(); panelAgentCount.add(sliderAgent); sliderAgent.setValue(10); sliderAgent.setSnapToTicks(true); sliderAgent.setPaintTicks(true); sliderAgent.setPaintLabels(true); sliderAgent.setMinorTickSpacing(10); sliderAgent.setMajorTickSpacing(10); sliderAgent.setMinimum(10); sliderAgent.setMaximum(70); sliderAgent.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { Integer spinnerValue = (Integer) spinnerMaxEaten.getValue(); if (spinnerValue > sliderAgent.getValue()) { spinnerValue = sliderAgent.getValue(); } spinnerMaxEaten.setModel(new SpinnerNumberModel(spinnerValue, new Integer(0), new Integer(sliderAgent.getValue()), new Integer(1))); JFormattedTextField tfMaxEaten = ((JSpinner.DefaultEditor) spinnerMaxEaten.getEditor()) .getTextField(); tfMaxEaten.setEditable(false); } }); JPanel panelCommType = new JPanel(); panelTab1.add(panelCommType); JLabel lblNewLabel_1 = new JLabel("Communication Type"); panelCommType.add(lblNewLabel_1); comboBoxCommType = new JComboBox<String>(); panelCommType.add(comboBoxCommType); comboBoxCommType .setModel(new DefaultComboBoxModel<String>(new String[] { "Global", "Topological", "Metric" })); comboBoxCommType.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { String item = (String) comboBoxCommType.getSelectedItem(); if (item.equals("Topological")) { panelNearestNeighborCount.setVisible(true); panelMaxLocationRadius.setVisible(false); } else if (item.equals("Metric")) { panelNearestNeighborCount.setVisible(false); panelMaxLocationRadius.setVisible(true); } else if (item.equals("Global")) { panelNearestNeighborCount.setVisible(false); panelMaxLocationRadius.setVisible(false); } } }); JPanel panelDestinationRadius = new JPanel(); panelTab1.add(panelDestinationRadius); JLabel lblDestinationRadius = new JLabel("Destination Radius"); panelDestinationRadius.add(lblDestinationRadius); frmtdtxtfldDestinationRadius = new JFormattedTextField(doubleFormat); frmtdtxtfldDestinationRadius.setColumns(4); frmtdtxtfldDestinationRadius.setValue((Number) 10); panelDestinationRadius.add(frmtdtxtfldDestinationRadius); JPanel panelResultsOutput = new JPanel(); panelTab1.add(panelResultsOutput); JLabel lblResultsOutput = new JLabel("Results Output"); panelResultsOutput.add(lblResultsOutput); final JCheckBox chckbxEskridge = new JCheckBox("Eskridge"); panelResultsOutput.add(chckbxEskridge); final JCheckBox chckbxConflict = new JCheckBox("Conflict"); panelResultsOutput.add(chckbxConflict); final JCheckBox chckbxPosition = new JCheckBox("Position"); panelResultsOutput.add(chckbxPosition); final JCheckBox chckbxPredationResults = new JCheckBox("Predation"); panelResultsOutput.add(chckbxPredationResults); JPanel panelMisc = new JPanel(); panelTab1.add(panelMisc); JLabel lblNewLabel_3 = new JLabel("Misc"); panelMisc.add(lblNewLabel_3); chckbxGraphical = new JCheckBox("Graphical?"); chckbxGraphical.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (chckbxGraphical.isSelected()) { frmtdtxtfldRunCount.setValue((Number) 1); frmtdtxtfldRunCount.setEnabled(false); chckbxEskridge.setSelected(false); chckbxEskridge.setEnabled(false); String agentBuilder = (String) comboBoxAgentBuilder.getSelectedItem(); if (agentBuilder.equals("Default")) { comboBoxAgentBuilder.setSelectedIndex(1); } } else { chckbxEskridge.setEnabled(true); frmtdtxtfldRunCount.setEnabled(true); } } }); panelMisc.add(chckbxGraphical); chckbxRandomSeed = new JCheckBox("Random Seed?"); panelMisc.add(chckbxRandomSeed); chckbxPredationEnable = new JCheckBox("Predation?"); chckbxPredationEnable.setSelected(true); chckbxPredationEnable.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (chckbxPredationEnable.isSelected()) { panelPredationStuff.setVisible(true); panelPredationBoxes.setVisible(true); panelPredationConstant.setVisible(true); panelNonMoversSurvive.setVisible(true); } else { panelPredationStuff.setVisible(false); panelPredationBoxes.setVisible(false); panelPredationConstant.setVisible(false); panelNonMoversSurvive.setVisible(false); } } }); panelMisc.add(chckbxPredationEnable); JPanel panelCounts = new JPanel(); panelTab1.add(panelCounts); JLabel lblNewLabel_4 = new JLabel("Run Count"); panelCounts.add(lblNewLabel_4); frmtdtxtfldRunCount = new JFormattedTextField(countFormat); frmtdtxtfldRunCount.setToolTipText("The number of runs. Each run has a different random seed."); panelCounts.add(frmtdtxtfldRunCount); frmtdtxtfldRunCount.setColumns(4); frmtdtxtfldRunCount.setValue((Number) 1); JLabel lblNewLabel_5 = new JLabel("Sim Count"); panelCounts.add(lblNewLabel_5); frmtdtxtfldSimCount = new JFormattedTextField(countFormat); frmtdtxtfldSimCount .setToolTipText("The number of simulations per run. Each simulation uses the same random seed."); frmtdtxtfldSimCount.setColumns(4); frmtdtxtfldSimCount.setValue((Number) 1); panelCounts.add(frmtdtxtfldSimCount); JLabel lblNewLabel_6 = new JLabel("Max Time Steps"); panelCounts.add(lblNewLabel_6); frmtdtxtfldMaxTimeSteps = new JFormattedTextField(countFormat); frmtdtxtfldMaxTimeSteps.setToolTipText("The max number of time steps per simulation."); frmtdtxtfldMaxTimeSteps.setColumns(6); frmtdtxtfldMaxTimeSteps.setValue((Number) 20000); panelCounts.add(frmtdtxtfldMaxTimeSteps); ////////Panel tab 2 JPanel panelTab2 = new JPanel(); tabbedPane.addTab("Parameters", null, panelTab2, null); JPanel panelDecisionCalculator = new JPanel(); panelTab2.add(panelDecisionCalculator); JLabel lblDecisionCalculator = new JLabel("Decision Calculator"); panelDecisionCalculator.add(lblDecisionCalculator); final JComboBox<String> comboBoxDecisionCalculator = new JComboBox<String>(); panelDecisionCalculator.add(comboBoxDecisionCalculator); comboBoxDecisionCalculator.setModel( new DefaultComboBoxModel<String>(new String[] { "Default", "Conflict", "Conflict Uninformed" })); JPanel panelAgentBuilder = new JPanel(); panelTab2.add(panelAgentBuilder); JLabel lblAgentBuilder = new JLabel("Agent Builder"); panelAgentBuilder.add(lblAgentBuilder); comboBoxAgentBuilder = new JComboBox<String>(); panelAgentBuilder.add(comboBoxAgentBuilder); comboBoxAgentBuilder.setModel(new DefaultComboBoxModel<String>(new String[] { "Default", "Simple Angular", "Personality Simple Angular", "Simple Angular Uninformed" })); comboBoxAgentBuilder.setSelectedIndex(1); comboBoxAgentBuilder.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (chckbxGraphical.isSelected()) { String agentBuilder = (String) comboBoxAgentBuilder.getSelectedItem(); if (agentBuilder.equals("Default")) { comboBoxAgentBuilder.setSelectedIndex(1); } } } }); JPanel panelModel = new JPanel(); panelTab2.add(panelModel); JLabel lblModel = new JLabel("Model"); panelModel.add(lblModel); comboBoxModel = new JComboBox<String>(); panelModel.add(comboBoxModel); comboBoxModel.setModel(new DefaultComboBoxModel<String>(new String[] { "Sueur", "Gautrais" })); comboBoxModel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { String item = (String) comboBoxModel.getSelectedItem(); if (item.equals("Sueur")) { panelSueurValues.setVisible(true); panelGautraisValues.setVisible(false); } else if (item.equals("Gautrais")) { panelSueurValues.setVisible(false); panelGautraisValues.setVisible(true); } } }); JPanel panelEnvironment = new JPanel(); panelTab2.add(panelEnvironment); JLabel lblEnvironment = new JLabel("Environment"); panelEnvironment.add(lblEnvironment); comboBoxEnvironment = new JComboBox<String>(); comboBoxEnvironment.setModel( new DefaultComboBoxModel<String>(new String[] { "Minimum", "Medium", "Maximum", "Uninformed" })); comboBoxEnvironment.setSelectedIndex(1); comboBoxEnvironment.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { String item = (String) comboBoxEnvironment.getSelectedItem(); if (!item.equals("Uninformed")) { comboBoxDecisionCalculator.setEnabled(true); comboBoxAgentBuilder.setEnabled(true); } if (item.equals("Medium")) { panelAngle.setVisible(true); panelDistance.setVisible(true); panelPercentage.setVisible(true); panelNumberOfDestinations.setVisible(false); panelInformedCount.setVisible(false); } else if (item.equals("Minimum")) { panelAngle.setVisible(false); panelDistance.setVisible(false); panelPercentage.setVisible(true); panelNumberOfDestinations.setVisible(false); panelInformedCount.setVisible(false); } else if (item.equals("Maximum")) { panelAngle.setVisible(false); panelDistance.setVisible(false); panelPercentage.setVisible(true); panelNumberOfDestinations.setVisible(false); panelInformedCount.setVisible(false); } else if (item.equals("Uninformed")) { panelAngle.setVisible(true); panelDistance.setVisible(true); panelPercentage.setVisible(true); panelNumberOfDestinations.setVisible(false); panelInformedCount.setVisible(true); comboBoxDecisionCalculator.setSelectedIndex(2); comboBoxDecisionCalculator.setEnabled(false); comboBoxAgentBuilder.setSelectedIndex(3); comboBoxAgentBuilder.setEnabled(false); } } }); panelEnvironment.add(comboBoxEnvironment); JPanel panelDefaultConflict = new JPanel(); panelTab2.add(panelDefaultConflict); JLabel lblDefaultConflict = new JLabel("Default Conflict"); panelDefaultConflict.add(lblDefaultConflict); final JSpinner spinnerDefaultConflict = new JSpinner(); panelDefaultConflict.add(spinnerDefaultConflict); spinnerDefaultConflict.setModel( new SpinnerNumberModel(new Float(0.9f), new Float(0.1f), new Float(0.91f), new Float(0.05))); JFormattedTextField tfSpinnerConflict = ((JSpinner.DefaultEditor) spinnerDefaultConflict.getEditor()) .getTextField(); tfSpinnerConflict.setEditable(false); JPanel panelCancelationThreshold = new JPanel(); panelTab2.add(panelCancelationThreshold); JLabel lblCancelationThreshold = new JLabel("Cancelation Threshold"); panelCancelationThreshold.add(lblCancelationThreshold); final JSpinner spinnerCancelationThreshold = new JSpinner(); panelCancelationThreshold.add(spinnerCancelationThreshold); spinnerCancelationThreshold.setModel( new SpinnerNumberModel(new Float(1.0f), new Float(0.0f), new Float(1.01f), new Float(0.05))); JFormattedTextField tfCancelationThreshold = ((JSpinner.DefaultEditor) spinnerCancelationThreshold .getEditor()).getTextField(); tfCancelationThreshold.setEditable(false); JPanel panelStopAnywhere = new JPanel(); panelTab2.add(panelStopAnywhere); final JCheckBox chckbxStopAnywhere = new JCheckBox("Stop Anywhere?"); panelStopAnywhere.add(chckbxStopAnywhere); panelNearestNeighborCount = new JPanel(); panelNearestNeighborCount.setVisible(false); panelTab2.add(panelNearestNeighborCount); JLabel lblNearestNeighborCount = new JLabel("Nearest Neighbor Count"); panelNearestNeighborCount.add(lblNearestNeighborCount); frmtdtxtfldNearestNeighborCount = new JFormattedTextField(countFormat); panelNearestNeighborCount.add(frmtdtxtfldNearestNeighborCount); frmtdtxtfldNearestNeighborCount.setColumns(3); frmtdtxtfldNearestNeighborCount.setValue((Number) 10); panelMaxLocationRadius = new JPanel(); panelMaxLocationRadius.setVisible(false); panelTab2.add(panelMaxLocationRadius); JLabel lblMaxLocationRadius = new JLabel("Max Location Radius"); panelMaxLocationRadius.add(lblMaxLocationRadius); frmtdtxtfldMaxLocationRadius = new JFormattedTextField(doubleFormat); panelMaxLocationRadius.add(frmtdtxtfldMaxLocationRadius); frmtdtxtfldMaxLocationRadius.setColumns(5); frmtdtxtfldMaxLocationRadius.setValue((Number) 10.0); panelPredationBoxes = new JPanel(); panelTab2.add(panelPredationBoxes); final JCheckBox chckbxUsePredationThreshold = new JCheckBox("Use Predation Threshold"); panelPredationBoxes.add(chckbxUsePredationThreshold); final JCheckBox chckbxPopulationIndependent = new JCheckBox("Population Independent"); chckbxPopulationIndependent.setSelected(true); panelPredationBoxes.add(chckbxPopulationIndependent); chckbxPopulationIndependent.setToolTipText( "Select this to allow predation to be independent of population size. Max predation for 10 agents will be the same as for 50 agents. "); panelPredationStuff = new JPanel(); panelTab2.add(panelPredationStuff); JLabel lblPredationMinimum = new JLabel("Predation Minimum"); panelPredationStuff.add(lblPredationMinimum); frmtdtxtfldPredationMinimum = new JFormattedTextField(doubleFormat); frmtdtxtfldPredationMinimum.setColumns(4); frmtdtxtfldPredationMinimum.setValue((Number) 0.0); panelPredationStuff.add(frmtdtxtfldPredationMinimum); JLabel lblPredationThreshold = new JLabel("Predation Threshold"); panelPredationStuff.add(lblPredationThreshold); final JSpinner spinnerPredationThreshold = new JSpinner(); panelPredationStuff.add(spinnerPredationThreshold); spinnerPredationThreshold.setModel( new SpinnerNumberModel(new Float(1.0f), new Float(0.0f), new Float(1.01f), new Float(0.05))); JFormattedTextField tfPredationThreshold = ((JSpinner.DefaultEditor) spinnerPredationThreshold.getEditor()) .getTextField(); tfPredationThreshold.setEditable(false); JLabel lblMaxEaten = new JLabel("Max Eaten"); panelPredationStuff.add(lblMaxEaten); spinnerMaxEaten = new JSpinner(); spinnerMaxEaten.setToolTipText("The max number eaten per time step."); panelPredationStuff.add(spinnerMaxEaten); spinnerMaxEaten.setModel(new SpinnerNumberModel(new Integer(10), new Integer(0), new Integer(sliderAgent.getValue()), new Integer(1))); JFormattedTextField tfMaxEaten = ((JSpinner.DefaultEditor) spinnerMaxEaten.getEditor()).getTextField(); tfMaxEaten.setEditable(false); panelPredationConstant = new JPanel(); panelTab2.add(panelPredationConstant); JLabel lblPredationConstant = new JLabel("Predation Constant"); panelPredationConstant.add(lblPredationConstant); frmtdtxtfldPredationConstant = new JFormattedTextField(doubleFormat); panelPredationConstant.add(frmtdtxtfldPredationConstant); frmtdtxtfldPredationConstant.setToolTipText("Value should be positive. Recommended values are near 0.001"); frmtdtxtfldPredationConstant.setColumns(4); frmtdtxtfldPredationConstant.setValue((Number) 0.001); panelNonMoversSurvive = new JPanel(); panelTab2.add(panelNonMoversSurvive); final JCheckBox chckbxNonMoversSurvive = new JCheckBox("Non-movers Survive?"); chckbxNonMoversSurvive.setSelected(false); panelNonMoversSurvive.add(chckbxNonMoversSurvive); ////////Tab 3 JPanel panelTab3 = new JPanel(); tabbedPane.addTab("Environment", null, panelTab3, null); panelTab3.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); panelSueurValues = new JPanel(); panelTab3.add(panelSueurValues); panelSueurValues.setLayout(new BoxLayout(panelSueurValues, BoxLayout.Y_AXIS)); JLabel lblSueurValues = new JLabel("Sueur Values"); lblSueurValues.setHorizontalAlignment(SwingConstants.TRAILING); lblSueurValues.setAlignmentX(Component.CENTER_ALIGNMENT); panelSueurValues.add(lblSueurValues); JPanel panelAlpha = new JPanel(); FlowLayout flowLayout = (FlowLayout) panelAlpha.getLayout(); flowLayout.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelAlpha); JLabel lblAlpha = new JLabel("alpha"); lblAlpha.setHorizontalAlignment(SwingConstants.CENTER); panelAlpha.add(lblAlpha); final JFormattedTextField frmtdtxtfldAlpha = new JFormattedTextField(doubleFormat); frmtdtxtfldAlpha.setHorizontalAlignment(SwingConstants.TRAILING); lblAlpha.setLabelFor(frmtdtxtfldAlpha); panelAlpha.add(frmtdtxtfldAlpha); frmtdtxtfldAlpha.setColumns(6); frmtdtxtfldAlpha.setValue((Number) 0.006161429); JPanel panelAlphaC = new JPanel(); FlowLayout flowLayout_2 = (FlowLayout) panelAlphaC.getLayout(); flowLayout_2.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelAlphaC); JLabel lblAlphaC = new JLabel("alpha c"); panelAlphaC.add(lblAlphaC); final JFormattedTextField frmtdtxtfldAlphaC = new JFormattedTextField(doubleFormat); frmtdtxtfldAlphaC.setHorizontalAlignment(SwingConstants.TRAILING); lblAlphaC.setLabelFor(frmtdtxtfldAlphaC); panelAlphaC.add(frmtdtxtfldAlphaC); frmtdtxtfldAlphaC.setColumns(6); frmtdtxtfldAlphaC.setValue((Number) 0.009); JPanel panelBeta = new JPanel(); FlowLayout flowLayout_1 = (FlowLayout) panelBeta.getLayout(); flowLayout_1.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelBeta); JLabel lblBeta = new JLabel("beta"); panelBeta.add(lblBeta); final JFormattedTextField frmtdtxtfldBeta = new JFormattedTextField(doubleFormat); frmtdtxtfldBeta.setHorizontalAlignment(SwingConstants.TRAILING); panelBeta.add(frmtdtxtfldBeta); frmtdtxtfldBeta.setColumns(6); frmtdtxtfldBeta.setValue((Number) 0.013422819); JPanel panelBetaC = new JPanel(); FlowLayout flowLayout_14 = (FlowLayout) panelBetaC.getLayout(); flowLayout_14.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelBetaC); JLabel lblBetaC = new JLabel("beta c"); panelBetaC.add(lblBetaC); final JFormattedTextField frmtdtxtfldBetaC = new JFormattedTextField(doubleFormat); frmtdtxtfldBetaC.setHorizontalAlignment(SwingConstants.TRAILING); panelBetaC.add(frmtdtxtfldBetaC); frmtdtxtfldBetaC.setColumns(6); frmtdtxtfldBetaC.setValue((Number) (-0.009)); JPanel panelS = new JPanel(); FlowLayout flowLayout_3 = (FlowLayout) panelS.getLayout(); flowLayout_3.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelS); JLabel lblS = new JLabel("S"); panelS.add(lblS); final JFormattedTextField frmtdtxtfldS = new JFormattedTextField(countFormat); frmtdtxtfldS.setHorizontalAlignment(SwingConstants.TRAILING); panelS.add(frmtdtxtfldS); frmtdtxtfldS.setColumns(6); frmtdtxtfldS.setValue((Number) 2); JPanel panelQ = new JPanel(); FlowLayout flowLayout_4 = (FlowLayout) panelQ.getLayout(); flowLayout_4.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelQ); JLabel lblQ = new JLabel("q"); panelQ.add(lblQ); final JFormattedTextField frmtdtxtfldQ = new JFormattedTextField(doubleFormat); frmtdtxtfldQ.setHorizontalAlignment(SwingConstants.TRAILING); panelQ.add(frmtdtxtfldQ); frmtdtxtfldQ.setColumns(6); frmtdtxtfldQ.setValue((Number) 2.3); panelGautraisValues = new JPanel(); panelGautraisValues.setVisible(false); panelTab3.add(panelGautraisValues); panelGautraisValues.setLayout(new BoxLayout(panelGautraisValues, BoxLayout.Y_AXIS)); JLabel label = new JLabel("Gautrais Values"); label.setAlignmentX(Component.CENTER_ALIGNMENT); panelGautraisValues.add(label); JPanel panelTauO = new JPanel(); FlowLayout flowLayout_5 = (FlowLayout) panelTauO.getLayout(); flowLayout_5.setAlignment(FlowLayout.RIGHT); panelGautraisValues.add(panelTauO); JLabel lblTauO = new JLabel("tau o"); panelTauO.add(lblTauO); final JFormattedTextField frmtdtxtfldTaoO = new JFormattedTextField(doubleFormat); frmtdtxtfldTaoO.setHorizontalAlignment(SwingConstants.TRAILING); panelTauO.add(frmtdtxtfldTaoO); frmtdtxtfldTaoO.setColumns(4); frmtdtxtfldTaoO.setValue((Number) 1290); JPanel panelGammaC = new JPanel(); FlowLayout flowLayout_6 = (FlowLayout) panelGammaC.getLayout(); flowLayout_6.setAlignment(FlowLayout.RIGHT); panelGautraisValues.add(panelGammaC); JLabel lblGammaC = new JLabel("gamma c"); panelGammaC.add(lblGammaC); final JFormattedTextField frmtdtxtfldGammaC = new JFormattedTextField(doubleFormat); frmtdtxtfldGammaC.setHorizontalAlignment(SwingConstants.TRAILING); panelGammaC.add(frmtdtxtfldGammaC); frmtdtxtfldGammaC.setColumns(4); frmtdtxtfldGammaC.setValue((Number) 2.0); JPanel panelEpsilonC = new JPanel(); FlowLayout flowLayout_7 = (FlowLayout) panelEpsilonC.getLayout(); flowLayout_7.setAlignment(FlowLayout.RIGHT); panelGautraisValues.add(panelEpsilonC); JLabel lblEpsilonC = new JLabel("epsilon c"); panelEpsilonC.add(lblEpsilonC); final JFormattedTextField frmtdtxtfldEpsilonC = new JFormattedTextField(doubleFormat); frmtdtxtfldEpsilonC.setHorizontalAlignment(SwingConstants.TRAILING); panelEpsilonC.add(frmtdtxtfldEpsilonC); frmtdtxtfldEpsilonC.setColumns(4); frmtdtxtfldEpsilonC.setValue((Number) 2.3); JPanel panelAlphaF = new JPanel(); FlowLayout flowLayout_8 = (FlowLayout) panelAlphaF.getLayout(); flowLayout_8.setAlignment(FlowLayout.RIGHT); panelGautraisValues.add(panelAlphaF); JLabel lblAlphaF = new JLabel("alpha f"); panelAlphaF.add(lblAlphaF); final JFormattedTextField frmtdtxtfldAlphaF = new JFormattedTextField(doubleFormat); frmtdtxtfldAlphaF.setHorizontalAlignment(SwingConstants.TRAILING); panelAlphaF.add(frmtdtxtfldAlphaF); frmtdtxtfldAlphaF.setColumns(4); frmtdtxtfldAlphaF.setValue((Number) 162.3); JPanel panelBetaF = new JPanel(); FlowLayout flowLayout_9 = (FlowLayout) panelBetaF.getLayout(); flowLayout_9.setAlignment(FlowLayout.RIGHT); panelGautraisValues.add(panelBetaF); JLabel lblBetaF = new JLabel("beta f"); panelBetaF.add(lblBetaF); final JFormattedTextField frmtdtxtfldBetaF = new JFormattedTextField(doubleFormat); frmtdtxtfldBetaF.setHorizontalAlignment(SwingConstants.TRAILING); panelBetaF.add(frmtdtxtfldBetaF); frmtdtxtfldBetaF.setColumns(4); frmtdtxtfldBetaF.setValue((Number) 75.4); JPanel panelEnvironmentVariables = new JPanel(); panelTab3.add(panelEnvironmentVariables); panelEnvironmentVariables.setLayout(new BoxLayout(panelEnvironmentVariables, BoxLayout.Y_AXIS)); JLabel lblEnvironmentVariables = new JLabel("Environment Variables"); lblEnvironmentVariables.setAlignmentX(Component.CENTER_ALIGNMENT); panelEnvironmentVariables.add(lblEnvironmentVariables); panelAngle = new JPanel(); FlowLayout flowLayout_10 = (FlowLayout) panelAngle.getLayout(); flowLayout_10.setAlignment(FlowLayout.RIGHT); panelEnvironmentVariables.add(panelAngle); JLabel lblAngle = new JLabel("Angle"); panelAngle.add(lblAngle); final JFormattedTextField frmtdtxtfldAngle = new JFormattedTextField(doubleFormat); frmtdtxtfldAngle.setHorizontalAlignment(SwingConstants.TRAILING); frmtdtxtfldAngle.setToolTipText("Angle between destinations"); panelAngle.add(frmtdtxtfldAngle); frmtdtxtfldAngle.setColumns(3); frmtdtxtfldAngle.setValue((Number) 72.00); panelNumberOfDestinations = new JPanel(); FlowLayout flowLayout_13 = (FlowLayout) panelNumberOfDestinations.getLayout(); flowLayout_13.setAlignment(FlowLayout.RIGHT); panelNumberOfDestinations.setVisible(false); panelEnvironmentVariables.add(panelNumberOfDestinations); JLabel lblNumberOfDestinations = new JLabel("Number of Destinations"); panelNumberOfDestinations.add(lblNumberOfDestinations); JFormattedTextField frmtdtxtfldNumberOfDestinations = new JFormattedTextField(countFormat); frmtdtxtfldNumberOfDestinations.setHorizontalAlignment(SwingConstants.TRAILING); panelNumberOfDestinations.add(frmtdtxtfldNumberOfDestinations); frmtdtxtfldNumberOfDestinations.setColumns(3); frmtdtxtfldNumberOfDestinations.setValue((Number) 2); panelDistance = new JPanel(); FlowLayout flowLayout_11 = (FlowLayout) panelDistance.getLayout(); flowLayout_11.setAlignment(FlowLayout.RIGHT); panelEnvironmentVariables.add(panelDistance); JLabel lblDistance = new JLabel("Distance"); panelDistance.add(lblDistance); frmtdtxtfldDistance = new JFormattedTextField(doubleFormat); frmtdtxtfldDistance.setHorizontalAlignment(SwingConstants.TRAILING); frmtdtxtfldDistance.setToolTipText("Distance the destination is from origin (0,0)"); panelDistance.add(frmtdtxtfldDistance); frmtdtxtfldDistance.setColumns(3); frmtdtxtfldDistance.setValue((Number) 150.0); panelPercentage = new JPanel(); FlowLayout flowLayout_12 = (FlowLayout) panelPercentage.getLayout(); flowLayout_12.setAlignment(FlowLayout.RIGHT); panelEnvironmentVariables.add(panelPercentage); JLabel lblPercentage = new JLabel("Percentage"); panelPercentage.add(lblPercentage); frmtdtxtfldPercentage = new JFormattedTextField(doubleFormat); frmtdtxtfldPercentage.setHorizontalAlignment(SwingConstants.TRAILING); frmtdtxtfldPercentage.setToolTipText( "The percentage moving to one of the two destinations ( The other gets 1 - percentage)."); panelPercentage.add(frmtdtxtfldPercentage); frmtdtxtfldPercentage.setColumns(3); frmtdtxtfldPercentage.setValue((Number) 0.500); panelInformedCount = new JPanel(); panelEnvironmentVariables.add(panelInformedCount); JLabel lblInformedCount = new JLabel("Informed Count"); panelInformedCount.add(lblInformedCount); final JFormattedTextField frmtdtxtfldInformedCount = new JFormattedTextField(countFormat); frmtdtxtfldInformedCount.setHorizontalAlignment(SwingConstants.TRAILING); frmtdtxtfldInformedCount.setColumns(3); frmtdtxtfldInformedCount.setToolTipText( "The number of agents moving toward a preferred destination. This number is duplicated on the southern pole as well."); frmtdtxtfldInformedCount.setValue((Number) 4); panelInformedCount.setVisible(false); panelInformedCount.add(frmtdtxtfldInformedCount); JPanel panelStartButtons = new JPanel(); JButton btnStartSimulation = new JButton("Create Simulator Instance"); btnStartSimulation.setToolTipText("Creates a new simulator instance from the settings provided."); btnStartSimulation.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean isReady = true; ErrorPacketContainer errorPacketContainer = new ErrorPacketContainer(); if (jframeErrorMessages != null && jframeErrorMessages.isVisible()) { jframeErrorMessages.dispose(); } frmtdtxtfldRunCount.setBackground(Color.WHITE); frmtdtxtfldSimCount.setBackground(Color.WHITE); frmtdtxtfldMaxTimeSteps.setBackground(Color.WHITE); frmtdtxtfldPredationMinimum.setBackground(Color.WHITE); frmtdtxtfldPredationConstant.setBackground(Color.WHITE); frmtdtxtfldNearestNeighborCount.setBackground(Color.WHITE); frmtdtxtfldMaxLocationRadius.setBackground(Color.WHITE); frmtdtxtfldPercentage.setBackground(Color.WHITE); frmtdtxtfldDistance.setBackground(Color.WHITE); frmtdtxtfldDestinationRadius.setBackground(Color.WHITE); frmtdtxtfldAngle.setBackground(Color.WHITE); frmtdtxtfldInformedCount.setBackground(Color.WHITE); StringBuilder errorMessages = new StringBuilder(); if (((Number) frmtdtxtfldRunCount.getValue()).intValue() <= 0) { errorMessages.append("Run Count must be positive\n"); frmtdtxtfldRunCount.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Run Count must be positive", frmtdtxtfldRunCount, 0); isReady = false; } if (((Number) frmtdtxtfldSimCount.getValue()).intValue() <= 0) { errorMessages.append("Sim Count must be positive\n"); frmtdtxtfldSimCount.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Sim Count must be positive", frmtdtxtfldSimCount, 0); isReady = false; } if (((Number) frmtdtxtfldMaxTimeSteps.getValue()).intValue() <= 0) { errorMessages.append("Max Time Steps must be positive\n"); frmtdtxtfldMaxTimeSteps.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Max Time Steps must be positive", frmtdtxtfldMaxTimeSteps, 0); isReady = false; } if (((Number) frmtdtxtfldPredationMinimum.getValue()).doubleValue() < 0 && chckbxPredationEnable.isSelected()) { errorMessages.append("Predation Minimum must be positive\n"); frmtdtxtfldPredationMinimum.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Predation Minimum must be positive", frmtdtxtfldPredationMinimum, 1); isReady = false; } if (((Number) frmtdtxtfldPredationConstant.getValue()).doubleValue() <= 0 && chckbxPredationEnable.isSelected()) { errorMessages.append("Predation Constant must be positive\n"); frmtdtxtfldPredationConstant.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Predation Constant must be positive", frmtdtxtfldPredationConstant, 1); isReady = false; } if (((Number) frmtdtxtfldNearestNeighborCount.getValue()).intValue() < 0 && panelNearestNeighborCount.isVisible()) { errorMessages.append("Nearest Neighbor Count must be positive\n"); frmtdtxtfldNearestNeighborCount.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Nearest Neighbor Count must be positive", frmtdtxtfldNearestNeighborCount, 1); isReady = false; } if (((Number) frmtdtxtfldMaxLocationRadius.getValue()).doubleValue() < 0 && panelMaxLocationRadius.isVisible()) { errorMessages.append("Max Location Radius must be positive\n"); frmtdtxtfldMaxLocationRadius.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Max Location Radius must be positive", frmtdtxtfldMaxLocationRadius, 1); isReady = false; } if ((((Number) frmtdtxtfldPercentage.getValue()).doubleValue() < 0.0 || ((Number) frmtdtxtfldPercentage.getValue()).doubleValue() > 1.0) && panelPercentage.isVisible()) { errorMessages.append( "Percentage needs to be greater than or equal to 0 and less than or equal to 1\n"); frmtdtxtfldPercentage.setBackground(Color.YELLOW); errorPacketContainer.addPacket( "Percentage needs to be greater than or equal to 0 and less than or equal to 1", frmtdtxtfldPercentage, 2); isReady = false; } if (((Number) frmtdtxtfldDistance.getValue()).doubleValue() <= 0 && frmtdtxtfldDistance.isVisible()) { errorMessages.append("Distance must be positive\n"); frmtdtxtfldDistance.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Distance must be positive", frmtdtxtfldDistance, 2); isReady = false; } if (((Number) frmtdtxtfldDestinationRadius.getValue()).doubleValue() <= 0) { errorMessages.append("Destination Radius must be positive\n"); frmtdtxtfldDestinationRadius.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Destination Radius must be positive", frmtdtxtfldDestinationRadius, 0); isReady = false; } if (((Number) frmtdtxtfldAngle.getValue()).doubleValue() < 0) { errorMessages.append("Angle must be positive or zero\n"); frmtdtxtfldAngle.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Angle must be positive", frmtdtxtfldAngle, 2); isReady = false; } if (((Number) frmtdtxtfldInformedCount.getValue()).intValue() <= 0) { errorMessages.append("Informed Count must be positive\n"); frmtdtxtfldInformedCount.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Informed Count must be positive", frmtdtxtfldInformedCount, 2); isReady = false; } else if (((Number) frmtdtxtfldInformedCount.getValue()).intValue() * 2 > sliderAgent.getValue()) { errorMessages.append("Informed Count should at most be half the count of total agents\n"); frmtdtxtfldInformedCount.setBackground(Color.YELLOW); errorPacketContainer.addPacket( "Informed Count should at most be half the count of total agents", frmtdtxtfldInformedCount, 2); isReady = false; } if (!isReady) { jframeErrorMessages = createJFrameErrorMessages(errorPacketContainer, tabbedPane); jframeErrorMessages.setVisible(true); } else { _simulatorProperties = new Properties(); _simulatorProperties.put("run-count", String.valueOf(frmtdtxtfldRunCount.getValue())); _simulatorProperties.put("simulation-count", String.valueOf(frmtdtxtfldSimCount.getValue())); _simulatorProperties.put("max-simulation-time-steps", String.valueOf(frmtdtxtfldMaxTimeSteps.getValue())); _simulatorProperties.put("random-seed", String.valueOf(1)); // Doesn't change _simulatorProperties.put("individual-count", String.valueOf(sliderAgent.getValue())); _simulatorProperties.put("run-graphical", String.valueOf(chckbxGraphical.isSelected())); _simulatorProperties.put("pre-calculate-probabilities", String.valueOf(false)); // Doesn't change _simulatorProperties.put("use-random-random-seed", String.valueOf(chckbxRandomSeed.isSelected())); _simulatorProperties.put("can-multiple-initiate", String.valueOf(true)); // Doesn't change _simulatorProperties.put("eskridge-results", String.valueOf(chckbxEskridge.isSelected())); _simulatorProperties.put("conflict-results", String.valueOf(chckbxConflict.isSelected())); _simulatorProperties.put("position-results", String.valueOf(chckbxPosition.isSelected())); _simulatorProperties.put("predation-results", String.valueOf(chckbxPredationResults.isSelected())); _simulatorProperties.put("communication-type", String.valueOf(comboBoxCommType.getSelectedItem()).toLowerCase()); _simulatorProperties.put("nearest-neighbor-count", String.valueOf(frmtdtxtfldNearestNeighborCount.getValue())); _simulatorProperties.put("max-location-radius", String.valueOf(frmtdtxtfldMaxLocationRadius.getValue())); _simulatorProperties.put("destination-size-radius", String.valueOf(frmtdtxtfldDestinationRadius.getValue())); _simulatorProperties.put("max-agents-eaten-per-step", String.valueOf(spinnerMaxEaten.getValue())); _simulatorProperties.put("enable-predator", String.valueOf(chckbxPredationEnable.isSelected())); _simulatorProperties.put("predation-probability-minimum", String.valueOf(frmtdtxtfldPredationMinimum.getValue())); _simulatorProperties.put("predation-multiplier", String.valueOf(frmtdtxtfldPredationConstant.getValue())); _simulatorProperties.put("use-predation-threshold", String.valueOf(chckbxUsePredationThreshold.isSelected())); _simulatorProperties.put("predation-threshold", String.valueOf(spinnerPredationThreshold.getValue())); _simulatorProperties.put("predation-by-population", String.valueOf(chckbxPopulationIndependent.isSelected())); _simulatorProperties.put("count-non-movers-as-survivors", String.valueOf(chckbxNonMoversSurvive.isSelected())); _simulatorProperties.put("stop-at-any-destination", String.valueOf(chckbxStopAnywhere.isSelected())); _simulatorProperties.put("adhesion-time-limit", String.valueOf(frmtdtxtfldMaxTimeSteps.getValue())); _simulatorProperties.put("alpha", String.valueOf(frmtdtxtfldAlpha.getValue())); _simulatorProperties.put("alpha-c", String.valueOf(frmtdtxtfldAlphaC.getValue())); _simulatorProperties.put("beta", String.valueOf(frmtdtxtfldBeta.getValue())); _simulatorProperties.put("beta-c", String.valueOf(frmtdtxtfldBetaC.getValue())); _simulatorProperties.put("S", String.valueOf(frmtdtxtfldS.getValue())); _simulatorProperties.put("q", String.valueOf(frmtdtxtfldQ.getValue())); _simulatorProperties.put("lambda", String.valueOf(0.2)); _simulatorProperties.put("tau-o", String.valueOf(frmtdtxtfldTaoO.getValue())); _simulatorProperties.put("gamma-c", String.valueOf(frmtdtxtfldGammaC.getValue())); _simulatorProperties.put("epsilon-c", String.valueOf(frmtdtxtfldEpsilonC.getValue())); _simulatorProperties.put("alpha-f", String.valueOf(frmtdtxtfldAlphaF.getValue())); _simulatorProperties.put("beta-f", String.valueOf(frmtdtxtfldBetaF.getValue())); _simulatorProperties.put("default-conflict-value", String.valueOf(spinnerDefaultConflict.getValue())); _simulatorProperties.put("cancellation-threshold", String.valueOf(spinnerCancelationThreshold.getValue())); StringBuilder sbAgentBuilder = new StringBuilder(); sbAgentBuilder.append("edu.snu.leader.discrete.simulator.Sueur"); sbAgentBuilder.append(comboBoxAgentBuilder.getSelectedItem().toString().replace(" ", "")); sbAgentBuilder.append("AgentBuilder"); _simulatorProperties.put("agent-builder", String.valueOf(sbAgentBuilder.toString())); StringBuilder sbDecisionCalculator = new StringBuilder(); sbDecisionCalculator.append("edu.snu.leader.discrete.simulator."); sbDecisionCalculator.append(comboBoxModel.getSelectedItem()); // sbDecisionCalculator.append(comboBoxDecisionCalculator.getSelectedItem()); sbDecisionCalculator .append(comboBoxDecisionCalculator.getSelectedItem().toString().replace(" ", "")); sbDecisionCalculator.append("DecisionCalculator"); _simulatorProperties.put("decision-calculator", String.valueOf(sbDecisionCalculator.toString())); StringBuilder sbLocationsFile = new StringBuilder(); sbLocationsFile.append("cfg/sim/locations/metric/valid-metric-loc-"); sbLocationsFile.append(String.format("%03d", sliderAgent.getValue())); sbLocationsFile.append("-seed-00001.dat"); _simulatorProperties.put("locations-file", String.valueOf(sbLocationsFile.toString())); //create destination file DestinationBuilder db = new DestinationBuilder(sliderAgent.getValue(), 1L); StringBuilder sbDestinationsFile = new StringBuilder(); sbDestinationsFile.append("cfg/sim/destinations/destinations-"); switch (comboBoxEnvironment.getSelectedItem().toString()) { case ("Minimum"): sbDestinationsFile.append("diffdis-" + sliderAgent.getValue()); sbDestinationsFile.append("-per-" + frmtdtxtfldPercentage.getValue()); sbDestinationsFile.append("-seed-1.dat"); db.generateDifferentDistance(((Number) frmtdtxtfldPercentage.getValue()).doubleValue(), 200, 100, 75); break; case ("Medium"): sbDestinationsFile.append("split-" + sliderAgent.getValue()); sbDestinationsFile.append("-dis-" + frmtdtxtfldDistance.getValue()); sbDestinationsFile.append("-ang-" + String.format("%.2f", ((Number) frmtdtxtfldAngle.getValue()).doubleValue())); sbDestinationsFile.append("-per-" + String.format("%.3f", ((Number) frmtdtxtfldPercentage.getValue()).doubleValue())); sbDestinationsFile.append("-seed-1.dat"); db.generateSplitNorth(((Number) frmtdtxtfldDistance.getValue()).doubleValue(), ((Number) frmtdtxtfldAngle.getValue()).doubleValue(), ((Number) frmtdtxtfldPercentage.getValue()).doubleValue()); break; case ("Maximum"): sbDestinationsFile.append("poles-" + sliderAgent.getValue()); sbDestinationsFile.append("-per-" + frmtdtxtfldPercentage.getValue()); sbDestinationsFile.append("-seed-1.dat"); db.generatePoles(50, 100, ((Number) frmtdtxtfldPercentage.getValue()).doubleValue()); break; case ("Uninformed"): sbDestinationsFile.append("split-poles-" + frmtdtxtfldInformedCount.getValue()); sbDestinationsFile.append("-dis-" + String.format("%.1f", ((Number) frmtdtxtfldDistance.getValue()).doubleValue())); sbDestinationsFile.append("-ang-" + String.format("%.2f", ((Number) frmtdtxtfldAngle.getValue()).doubleValue())); sbDestinationsFile.append("-per-" + String.format("%.3f", ((Number) frmtdtxtfldPercentage.getValue()).doubleValue())); sbDestinationsFile.append("-seed-1.dat"); db.generateSplitPoles(((Number) frmtdtxtfldDistance.getValue()).doubleValue(), ((Number) frmtdtxtfldAngle.getValue()).doubleValue(), ((Number) frmtdtxtfldPercentage.getValue()).doubleValue(), ((Number) frmtdtxtfldInformedCount.getValue()).intValue()); break; default: //Should never happen break; } _simulatorProperties.put("destinations-file", String.valueOf(sbDestinationsFile.toString())); _simulatorProperties.put("live-delay", String.valueOf(15)); //Doesn't change _simulatorProperties.put("results-dir", "results"); //Doesn't change new Thread(new Runnable() { public void run() { try { runSimulation(); } catch (Exception e) { e.printStackTrace(); } } }).start(); } } }); panelStartButtons.add(btnStartSimulation); JButton btnStartSimulationFrom = new JButton("Run Simulation from Properties File"); btnStartSimulationFrom .setToolTipText("Runs the simulator with the values provided in the properties file."); btnStartSimulationFrom.setEnabled(false); panelStartButtons.add(btnStartSimulationFrom); panelTab3.add(panelStartButtons); }
From source file:org.pentaho.reporting.ui.datasources.olap4j.Olap4JDataSourceEditor.java
private JPanel createQueryListPanel() { // Create the query list panel final RemoveQueryAction queryRemoveAction = new RemoveQueryAction(); dialogModel.addPropertyChangeListener(queryRemoveAction); final JPanel theQueryButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 5)); theQueryButtonsPanel.add(new BorderlessButton(new AddQueryAction())); theQueryButtonsPanel.add(new BorderlessButton(queryRemoveAction)); final JPanel theQueryControlsPanel = new JPanel(new BorderLayout()); theQueryControlsPanel.add(new JLabel(Messages.getString("Olap4JDataSourceEditor.AvailableQueriesLabel")), BorderLayout.WEST);//from w ww . j a v a2s. c om theQueryControlsPanel.add(theQueryButtonsPanel, BorderLayout.EAST); final JPanel queryListPanel = new JPanel(new BorderLayout()); queryListPanel.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8)); queryListPanel.add(BorderLayout.NORTH, theQueryControlsPanel); queryListPanel.add(BorderLayout.CENTER, new JScrollPane(queryNameList)); return queryListPanel; }
From source file:org.pentaho.reporting.ui.datasources.kettle.KettleDataSourceDialog.java
private JPanel createQueryListPanel() { final RemoveQueryAction removeQueryAction = new RemoveQueryAction(); queryNameList.addListSelectionListener(removeQueryAction); final JPanel queryListButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); queryListButtonsPanel.add(new BorderlessButton(new AddQueryAction())); queryListButtonsPanel.add(new BorderlessButton(removeQueryAction)); final JPanel queryListPanel = new JPanel(new BorderLayout()); queryListPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 0)); queryListPanel.add(new JScrollPane(queryNameList), BorderLayout.CENTER); queryListPanel.add(queryListButtonsPanel, BorderLayout.NORTH); return queryListPanel; }
From source file:org.pentaho.reporting.ui.datasources.kettle.KettleDataSourceDialog.java
private JPanel createTransformParameterPanel() { final JPanel stopOnErrorsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 5)); stopOnErrorsPanel.add(stopOnErrorsCheckBox); final JPanel previewAndParameterPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 5)); previewAndParameterPanel.add(new JButton(editParameterAction)); previewAndParameterPanel.add(new JButton(previewAction)); final JPanel transParameterPanel = new JPanel(new BorderLayout()); transParameterPanel.add(stopOnErrorsPanel, BorderLayout.NORTH); transParameterPanel.add(previewAndParameterPanel, BorderLayout.CENTER); return transParameterPanel; }
From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.ImportDialog.java
/** * Builds and lays out the tool bar.//ww w . j a v a2 s . com * @return See above. */ private JPanel buildToolBarRight() { JPanel bar = new JPanel(new FlowLayout(FlowLayout.RIGHT)); bar.add(cancelImportButton); bar.add(Box.createHorizontalStrut(5)); bar.add(importButton); bar.add(Box.createHorizontalStrut(10)); return bar; }
From source file:org.pentaho.reporting.ui.datasources.pmd.PmdDataSourceEditor.java
private JPanel createGlobalPropertiesPanel() { final JPanel filePanel = new JPanel(); filePanel.setLayout(new BoxLayout(filePanel, BoxLayout.X_AXIS)); filePanel.add(filenameField);/*from w ww . j ava 2s . c o m*/ filePanel.add(new JButton(new BrowseAction())); final JPanel queryListButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); queryListButtonsPanel.add(queryAddButton); queryListButtonsPanel.add(queryRemoveButton); final JPanel queryListButtonsPanelWrapper = new JPanel(new BorderLayout()); queryListButtonsPanelWrapper.add(new JLabel(Messages.getString("PmdDataSourceEditor.AvailableQueries")), BorderLayout.WEST); queryListButtonsPanelWrapper.add(queryListButtonsPanel, BorderLayout.EAST); final JPanel dataSourceConfigurationPanel = new JPanel(); dataSourceConfigurationPanel.setLayout(new VerticalLayout(5, VerticalLayout.BOTH, VerticalLayout.TOP)); dataSourceConfigurationPanel.add(new JLabel(Messages.getString("PmdDataSourceEditor.XmiFileLabel"))); dataSourceConfigurationPanel.add(filePanel); dataSourceConfigurationPanel.add(new JLabel(Messages.getString("PmdDataSourceEditor.DomainId"))); dataSourceConfigurationPanel.add(domainIdTextField); dataSourceConfigurationPanel.add(queryListButtonsPanelWrapper); dataSourceConfigurationPanel.add(new JScrollPane(queryNameList)); dataSourceConfigurationPanel.add(new JLabel(Messages.getString("PmdDataSourceEditor.QueryName"))); dataSourceConfigurationPanel.add(queryNameTextField); return dataSourceConfigurationPanel; }
From source file:net.sf.taverna.t2.activities.spreadsheet.views.SpreadsheetImportConfigView.java
@Override protected void initialise() { super.initialise(); newConfiguration = getJson().deepCopy(); // title/* w w w. j av a 2 s. c om*/ titlePanel = new JPanel(new BorderLayout()); titlePanel.setBackground(Color.WHITE); addDivider(titlePanel, SwingConstants.BOTTOM, true); titleLabel = new JLabel(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.panelTitle")); titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 13.5f)); titleIcon = new JLabel(""); titleMessage = new DialogTextArea(DEFAULT_MESSAGE); titleMessage.setMargin(new Insets(5, 10, 10, 10)); // titleMessage.setMinimumSize(new Dimension(0, 30)); titleMessage.setFont(titleMessage.getFont().deriveFont(11f)); titleMessage.setEditable(false); titleMessage.setFocusable(false); // titleMessage.setFont(titleLabel.getFont().deriveFont(Font.PLAIN, // 12f)); // column range columnLabel = new JLabel( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.columnSectionLabel")); JsonNode columnRange = newConfiguration.get("columnRange"); columnFromValue = new JTextField(new UpperCaseDocument(), SpreadsheetUtils.getColumnLabel(columnRange.get("start").intValue()), 4); columnFromValue.setMinimumSize(columnFromValue.getPreferredSize()); columnToValue = new JTextField(new UpperCaseDocument(), SpreadsheetUtils.getColumnLabel(columnRange.get("end").intValue()), 4); columnToValue.setMinimumSize(columnToValue.getPreferredSize()); columnFromValue.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { } public void insertUpdate(DocumentEvent e) { checkValue(columnFromValue.getText()); } public void removeUpdate(DocumentEvent e) { checkValue(columnFromValue.getText()); } private void checkValue(String text) { if (text.trim().equals("")) { addErrorMessage(EMPTY_FROM_COLUMN_ERROR_MESSAGE); } else if (text.trim().matches("[A-Za-z]+")) { String fromColumn = columnFromValue.getText().toUpperCase(); String toColumn = columnToValue.getText().toUpperCase(); int fromColumnIndex = SpreadsheetUtils.getColumnIndex(fromColumn); int toColumnIndex = SpreadsheetUtils.getColumnIndex(toColumn); if (checkColumnRange(fromColumnIndex, toColumnIndex)) { columnMappingTableModel.setFromColumn(fromColumnIndex); columnMappingTableModel.setToColumn(toColumnIndex); newConfiguration.set("columnRange", newConfiguration.objectNode() .put("start", fromColumnIndex).put("end", toColumnIndex)); validatePortNames(); } removeErrorMessage(FROM_COLUMN_ERROR_MESSAGE); removeErrorMessage(EMPTY_FROM_COLUMN_ERROR_MESSAGE); } else { addErrorMessage(FROM_COLUMN_ERROR_MESSAGE); removeErrorMessage(EMPTY_FROM_COLUMN_ERROR_MESSAGE); } } }); columnToValue.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { } public void insertUpdate(DocumentEvent e) { checkValue(columnToValue.getText()); } public void removeUpdate(DocumentEvent e) { checkValue(columnToValue.getText()); } private void checkValue(String text) { if (text.trim().equals("")) { addErrorMessage(EMPTY_TO_COLUMN_ERROR_MESSAGE); } else if (text.trim().matches("[A-Za-z]+")) { String fromColumn = columnFromValue.getText().toUpperCase(); String toColumn = columnToValue.getText().toUpperCase(); int fromColumnIndex = SpreadsheetUtils.getColumnIndex(fromColumn); int toColumnIndex = SpreadsheetUtils.getColumnIndex(toColumn); if (checkColumnRange(fromColumnIndex, toColumnIndex)) { columnMappingTableModel.setFromColumn(fromColumnIndex); columnMappingTableModel.setToColumn(toColumnIndex); newConfiguration.set("columnRange", newConfiguration.objectNode() .put("start", fromColumnIndex).put("end", toColumnIndex)); validatePortNames(); } removeErrorMessage(TO_COLUMN_ERROR_MESSAGE); removeErrorMessage(EMPTY_TO_COLUMN_ERROR_MESSAGE); } else { addErrorMessage(TO_COLUMN_ERROR_MESSAGE); removeErrorMessage(EMPTY_TO_COLUMN_ERROR_MESSAGE); } } }); // row range rowLabel = new JLabel(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.rowSectionLabel")); addDivider(rowLabel, SwingConstants.TOP, false); rowSelectAllOption = new JCheckBox( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.selectAllRowsOption")); rowExcludeFirstOption = new JCheckBox( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.excludeHeaderRowOption")); rowIgnoreBlankRows = new JCheckBox( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.ignoreBlankRowsOption")); rowSelectAllOption.setFocusable(false); rowExcludeFirstOption.setFocusable(false); JsonNode rowRange = newConfiguration.get("rowRange"); rowFromValue = new JTextField(new NumericDocument(), String.valueOf(rowRange.get("start").intValue() + 1), 4); if (rowRange.get("end").intValue() == -1) { rowToValue = new JTextField(new NumericDocument(), "", 4); } else { rowToValue = new JTextField(new NumericDocument(), String.valueOf(rowRange.get("end").intValue() + 1), 4); } rowFromValue.setMinimumSize(rowFromValue.getPreferredSize()); rowToValue.setMinimumSize(rowToValue.getPreferredSize()); if (newConfiguration.get("allRows").booleanValue()) { rowSelectAllOption.setSelected(true); rowFromValue.setEditable(false); rowFromValue.setEnabled(false); rowToValue.setEditable(false); rowToValue.setEnabled(false); } else { rowExcludeFirstOption.setEnabled(false); } rowExcludeFirstOption.setSelected(newConfiguration.get("excludeFirstRow").booleanValue()); rowIgnoreBlankRows.setSelected(newConfiguration.get("ignoreBlankRows").booleanValue()); rowFromValue.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { } public void insertUpdate(DocumentEvent e) { checkValue(rowFromValue.getText()); } public void removeUpdate(DocumentEvent e) { checkValue(rowFromValue.getText()); } private void checkValue(String text) { if (text.trim().equals("")) { addErrorMessage(EMPTY_FROM_ROW_ERROR_MESSAGE); } else if (text.trim().matches("[1-9][0-9]*")) { checkRowRange(rowFromValue.getText(), rowToValue.getText()); int fromRow = Integer.parseInt(rowFromValue.getText()); ((ObjectNode) newConfiguration.get("rowRange")).put("start", fromRow - 1); removeErrorMessage(FROM_ROW_ERROR_MESSAGE); removeErrorMessage(EMPTY_FROM_ROW_ERROR_MESSAGE); } else { addErrorMessage(FROM_ROW_ERROR_MESSAGE); removeErrorMessage(EMPTY_FROM_ROW_ERROR_MESSAGE); } } }); rowToValue.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { } public void insertUpdate(DocumentEvent e) { checkValue(rowToValue.getText()); } public void removeUpdate(DocumentEvent e) { checkValue(rowToValue.getText()); } private void checkValue(String text) { if (text.trim().equals("")) { ((ObjectNode) newConfiguration.get("rowRange")).put("end", -1); removeErrorMessage(TO_ROW_ERROR_MESSAGE); removeErrorMessage(INCONSISTENT_ROW_MESSAGE); } else if (text.trim().matches("[0-9]+")) { checkRowRange(rowFromValue.getText(), rowToValue.getText()); int toRow = Integer.parseInt(rowToValue.getText()); ((ObjectNode) newConfiguration.get("rowRange")).put("end", toRow - 1); removeErrorMessage(TO_ROW_ERROR_MESSAGE); } else { addErrorMessage(TO_ROW_ERROR_MESSAGE); } } }); rowSelectAllOption.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { newConfiguration.put("allRows", true); rowExcludeFirstOption.setEnabled(true); if (rowExcludeFirstOption.isSelected()) { rowFromValue.setText("2"); } else { rowFromValue.setText("1"); } rowToValue.setText(""); rowFromValue.setEditable(false); rowFromValue.setEnabled(false); rowToValue.setEditable(false); rowToValue.setEnabled(false); } else { newConfiguration.put("allRows", false); rowExcludeFirstOption.setEnabled(false); rowFromValue.setEditable(true); rowFromValue.setEnabled(true); rowToValue.setEditable(true); rowToValue.setEnabled(true); } } }); rowExcludeFirstOption.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { newConfiguration.put("excludeFirstRow", true); rowFromValue.setText("2"); ((ObjectNode) newConfiguration.get("rowRange")).put("start", 1); } else { newConfiguration.put("excludeFirstRow", false); rowFromValue.setText("1"); ((ObjectNode) newConfiguration.get("rowRange")).put("start", 0); } } }); rowIgnoreBlankRows.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { newConfiguration.put("ignoreBlankRows", e.getStateChange() == ItemEvent.SELECTED); } }); // empty cells emptyCellLabel = new JLabel( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.emptyCellSectionLabel")); addDivider(emptyCellLabel, SwingConstants.TOP, false); emptyCellButtonGroup = new ButtonGroup(); emptyCellEmptyStringOption = new JRadioButton( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.emptyStringOption")); emptyCellUserDefinedOption = new JRadioButton( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.userDefinedOption")); emptyCellErrorValueOption = new JRadioButton( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.generateErrorOption")); emptyCellEmptyStringOption.setFocusable(false); emptyCellUserDefinedOption.setFocusable(false); emptyCellErrorValueOption.setFocusable(false); emptyCellUserDefinedValue = new JTextField(newConfiguration.get("emptyCellValue").textValue()); emptyCellButtonGroup.add(emptyCellEmptyStringOption); emptyCellButtonGroup.add(emptyCellUserDefinedOption); emptyCellButtonGroup.add(emptyCellErrorValueOption); if (newConfiguration.get("emptyCellPolicy").textValue().equals("GENERATE_ERROR")) { emptyCellErrorValueOption.setSelected(true); emptyCellUserDefinedValue.setEnabled(false); emptyCellUserDefinedValue.setEditable(false); } else if (newConfiguration.get("emptyCellPolicy").textValue().equals("EMPTY_STRING")) { emptyCellEmptyStringOption.setSelected(true); emptyCellUserDefinedValue.setEnabled(false); emptyCellUserDefinedValue.setEditable(false); } else { emptyCellUserDefinedOption.setSelected(true); emptyCellUserDefinedValue.setText(newConfiguration.get("emptyCellValue").textValue()); emptyCellUserDefinedValue.setEnabled(true); emptyCellUserDefinedValue.setEditable(true); } emptyCellEmptyStringOption.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { newConfiguration.put("emptyCellPolicy", "EMPTY_STRING"); emptyCellUserDefinedValue.setEnabled(false); emptyCellUserDefinedValue.setEditable(false); } }); emptyCellUserDefinedOption.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { newConfiguration.put("emptyCellPolicy", "USER_DEFINED"); emptyCellUserDefinedValue.setEnabled(true); emptyCellUserDefinedValue.setEditable(true); emptyCellUserDefinedValue.requestFocusInWindow(); } }); emptyCellErrorValueOption.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { newConfiguration.put("emptyCellPolicy", "GENERATE_ERROR"); emptyCellUserDefinedValue.setEnabled(false); emptyCellUserDefinedValue.setEditable(false); } }); emptyCellUserDefinedValue.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { newConfiguration.put("emptyCellValue", emptyCellUserDefinedValue.getText()); } public void insertUpdate(DocumentEvent e) { newConfiguration.put("emptyCellValue", emptyCellUserDefinedValue.getText()); } public void removeUpdate(DocumentEvent e) { newConfiguration.put("emptyCellValue", emptyCellUserDefinedValue.getText()); } }); // column mappings columnMappingLabel = new JLabel( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.columnMappingSectionLabel")); addDivider(columnMappingLabel, SwingConstants.TOP, false); Map<String, String> columnToPortMapping = new HashMap<>(); if (newConfiguration.has("columnNames")) { for (JsonNode columnName : newConfiguration.get("columnNames")) { columnToPortMapping.put(columnName.get("column").textValue(), columnName.get("port").textValue()); } } columnMappingTableModel = new SpreadsheetImportConfigTableModel(columnFromValue.getText(), columnToValue.getText(), columnToPortMapping); columnMappingTable = new JTable(); columnMappingTable.setRowSelectionAllowed(false); columnMappingTable.getTableHeader().setReorderingAllowed(false); columnMappingTable.setGridColor(Color.LIGHT_GRAY); // columnMappingTable.setFocusable(false); columnMappingTable.setColumnModel(new DefaultTableColumnModel() { public TableColumn getColumn(int columnIndex) { TableColumn column = super.getColumn(columnIndex); if (columnIndex == 0) { column.setMaxWidth(100); } return column; } }); TableCellEditor defaultEditor = columnMappingTable.getDefaultEditor(String.class); if (defaultEditor instanceof DefaultCellEditor) { DefaultCellEditor defaultCellEditor = (DefaultCellEditor) defaultEditor; defaultCellEditor.setClickCountToStart(1); Component editorComponent = defaultCellEditor.getComponent(); if (editorComponent instanceof JTextComponent) { final JTextComponent textField = (JTextComponent) editorComponent; textField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { updateModel(textField.getText()); } public void insertUpdate(DocumentEvent e) { updateModel(textField.getText()); } public void removeUpdate(DocumentEvent e) { updateModel(textField.getText()); } private void updateModel(String text) { int row = columnMappingTable.getEditingRow(); int column = columnMappingTable.getEditingColumn(); columnMappingTableModel.setValueAt(text, row, column); ArrayNode columnNames = newConfiguration.arrayNode(); Map<String, String> columnToPortMapping = columnMappingTableModel.getColumnToPortMapping(); for (Entry<String, String> entry : columnToPortMapping.entrySet()) { columnNames.add(newConfiguration.objectNode().put("column", entry.getKey()).put("port", entry.getValue())); } newConfiguration.put("columnNames", columnNames); validatePortNames(); } }); } } columnMappingTable.setModel(columnMappingTableModel); // output format outputFormatLabel = new JLabel( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.outputFormatSectionLabel")); outputFormatMultiplePort = new JRadioButton( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.multiplePortOption")); outputFormatSinglePort = new JRadioButton( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.singlePortOption")); outputFormatMultiplePort.setFocusable(false); outputFormatSinglePort.setFocusable(false); outputFormatDelimiterLabel = new JLabel( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.userDefinedCsvDelimiter")); outputFormatDelimiter = new JTextField(newConfiguration.get("csvDelimiter").textValue(), 5); outputFormatButtonGroup = new ButtonGroup(); outputFormatButtonGroup.add(outputFormatMultiplePort); outputFormatButtonGroup.add(outputFormatSinglePort); if (newConfiguration.get("outputFormat").textValue().equals("PORT_PER_COLUMN")) { outputFormatMultiplePort.setSelected(true); outputFormatDelimiterLabel.setEnabled(false); outputFormatDelimiter.setEnabled(false); } else { outputFormatSinglePort.setSelected(true); columnMappingLabel.setEnabled(false); enableTable(columnMappingTable, false); } outputFormatMultiplePort.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { outputFormatDelimiterLabel.setEnabled(false); outputFormatDelimiter.setEnabled(false); columnMappingLabel.setEnabled(true); enableTable(columnMappingTable, true); newConfiguration.put("outputFormat", "PORT_PER_COLUMN"); } }); outputFormatSinglePort.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { outputFormatDelimiterLabel.setEnabled(true); outputFormatDelimiter.setEnabled(true); columnMappingLabel.setEnabled(false); enableTable(columnMappingTable, false); newConfiguration.put("outputFormat", "SINGLE_PORT"); } }); outputFormatDelimiter.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { handleUpdate(); } public void insertUpdate(DocumentEvent e) { handleUpdate(); } public void removeUpdate(DocumentEvent e) { handleUpdate(); } private void handleUpdate() { String text = null; try { text = StringEscapeUtils.unescapeJava(outputFormatDelimiter.getText()); } catch (RuntimeException re) { } if (text == null || text.length() == 0) { newConfiguration.put("csvDelimiter", ","); } else { newConfiguration.put("csvDelimiter", text.substring(0, 1)); } } }); // buttons nextButton = new JButton(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.nextButton")); nextButton.setFocusable(false); nextButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { backButton.setVisible(true); nextButton.setVisible(false); cardLayout.last(contentPanel); } }); backButton = new JButton(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.backButton")); backButton.setFocusable(false); backButton.setVisible(false); backButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { nextButton.setVisible(true); backButton.setVisible(false); cardLayout.first(contentPanel); } }); buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); addDivider(buttonPanel, SwingConstants.TOP, true); removeAll(); layoutPanel(); }
From source file:org.pentaho.reporting.ui.datasources.pmd.PmdDataSourceEditor.java
private JPanel createPreviewButtonsPanel() { final JPanel previewButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); previewButtonsPanel.add(new JCheckBox(new LimitRowsCheckBoxActionListener(maxPreviewRowsSpinner))); previewButtonsPanel.add(maxPreviewRowsSpinner); previewButtonsPanel.add(new JButton(previewAction)); return previewButtonsPanel; }
From source file:edu.harvard.mcz.imagecapture.VerbatimClassifyDialog.java
protected void init() { setTitle("Interpret verbatim data into fields."); setBounds(100, 100, 1203, 899);/*from w ww. ja v a 2 s . c om*/ getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS)); { JPanel panelVerbatimValues = new JPanel(); contentPanel.add(panelVerbatimValues); GridBagLayout gbl_panelVerbatimValues = new GridBagLayout(); gbl_panelVerbatimValues.columnWidths = new int[] { 70, 0, 0, 0, 35, 0, 58, 0, 0, 0 }; gbl_panelVerbatimValues.rowHeights = new int[] { 15, 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 0 }; gbl_panelVerbatimValues.columnWeights = new double[] { 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0 }; gbl_panelVerbatimValues.rowWeights = new double[] { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE }; panelVerbatimValues.setLayout(gbl_panelVerbatimValues); { lblCount = new JLabel("New label"); GridBagConstraints gbc_lblNewLabel = new GridBagConstraints(); gbc_lblNewLabel.gridwidth = 2; gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5); gbc_lblNewLabel.anchor = GridBagConstraints.SOUTHWEST; gbc_lblNewLabel.gridx = 0; gbc_lblNewLabel.gridy = 0; panelVerbatimValues.add(lblCount, gbc_lblNewLabel); } JButton buttonFillFromLast = new JButton("Fill From Last"); GridBagConstraints gbc_buttonFillFromLast = new GridBagConstraints(); gbc_buttonFillFromLast.anchor = GridBagConstraints.SOUTH; gbc_buttonFillFromLast.insets = new Insets(0, 0, 5, 5); gbc_buttonFillFromLast.gridx = 3; gbc_buttonFillFromLast.gridy = 0; panelVerbatimValues.add(buttonFillFromLast, gbc_buttonFillFromLast); { JLabel lblNewLabel_1 = new JLabel("Field values to apply to all records."); GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints(); gbc_lblNewLabel_1.anchor = GridBagConstraints.SOUTHEAST; gbc_lblNewLabel_1.gridwidth = 4; gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5); gbc_lblNewLabel_1.gridx = 4; gbc_lblNewLabel_1.gridy = 0; panelVerbatimValues.add(lblNewLabel_1, gbc_lblNewLabel_1); } { JLabel lblNewLabel_2 = new JLabel("Verbatim Locality"); GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints(); gbc_lblNewLabel_2.anchor = GridBagConstraints.EAST; gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5); gbc_lblNewLabel_2.gridx = 0; gbc_lblNewLabel_2.gridy = 1; panelVerbatimValues.add(lblNewLabel_2, gbc_lblNewLabel_2); } { textFieldVerbLocality = new JTextArea(); textFieldVerbLocality.setEditable(false); textFieldVerbLocality.setRows(5); GridBagConstraints gbc_textField = new GridBagConstraints(); gbc_textField.gridheight = 3; gbc_textField.insets = new Insets(0, 0, 5, 5); gbc_textField.fill = GridBagConstraints.BOTH; gbc_textField.gridx = 1; gbc_textField.gridy = 1; panelVerbatimValues.add(textFieldVerbLocality, gbc_textField); textFieldVerbLocality.setColumns(30); } JLabel lblNewLabel = new JLabel("HigherGeography"); GridBagConstraints gbc_lblNewLabel = new GridBagConstraints(); gbc_lblNewLabel.anchor = GridBagConstraints.EAST; gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5); gbc_lblNewLabel.gridx = 3; gbc_lblNewLabel.gridy = 1; panelVerbatimValues.add(lblNewLabel, gbc_lblNewLabel); GridBagConstraints gbc_textFieldHigherGeography = new GridBagConstraints(); gbc_textFieldHigherGeography.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldHigherGeography.gridwidth = 5; gbc_textFieldHigherGeography.insets = new Insets(0, 0, 5, 5); gbc_textFieldHigherGeography.gridx = 4; gbc_textFieldHigherGeography.gridy = 1; panelVerbatimValues.add(getComboBoxHighGeog(), gbc_textFieldHigherGeography); JButton btnCopyLocality = new JButton(">"); btnCopyLocality.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (textFieldSpecificLocality.getText().isEmpty()) { textFieldSpecificLocality.setText(textFieldVerbLocality.getText().replace("\n", "").trim()); } } }); GridBagConstraints gbc_btnCopyLocality = new GridBagConstraints(); gbc_btnCopyLocality.insets = new Insets(0, 0, 5, 5); gbc_btnCopyLocality.gridx = 2; gbc_btnCopyLocality.gridy = 2; panelVerbatimValues.add(btnCopyLocality, gbc_btnCopyLocality); JLabel lblSpecificLocality = new JLabel("Specific Locality"); GridBagConstraints gbc_lblSpecificLocality = new GridBagConstraints(); gbc_lblSpecificLocality.anchor = GridBagConstraints.EAST; gbc_lblSpecificLocality.insets = new Insets(0, 0, 5, 5); gbc_lblSpecificLocality.gridx = 3; gbc_lblSpecificLocality.gridy = 2; panelVerbatimValues.add(lblSpecificLocality, gbc_lblSpecificLocality); JLabel lblElevation = new JLabel("Elevation"); GridBagConstraints gbc_lblElevation = new GridBagConstraints(); gbc_lblElevation.anchor = GridBagConstraints.EAST; gbc_lblElevation.insets = new Insets(0, 0, 5, 5); gbc_lblElevation.gridx = 3; gbc_lblElevation.gridy = 3; panelVerbatimValues.add(lblElevation, gbc_lblElevation); textFieldMinElevation = new JTextField(); textFieldMinElevation.setMinimumSize(new Dimension(60, 19)); GridBagConstraints gbc_textFieldMinElevation = new GridBagConstraints(); gbc_textFieldMinElevation.insets = new Insets(0, 0, 5, 5); gbc_textFieldMinElevation.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldMinElevation.gridx = 4; gbc_textFieldMinElevation.gridy = 3; panelVerbatimValues.add(textFieldMinElevation, gbc_textFieldMinElevation); textFieldMinElevation.setColumns(4); JLabel lblTo = new JLabel("to"); GridBagConstraints gbc_lblTo = new GridBagConstraints(); gbc_lblTo.anchor = GridBagConstraints.EAST; gbc_lblTo.insets = new Insets(0, 0, 5, 5); gbc_lblTo.gridx = 5; gbc_lblTo.gridy = 3; panelVerbatimValues.add(lblTo, gbc_lblTo); textFieldMaxElevation = new JTextField(); textFieldMaxElevation.setMinimumSize(new Dimension(60, 19)); GridBagConstraints gbc_textFieldMaxElevation = new GridBagConstraints(); gbc_textFieldMaxElevation.anchor = GridBagConstraints.WEST; gbc_textFieldMaxElevation.insets = new Insets(0, 0, 5, 5); gbc_textFieldMaxElevation.gridx = 6; gbc_textFieldMaxElevation.gridy = 3; panelVerbatimValues.add(textFieldMaxElevation, gbc_textFieldMaxElevation); textFieldMaxElevation.setColumns(5); comboBoxElevUnits = new JComboBox(); GridBagConstraints gbc_comboBoxElevUnits = new GridBagConstraints(); gbc_comboBoxElevUnits.insets = new Insets(0, 0, 5, 5); gbc_comboBoxElevUnits.fill = GridBagConstraints.HORIZONTAL; gbc_comboBoxElevUnits.gridx = 7; gbc_comboBoxElevUnits.gridy = 3; panelVerbatimValues.add(comboBoxElevUnits, gbc_comboBoxElevUnits); { JLabel lblVerbatimdate = new JLabel("VerbatimDate"); GridBagConstraints gbc_lblVerbatimdate = new GridBagConstraints(); gbc_lblVerbatimdate.anchor = GridBagConstraints.EAST; gbc_lblVerbatimdate.insets = new Insets(0, 0, 5, 5); gbc_lblVerbatimdate.gridx = 0; gbc_lblVerbatimdate.gridy = 4; panelVerbatimValues.add(lblVerbatimdate, gbc_lblVerbatimdate); } textFieldVerbDate = new JTextField(); GridBagConstraints gbc_textFieldVerbDate = new GridBagConstraints(); gbc_textFieldVerbDate.insets = new Insets(0, 0, 5, 5); gbc_textFieldVerbDate.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldVerbDate.gridx = 1; gbc_textFieldVerbDate.gridy = 4; panelVerbatimValues.add(textFieldVerbDate, gbc_textFieldVerbDate); textFieldVerbDate.setColumns(30); JButton btnCopyDate = new JButton(">"); btnCopyDate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (textFieldISODate.getText().isEmpty()) { Map<String, String> extractResult = DateUtils .extractDateFromVerbatim(textFieldVerbDate.getText().trim()); if (extractResult.containsKey("result")) { textFieldISODate.setText(extractResult.get("result")); } if (extractResult.containsKey("resultState")) { // TODO: Report suspect etc } } } }); GridBagConstraints gbc_btnCopyDate = new GridBagConstraints(); gbc_btnCopyDate.insets = new Insets(0, 0, 5, 5); gbc_btnCopyDate.gridx = 2; gbc_btnCopyDate.gridy = 4; panelVerbatimValues.add(btnCopyDate, gbc_btnCopyDate); JLabel lblNewLabel_3 = new JLabel("ISO Date"); GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints(); gbc_lblNewLabel_3.anchor = GridBagConstraints.EAST; gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 5); gbc_lblNewLabel_3.gridx = 3; gbc_lblNewLabel_3.gridy = 4; panelVerbatimValues.add(lblNewLabel_3, gbc_lblNewLabel_3); textFieldISODate = new JTextField(); textFieldISODate.setInputVerifier( MetadataRetriever.getInputVerifier(Specimen.class, "ISODate", textFieldISODate)); textFieldISODate.setToolTipText(MetadataRetriever.getFieldHelp(Specimen.class, "ISODate")); GridBagConstraints gbc_textFieldISODate = new GridBagConstraints(); gbc_textFieldISODate.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldISODate.gridwidth = 5; gbc_textFieldISODate.insets = new Insets(0, 0, 5, 5); gbc_textFieldISODate.gridx = 4; gbc_textFieldISODate.gridy = 4; panelVerbatimValues.add(textFieldISODate, gbc_textFieldISODate); textFieldISODate.setColumns(10); textFieldSpecificLocality = new JTextField(); GridBagConstraints gbc_textFieldSpecificLocality = new GridBagConstraints(); gbc_textFieldSpecificLocality.gridwidth = 5; gbc_textFieldSpecificLocality.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldSpecificLocality.insets = new Insets(0, 0, 5, 5); gbc_textFieldSpecificLocality.gridx = 4; gbc_textFieldSpecificLocality.gridy = 2; panelVerbatimValues.add(textFieldSpecificLocality, gbc_textFieldSpecificLocality); textFieldSpecificLocality.setColumns(25); { JLabel lblVerbatimCollector = new JLabel("Verbatim Collector"); GridBagConstraints gbc_lblVerbatimCollector = new GridBagConstraints(); gbc_lblVerbatimCollector.anchor = GridBagConstraints.EAST; gbc_lblVerbatimCollector.insets = new Insets(0, 0, 5, 5); gbc_lblVerbatimCollector.gridx = 0; gbc_lblVerbatimCollector.gridy = 6; panelVerbatimValues.add(lblVerbatimCollector, gbc_lblVerbatimCollector); } textFieldVerbCollector = new JTextArea(); textFieldVerbCollector.setEditable(false); textFieldVerbCollector.setRows(3); GridBagConstraints gbc_textFieldVerbCollector = new GridBagConstraints(); gbc_textFieldVerbCollector.gridheight = 2; gbc_textFieldVerbCollector.insets = new Insets(0, 0, 5, 5); gbc_textFieldVerbCollector.fill = GridBagConstraints.BOTH; gbc_textFieldVerbCollector.gridx = 1; gbc_textFieldVerbCollector.gridy = 6; panelVerbatimValues.add(textFieldVerbCollector, gbc_textFieldVerbCollector); textFieldVerbCollector.setColumns(30); JLabel lblCollectors = new JLabel("Collector(s)"); GridBagConstraints gbc_lblCollectors = new GridBagConstraints(); gbc_lblCollectors.anchor = GridBagConstraints.EAST; gbc_lblCollectors.insets = new Insets(0, 0, 5, 5); gbc_lblCollectors.gridx = 3; gbc_lblCollectors.gridy = 6; panelVerbatimValues.add(lblCollectors, gbc_lblCollectors); JButton btnAddCollector = new JButton("+"); btnAddCollector.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { ((CollectorTableModel) jTableCollectors.getModel()).addCollector(new Collector(null, "")); } }); GridBagConstraints gbc_btnAddCollector = new GridBagConstraints(); gbc_btnAddCollector.anchor = GridBagConstraints.EAST; gbc_btnAddCollector.insets = new Insets(0, 0, 5, 5); gbc_btnAddCollector.gridx = 3; gbc_btnAddCollector.gridy = 7; panelVerbatimValues.add(btnAddCollector, gbc_btnAddCollector); GridBagConstraints gbc_collectorTable = new GridBagConstraints(); gbc_collectorTable.insets = new Insets(0, 0, 5, 5); gbc_collectorTable.fill = GridBagConstraints.BOTH; gbc_collectorTable.gridx = 4; gbc_collectorTable.gridy = 6; gbc_collectorTable.gridheight = 2; gbc_collectorTable.gridwidth = 5; panelVerbatimValues.add(getJScrollPaneCollectors(), gbc_collectorTable); JLabel lblVerbatimCollection = new JLabel("Verbatim Collection"); GridBagConstraints gbc_lblVerbatimCollection = new GridBagConstraints(); gbc_lblVerbatimCollection.anchor = GridBagConstraints.EAST; gbc_lblVerbatimCollection.insets = new Insets(0, 0, 5, 5); gbc_lblVerbatimCollection.gridx = 0; gbc_lblVerbatimCollection.gridy = 8; panelVerbatimValues.add(lblVerbatimCollection, gbc_lblVerbatimCollection); textFieldVerbCollection = new JTextArea(); textFieldVerbCollection.setEditable(false); textFieldVerbCollection.setRows(3); GridBagConstraints gbc_textFieldVerbCollection = new GridBagConstraints(); gbc_textFieldVerbCollection.gridheight = 2; gbc_textFieldVerbCollection.insets = new Insets(0, 0, 5, 5); gbc_textFieldVerbCollection.fill = GridBagConstraints.BOTH; gbc_textFieldVerbCollection.gridx = 1; gbc_textFieldVerbCollection.gridy = 8; panelVerbatimValues.add(textFieldVerbCollection, gbc_textFieldVerbCollection); textFieldVerbCollection.setColumns(30); JLabel lblCollection = new JLabel("Collection"); GridBagConstraints gbc_lblCollection = new GridBagConstraints(); gbc_lblCollection.anchor = GridBagConstraints.EAST; gbc_lblCollection.insets = new Insets(0, 0, 5, 5); gbc_lblCollection.gridx = 3; gbc_lblCollection.gridy = 8; panelVerbatimValues.add(lblCollection, gbc_lblCollection); GridBagConstraints gbc_textFieldCollection = new GridBagConstraints(); gbc_textFieldCollection.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldCollection.gridwidth = 5; gbc_textFieldCollection.insets = new Insets(0, 0, 5, 5); gbc_textFieldCollection.gridx = 4; gbc_textFieldCollection.gridy = 8; panelVerbatimValues.add(getJComboBoxCollection(), gbc_textFieldCollection); JLabel lblVerbatimNumbers = new JLabel("Verbatim Numbers"); GridBagConstraints gbc_lblVerbatimNumbers = new GridBagConstraints(); gbc_lblVerbatimNumbers.anchor = GridBagConstraints.EAST; gbc_lblVerbatimNumbers.insets = new Insets(0, 0, 5, 5); gbc_lblVerbatimNumbers.gridx = 0; gbc_lblVerbatimNumbers.gridy = 10; panelVerbatimValues.add(lblVerbatimNumbers, gbc_lblVerbatimNumbers); textFieldVerbNumbers = new JTextArea(); textFieldVerbNumbers.setRows(3); textFieldVerbNumbers.setEditable(false); GridBagConstraints gbc_textFieldVerbNumbers = new GridBagConstraints(); gbc_textFieldVerbNumbers.gridheight = 2; gbc_textFieldVerbNumbers.insets = new Insets(0, 0, 5, 5); gbc_textFieldVerbNumbers.fill = GridBagConstraints.BOTH; gbc_textFieldVerbNumbers.gridx = 1; gbc_textFieldVerbNumbers.gridy = 10; panelVerbatimValues.add(textFieldVerbNumbers, gbc_textFieldVerbNumbers); textFieldVerbNumbers.setColumns(30); JLabel lblNumbers = new JLabel("Numbers"); GridBagConstraints gbc_lblNumbers = new GridBagConstraints(); gbc_lblNumbers.anchor = GridBagConstraints.EAST; gbc_lblNumbers.insets = new Insets(0, 0, 5, 5); gbc_lblNumbers.gridx = 3; gbc_lblNumbers.gridy = 10; panelVerbatimValues.add(lblNumbers, gbc_lblNumbers); JButton btnAddNumber = new JButton("+"); btnAddNumber.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { ((NumberTableModel) jTableNumbers.getModel()) .addNumber(new edu.harvard.mcz.imagecapture.data.Number(null, "", "")); } }); GridBagConstraints gbc_btnAddNumber = new GridBagConstraints(); gbc_btnAddNumber.anchor = GridBagConstraints.EAST; gbc_btnAddNumber.insets = new Insets(0, 0, 5, 5); gbc_btnAddNumber.gridx = 3; gbc_btnAddNumber.gridy = 11; panelVerbatimValues.add(btnAddNumber, gbc_btnAddNumber); GridBagConstraints gbc_numberTable = new GridBagConstraints(); gbc_numberTable.insets = new Insets(0, 0, 5, 5); gbc_numberTable.fill = GridBagConstraints.BOTH; gbc_numberTable.gridx = 4; gbc_numberTable.gridy = 10; gbc_numberTable.gridheight = 2; gbc_numberTable.gridwidth = 5; panelVerbatimValues.add(this.getJScrollPaneNumbers(), gbc_numberTable); JLabel lblVerbatimOtherText = new JLabel("Verbatim Other Text"); GridBagConstraints gbc_lblVerbatimOtherText = new GridBagConstraints(); gbc_lblVerbatimOtherText.anchor = GridBagConstraints.EAST; gbc_lblVerbatimOtherText.insets = new Insets(0, 0, 5, 5); gbc_lblVerbatimOtherText.gridx = 0; gbc_lblVerbatimOtherText.gridy = 12; panelVerbatimValues.add(lblVerbatimOtherText, gbc_lblVerbatimOtherText); textFieldVerbUnclassifiedText = new JTextArea(); textFieldVerbUnclassifiedText.setEditable(false); textFieldVerbUnclassifiedText.setRows(5); GridBagConstraints gbc_textFieldVerbUnclassifiedText = new GridBagConstraints(); gbc_textFieldVerbUnclassifiedText.gridheight = 3; gbc_textFieldVerbUnclassifiedText.insets = new Insets(0, 0, 5, 5); gbc_textFieldVerbUnclassifiedText.fill = GridBagConstraints.BOTH; gbc_textFieldVerbUnclassifiedText.gridx = 1; gbc_textFieldVerbUnclassifiedText.gridy = 12; panelVerbatimValues.add(textFieldVerbUnclassifiedText, gbc_textFieldVerbUnclassifiedText); textFieldVerbUnclassifiedText.setColumns(30); JLabel lblHabitat = new JLabel("Habitat"); GridBagConstraints gbc_lblHabitat = new GridBagConstraints(); gbc_lblHabitat.anchor = GridBagConstraints.EAST; gbc_lblHabitat.insets = new Insets(0, 0, 5, 5); gbc_lblHabitat.gridx = 3; gbc_lblHabitat.gridy = 12; panelVerbatimValues.add(lblHabitat, gbc_lblHabitat); textFieldHabitat = new JTextField(); GridBagConstraints gbc_textFieldHabitat = new GridBagConstraints(); gbc_textFieldHabitat.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldHabitat.gridwidth = 4; gbc_textFieldHabitat.insets = new Insets(0, 0, 5, 5); gbc_textFieldHabitat.gridx = 4; gbc_textFieldHabitat.gridy = 12; panelVerbatimValues.add(textFieldHabitat, gbc_textFieldHabitat); textFieldHabitat.setColumns(10); JLabel lblMicrohabitat = new JLabel("Microhabitat"); GridBagConstraints gbc_lblMicrohabitat = new GridBagConstraints(); gbc_lblMicrohabitat.anchor = GridBagConstraints.EAST; gbc_lblMicrohabitat.insets = new Insets(0, 0, 5, 5); gbc_lblMicrohabitat.gridx = 3; gbc_lblMicrohabitat.gridy = 13; panelVerbatimValues.add(lblMicrohabitat, gbc_lblMicrohabitat); textFieldMicrohabitat = new JTextField(); GridBagConstraints gbc_textFieldMicrohabitat = new GridBagConstraints(); gbc_textFieldMicrohabitat.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldMicrohabitat.gridwidth = 4; gbc_textFieldMicrohabitat.insets = new Insets(0, 0, 5, 5); gbc_textFieldMicrohabitat.gridx = 4; gbc_textFieldMicrohabitat.gridy = 13; panelVerbatimValues.add(textFieldMicrohabitat, gbc_textFieldMicrohabitat); textFieldMicrohabitat.setColumns(10); JLabel lblNewLabel_4 = new JLabel("Workflow Status"); GridBagConstraints gbc_lblNewLabel_4 = new GridBagConstraints(); gbc_lblNewLabel_4.insets = new Insets(0, 0, 5, 5); gbc_lblNewLabel_4.gridx = 3; gbc_lblNewLabel_4.gridy = 15; panelVerbatimValues.add(lblNewLabel_4, gbc_lblNewLabel_4); comboBoxWorkflowStatus = new JComboBox(WorkFlowStatus.getVerbatimClassifiedWorkFlowStatusValues()); comboBoxWorkflowStatus.setSelectedItem(WorkFlowStatus.STAGE_CLASSIFIED); GridBagConstraints gbc_comboBoxWorkflowStatus = new GridBagConstraints(); gbc_comboBoxWorkflowStatus.gridwidth = 4; gbc_comboBoxWorkflowStatus.fill = GridBagConstraints.HORIZONTAL; gbc_comboBoxWorkflowStatus.insets = new Insets(0, 0, 5, 5); gbc_comboBoxWorkflowStatus.gridx = 4; gbc_comboBoxWorkflowStatus.gridy = 15; panelVerbatimValues.add(comboBoxWorkflowStatus, gbc_comboBoxWorkflowStatus); JButton btnApplyToAll = new JButton("Apply To All Records"); GridBagConstraints gbc_btnApplyToAll = new GridBagConstraints(); gbc_btnApplyToAll.gridwidth = 4; gbc_btnApplyToAll.insets = new Insets(0, 0, 5, 5); gbc_btnApplyToAll.gridx = 4; gbc_btnApplyToAll.gridy = 16; panelVerbatimValues.add(btnApplyToAll, gbc_btnApplyToAll); btnApplyToAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveChanges(); } }); } { JPanel panelRelatedData = new JPanel(); contentPanel.add(panelRelatedData); GridBagLayout gbl_panelRelatedData = new GridBagLayout(); gbl_panelRelatedData.maximumLayoutSize(panelRelatedData); gbl_panelRelatedData.columnWidths = new int[] { 20, 33, 1, 0 }; gbl_panelRelatedData.rowHeights = new int[] { 25, 0 }; gbl_panelRelatedData.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE }; gbl_panelRelatedData.rowWeights = new double[] { 1.0, Double.MIN_VALUE }; panelRelatedData.setLayout(gbl_panelRelatedData); { JLabel lblTaxa = new JLabel("Taxa"); GridBagConstraints gbc_lblTaxa = new GridBagConstraints(); gbc_lblTaxa.anchor = GridBagConstraints.NORTHEAST; gbc_lblTaxa.insets = new Insets(0, 0, 0, 5); gbc_lblTaxa.gridx = 0; gbc_lblTaxa.gridy = 0; panelRelatedData.add(lblTaxa, gbc_lblTaxa); } JScrollPane scrollPane = new JScrollPane(); // scrollPane.setPreferredSize(new Dimension(1000,100)); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.anchor = GridBagConstraints.NORTH; gbc_scrollPane.insets = new Insets(0, 0, 0, 5); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 1; gbc_scrollPane.gridy = 0; panelRelatedData.add(scrollPane, gbc_scrollPane); tableTaxa = new JTable(); SpecimenLifeCycle sls = new SpecimenLifeCycle(); tableTaxa.setModel(new CountValueTableModel(sls.findTaxaFromVerbatim(this.verbatimData), "Current Idenfifications for these verbatim values.")); scrollPane.setViewportView(tableTaxa); } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton cancelButton = new JButton("Close"); cancelButton.setActionCommand("Close"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }); buttonPane.add(cancelButton); } } }
From source file:eu.ggnet.dwoss.receipt.unit.UnitView.java
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form/*from w w w.ja v a 2s. c om*/ * Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; manufacturerButtonGroup = new javax.swing.ButtonGroup(); jPanel1 = new javax.swing.JPanel(); unitSplitPane = new javax.swing.JSplitPane(); unitWritePanel = new javax.swing.JPanel(); internalCommentAreaScrollPane = new javax.swing.JScrollPane(); internalCommentArea = new javax.swing.JTextArea(); commentAreaScrollPane = new javax.swing.JScrollPane(); commentArea = new javax.swing.JTextArea(); unitItemLabel = new javax.swing.JLabel(); unitStatusLabel = new javax.swing.JLabel(); unitStateBox = new javax.swing.JComboBox(); editProductButton = new javax.swing.JButton(); partNoField = new javax.swing.JTextField(); refurbishedIdField = new javax.swing.JTextField(); unitSnLabel = new javax.swing.JLabel(); unitNumberLabel = new javax.swing.JLabel(); serialField = new javax.swing.JTextField(); editRefurbishedIdButton = new javax.swing.JButton(); mfgLabel = new javax.swing.JLabel(); mfgDateChooser = new com.toedter.calendar.JDateChooser(); jLabel3 = new javax.swing.JLabel(); warrantyTillChooser = new com.toedter.calendar.JDateChooser(); jLabel4 = new javax.swing.JLabel(); warrantyTypeChooser = new javax.swing.JComboBox(); manufacturerPanel = new javax.swing.JPanel(); contractorBox = new javax.swing.JComboBox(); jScrollPane3 = new javax.swing.JScrollPane(); equipmentTable = new javax.swing.JTable(); jScrollPane4 = new javax.swing.JScrollPane(); commentTable = new javax.swing.JTable(); jScrollPane5 = new javax.swing.JScrollPane(); internalCommentTable = new javax.swing.JTable(); unitReadPanel = new javax.swing.JPanel(); unitShipLabel = new javax.swing.JLabel(); unitShipField = new javax.swing.JTextField(); unitOwnerLabel = new javax.swing.JLabel(); unitOwnerField = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); detailArea = new javax.swing.JEditorPane(); messagesButton = new javax.swing.JButton(); operationButtonPanel = new javax.swing.JPanel(); cancelButton = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Gert bearbeiten/aufnehmen"); setMinimumSize(new java.awt.Dimension(1080, 700)); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); unitSplitPane.setDividerLocation(600); unitSplitPane.setResizeWeight(1.0); unitSplitPane.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); unitSplitPane.setDoubleBuffered(true); unitWritePanel.setBorder(javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED, new java.awt.Color(204, 204, 255), new java.awt.Color(51, 51, 51)))); unitWritePanel.setMinimumSize(new java.awt.Dimension(500, 400)); unitWritePanel.setPreferredSize(new java.awt.Dimension(500, 400)); unitWritePanel.setLayout(new java.awt.GridBagLayout()); internalCommentArea.setColumns(20); internalCommentArea.setLineWrap(true); internalCommentArea.setRows(5); internalCommentArea.setWrapStyleWord(true); internalCommentAreaScrollPane.setViewportView(internalCommentArea); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 10; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START; gridBagConstraints.weighty = 0.1; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); unitWritePanel.add(internalCommentAreaScrollPane, gridBagConstraints); commentArea.setColumns(20); commentArea.setLineWrap(true); commentArea.setRows(5); commentArea.setWrapStyleWord(true); commentAreaScrollPane.setViewportView(commentArea); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 10; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START; gridBagConstraints.weighty = 0.1; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); unitWritePanel.add(commentAreaScrollPane, gridBagConstraints); unitItemLabel.setText("ArtikelNr:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); unitWritePanel.add(unitItemLabel, gridBagConstraints); unitStatusLabel.setText("Zustand:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 5; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); unitWritePanel.add(unitStatusLabel, gridBagConstraints); unitStateBox.setNextFocusableComponent(warrantyTillChooser); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 5; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); unitWritePanel.add(unitStateBox, gridBagConstraints); editProductButton.setText("Edit"); editProductButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { editProductButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; unitWritePanel.add(editProductButton, gridBagConstraints); partNoField.setName("partNo"); // NOI18N partNoField.setNextFocusableComponent(unitStateBox); partNoField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { partNoFieldFocusLost(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); unitWritePanel.add(partNoField, gridBagConstraints); refurbishedIdField.setName("refurbishId"); // NOI18N refurbishedIdField.setNextFocusableComponent(serialField); refurbishedIdField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { refurbishedIdFieldFocusLost(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.1; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); unitWritePanel.add(refurbishedIdField, gridBagConstraints); unitSnLabel.setText("SerienNr:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2); unitWritePanel.add(unitSnLabel, gridBagConstraints); unitNumberLabel.setText("SopoNr:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); unitWritePanel.add(unitNumberLabel, gridBagConstraints); serialField.setName("serial"); // NOI18N serialField.setNextFocusableComponent(partNoField); serialField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { serialFieldFocusLost(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); unitWritePanel.add(serialField, gridBagConstraints); editRefurbishedIdButton.setText("Edit"); editRefurbishedIdButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { editRefurbishedIdButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; unitWritePanel.add(editRefurbishedIdButton, gridBagConstraints); mfgLabel.setText("MFG Date:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; unitWritePanel.add(mfgLabel, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); unitWritePanel.add(mfgDateChooser, gridBagConstraints); jLabel3.setText("Garantie bis:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 7; gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_END; gridBagConstraints.insets = new java.awt.Insets(8, 0, 0, 0); unitWritePanel.add(jLabel3, gridBagConstraints); warrantyTillChooser.setEnabled(false); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 7; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.PAGE_START; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); unitWritePanel.add(warrantyTillChooser, gridBagConstraints); jLabel4.setText("Garantietyp:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 6; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; unitWritePanel.add(jLabel4, gridBagConstraints); warrantyTypeChooser.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { warrantyTypeChooserActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 6; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); unitWritePanel.add(warrantyTypeChooser, gridBagConstraints); manufacturerPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Hersteller Support")); contractorBox.setModel( new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); contractorBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { contractorBoxActionPerformed(evt); } }); javax.swing.GroupLayout manufacturerPanelLayout = new javax.swing.GroupLayout(manufacturerPanel); manufacturerPanel.setLayout(manufacturerPanelLayout); manufacturerPanelLayout.setHorizontalGroup( manufacturerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( contractorBox, javax.swing.GroupLayout.Alignment.TRAILING, 0, 333, Short.MAX_VALUE)); manufacturerPanelLayout.setVerticalGroup( manufacturerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(contractorBox, javax.swing.GroupLayout.Alignment.TRAILING)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; unitWritePanel.add(manufacturerPanel, gridBagConstraints); equipmentTable .setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); jScrollPane3.setViewportView(equipmentTable); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 9; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.1; gridBagConstraints.weighty = 0.2; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); unitWritePanel.add(jScrollPane3, gridBagConstraints); commentTable .setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); jScrollPane4.setViewportView(commentTable); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 8; gridBagConstraints.gridwidth = 3; gridBagConstraints.gridheight = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weighty = 0.2; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); unitWritePanel.add(jScrollPane4, gridBagConstraints); internalCommentTable .setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); jScrollPane5.setViewportView(internalCommentTable); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 9; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.1; gridBagConstraints.weighty = 0.2; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); unitWritePanel.add(jScrollPane5, gridBagConstraints); unitSplitPane.setLeftComponent(unitWritePanel); unitReadPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED, new java.awt.Color(204, 204, 255), java.awt.Color.black))); unitShipLabel.setText("Shipment ID:"); unitShipField.setEditable(false); unitShipField.setFocusable(false); unitOwnerLabel.setText("Besitzer:"); unitOwnerField.setEditable(false); unitOwnerField.setFocusable(false); jLabel1.setText("Details:"); jScrollPane2.setFocusable(false); detailArea.setContentType("text/html"); // NOI18N detailArea.setFocusable(false); jScrollPane2.setViewportView(detailArea); messagesButton.setText("Meldungen"); messagesButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { messagesButtonActionPerformed(evt); } }); javax.swing.GroupLayout unitReadPanelLayout = new javax.swing.GroupLayout(unitReadPanel); unitReadPanel.setLayout(unitReadPanelLayout); unitReadPanelLayout.setHorizontalGroup(unitReadPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE) .addGroup(unitReadPanelLayout.createSequentialGroup() .addGroup(unitReadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(unitShipLabel).addComponent(unitOwnerLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(unitReadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(unitShipField, javax.swing.GroupLayout.DEFAULT_SIZE, 308, Short.MAX_VALUE) .addComponent(unitOwnerField, javax.swing.GroupLayout.DEFAULT_SIZE, 308, Short.MAX_VALUE))) .addGroup(unitReadPanelLayout.createSequentialGroup().addComponent(jLabel1).addGap(0, 346, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, unitReadPanelLayout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE).addComponent(messagesButton))); unitReadPanelLayout.setVerticalGroup(unitReadPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(unitReadPanelLayout.createSequentialGroup().addGroup(unitReadPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(unitShipLabel) .addComponent(unitShipField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( unitReadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(unitOwnerLabel).addComponent(unitOwnerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(messagesButton))); unitSplitPane.setRightComponent(unitReadPanel); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap() .addComponent(unitSplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1008, Short.MAX_VALUE) .addContainerGap())); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout .createSequentialGroup().addContainerGap().addComponent(unitSplitPane).addContainerGap())); operationButtonPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); operationButtonPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); cancelButton.setText("Abbrechen"); cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelButtonActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addComponent(cancelButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(operationButtonPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(operationButtonPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(cancelButton).addContainerGap())))); pack(); }