List of usage examples for javax.swing DefaultComboBoxModel DefaultComboBoxModel
public DefaultComboBoxModel(Vector<E> v)
From source file:com.mirth.connect.client.ui.components.rsta.FindReplaceDialog.java
private void updateProperties() { FindReplaceProperties findReplaceProperties = MirthRSyntaxTextArea.getRSTAPreferences() .getFindReplaceProperties(); String findText = (String) findComboBox.getSelectedItem(); List<String> findHistory = findReplaceProperties.getFindHistory(); findHistory.remove(findText);/*ww w .ja va 2s.com*/ findHistory.add(0, findText); while (findHistory.size() > 10) { findHistory.remove(10); } findComboBox.setModel(new DefaultComboBoxModel(findHistory.toArray(new String[findHistory.size()]))); findComboBox.setSelectedIndex(0); String replaceText = (String) replaceComboBox.getSelectedItem(); if (StringUtils.isNotEmpty(replaceText)) { List<String> replaceHistory = findReplaceProperties.getReplaceHistory(); replaceHistory.remove(replaceText); replaceHistory.add(0, replaceText); while (replaceHistory.size() > 10) { replaceHistory.remove(10); } replaceComboBox .setModel(new DefaultComboBoxModel(replaceHistory.toArray(new String[replaceHistory.size()]))); replaceComboBox.setSelectedIndex(0); } findReplaceProperties.setForward(directionForwardRadio.isSelected()); findReplaceProperties.setWrapSearch(wrapSearchCheckBox.isSelected()); findReplaceProperties.setMatchCase(matchCaseCheckBox.isSelected()); findReplaceProperties.setRegularExpression(regularExpressionCheckBox.isSelected()); findReplaceProperties.setWholeWord(wholeWordCheckBox.isSelected()); MirthRSyntaxTextArea.updateFindReplacePreferences(); }
From source file:net.sourceforge.doddle_owl.ui.InputDocumentSelectionPanel.java
public InputDocumentSelectionPanel(InputTermSelectionPanel iwsPanel, DODDLEProject p) { project = p;// w w w .j av a 2 s . c o m inputTermSelectionPanel = iwsPanel; termInfoMap = new HashMap<String, TermInfo>(); stopWordSet = new HashSet<String>(); docList = new JList(new DefaultListModel()); docList.addListSelectionListener(this); JScrollPane docListScroll = new JScrollPane(docList); inputDocList = new JList(new DefaultListModel()); inputDocList.addListSelectionListener(this); JScrollPane inputDocListScroll = new JScrollPane(inputDocList); DefaultComboBoxModel docLangBoxModel = new DefaultComboBoxModel(new Object[] { "en", "ja" }); docLangBox = new JComboBox(docLangBoxModel); docLangBox.addActionListener(this); addDocButton = new JButton(new AddDocAction(Translator.getTerm("AddDocumentButton"))); removeDocButton = new JButton(new RemoveDocAction(Translator.getTerm("RemoveDocumentButton"))); DefaultComboBoxModel inputDocLangBoxModel = new DefaultComboBoxModel(new Object[] { "en", "ja" }); inputDocLangBox = new JComboBox(inputDocLangBoxModel); inputDocLangBox.addActionListener(this); addInputDocButton = new JButton(new AddInputDocAction(Translator.getTerm("AddInputDocumentButton"))); removeInputDocButton = new JButton( new RemoveInputDocAction(Translator.getTerm("RemoveInputDocumentButton"))); inputDocArea = new JTextArea(); inputDocArea.setLineWrap(true); JScrollPane inputDocAreaScroll = new JScrollPane(inputDocArea); JPanel docButtonPanel = new JPanel(); docButtonPanel.setLayout(new BorderLayout()); docButtonPanel.setLayout(new GridLayout(1, 3)); docButtonPanel.add(docLangBox); docButtonPanel.add(addDocButton); docButtonPanel.add(removeDocButton); JPanel docPanel = new JPanel(); docPanel.setLayout(new BorderLayout()); docPanel.add(docListScroll, BorderLayout.CENTER); docPanel.add(docButtonPanel, BorderLayout.SOUTH); punctuationField = new JTextField(10); punctuationField.setText(PUNCTUATION_CHARS); setPunctuationButton = new JButton(Translator.getTerm("SetPunctuationCharacterButton")); setPunctuationButton.addActionListener(this); JPanel punctuationPanel = new JPanel(); punctuationPanel.add(punctuationField); punctuationPanel.add(setPunctuationButton); JPanel inputDocButtonPanel = new JPanel(); inputDocButtonPanel.setLayout(new GridLayout(1, 3)); inputDocButtonPanel.add(inputDocLangBox); inputDocButtonPanel.add(addInputDocButton); inputDocButtonPanel.add(removeInputDocButton); JPanel southPanel = new JPanel(); southPanel.setLayout(new BorderLayout()); southPanel.add(inputDocButtonPanel, BorderLayout.WEST); southPanel.add(punctuationPanel, BorderLayout.EAST); JPanel inputDocPanel = new JPanel(); inputDocPanel.setLayout(new BorderLayout()); inputDocPanel.add(inputDocListScroll, BorderLayout.CENTER); inputDocPanel.add(southPanel, BorderLayout.SOUTH); termExtractionButton = new JButton(Translator.getTerm("InputTermExtractionButton"), Utils.getImageIcon("input_term_selection.png")); termExtractionButton.addActionListener(this); genSenCheckBox = new JCheckBox(Translator.getTerm("GensenCheckBox")); genSenCheckBox.setSelected(false); cabochaCheckBox = new JCheckBox(Translator.getTerm("CabochaCheckBox")); cabochaCheckBox.setSelected(true); showImportanceCheckBox = new JCheckBox("??"); nounCheckBox = new JCheckBox(Translator.getTerm("NounCheckBox")); nounCheckBox.setSelected(true); verbCheckBox = new JCheckBox(Translator.getTerm("VerbCheckBox")); verbCheckBox.setSelected(false); otherCheckBox = new JCheckBox(Translator.getTerm("OtherPOSCheckBox")); oneWordCheckBox = new JCheckBox(Translator.getTerm("OneCharacterCheckBox")); JPanel morphemeAnalysisPanel = new JPanel(); morphemeAnalysisPanel.add(genSenCheckBox); morphemeAnalysisPanel.add(cabochaCheckBox); morphemeAnalysisPanel.add(nounCheckBox); morphemeAnalysisPanel.add(verbCheckBox); morphemeAnalysisPanel.add(otherCheckBox); morphemeAnalysisPanel.add(oneWordCheckBox); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BorderLayout()); buttonPanel.add(morphemeAnalysisPanel, BorderLayout.WEST); buttonPanel.add(termExtractionButton, BorderLayout.EAST); mainViews = new View[2]; ViewMap viewMap = new ViewMap(); // mainViews[0] = new View(Translator.getTerm("DocumentList"), null, // docPanel); mainViews[0] = new View(Translator.getTerm("InputDocumentList"), null, inputDocPanel); mainViews[1] = new View(Translator.getTerm("InputDocumentArea"), null, inputDocAreaScroll); for (int i = 0; i < mainViews.length; i++) { viewMap.addView(i, mainViews[i]); } rootWindow = Utils.createDODDLERootWindow(viewMap); setLayout(new BorderLayout()); add(rootWindow, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); }
From source file:edu.gmu.cs.sim.util.media.chart.ScatterPlotSeriesAttributes.java
public void buildAttributes() { // The following three variables aren't defined until AFTER construction if // you just define them above. So we define them below here instead. opacity = 1.0;//from w w w .j ava 2 s .c om // NOTE: // Paint paint = renderer.getSeriesPaint(getSeriesIndex()); // In JFreeChart 1.0.6 getSeriesPaint returns null!!! // You need lookupSeriesPaint(), but that's not backward compatible. // The only thing consistent in all versions is getItemPaint // (which looks like a gross miss-use, but gets the job done) color = (Color) ((((XYPlot) getPlot()).getRenderer()).getItemPaint(getSeriesIndex(), -1)); colorWell = new ColorWell(color) { public Color changeColor(Color c) { color = c; rebuildGraphicsDefinitions(); return c; } }; addLabelled("Color", colorWell); opacityField = new NumberTextField("Opacity ", opacity, 1.0, 0.125) { public double newValue(double newValue) { if (newValue < 0.0 || newValue > 1.0) { newValue = currentValue; } opacity = (float) newValue; rebuildGraphicsDefinitions(); return newValue; } }; addLabelled("", opacityField); shapeList = new JComboBox(); shapeList.setEditable(false); shapeList.setModel(new DefaultComboBoxModel(new java.util.Vector(Arrays.asList(shapeNames)))); shapeList.setSelectedIndex(shapeNum); shapeList.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { shapeNum = shapeList.getSelectedIndex(); shape = shapes[shapeNum]; rebuildGraphicsDefinitions(); } }); addLabelled("Shape", shapeList); }
From source file:Java2sAutoTextField.java
public Java2sAutoComboBox(java.util.List list) { isFired = false;/*w w w . j ava 2 s .com*/ autoTextFieldEditor = new AutoTextFieldEditor(list); setEditable(true); setModel(new DefaultComboBoxModel(list.toArray()) { protected void fireContentsChanged(Object obj, int i, int j) { if (!isFired) super.fireContentsChanged(obj, i, j); } }); setEditor(autoTextFieldEditor); }
From source file:com.jhash.oimadmin.ui.EventHandlerUI.java
@Override public void initializeComponent() { logger.debug("Initializing {} ...", this); javaCompiler = new UIJavaCompile("Source Code", "EventHandlerSource", configuration, selectionTree, displayArea);//from w w w .j a v a 2 s .com javaCompiler.initialize(); nameField.setText("CustomEventHandler"); nameField.setToolTipText("Name of event handler"); orcTargetLabel.setToolTipText( "type of orchestration, such as Entity, MDS, Relation, Toplink orchestration.\n The default value is oracle.iam.platform.kernel.vo.EntityOrchestration. This is the only supported type for writing custom event handlers"); syncCheckBox.setToolTipText( "If set to TRUE (synchronous), then the kernel expects the event handler to return an EventResult.\n If set to FALSE (asynchronous), then you must return null as the event result and notify the kernel about the event result later."); txCheckBox.setToolTipText( "The tx attribute indicates whether or not the event handler should run in its own transaction.\n Supported values are TRUE or FALSE. By default, the value is FALSE."); classNameText.setText("com.jhash.oim.eventhandler.CustomEventHandler"); classNameText.setToolTipText("Full package name of the Java class that implements the event handler"); classNameText.getDocument().addDocumentListener( new UIJavaCompile.ConnectTextFieldListener(classNameText, javaCompiler.classNameText)); orderField.setToolTipText( "Identifies the order (or sequence) in which the event handler is executed.\n Order value is in the scope of entity, operation, and stage. Order value for each event handler in this scope must be unique. If there is a conflict, then the order in which these conflicted event handlers are executed is arbitrary." + "\nSupported values are FIRST (same as Integer.MIN_VALUE), LAST (same as Integer.MAX_VALUE), or a numeral."); final Set<String> entityNames = new HashSet<String>(); entityNames.addAll(OIMJMXWrapper.OperationDetail.getOperationDetails(connection).keySet()); entityNames.add("ANY"); String[] entityNamesArray = entityNames.toArray(new String[0]); entityType.setModel(new DefaultComboBoxModel<String>(entityNamesArray)); entityType.setToolTipText( "Identifies the type of entity the event handler is executed on. A value of ANY sets the event handler to execute on any entity."); operationType.setToolTipText( "Identifies the type of operation the event handler is executed on. A value of ANY sets the event handler to execute on any operation."); entityType.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String entityTypeSelected = (String) entityType.getSelectedItem(); if (entityTypeSelected != null && entityNames.contains(entityTypeSelected)) { try { Set<String> operations = null; Map<String, Set<String>> operationDetails = OIMJMXWrapper.OperationDetail .getOperationDetails(connection); if (operationDetails.containsKey(entityTypeSelected)) { operations = operationDetails.get(entityTypeSelected); } else { operations = new HashSet<String>(); } operations.add("ANY"); operationType.setModel(new DefaultComboBoxModel<String>(operations.toArray(new String[0]))); } catch (Exception exception) { displayMessage("Entity Type selection failed", "Failed to load operation details associated with " + entityTypeSelected, exception); } } else { logger.trace("Nothing to do since the selected entity type {} is not recognized", entityTypeSelected); } } }); eventHandlerTypes.setRenderer(new DefaultListCellRenderer() { private static final long serialVersionUID = 1L; @Override public JComponent getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JComponent comp = (JComponent) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (index >= 0 && index < EVENT_HANDLER_TYPES_TOOL_TIPS.length) { list.setToolTipText(EVENT_HANDLER_TYPES_TOOL_TIPS[index]); } else { list.setToolTipText(""); } return comp; } }); eventHandlerTypes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String selectedValue; if ((selectedValue = (String) eventHandlerTypes.getSelectedItem()) != null && (!selectedValue.isEmpty())) { if (selectedValue.equals("action-handler") || selectedValue.equals("change-failed")) { syncCheckBox.setEnabled(true); } else { syncCheckBox.setEnabled(false); syncCheckBox.setSelected(false); } if (selectedValue.equals("validation-handler")) { syncCheckBox.setSelected(true); } if (Arrays.asList(new String[] { "out-of-band-handler", "action-handler", "compensate-handler", "finalization-handler" }).contains(selectedValue)) { txCheckBox.setEnabled(true); } else { txCheckBox.setEnabled(false); txCheckBox.setSelected(false); } if (Arrays.asList(new String[] { "out-of-band-handler", "action-handler", "failed-handler" }) .contains(selectedValue)) { stageComboBox.setEnabled(true); } else { stageComboBox.setEnabled(false); stageComboBox.setSelectedItem(""); } } else { logger.trace("Nothing to do since {} item has been selected", selectedValue); } } }); entityType.setSelectedItem(entityNamesArray[0]); // TODO: Is this needed? // operationType.setSelectedItem(associatedOperationSplitDetails[1]); eventHandlerTypes.setSelectedItem(EVENT_HANDLER_TYPES[0]); javaCompiler.classNameText.setText(classNameText.getText()); configurationPanel = new EventHandlerConfigurationPanel("Configure"); configurationPanel.initialize(); packagePanel = new EventHandlerPackagePanel("Package"); packagePanel.initialize(); eventHandlerUI = buildEventHandlerUI(); logger.debug("Initialized {}", this); }
From source file:edu.ku.brc.specify.datamodel.busrules.InstitutionBusRules.java
@Override public void afterFillForm(final Object dataObj) { super.afterFillForm(dataObj); if (checkbox == null && dataObj != null) { Component comp = formViewObj.getControlById("curMgrRelVer"); if (comp instanceof ValComboBox) { relCombobox = (ValComboBox) comp; }/*w w w. j a v a 2 s . c o m*/ comp = formViewObj.getControlById("isRelMgrGlb"); if (relCombobox != null && comp instanceof ValCheckBox) { checkbox = (ValCheckBox) comp; checkbox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { relCombobox.setEnabled(checkbox.isSelected()); ((JLabel) formViewObj.getLabelById("curMgrRelVerLbl")).setEnabled(checkbox.isSelected()); } }); final Institution inst = (Institution) viewable.getDataObj(); if (inst != null) { Vector<String> releases = new Vector<String>(); String curRelease = AppPreferences.getGlobalPrefs().get(RELEASES, null); if (curRelease == null) { curRelease = UIHelper.getInstall4JInstallString(); AppPreferences.getGlobalPrefs().put(RELEASES, curRelease); } releases.add(curRelease); String managedRelease = inst.getCurrentManagedRelVersion(); if (managedRelease == null) { managedRelease = curRelease; inst.setCurrentManagedRelVersion(managedRelease); } boolean releaseNumMismatch = !managedRelease.equals(curRelease); if (releaseNumMismatch) { releases.insertElementAt(managedRelease, 0); } relCombobox.getComboBox().setModel(new DefaultComboBoxModel(releases)); relCombobox.getComboBox().setSelectedIndex(releaseNumMismatch ? 1 : 0); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { UIValidator.setIgnoreAllValidation(this, true); try { checkbox.setSelected(!inst.getIsReleaseManagedGlobally()); // make sure the ChangeListener gets activated checkbox.setSelected(inst.getIsReleaseManagedGlobally()); } catch (Exception ex) { } finally { UIValidator.setIgnoreAllValidation(this, false); } } }); } } } }
From source file:com.cch.aj.entryrecorder.frame.EntryJFrame.java
private int FillMouldComboBox(JComboBox comboBox, int id) { int result = -1; List<Mould> moulds = this.mouldService.GetAllEntities(); if (moulds.size() > 0) { List<ComboBoxItem<Mould>> mouldNames = moulds.stream().sorted(comparing(x -> x.getCode())) .map(x -> ComboBoxItemConvertor.ConvertToComboBoxItem(x, x.getCode(), x.getId())) .collect(Collectors.toList()); Mould mould = new Mould(); mould.setId(0);//from w w w . j a v a 2s . c om mould.setCode("- Select -"); mouldNames.add(0, new ComboBoxItem<Mould>(mould, mould.getCode(), mould.getId())); ComboBoxItem[] mouldNamesArray = mouldNames.toArray(new ComboBoxItem[mouldNames.size()]); comboBox.setModel(new DefaultComboBoxModel(mouldNamesArray)); if (id != 0) { ComboBoxItem<Mould> currentMouldName = mouldNames.stream().filter(x -> x.getId() == id).findFirst() .get(); result = mouldNames.indexOf(currentMouldName); } else { result = 0; } comboBox.setSelectedIndex(result); } return result; }
From source file:de.cebitec.readXplorer.differentialExpression.plot.BaySeqGraphicsTopComponent.java
private void addResults() { List<Group> groups = baySeqAnalysisHandler.getGroups(); groupComboBox.setModel(new DefaultComboBoxModel(groups.toArray())); List<PersistentTrack> tracks = baySeqAnalysisHandler.getSelectedTracks(); for (Iterator<PersistentTrack> it = tracks.iterator(); it.hasNext();) { PersistentTrack persistentTrack = it.next(); samplesA.addElement(persistentTrack); samplesB.addElement(persistentTrack); }//w ww . ja v a 2 s .c o m }
From source file:com.google.cloud.tools.intellij.appengine.cloud.AppEngineDeploymentRunConfigurationEditor.java
/** * Initializes the UI components./*from w w w. j a v a2s. com*/ */ public AppEngineDeploymentRunConfigurationEditor(final Project project, final AppEngineDeployable deploymentSource, final AppEngineHelper appEngineHelper) { this.project = project; this.deploymentSource = deploymentSource; versionIdField.setPlaceholderText(GctBundle.message("appengine.flex.version.placeholder.text")); promoteCheckbox.setSelected(PROMOTE_DEFAULT); stopPreviousVersionCheckbox.setSelected(STOP_PREVIOUS_VERSION_DEFAULT); resetOverridableFields(versionOverrideCheckBox, versionIdField); updateJarWarSelector(); userSpecifiedArtifactFileSelector.setVisible(true); environment = deploymentSource.getEnvironment(); promoteInfoLabel.setText(GctBundle.message("appengine.promote.info.label", LABEL_OPEN_TAG, PROMOTE_INFO_HREF_OPEN_TAG, LABEL_HREF_CLOSE_TAG, LABEL_CLOSE_TAG)); promoteInfoLabel.addHyperlinkListener(new BrowserOpeningHyperLinkListener()); if (environment.isFlexible()) { appEngineCostWarningLabel.setText(GctBundle.message("appengine.flex.deployment.cost.warning", LABEL_OPEN_TAG, COST_WARNING_HREF_OPEN_TAG, LABEL_HREF_CLOSE_TAG, LABEL_CLOSE_TAG)); appEngineCostWarningLabel.addHyperlinkListener(new BrowserOpeningHyperLinkListener()); appEngineCostWarningLabel.setBackground(editorPanel.getBackground()); environmentLabel.setText(getEnvironmentDisplayableLabel()); } else { appEngineCostWarningLabel.setVisible(false); environmentLabel.setText(environment.localizedLabel()); stopPreviousVersionLabel.setVisible(false); stopPreviousVersionCheckbox.setVisible(false); } configTypeComboBox.setModel(new DefaultComboBoxModel(ConfigType.values())); configTypeComboBox.setSelectedItem(ConfigType.AUTO); appEngineConfigFilesPanel.setVisible(false); configTypeComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (getConfigType() == ConfigType.CUSTOM) { appEngineConfigFilesPanel.setVisible(true); // For user convenience, pre-fill the path fields for app.yaml and Dockerfile // if they already exist in their usual directories in the current project. if (project != null && project.getBasePath() != null) { if (StringUtil.isEmpty(appYamlPathField.getText())) { Path defaultAppYamlPath = Paths .get(project.getBasePath() + DEFAULT_APP_YAML_DIR + "/app.yaml"); if (Files.exists(defaultAppYamlPath)) { appYamlPathField.setText(defaultAppYamlPath.toString()); } } if (StringUtil.isEmpty(dockerFilePathField.getText())) { Path defaultDockerfilePath = Paths .get(project.getBasePath() + DEFAULT_DOCKERFILE_DIR + "/Dockerfile"); if (Files.exists(defaultDockerfilePath)) { dockerFilePathField.setText(defaultDockerfilePath.toString()); } } } } else { appEngineConfigFilesPanel.setVisible(false); } } }); userSpecifiedArtifactFileSelector.addBrowseFolderListener( GctBundle.message("appengine.flex.config.user.specified.artifact.title"), null, project, FileChooserDescriptorFactory.createSingleFileDescriptor() .withFileFilter(new Condition<VirtualFile>() { @Override public boolean value(VirtualFile file) { return Comparing.equal(file.getExtension(), "jar", SystemInfo.isFileSystemCaseSensitive) || Comparing.equal(file.getExtension(), "war", SystemInfo.isFileSystemCaseSensitive); } })); userSpecifiedArtifactFileSelector.getTextField().getDocument() .addDocumentListener(getUserSpecifiedArtifactFileListener()); dockerFilePathField.addBrowseFolderListener( GctBundle.message("appengine.dockerfile.location.browse.button"), null, project, FileChooserDescriptorFactory.createSingleFileDescriptor()); appYamlPathField.addBrowseFolderListener( GctBundle.message("appengine.appyaml.location.browse.window.title"), null, project, FileChooserDescriptorFactory.createSingleFileDescriptor()); generateAppYamlButton.addActionListener(new GenerateConfigActionListener(project, "app.yaml", ConfigFileType.APP_YAML, new Supplier<Path>() { @Override public Path get() { return appEngineHelper.defaultAppYaml(); } }, appYamlPathField, userSpecifiedArtifactFileSelector)); generateDockerfileButton.addActionListener(new GenerateConfigActionListener(project, "Dockerfile", ConfigFileType.DOCKERFILE, new Supplier<Path>() { @Override public Path get() { return appEngineHelper.defaultDockerfile(AppEngineFlexDeploymentArtifactType .typeForPath(Paths.get(deploymentSource.getFilePath()))); } }, dockerFilePathField, userSpecifiedArtifactFileSelector)); versionOverrideCheckBox .addItemListener(new CustomFieldOverrideListener(versionOverrideCheckBox, versionIdField)); promoteCheckbox.addItemListener(new PromoteListener()); appEngineFlexConfigPanel.setVisible(environment == AppEngineEnvironment.APP_ENGINE_FLEX && !AppEngineProjectService.getInstance().isFlexCompat(project, deploymentSource)); }
From source file:com.ga.forms.DailyLogAddUI.java
private void initComponentValues() { args = new HashMap(); dateObj = new Date(); formatDateToday = new SimpleDateFormat("dd-MMM-yyyy"); dateDisplayLbl.setText(formatDateToday.format(dateObj)); args.put("date", formatDateToday.format(dateObj)); DailyLogRecord record = new DailyLogRecord(); ArrayList logRecord = record.retrieveRecord(args); formatDateToday = new SimpleDateFormat("EEEE", Locale.ENGLISH); dayDisplayLbl.setText(formatDateToday.format(dateObj)); timeList = new ArrayList<String>(); timeList = getTimeList();/* w w w . ja v a2 s.c o m*/ if (!logRecord.isEmpty()) { args.clear(); args = new HashMap(); formatDateToday = new SimpleDateFormat("HH:mm"); currentTime = formatDateToday.format(dateObj); DailyLogAddUI.logRecordJSONObject = new JSONObject((Map) logRecord.get(0)); DailyLogAddUI.logRecordMetaJSONObject = new JSONObject( (Map) DailyLogAddUI.logRecordJSONObject.get("meta")); DailyLogAddUI.checkIn = Boolean .parseBoolean((String) DailyLogAddUI.logRecordMetaJSONObject.get("checked-in")); if (DailyLogAddUI.logRecordMetaJSONObject.get("had-break").equals("") || DailyLogAddUI.logRecordMetaJSONObject.get("had-break").equals("false")) { DailyLogAddUI.breakDone = false; } else { DailyLogAddUI.breakDone = Boolean .parseBoolean((String) DailyLogAddUI.logRecordMetaJSONObject.get("had-break")); } checkInTimeCombo.setModel(new DefaultComboBoxModel(timeList.toArray())); checkInTimeCombo.setSelectedIndex(timeList.indexOf(DailyLogAddUI.logRecordJSONObject.get("check-in"))); checkInTimeCombo.setEnabled(false); if (!DailyLogAddUI.breakDone) { breakOptionPanel.setEnabled(true); yesRdButton.setEnabled(true); noRdButton.setEnabled(true); customRdButton.setEnabled(true); checkInOutButton.setText("Update"); } else { breakOptionPanel.setEnabled(false); yesRdButton.setEnabled(false); noRdButton.setEnabled(false); customRdButton.setEnabled(false); this.timeOnBreak = DailyLogAddUI.logRecordJSONObject.get("break").toString(); checkInOutButton.setPreferredSize(new Dimension(115, 29)); checkInOutButton.setText("Check Out"); } DailyLogDuration durationAgent = new DailyLogDuration(); durationAgent.calculateCurrentDuration(DailyLogAddUI.logRecordJSONObject.get("check-in").toString(), this.timeOnBreak, ""); String currentTimeDuration = durationAgent.getCurrentDuration(); String[] currentTimeDurationArray = currentTimeDuration.split(":"); int hours = Integer.parseInt(currentTimeDurationArray[0]); if (hours >= 9 && (DailyLogAddUI.logRecordMetaJSONObject.get("checked-out").equals("") || DailyLogAddUI.logRecordMetaJSONObject.get("checked-out").equals("false"))) { // or duration <=9 and duration>=7 DailyLogAddUI.checkOut = false; } else { DailyLogAddUI.checkOut = Boolean .parseBoolean((String) DailyLogAddUI.logRecordMetaJSONObject.get("checked-out")); } if (!DailyLogAddUI.checkOut) { checkOutTimeCombo.setModel(new DefaultComboBoxModel(timeList.toArray())); checkOutTimeCombo.setSelectedIndex(timeList.indexOf(currentTime)); } else { checkOutTimeCombo.setModel(new DefaultComboBoxModel(timeList.toArray())); checkOutTimeCombo .setSelectedIndex(timeList.indexOf(DailyLogAddUI.logRecordJSONObject.get("check-out"))); checkOutTimeCombo.setEnabled(false); checkInOutButton.setEnabled(false); } } else { formatDateToday = new SimpleDateFormat("HH:mm"); currentTime = formatDateToday.format(dateObj); checkInTimeCombo.setModel(new DefaultComboBoxModel(timeList.toArray())); checkInTimeCombo.setSelectedIndex(timeList.indexOf(currentTime)); checkOutTimeCombo.setModel(new DefaultComboBoxModel(timeList.toArray())); checkOutTimeCombo.setSelectedIndex(timeList.indexOf("00:00")); } groupRadioButtons(); }