List of usage examples for com.jgoodies.forms.layout FormLayout FormLayout
public FormLayout(ColumnSpec[] colSpecs)
From source file:ca.sqlpower.architect.swingui.enterprise.SecurityPanel.java
License:Open Source License
public SecurityPanel(SPServerInfo serverInfo, Action closeAction, Dialog d, ArchitectSession session) { this.closeAction = closeAction; splitpane = new JSplitPane(); panel = new JPanel(); ArchitectClientSideSession clientSideSession = ArchitectClientSideSession.getSecuritySessions() .get(serverInfo.getServerAddress()); //Displaying an indeterminate progress bar in place of the split pane //until the security session has loaded fully. if (clientSideSession.getUpdater().getRevision() <= 0) { JLabel messageLabel = new JLabel("Opening"); JProgressBar progressBar = new JProgressBar(); progressBar.setIndeterminate(true); DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout("pref:grow, 5dlu, pref")); builder.setDefaultDialogBorder(); builder.append(messageLabel, 3); builder.nextLine();/* w w w.j a v a 2 s . c om*/ builder.append(progressBar, 3); UpdateListener l = new UpdateListener() { @Override public void workspaceDeleted() { //do nothing } @Override public boolean updatePerformed(AbstractNetworkConflictResolver resolver) { panel.removeAll(); panel.add(splitpane); dialog.pack(); refreshTree(); return true; } @Override public boolean updateException(AbstractNetworkConflictResolver resolver, Throwable t) { //do nothing, the error will be handled elsewhere return true; } @Override public void preUpdatePerformed(AbstractNetworkConflictResolver resolver) { //do nothing } }; clientSideSession.getUpdater().addListener(l); panel.add(builder.getPanel()); } this.securityWorkspace = clientSideSession.getWorkspace(); this.username = serverInfo.getUsername(); this.dialog = d; this.session = session; try { digester = MessageDigest.getInstance("SHA-256"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } rootNode.add(usersNode); rootNode.add(groupsNode); rightSidePanel = new JPanel(); tree = new JTree(rootNode); tree.addTreeSelectionListener(treeListener); tree.setRootVisible(false); tree.setShowsRootHandles(true); tree.setCellRenderer(new DefaultTreeCellRenderer() { public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); Object userObject = ((DefaultMutableTreeNode) value).getUserObject(); if (userObject instanceof User) { setIcon(USER_ICON); } else if (userObject instanceof Group) { setIcon(GROUP_ICON); } return this; } }); treePane = new JScrollPane(tree); treePane.setPreferredSize(new Dimension(200, treePane.getPreferredSize().height)); tree.addMouseListener(popupListener); splitpane.setRightComponent(rightSidePanel); splitpane.setLeftComponent(treePane); if (clientSideSession.getUpdater().getRevision() > 0) { panel.removeAll(); panel.add(splitpane); } refreshTree(); try { tree.setSelectionPath(new TreePath(usersNode.getFirstChild())); } catch (NoSuchElementException e) { } // This just means that the node has no children, so we cannot expand the path. }
From source file:ca.sqlpower.architect.swingui.KettleDataSourceOptionsPanel.java
License:Open Source License
/** * Creates a GUI panel for options which are required for interacting * with Kettle, and are not already covered on the general pref panel. *//* w w w . ja v a2s.c om*/ private JPanel buildKettleOptionsPanel() { DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout("pref, 4dlu, pref:grow")); //$NON-NLS-1$ builder.append(Messages.getString("KettleDataSourceOptionsPanel.hostname"), //$NON-NLS-1$ kettleHostName = new JTextField()); builder.append(Messages.getString("KettleDataSourceOptionsPanel.port"), kettlePort = new JTextField()); //$NON-NLS-1$ builder.append(Messages.getString("KettleDataSourceOptionsPanel.database"), //$NON-NLS-1$ kettleDatabase = new JTextField()); builder.append(Messages.getString("KettleDataSourceOptionsPanel.repositoryLoginName"), //$NON-NLS-1$ kettleLogin = new JTextField()); builder.append(Messages.getString("KettleDataSourceOptionsPanel.repositoryPassword"), //$NON-NLS-1$ kettlePassword = new JPasswordField()); return builder.getPanel(); }
From source file:ca.sqlpower.architect.swingui.RelationshipEditPanel.java
License:Open Source License
public RelationshipEditPanel(Relationship r) { relationshipLine = r;//from w ww . jav a 2s .c o m this.color = relationshipLine.getForegroundColor(); FormLayout layout = new FormLayout("pref, 4dlu, pref:grow, 4dlu, pref, 4dlu, pref:grow, 4dlu, pref"); //$NON-NLS-1$ layout.setColumnGroups(new int[][] { { 3, 7 } }); DefaultFormBuilder fb = new DefaultFormBuilder(layout, logger.isDebugEnabled() ? new FormDebugPanel() : new JPanel()); fb.append(Messages.getString("RelationshipEditPanel.name"), relationshipName = new JTextField(), 7); //$NON-NLS-1$ fb.nextLine(); fb.append(Messages.getString("RelationshipEditPanel.lineColour"), //$NON-NLS-1$ relationLineColor = new JComboBox(Relationship.SUGGESTED_COLOURS)); ColorCellRenderer renderer = new ColorCellRenderer(40, 20); relationLineColor.setRenderer(renderer); if (!containsColor(Relationship.SUGGESTED_COLOURS, color)) { relationLineColor.addItem(color); relationLineColor.setSelectedItem(color); } fb.append(new JButton(customColour)); fb.nextLine(); fb.append(Messages.getString("RelationshipEditPanel.pkLabel"), pkLabelTextField = new JTextField()); fb.append(Messages.getString("RelationshipEditPanel.fkLabel"), fkLabelTextField = new JTextField()); JButton swapButton = new JButton(swapLabelText); swapButton.setIcon( SPSUtils.createIcon("arrow_refresh", "Swap Labels", ArchitectSwingSessionContext.ICON_SIZE)); swapButton.setToolTipText("Swap Label Texts"); fb.append(swapButton); fb.nextLine(); identifyingGroup = new ButtonGroup(); fb.append(Messages.getString("RelationshipEditPanel.type"), //$NON-NLS-1$ identifyingButton = new JRadioButton(Messages.getString("RelationshipEditPanel.identifying")), 7); //$NON-NLS-1$ identifyingGroup.add(identifyingButton); fb.append("", //$NON-NLS-1$ nonIdentifyingButton = new JRadioButton(Messages.getString("RelationshipEditPanel.nonIdentifying")), //$NON-NLS-1$ 7); identifyingGroup.add(nonIdentifyingButton); fb.nextLine(); fb.appendUnrelatedComponentsGapRow(); pkTypeGroup = new ButtonGroup(); fkTypeGroup = new ButtonGroup(); fb.nextLine(); fb.append(Messages.getString("RelationshipEditPanel.cardinality"), //$NON-NLS-1$ pkTableName = new JLabel("PK Table: Unknown")); //$NON-NLS-1$ fb.append("", fkTableName = new JLabel("FK Table: Unknown")); //$NON-NLS-1$ //$NON-NLS-2$ fb.nextLine(); fb.append("", pkTypeZeroToMany = new JRadioButton(Messages.getString("RelationshipEditPanel.zeroOrMore"))); //$NON-NLS-1$ //$NON-NLS-2$ pkTypeGroup.add(pkTypeZeroToMany); fb.append("", fkTypeZeroToMany = new JRadioButton(Messages.getString("RelationshipEditPanel.zeroOrMore"))); //$NON-NLS-1$ //$NON-NLS-2$ fkTypeGroup.add(fkTypeZeroToMany); fb.nextLine(); fb.append("", pkTypeOneToMany = new JRadioButton(Messages.getString("RelationshipEditPanel.oneOrMore"))); //$NON-NLS-1$ //$NON-NLS-2$ pkTypeGroup.add(pkTypeOneToMany); fb.append("", fkTypeOneToMany = new JRadioButton(Messages.getString("RelationshipEditPanel.oneOrMore"))); //$NON-NLS-1$ //$NON-NLS-2$ fkTypeGroup.add(fkTypeOneToMany); fb.nextLine(); fb.append("", pkTypeZeroOne = new JRadioButton(Messages.getString("RelationshipEditPanel.zeroOrOne"))); //$NON-NLS-1$ //$NON-NLS-2$ pkTypeGroup.add(pkTypeZeroOne); fb.append("", fkTypeZeroOne = new JRadioButton(Messages.getString("RelationshipEditPanel.zeroOrOne"))); //$NON-NLS-1$ //$NON-NLS-2$ fkTypeGroup.add(fkTypeZeroOne); fb.nextLine(); fb.append("", pkTypeOne = new JRadioButton(Messages.getString("RelationshipEditPanel.exactlyOne"))); //$NON-NLS-1$ //$NON-NLS-2$ pkTypeGroup.add(pkTypeOne); fb.nextLine(); fb.appendUnrelatedComponentsGapRow(); fb.nextLine(); deferrabilityGroup = new ButtonGroup(); fb.append(Messages.getString("RelationshipEditPanel.deferrability"), //$NON-NLS-1$ notDeferrable = new JRadioButton(Messages.getString("RelationshipEditPanel.notDeferrable")), 7); //$NON-NLS-1$ deferrabilityGroup.add(notDeferrable); fb.append("", //$NON-NLS-1$ initiallyDeferred = new JRadioButton(Messages.getString("RelationshipEditPanel.initiallyDeferred")), //$NON-NLS-1$ 7); deferrabilityGroup.add(initiallyDeferred); fb.append("", initiallyImmediate = new JRadioButton( //$NON-NLS-1$ Messages.getString("RelationshipEditPanel.initiallyImmediate")), 7); //$NON-NLS-1$ deferrabilityGroup.add(initiallyImmediate); fb.nextLine(); fb.appendUnrelatedComponentsGapRow(); updateRuleGroup = new ButtonGroup(); deleteRuleGroup = new ButtonGroup(); fb.nextLine(); fb.append(Messages.getString("RelationshipEditPanel.updateRule"), //$NON-NLS-1$ updateCascade = new JRadioButton(Messages.getString("RelationshipEditPanel.cascade"))); //$NON-NLS-1$ updateRuleGroup.add(updateCascade); fb.append(Messages.getString("RelationshipEditPanel.deleteRule"), //$NON-NLS-1$ deleteCascade = new JRadioButton(Messages.getString("RelationshipEditPanel.cascade"))); //$NON-NLS-1$ deleteRuleGroup.add(deleteCascade); fb.nextLine(); fb.append("", updateRestrict = new JRadioButton(Messages.getString("RelationshipEditPanel.restrict"))); //$NON-NLS-1$ //$NON-NLS-2$ updateRuleGroup.add(updateRestrict); fb.append("", deleteRestrict = new JRadioButton(Messages.getString("RelationshipEditPanel.restrict"))); //$NON-NLS-1$ //$NON-NLS-2$ deleteRuleGroup.add(deleteRestrict); fb.nextLine(); fb.append("", updateNoAction = new JRadioButton(Messages.getString("RelationshipEditPanel.noAction"))); //$NON-NLS-1$ //$NON-NLS-2$ updateRuleGroup.add(updateNoAction); fb.append("", deleteNoAction = new JRadioButton(Messages.getString("RelationshipEditPanel.noAction"))); //$NON-NLS-1$ //$NON-NLS-2$ deleteRuleGroup.add(deleteNoAction); fb.nextLine(); fb.append("", updateSetNull = new JRadioButton(Messages.getString("RelationshipEditPanel.setNull"))); //$NON-NLS-1$ //$NON-NLS-2$ updateRuleGroup.add(updateSetNull); fb.append("", deleteSetNull = new JRadioButton(Messages.getString("RelationshipEditPanel.setNull"))); //$NON-NLS-1$ //$NON-NLS-2$ deleteRuleGroup.add(deleteSetNull); fb.nextLine(); fb.append("", updateSetDefault = new JRadioButton(Messages.getString("RelationshipEditPanel.setDefault"))); //$NON-NLS-1$ //$NON-NLS-2$ updateRuleGroup.add(updateSetDefault); fb.append("", deleteSetDefault = new JRadioButton(Messages.getString("RelationshipEditPanel.setDefault"))); //$NON-NLS-1$ //$NON-NLS-2$ deleteRuleGroup.add(deleteSetDefault); fb.nextLine(); setRelationship(r.getModel()); //TODO Doesn't work! relationshipName.selectAll(); fb.setDefaultDialogBorder(); panel = fb.getPanel(); }
From source file:ca.sqlpower.matchmaker.swingui.address.AddressValidationEntryPanel.java
License:Open Source License
public void updateProblemDetails() { validateResult = addressValidator.getResults(); logger.debug("The size of the Problems is : " + validateResult.size()); problemsBuilder.getPanel().removeAll(); //XXX:This recreates the panel based on the same panel. problemsBuilder = new DefaultFormBuilder(new FormLayout("max(400;min)"), problemsBuilder.getPanel()); JLabel problemsHeading = new JLabel("Problems:"); problemsHeading.setFont(new Font(null, Font.BOLD, 13)); problemsBuilder.append(problemsHeading); for (ValidateResult vr : validateResult) { logger.debug("The Problem details are: " + vr); if (vr.getStatus() == Status.FAIL) { problemsBuilder.append(new JLabel("<html>Fail: " + vr.getMessage() + "</html>", SPSUtils.createIcon("fail", "Fail"), JLabel.LEFT)); } else if (vr.getStatus() == Status.WARN) { problemsBuilder.append(new JLabel("<html>Warning: " + vr.getMessage() + "</html>", SPSUtils.createIcon("warn", "Warn"), JLabel.LEFT)); }//from w w w. ja v a 2 s . co m } problemsBuilder.getPanel().revalidate(); problemsBuilder.getPanel().repaint(); }
From source file:ca.sqlpower.matchmaker.swingui.data.CommonWordsFinderPanel.java
License:Open Source License
public CommonWordsFinderPanel(final MatchMakerSwingSession session, SPDataSource defaultConnection) { this.session = session; DataSourceCollection dataSources = session.getContext().getPlDotIni(); final JComboBox connectionChooser = new JComboBox(new ConnectionComboBoxModel(dataSources)); connectionChooser.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { JDBCDataSource ds = (JDBCDataSource) connectionChooser.getSelectedItem(); // Gets the session's shared SQLDatabase for this data source SQLDatabase db = session.getDatabase(ds); // XXX don't know if this is going to reparent the shared database in a bad way! SQLObjectRoot root = new SQLObjectRoot(); root.addChild(db);//from w w w . j a va 2s . c om DBTreeModel model = new DBTreeModel(root); columnPicker.setModel(model); } catch (SQLObjectException ex) { throw new RuntimeException(ex); } } }); columnPicker = new JTree(); DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout("pref:grow")); builder.append("Choose a column to analyze for frequently-occurring words:"); builder.append(connectionChooser); builder.append(new JScrollPane(columnPicker)); JDefaultButton okButton = new JDefaultButton("Start"); JButton cancelButton = new JButton("Cancel"); builder.append(ButtonBarFactory.buildOKCancelBar(okButton, cancelButton)); panel = builder.getPanel(); }
From source file:ca.sqlpower.matchmaker.swingui.engine.AddressValidationSettingsPanel.java
License:Open Source License
private void buildUI() { FormLayout validationSettingsLayout = new FormLayout("pref"); DefaultFormBuilder dfb = new DefaultFormBuilder(validationSettingsLayout); dfb.append("Address Filter Setting"); dfb.nextLine();//ww w .jav a 2 s .com valid = new JCheckBox("Include all valid addresses"); if (settings.getPoolFilterSetting() == PoolFilterSetting.EVERYTHING || settings.getPoolFilterSetting() == PoolFilterSetting.VALID_ONLY || settings.getPoolFilterSetting() == PoolFilterSetting.VALID_OR_DIFFERENT_FORMAT || settings.getPoolFilterSetting() == PoolFilterSetting.VALID_OR_INVALID) { valid.setSelected(true); } dfb.append(valid); dfb.nextLine(); differentFormat = new JCheckBox("Include all valid addresses with different formatting"); if (settings.getPoolFilterSetting() == PoolFilterSetting.EVERYTHING || settings.getPoolFilterSetting() == PoolFilterSetting.INVALID_OR_DIFFERENT_FORMAT || settings.getPoolFilterSetting() == PoolFilterSetting.VALID_OR_DIFFERENT_FORMAT || settings.getPoolFilterSetting() == PoolFilterSetting.DIFFERENT_FORMAT_ONLY) { differentFormat.setSelected(true); } dfb.append(differentFormat); dfb.nextLine(); invalid = new JCheckBox("Include all invalid addresses"); if (settings.getPoolFilterSetting() == PoolFilterSetting.EVERYTHING || settings.getPoolFilterSetting() == PoolFilterSetting.INVALID_OR_DIFFERENT_FORMAT || settings.getPoolFilterSetting() == PoolFilterSetting.VALID_OR_INVALID || settings.getPoolFilterSetting() == PoolFilterSetting.INVALID_ONLY) { invalid.setSelected(true); } dfb.append(invalid); dfb.nextLine(); dfb.appendUnrelatedComponentsGapRow(); dfb.nextLine(); dfb.append("Auto-correction Setting"); ButtonGroup autoValidateButtonGroup = new ButtonGroup(); dfb.nextLine(); avcNothingRB = new JRadioButton(AutoValidateSetting.NOTHING.getLongDescription()); if (settings.getAutoValidateSetting() == AutoValidateSetting.NOTHING) { avcNothingRB.setSelected(true); } dfb.append(avcNothingRB); autoValidateButtonGroup.add(avcNothingRB); dfb.nextLine(); avcSerpCorrectableRB = new JRadioButton(AutoValidateSetting.SERP_CORRECTABLE.getLongDescription()); if (settings.getAutoValidateSetting() == AutoValidateSetting.SERP_CORRECTABLE) { avcSerpCorrectableRB.setSelected(true); } dfb.append(avcSerpCorrectableRB); autoValidateButtonGroup.add(avcSerpCorrectableRB); dfb.nextLine(); avcEverythingWithOneSuggestionRB = new JRadioButton( AutoValidateSetting.EVERYTHING_WITH_ONE_SUGGESTION.getLongDescription()); if (settings.getAutoValidateSetting() == AutoValidateSetting.EVERYTHING_WITH_ONE_SUGGESTION) { avcEverythingWithOneSuggestionRB.setSelected(true); } dfb.append(avcEverythingWithOneSuggestionRB); autoValidateButtonGroup.add(avcEverythingWithOneSuggestionRB); dfb.nextLine(); avcEverythingWithSuggestionRB = new JRadioButton( AutoValidateSetting.EVERYTHING_WITH_SUGGESTION.getLongDescription()); if (settings.getAutoValidateSetting() == AutoValidateSetting.EVERYTHING_WITH_SUGGESTION) { avcEverythingWithSuggestionRB.setSelected(true); } dfb.append(avcEverythingWithSuggestionRB); autoValidateButtonGroup.add(avcEverythingWithSuggestionRB); panel = dfb.getPanel(); }
From source file:ca.sqlpower.matchmaker.swingui.MatchMakerSplashScreen.java
License:Open Source License
private void buildUI() { JPanel spgLogo = new JPanel(new LogoLayout()); spgLogo.add(//from w ww . j a va2 s . c o m new JLabel("<html><div align='center'>SQL Power Group Inc.<br>http://www.sqlpower.ca/</div></html>", JLabel.CENTER)); spgLogo.add(new JLabel(new ImageIcon(getClass().getResource("/icons/sqlpower_alpha_gradient.png")))); spgLogo.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { try { BrowserUtil.launch(SPSUtils.SQLP_URL); } catch (IOException e1) { throw new RuntimeException("Could not launch web browser with URL " + SPSUtils.SQLP_URL, e1); } } }); JLabel mmLogo = new JLabel(SPSUtils.createIcon("dqguru_huge", "DQguru Huge Icon"), JLabel.CENTER); JLabel title = new JLabel("<html>" + "SQL Power DQguru " + MatchMakerVersion.APP_VERSION + "</html>", JLabel.CENTER); Font f = title.getFont(); Font newf = new Font(f.getName(), f.getStyle(), (int) (f.getSize() * 1.5)); title.setFont(newf); FormLayout layout = new FormLayout("4dlu, pref:grow, 4dlu "); int rowCount = 0; PanelBuilder pb = new PanelBuilder(layout); CellConstraints c = new CellConstraints(); pb.appendRow(new RowSpec("10px:grow")); rowCount++; pb.appendRow(new RowSpec("pref")); rowCount++; pb.add(mmLogo, c.xy(2, rowCount)); pb.appendRow(new RowSpec("15px")); rowCount++; pb.appendRow(new RowSpec("pref")); rowCount++; pb.add(title, c.xy(2, rowCount)); pb.appendRow(new RowSpec("40px")); rowCount++; pb.appendRow(new RowSpec("fill:pref")); rowCount++; pb.appendRow(new RowSpec("40px")); rowCount++; pb.appendRow(new RowSpec("fill:pref")); rowCount++; pb.add(spgLogo, c.xy(2, rowCount)); rowCount++; pb.appendRow(new RowSpec("10px:grow")); rowCount++; splashScreen = pb.getPanel(); }
From source file:ca.sqlpower.matchmaker.swingui.munge.ConcatMungeComponent.java
License:Open Source License
@Override protected JPanel buildUI() { ConcatMungeStep step = (ConcatMungeStep) getStep(); addInputButton = new JButton(new AddInputAction("Add Input")); removeInputsButton = new JButton(new RemoveUnusedInputAction("Clean Up")); delimiterField = new JTextField(step.getDelimiter()); delimiterField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { doStuff();/*from w w w.ja v a 2 s . c om*/ } public void removeUpdate(DocumentEvent e) { doStuff(); } public void changedUpdate(DocumentEvent e) { doStuff(); } private void doStuff() { ConcatMungeStep step = (ConcatMungeStep) getStep(); step.setDelimiter(delimiterField.getText()); } }); FormLayout fl = new FormLayout("pref:grow,4dlu,pref:grow"); DefaultFormBuilder b = new DefaultFormBuilder(fl); b.append("Delimiter", delimiterField); b.append(ButtonBarFactory.buildAddRemoveBar(addInputButton, removeInputsButton), 3); content = b.getPanel(); return content; }
From source file:ca.sqlpower.matchmaker.swingui.munge.CSVWriterMungeComponent.java
License:Open Source License
@Override protected JPanel buildUI() { final CSVWriterMungeStep step = (CSVWriterMungeStep) getStep(); addInputButton = new JButton(new AddInputAction("Add Input")); removeInputsButton = new JButton(new RemoveUnusedInputAction("Clean Up")); separatorField = new JTextField(step.getSeparator() + "", 1); getHandler().addValidateObject(separatorField, new CharacterValidator("separator")); separatorField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { doStuff();//from w ww. j a v a2 s.c o m } public void insertUpdate(DocumentEvent e) { doStuff(); } public void removeUpdate(DocumentEvent e) { doStuff(); } private void doStuff() { if (separatorField.getText().length() == 1) { step.setSeparator(separatorField.getText().charAt(0)); } } }); quoteField = new JTextField(step.getQuoteChar() + "", 1); getHandler().addValidateObject(quoteField, new CharacterValidator("quote")); quoteField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { doStuff(); } public void insertUpdate(DocumentEvent e) { doStuff(); } public void removeUpdate(DocumentEvent e) { doStuff(); } private void doStuff() { if (quoteField.getText().length() == 1) { step.setQuoteChar(quoteField.getText().charAt(0)); } } }); escapeField = new JTextField(step.getEscapeChar() + "", 1); getHandler().addValidateObject(escapeField, new CharacterValidator("escape")); escapeField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { doStuff(); } public void insertUpdate(DocumentEvent e) { doStuff(); } public void removeUpdate(DocumentEvent e) { doStuff(); } private void doStuff() { if (escapeField.getText().length() == 1) { step.setEscapeChar(escapeField.getText().charAt(0)); } } }); filePathField = new JTextField(step.getFilePath(), 20); getHandler().addValidateObject(filePathField, new FileNameValidator("Output")); filePathField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { doStuff(); } public void insertUpdate(DocumentEvent e) { doStuff(); } public void removeUpdate(DocumentEvent e) { doStuff(); } private void doStuff() { step.setFilePath(filePathField.getText()); } }); fileChooser = new JFileChooser(); fileButton = new JButton(new AbstractAction("...") { public void actionPerformed(ActionEvent e) { if (fileChooser.showSaveDialog(CSVWriterMungeComponent.this) == JFileChooser.APPROVE_OPTION) { filePathField.setText(fileChooser.getSelectedFile().getAbsolutePath()); } } }); clrFileCheckBox = new JCheckBox(); clrFileCheckBox.setSelected(step.getClearFile()); clrFileCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { step.setClearFile(clrFileCheckBox.isSelected()); } }); FormLayout fl = new FormLayout("pref:grow,4dlu,pref:grow"); DefaultFormBuilder b = new DefaultFormBuilder(fl); b.append(filePathField, fileButton); b.append("Separator", separatorField); b.append("Quote Char", quoteField); b.append("Escape Char", escapeField); b.append("Clear File", clrFileCheckBox); b.append(ButtonBarFactory.buildAddRemoveBar(addInputButton, removeInputsButton), 3); content = b.getPanel(); return content; }
From source file:ca.sqlpower.matchmaker.swingui.munge.DateConstantMungeComponent.java
License:Open Source License
@Override protected JPanel buildUI() { final DateConstantMungeStep step = (DateConstantMungeStep) getStep(); Date value;//from ww w . j av a 2 s.c om try { value = ((DateConstantMungeStep) getStep()).getValueAsDate(); } catch (ParseException e) { SPSUtils.showExceptionDialogNoReport(getPen(), "Error Loading munge step", e); value = null; } if (value == null) { value = new Date(); ((DateConstantMungeStep) getStep()).setValueAsDate(value); } dc = new SpinnerDateModel(value, null, null, Calendar.SECOND); date = new JSpinner(dc); editor = new JSpinner.DateEditor(date, getFormateString()); date.setEditor(editor); getHandler().addValidateObject(date, new DateValidator()); dc.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { setDate(); } }); retNull = new JCheckBox("Return null"); retNull.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { boolean b = retNull.isSelected(); if (b) { useCurrent.setEnabled(false); useCurrent.setSelected(false); date.setEnabled(false); opts.setEnabled(!retNull.isSelected()); } else if (!useCurrent.isSelected()) { date.setEnabled(true); useCurrent.setEnabled(true); opts.setEnabled(!retNull.isSelected()); } step.setReturnNull(b); } }); useCurrent = new JCheckBox("Use Time of engine run"); useCurrent.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { boolean b = useCurrent.isSelected(); if (b) { retNull.setEnabled(false); retNull.setSelected(false); date.setEnabled(false); opts.setEnabled(!retNull.isSelected()); } else if (!retNull.isSelected()) { date.setEnabled(true); opts.setEnabled(!retNull.isSelected()); retNull.setEnabled(true); } step.setUseCurrentTime(b); } }); retNull.setSelected(step.isReturnNull()); if (retNull.isSelected()) { useCurrent.setEnabled(false); } useCurrent.setSelected(step.getUseCurrentTime()); if (useCurrent.isSelected()) { retNull.setEnabled(false); } date.setEnabled(!retNull.isSelected() && !useCurrent.isSelected()); opts = new JComboBox(DateConstantMungeStep.FORMAT.toArray()); opts.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { step.setDateFormat((String) opts.getSelectedItem()); date.setEditor(new JSpinner.DateEditor(date, getFormateString())); } }); opts.setSelectedItem(step.getDateFormat()); opts.setEnabled(!retNull.isSelected()); FormLayout layout = new FormLayout("pref,4dlu,pref:grow"); DefaultFormBuilder fb = new DefaultFormBuilder(layout); fb.append("Value:", date); fb.append("Format", opts); fb.append("", retNull); fb.append("", useCurrent); return fb.getPanel(); }