List of usage examples for com.jgoodies.forms.layout CellConstraints CellConstraints
public CellConstraints()
From source file:ca.sqlpower.matchmaker.swingui.DeriveRelatedRulesPanel.java
License:Open Source License
private JPanel buildUI() { FormLayout layout = new FormLayout("4dlu,fill:pref:grow,4dlu", // columns: 1 2 3 "10dlu,pref:grow,4dlu,pref:grow,4dlu,fill:min(200dlu;pref):grow,4dlu,pref,pref,pref,10dlu"); // rows: 1 2 3 4 5 6 7 8 9 10 11 PanelBuilder pb;/* w ww. j a v a 2 s.c om*/ JPanel panel = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout); pb = new PanelBuilder(layout, panel); CellConstraints cc = new CellConstraints(); pb.add(statusComponent, cc.xy(2, 2)); pb.add(new JLabel("Table: " + DDLUtils.toQualifiedName(project.getSourceTable())), cc.xy(2, 4)); try { sourceTable = project.getSourceTable(); SQLIndex oldIndex = project.getSourceTableIndex(); columnTableModel = new ColumnChooserTableModel(sourceTable, oldIndex, false); columnTable = new EditableJTable(columnTableModel); columnTable.addColumnSelectionInterval(1, 1); TableUtils.fitColumnWidths(columnTable, 10); } catch (SQLObjectException ex) { SPSUtils.showExceptionDialogNoReport(swingSession.getFrame(), "Error in deriving related rules.", ex); } JScrollPane scrollPane = new JScrollPane(columnTable); pb.add(scrollPane, cc.xy(2, 6, "f,f")); deriveByColumnNames = new JCheckBox("Derive by column names", true); pb.add(deriveByColumnNames, cc.xy(2, 8)); deriveByForeignKeyConstraints = new JCheckBox("Derive by foreign key constraints", true); pb.add(deriveByForeignKeyConstraints, cc.xy(2, 9)); pb.add(progressBar, cc.xy(2, 10, "f,f")); return pb.getPanel(); }
From source file:ca.sqlpower.matchmaker.swingui.engine.EngineSettingsPanel.java
License:Open Source License
/** * Builds the UI for this editor pane. This is broken into two parts, * the configuration and output. Configuration is done in this method * while the output section is handled by the EngineOutputPanel and * this method simply lays out the components that class provides. *//*from w w w . ja v a 2 s.c o m*/ private JPanel buildUI() { logger.debug("We are building the UI of an engine settings panel."); if (type == EngineType.ADDRESS_CORRECTION_ENGINE) { expiryDatePane = new JEditorPane(); expiryDatePane.setEditable(false); final AddressDatabase addressDatabase; try { addressDatabase = new AddressDatabase( new File(swingSession.getContext().getAddressCorrectionDataPath())); expiryDate = addressDatabase.getExpiryDate(); expiryDatePane.setText(DateFormat.getDateInstance().format(expiryDate)); } catch (DatabaseException e1) { MMSUtils.showExceptionDialog(parentFrame, "An error occured while loading the Address Correction Data", e1); expiryDatePane.setText("Database missing, expiry date invalid"); } logger.debug("We are adding the listener"); swingSession.getContext().addPreferenceChangeListener(new PreferenceChangeListener() { public void preferenceChange(PreferenceChangeEvent evt) { if (MatchMakerSessionContext.ADDRESS_CORRECTION_DATA_PATH.equals(evt.getKey())) { logger.debug("The new database path is: " + evt.getNewValue()); final AddressDatabase addressDatabase; try { addressDatabase = new AddressDatabase(new File(evt.getNewValue())); expiryDate = addressDatabase.getExpiryDate(); expiryDatePane.setText(DateFormat.getDateInstance().format(expiryDate)); } catch (DatabaseException ex) { MMSUtils.showExceptionDialog(parentFrame, "An error occured while loading the Address Correction Data", ex); expiryDate = null; expiryDatePane.setText("Database missing, expiry date invalid"); } } } }); // handler listens to expiryDatePane so whenever the expiryDatePane's text has been changed, the below method will be called. handler.addValidateObject(expiryDatePane, new Validator() { public ValidateResult validate(Object contents) { if (expiryDate == null) { return ValidateResult.createValidateResult(Status.FAIL, "Address Correction Database is missing. Please reset your Address Correction Data Path in Preferences."); } if (Calendar.getInstance().getTime().after(expiryDate)) { return ValidateResult.createValidateResult(Status.WARN, "Address Correction Database is expired. The results of this engine run cannot be SERP valid."); } return ValidateResult.createValidateResult(Status.OK, ""); } }); } File logFile = engineSettings.getLog(); logFilePath = new JTextField(logFile.getAbsolutePath()); handler.addValidateObject(logFilePath, new FileNameValidator("Log")); browseLogFileAction = new BrowseFileAction(parentFrame, logFilePath); appendToLog = new JCheckBox("Append to old Log File?", engineSettings.getAppendToLog()); recordsToProcess = new JSpinner(new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 100)); if (engineSettings.getProcessCount() != null) { recordsToProcess.setValue(engineSettings.getProcessCount()); } spinnerUpdateManager = new SpinnerUpdateManager(recordsToProcess, engineSettings, "processCount", handler, this, refreshButton); debugMode = new JCheckBox("Debug Mode (Changes will be rolled back)", engineSettings.getDebug()); updaters.add(new CheckBoxModelUpdater(debugMode, "debug")); engineSettings.addSPListener(updaters.get(updaters.size() - 1)); itemListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (((JCheckBox) e.getSource()).isSelected()) { if (type == EngineType.MATCH_ENGINE || type == EngineType.ADDRESS_CORRECTION_ENGINE) { clearMatchPool.setSelected(false); // I've currently disabled the clear match pool option because the match // in debug mode, changes should be rolled back, but if the clearing of the match // pool is rolled back but the engine thinks that it is cleared, it can cause // unique key violations when it tries to insert 'new' matches. But if the engine // is made aware of the rollback, then it would be as if clear match pool wasn't // selected in the first place, so I don't see the point in enabling it in debug mode clearMatchPool.setEnabled(false); } recordsToProcess.setValue(new Integer(1)); engine.setMessageLevel(Level.ALL); messageLevel.setSelectedItem(engine.getMessageLevel()); } else { if (type == EngineType.MATCH_ENGINE || type == EngineType.ADDRESS_CORRECTION_ENGINE) { clearMatchPool.setEnabled(true); } recordsToProcess.setValue(new Integer(0)); } engineSettings.setDebug(debugMode.isSelected()); } }; debugMode.addItemListener(itemListener); if (type == EngineType.MATCH_ENGINE || type == EngineType.ADDRESS_CORRECTION_ENGINE) { if (type == EngineType.MATCH_ENGINE) { clearMatchPool = new JCheckBox("Clear match pool", ((MungeSettings) engineSettings).isClearMatchPool()); } else { clearMatchPool = new JCheckBox("Clear address pool", ((MungeSettings) engineSettings).isClearMatchPool()); } itemListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { ((MungeSettings) engineSettings).setClearMatchPool(clearMatchPool.isSelected()); } }; clearMatchPool.addItemListener(itemListener); updaters.add(new CheckBoxModelUpdater(clearMatchPool, "clearMatchPool")); engineSettings.addSPListener(updaters.get(updaters.size() - 1)); if (debugMode.isSelected()) { clearMatchPool.setSelected(false); // See comment just above about why this is disabled clearMatchPool.setEnabled(false); } } if (engineSettings instanceof MungeSettings) { useBatchExecute = new JCheckBox("Batch execute SQL statments", ((MungeSettings) engineSettings).isUseBatchExecution()); itemListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { ((MungeSettings) engineSettings).setUseBatchExecution(useBatchExecute.isSelected()); } }; useBatchExecute.addItemListener(itemListener); updaters.add(new CheckBoxModelUpdater(useBatchExecute, "useBatchExecution")); engineSettings.addSPListener(updaters.get(updaters.size() - 1)); } if (type == EngineType.ADDRESS_CORRECTION_ENGINE) { autoWriteAutoValidatedAddresses = new JCheckBox("Immediately commit auto-corrected addresses", ((MungeSettings) engineSettings).isAutoWriteAutoValidatedAddresses()); itemListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { ((MungeSettings) engineSettings) .setAutoWriteAutoValidatedAddresses(autoWriteAutoValidatedAddresses.isSelected()); } }; autoWriteAutoValidatedAddresses.addItemListener(itemListener); updaters.add( new CheckBoxModelUpdater(autoWriteAutoValidatedAddresses, "autoWriteAutoValidatedAddresses")); engineSettings.addSPListener(updaters.get(updaters.size() - 1)); } messageLevel = new JComboBox(new Level[] { Level.OFF, Level.FATAL, Level.ERROR, Level.WARN, Level.INFO, Level.DEBUG, Level.ALL }); messageLevel.setSelectedItem(engine.getMessageLevel()); messageLevel.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); setText(value == null ? null : value.toString()); return this; } }); messageLevelActionListener = new AbstractAction() { public void actionPerformed(ActionEvent e) { Level sel = (Level) messageLevel.getSelectedItem(); engine.setMessageLevel(sel); } }; messageLevel.addActionListener(messageLevelActionListener); String rowSpecs; if (type == EngineType.ADDRESS_CORRECTION_ENGINE) { rowSpecs = ADDRESS_CORRECTION_ENGINE_PANEL_ROW_SPECS; } else if (type == EngineType.VALIDATED_ADDRESS_COMMITING_ENGINE) { rowSpecs = ADDRESS_COMMITTING_ENGINE_PANEL_ROW_SPECS; } else if (type == EngineType.MERGE_ENGINE) { rowSpecs = MERGE_ENGINE_PANEL_ROW_SPECS; } else if (type == EngineType.CLEANSE_ENGINE) { rowSpecs = CLEANSE_ENGINE_PANEL_ROW_SPECS; } else { rowSpecs = MATCH_ENGINE_PANEL_ROW_SPECS; } String columnSpecs = "4dlu,fill:pref,4dlu,pref,pref,40dlu,fill:pref:grow,pref,4dlu"; FormLayout layout = new FormLayout(columnSpecs, rowSpecs); PanelBuilder pb; JPanel p = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout); pb = new PanelBuilder(layout, p); CellConstraints cc = new CellConstraints(); pb.add(status, cc.xyw(4, 2, 6, "l,c")); pb.add(refreshButton, cc.xy(6, 2, "l, c")); refreshButton.setVisible(false); int y = 4; pb.add(new JLabel("Log File:"), cc.xy(2, y, "r,f")); pb.add(logFilePath, cc.xyw(4, y, 4, "f,f")); pb.add(new JButton(browseLogFileAction), cc.xy(8, y, "l,f")); y += 2; pb.add(appendToLog, cc.xy(4, y, "l,t")); pb.add(new JButton(new ShowLogFileAction(logFilePath)), cc.xy(5, y, "r,t")); if (type == EngineType.MATCH_ENGINE || type == EngineType.CLEANSE_ENGINE) { y += 2; pb.add(new JLabel("Tranformations to run: "), cc.xy(2, y, "r,t")); final MungeProcessSelectionList selectionButton = new MungeProcessSelectionList(project) { @Override public boolean getValue(MungeProcess mp) { return mp.getActive(); } @Override public void setValue(MungeProcess mp, boolean value) { mp.setActive(value); } }; activeListener = new AbstractPoolingSPListener() { boolean isSelectionListUpdate = false; @Override protected void finalCommitImpl(TransactionEvent e) { if (isSelectionListUpdate) { selectionButton.checkModel(); } } @Override public void propertyChangeImpl(PropertyChangeEvent evt) { logger.debug("checking property with name " + evt.getPropertyName()); if (evt.getPropertyName().equals("active")) { isSelectionListUpdate = true; } else { isSelectionListUpdate = false; } } }; swingSession.getRootNode().addSPListener(activeListener); for (MungeProcess mp : project.getMungeProcesses()) { mp.addSPListener(activeListener); } newMungeProcessListener = new AbstractSPListener() { @Override public void childAdded(SPChildEvent e) { selectionButton.refreshList(); } @Override public void childRemoved(SPChildEvent e) { selectionButton.refreshList(); } }; project.addSPListener(newMungeProcessListener); pb.add(selectionButton, cc.xyw(4, y, 2, "l,c")); } y += 2; pb.add(new JLabel("# of records to process:"), cc.xy(2, y, "r,c")); pb.add(recordsToProcess, cc.xy(4, y, "l,c")); pb.add(new JLabel(" (Set to 0 to process all)"), cc.xy(5, y, "l, c")); if (type == EngineType.ADDRESS_CORRECTION_ENGINE) { pb.add(new JLabel("Address Filter Setting:"), cc.xy(7, y)); } if (engineSettings instanceof MungeSettings) { MungeSettings mungeSettings = (MungeSettings) engineSettings; y += 2; pb.add(useBatchExecute, cc.xyw(4, y, 2, "l,c")); if (type == EngineType.ADDRESS_CORRECTION_ENGINE) { final JLabel poolSettingLabel = new JLabel( mungeSettings.getPoolFilterSetting().getLongDescription()); SPListener poolFilterSettingChangeListener = new SPListener() { public void childAdded(SPChildEvent evt) { // no-op } public void childRemoved(SPChildEvent evt) { // no-op } public void propertyChanged(PropertyChangeEvent evt) { if (evt.getPropertyName() == "poolFilterSetting") { PoolFilterSetting newValue = (PoolFilterSetting) evt.getNewValue(); poolSettingLabel.setText(newValue.getLongDescription()); } } public void transactionStarted(TransactionEvent evt) { // no-op } public void transactionRollback(TransactionEvent evt) { // no-op } public void transactionEnded(TransactionEvent evt) { } }; mungeSettings.addSPListener(poolFilterSettingChangeListener); Font f = poolSettingLabel.getFont(); Font newFont = f.deriveFont(Font.ITALIC); poolSettingLabel.setFont(newFont); pb.add(poolSettingLabel, cc.xy(7, y)); } } if (type == EngineType.ADDRESS_CORRECTION_ENGINE) { y += 2; pb.add(autoWriteAutoValidatedAddresses, cc.xyw(4, y, 2, "l,c")); if (type == EngineType.ADDRESS_CORRECTION_ENGINE) { pb.add(new JLabel("Auto-correction Setting:"), cc.xy(7, y)); } } if (type == EngineType.MATCH_ENGINE || type == EngineType.ADDRESS_CORRECTION_ENGINE) { y += 2; pb.add(clearMatchPool, cc.xyw(4, y, 2, "l,c")); if (type == EngineType.ADDRESS_CORRECTION_ENGINE) { MungeSettings mungeSettings = (MungeSettings) engineSettings; final JLabel autoValidateSettingLabel = new JLabel( ((MungeSettings) engineSettings).getAutoValidateSetting().getLongDescription()); SPListener poolFilterSettingChangeListener = new SPListener() { public void childAdded(SPChildEvent evt) { // no-op } public void childRemoved(SPChildEvent evt) { // no-op } public void propertyChanged(PropertyChangeEvent evt) { if (evt.getPropertyName() == "autoValidateSetting") { AutoValidateSetting newValue = (AutoValidateSetting) evt.getNewValue(); autoValidateSettingLabel.setText(newValue.getLongDescription()); } } public void transactionStarted(TransactionEvent evt) { // no-op } public void transactionRollback(TransactionEvent evt) { // no-op } public void transactionEnded(TransactionEvent evt) { // no-op } }; mungeSettings.addSPListener(poolFilterSettingChangeListener); Font f = autoValidateSettingLabel.getFont(); Font newFont = f.deriveFont(Font.ITALIC); autoValidateSettingLabel.setFont(newFont); pb.add(autoValidateSettingLabel, cc.xy(7, y)); } } y += 2; pb.add(debugMode, cc.xyw(4, y, 2, "l,c")); if (type == EngineType.ADDRESS_CORRECTION_ENGINE) { final AddressValidationSettingsPanel avsp = new AddressValidationSettingsPanel( (MungeSettings) engineSettings); final JDialog validationSettingsDialog = DataEntryPanelBuilder.createDataEntryPanelDialog(avsp, swingSession.getFrame(), "Address Validation Settings", "OK", new Callable<Boolean>() { public Boolean call() throws Exception { boolean returnValue = avsp.applyChanges(); return returnValue; } }, new Callable<Boolean>() { public Boolean call() throws Exception { return true; } }); validationSettingsDialog.setLocationRelativeTo(pb.getPanel()); JButton addressValidationSettings = new JButton(new AbstractAction("Validation Settings...") { public void actionPerformed(ActionEvent e) { validationSettingsDialog.setVisible(true); } }); pb.add(addressValidationSettings, cc.xy(7, y, "l,c")); } y += 2; pb.add(new JLabel("Message Level:"), cc.xy(2, y, "r,t")); pb.add(messageLevel, cc.xy(4, y, "l,t")); abortButton = new JButton(new AbstractAction("Abort!") { public void actionPerformed(ActionEvent e) { engine.setCancelled(true); } }); abortButton.setEnabled(false); ButtonBarBuilder bbb = new ButtonBarBuilder(); bbb.addFixed(new JButton(new SaveAction())); bbb.addRelatedGap(); bbb.addFixed(new JButton(new ShowCommandAction(parentFrame, this, engine))); bbb.addRelatedGap(); bbb.addFixed(new JButton(runEngineAction)); bbb.addRelatedGap(); bbb.addFixed(abortButton); y += 2; pb.add(bbb.getPanel(), cc.xyw(2, y, 7, "r,c")); y += 2; pb.add(engineOutputPanel.getProgressBar(), cc.xyw(2, y, 7)); y += 2; pb.add(engineOutputPanel.getOutputComponent(), cc.xyw(2, y, 7)); y += 2; pb.add(engineOutputPanel.getButtonBar(), cc.xyw(2, y, 7)); refreshRunActionStatus(); return pb.getPanel(); }
From source file:ca.sqlpower.matchmaker.swingui.engine.MungeProcessSelectionList.java
License:Open Source License
/** * Builds and returns the popup menu for choosing the munge processes. *///from w w w . j ava 2 s .co m private void buildPopupMenu() { if (mps == null) { mps = new ArrayList<MungeProcess>(); } else { mps.clear(); } for (MungeProcess mp : project.getMungeProcesses()) { mps.add(mp); } popupMenu = new JPopupMenu("Choose Processes"); popupMenu.setBorder(BorderFactory.createRaisedBevelBorder()); final JButton selectAll = new JButton("Select All"); selectAll.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { processesList.setSelectionInterval(0, mps.size() - 1); } }); final JButton unselectAll = new JButton(new AbstractAction("Unselect All") { public void actionPerformed(ActionEvent e) { processesList.clearSelection(); } }); final JButton close = new JButton(new AbstractAction("OK") { public void actionPerformed(ActionEvent e) { popupMenu.setVisible(false); if (closeAction != null) { closeAction.run(); } } }); FormLayout layout = new FormLayout("10dlu,pref,10dlu", "4dlu,pref,4dlu,pref,4dlu,pref,4dlu"); JPanel menu = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout); JPanel top = new JPanel(new FlowLayout()); top.add(selectAll); top.add(unselectAll); CellConstraints cc = new CellConstraints(); int row = 2; menu.add(top, cc.xy(2, row)); row += 2; Collections.sort(mps, new MungeProcessPriorityComparator()); processesList = new JList(mps.toArray()); fireEvents = false; setIndices(); fireEvents = true; processesList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (fireEvents) applyChanges(); } }); processesPane = new JScrollPane(processesList); processesPane.setPreferredSize(new Dimension(160, 100)); menu.add(processesPane, cc.xy(2, row)); row += 2; JPanel tmp = new JPanel(new FlowLayout()); tmp.add(close); menu.add(tmp, cc.xy(2, row)); popupMenu.add(menu); setPopupButtonText(); }
From source file:ca.sqlpower.matchmaker.swingui.engine.ShowCommandAction.java
License:Open Source License
/** * Tells the editor to save its changes, then asks the engine for its command line. * Displays the resulting command line to the user in a pop-up dialog. */// ww w. j av a 2 s . c o m public void actionPerformed(ActionEvent e) { final String cmd = engine.createCommandLine(); final JDialog d = new JDialog(parent, "DQguru Engine Command Line"); FormLayout layout = new FormLayout("4dlu,fill:pref:grow,4dlu", // columns "4dlu,fill:pref:grow,4dlu,pref,4dlu"); // rows // 1 2 3 4 5 PanelBuilder pb; JPanel p = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout); pb = new PanelBuilder(layout, p); CellConstraints cc = new CellConstraints(); final JTextArea cmdText = new JTextArea(15, 60); cmdText.setText(cmd); cmdText.setEditable(false); cmdText.setWrapStyleWord(true); cmdText.setLineWrap(true); pb.add(new JScrollPane(cmdText), cc.xy(2, 2, "f,f")); ButtonBarBuilder bbBuilder = new ButtonBarBuilder(); Action saveAsAction = new AbstractAction("Save As...") { public void actionPerformed(ActionEvent e) { SPSUtils.saveDocument(d, cmdText.getDocument(), (FileExtensionFilter) SPSUtils.BATCH_FILE_FILTER); } }; JButton saveAsButton = new JButton(saveAsAction); bbBuilder.addGridded(saveAsButton); bbBuilder.addRelatedGap(); JButton copyButton = new JButton(new AbstractAction("Copy to Clipboard") { public void actionPerformed(ActionEvent e) { StringSelection selection = new StringSelection(cmdText.getText()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(selection, selection); } }); bbBuilder.addGridded(copyButton); bbBuilder.addRelatedGap(); bbBuilder.addGlue(); JButton cancelButton = new JButton(new AbstractAction() { public void actionPerformed(ActionEvent e) { d.setVisible(false); } }); cancelButton.setText("Close"); bbBuilder.addGridded(cancelButton); pb.add(bbBuilder.getPanel(), cc.xy(2, 4)); d.add(pb.getPanel()); SPSUtils.makeJDialogCancellable(d, null); d.pack(); d.setLocationRelativeTo(parent); d.setVisible(true); }
From source file:ca.sqlpower.matchmaker.swingui.FilterMakerDialog.java
License:Open Source License
public void buildUI() { FormLayout layout = new FormLayout( "4dlu,fill:min(70dlu;default), 4dlu, fill:150dlu:grow,4dlu, min(60dlu;default),4dlu", "10dlu,pref,4dlu,pref,4dlu,pref,4dlu,20dlu,4dlu,fill:60dlu:grow,10dlu,pref,10dlu"); CellConstraints cc = new CellConstraints(); PanelBuilder pb;//from ww w . j av a 2s. c o m JPanel p = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout); pb = new PanelBuilder(layout, p); columnName = new JComboBox(new ColumnComboBoxModel(projectSourceTable)); comparisonOperator = new JComboBox(); pasteButton = new JButton(pasteAction); andButton = new JButton(andAction); andButton.setSize(new Dimension(1, 1)); orButton = new JButton(orAction); orButton.setSize(new Dimension(1, 1)); notButton = new JButton(notAction); notButton.setSize(new Dimension(1, 1)); testButton = new JButton(testAction); clearButton = new JButton(clearAction); okButton = new JButton(okAction); cancelButton = new JButton(cancelAction); filterText = new JTextArea(); setFilterTextContent(returnText); pb.add(new JLabel("Duplicate1:"), cc.xy(2, 2, "l,c")); pb.add(columnName, cc.xy(4, 2, "f,c")); pb.add(new JLabel("Comparison Operator:"), cc.xy(2, 4, "l,c")); pb.add(comparisonOperator, cc.xy(4, 4)); pb.add(new JLabel("Duplicate2:"), cc.xy(2, 6, "l,c")); //If trueForTextArea is true, initiailize and use JTextField //if false, use a JComboBox and fill the dropdown with columns of the table if (trueForTextField) { conditionTextField = new JTextField(); pb.add(conditionTextField, cc.xy(4, 6)); } else { columnName2 = new JComboBox(new ColumnComboBoxModel(projectSourceTable)); pb.add(columnName2, cc.xy(4, 6)); } pb.add(pasteButton, cc.xy(6, 6, "r,c")); ButtonBarBuilder syntaxBar = new ButtonBarBuilder(); syntaxBar.addGridded(andButton); syntaxBar.addRelatedGap(); syntaxBar.addGridded(orButton); syntaxBar.addRelatedGap(); syntaxBar.addGridded(notButton); syntaxBar.addRelatedGap(); pb.add(syntaxBar.getPanel(), cc.xyw(2, 8, 3)); pb.add(new JTextAreaUndoWrapper(filterText), cc.xyw(2, 10, 5, "f,f")); ButtonBarBuilder bottomButtons = new ButtonBarBuilder(); bottomButtons.addGridded(testButton); bottomButtons.addRelatedGap(); bottomButtons.addGlue(); bottomButtons.addGridded(clearButton); bottomButtons.addRelatedGap(); bottomButtons.addGlue(); bottomButtons.addGridded(okButton); bottomButtons.addRelatedGap(); bottomButtons.addGlue(); bottomButtons.addGridded(cancelButton); bottomButtons.addRelatedGap(); bottomButtons.addGlue(); pb.add(bottomButtons.getPanel(), cc.xyw(2, 12, 5, "f,f")); setupOperatorDropdown(); getContentPane().add(pb.getPanel()); }
From source file:ca.sqlpower.matchmaker.swingui.FolderEditor.java
License:Open Source License
private void buildUI() { folderName.setName("Folder Name"); folderDesc.setName("Folder Description"); JButton saveButton = new JButton(saveAction); FormLayout layout = new FormLayout("4dlu,pref,4dlu,pref,4dlu,pref,4dlu", // columns "10dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,10dlu"); // rows // 1 2 3 4 5 6 7 8 9 PanelBuilder pb;/* w w w . j ava 2s .c o m*/ JPanel p = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout); pb = new PanelBuilder(layout, p); CellConstraints cc = new CellConstraints(); pb.add(status, cc.xy(4, 2, "l,c")); pb.add(refreshButton, cc.xy(6, 2, "l, c")); refreshButton.setVisible(false); pb.add(new JLabel("Folder Name:"), cc.xy(2, 4, "r,c")); pb.add(new JLabel("Description:"), cc.xy(2, 6, "r,c")); pb.add(folderName, cc.xy(4, 4, "l,c")); pb.add(new JScrollPane(folderDesc), cc.xy(4, 6, "l,c")); pb.add(saveButton, cc.xyw(2, 8, 3, "c,c")); panel = pb.getPanel(); }
From source file:ca.sqlpower.matchmaker.swingui.MatchMakerIndexBuilder.java
License:Open Source License
public MatchMakerIndexBuilder(final SQLTable table, final MutableComboBoxModel indexModel, final MatchMakerSwingSession swingSession) throws SQLObjectException { this.table = table; this.indexModel = indexModel; this.swingSession = swingSession; final SQLIndex oldIndex = (SQLIndex) indexModel.getSelectedItem(); if (oldIndex != null && table.getIndexByName(oldIndex.getName()) == null) { oldName = oldIndex.getName();//from w ww . java 2 s . c om } else { for (int i = 0;; i++) { oldName = table.getName() + "_UPK" + (i == 0 ? "" : String.valueOf(i)); if (table.getIndexByName(oldName) == null) break; } } columnChooserTableModel = new ColumnChooserTableModel(table, oldIndex, true); final EditableJTable columntable = new EditableJTable(columnChooserTableModel); columntable.addColumnSelectionInterval(1, 1); TableUtils.fitColumnWidths(columntable, 15); FormLayout layout = new FormLayout("4dlu,fill:pref:grow,4dlu", //column 1 2 3 "10dlu,pref:grow,4dlu,pref:grow,4dlu,pref:grow,10dlu,fill:min(200dlu;pref):grow,4dlu"); //row 1 2 3 4 5 6 7 8 9 10 11 panel = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout); PanelBuilder pb = new PanelBuilder(layout, panel); CellConstraints cc = new CellConstraints(); statusComponent = new StatusComponent(); pb.add(statusComponent, cc.xy(2, 2)); pb.add(new JLabel("Table: " + DDLUtils.toQualifiedName(table)), cc.xy(2, 4)); indexName = new JTextField(oldName, 15); pb.add(indexName, cc.xy(2, 6)); JScrollPane scrollPane = new JScrollPane(columntable); pb.add(scrollPane, cc.xy(2, 8, "f,f")); validationHandler = new FormValidationHandler(statusComponent); validationHandler.addValidateObject(indexName, new RegExValidator("[a-z_][a-z0-9_]*", "Index name must be a valid SQL identifier", false)); }
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 ww w . j a v a2 s . co 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.MatchResultVisualizer.java
License:Open Source License
public MatchResultVisualizer(Project project, MatchMakerSwingSession session) throws SQLException, SQLObjectException { super(session, project.getMatchPool()); this.project = project; this.session = session; this.pool = project.getMatchPool(); if (!project.doesSourceTableExist() || !project.verifySourceTableStructure()) { String errorText = "The DQguru has detected changes in the source table structure.\n" + "Your project will require modifications before the engines can run properly.\n" + "The DQguru can automatically modify the project but the changes may not be reversible.\n" + "Would you like the DQguru to modify the project now?"; int response = JOptionPane.showOptionDialog(session.getFrame(), errorText, "Source Table Changed", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[] { "Fix Now", "Not Now" }, "Fix Now"); if (response == JOptionPane.YES_OPTION) { try { SQLDatabase db = project.getSourceTable().getParentDatabase(); db.refresh();/* ww w . java 2 s . c o m*/ } catch (Exception ex1) { MMSUtils.showExceptionDialog(getPanel(), "Failed to fix project!", ex1); } } } pool.clearRecords(); pool.find(displayColumns); FormLayout topLayout = new FormLayout("pref", "pref, pref"); JPanel topPanel = new JPanel(topLayout); PanelBuilder pb = new PanelBuilder(topLayout, topPanel); CellConstraints cc = new CellConstraints(); JPanel buttonPanel = new JPanel(new GridLayout(8, 1)); buttonPanel.add(new JButton(chooseDisplayedValueAction)); selectionButton = new MungeProcessSelectionList(project) { @Override public boolean getValue(MungeProcess mp) { return mp.isValidate(); } @Override public void setValue(MungeProcess mp, boolean value) { mp.setValidate(value); } }; selectionButton.setCloseAction(new Runnable() { public void run() { graph.setSelectedNode(null); graph.setFocusedNode(null); pool.clearRecords(); pool.clearCache(); try { pool.find(displayColumns); } catch (SQLObjectException ex) { MMSUtils.showExceptionDialog(getPanel(), ex.getMessage(), ex); } catch (SQLException sqlEx) { MMSUtils.showExceptionDialog(getPanel(), sqlEx.getMessage(), sqlEx); } ((DefaultGraphLayoutCache) graph.getLayoutCache()).clearNodes(); updateAutoMatchComboBox(); doAutoLayout(); graph.repaint(); } }); buttonPanel.add(selectionButton); buttonPanel.add(new JButton(resetPoolAction)); resetClusterButton = new JButton(resetClusterAction); resetClusterButton.setEnabled(selectedNode != null); buttonPanel.add(resetClusterButton); JPanel limitPanel = new JPanel(new GridLayout(1, 2)); limitPanel.add(new JLabel("# of clusters to view: ")); limitField = new JTextField(20); limitPanel.add(limitField); buttonPanel.add(limitPanel); refreshButton = new JButton(refreshAction); buttonPanel.add(refreshButton); JPanel setPanel = new JPanel(new GridLayout(1, 2)); previousSet = new JButton(new AbstractAction("Previous Set") { @Override public void actionPerformed(ActionEvent arg0) { pool.setLimit(Integer.parseInt(limitField.getText())); int limit = pool.getLimit(); int n = pool.getCurrentMatchNumber(); if (n < limit) { n = 0; } else { n = n - limit; } try { pool.setCurrentMatchNumber(n); pool.clearRecords(); pool.find(displayColumns); setViewLabelText(); refreshGraph(); } catch (SQLException ex) { throw new RuntimeException(ex); } catch (SQLObjectException ex) { throw new RuntimeException(ex); } } }); if (pool.getLimit() == 0) { previousSet.setEnabled(false); } setPanel.add(previousSet); nextSet = new JButton(new AbstractAction("Next Set") { @Override public void actionPerformed(ActionEvent arg0) { pool.setLimit(Integer.parseInt(limitField.getText())); int limit = pool.getLimit(); int n = pool.getCurrentMatchNumber(); n += limit; try { pool.setCurrentMatchNumber(n); pool.clearRecords(); pool.find(displayColumns); setViewLabelText(); refreshGraph(); } catch (SQLException ex) { throw new RuntimeException(ex); } catch (SQLObjectException ex) { throw new RuntimeException(ex); } } }); setPanel.add(nextSet); buttonPanel.add(setPanel); viewLabel = new JLabel(); setViewLabelText(); buttonPanel.add(viewLabel); buttonPanel.setPreferredSize(new Dimension(350, 200)); String prefNodePath = "ca/sqlpower/matchmaker/projectSettings/$" + project.getUUID() + "/matchValidation"; matchValidationPrefs = Preferences.userRoot().node(prefNodePath); try { final Preferences displayColumnPrefs = matchValidationPrefs.node("displayColumns"); String[] keys = displayColumnPrefs.keys(); for (String key : keys) { SQLColumn column = project.getSourceTable().getColumnByName(key); if (column != null) { displayColumns.add(column); } } Collections.sort(displayColumns, new Comparator<SQLColumn>() { public int compare(SQLColumn o1, SQLColumn o2) { int o1Index = displayColumnPrefs.getInt(o1.getName(), -1); int o2Index = displayColumnPrefs.getInt(o2.getName(), -1); if (o1Index < o2Index) return -1; if (o1Index > o2Index) return 1; return 0; } }); } catch (BackingStoreException e) { logger.error("Error loading preferred display values for graph. Defaulting to primary key values", e); displayColumns.clear(); } try { shownColumns = new ArrayList<SQLColumn>(); final Preferences shownColumnPrefs = matchValidationPrefs.node("shownColumns"); String[] keys = shownColumnPrefs.keys(); if (keys.length == 0) { shownColumns = null; } else { for (String key : keys) { SQLColumn column = project.getSourceTable().getColumnByName(key); if (column != null) { shownColumns.add(column); } } Collections.sort(shownColumns, new Comparator<SQLColumn>() { public int compare(SQLColumn o1, SQLColumn o2) { int o1Index = shownColumnPrefs.getInt(o1.getName(), -1); int o2Index = shownColumnPrefs.getInt(o2.getName(), -1); if (o1Index < o2Index) return -1; if (o1Index > o2Index) return 1; return 0; } }); } } catch (BackingStoreException e) { logger.error("Error loading preferred display columns for table. Defaulting to all columns", e); shownColumns = null; } for (PotentialMatchRecord pmr : pool.getPotentialMatchRecords()) { updaterListener = new AbstractSPListener() { @Override public void propertyChanged(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("master") || evt.getPropertyName().equals("matchStatus")) { graph.repaint(); } } }; pmr.addSPListener(updaterListener); } graphModel = new MatchPoolGraphModel(pool); graph = new GraphViewer<SourceTableRecord, PotentialMatchRecord>(graphModel); graph.setNodeRenderer(new SourceTableNodeRenderer()); graph.setEdgeRenderer(new PotentialMatchEdgeRenderer(graph)); graph.addSelectionListener(selectionListener); JPanel autoMatchPanel = new JPanel(new FlowLayout()); mungeProcessComboBox = new JComboBox(); mungeProcessComboBox.setRenderer(new MatchMakerObjectComboBoxCellRenderer()); autoMatchButton = new JButton(new AutoMatchAction(graph.getModel(), session)); autoMatchPanel.add(autoMatchButton); updateAutoMatchComboBox(); autoMatchPanel.add(new JLabel(":")); autoMatchPanel.add(mungeProcessComboBox); pb.add(buttonPanel, cc.xy(1, 1)); limitField.setText(pool.getLimit() + ""); pb.add(autoMatchPanel, cc.xy(1, 2)); doAutoLayout(); JPanel graphPanel = new JPanel(new BorderLayout()); graphPanel.add(pb.getPanel(), BorderLayout.NORTH); graphPanel.add(new JScrollPane(graph), BorderLayout.CENTER); recordViewerPanel.add(SourceTableRecordViewer.getNoNodeSelectedLabel()); final JScrollPane recordViewerScrollPane = new JScrollPane(recordViewerPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); recordViewerScrollPane.getHorizontalScrollBar().setBlockIncrement(100); recordViewerScrollPane.getHorizontalScrollBar().setUnitIncrement(15); recordViewerScrollPane.getVerticalScrollBar().setBlockIncrement(100); recordViewerScrollPane.getVerticalScrollBar().setUnitIncrement(15); recordViewerScrollPane.setColumnHeaderView(recordViewerColumnHeader); recordViewerScrollPane.setRowHeaderView(recordViewerRowHeader); recordViewerScrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, recordViewerCornerPanel); // put it all together JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, graphPanel, recordViewerScrollPane); JPanel panel = new JPanel(new BorderLayout(12, 12)); panel.add(splitPane, BorderLayout.CENTER); super.setPanel(panel); }
From source file:ca.sqlpower.matchmaker.swingui.MatchValidationStatus.java
License:Open Source License
/** * Returns a panel that displays all the status information *//*from w w w .j a v a 2 s.co m*/ private JPanel buildUI() { RowSetModel rsm = null; try { rsm = new RowSetModel(getMatchStats()); MatchStatsTableModel tableModel = new MatchStatsTableModel(rsm); status.setModel(tableModel); SQLTable resultTable = project.getResultTable(); status.setName(DDLUtils.toQualifiedName(resultTable.getCatalogName(), resultTable.getSchemaName(), resultTable.getName())); } catch (SQLException e1) { MMSUtils.showExceptionDialog(getPanel(), "Unknown SQL Error", e1); } FormLayout layout = new FormLayout("10dlu,fill:pref:grow, 10dlu", // 1 2 3 "10dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,10dlu,fill:pref:grow,4dlu,pref,4dlu"); // 1 2 3 4 5 6 7 8 9 10 11 12 13 PanelBuilder pb; JPanel p = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout); pb = new PanelBuilder(layout, p); CellConstraints cc = new CellConstraints(); pb.add(new JLabel("Project: " + project.getName()), cc.xy(2, 6, "l,c")); pb.add(new JScrollPane(status), cc.xy(2, 10)); JButton save = new JButton(new AbstractAction("Save") { public void actionPerformed(ActionEvent e) { new JTableExporter(getPanel(), status); } }); ButtonBarBuilder bb1 = new ButtonBarBuilder(); bb1.addRelatedGap(); bb1.addGridded(save); bb1.addRelatedGap(); pb.add(bb1.getPanel(), cc.xy(2, 12)); return pb.getPanel(); }