List of usage examples for java.awt GridBagConstraints BOTH
int BOTH
To view the source code for java.awt GridBagConstraints BOTH.
Click Source Link
From source file:org.jets3t.apps.uploader.Uploader.java
/** * Initialises the application's GUI elements. *//* w ww . j a v a 2s. co m*/ private void initGui() { // Initialise skins factory. skinsFactory = SkinsFactory.getInstance(uploaderProperties.getProperties()); // Set Skinned Look and Feel. LookAndFeel lookAndFeel = skinsFactory.createSkinnedMetalTheme("SkinnedLookAndFeel"); try { UIManager.setLookAndFeel(lookAndFeel); } catch (UnsupportedLookAndFeelException e) { log.error("Unable to set skinned LookAndFeel", e); } // Apply branding String applicationTitle = replaceMessageVariables( uploaderProperties.getStringProperty("gui.applicationTitle", null)); if (applicationTitle != null) { ownerFrame.setTitle(applicationTitle); } String applicationIconPath = uploaderProperties.getStringProperty("gui.applicationIcon", null); if (!isRunningAsApplet && applicationIconPath != null) { guiUtils.applyIcon(ownerFrame, applicationIconPath); } String footerHtml = uploaderProperties.getStringProperty("gui.footerHtml", null); String footerIconPath = uploaderProperties.getStringProperty("gui.footerIcon", null); // Footer for branding boolean includeFooter = false; JHtmlLabel footerLabel = skinsFactory.createSkinnedJHtmlLabel("FooterLabel"); footerLabel.setHyperlinkeActivatedListener(this); footerLabel.setHorizontalAlignment(JLabel.CENTER); if (footerHtml != null) { footerLabel.setText(replaceMessageVariables(footerHtml)); includeFooter = true; } if (footerIconPath != null) { guiUtils.applyIcon(footerLabel, footerIconPath); } userInputFields = new UserInputFields(insetsDefault, this, skinsFactory); // Screeen 1 : User input fields. JPanel screen1Panel = skinsFactory.createSkinnedJPanel("Screen1Panel"); screen1Panel.setLayout(GRID_BAG_LAYOUT); userInputFields.buildFieldsPanel(screen1Panel, uploaderProperties); // Screen 2 : Drag/drop panel. JPanel screen2Panel = skinsFactory.createSkinnedJPanel("Screen2Panel"); screen2Panel.setLayout(GRID_BAG_LAYOUT); dragDropTargetLabel = skinsFactory.createSkinnedJHtmlLabel("DragDropTargetLabel"); dragDropTargetLabel.setHyperlinkeActivatedListener(this); dragDropTargetLabel.setHorizontalAlignment(JLabel.CENTER); dragDropTargetLabel.setVerticalAlignment(JLabel.CENTER); JButton chooseFileButton = skinsFactory.createSkinnedJButton("ChooseFileButton"); chooseFileButton.setActionCommand("ChooseFile"); chooseFileButton.addActionListener(this); configureButton(chooseFileButton, "screen.2.browseButton"); screen2Panel.add(dragDropTargetLabel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); screen2Panel.add(chooseFileButton, new GridBagConstraints(0, 1, 1, 1, 1, 1, GridBagConstraints.NORTH, GridBagConstraints.NONE, insetsDefault, 0, 0)); // Screen 3 : Information about the file to be uploaded. JPanel screen3Panel = skinsFactory.createSkinnedJPanel("Screen3Panel"); screen3Panel.setLayout(GRID_BAG_LAYOUT); fileToUploadLabel = skinsFactory.createSkinnedJHtmlLabel("FileToUploadLabel"); fileToUploadLabel.setHyperlinkeActivatedListener(this); fileToUploadLabel.setHorizontalAlignment(JLabel.CENTER); fileToUploadLabel.setVerticalAlignment(JLabel.CENTER); screen3Panel.add(fileToUploadLabel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); // Screen 4 : Upload progress. JPanel screen4Panel = skinsFactory.createSkinnedJPanel("Screen4Panel"); screen4Panel.setLayout(GRID_BAG_LAYOUT); fileInformationLabel = skinsFactory.createSkinnedJHtmlLabel("FileInformationLabel"); fileInformationLabel.setHyperlinkeActivatedListener(this); fileInformationLabel.setHorizontalAlignment(JLabel.CENTER); progressBar = skinsFactory.createSkinnedJProgressBar("ProgressBar", 0, 100); progressBar.setStringPainted(true); progressStatusTextLabel = skinsFactory.createSkinnedJHtmlLabel("ProgressStatusTextLabel"); progressStatusTextLabel.setHyperlinkeActivatedListener(this); progressStatusTextLabel.setText(" "); progressStatusTextLabel.setHorizontalAlignment(JLabel.CENTER); progressTransferDetailsLabel = skinsFactory.createSkinnedJHtmlLabel("ProgressTransferDetailsLabel"); progressTransferDetailsLabel.setHyperlinkeActivatedListener(this); progressTransferDetailsLabel.setText(" "); progressTransferDetailsLabel.setHorizontalAlignment(JLabel.CENTER); cancelUploadButton = skinsFactory.createSkinnedJButton("CancelUploadButton"); cancelUploadButton.setActionCommand("CancelUpload"); cancelUploadButton.addActionListener(this); configureButton(cancelUploadButton, "screen.4.cancelButton"); screen4Panel.add(fileInformationLabel, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); screen4Panel.add(progressBar, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); screen4Panel.add(progressStatusTextLabel, new GridBagConstraints(0, 2, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); screen4Panel.add(progressTransferDetailsLabel, new GridBagConstraints(0, 3, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); screen4Panel.add(cancelUploadButton, new GridBagConstraints(0, 4, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsDefault, 0, 0)); // Screen 5 : Thankyou message. JPanel screen5Panel = skinsFactory.createSkinnedJPanel("Screen5Panel"); screen5Panel.setLayout(GRID_BAG_LAYOUT); finalMessageLabel = skinsFactory.createSkinnedJHtmlLabel("FinalMessageLabel"); finalMessageLabel.setHyperlinkeActivatedListener(this); finalMessageLabel.setHorizontalAlignment(JLabel.CENTER); screen5Panel.add(finalMessageLabel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); // Wizard Button panel. backButton = skinsFactory.createSkinnedJButton("backButton"); backButton.setActionCommand("Back"); backButton.addActionListener(this); nextButton = skinsFactory.createSkinnedJButton("nextButton"); nextButton.setActionCommand("Next"); nextButton.addActionListener(this); buttonsPanel = skinsFactory.createSkinnedJPanel("ButtonsPanel"); buttonsPanelCardLayout = new CardLayout(); buttonsPanel.setLayout(buttonsPanelCardLayout); JPanel buttonsInvisiblePanel = skinsFactory.createSkinnedJPanel("ButtonsInvisiblePanel"); JPanel buttonsVisiblePanel = skinsFactory.createSkinnedJPanel("ButtonsVisiblePanel"); buttonsVisiblePanel.setLayout(GRID_BAG_LAYOUT); buttonsVisiblePanel.add(backButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0)); buttonsVisiblePanel.add(nextButton, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); buttonsPanel.add(buttonsInvisiblePanel, "invisible"); buttonsPanel.add(buttonsVisiblePanel, "visible"); // Overall content panel. appContentPanel = skinsFactory.createSkinnedJPanel("ApplicationContentPanel"); appContentPanel.setLayout(GRID_BAG_LAYOUT); JPanel userGuidancePanel = skinsFactory.createSkinnedJPanel("UserGuidancePanel"); userGuidancePanel.setLayout(GRID_BAG_LAYOUT); primaryPanel = skinsFactory.createSkinnedJPanel("PrimaryPanel"); primaryPanelCardLayout = new CardLayout(); primaryPanel.setLayout(primaryPanelCardLayout); JPanel navigationPanel = skinsFactory.createSkinnedJPanel("NavigationPanel"); navigationPanel.setLayout(GRID_BAG_LAYOUT); appContentPanel.add(userGuidancePanel, new GridBagConstraints(0, 0, 1, 1, 1, 0.2, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); appContentPanel.add(primaryPanel, new GridBagConstraints(0, 1, 1, 1, 1, 0.6, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); appContentPanel.add(navigationPanel, new GridBagConstraints(0, 2, 1, 1, 1, 0.2, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); if (includeFooter) { log.debug("Adding footer for branding"); appContentPanel.add(footerLabel, new GridBagConstraints(0, 3, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); } this.getContentPane().add(appContentPanel); userGuidanceLabel = skinsFactory.createSkinnedJHtmlLabel("UserGuidanceLabel"); userGuidanceLabel.setHyperlinkeActivatedListener(this); userGuidanceLabel.setHorizontalAlignment(JLabel.CENTER); userGuidancePanel.add(userGuidanceLabel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsNone, 0, 0)); navigationPanel.add(buttonsPanel, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsNone, 0, 0)); primaryPanel.add(screen1Panel, "screen1"); primaryPanel.add(screen2Panel, "screen2"); primaryPanel.add(screen3Panel, "screen3"); primaryPanel.add(screen4Panel, "screen4"); primaryPanel.add(screen5Panel, "screen5"); // Set preferred sizes int preferredWidth = uploaderProperties.getIntProperty("gui.minSizeWidth", 400); int preferredHeight = uploaderProperties.getIntProperty("gui.minSizeHeight", 500); this.setBounds(new Rectangle(new Dimension(preferredWidth, preferredHeight))); // Initialize drop target. initDropTarget(new Component[] { this }); // Revert to default Look and Feel for all future GUI elements (eg Dialog boxes). try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { log.error("Unable to set default system LookAndFeel", e); } wizardStepForward(); }
From source file:org.dwfa.ace.classifier.CNFormsLabelPanel.java
public CNFormsLabelPanel(I_GetConceptData conceptIn, List<I_Position> cEditPathPos, List<I_Position> cClassPathPos, SnoTable cSnoTable) { super();/* ww w . j a v a 2 s . c o m*/ this.theCBean = conceptIn; this.cEditPathPos = cEditPathPos; this.cClassPathPos = cClassPathPos; this.cSnoTable = cSnoTable; setLayout(new GridBagLayout()); // CNFormsLabelPanel LayoutManager GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.NORTHWEST; // Place // CNFormsLabelPanel // TOP ROW c.gridy = 0; // first row c.gridx = 0; // reset at west side of row c.weightx = 0.0; // no extra space c.weighty = 0.0; // no extra space c.gridwidth = 1; c.fill = GridBagConstraints.NONE; // ADD CHECK BOXES c.gridy++;// next row c.gridx = 0; c.gridwidth = 5; JLabel label = new JLabel("Normal Forms Expanded View:"); label.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 0)); add(label, c); c.gridx++; add(showDistFormCB, c); c.gridx++; add(showAuthFormCB, c); c.gridx++; add(showLongFormCB, c); c.gridx++; add(showShortFormCB, c); // FORM SELECTION CHECKBOX ROW c.gridy++; // next row c.gridx = 0; // first cell in row c.gridwidth = 1; c.weightx = 0.0; c.fill = GridBagConstraints.NONE; label = new JLabel("Information:"); label.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 0)); add(label, c); c.gridx++; add(showDetailCB, c); c.gridx++; add(showStatusCB, c); // SETUP CHECKBOX VALUES & LISTENER showStatusCB.setSelected(false); showStatusCB.addActionListener(this); showDetailCB.setSelected(false); showDetailCB.addActionListener(this); showDistFormCB.setSelected(false); showDistFormCB.addActionListener(this); showAuthFormCB.setSelected(false); showAuthFormCB.addActionListener(this); showLongFormCB.setSelected(false); showLongFormCB.addActionListener(this); showShortFormCB.setSelected(false); showShortFormCB.addActionListener(this); // COMMON & DIFFERENT PANELS ROW c.gridy++; c.gridx = 0; c.gridwidth = 2; c.fill = GridBagConstraints.BOTH; c.weightx = 0; commonJPanel = newMinMaxJPanel(); commonJPanel.setLayout(new GridLayout(0, 1)); commonJPanel.setName("Common Panel"); commonJPanel.setBorder(BorderFactory.createTitledBorder("Common: ")); add(commonJPanel, c); c.gridx = c.gridx + 1; deltaJPanel = newMinMaxJPanel(); deltaJPanel.setLayout(new GridLayout(0, 1)); deltaJPanel.setName("Differences Panel"); deltaJPanel.setBorder(BorderFactory.createTitledBorder("Different: ")); add(deltaJPanel, c); // FORMS PANEL ROW c.gridy++;// next row c.gridx = 0; // reset at west side of row c.gridwidth = 2; // number of cells in row c.fill = GridBagConstraints.BOTH; formsJPanel = new JPanel(new GridBagLayout()); formsJPanel.setName("Forms Panel"); formsJPanel.setBorder(BorderFactory.createTitledBorder("Forms: ")); JScrollPane formJScrollPane = new JScrollPane(formsJPanel); formJScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); add(formJScrollPane, c); }
From source file:org.openconcerto.erp.core.sales.pos.element.SaisieVenteComptoirSQLElement.java
public SQLComponent createComponent() { return new BaseSQLComponent(this) { private final JCheckBox checkService = new JCheckBox("dont "); private SQLSearchableTextCombo textNom; private DeviseField textMontantTTC; private DeviseField textMontantService; private ElementComboBox comboFournisseur; private JTextField textEcheance; private ElementComboBox comboTaxe; private DeviseField textMontantHT; private JCheckBox checkCommande; private JDate dateSaisie; private ElementComboBox nomArticle; private Date dateEch; private JLabel labelEcheancejours = new JLabel("jours"); private ElementComboBox comboAvoir; private ElementComboBox comboClient; private final JLabel labelWarning = new JLabelWarning( "le montant du service ne peut pas dpasser le total HT!"); private ValidState validState = ValidState.getTrueInstance(); // FIXME: use w private Where w; private DocumentListener docTTCListen; private PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ((nomArticle.getValidState().isValid()) && (!nomArticle.isEmpty()) && !isFilling()) { int idArticle = nomArticle.getValue().intValue(); SQLTable tableArticle = ((ComptaPropsConfiguration) Configuration.getInstance()) .getRootSociete().getTable("ARTICLE"); SQLRow rowArticle = tableArticle.getRow(idArticle); if (rowArticle != null) { comboTaxe.setValue(rowArticle.getInt("ID_TAXE")); textMontantTTC.setText(((BigDecimal) rowArticle.getObject("PV_TTC")).toString()); }/* w ww. j a v a 2s . c o m*/ System.out.println("value article Changed"); } } }; public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); this.docTTCListen = new DocumentListener() { public void changedUpdate(DocumentEvent e) { calculMontant(); } public void removeUpdate(DocumentEvent e) { calculMontant(); } public void insertUpdate(DocumentEvent e) { calculMontant(); } }; /*********************************************************************************** * * RENSEIGNEMENTS **********************************************************************************/ c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 1; TitledSeparator sep = new TitledSeparator("Renseignements"); this.add(sep, c); c.insets = new Insets(2, 2, 1, 2); c.gridwidth = 1; // Libell vente JLabel labelNom = new JLabel(getLabelFor("NOM")); labelNom.setHorizontalAlignment(SwingConstants.RIGHT); c.gridy++; c.gridx = 0; c.weightx = 0; this.add(labelNom, c); this.textNom = new SQLSearchableTextCombo(); c.gridx++; c.weightx = 1; c.gridwidth = 2; this.add(this.textNom, c); // Date JLabel labelDate = new JLabel(getLabelFor("DATE")); this.dateSaisie = new JDate(true); c.gridwidth = 1; // c.gridx += 2; c.gridx = 0; c.gridy++; c.weightx = 0; labelDate.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelDate, c); c.gridx++; c.weightx = 1; this.add(this.dateSaisie, c); // article c.gridy++; c.gridx = 0; this.nomArticle = new ElementComboBox(); JLabel labelNomArticle = new JLabel(getLabelFor("ID_ARTICLE")); c.weightx = 0; labelNomArticle.setHorizontalAlignment(SwingConstants.RIGHT); // this.add(labelNomArticle, c); c.gridx++; c.weightx = 0; c.gridwidth = GridBagConstraints.REMAINDER; // this.add(this.nomArticle, c); this.nomArticle.addValueListener(this.propertyChangeListener); // client this.comboClient = new ElementComboBox(); this.comboClient.addValueListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (comboClient.isEmpty()) { w = new Where(getTable().getBase().getTable("AVOIR_CLIENT").getField("ID_CLIENT"), "=", -1); } else { w = new Where(getTable().getBase().getTable("AVOIR_CLIENT").getField("ID_CLIENT"), "=", comboClient.getSelectedId()); } } }); JLabel labelNomClient = new JLabel(getLabelFor("ID_CLIENT")); c.gridy++; c.gridx = 0; c.gridwidth = 1; c.weightx = 0; labelNomClient.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelNomClient, c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 0; this.add(this.comboClient, c); // Selection d'un avoir si le client en possede this.comboAvoir = new ElementComboBox(); JLabel labelAvoirClient = new JLabel(getLabelFor("ID_AVOIR_CLIENT")); c.gridy++; c.gridx = 0; c.gridwidth = 1; c.weightx = 0; labelAvoirClient.setHorizontalAlignment(SwingConstants.RIGHT); // this.add(labelAvoirClient, c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 0; // this.add(this.comboAvoir, c); /*********************************************************************************** * * MONTANT **********************************************************************************/ c.gridwidth = GridBagConstraints.REMAINDER; c.gridx = 0; c.gridy++; c.weightx = 1; sep = new TitledSeparator("Montant en Euros"); c.insets = new Insets(10, 2, 1, 2); this.add(sep, c); c.insets = new Insets(2, 2, 1, 2); c.gridwidth = 1; final JLabel labelMontantHT = new JLabel(getLabelFor("MONTANT_HT")); labelMontantHT.setHorizontalAlignment(SwingConstants.RIGHT); this.textMontantHT = new DeviseField(); this.textMontantHT.setEditable(false); this.textMontantHT.setEnabled(false); this.textMontantHT.setFocusable(false); final JLabel labelMontantTTC = new JLabel(getLabelFor("MONTANT_TTC")); labelMontantTTC.setHorizontalAlignment(SwingConstants.RIGHT); this.textMontantTTC = new DeviseField(); this.textMontantTTC.getDocument().addDocumentListener(this.docTTCListen); // Montant HT c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridy++; c.gridx = 0; c.gridwidth = 1; this.add(labelMontantHT, c); c.gridx++; c.weightx = 1; this.add(this.textMontantHT, c); // Montant Service c.gridx++; c.weightx = 0; this.add(checkService, c); checkService.addActionListener(new ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if (isFilling()) return; boolean b = checkService.isSelected(); textMontantService.setEditable(b); textMontantService.setEnabled(b); textMontantService.setFocusable(b); if (!b) { textMontantService.setText(""); // montantServiceValide = true; } else { textMontantService.setText(textMontantHT.getText()); } }; }); this.textMontantService = new DeviseField(); c.gridx++; c.weightx = 1; this.add(this.textMontantService, c); JLabel labelMontantService = new JLabel("de service HT"); c.weightx = 0; c.gridx++; this.add(labelMontantService, c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; this.add(this.labelWarning, c); this.labelWarning.setVisible(false); // Choix TVA c.gridy++; c.gridx = 0; c.weightx = 0; c.gridwidth = 1; final JLabel labelTaxe = new JLabel(getLabelFor("ID_TAXE")); labelTaxe.setHorizontalAlignment(SwingUtilities.RIGHT); this.add(labelTaxe, c); c.gridx++; this.comboTaxe = new ElementComboBox(false); c.fill = GridBagConstraints.NONE; this.add(this.comboTaxe, c); c.fill = GridBagConstraints.HORIZONTAL; // Montant TTC c.gridy++; c.gridx = 0; c.weightx = 0; this.add(labelMontantTTC, c); c.gridx++; c.weightx = 0; this.add(this.textMontantTTC, c); /*********************************************************************************** * * MODE DE REGLEMENT **********************************************************************************/ c.gridwidth = GridBagConstraints.REMAINDER; c.gridx = 0; c.gridy++; sep = new TitledSeparator("Mode de rglement"); c.insets = new Insets(10, 2, 1, 2); this.add(sep, c); c.insets = new Insets(2, 2, 1, 2); c.gridx = 0; c.gridy++; c.gridwidth = GridBagConstraints.REMAINDER; this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP); ElementSQLObject eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT"); this.add(eltModeRegl, c); /*********************************************************************************** * * COMMANDE **********************************************************************************/ c.gridwidth = GridBagConstraints.REMAINDER; c.gridx = 0; c.gridy++; sep = new TitledSeparator("Commande"); c.insets = new Insets(10, 2, 1, 2); this.add(sep, c); c.insets = new Insets(2, 2, 1, 2); this.checkCommande = new JCheckBox("Produit commander"); c.gridx = 0; c.gridy++; c.weightx = 0; c.gridwidth = 2; // this.add(this.checkCommande, c); this.checkCommande.addActionListener(new ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { boolean b = checkCommande.isSelected(); comboFournisseur.setEnabled(b); comboFournisseur.setEditable(b); textEcheance.setEditable(b); textEcheance.setEnabled(b); updateValidState(); }; }); // Fournisseurs JLabel labelFournisseur = new JLabel(getLabelFor("ID_FOURNISSEUR")); c.gridx = 0; c.gridy++; c.weightx = 0; c.gridwidth = 1; labelFournisseur.setHorizontalAlignment(SwingConstants.RIGHT); // this.add(labelFournisseur, c); this.comboFournisseur = new ElementComboBox(); c.gridx++; c.weightx = 1; c.gridwidth = 4; // this.add(this.comboFournisseur, c); // Echeance JLabel labelEcheance = new JLabel("Echeance"); c.gridx = 0; c.gridy++; c.weightx = 0; c.gridwidth = 1; labelEcheance.setHorizontalAlignment(SwingConstants.RIGHT); // this.add(labelEcheance, c); c.gridx++; c.weightx = 1; this.textEcheance = new JTextField(); // this.add(this.textEcheance, c); this.textEcheance.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { calculDate(); } }); c.gridx++; c.weightx = 0; // this.add(this.labelEcheancejours, c); /*********************************************************************************** * * INFORMATIONS COMPLEMENTAIRES **********************************************************************************/ c.gridwidth = GridBagConstraints.REMAINDER; c.gridx = 0; c.gridy++; sep = new TitledSeparator("Informations complmentaires"); c.insets = new Insets(10, 2, 1, 2); // this.add(sep, c); c.insets = new Insets(2, 2, 1, 2); ITextArea textInfos = new ITextArea(); c.gridx = 0; c.gridy++; c.gridheight = GridBagConstraints.REMAINDER; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; // this.add(textInfos, c); this.addSQLObject(this.textNom, "NOM"); this.addRequiredSQLObject(this.comboClient, "ID_CLIENT"); this.addSQLObject(this.nomArticle, "ID_ARTICLE"); this.addRequiredSQLObject(this.textMontantTTC, "MONTANT_TTC"); this.addRequiredSQLObject(this.textMontantHT, "MONTANT_HT"); this.addSQLObject(this.textMontantService, "MONTANT_SERVICE"); this.addRequiredSQLObject(this.dateSaisie, "DATE"); this.addSQLObject(textInfos, "INFOS"); this.addSQLObject(this.comboFournisseur, "ID_FOURNISSEUR"); this.addSQLObject(this.textEcheance, "ECHEANCE"); this.addRequiredSQLObject(this.comboTaxe, "ID_TAXE"); this.addSQLObject(this.comboAvoir, "ID_AVOIR_CLIENT"); this.comboTaxe.setButtonsVisible(false); this.comboTaxe.setValue(2); checkService.setSelected(false); this.textMontantService.setEditable(false); this.textMontantService.setEnabled(false); this.checkCommande.setSelected(false); this.comboFournisseur.setEditable(false); this.comboFournisseur.setEnabled(false); this.textEcheance.setEditable(false); this.textEcheance.setEnabled(false); this.comboTaxe.addValueListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { calculMontant(); } }); final SimpleDocumentListener docL = new SimpleDocumentListener() { @Override public void update(DocumentEvent e) { updateValidState(); } }; this.textMontantService.getDocument().addDocumentListener(docL); this.textMontantHT.getDocument().addDocumentListener(docL); this.comboFournisseur.addEmptyListener(new EmptyListener() { @Override public void emptyChange(EmptyObj src, boolean newValue) { updateValidState(); } }); /* * this.nomClient.addValueListener(new PropertyChangeListener() { * * public void propertyChange(PropertyChangeEvent evt) { if (nomClient.isValid()) { * System.err.println("Changed Combo Avoir"); comboAvoir = new ElementComboBox(new * AvoirClientSQLElement(new Where(new * AvoirClientSQLElement().getTable().getField("ID_CLIENT"), "=", * nomClient.getValue()))); if (comboAvoir != null) { comboAvoir.setEnabled(true); } * } else { comboAvoir.setEnabled(false); } } }); */ } @Override public Set<String> getPartialResetNames() { Set<String> s = new HashSet<String>(); s.addAll(super.getPartialResetNames()); s.add("MONTANT_TTC"); s.add("MONTANT_SERVICE"); s.add("MONTANT_HT"); s.add("NOM"); s.add("ID_AVOIR_CLIENT"); s.add("ID_ARTICLE"); s.add("INFOS"); return s; } private void calculMontant() { if (!isFilling()) { float taux; // PrixHT pHT; PrixTTC pTTC; // taux de la TVA selectionnee int idTaxe = this.comboTaxe.getSelectedId(); if (idTaxe > 1) { SQLRow ligneTaxe = getTable().getBase().getTable("TAXE").getRow(idTaxe); if (ligneTaxe != null) { taux = (ligneTaxe.getFloat("TAUX")) / 100.0F; // calcul des montants HT ou TTC if (this.textMontantTTC.getText().trim().length() > 0) { if (this.textMontantTTC.getText().trim().equals("-")) { pTTC = new PrixTTC(0); } else { pTTC = new PrixTTC( GestionDevise.parseLongCurrency(this.textMontantTTC.getText())); } // affichage updateTextHT(GestionDevise.currencyToString(pTTC.calculLongHT(taux))); } else { updateTextHT(""); } } } } } private boolean isMontantServiceValid() { String montant = this.textMontantService.getText().trim(); String montantHT = this.textMontantHT.getText().trim(); boolean b; if (montant.length() == 0) { b = true; } else { if (montantHT.length() == 0) { b = false; } else { b = (GestionDevise.parseLongCurrency(montantHT) >= GestionDevise .parseLongCurrency(montant)); } } this.labelWarning.setVisible(!b); System.err.println("Montant service is valid ? " + b + " --> HT val " + montantHT + " --> service val " + montant); return b; } /* * private void calculMontantHT() { * * float taux; PrixHT pHT; * * if (!this.comboTaxe.isEmpty()) { // taux de la TVA selectionnee SQLRow ligneTaxe = * Configuration.getInstance().getBase().getTable("TAXE").getRow(((Integer) * this.comboTaxe.getValue()).intValue()); taux = (ligneTaxe.getFloat("TAUX")) / 100; // * calcul des montants HT ou TTC if (this.textMontantHT.getText().trim().length() > 0) { * * if (this.textMontantHT.getText().trim().equals("-")) { pHT = new PrixHT(0); } else { * pHT = new PrixHT(Float.parseFloat(this.textMontantHT.getText())); } // affichage * updateTextTTC(String.valueOf(pHT.CalculTTC(taux))); } else updateTextTTC(""); } } */ private void updateTextHT(final String prixHT) { SwingUtilities.invokeLater(new Runnable() { public void run() { textMontantHT.setText(prixHT); } }); } @Override protected SQLRowValues createDefaults() { SQLRowValues vals = new SQLRowValues(this.getTable()); SQLRowAccessor r; try { r = ModeReglementDefautPrefPanel.getDefaultRow(true); SQLElement eltModeReglement = Configuration.getInstance().getDirectory() .getElement("MODE_REGLEMENT"); if (r.getID() > 1) { SQLRowValues rowVals = eltModeReglement.createCopy(r.getID()); System.err.println(rowVals.getInt("ID_TYPE_REGLEMENT")); vals.put("ID_MODE_REGLEMENT", rowVals); } } catch (SQLException e) { System.err.println("Impossible de slectionner le mode de rglement par dfaut du client."); e.printStackTrace(); } return vals; } // private void updateTextTTC(final String prixTTC) { // SwingUtilities.invokeLater(new Runnable() { // // public void run() { // // if (docTTCListen != null) { // // textMontantTTC.getDocument().removeDocumentListener(docTTCListen); // } // // textMontantTTC.setText(prixTTC); // // // textTaxe.setText(prixTVA); // textMontantTTC.getDocument().addDocumentListener(docTTCListen); // } // }); // } private void calculDate() { int aJ = 0; // on rcupre les valeurs saisies if (this.textEcheance.getText().trim().length() != 0) { try { aJ = Integer.parseInt(this.textEcheance.getText()); } catch (Exception e) { System.out.println("Erreur de format sur TextField Ajour " + this.textEcheance.getText()); } } Calendar cal = Calendar.getInstance(); // on fixe le temps sur ToDay + Ajour cal.setTime(new Date()); long tempsMil = aJ * 86400000; cal.setTimeInMillis(cal.getTimeInMillis() + tempsMil); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy"); this.dateEch = cal.getTime(); this.labelEcheancejours.setText("jours, soit le " + dateFormat.format(this.dateEch)); } private void updateValidState() { this.setValidState(this.computeValidState()); } private ValidState computeValidState() { ValidState res = ValidState.getTrueInstance(); if (!this.isMontantServiceValid()) res = res.and(ValidState.createCached(false, this.labelWarning.getText())); if (this.checkCommande.isSelected()) res = res.and(ValidState.createCached(!this.comboFournisseur.isEmpty(), "Fournisseur non renseign")); return res; } private final void setValidState(ValidState validState) { if (!validState.equals(this.validState)) { this.validState = validState; this.fireValidChange(); } } @Override public synchronized ValidState getValidState() { return super.getValidState().and(this.validState); } public int insert(SQLRow order) { // On teste si l'article n'existe pas, on le cre if (this.nomArticle.isEmpty()) { createArticle(); } if (this.textNom.getValue() == null || this.textNom.getValue().trim().length() <= 0) { this.textNom.setValue(this.nomArticle.getTextComp().getText()); } final int id = super.insert(order); // on verifie si le produit est commander if (this.checkCommande.isSelected()) { createCommande(id); } SQLRow rowArt = getTable().getRow(id).getForeignRow("ID_ARTICLE"); if (rowArt != null && !rowArt.isUndefined() && rowArt.getBoolean("GESTION_STOCK")) { Configuration.getInstance().getNonInteractiveSQLExecutor().execute(new Runnable() { @Override public void run() { final SQLRow rowVC = getTable().getRow(id); // Mise jour des stocks final SQLElement eltMvtStock = Configuration.getInstance().getDirectory() .getElement("MOUVEMENT_STOCK"); final SQLRowValues rowVals = new SQLRowValues(eltMvtStock.getTable()); rowVals.put("QTE", -1); rowVals.put("NOM", "Saisie vente comptoir"); rowVals.put("IDSOURCE", id); rowVals.put("SOURCE", getTable().getName()); rowVals.put("ID_ARTICLE", rowVC.getInt("ID_ARTICLE")); rowVals.put("DATE", rowVC.getObject("DATE")); try { final SQLRow row = rowVals.insert(); final ListMap<SQLRow, SQLRowValues> map = ((MouvementStockSQLElement) Configuration .getInstance().getDirectory().getElement("MOUVEMENT_STOCK")) .updateStock(Arrays.asList(row), false); MouvementStockSQLElement.createCommandeF(map, null); } catch (SQLException e) { ExceptionHandler.handle("Erreur lors de la cration des mouvements de stock", e); } } }); } new GenerationMvtSaisieVenteComptoir(id); return id; } private void createCommande(final int id) { System.out.println("Ajout d'une commande"); SQLRow rowSaisie = SaisieVenteComptoirSQLElement.this.getTable().getRow(id); Map<String, Object> m = new HashMap<String, Object>(); // NOM, DATE, ECHEANCE, IDSOURCE, SOURCE, ID_CLI, ID_FOURN, ID_ARTICLE m.put("NOM", rowSaisie.getObject("NOM")); m.put("DATE", rowSaisie.getObject("DATE")); m.put("DATE_ECHEANCE", new java.sql.Date(this.dateEch.getTime())); m.put("IDSOURCE", new Integer(id)); m.put("SOURCE", "SAISIE_VENTE_COMPTOIR"); m.put("ID_CLIENT", rowSaisie.getObject("ID_CLIENT")); m.put("ID_FOURNISSEUR", rowSaisie.getObject("ID_FOURNISSEUR")); m.put("ID_ARTICLE", rowSaisie.getObject("ID_ARTICLE")); SQLTable tableCmd = getTable().getBase().getTable("COMMANDE_CLIENT"); SQLRowValues valCmd = new SQLRowValues(tableCmd, m); try { if (valCmd.getInvalid() == null) { // ajout de l'ecriture valCmd.insert(); } } catch (Exception e) { System.err.println("Erreur l'insertion dans la table " + valCmd.getTable().getName()); e.printStackTrace(); } } private void createArticle() { System.out.println("Cration de l'article"); String tNomArticle = this.nomArticle.getTextComp().getText(); String codeArticle = "";// this.nomArticle.getTextOpt(); if (tNomArticle.trim().length() == 0 && codeArticle.trim().length() == 0) { return; } SQLTable articleTable = getTable().getBase().getTable("ARTICLE"); int idTaxe = this.comboTaxe.getSelectedId(); final BigDecimal prix = StringUtils.getBigDecimalFromUserText(this.textMontantHT.getText()); final BigDecimal prixTTC = StringUtils.getBigDecimalFromUserText(this.textMontantTTC.getText()); if (tNomArticle.trim().length() == 0) { tNomArticle = "Nom Indefini"; } if (codeArticle.trim().length() == 0) { codeArticle = "Indefini"; } SQLRowValues vals = new SQLRowValues(articleTable); vals.put("NOM", tNomArticle); vals.put("CODE", codeArticle); vals.put("PA_HT", prix); vals.put("PV_HT", prix); vals.put("PRIX_METRIQUE_VT_1", prix); vals.put("PRIX_METRIQUE_HA_1", prix); vals.put("PV_TTC", prixTTC); vals.put("ID_UNITE_VENTE", UniteVenteArticleSQLElement.A_LA_PIECE); vals.put("ID_TAXE", new Integer(idTaxe)); vals.put("CREATION_AUTO", Boolean.TRUE); vals.put("GESTION_STOCK", Boolean.FALSE); try { SQLRow row = vals.insert(); this.nomArticle.setValue(row); } catch (SQLException e) { e.printStackTrace(); } } public void update() { if (JOptionPane.showConfirmDialog(this, "Attention en modifiant cette vente comptoir, vous supprimerez les chques et les chances associs. Continuer?", "Modification de vente comptoir", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { // on efface les mouvements de stocks associs SQLRow row = getTable().getRow(this.getSelectedID()); SQLElement eltMvtStock = Configuration.getInstance().getDirectory() .getElement("MOUVEMENT_STOCK"); SQLSelect sel = new SQLSelect(); sel.addSelect(eltMvtStock.getTable().getField("ID")); Where w = new Where(eltMvtStock.getTable().getField("IDSOURCE"), "=", row.getID()); Where w2 = new Where(eltMvtStock.getTable().getField("SOURCE"), "=", getTable().getName()); sel.setWhere(w.and(w2)); List l = (List) eltMvtStock.getTable().getBase().getDataSource().execute(sel.asString(), new ArrayListHandler()); if (l != null) { for (int i = 0; i < l.size(); i++) { Object[] tmp = (Object[]) l.get(i); try { eltMvtStock.archive(((Number) tmp[0]).intValue()); } catch (SQLException e) { e.printStackTrace(); } } } if (this.textNom.getValue() != null && this.textNom.getValue().trim().length() <= 0) { this.textNom.setValue(this.nomArticle.getTextComp().getText()); } // On teste si l'article n'existe pas, on le cre if (this.nomArticle.getValue() == null || Integer.parseInt(this.nomArticle.getValue().toString()) == -1) { createArticle(); } // TODO check echeance, ---> creation article, commande?? super.update(); row = getTable().getRow(this.getSelectedID()); int idMvt = row.getInt("ID_MOUVEMENT"); System.out.println(row.getID() + "__________***************** UPDATE " + idMvt); // on supprime tout ce qui est li la facture EcritureSQLElement eltEcr = (EcritureSQLElement) Configuration.getInstance().getDirectory() .getElement("ECRITURE"); eltEcr.archiveMouvementProfondeur(idMvt, false); SQLRow rowArt = row.getForeignRow("ID_ARTICLE"); if (rowArt != null && !rowArt.isUndefined() && rowArt.getBoolean("GESTION_STOCK")) { // Mise jour des stocks SQLRowValues rowVals = new SQLRowValues(eltMvtStock.getTable()); rowVals.put("QTE", -1); rowVals.put("NOM", "Saisie vente comptoir"); rowVals.put("IDSOURCE", getSelectedID()); rowVals.put("SOURCE", getTable().getName()); rowVals.put("ID_ARTICLE", row.getInt("ID_ARTICLE")); rowVals.put("DATE", row.getObject("DATE")); try { SQLRow rowNew = rowVals.insert(); final ListMap<SQLRow, SQLRowValues> map = ((MouvementStockSQLElement) Configuration .getInstance().getDirectory().getElement("MOUVEMENT_STOCK")) .updateStock(Arrays.asList(rowNew), false); ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor() .execute(new Runnable() { @Override public void run() { MouvementStockSQLElement.createCommandeF(map, null); } }); } catch (SQLException e) { e.printStackTrace(); } } if (idMvt > 1) { new GenerationMvtSaisieVenteComptoir(this.getSelectedID(), idMvt); } else { new GenerationMvtSaisieVenteComptoir(this.getSelectedID()); } } } @Override public void select(SQLRowAccessor r) { this.textMontantTTC.getDocument().removeDocumentListener(this.docTTCListen); this.nomArticle.rmValueListener(this.propertyChangeListener); super.select(r); checkService.setSelected( r != null && r.getObject("MONTANT_SERVICE") != null && r.getLong("MONTANT_SERVICE") > 0); this.textMontantTTC.getDocument().addDocumentListener(this.docTTCListen); this.nomArticle.addValueListener(this.propertyChangeListener); } @Override public void select(SQLRowAccessor r, Set<String> views) { super.select(r, views); checkService.setSelected( r != null && r.getObject("MONTANT_SERVICE") != null && r.getLong("MONTANT_SERVICE") > 0); } }; }
From source file:junk.gui.HazardDataSetCalcCondorApp.java
/** * Initialize the ERF Gui Bean/* w w w . j av a 2 s . c o m*/ */ private void initERFSelector_GuiBean() { // create the ERF Gui Bean object ArrayList erf_Classes = new ArrayList(); erf_Classes.add(RMI_FRANKEL02_ADJ_FORECAST_CLASS_NAME); erf_Classes.add(RMI_FLOATING_POISSON_FAULT_ERF_CLASS_NAME); erf_Classes.add(RMI_FRANKEL_ADJ_FORECAST_CLASS_NAME); erf_Classes.add(RMI_STEP_FORECAST_CLASS_NAME); erf_Classes.add(RMI_STEP_ALASKAN_FORECAST_CLASS_NAME); erf_Classes.add(RMI_WG02_ADJ_FORECAST_CLASS_NAME); erf_Classes.add(RMI_WGCEP_UCERF1_ERF_CLASS_NAME); try { erfGuiBean = new ERF_GuiBean(erf_Classes); } catch (InvocationTargetException e) { throw new RuntimeException("Connection to ERF servlets failed"); } eqkRupPanel.add(erfGuiBean, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, defaultInsets, 0, 0)); }
From source file:de.tor.tribes.ui.views.DSWorkbenchFormFrame.java
/** This method is called from within the constructor to * initialize the form./* w w w . j a va 2 s . c o m*/ * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; jFormTablePanel = new org.jdesktop.swingx.JXPanel(); infoPanel = new org.jdesktop.swingx.JXCollapsiblePane(); jXLabel1 = new org.jdesktop.swingx.JXLabel(); jScrollPane4 = new javax.swing.JScrollPane(); jFormPanel = new javax.swing.JPanel(); jAlwaysOnTop = new javax.swing.JCheckBox(); capabilityInfoPanel1 = new de.tor.tribes.ui.components.CapabilityInfoPanel(); jFormTablePanel.setLayout(new java.awt.BorderLayout()); infoPanel.setCollapsed(true); infoPanel.setInheritAlpha(false); jXLabel1.setText("Keine Meldung"); jXLabel1.setOpaque(true); jXLabel1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseReleased(java.awt.event.MouseEvent evt) { fireHideInfoEvent(evt); } }); infoPanel.add(jXLabel1, java.awt.BorderLayout.CENTER); jFormTablePanel.add(infoPanel, java.awt.BorderLayout.SOUTH); jFormsTable .setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); jScrollPane4.setViewportView(jFormsTable); jFormTablePanel.add(jScrollPane4, java.awt.BorderLayout.CENTER); setTitle("Zeichnungen"); getContentPane().setLayout(new java.awt.GridBagLayout()); jFormPanel.setBackground(new java.awt.Color(239, 235, 223)); jFormPanel.setLayout(new java.awt.BorderLayout()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.ipadx = 439; gridBagConstraints.ipady = 319; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; getContentPane().add(jFormPanel, gridBagConstraints); jAlwaysOnTop.setText("Immer im Vordergrund"); jAlwaysOnTop.setOpaque(false); jAlwaysOnTop.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { fireFormFrameAlwaysOnTopEvent(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); getContentPane().add(jAlwaysOnTop, gridBagConstraints); capabilityInfoPanel1.setPastable(false); capabilityInfoPanel1.setSearchable(false); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); getContentPane().add(capabilityInfoPanel1, gridBagConstraints); pack(); }
From source file:org.bigwiv.blastgraph.gui.BlastGraphFrame.java
private void initComponents() { URL icon;//w w w . j a v a2 s.c o m icon = getClass().getResource("/org/bigwiv/blastgraph/icons/icon.png"); this.setIconImage(Toolkit.getDefaultToolkit().createImage(icon)); JComponent pane; pane = (JComponent) getContentPane(); // ====================Menu Setting======================= newItem = new JMenuItem("New From Blast"); newItem.setMnemonic('n'); newItem.addActionListener(commandActionListener); openItem = new JMenuItem("Open"); openItem.setMnemonic('o'); openItem.addActionListener(commandActionListener); appendGraphItem = new JMenuItem("Append Graph"); appendGraphItem.setMnemonic('a'); appendGraphItem.addActionListener(commandActionListener); saveItem = new JMenuItem("Save"); saveItem.setMnemonic('s'); saveItem.addActionListener(commandActionListener); saveAsGraphItem = new JMenuItem("Save As"); saveAsGraphItem.addActionListener(commandActionListener); exportGraphItem = new JMenuItem("Export"); exportGraphItem.addActionListener(commandActionListener); saveCurGraphItem = new JMenuItem("Save Current Graph"); saveCurGraphItem.addActionListener(commandActionListener); saveCurImgItem = new JMenuItem("Save Image"); saveCurImgItem.addActionListener(commandActionListener); saveAllVertexAttrItem = new JMenuItem("Save Vertex Attribute"); saveAllVertexAttrItem.addActionListener(commandActionListener); saveCurVertexAttrItem = new JMenuItem("Save Vertex Attribute"); saveCurVertexAttrItem.addActionListener(commandActionListener); saveAsMenu = new JMenu("Save As"); saveAsMenu.add(saveAsGraphItem); saveAsMenu.add(saveAllVertexAttrItem); saveCurGraphMenu = new JMenu("Save Current Graph"); saveCurGraphMenu.add(saveCurGraphItem); saveCurGraphMenu.add(saveCurImgItem); saveCurGraphMenu.add(saveCurVertexAttrItem); printItem = new JMenuItem("Print..."); printItem.setMnemonic('p'); printItem.addActionListener(commandActionListener); importVertexAttrItem = new JMenuItem("Import Vertex Attribute"); importVertexAttrItem.addActionListener(commandActionListener); closeItem = new JMenuItem("Close"); closeItem.setMnemonic('c'); closeItem.addActionListener(commandActionListener); exitItem = new JMenuItem("Exit"); exitItem.setMnemonic('x'); exitItem.addActionListener(commandActionListener); fileMenu = new JMenu("File"); fileMenu.setMnemonic('f'); fileMenu.add(newItem); fileMenu.add(openItem); fileMenu.add(appendGraphItem); fileMenu.add(new JSeparator()); fileMenu.add(closeItem); fileMenu.add(new JSeparator()); fileMenu.add(saveItem); fileMenu.add(saveAsMenu); fileMenu.add(saveCurGraphMenu); fileMenu.add(new JSeparator()); fileMenu.add(printItem); fileMenu.add(new JSeparator()); fileMenu.add(importVertexAttrItem); fileMenu.add(exportGraphItem); fileMenu.add(new JSeparator()); fileMenu.add(exitItem); // edit menu undoItem = new JMenuItem("Undo"); redoItem = new JMenuItem("Redo"); Global.COMMAND_MANAGER.registerUndoRedoItem(undoItem, redoItem); removeSingleItem = new JMenuItem("Remove Single Vertices"); removeSingleItem.addActionListener(commandActionListener); filterItem = new JMenuItem("Filt Graph"); filterItem.addActionListener(commandActionListener); settingItem = new JMenuItem("Setting"); settingItem.addActionListener(commandActionListener); markovClusterItem = new JMenuItem("Markov Cluster"); markovClusterItem.addActionListener(commandActionListener); // genomeNumFiltItem = new JMenuItem("GenomeNum Filt"); // genomeNumFiltItem.addActionListener(commandActionListener); // removeSingleLinkageItem = new JMenuItem("Remove Single Linkage"); // removeSingleLinkageItem.addActionListener(commandActionListener); editMenu = new JMenu("Edit"); editMenu.setMnemonic('e'); editMenu.add(undoItem); editMenu.add(redoItem); editMenu.add(filterItem); editMenu.add(markovClusterItem); editMenu.add(removeSingleItem); // editMenu.add(genomeNumFiltItem); // editMenu.add(removeSingleLinkageItem); editMenu.add(settingItem); // Tools Item geneContentItem = new JMenuItem("Gene Content Table"); geneContentItem.addActionListener(commandActionListener); batchSaveItem = new JMenuItem("Batch Save"); batchSaveItem.addActionListener(commandActionListener); mstItem = new JMenuItem("Minimum Spanning Tree"); mstItem.addActionListener(commandActionListener); viewNeighborItem = new JMenuItem("View Neighbor of..."); viewNeighborItem.addActionListener(commandActionListener); // // tempWorkItem = new JMenuItem("Temp Work"); // tempWorkItem.addActionListener(commandActionListener); toolsMenu = new JMenu("Tools"); toolsMenu.setMnemonic('t'); toolsMenu.add(geneContentItem); toolsMenu.add(viewNeighborItem); toolsMenu.add(mstItem); toolsMenu.add(batchSaveItem); // toolsMenu.add(tempWorkItem); // graph Menu graphMenu = new JMenu("Graph"); previousItem = new JMenuItem("Previous"); previousItem.addActionListener(commandActionListener); nextItem = new JMenuItem("Next"); nextItem.addActionListener(commandActionListener); resortItem = new JMenuItem("Resort graphs"); resortItem.addActionListener(commandActionListener); graphMenu.add(nextItem); graphMenu.add(previousItem); graphMenu.add(resortItem); // help Menu helpContentItem = new JMenuItem("Online Manual"); helpContentItem.addActionListener(commandActionListener); aboutItem = new JMenuItem("About BlastGraph"); aboutItem.addActionListener(commandActionListener); helpMenu = new JMenu("Help"); helpMenu.add(helpContentItem); helpMenu.add(aboutItem); // menu bar menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(editMenu); menuBar.add(graphMenu); menuBar.add(toolsMenu); menuBar.add(helpMenu); setJMenuBar(menuBar); // ===================mainPanel Setting=================== GridBagManager.reset(); GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH; GridBagManager.GRID_BAG.anchor = GridBagConstraints.FIRST_LINE_START; GridBagManager.GRID_BAG.weightx = 0; GridBagManager.GRID_BAG.weighty = 0; GridBagManager.GRID_BAG.insets = new Insets(2, 2, 1, 1); mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); pane.add(mainPanel); hsplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); hsplitPane.setContinuousLayout(true); hsplitPane.setOneTouchExpandable(true); hsplitPane.setResizeWeight(0.9); // ===================toolBarPanel Setting=================== // graph file toolbar fileToolBar = new JToolBar(); fileToolBar.setRollover(true); newButton = new JButton(); newButton.setBorderPainted(false); newButton.setMnemonic('n'); newButton.setToolTipText("New From Blast"); newButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/filenew.png"); // System.out.println(icon); newButton.setIcon(new ImageIcon(icon)); openButton = new JButton(); openButton.setBorderPainted(false); openButton.setMnemonic('o'); openButton.setToolTipText("Open"); openButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/fileopen.png"); openButton.setIcon(new ImageIcon(icon)); saveButton = new JButton(); saveButton.setBorderPainted(false); saveButton.setMnemonic('s'); saveButton.setToolTipText("Save"); saveButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/filesave.png"); saveButton.setIcon(new ImageIcon(icon)); saveCurImgButton = new JButton(); saveCurImgButton.setBorderPainted(false); saveCurImgButton.setToolTipText("Save current image"); saveCurImgButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/saveimage.png"); saveCurImgButton.setIcon(new ImageIcon(icon)); printButton = new JButton(); printButton.setBorderPainted(false); printButton.setToolTipText("Print..."); printButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/fileprint.png"); printButton.setIcon(new ImageIcon(icon)); fileToolBar.add(newButton); fileToolBar.add(openButton); fileToolBar.add(saveButton); fileToolBar.add(saveCurImgButton); fileToolBar.add(printButton); // graph control toolbar graphToolBar = new JToolBar(); graphToolBar.setRollover(true); previousButton = new JButton(); previousButton.setBorderPainted(false); previousButton.setToolTipText("Previous graph"); previousButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/previous.png"); previousButton.setIcon(new ImageIcon(icon)); indexField = new JTextField(); indexField.setSize(new Dimension(25, 16)); indexField.setMinimumSize(new Dimension(25, 16)); indexField.setPreferredSize(new Dimension(25, 16)); indexField.addKeyListener(keyListener); nextButton = new JButton(); nextButton.setBorderPainted(false); nextButton.setToolTipText("Next graph"); nextButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/next.png"); nextButton.setIcon(new ImageIcon(icon)); filterButton = new JButton(); filterButton.setBorderPainted(false); filterButton.setToolTipText("Filt graph"); filterButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/filter.png"); filterButton.setIcon(new ImageIcon(icon)); resortButton = new JButton(); resortButton.setBorderPainted(false); resortButton.setToolTipText("Resort graph"); resortButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/resort.png"); resortButton.setIcon(new ImageIcon(icon)); searchField = new JTextField(); searchField.setSize(new Dimension(60, 16)); searchField.setMinimumSize(new Dimension(60, 16)); searchField.setPreferredSize(new Dimension(60, 16)); searchField.addKeyListener(keyListener); searchButton = new JButton(); searchButton.setBorderPainted(false); searchButton.setToolTipText("Search"); searchButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/search.png"); searchButton.setIcon(new ImageIcon(icon)); graphToolBar.add(filterButton); graphToolBar.add(resortButton); // graphToolBar.add(new JToolBar.Separator()); graphToolBar.add(previousButton); graphToolBar.add(indexField); graphToolBar.add(nextButton); graphToolBar.add(searchField); graphToolBar.add(searchButton); // view toolbar (modebox & layoutbox) viewToolBar = new JToolBar(); viewToolBar.setRollover(true); modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { int index = modeBox.getSelectedIndex(); if (index == 2) { int annotCount = annotationToolBar.getComponentCount(); for (int i = 0; i < annotCount; i++) { annotationToolBar.getComponent(i).setEnabled(true); } } else { int annotCount = annotationToolBar.getComponentCount(); for (int i = 0; i < annotCount; i++) { annotationToolBar.getComponent(i).setEnabled(false); } } } }); layoutBox = this.getLayoutComboBox(); viewToolBar.add(modeBox); viewToolBar.add(layoutBox); colorComboBox = new JComboBox(new String[] { "vertex color", "index", "strand", "genomeAcc", "organism" }); viewToolBar.add(colorComboBox); // add additional menu to graphMenu modeMenu = graphMouse.getModeMenu(); modeMenu.setText("Mode"); layoutMenu = getLayoutMenu(); layoutMenu.setText("Layout"); graphMenu.add(modeMenu); graphMenu.add(layoutMenu); // annotation toolbar AnnotationControls<HitVertex, ValueEdge> annotationControls = new AnnotationControls<HitVertex, ValueEdge>( annotatingPlugin); annotationToolBar = annotationControls.getAnnotationsToolBar(); ((JButton) annotationToolBar.getComponent(1)).setBorderPainted(false); ((JToggleButton) annotationToolBar.getComponent(2)).setBorderPainted(false); // add toolbars to toolBarPanel toolBarPanel = new JPanel(); toolBarPanel.setLayout(new ModifiedFlowLayout(ModifiedFlowLayout.LEFT, 0, 0)); toolBarPanel.setBorder(new EtchedBorder()); toolBarPanel.add(fileToolBar); toolBarPanel.add(graphToolBar); toolBarPanel.add(viewToolBar); toolBarPanel.add(annotationToolBar); mainPanel.add(toolBarPanel, BorderLayout.NORTH); mainPanel.add(hsplitPane, BorderLayout.CENTER); // GridBagManager.add(mainPanel, toolBarPanel, 0, 0, 1, 1); // GridBagManager.add(mainPanel, hsplitPane, 0, 1, 1, 1); // mainPanel.add(toolBarPanel, BorderLayout.NORTH); // ===================vsplitPane Setting================= vsplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); vsplitPane.setContinuousLayout(true); vsplitPane.setOneTouchExpandable(true); vsplitPane.setResizeWeight(0.9); hsplitPane.setLeftComponent(vsplitPane); // GridBagManager.GRID_BAG.weightx = 0.9; // GridBagManager.GRID_BAG.weighty = 1; // GridBagManager.add(mainPanel, vsplitPane, 0, 1, 1, 2); // mainPanel.add(vsplitPane, BorderLayout.CENTER); // ===================vvPanel Setting=================== vvPanel = new GraphZoomScrollPane(vv); vsplitPane.setTopComponent(vvPanel); // ===================Tab Panel Setting======================= // progressPanel = new ProgressPanel(); verticesTable = new VerticesTable(); verticesTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int row = verticesTable.rowAtPoint(e.getPoint()); int col = verticesTable.columnAtPoint(e.getPoint()); // System.out.println(row + " " + col); String value = verticesTable.getValueAt(row, col).toString(); // System.out.println(value); if (Global.graph.containsVertex(new HitVertex(value))) { for (int i = 0; i < subSetList.size(); i++) { if (subSetList.get(i).contains(new HitVertex(value))) { curGraph = FilterUtils.createInducedSubgraph(subSetList.get(i), Global.graph); PickedState<HitVertex> pickedVertexState = vv.getPickedVertexState(); // picked is a reference to picked vertices // use a temp set to avoid concurrent modification Set<HitVertex> picked = pickedVertexState.getPicked(); Set<HitVertex> temp = new HashSet<HitVertex>(); for (HitVertex hitVertex : picked) { temp.add(hitVertex); } for (HitVertex hv : temp) { pickedVertexState.pick(hv, false); } pickedVertexState.pick(new HitVertex(value), true); // refreshSubGraphView(); return; } } } } }); verticesTable.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { int row = verticesTable.rowAtPoint(e.getPoint()); int col = verticesTable.columnAtPoint(e.getPoint()); String value = verticesTable.getValueAt(row, col).toString(); // System.out.println(value); if (Global.graph.containsVertex(value)) { Cursor normalCursor = new Cursor(Cursor.HAND_CURSOR); setCursor(normalCursor); } else { Cursor normalCursor = new Cursor(Cursor.DEFAULT_CURSOR); setCursor(normalCursor); } } }); verticesPanel = new JPanel(); verticesPanel.setLayout(new GridLayout()); verticesPanel.add(new JScrollPane(verticesTable)); edgesTable = new EdgesTable(); edgesPanel = new JPanel(); edgesPanel.setLayout(new GridLayout()); edgesPanel.add(new JScrollPane(edgesTable)); tabbedPane = new JTabbedPane(); tabbedPane.addTab("Vertices", verticesPanel); tabbedPane.addTab("Edges", edgesPanel); vsplitPane.setBottomComponent(tabbedPane); graphMouse.addPichedChangeListener(verticesTable, edgesTable); // ===================Info Panel Setting=================== infoPanel = new JPanel(new GridBagLayout()); GridBagManager.GRID_BAG.weightx = 0.1; GridBagManager.GRID_BAG.weighty = 1; hsplitPane.setRightComponent(infoPanel); JPanel mainInfoPanel = new JPanel(new GridBagLayout()); mainInfoPanel .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Main Info")); JPanel currentInfoPanel = new JPanel(new GridBagLayout()); currentInfoPanel.setBorder( BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Current Graph")); JPanel selectedInfoPanel = new JPanel(new GridBagLayout()); selectedInfoPanel .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Selected")); JPanel statisticsInfoPanel = new JPanel(new GridBagLayout()); statisticsInfoPanel .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Statistics")); JPanel progressInfoPanel = new JPanel(new GridBagLayout()); progressInfoPanel .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Progress")); GridBagManager.GRID_BAG.anchor = GridBagConstraints.NORTH; GridBagManager.GRID_BAG.fill = GridBagConstraints.HORIZONTAL; GridBagManager.GRID_BAG.weighty = 0; GridBagManager.add(infoPanel, mainInfoPanel, 0, 1, 1, 1); GridBagManager.add(infoPanel, currentInfoPanel, 0, 2, 1, 1); GridBagManager.add(infoPanel, selectedInfoPanel, 0, 3, 1, 1); GridBagManager.GRID_BAG.weighty = 0.5; GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH; GridBagManager.add(infoPanel, statisticsInfoPanel, 0, 4, 1, 1); GridBagManager.add(infoPanel, progressInfoPanel, 0, 5, 1, 1); // mainInfoPanel { JLabel vertices = new JLabel("Vertices:"); vertexCountLabel = new JLabel("0"); JLabel edges = new JLabel("Edges:"); edgeCountLabel = new JLabel("0"); JLabel subGraphs = new JLabel("SubGraphs:"); subGraphCountLabel = new JLabel("0"); GridBagManager.GRID_BAG.anchor = GridBagConstraints.WEST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(mainInfoPanel, vertices, 0, 0, 1, 1); GridBagManager.add(mainInfoPanel, edges, 0, 1, 1, 1); GridBagManager.add(mainInfoPanel, subGraphs, 0, 2, 1, 1); GridBagManager.GRID_BAG.anchor = GridBagConstraints.EAST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(mainInfoPanel, vertexCountLabel, 1, 0, 1, 1); GridBagManager.add(mainInfoPanel, edgeCountLabel, 1, 1, 1, 1); GridBagManager.add(mainInfoPanel, subGraphCountLabel, 1, 2, 1, 1); } // end of mainInfoPanel // currentInfoPanel { JLabel vertices = new JLabel("Vertices:"); currentVertexCountLabel = new JLabel("0"); JLabel edges = new JLabel("Edges:"); currentEdgeCountLabel = new JLabel("0"); JLabel acc = new JLabel("ACC:"); currentAccLabel = new JLabel("0"); GridBagManager.GRID_BAG.anchor = GridBagConstraints.WEST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(currentInfoPanel, vertices, 0, 0, 1, 1); GridBagManager.add(currentInfoPanel, edges, 0, 1, 1, 1); GridBagManager.add(currentInfoPanel, acc, 0, 2, 1, 1); GridBagManager.GRID_BAG.anchor = GridBagConstraints.EAST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(currentInfoPanel, currentVertexCountLabel, 1, 0, 1, 1); GridBagManager.add(currentInfoPanel, currentEdgeCountLabel, 1, 1, 1, 1); GridBagManager.add(currentInfoPanel, currentAccLabel, 1, 2, 1, 1); } // end of currentInfoPanel // selectedInfoPanel { JLabel vertices = new JLabel("Vertices:"); selectedVertexCountLabel = new JLabel("0"); JLabel edges = new JLabel("Edges:"); selectedEdgeCountLabel = new JLabel("0"); GridBagManager.GRID_BAG.anchor = GridBagConstraints.WEST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(selectedInfoPanel, vertices, 0, 0, 1, 1); GridBagManager.add(selectedInfoPanel, edges, 0, 1, 1, 1); GridBagManager.GRID_BAG.anchor = GridBagConstraints.EAST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(selectedInfoPanel, selectedVertexCountLabel, 1, 0, 1, 1); GridBagManager.add(selectedInfoPanel, selectedEdgeCountLabel, 1, 1, 1, 1); CollectionChangeListener<HitVertex> svListener = new CollectionChangeListener<HitVertex>() { @Override public void onCollectionChange(Set<HitVertex> set) { selectedVertexCountLabel.setText("" + set.size()); } }; CollectionChangeListener<ValueEdge> veListener = new CollectionChangeListener<ValueEdge>() { @Override public void onCollectionChange(Set<ValueEdge> set) { selectedEdgeCountLabel.setText("" + set.size()); } }; graphMouse.addPichedChangeListener(svListener, veListener); } // end of selectedInfoPanel {// statistics Panel GridBagManager.GRID_BAG.anchor = GridBagConstraints.NORTH; GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH; GridBagManager.add(statisticsInfoPanel, graphStatisticsPanel, 0, 0, 1, 1); } // statistics Panel {// progressInfoPanel GridBagManager.GRID_BAG.anchor = GridBagConstraints.NORTH; GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH; GridBagManager.add(progressInfoPanel, progressPanel, 0, 0, 1, 1); } // progressInfoPanel // set frame size Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); setSize((screen.width * 3) / 4, (screen.height * 9) / 10); setLocation(screen.width / 6, screen.height / 16); refreshUI(false); }
From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java
private JPanel createFakeDataPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 0.5;/*from w w w .j a va 2s .c o m*/ JPanel folderPanel = new JPanel(); folderPanel.setLayout(new BoxLayout(folderPanel, BoxLayout.X_AXIS)); folderPanel.setBorder(BorderFactory.createTitledBorder("Scan report file")); scanReportFileField = new JTextField(); scanReportFileField.setText((new File("ScanReport.xlsx").getAbsolutePath())); scanReportFileField.setToolTipText( "The path to the scan report that will be used as a template to generate the fake data"); folderPanel.add(scanReportFileField); JButton pickButton = new JButton("Pick file"); pickButton.setToolTipText("Pick a scan report file"); folderPanel.add(pickButton); pickButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pickScanReportFile(); } }); componentsToDisableWhenRunning.add(pickButton); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; panel.add(folderPanel, c); JPanel targetPanel = new JPanel(); targetPanel.setLayout(new GridLayout(0, 2)); targetPanel.setBorder(BorderFactory.createTitledBorder("Target data location")); targetPanel.add(new JLabel("Data type")); targetType = new JComboBox<String>( new String[] { "Delimited text files", "MySQL", "Oracle", "SQL Server", "PostgreSQL" }); // targetType = new JComboBox(new String[] { "Delimited text files", "MySQL" }); targetType.setToolTipText("Select the type of source data available"); targetType.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent arg0) { targetIsFiles = arg0.getItem().toString().equals("Delimited text files"); targetServerField.setEnabled(!targetIsFiles); targetUserField.setEnabled(!targetIsFiles); targetPasswordField.setEnabled(!targetIsFiles); targetDatabaseField.setEnabled(!targetIsFiles); targetCSVFormat.setEnabled(targetIsFiles); if (!targetIsFiles && arg0.getItem().toString().equals("Oracle")) { targetServerField.setToolTipText( "For Oracle servers this field contains the SID, servicename, and optionally the port: '<host>/<sid>', '<host>:<port>/<sid>', '<host>/<service name>', or '<host>:<port>/<service name>'"); targetUserField.setToolTipText( "For Oracle servers this field contains the name of the user used to log in"); targetPasswordField.setToolTipText( "For Oracle servers this field contains the password corresponding to the user"); targetDatabaseField.setToolTipText( "For Oracle servers this field contains the schema (i.e. 'user' in Oracle terms) containing the source tables"); } else if (!targetIsFiles && arg0.getItem().toString().equals("PostgreSQL")) { targetServerField.setToolTipText( "For PostgreSQL servers this field contains the host name and database name (<host>/<database>)"); targetUserField.setToolTipText("The user used to log in to the server"); targetPasswordField.setToolTipText("The password used to log in to the server"); targetDatabaseField.setToolTipText( "For PostgreSQL servers this field contains the schema containing the source tables"); } else if (!targetIsFiles) { targetServerField .setToolTipText("This field contains the name or IP address of the database server"); if (arg0.getItem().toString().equals("SQL Server")) targetUserField.setToolTipText( "The user used to log in to the server. Optionally, the domain can be specified as <domain>/<user> (e.g. 'MyDomain/Joe')"); else targetUserField.setToolTipText("The user used to log in to the server"); targetPasswordField.setToolTipText("The password used to log in to the server"); targetDatabaseField.setToolTipText("The name of the database containing the source tables"); } } }); targetPanel.add(targetType); targetPanel.add(new JLabel("Server location")); targetServerField = new JTextField("127.0.0.1"); targetServerField.setEnabled(false); targetPanel.add(targetServerField); targetPanel.add(new JLabel("User name")); targetUserField = new JTextField(""); targetUserField.setEnabled(false); targetPanel.add(targetUserField); targetPanel.add(new JLabel("Password")); targetPasswordField = new JPasswordField(""); targetPasswordField.setEnabled(false); targetPanel.add(targetPasswordField); targetPanel.add(new JLabel("Database name")); targetDatabaseField = new JTextField(""); targetDatabaseField.setEnabled(false); targetPanel.add(targetDatabaseField); targetPanel.add(new JLabel("CSV Format")); targetCSVFormat = new JComboBox<>(new String[] { "Default (comma, CRLF)", "TDF (tab, CRLF)", "MySQL (tab, LF)", "RFC4180", "Excel CSV" }); targetCSVFormat.setToolTipText("The format of the output"); targetCSVFormat.setEnabled(true); targetPanel.add(targetCSVFormat); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; panel.add(targetPanel, c); JPanel fakeDataButtonPanel = new JPanel(); fakeDataButtonPanel.setLayout(new BoxLayout(fakeDataButtonPanel, BoxLayout.X_AXIS)); fakeDataButtonPanel.add(new JLabel("Max rows per table")); generateRowCount = new JSpinner(); generateRowCount.setValue(10000); fakeDataButtonPanel.add(generateRowCount); fakeDataButtonPanel.add(Box.createHorizontalGlue()); JButton testConnectionButton = new JButton("Test connection"); testConnectionButton.setBackground(new Color(151, 220, 141)); testConnectionButton.setToolTipText("Test the connection"); testConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { testConnection(getTargetDbSettings()); } }); componentsToDisableWhenRunning.add(testConnectionButton); fakeDataButtonPanel.add(testConnectionButton); JButton fakeDataButton = new JButton("Generate fake data"); fakeDataButton.setBackground(new Color(151, 220, 141)); fakeDataButton.setToolTipText("Generate fake data based on the scan report"); fakeDataButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fakeDataRun(); } }); componentsToDisableWhenRunning.add(fakeDataButton); fakeDataButtonPanel.add(fakeDataButton); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; panel.add(fakeDataButtonPanel, c); return panel; }
From source file:org.apache.taverna.activities.rest.ui.config.RESTActivityConfigurationPanel.java
private JPanel createAdvancedTab() { JPanel jpAdvanced = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0;// w ww .j a va 2 s .co m c.gridy = 0; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.BOTH; c.insets = new Insets(8, 10, 2, 4); JLabel jlExpectHeaderInfoIcon = new JLabel(infoIcon); jlExpectHeaderInfoIcon .setToolTipText("<html>Ticking this checkbox may significantly improve performance when<br>" + "large volumes of data are sent to the remote server and a redirect<br>" + "from the original URL to the one specified by the server is likely.<br>" + "<br>" + "However, this checkbox <b>must not</b> be ticked to allow this activity<br>" + "to post updates to Twitter.</html>"); jpAdvanced.add(jlExpectHeaderInfoIcon, c); c.gridx++; c.weightx = 1.0; c.insets = new Insets(8, 0, 2, 8); cbSendHTTPExpectHeader = new JCheckBox("Send HTTP Expect request-header field"); jpAdvanced.add(cbSendHTTPExpectHeader, c); c.gridx = 0; c.gridy++; c.weightx = 0; c.insets = new Insets(2, 10, 5, 4); JLabel jlShowRedirectionOutputPortInfoIcon = new JLabel(infoIcon); jlShowRedirectionOutputPortInfoIcon .setToolTipText("<html>\"Redirection\" output port displays the URL of the final redirect<br>" + "that has yielded the output data on the \"Response Body\" port.</html>"); jpAdvanced.add(jlShowRedirectionOutputPortInfoIcon, c); c.gridx++; c.weightx = 1.0; c.insets = new Insets(2, 0, 5, 8); cbShowRedirectionOutputPort = new JCheckBox("Show \"Redirection\" output port"); jpAdvanced.add(cbShowRedirectionOutputPort, c); c.gridx = 0; c.gridy++; c.weightx = 0; c.insets = new Insets(2, 10, 5, 4); JLabel jlShowActualUrlPortInfoIcon = new JLabel(infoIcon); jlShowActualUrlPortInfoIcon .setToolTipText("<html>\"Actual URL\" output port displays the URL used by the REST service<br>" + "with the actual parameter values.</html>"); jpAdvanced.add(jlShowActualUrlPortInfoIcon, c); c.gridx++; c.weightx = 1.0; c.insets = new Insets(2, 0, 5, 8); cbShowActualUrlPort = new JCheckBox("Show \"Actual URL\" output port"); jpAdvanced.add(cbShowActualUrlPort, c); c.gridx = 0; c.gridy++; c.weightx = 0; c.insets = new Insets(2, 10, 5, 4); JLabel jlShowResponseHeadersPortInfoIcon = new JLabel(infoIcon); jlShowResponseHeadersPortInfoIcon .setToolTipText("<html>\"Response headers\" output port displays the HTTP headers<br>" + "received from the final (after redirection) HTTP call.</html>"); jpAdvanced.add(jlShowResponseHeadersPortInfoIcon, c); c.gridx++; c.weightx = 1.0; c.insets = new Insets(2, 0, 5, 8); cbShowResponseHeadersPort = new JCheckBox("Show \"Response headers\" output port"); jpAdvanced.add(cbShowResponseHeadersPort, c); c.gridx = 0; c.gridy++; c.weightx = 0; c.insets = new Insets(2, 10, 5, 4); JLabel jlEscapeParametersInfoIcon = new JLabel(infoIcon); jlEscapeParametersInfoIcon.setToolTipText("<html>Determines if parameters you pass to form the full URL<br>" + " of the REST service will be URL-escaped.</html>"); jpAdvanced.add(jlEscapeParametersInfoIcon, c); c.gridx++; c.weightx = 1.0; c.insets = new Insets(2, 0, 5, 8); cbEscapeParameters = new JCheckBox("Escape URL parameter values"); jpAdvanced.add(cbEscapeParameters, c); c.gridx = 0; c.gridy++; c.weightx = 0; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; c.insets = new Insets(2, 10, 5, 4); JLabel jlHTTPHeadersInfoIcon = new JLabel(infoIcon); jlHTTPHeadersInfoIcon.setToolTipText("<html>Set additional HTTP headers</html>"); jpAdvanced.add(jlHTTPHeadersInfoIcon, c); c.gridx = 1; c.weightx = 0; c.weighty = 0; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; c.insets = new Insets(2, 10, 5, 4); addHeaderButton = new JButton("Add HTTP header"); addHeaderButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { httpHeadersTableModel.addEmptyRow(); httpHeadersTable.getSelectionModel().setSelectionInterval(httpHeadersTableModel.getRowCount() - 1, httpHeadersTableModel.getRowCount() - 1); } }); removeHeaderButton = new JButton("Remove HTTP header"); removeHeaderButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int row = httpHeadersTable.getSelectedRow(); httpHeadersTableModel.removeRow(row); } }); JPanel buttonPanel = new JPanel(); buttonPanel.add(addHeaderButton, FlowLayout.LEFT); buttonPanel.add(removeHeaderButton); jpAdvanced.add(buttonPanel, c); c.gridx = 1; c.gridy++; c.weightx = 0; c.weighty = 1.0; c.fill = GridBagConstraints.BOTH; c.insets = new Insets(2, 10, 5, 4); httpHeadersTableModel = new HTTPHeadersTableModel(); httpHeadersTable = new JTable(httpHeadersTableModel); httpHeadersTable.setGridColor(Color.GRAY); httpHeadersTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); setVisibleRowCount(httpHeadersTable, 3); JScrollPane headersTableScrollPane = new JScrollPane(httpHeadersTable); jpAdvanced.add(headersTableScrollPane, c); return (jpAdvanced); }
From source file:org.apache.jmeter.testbeans.gui.GenericTestBeanCustomizer.java
/** * Initialize the GUI.//w ww. j av a2 s.c o m */ private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final) setLayout(new GridBagLayout()); GridBagConstraints cl = new GridBagConstraints(); // for labels cl.gridx = 0; cl.anchor = GridBagConstraints.EAST; cl.insets = new Insets(0, 1, 0, 1); GridBagConstraints ce = new GridBagConstraints(); // for editors ce.fill = GridBagConstraints.BOTH; ce.gridx = 1; ce.weightx = 1.0; ce.insets = new Insets(0, 1, 0, 1); GridBagConstraints cp = new GridBagConstraints(); // for panels cp.fill = GridBagConstraints.BOTH; cp.gridx = 1; cp.gridy = GridBagConstraints.RELATIVE; cp.gridwidth = 2; cp.weightx = 1.0; JPanel currentPanel = this; String currentGroup = DEFAULT_GROUP; int y = 0; for (int i = 0; i < editors.length; i++) { if (editors[i] == null) { continue; } if (log.isDebugEnabled()) { log.debug("Laying property " + descriptors[i].getName()); } String g = group(descriptors[i]); if (!currentGroup.equals(g)) { if (currentPanel != this) { add(currentPanel, cp); } currentGroup = g; currentPanel = new JPanel(new GridBagLayout()); currentPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), groupDisplayName(g))); cp.weighty = 0.0; y = 0; } Component customEditor = editors[i].getCustomEditor(); boolean multiLineEditor = false; if (customEditor.getPreferredSize().height > 50 || customEditor instanceof JScrollPane || descriptors[i].getValue(MULTILINE) != null) { // TODO: the above works in the current situation, but it's // just a hack. How to get each editor to report whether it // wants to grow bigger? Whether the property label should // be at the left or at the top of the editor? ...? multiLineEditor = true; } JLabel label = createLabel(descriptors[i]); label.setLabelFor(customEditor); cl.gridy = y; cl.gridwidth = multiLineEditor ? 2 : 1; cl.anchor = multiLineEditor ? GridBagConstraints.CENTER : GridBagConstraints.EAST; currentPanel.add(label, cl); ce.gridx = multiLineEditor ? 0 : 1; ce.gridy = multiLineEditor ? ++y : y; ce.gridwidth = multiLineEditor ? 2 : 1; ce.weighty = multiLineEditor ? 1.0 : 0.0; cp.weighty += ce.weighty; currentPanel.add(customEditor, ce); y++; } if (currentPanel != this) { add(currentPanel, cp); } // Add a 0-sized invisible component that will take all the vertical // space that nobody wants: cp.weighty = 0.0001; add(Box.createHorizontalStrut(0), cp); }
From source file:Citas.FrameCita.java
private void dibujarPanelCita(Medico medico) { min = medico.getMinutosDeAtencionxPaciente(); int horaInicio; int minInicio; int horaActual; int minActual; GridBagConstraints gbc = new GridBagConstraints(); horaInicio = medico.getHoraInicio(); horaActual = medico.getHoraInicio(); minInicio = medico.getMinInicio();/* www .j a v a 2 s. c o m*/ minActual = medico.getMinInicio(); gbc.gridx = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.BOTH; for (int i = 0; i < medico.getCitasPorDia(); i++) { minActual += medico.getMinutosDeAtencionxPaciente(); if (minActual == 60) { horaActual += 1; minActual = 0; } gbc.gridy = i + 1; System.out.print(String.format("%02d", horaInicio)); citas[i] = new Citas( ("" + String.format("%02d", horaInicio) + ":" + String.format("%02d", minInicio) + " - " + String.format("%02d", horaActual) + ":" + String.format("%02d", minActual)), ("" + String.format("%02d", horaInicio) + ":" + String.format("%02d", minInicio) + ":" + String.format("%02d", 0))); citas[i].setBorder(BorderFactory.createLineBorder(Color.black)); citas[i].setOpaque(true); citas[i].addMouseListener(new MouseListener() { @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mouseClicked(MouseEvent e) { fechaJ.setText(jCalendar1.getDate().toString()); fechaJ.setEnabled(true); acciones(null); } }); PanelCita.add(citas[i], gbc); System.out.print(i); horaInicio = horaActual; minInicio = minActual; } }