List of usage examples for com.jgoodies.forms.layout FormLayout FormLayout
public FormLayout(ColumnSpec[] colSpecs, RowSpec[] rowSpecs)
From source file:ca.sqlpower.matchmaker.swingui.MergeColumnRuleEditor.java
License:Open Source License
private void buildUI() { String comboMinSize = "fill:min(pref;" + (new JComboBox().getMinimumSize().width) + "px):grow"; FormLayout layout = new FormLayout( "4dlu,pref,4dlu," + comboMinSize + ",4dlu,pref,4dlu," + comboMinSize + ",4dlu,pref,4dlu", // columns "10dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,fill:40dlu:grow,4dlu,pref,4dlu"); // rows // 1 2 3 4 5 6 7 8 9 10 11 // status cat schema table index del dup table button bar PanelBuilder pb;/*from w ww.j av a 2 s . co m*/ JPanel p = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout); pb = new PanelBuilder(layout, p); CellConstraints cc = new CellConstraints(); int row = 2; pb.add(status, cc.xy(4, row)); row += 2; pb.add(new JLabel("Catalog:"), cc.xy(2, row, "r,c")); JTextField temp = new JTextField(mmo.getSourceTable().getCatalogName()); temp.setEditable(false); pb.add(temp, cc.xyw(4, row, 5, "f,c")); row += 2; pb.add(new JLabel("Schema:"), cc.xy(2, row, "r,c")); temp = new JTextField(mmo.getSourceTable().getSchemaName()); temp.setEditable(false); pb.add(temp, cc.xyw(4, row, 5, "f,c")); row += 2; pb.add(new JLabel("Table Name:"), cc.xy(2, row, "r,c")); temp = new JTextField(mmo.getTableName()); temp.setEditable(false); pb.add(temp, cc.xyw(4, row, 5, "f,c")); row += 2; pb.add(new JLabel("Index Name:"), cc.xy(2, row, "r,c")); String indexName = ""; if (mmo.getTableIndex() == null) { indexName = ""; } else { indexName = mmo.getTableIndex().getName(); } temp = new JTextField(indexName); temp.setEditable(false); pb.add(temp, cc.xyw(4, row, 5, "f,c")); row += 2; if (!mmo.isSourceMergeRule()) { pb.add(new JLabel("Parent Table:"), cc.xy(2, row, "l,c")); pb.add(parentMergeRule, cc.xy(4, row, "f,c")); if (mmo.getParentMergeRule() != null) { parentMergeRule.setSelectedItem(mmo.getParentMergeRule().getSourceTable()); } else { parentMergeRule.setSelectedItem(null); } pb.add(new JLabel("Merge Action:"), cc.xy(6, row, "r,c")); pb.add(childMergeAction, cc.xy(8, row, "f,c")); childMergeAction.setSelectedItem(mmo.getChildMergeAction()); } row += 2; pb.add(new JScrollPane(ruleTable), cc.xyw(4, row, 5, "f,f")); row += 2; pb.add(new JButton(saveAction), cc.xyw(4, row, 5, "c,c")); panel = pb.getPanel(); }
From source file:ca.sqlpower.matchmaker.swingui.MergeTableRuleEditor.java
License:Open Source License
private void buildUI() { FormLayout layout = new FormLayout( "4dlu,14dlu,4dlu,fill:min(pref;" + 3 * (new JComboBox().getMinimumSize().width) + "px):grow, 4dlu,pref,4dlu", // columns "10dlu,pref,12dlu,pref,4dlu,fill:40dlu:grow,4dlu,pref,4dlu"); // rows // 1 2 3 4 5 6 7 8 9 10 PanelBuilder pb;/* ww w . j a v a 2 s. c o m*/ JPanel p = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout); pb = new PanelBuilder(layout, p); CellConstraints cc = new CellConstraints(); int row = 2; pb.add(new JLabel("List of table merge rules:"), cc.xy(4, row)); row += 2; pb.add(new JLabel("Merge Rules:"), cc.xy(4, row, "l,t")); row += 2; mergeRulesScrollPane = new JScrollPane(mergeRulesTable); pb.add(mergeRulesScrollPane, cc.xy(4, row, "f,f")); ButtonStackBuilder bsb = new ButtonStackBuilder(); bsb.addGridded(new JButton(moveUp)); bsb.addRelatedGap(); bsb.addGridded(new JButton(moveDown)); pb.add(bsb.getPanel(), cc.xy(6, row, "c,c")); ButtonBarBuilder bbb = new ButtonBarBuilder(); //new actions for delete and save should be extracted and be put into its own file. bbb.addGridded(new JButton(new NewMergeRuleAction(swingSession, mmo))); bbb.addRelatedGap(); bbb.addGridded(new JButton(new DeriveRelatedRulesAction(swingSession, mmo))); bbb.addRelatedGap(); bbb.addGridded(new JButton(deleteRule)); bbb.addRelatedGap(); bbb.addGridded(new JButton(saveAction)); row += 2; pb.add(bbb.getPanel(), cc.xy(4, row, "c,c")); panel = pb.getPanel(); moveDown.setEnabled(false); moveUp.setEnabled(false); deleteRule.setEnabled(false); }
From source file:ca.sqlpower.matchmaker.swingui.MMODuplicateValidatorDemo.java
License:Open Source License
private void buildUI() { statusLabel = new StatusComponent(); form = new FormValidationHandler(statusLabel); field = new JTextField(); d = new JDialog(); items = new JComboBox(); area = new JTextArea(); area.setEditable(false);/* w ww . j av a2 s.com*/ create = new JButton(new AbstractAction("Create") { public void actionPerformed(ActionEvent e) { StubMatchMakerObject child = new StubMatchMakerObject(field.getText()); child.setAllowChildren(false); obj.addChild(child); field.setText(""); refreshTextArea(); } }); exit = new JButton(new AbstractAction("Exit") { public void actionPerformed(ActionEvent e) { d.setVisible(false); d.dispose(); } }); FormLayout layout = new FormLayout("4dlu,pref,4dlu,fill:50dlu:grow,4dlu,pref,4dlu", "4dlu,pref,4dlu,pref,4dlu,fill:80dlu:grow, 4dlu, pref,4dlu"); PanelBuilder pb = new PanelBuilder(layout); CellConstraints cc = new CellConstraints(); pb.add(statusLabel, cc.xyw(2, 2, 6)); pb.add(new JLabel("Project Name"), cc.xy(2, 4)); pb.add(field, cc.xy(4, 4)); pb.add(create, cc.xy(6, 4)); pb.add(new JScrollPane(area), cc.xyw(2, 6, 5)); pb.add(exit, cc.xy(6, 8)); Validator v1 = new MMODuplicateValidator(obj, null, "Cannot have Duplicate Name", new MatchMakerTranslateGroup()); form.addValidateObject(field, v1); d.getContentPane().add(pb.getPanel()); }
From source file:ca.sqlpower.matchmaker.swingui.munge.AbstractMungeComponent.java
License:Open Source License
/** * Creates a AbstractMungeComponent for the given step that will be in the munge pen. * Sets the background and border colours to given colours. * //from w w w. j a va 2 s . co m * @param step The step connected to the UI * @param border The colour for the border around the rectangle * @param bg The background colour to the rectangle */ public AbstractMungeComponent(MungeStep step, FormValidationHandler handler, MatchMakerSession s) { if (step == null) throw new NullPointerException("Null step"); try { step.refresh(logger); } catch (Exception e1) { throw new RuntimeException("Failed to refresh step " + step.getName(), e1); } this.session = (MatchMakerSwingSession) s; this.handler = handler; this.step = step; setVisible(true); setBackground(normalBackground); autoScrollTimer = new Timer(AUTO_SCROLL_TIME, new AbstractAction() { public void actionPerformed(ActionEvent e) { logger.debug("TIMER GO!!!"); getPen().autoscroll(autoScrollPoint, AbstractMungeComponent.this); } }); autoScrollTimer.stop(); autoScrollTimer.setRepeats(true); dropNibIndex = -1; ToolTipManager toolTipManager = ToolTipManager.sharedInstance(); toolTipManager.setInitialDelay(0); bustGhost(); mungeComKeyListener = new MungeComponentKeyListener(); addKeyListener(mungeComKeyListener); step.addSPListener(new StepEventHandler()); setName(step.getName()); resizeBorders(); setOpaque(false); setFocusable(true); Dimension ps = getPreferredSize(); setBounds(0, 0, ps.width, ps.height); DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout("pref", "pref, pref, fill:pref, pref"), this); setBackground(Color.GREEN); inputNames = new JPanel(); inputNames.setOpaque(false); inputNames.setLayout(new FlowLayout()); inputLabels = new CoolJLabel[step.getMSOInputs().size()]; for (int x = 0; x < inputLabels.length; x++) { InputDescriptor id = step.getInputDescriptor(x); inputLabels[x] = new CoolJLabel(id.getName(), id.getType()); inputLabels[x].collapse(); inputNames.add(inputLabels[x]); inputLabels[x].setOpaque(false); } setInputShowNames(false); builder.append(inputNames); builder.nextLine(); if (isExpanded() && inputNames.isVisible()) { inputNames.setVisible(true); } else { inputNames.setVisible(false); } revalidate(); outputNames = new JPanel(); outputNames.setOpaque(false); outputNames.setLayout(new FlowLayout()); outputLabels = new CoolJLabel[step.getChildren(MungeStepOutput.class).size()]; for (int x = 0; x < outputLabels.length; x++) { MungeStepOutput out = step.getChildren(MungeStepOutput.class).get(x); outputLabels[x] = new CoolJLabel(out.getName(), out.getType()); outputLabels[x].collapse(); outputNames.add(outputLabels[x]); outputLabels[x].setOpaque(false); } setOutputShowNames(false); JPanel tmp = new JPanel(new FlowLayout()); tmp.setBackground(Color.BLUE); tmp.add(new JLabel(step.getName())); hideShow = new JButton(new HideShowAction()); hideShow.setIcon(EXPOSE_OFF); setupOpaqueComponents(); content = buildUI(); //returning null will prevent the +/- button form showing up if (content != null) { deOpaquify(content); JToolBar tb = new JToolBar(); hideShow.setBorder(null); hideShow.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { hideShow.setIcon(EXPOSE_ON); hideShow.setBorder(null); } public void mouseExited(MouseEvent e) { hideShow.setIcon(EXPOSE_OFF); hideShow.setBorder(null); } }); tb.setBorder(null); tb.add(hideShow); tb.setFloatable(false); tmp.add(tb); } builder.append(tmp); builder.nextLine(); if (content != null) { builder.append(content); } builder.nextLine(); builder.append(outputNames); addMouseListener(new MungeComponentMouseListener()); addMouseMotionListener(new MungeComponentMouseMoveListener()); addComponentListener(new ComponentListener() { public void componentHidden(ComponentEvent e) { } public void componentMoved(ComponentEvent e) { getParent().repaint(); } public void componentResized(ComponentEvent e) { getParent().repaint(); } public void componentShown(ComponentEvent e) { } }); addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { //if it is being deleted if (getParent() != null) { getParent().repaint(); MatchMakerTreeModel treeModel = (MatchMakerTreeModel) session.getTree().getModel(); TreePath menuPath = treeModel.getPathForNode(getStep()); session.getTree().setSelectionPath(menuPath); } } public void focusLost(FocusEvent e) { if (getParent() != null) { getParent().repaint(); } if (autoScrollTimer.isRunning()) { autoScrollTimer.stop(); } } }); setOpaque(false); tmp.setOpaque(false); // Note, this does not take care of the content panel; only the basic // stuff added here in the constructor (most importantly, the +/- button) deOpaquify(this); deOpaquify(inputNames); setDefaults(); }
From source file:ca.sqlpower.matchmaker.swingui.munge.AddressCorrectionMungeComponent.java
License:Open Source License
@Override protected JPanel buildUI() { if (addressDataRequired != null) { addressDataRequired.removeMouseListener(HyperlinkTextSelectedListener); }/* ww w . j av a2s. c o m*/ if (HyperlinkTextSelectedListener == null) { HyperlinkTextSelectedListener = new MouseAdapter() { public void mouseEntered(MouseEvent e) { setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } public void mousePressed(MouseEvent e) { try { BrowserUtil.launch(addressDataURL); } catch (IOException e1) { SPSUtils.showExceptionDialogNoReport(AddressCorrectionMungeComponent.this, "Invalid URL", e1); } } public void mouseExited(MouseEvent e) { setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }; } DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout("center:pref:grow", "fill:pref, pref")); addressDataURL = "http://www.sqlpower.ca/page/dqguru_address_data"; addressDataRequired = new JLabel( "<html> <p align =\"center\">You cannot continue without having a valid address database to compare against!<br> Please set the path to your address database in the User Preferences... <br> To purchase one, click on the following link:<br> <a href=\"" + addressDataURL + "\">http://www.sqlpower.ca/page/dqguru_address_data</a><html>"); addressDataRequired.addMouseListener(HyperlinkTextSelectedListener); builder.add(addressDataRequired); builder.nextLine(); addressDataRequired.setVisible(false); if (!((AddressCorrectionMungeStep) getStep()).doesDatabaseExist()) { addressDataRequired.setVisible(true); } showAllButton = new JButton(new HideShowAllLabelsAction("Show All", true, true, true)); hideAllButton = new JButton(new HideShowAllLabelsAction("Hide All", true, true, false)); JPanel content = new JPanel(new FlowLayout()); content.add(showAllButton); content.add(hideAllButton); builder.append(content); setOutputShowNames(true); setInputShowNames(true); return builder.getPanel(); }
From source file:ca.sqlpower.matchmaker.swingui.munge.BooleanToStringMungeComponent.java
License:Open Source License
@Override protected JPanel buildUI() { final BooleanToStringMungeStep step = (BooleanToStringMungeStep) getStep(); trueValue = new JTextField(step.getTrueString()); trueValue.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { doStuff();/*w w w . ja v a 2s .co m*/ } public void removeUpdate(DocumentEvent e) { doStuff(); } public void changedUpdate(DocumentEvent e) { doStuff(); } private void doStuff() { step.setTrueString(trueValue.getText()); } }); falseValue = new JTextField(step.getFalseString()); falseValue.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { doStuff(); } public void removeUpdate(DocumentEvent e) { doStuff(); } public void changedUpdate(DocumentEvent e) { doStuff(); } private void doStuff() { step.setFalseString(falseValue.getText()); } }); FormLayout layout = new FormLayout("4dlu,pref,4dlu,fill:pref:grow,4dlu", // columns "4dlu,pref,4dlu,pref,4dlu"); // rows CellConstraints cc = new CellConstraints(); JPanel content = new JPanel(layout); content.add(new JLabel("True:"), cc.xy(2, 2)); content.add(trueValue, cc.xy(4, 2)); content.add(new JLabel("False:"), cc.xy(2, 4)); content.add(falseValue, cc.xy(4, 4)); return content; }
From source file:ca.sqlpower.matchmaker.swingui.munge.DateToStringMungeComponent.java
License:Open Source License
@Override protected JPanel buildUI() { JPanel content = new JPanel( new FormLayout("4dlu,pref,4dlu,pref,4dlu", "4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu")); final DateToStringMungeStep temp = (DateToStringMungeStep) getStep(); final String[] dateFormats = DateToStringMungeStep.DATE_FORMATS.toArray(new String[] {}); final String[] timeFormats = DateToStringMungeStep.TIME_FORMATS.toArray(new String[] {}); dateFormat = new JComboBox(dateFormats); dateFormat.setSelectedItem(temp.getDateFormat()); dateFormat.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { temp.setDateFormat((String) e.getItem()); format.setText(temp.getFormat()); }/*w w w . j av a 2 s . c om*/ }); timeFormat = new JComboBox(timeFormats); timeFormat.setSelectedItem(temp.getTimeFormat()); timeFormat.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { temp.setTimeFormat((String) e.getItem()); format.setText(temp.getFormat()); } }); format = new JTextField(temp.getFormat()); format.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { doStuff(); } public void removeUpdate(DocumentEvent e) { doStuff(); } public void changedUpdate(DocumentEvent e) { doStuff(); } private void doStuff() { temp.setFormat(format.getText()); if (getHandler().getWorstValidationStatus().getStatus() == Status.OK) { SimpleDateFormat sdf = new SimpleDateFormat(temp.getFormat()); sample.setText(sdf.format(DateToStringMungeComponent.SAMPLE_DATE)); } } }); SimpleDateFormat sdf = new SimpleDateFormat(temp.getFormat()); sample = new JTextField(sdf.format(DateToStringMungeComponent.SAMPLE_DATE)); sample.setEditable(false); getHandler().addValidateObject(format, new DateFormatPatternValidator()); CellConstraints cc = new CellConstraints(); int row = 2; content.add(new JLabel("Example: "), cc.xy(2, row)); content.add(sample, cc.xy(4, row)); row += 2; content.add(new JLabel("Date Format: "), cc.xy(2, row)); content.add(dateFormat, cc.xy(4, row)); row += 2; content.add(new JLabel("Time Format: "), cc.xy(2, row)); content.add(timeFormat, cc.xy(4, row)); row += 2; content.add(new JLabel("Format: "), cc.xy(2, row)); content.add(format, cc.xy(4, row)); return content; }
From source file:ca.sqlpower.matchmaker.swingui.munge.GoogleAddressLookupMungeComponent.java
License:Open Source License
@Override protected JPanel buildUI() { GoogleAddressLookup temp = (GoogleAddressLookup) getStep(); url = new JTextField(temp.getGoogleGeocoderURL()); url.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { doStuff();//from w ww . j ava 2 s . co m } public void removeUpdate(DocumentEvent e) { doStuff(); } public void changedUpdate(DocumentEvent e) { doStuff(); } private void doStuff() { GoogleAddressLookup step = (GoogleAddressLookup) getStep(); step.setGoogleGeocoderURL(url.getText()); } }); key = new JTextField(temp.getGoogleMapsApiKey()); key.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { doStuff(); } public void removeUpdate(DocumentEvent e) { doStuff(); } public void changedUpdate(DocumentEvent e) { doStuff(); } private void doStuff() { GoogleAddressLookup step = (GoogleAddressLookup) getStep(); step.setGoogleMapsApiKey(key.getText()); } }); rateLimit = new JSpinner(new SpinnerNumberModel(0.0, 0.0, 10.0, 0.1)); rateLimit.setValue(temp.getRateLimit()); JPanel mainContent = new JPanel(); DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout("fill:pref:grow", "fill:pref, pref"), mainContent); FormLayout layout = new FormLayout("4dlu,pref,4dlu,fill:pref:grow,4dlu", // columns "4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu"); // rows CellConstraints cc = new CellConstraints(); JPanel content = new JPanel(layout); content.add(new JLabel("URL:"), cc.xy(2, 2)); content.add(url, cc.xy(4, 2)); content.add(new JLabel("Google Maps API Key:"), cc.xy(2, 4)); content.add(key, cc.xy(4, 4)); content.add(new JLabel("Rate Limit (s):"), cc.xy(2, 6)); content.add(rateLimit, cc.xy(4, 6)); JPanel subPanel = new JPanel(new FlowLayout()); showAllButton = new JButton(new HideShowAllLabelsAction("Show All", false, true, true)); hideAllButton = new JButton(new HideShowAllLabelsAction("Hide All", false, true, false)); subPanel.add(showAllButton); subPanel.add(hideAllButton); builder.append(content); builder.nextLine(); builder.append(subPanel); return mainContent; }
From source file:ca.sqlpower.matchmaker.swingui.munge.MungePreviewPanel.java
License:Open Source License
public MungePreviewPanel(MungeProcess process, MungePen pen) { this.mungePen = pen; previewer = new MungePreviewer(process); previewer.addPreviewListener(listener); FormLayout layout = new FormLayout("pref, 4dlu, pref", "pref"); panel = new JPanel(layout) { @Override//from w ww . ja v a2s .c o m public void paint(Graphics g) { AbstractMungeComponent lastModifiedMungeComp = mungePen .getMungeComponent(getLastModifiedOrSelectedStep()); if (lastModifiedMungeComp != null) { Rectangle stepBounds = lastModifiedMungeComp.getBounds(); setBounds(stepBounds.x + stepBounds.width, stepBounds.y, getPreferredSize().width, getPreferredSize().height); } g.setColor(getBackground()); g.fillRoundRect(0, 0, getWidth(), getHeight(), BORDER_WIDTH * 3, BORDER_WIDTH * 3); super.paint(g); } }; CellConstraints cc = new CellConstraints(); inputTable = new JTable(new MSOTableModel("Input", 0, 0)); outputTable = new JTable(new MSOTableModel("Output", 0, 0)); JPanel inputPanel = new JPanel(new BorderLayout()); inputPanel.add(inputTable, BorderLayout.CENTER); inputPanel.add(inputTable.getTableHeader(), BorderLayout.NORTH); panel.add(inputPanel, cc.xy(1, 1)); JPanel outputPanel = new JPanel(new BorderLayout()); outputPanel.add(outputTable, BorderLayout.CENTER); outputPanel.add(outputTable.getTableHeader(), BorderLayout.NORTH); panel.add(outputPanel, cc.xy(3, 1)); panel.setOpaque(false); panel.setBackground(new Color(0x99333333, true)); panel.setForeground(Color.WHITE); panel.setBorder(BorderFactory.createEmptyBorder(BORDER_WIDTH, BORDER_WIDTH, BORDER_WIDTH, BORDER_WIDTH)); inputPanel.setOpaque(false); inputPanel.setBackground(null); inputPanel.setForeground(null); inputTable.setOpaque(false); inputTable.setBackground(null); inputTable.setForeground(null); inputTable.getTableHeader().setOpaque(false); inputTable.getTableHeader().setBackground(null); inputTable.getTableHeader().setForeground(null); outputPanel.setOpaque(false); outputPanel.setBackground(null); outputPanel.setForeground(null); outputTable.setOpaque(false); outputTable.setBackground(null); outputTable.setForeground(null); outputTable.getTableHeader().setOpaque(false); outputTable.getTableHeader().setBackground(null); outputTable.getTableHeader().setForeground(null); inputTable.getTableHeader().setBorder(new LineBorder(null)); inputTable.setBorder(new LineBorder(null)); inputTable.getTableHeader().setDefaultRenderer(new TableCellRenderer() { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { return table.getCellRenderer(0, column).getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } }); outputTable.getTableHeader().setBorder(new LineBorder(null)); outputTable.setBorder(new LineBorder(null)); outputTable.getTableHeader().setDefaultRenderer(new TableCellRenderer() { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { return table.getCellRenderer(0, column).getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } }); enablePreviewCheckBox = new JCheckBox(new AbstractAction("Show Preview") { public void actionPerformed(ActionEvent e) { enablePreview(enablePreviewCheckBox.isSelected()); } }); enablePreview(false); engineListener = new EngineListener() { public void engineStopped(EngineEvent e) { enablePreviewCheckBox.setEnabled(true); } public void engineStarted(EngineEvent e) { enablePreviewCheckBox.setEnabled(false); } }; project = process.getParent(); switch (project.getType()) { case FIND_DUPES: MatchEngineImpl matchingEngine = project.getMatchingEngine(); matchingEngine.addEngineListener(engineListener); if (matchingEngine.isStarted() && !matchingEngine.isFinished()) enablePreviewCheckBox.setEnabled(false); MergeEngineImpl mergingEngine = project.getMergingEngine(); mergingEngine.addEngineListener(engineListener); if (mergingEngine.isStarted() && !mergingEngine.isFinished()) enablePreviewCheckBox.setEnabled(false); break; case CLEANSE: CleanseEngineImpl cleansingEngine = project.getCleansingEngine(); cleansingEngine.addEngineListener(engineListener); cleansingEngine.addEngineListener(engineListener); if (cleansingEngine.isStarted() && !cleansingEngine.isFinished()) enablePreviewCheckBox.setEnabled(false); break; case ADDRESS_CORRECTION: AddressCorrectionEngine addressCorrectionEngine = project.getAddressCorrectionEngine(); addressCorrectionEngine.addEngineListener(engineListener); if (addressCorrectionEngine.isStarted() && !addressCorrectionEngine.isFinished()) enablePreviewCheckBox.setEnabled(false); AddressCorrectionEngine addressCommittingEngine = project.getAddressCommittingEngine(); addressCommittingEngine.addEngineListener(engineListener); if (addressCommittingEngine.isStarted() && !addressCommittingEngine.isFinished()) enablePreviewCheckBox.setEnabled(false); break; } }
From source file:ca.sqlpower.matchmaker.swingui.munge.SortWordsMungeComponent.java
License:Open Source License
@Override protected JPanel buildUI() { final SortWordsMungeStep step = getStep(); useRegex = new JCheckBox("Use Regular Expressions"); useRegex.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { step.setRegex(useRegex.isSelected()); }//from ww w . j ava 2 s .c o m }); useRegex.setSelected(step.isRegex()); caseSensitive = new JCheckBox("Case Sensitive"); caseSensitive.setSelected(step.isCaseSensitive()); caseSensitive.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { step.setCaseSensitive(caseSensitive.isSelected()); } }); delimiter = new JTextField(step.getDelimiter()); delimiter.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { doStuff(); } public void removeUpdate(DocumentEvent e) { doStuff(); } public void changedUpdate(DocumentEvent e) { doStuff(); } private void doStuff() { step.setDelimiter(delimiter.getText()); } }); RegexValidator validator = new RegexValidator(); getHandler().addValidateObject(delimiter, useRegex, validator, true, ""); resultDelimiter = new JTextField(step.getResultDelim()); resultDelimiter.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { doStuff(); } public void removeUpdate(DocumentEvent e) { doStuff(); } public void changedUpdate(DocumentEvent e) { doStuff(); } private void doStuff() { step.setResultDelim(resultDelimiter.getText()); } }); FormLayout layout = new FormLayout("4dlu,pref,4dlu,fill:pref:grow,4dlu", // columns "4dlu,pref,4dlu,pref,4dlu,pref,4dlu"); // rows CellConstraints cc = new CellConstraints(); JPanel content = new JPanel(layout); content.add(new JLabel("Delimiter:"), cc.xy(2, 2)); content.add(delimiter, cc.xy(4, 2)); content.add(new JLabel("Result Delim:"), cc.xy(2, 4)); content.add(resultDelimiter, cc.xy(4, 4)); JPanel bottom = new JPanel(new GridLayout(2, 1)); bottom.add(useRegex); bottom.add(caseSensitive); content.add(bottom, cc.xyw(2, 6, 3, "c,f")); return content; }