List of usage examples for com.jgoodies.forms.layout CellConstraints xy
public CellConstraints xy(int col, int row)
Examples:
cc.xy(1, 1); cc.xy(1, 3);
From source file:ca.sqlpower.matchmaker.swingui.address.AddressValidationEntryPanel.java
License:Open Source License
private void buildUI() { DefaultFormBuilder builder = new DefaultFormBuilder( new FormLayout("fill:pref:grow,4dlu,fill:pref", "pref,4dlu,pref,4dlu,fill:pref:grow"), panel); builder.setDefaultDialogBorder();//w ww. j ava2s .com CellConstraints cc = new CellConstraints(); try { final Address address1; logger.debug("ADDRESS BEFORE PARSING IS : " + addressResult.getOutputAddress()); address1 = Address.parse(addressResult.getOutputAddress().getAddress(), addressResult.getOutputAddress().getMunicipality(), addressResult.getOutputAddress().getProvince(), addressResult.getOutputAddress().getPostalCode(), addressResult.getOutputAddress().getCountry(), addressDatabase); logger.debug("ADDRESS AFTER PARSING IS : " + address1); logger.debug("The output address is not empty."); logger.debug("The non-empty address is: " + address1); this.addressValidator = new AddressValidator(addressDatabase, address1); JButton saveButton = new JButton("Save"); selectedAddressLabel = new AddressLabel(addressResult.getOutputAddress(), null, true, addressValidator.isAddressValid()); selectedAddressLabel.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("currentAddress")) { // update the suggestionList Address address = (Address) evt.getNewValue(); if (address.getType() == null) { //unparsed address, needs to be parsed, This could also be a failed to parse address, won't hurt to try parsing again try { address = Address.parse(address.getAddress(), address.getMunicipality(), address.getProvince(), address.getPostalCode(), address.getCountry(), addressDatabase); } catch (RecognitionException e) { MMSUtils.showExceptionDialog(panel, "There was an error while trying to parse this address", e); } catch (DatabaseException e) { MMSUtils.showExceptionDialog(panel, "There was a database error while trying to parse this address", e); } } addressValidator = new AddressValidator(addressDatabase, address); suggestionList.setModel(new JList(addressValidator.getSuggestions().toArray()).getModel()); selectedAddressLabel.setAddressValid(addressValidator.isAddressValid()); updateProblemDetails(); save(); } } }); selectedAddressLabel.setFont(selectedAddressLabel.getFont() .deriveFont((float) (selectedAddressLabel.getFont().getSize() + 3))); JButton revertButton = new JButton("Revert"); revertButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { logger.debug("Revert Address: " + addressResult.toString()); Address address = Address.parse(addressResult.getInputAddress().getUnparsedAddressLine1(), addressResult.getInputAddress().getMunicipality(), addressResult.getInputAddress().getProvince(), addressResult.getInputAddress().getPostalCode(), addressResult.getInputAddress().getCountry(), addressDatabase); addressResult.setOutputAddress(selectedAddressLabel.getCurrentAddress()); selectedAddressLabel.setCurrentAddress(address); } catch (RecognitionException e1) { e1.printStackTrace(); } catch (DatabaseException e1) { throw new RuntimeException("A database exception occurred while parsing the address" + e1); } } }); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { save(); } }); // undoButton = new JButton("Undo"); // redoButton = new JButton("Redo"); JLabel suggestLabel = new JLabel("Suggestions:"); suggestLabel.setFont(suggestLabel.getFont().deriveFont(Font.BOLD)); problemsBuilder = new DefaultFormBuilder(new FormLayout("fill:pref:grow")); updateProblemDetails(); suggestionList = new JList(addressValidator.getSuggestions().toArray()); logger.debug("There are " + addressValidator.getSuggestions().size() + " suggestions."); suggestionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); suggestionList.setCellRenderer(new AddressListCellRenderer(address1, false)); suggestionList.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { logger.debug("Mouse Clicked on suggestion list " + ((JList) e.getSource()).getSelectedValue()); final Address selected = (Address) ((JList) e.getSource()).getSelectedValue(); if (selected != null) { //XXX:This does not update the model currently selectedAddressLabel.setCurrentAddress(selected); } } }); JScrollPane scrollList = new JScrollPane(suggestionList); scrollList.setPreferredSize(new Dimension(230, 1000)); ButtonBarBuilder bbb = new ButtonBarBuilder(); bbb.addRelatedGap(); bbb.addGridded(revertButton); bbb.addRelatedGap(); bbb.addGridded(saveButton); bbb.addRelatedGap(); builder.add(bbb.getPanel(), cc.xy(1, 1)); builder.add(suggestLabel, cc.xy(3, 1)); builder.add(selectedAddressLabel, cc.xy(1, 3)); builder.add(problemsBuilder.getPanel(), cc.xy(1, 5)); builder.add(scrollList, cc.xywh(3, 3, 1, 3)); } catch (RecognitionException e1) { MMSUtils.showExceptionDialog(getPanel(), "There was an error while trying to parse this address", e1); } catch (DatabaseException e1) { MMSUtils.showExceptionDialog(getPanel(), "There was a database error while trying to parse this address", e1); } }
From source file:ca.sqlpower.matchmaker.swingui.BuildExampleTableDialog.java
License:Open Source License
/** * Builds the gui for this dialog//from w w w .j av a 2 s. c o m */ private void buildGUI() { JPanel panel; if (logger.isDebugEnabled()) { panel = new FormDebugPanel(); } else { panel = new JPanel(); } FormLayout layout = new FormLayout("4dlu,pref,4dlu,pref:grow,4dlu", "4dlu,pref:grow,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu"); panel.setLayout(layout); CellConstraints cc = new CellConstraints(); int row = 2; panel.add(status, cc.xyw(2, row, 3)); row += 2; panel.add(new JLabel("Data Source:"), cc.xy(2, row)); panel.add(sourceChooser.getDataSourceComboBox(), cc.xy(4, row)); row += 2; panel.add(sourceChooser.getCatalogTerm(), cc.xy(2, row)); panel.add(sourceChooser.getCatalogComboBox(), cc.xy(4, row)); row += 2; panel.add(sourceChooser.getSchemaTerm(), cc.xy(2, row)); panel.add(sourceChooser.getSchemaComboBox(), cc.xy(4, row)); row += 2; panel.add(new JLabel("Table:"), cc.xy(2, row)); panel.add(tableName, cc.xy(4, row)); row += 2; panel.add(new JLabel("# of Rows to Insert:"), cc.xy(2, row)); panel.add(rowCounter, cc.xy(4, row)); row += 2; cancel = new JButton(new AbstractAction("Close") { public void actionPerformed(ActionEvent e) { dispose(); } }); create = new JButton(new AbstractAction("Create") { public void actionPerformed(ActionEvent e) { try { generateTableSQL(); } catch (Exception ex) { SPSUtils.showExceptionDialogNoReport(BuildExampleTableDialog.this, "Error while trying to create example table", ex); } } }); panel.add(ButtonBarFactory.buildOKCancelBar(create, cancel), cc.xyw(2, row, 3)); row += 2; progress = new JProgressBar(0, spinnerNumberModel.getNumber().intValue()); popMon = new PopulationMonitor(spinnerNumberModel.getNumber().intValue()); pw = new ProgressWatcher(progress, popMon); panel.add(progress, cc.xyw(2, row, 3)); setContentPane(panel); pack(); }
From source file:ca.sqlpower.matchmaker.swingui.BuildExampleTableDialog.java
License:Open Source License
/** * Creates and shows a dialog with the generated SQL for the * result table in it. The dialog has buttons with actions * that can save, execute, or copy the SQL to the clipboard. *//*ww w. ja v a 2 s. c o m*/ public void generateTableSQL() throws InstantiationException, IllegalAccessException, HeadlessException, SQLException, SQLObjectException, ClassNotFoundException { final DDLGenerator ddlg = DDLUtils.createDDLGenerator(getDataSource()); if (ddlg == null) { JOptionPane.showMessageDialog(swingSession.getFrame(), "Couldn't create DDL Generator for database type\n" + getDataSource().getDriverClass()); return; } ddlg.setTargetCatalog(getTableCatalog()); ddlg.setTargetSchema(getTableSchema()); table = swingSession.getDatabase(getDataSource()).getTableByName(getTableCatalog(), getTableSchema(), tableName.getText()); if (swingSession.tableExists(table)) { int answer = JOptionPane.showConfirmDialog(swingSession.getFrame(), "Example table already exists, do you want to drop and recreate it?", "Table already exists", JOptionPane.YES_NO_OPTION); if (answer != JOptionPane.YES_OPTION) { return; } ddlg.dropTable(table); while (table.getColumns().size() != 0) { table.removeColumn(0); } } else { table = SQLObjectUtils.addSimulatedTable(swingSession.getDatabase(getDataSource()), getTableCatalog(), getTableSchema(), tableName.getText()); } SQLColumn id = new SQLColumn(table, "ID", swingSession.getSQLType(Types.INTEGER), 0, 0, false); table.addColumn(id); table.addToPK(id); table.addColumn(new SQLColumn(table, "FirstName", swingSession.getSQLType(Types.VARCHAR), 100, 0, false)); table.addColumn(new SQLColumn(table, "LastName", swingSession.getSQLType(Types.VARCHAR), 100, 0, false)); table.addColumn(new SQLColumn(table, "Email", swingSession.getSQLType(Types.VARCHAR), 100, 0, false)); table.addColumn(new SQLColumn(table, "Address", swingSession.getSQLType(Types.VARCHAR), 100, 0, false)); table.addColumn(new SQLColumn(table, "HomePhone", swingSession.getSQLType(Types.VARCHAR), 100, 0, false)); table.addColumn(new SQLColumn(table, "CellPhone", swingSession.getSQLType(Types.VARCHAR), 100, 0, false)); ddlg.addTable(table); final JDialog editor = new JDialog(swingSession.getFrame(), "Create Example Table", true); JComponent cp = (JComponent) editor.getContentPane(); Box statementsBox = Box.createVerticalBox(); final List<JTextArea> sqlTextFields = new ArrayList<JTextArea>(); for (DDLStatement sqlStatement : ddlg.getDdlStatements()) { final JTextArea sqlTextArea = new JTextArea(sqlStatement.getSQLText()); statementsBox.add(sqlTextArea); sqlTextFields.add(sqlTextArea); } Action saveAction = new AbstractAction("Save") { public void actionPerformed(ActionEvent e) { AbstractDocument doc = new DefaultStyledDocument(); for (JTextArea sqlText : sqlTextFields) { try { doc.insertString(doc.getLength(), sqlText.getText(), null); doc.insertString(doc.getLength(), ";\n", null); } catch (BadLocationException e1) { SPSUtils.showExceptionDialogNoReport(editor, "Unexcepted Document Error", e1); } } SPSUtils.saveDocument(swingSession.getFrame(), doc, (FileExtensionFilter) SPSUtils.SQL_FILE_FILTER); } }; Action copyAction = new AbstractAction("Copy to Clipboard") { public void actionPerformed(ActionEvent e) { StringBuffer buf = new StringBuffer(); for (JTextArea sqlText : sqlTextFields) { buf.append(sqlText.getText()); buf.append(";\n"); } StringSelection selection = new StringSelection(buf.toString()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(selection, selection); } }; Action executeAction = new AbstractAction("Execute") { public void actionPerformed(ActionEvent e) { // Builds the gui part of the error pane that will be used // if a sql statement fails JPanel errorPanel = new JPanel( new FormLayout("4dlu,300dlu,4dlu", "4dlu,pref,4dlu,pref,4dlu,200dlu,4dlu,pref,4dlu")); CellConstraints cc = new CellConstraints(); JLabel topLabel = new JLabel(); JTextArea errorMsgLabel = new JTextArea(); errorMsgLabel.setLineWrap(true); errorMsgLabel.setWrapStyleWord(true); errorMsgLabel.setPreferredSize(new Dimension(300, 40)); JLabel bottomLabel = new JLabel(); JTextArea errorStmtLabel = new JTextArea(); JScrollPane errorStmtPane = new JScrollPane(errorStmtLabel); errorStmtPane.setPreferredSize(new Dimension(300, 300)); errorStmtPane.scrollRectToVisible(new Rectangle(0, 0)); int row = 2; errorPanel.add(topLabel, cc.xy(2, row)); row += 2; errorPanel.add(errorMsgLabel, cc.xy(2, row)); row += 2; errorPanel.add(errorStmtPane, cc.xy(2, row)); row += 2; errorPanel.add(bottomLabel, cc.xy(2, row, "f,f")); Connection con = null; Statement stmt = null; String sql = null; try { con = swingSession.getDatabase(getDataSource()).getConnection(); stmt = con.createStatement(); int successCount = 0; for (JTextArea sqlText : sqlTextFields) { sql = sqlText.getText(); try { stmt.executeUpdate(sql); successCount += 1; } catch (SQLException e1) { topLabel.setText("There was an error in the SQL statement: "); errorMsgLabel.setText(e1.getMessage()); errorStmtLabel.setText(sql); bottomLabel.setText("Do you want to continue executing the create script?"); int choice = JOptionPane.showOptionDialog(editor, errorPanel, "SQL Error", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, new String[] { "Abort", "Continue" }, "Continue"); if (choice != 1) { break; } } } JOptionPane.showMessageDialog(swingSession.getFrame(), "Successfully executed " + successCount + " of " + sqlTextFields.size() + " SQL Statements." + (successCount == 0 ? "\n\nBetter Luck Next Time." : "")); //closes the dialog if all the statement is executed successfully //if not, the dialog remains on the screen if (successCount == sqlTextFields.size()) { editor.dispose(); //start the thread to populate the table. new Thread(new PopulateTableWorker(swingSession, table)).start(); } } catch (SQLException ex) { SPSUtils.showExceptionDialogNoReport(editor, "Create Script Failure", ex); } catch (SQLObjectException ex) { SPSUtils.showExceptionDialogNoReport(editor, "Error Generating Example table", ex); } finally { try { if (stmt != null) { stmt.close(); } } catch (SQLException ex) { logger.warn("Couldn't close statement", ex); } try { if (con != null) { con.close(); } } catch (SQLException ex) { logger.warn("Couldn't close connection", ex); } } } }; Action cancelAction = new AbstractAction("Close") { public void actionPerformed(ActionEvent e) { editor.dispose(); } }; // the gui layout part cp.setLayout(new BorderLayout(10, 10)); cp.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); cp.add(new JScrollPane(statementsBox), BorderLayout.CENTER); ButtonBarBuilder bbb = ButtonBarBuilder.createLeftToRightBuilder(); bbb.addGridded(new JButton(saveAction)); bbb.addGridded(new JButton(copyAction)); bbb.addGridded(new JButton(executeAction)); bbb.addGridded(new JButton(cancelAction)); cp.add(bbb.getPanel(), BorderLayout.SOUTH); editor.pack(); editor.setLocationRelativeTo(BuildExampleTableDialog.this); editor.setVisible(true); }
From source file:ca.sqlpower.matchmaker.swingui.DeleteFolderDialog.java
License:Open Source License
public void buildUI() { FormLayout layout = new FormLayout("4dlu, pref, 4dlu", "4dlu,pref,4dlu,pref,4dlu, pref,4dlu,pref,4dlu"); //1 2 3 4 5 6 7 8 9 CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(layout); deleteAll = new JRadioButton("Delete all content"); moveContent = new JRadioButton("Move to:"); // default to move the contents moveContent.setSelected(true);/*from ww w. j a va 2 s . c om*/ moveTo = new JComboBox(); List<PlFolder> folders = new ArrayList<PlFolder>(); folders.addAll(session.getCurrentFolderParent().getChildren(PlFolder.class)); folders.remove(folder); moveTo.setModel(new DefaultComboBoxModel(folders.toArray())); moveTo.setRenderer(new MatchMakerObjectComboBoxCellRenderer()); okButton = new JButton(okAction); cancelButton = new JButton(cancelAction); group = new ButtonGroup(); group.add(deleteAll); group.add(moveContent); pb.add(deleteAll, cc.xy(2, 2)); pb.add(moveContent, cc.xy(2, 4)); pb.add(moveTo, cc.xy(2, 6)); if (folders.size() == 0) { moveContent.setEnabled(false); moveTo.setEnabled(false); deleteAll.setSelected(true); } pb.add(ButtonBarFactory.buildOKCancelBar(okButton, cancelButton), cc.xy(2, 8)); dialog = new JDialog(parent, "Delete " + folder.getName() + " folder"); pb.setBorder(new EmptyBorder(10, 10, 10, 10)); dialog.setContentPane(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 va 2s . co m 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.MungeProcessSelectionList.java
License:Open Source License
/** * Builds and returns the popup menu for choosing the munge processes. *//*from w w w.j av a2 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.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 w w . ja va2 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(// w ww .j a v a 2s.c o m new JLabel("<html><div align='center'>SQL Power Group Inc.<br>http://www.sqlpower.ca/</div></html>", JLabel.CENTER)); spgLogo.add(new JLabel(new ImageIcon(getClass().getResource("/icons/sqlpower_alpha_gradient.png")))); spgLogo.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { try { BrowserUtil.launch(SPSUtils.SQLP_URL); } catch (IOException e1) { throw new RuntimeException("Could not launch web browser with URL " + SPSUtils.SQLP_URL, e1); } } }); JLabel mmLogo = new JLabel(SPSUtils.createIcon("dqguru_huge", "DQguru Huge Icon"), JLabel.CENTER); JLabel title = new JLabel("<html>" + "SQL Power DQguru " + MatchMakerVersion.APP_VERSION + "</html>", JLabel.CENTER); Font f = title.getFont(); Font newf = new Font(f.getName(), f.getStyle(), (int) (f.getSize() * 1.5)); title.setFont(newf); FormLayout layout = new FormLayout("4dlu, pref:grow, 4dlu "); int rowCount = 0; PanelBuilder pb = new PanelBuilder(layout); CellConstraints c = new CellConstraints(); pb.appendRow(new RowSpec("10px:grow")); rowCount++; pb.appendRow(new RowSpec("pref")); rowCount++; pb.add(mmLogo, c.xy(2, rowCount)); pb.appendRow(new RowSpec("15px")); rowCount++; pb.appendRow(new RowSpec("pref")); rowCount++; pb.add(title, c.xy(2, rowCount)); pb.appendRow(new RowSpec("40px")); rowCount++; pb.appendRow(new RowSpec("fill:pref")); rowCount++; pb.appendRow(new RowSpec("40px")); rowCount++; pb.appendRow(new RowSpec("fill:pref")); rowCount++; pb.add(spgLogo, c.xy(2, rowCount)); rowCount++; pb.appendRow(new RowSpec("10px:grow")); rowCount++; splashScreen = pb.getPanel(); }
From source file:ca.sqlpower.matchmaker.swingui.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();/*from w w w . j a v a2 s.c om*/ } 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.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;// w w w . j a v a2s . c om 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(); }