List of usage examples for com.jgoodies.forms.debug FormDebugPanel FormDebugPanel
public FormDebugPanel(FormLayout layout)
From source file:ca.sqlpower.architect.swingui.CompareDMFrame.java
License:Open Source License
public JComponent mainFrame() { FormLayout layout = new FormLayout( "4dlu,fill:min(150dlu;default):grow, 6dlu, fill:min(150dlu;default):grow, 4dlu", // columns //$NON-NLS-1$ " min(300dlu;default), 6dlu, min(300dlu;default), 6dlu, min(300dlu;default), 3dlu, fill:min(300dlu;default):grow, 3dlu, 20dlu,6dlu,20dlu"); // rows //$NON-NLS-1$ CellConstraints cc = new CellConstraints(); JLabel titleLabel = new JLabel(title); Font oldFont = titleLabel.getFont(); Font titleFont = new Font(oldFont.getName(), oldFont.getStyle(), oldFont.getSize() * 2); titleLabel.setFont(titleFont);/* www. j a v a 2s . c o m*/ JLabel subTitleLabel = new JLabel(whatTheHeckIsGoingOn); leftOutputArea = new JTextPane(); leftOutputArea.setMargin(new Insets(6, 10, 4, 6)); leftOutputArea.setDocument(sourceOutputText); leftOutputArea.setEditable(false); JPanel comparePanel = new JPanel(new GridLayout(1, 2)); JScrollPane sp = new JScrollPane(comparePanel); int lineHeight = 16; try { FontMetrics fm = leftOutputArea.getFontMetrics(leftOutputArea.getFont()); lineHeight = fm.getHeight() + 2; } catch (Exception e) { lineHeight = 16; } // If the increments are not set, klicking on the up or down arrow of the scrollbar // will scroll the display by one pixel, which is definitely not what the user wants // by setting unitIncrement to the font's height the display will scroll by approx. one line sp.getVerticalScrollBar().setUnitIncrement(lineHeight); // Clicking in the "empty" area of the scrollbar will scroll by 10 lines sp.getVerticalScrollBar().setBlockIncrement(lineHeight * 10); comparePanel.add(leftOutputArea); Action sourceCopy = new sourceCopyAction(sourceOutputText); Action sourceSave = new AbstractAction() { public void actionPerformed(ActionEvent e) { SPSUtils.saveDocument(CompareDMFrame.this, sourceOutputText, (FileExtensionFilter) SPSUtils.TEXT_FILE_FILTER); } }; CloseAction close = new CloseAction(); close.setDialog(this); SPSUtils.makeJDialogCancellable(this, close); ButtonBarBuilder sourcebbBuilder = new ButtonBarBuilder(); JButton copySource = new JButton(sourceCopy); copySource.setText(Messages.getString("CompareDMFrame.copy")); //$NON-NLS-1$ sourcebbBuilder.addGridded(copySource); sourcebbBuilder.addRelatedGap(); sourcebbBuilder.addGlue(); JButton sourceSaveButton = new JButton(sourceSave); sourceSaveButton.setText(Messages.getString("CompareDMFrame.save")); //$NON-NLS-1$ sourcebbBuilder.addGridded(sourceSaveButton); sourcebbBuilder.addRelatedGap(); sourcebbBuilder.addGlue(); ButtonBarBuilder closeBar = new ButtonBarBuilder(); JButton closeButton = new JButton(close); closeButton.setText(Messages.getString("CompareDMFrame.close")); //$NON-NLS-1$ closeBar.addGridded(closeButton); PanelBuilder pb; layout.setColumnGroups(new int[][] { { 2, 4 } }); JPanel p = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout); pb = new PanelBuilder(layout, p); pb.setDefaultDialogBorder(); rightOutputArea = new JTextPane(); rightOutputArea.setMargin(new Insets(6, 10, 4, 6)); rightOutputArea.setDocument(targetOutputText); rightOutputArea.setEditable(false); comparePanel.add(rightOutputArea); Action targetCopy = new targetCopyAction(targetOutputText); //Sets the target Buttons ButtonBarBuilder targetbbBuilder = new ButtonBarBuilder(); JButton copyTarget = new JButton(targetCopy); copyTarget.setText(Messages.getString("CompareDMFrame.copy")); //$NON-NLS-1$ targetbbBuilder.addGridded(copyTarget); targetbbBuilder.addRelatedGap(); targetbbBuilder.addGlue(); Action targetSaveAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { SPSUtils.saveDocument(CompareDMFrame.this, targetOutputText, (FileExtensionFilter) SPSUtils.TEXT_FILE_FILTER); } }; JButton targetSave = new JButton(targetSaveAction); targetSave.setText(Messages.getString("CompareDMFrame.save")); //$NON-NLS-1$ targetbbBuilder.addGridded(targetSave); targetbbBuilder.addRelatedGap(); targetbbBuilder.addGlue(); getRootPane().setDefaultButton(targetSave); pb.add(titleLabel, cc.xyw(2, 1, 3, "c,c")); //$NON-NLS-1$ pb.add(subTitleLabel, cc.xyw(2, 3, 3, "c,c")); //$NON-NLS-1$ pb.add(new JLabel(Messages.getString("CompareDMFrame.older")), cc.xy(2, 5)); //$NON-NLS-1$ pb.add(new JLabel(Messages.getString("CompareDMFrame.newer")), cc.xy(4, 5)); //$NON-NLS-1$ pb.add(sp, cc.xyw(2, 7, 3)); pb.add(sourcebbBuilder.getPanel(), cc.xy(2, 9, "l,c")); //$NON-NLS-1$ pb.add(targetbbBuilder.getPanel(), cc.xy(4, 9, "r,c")); //$NON-NLS-1$ pb.add(closeBar.getPanel(), cc.xy(4, 11, "r,c")); //$NON-NLS-1$ return pb.getPanel(); }
From source file:ca.sqlpower.architect.swingui.olap.OLAPSchemaManager.java
License:Open Source License
private JPanel createPanel() { FormLayout layout = new FormLayout("6dlu, fill:min(160dlu;default):grow, 6dlu, pref, 6dlu", // columns //$NON-NLS-1$ " 6dlu,10dlu,6dlu,fill:min(180dlu;default):grow,10dlu"); // rows //$NON-NLS-1$ layout.setColumnGroups(new int[][] { { 1, 3, 5 } }); CellConstraints cc = new CellConstraints(); PanelBuilder pb;/*from w w w.ja v a 2 s . c o m*/ JPanel p = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout); pb = new PanelBuilder(layout, p); pb.setDefaultDialogBorder(); pb.add(new JLabel("Available OLAP Schemas"), cc.xy(2, 2)); //$NON-NLS-1$ TableModel tm = new SchemaTableModel(session.getOLAPRootObject()); osessionTable = new JTable(tm); osessionTable.setTableHeader(null); osessionTable.setShowGrid(false); osessionTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); osessionTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { boolean enableActions = getSelectedOSession() != null; removeOLAPSchemaAction.setEnabled(enableActions); editOLAPSchemaAction.setEnabled(enableActions); exportSchemaAction.setEnabled(enableActions); if (evt.getClickCount() == 2) { editOLAPSchemaAction.actionPerformed(null); } } }); JScrollPane sp = new JScrollPane(osessionTable); pb.add(sp, cc.xy(2, 4)); ButtonStackBuilder bsb = new ButtonStackBuilder(); JButton newOLAPSchemaButton = new JButton(new OLAPEditAction(session, null)); newOLAPSchemaButton.setText("New..."); bsb.addGridded(newOLAPSchemaButton); bsb.addRelatedGap(); JButton importOLAPSchemaButton = new JButton(new ImportSchemaAction(session)); importOLAPSchemaButton.setText("Import..."); bsb.addGridded(importOLAPSchemaButton); bsb.addGridded(new JButton(exportSchemaAction)); bsb.addRelatedGap(); bsb.addGridded(new JButton(editOLAPSchemaAction)); bsb.addRelatedGap(); bsb.addGridded(new JButton(removeOLAPSchemaAction)); removeOLAPSchemaAction.setEnabled(false); editOLAPSchemaAction.setEnabled(false); exportSchemaAction.setEnabled(false); bsb.addUnrelatedGap(); bsb.addGridded(new JButton(closeAction)); pb.add(bsb.getPanel(), cc.xy(4, 4)); return pb.getPanel(); }
From source file:ca.sqlpower.architect.swingui.ProfileGraphPanel.java
License:Open Source License
public ProfileGraphPanel(ProfilePanel panel, int rowCount) { this.profilePanel = panel; this.rowCount = rowCount; FormLayout displayLayout = new FormLayout("4dlu, default, 4dlu, 100dlu, 4dlu, fill:default:grow, 4dlu", // columns "4dlu, default, 6dlu"); // rows CellConstraints cc = new CellConstraints(); validResultsPanel = ProfileGraphPanel.logger.isDebugEnabled() ? new FormDebugPanel(displayLayout) : new JPanel(displayLayout); validResultsPanel.setBorder(BorderFactory.createEtchedBorder()); Font bodyFont = validResultsPanel.getFont(); Font titleFont = bodyFont.deriveFont(Font.BOLD, bodyFont.getSize() * 1.25F); title = new JLabel("Column Name"); title.setFont(titleFont);//from w ww .j a v a 2 s. co m PanelBuilder pb = new PanelBuilder(displayLayout, validResultsPanel); pb.add(title, cc.xyw(2, 2, 5)); int row = 4; rowCountDisplay = makeInfoRow(pb, "RowCount", row); row += 2; nullableLabel = makeInfoRow(pb, "Nullable", row); row += 2; nullCountLabel = makeInfoRow(pb, "Null Count", row); row += 2; nullPercentLabel = makeInfoRow(pb, "% Null Records", row); row += 2; minLengthLabel = makeInfoRow(pb, "Minimum Length", row); row += 2; maxLengthLabel = makeInfoRow(pb, "Maximum Length", row); row += 2; uniqueCountLabel = makeInfoRow(pb, "Unique Values", row); row += 2; uniquePercentLabel = makeInfoRow(pb, "% Unique", row); row += 2; minValue = makeInfoRow(pb, "Minimum Value", row); row += 2; maxValue = makeInfoRow(pb, "Maximum Value", row); row += 2; avgValue = makeInfoRow(pb, "Average Value", row); row += 2; freqValueTable = new FreqValueTable(null); freqValueSp = new JScrollPane(freqValueTable); pb.appendRow("fill:10dlu:grow"); pb.appendRow("fill:default:grow"); pb.add(freqValueSp, cc.xyw(2, row + 1, 3)); // Now add something to represent the chart JFreeChart createPieChart = ChartFactory.createPieChart("", new DefaultPieDataset(new DefaultKeyedValues()), false, false, false); chartPanel = new ChartPanel(createPieChart); chartPanel.setPreferredSize(new Dimension(300, 300)); if (panel.getProfileManager().getWorkspaceContainer() instanceof ArchitectSession && ((ArchitectSession) panel.getProfileManager().getWorkspaceContainer()).isEnterpriseSession()) { pb.add(new JLabel("Column Profile Notes"), cc.xy(6, 2)); notesField = new JTextArea(); notesField.setLineWrap(true); notesField.setWrapStyleWord(true); JScrollPane notesScroll = new JScrollPane(notesField); notesScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); notesScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); pb.add(notesScroll, cc.xywh(6, 4, 1, row - 4)); pb.appendRow("fill:4dlu:grow"); pb.appendRow("4dlu"); pb.add(chartPanel, cc.xy(6, row + 1)); } else { pb.appendRow("fill:4dlu:grow"); pb.appendRow("4dlu"); pb.add(chartPanel, cc.xywh(6, 4, 1, row - 2)); } invalidResultsPanel = new JPanel(new BorderLayout()); invalidResultsLabel = new JLabel("No error message yet"); invalidResultsPanel.add(invalidResultsLabel); displayArea = new JPanel(new GridLayout(1, 1)); displayArea.setPreferredSize(validResultsPanel.getPreferredSize()); }
From source file:ca.sqlpower.architect.swingui.ProfilePanel.java
License:Open Source License
private void setup() { progressBar.setVisible(false);// www . j av a 2s . c o m FormLayout controlsLayout = new FormLayout("4dlu,fill:min(150dlu;default):grow, 4dlu", // columns "default, 4dlu, fill:min(200dlu;default):grow,4dlu,default"); // rows CellConstraints cc = new CellConstraints(); setLayout(new BorderLayout()); controlsArea = logger.isDebugEnabled() ? new FormDebugPanel(controlsLayout) : new JPanel(controlsLayout); controlsArea.setLayout(new BoxLayout(controlsArea, BoxLayout.Y_AXIS)); tableSelector = new JComboBox(); tableSelector.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { TableProfileResult tpr = (TableProfileResult) value; StringBuffer buf = new StringBuffer(); if (tpr != null) { buf.append(tpr.getProfiledObject().getName()); buf.append(" ("); DateFormat df = DateFormat.getDateTimeInstance(); buf.append(df.format(new Date(tpr.getCreateStartTime()))); buf.append(")"); } else { buf.append("All"); } return super.getListCellRendererComponent(list, buf.toString(), index, isSelected, cellHasFocus); } }); tableSelector.addActionListener(new ActionListener() { /* * Called when the user selects a table; displays its profile (fast) */ public void actionPerformed(ActionEvent e) { final TableProfileResult tpr = (TableProfileResult) tableSelector.getSelectedItem(); try { List<SQLColumn> columns = new ArrayList<SQLColumn>(); if (tpr == null) { for (TableProfileResult tableProfile : tableModel.getTableResultsToScan()) { for (ColumnProfileResult cpr : tableProfile.getColumnProfileResults()) { columns.add(cpr.getProfiledObject()); } } } else { for (ColumnProfileResult cpr : tpr.getColumnProfileResults()) { SQLColumn column = cpr.getProfiledObject(); columns.add(column); } } SQLColumn selectedColumn = null; if (columnSelector.getSelectedIndex() >= 0) { selectedColumn = (SQLColumn) columnSelector.getSelectedValues()[0]; } columnSelector.setModel(new DefaultComboBoxModel(columns.toArray())); if (columns.size() > 0) { if (selectedColumn != null && columns.contains(selectedColumn)) { columnSelector.setSelectedValue(selectedColumn, true); } else { columnSelector.setSelectedIndex(0); } } } catch (Exception ex) { ASUtils.showExceptionDialogNoReport(ProfilePanel.this, "Error in profile", ex); } } }); columnSelector = new JList(); // TODO maybe someday we can allow the user to compare profiles by removing this... columnSelector.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); columnSelector.addListSelectionListener(new ListSelectionListener() { /* * Called when the user selects a column; gets its profile (fast) */ public void valueChanged(ListSelectionEvent e) { SQLColumn col = (SQLColumn) columnSelector.getSelectedValue(); if (col == null) { logger.debug("Null selection in columnSelector.ListSelectionListener"); return; } for (final ColumnProfileResult pr : tableModel.getResultList()) { SQLColumn column = (SQLColumn) pr.getProfiledObject(); if (col == column) { displayPanel.displayProfile((ColumnProfileResult) pr); break; } } } }); PanelBuilder pb = new PanelBuilder(controlsLayout, controlsArea); pb.setDefaultDialogBorder(); pb.add(tableSelector, cc.xy(2, 1)); pb.add(new JScrollPane(columnSelector), cc.xy(2, 3)); pb.add(progressBar, cc.xy(2, 5)); this.add(controlsArea, BorderLayout.WEST); this.add(displayPanel.getDisplayArea(), BorderLayout.CENTER); }
From source file:ca.sqlpower.architect.swingui.SQLScriptDialog.java
License:Open Source License
private JPanel buildPanel() { FormLayout sqlLayout = new FormLayout("4dlu, min:grow, 4dlu", //columns //$NON-NLS-1$ "pref, 4dlu, pref, 6dlu, fill:300dlu:grow,6dlu, pref, 6dlu, pref"); //rows //$NON-NLS-1$ CellConstraints cc = new CellConstraints(); sqlDoc = new DefaultStyledDocument(); SimpleAttributeSet att = new SimpleAttributeSet(); StyleConstants.setForeground(att, Color.black); for (DDLStatement ddl : statements) { try {// w w w . j ava 2 s . c o m sqlDoc.insertString(sqlDoc.getLength(), ddl.getSQLText() + ddl.getSqlTerminator(), att); } catch (BadLocationException e) { ASUtils.showExceptionDialogNoReport(parent, Messages.getString("SQLScriptDialog.couldNotCreateDocument"), e); //$NON-NLS-1$ logger.error("Could not create document for results", e); //$NON-NLS-1$ } } sqlScriptArea = new JTextPane(); sqlScriptArea.setMargin(new Insets(6, 10, 4, 6)); sqlScriptArea.setDocument(sqlDoc); sqlScriptArea.setEditable(false); sqlScriptArea.setAutoscrolls(true); JScrollPane sp = new JScrollPane(sqlScriptArea); Action copy = new CopyAction(sqlDoc); Action execute = null; execute = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (targetDataSource.get(JDBCDataSource.PL_UID) != null) { new Thread(executeTask).start(); ProgressWatcher.watchProgress(progressBar, executeTask, statusLabel); } else { JOptionPane.showMessageDialog(SQLScriptDialog.this, Messages.getString("SQLScriptDialog.noTargetDb"), //$NON-NLS-1$ Messages.getString("SQLScriptDialog.couldNotExecuteDialogTitle"), //$NON-NLS-1$ JOptionPane.ERROR_MESSAGE); } } }; Action save = new AbstractAction() { public void actionPerformed(ActionEvent e) { logger.info("SQL_FILE_FILTER:" + ((FileExtensionFilter) SPSUtils.SQL_FILE_FILTER).toString()); //$NON-NLS-1$ SPSUtils.saveDocument(parent, sqlDoc, (FileExtensionFilter) SPSUtils.SQL_FILE_FILTER); } }; CloseAction close = new CloseAction(); close.setWhatToClose(this); SPSUtils.makeJDialogCancellable(this, close); ButtonBarBuilder barBuilder = new ButtonBarBuilder(); JButton copyButton = new JButton(copy); copyButton.setText(Messages.getString("SQLScriptDialog.copyOption")); //$NON-NLS-1$ barBuilder.addGridded(copyButton); barBuilder.addRelatedGap(); barBuilder.addGlue(); executeButton = new JButton(execute); executeButton.setText(Messages.getString("SQLScriptDialog.executeOption")); //$NON-NLS-1$ barBuilder.addGridded(executeButton); barBuilder.addRelatedGap(); barBuilder.addGlue(); JButton saveButton = new JButton(save); saveButton.setText(Messages.getString("SQLScriptDialog.saveOption")); //$NON-NLS-1$ barBuilder.addGridded(saveButton); barBuilder.addRelatedGap(); barBuilder.addGlue(); addWindowListener(new CloseWindowAction()); JButton closeButton = new JButton(close); closeButton.setText(Messages.getString("SQLScriptDialog.closeOption")); //$NON-NLS-1$ barBuilder.addGridded(closeButton); getRootPane().setDefaultButton(executeButton); PanelBuilder pb; JPanel panel = logger.isDebugEnabled() ? new FormDebugPanel(sqlLayout) : new JPanel(sqlLayout); pb = new PanelBuilder(sqlLayout, panel); pb.setDefaultDialogBorder(); pb.add(new JLabel(header), cc.xy(2, 1)); // Prevent the user from being able to execute the script if // an invalid target database is selected. if (targetDataSource != null && targetDataSource.get(JDBCDataSource.PL_UID) != null) { pb.add(new JLabel(Messages.getString("SQLScriptDialog.yourTargetDbIs") + targetDataSource.getName()), //$NON-NLS-1$ cc.xy(2, 3)); executeButton.setEnabled(true); } else { pb.add(new JLabel(Messages.getString("SQLScriptDialog.yourTargetDbIsNotConfigured")), cc.xy(2, 3)); executeButton.setEnabled(false); } pb.add(sp, cc.xy(2, 5)); pb.add(barBuilder.getPanel(), cc.xy(2, 7, "c,c")); //$NON-NLS-1$ pb.add(progressBar, cc.xy(2, 9)); return pb.getPanel(); }
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;/* ww w . 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. *//* w w w .j a v a 2s . c om*/ 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 ww w . ja v a 2 s . c o 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. *///from w w w . j a v a2s . 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;/*ww w .j ava 2s . co 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()); }