List of usage examples for java.awt GridBagConstraints NONE
int NONE
To view the source code for java.awt GridBagConstraints NONE.
Click Source Link
From source file:it.cnr.icar.eric.client.ui.swing.RegistryBrowser.java
/** * Creates a new RegistryBrowser object. *//*w w w . j a v a2 s . c om*/ @SuppressWarnings("unchecked") private RegistryBrowser() { instance = this; classLoader = getClass().getClassLoader(); // new // JAXRBrowserClassLoader(getClass().getClassLoader()); Thread.currentThread().setContextClassLoader(classLoader); /* * try { classLoader.loadClass("javax.xml.soap.SOAPMessage"); } catch * (ClassNotFoundException e) { * log.error("Could not find class javax.xml.soap.SOAPMessage", e); } */ UIManager.addPropertyChangeListener(new UISwitchListener(getRootPane())); // add listener for 'locale' bound property addPropertyChangeListener(PROPERTY_LOCALE, this); menuBar = new JMenuBar(); fileMenu = new JMenu(); editMenu = new JMenu(); viewMenu = new JMenu(); helpMenu = new JMenu(); JSeparator JSeparator1 = new JSeparator(); newItem = new JMenuItem(); importItem = new JMenuItem(); saveItem = new JMenuItem(); saveAsItem = new JMenuItem(); exitItem = new JMenuItem(); cutItem = new JMenuItem(); copyItem = new JMenuItem(); pasteItem = new JMenuItem(); aboutItem = new JMenuItem(); setJMenuBar(menuBar); setTitle(resourceBundle.getString("title.registryBrowser.java")); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); getContentPane().setLayout(new BorderLayout(0, 0)); // Scale window to be centered using 70% of screen Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); setBounds((int) (dim.getWidth() * .15), (int) (dim.getHeight() * .1), (int) (dim.getWidth() * .7), (int) (dim.getHeight() * .75)); setVisible(false); saveFileDialog.setMode(FileDialog.SAVE); saveFileDialog.setTitle(resourceBundle.getString("dialog.save.title")); GridBagLayout gb = new GridBagLayout(); topPanel.setLayout(gb); getContentPane().add("North", topPanel); GridBagConstraints c = new GridBagConstraints(); toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0)); toolbarPanel.setBounds(0, 0, 488, 29); discoveryToolBar = createDiscoveryToolBar(); toolbarPanel.add(discoveryToolBar); // c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.5; c.weighty = 0.5; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 0); gb.setConstraints(toolbarPanel, c); topPanel.add(toolbarPanel); // Panel containing context info like registry location and user context JPanel contextPanel = new JPanel(); GridBagLayout gb1 = new GridBagLayout(); contextPanel.setLayout(gb1); locationLabel = new JLabel(resourceBundle.getString("label.registryLocation")); // locationLabel.setPreferredSize(new Dimension(80, 23)); // c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.5; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 0, 0); gb1.setConstraints(locationLabel, c); // contextPanel.setBackground(Color.green); contextPanel.add(locationLabel); selectAnItemText = new ItemText(selectAnItem); registryCombo.addItem(selectAnItemText.toString()); ConfigurationType uiConfigurationType = UIUtility.getInstance().getConfigurationType(); RegistryURIListType urlList = uiConfigurationType.getRegistryURIList(); List<String> urls = urlList.getRegistryURI(); Iterator<String> urlsIter = urls.iterator(); while (urlsIter.hasNext()) { ItemText url = new ItemText(urlsIter.next()); registryCombo.addItem(url.toString()); } registryCombo.setEditable(true); registryCombo.setEnabled(true); registryCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final String url = (String) registryCombo.getSelectedItem(); if ((url == null) || (url.equals(selectAnItem))) { return; } // Clean tabbedPaneParent. Will create new content tabbedPaneParent.removeAll(); conceptsTreeDialog = null; ConceptsTreeDialog.clearCache(); // design: // 1. connect and construct tabbedPane in a now swing thread // 2. add tabbedPane in swing thread // 3. call reloadModel that should use WingWorkers final SwingWorker worker1 = new SwingWorker(RegistryBrowser.this) { public Object doNonUILogic() { try { // Try to connect if (connectToRegistry(url)) { return new JBTabbedPane(); } } catch (JAXRException e1) { displayError(e1); } return null; } public void doUIUpdateLogic() { tabbedPane = (JBTabbedPane) get(); if (tabbedPane != null) { tabbedPaneParent.add(tabbedPane, BorderLayout.CENTER); tabbedPane.reloadModel(); try { // DBH 1/30/04 - Add the submissions panel if // the user is authenticated. ConnectionImpl connection = RegistryBrowser.client.connection; boolean newValue = connection.isAuthenticated(); firePropertyChange(PROPERTY_AUTHENTICATED, false, newValue); getRootPane().updateUI(); } catch (JAXRException e1) { displayError(e1); } } } }; worker1.start(); } }); // c.gridx = 1; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.9; c.weighty = 0.5; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 0, 5, 0); gb1.setConstraints(registryCombo, c); contextPanel.add(registryCombo); JLabel currentUserLabel = new JLabel(resourceBundle.getString("label.currentUser"), SwingConstants.TRAILING); c.gridx = 2; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 5, 0); gb1.setConstraints(currentUserLabel, c); // contextPanel.add(currentUserLabel); currentUserText.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { @SuppressWarnings("unused") String text = currentUserText.getText(); } }); currentUserText.setEditable(false); c.gridx = 3; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.9; c.weighty = 0.5; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 5, 5); gb1.setConstraints(currentUserText, c); // contextPanel.add(currentUserText); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.9; c.weighty = 0.5; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 0, 0, 0); gb.setConstraints(contextPanel, c); topPanel.add(contextPanel, c); tabbedPaneParent.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); tabbedPaneParent.setLayout(new BorderLayout()); tabbedPaneParent.setToolTipText(resourceBundle.getString("tabbedPane.tip")); getContentPane().add("Center", tabbedPaneParent); fileMenu.setText(resourceBundle.getString("menu.file")); fileMenu.setActionCommand("File"); fileMenu.setMnemonic((int) 'F'); menuBar.add(fileMenu); saveItem.setHorizontalTextPosition(SwingConstants.TRAILING); saveItem.setText(resourceBundle.getString("menu.save")); saveItem.setActionCommand("Save"); saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK)); saveItem.setMnemonic((int) 'S'); // fileMenu.add(saveItem); fileMenu.add(JSeparator1); importItem.setText(resourceBundle.getString("menu.import")); importItem.setActionCommand("Import"); importItem.setMnemonic((int) 'I'); importItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { RegistryBrowser.setWaitCursor(); importFromFile(); RegistryBrowser.setDefaultCursor(); } }); fileMenu.add(importItem); exitItem.setText(resourceBundle.getString("menu.exit")); exitItem.setActionCommand("Exit"); exitItem.setMnemonic((int) 'X'); fileMenu.add(exitItem); editMenu.setText(resourceBundle.getString("menu.edit")); editMenu.setActionCommand("Edit"); editMenu.setMnemonic((int) 'E'); // menuBar.add(editMenu); cutItem.setHorizontalTextPosition(SwingConstants.TRAILING); cutItem.setText(resourceBundle.getString("menu.cut")); cutItem.setActionCommand("Cut"); cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK)); cutItem.setMnemonic((int) 'T'); editMenu.add(cutItem); copyItem.setHorizontalTextPosition(SwingConstants.TRAILING); copyItem.setText(resourceBundle.getString("menu.copy")); copyItem.setActionCommand("Copy"); copyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK)); copyItem.setMnemonic((int) 'C'); editMenu.add(copyItem); pasteItem.setHorizontalTextPosition(SwingConstants.TRAILING); pasteItem.setText(resourceBundle.getString("menu.paste")); pasteItem.setActionCommand("Paste"); pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK)); pasteItem.setMnemonic((int) 'P'); editMenu.add(pasteItem); viewMenu.setText(resourceBundle.getString("menu.view")); viewMenu.setActionCommand("view"); viewMenu.setMnemonic((int) 'V'); themeMenu = new MetalThemeMenu(resourceBundle.getString("menu.theme"), themes); viewMenu.add(themeMenu); menuBar.add(viewMenu); helpMenu.setText(resourceBundle.getString("menu.help")); helpMenu.setActionCommand("Help"); helpMenu.setMnemonic((int) 'H'); menuBar.add(helpMenu); aboutItem.setHorizontalTextPosition(SwingConstants.TRAILING); aboutItem.setText(resourceBundle.getString("menu.about")); aboutItem.setActionCommand("About..."); aboutItem.setMnemonic((int) 'A'); aboutItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Object[] aboutArgs = { BROWSER_VERSION }; MessageFormat form = new MessageFormat(resourceBundle.getString("dialog.about.text")); JOptionPane.showMessageDialog(RegistryBrowser.this, form.format(aboutArgs), resourceBundle.getString("dialog.about.title"), JOptionPane.INFORMATION_MESSAGE); } }); helpMenu.add(aboutItem); // REGISTER_LISTENERS SymWindow aSymWindow = new SymWindow(); this.addWindowListener(aSymWindow); SymAction lSymAction = new SymAction(); saveItem.addActionListener(lSymAction); exitItem.addActionListener(lSymAction); SwingUtilities.updateComponentTreeUI(getContentPane()); SwingUtilities.updateComponentTreeUI(menuBar); SwingUtilities.updateComponentTreeUI(fileChooser); // Auto select the registry that is configured to connect to by default String selectedIndexStr = ProviderProperties.getInstance() .getProperty("jaxr-ebxml.registryBrowser.registryLocationCombo.initialSelectionIndex", "0"); int index = Integer.parseInt(selectedIndexStr); try { registryCombo.setSelectedIndex(index); } catch (IllegalArgumentException e) { Object[] invalidIndexArguments = { new Integer(index) }; MessageFormat form = new MessageFormat(resourceBundle.getString("message.error.invalidIndex")); displayError(form.format(invalidIndexArguments), e); } }
From source file:org.docx4all.swing.ExternalHyperlinkDialog.java
private void fillRow4(JPanel host, GridBagConstraints c) { c.gridx = 0;/*from ww w.java 2 s . c o m*/ c.gridy = 3; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.insets = gridCellInsets; c.ipadx = 0; c.ipady = 0; c.anchor = GridBagConstraints.LINE_START; c.fill = GridBagConstraints.NONE; this.directoryPathLabel = new JLabel("Directory Full Path"); host.add(this.directoryPathLabel, c); c.gridx = 1; c.gridy = 2; c.gridwidth = 2; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.insets = gridCellInsets; c.ipadx = 0; c.ipady = 0; c.anchor = GridBagConstraints.LINE_START; c.fill = GridBagConstraints.HORIZONTAL; host.add(Box.createHorizontalGlue(), c); }
From source file:TalkServerThread.java
public void init() { //Get the address of the host we came from. host = getCodeBase().getHost();/* w ww . j ava2 s . co m*/ //Set up the UI. GridBagLayout gridBag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridBag); message = new TextField(""); c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = GridBagConstraints.REMAINDER; gridBag.setConstraints(message, c); message.addActionListener(this); add(message); display = new TextArea(10, 40); display.setEditable(false); c.weightx = 1.0; c.weighty = 1.0; c.fill = GridBagConstraints.BOTH; gridBag.setConstraints(display, c); add(display); Label l = new Label("Enter the port (on host " + host + ") to send the request to:", Label.RIGHT); c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = 1; c.weightx = 0.0; c.weighty = 0.0; gridBag.setConstraints(l, c); add(l); portField = new TextField(6); c.fill = GridBagConstraints.NONE; gridBag.setConstraints(portField, c); portField.addActionListener(this); add(portField); button = new Button("Connect"); gridBag.setConstraints(button, c); button.addActionListener(this); add(button); newline = System.getProperty("line.separator"); }
From source file:edu.harvard.mcz.imagecapture.LoginDialog.java
/** * This method initializes jPanel1 //from w w w.ja v a2 s . c o m * * @return javax.swing.JPanel */ private JPanel getJPanel1() { if (jPanel1 == null) { GridBagConstraints gridBagConstraints13 = new GridBagConstraints(); gridBagConstraints13.ipady = 3; GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); gridBagConstraints11.anchor = GridBagConstraints.EAST; gridBagConstraints11.insets = new Insets(0, 0, 0, 0); gridBagConstraints11.gridx = 1; gridBagConstraints11.gridy = 0; gridBagConstraints11.ipady = 3; gridBagConstraints11.fill = GridBagConstraints.NONE; jPanel1 = new JPanel(); jPanel1.setLayout(new GridBagLayout()); jPanel1.add(getJButtonCancel(), gridBagConstraints13); jPanel1.add(getJButtonLogin(), gridBagConstraints11); } return jPanel1; }
From source file:it.ventuland.ytd.ui.GUIClient.java
private void addComponentsToPane(final Container pane) { this.panel = new JPanel(); this.panel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; ActionManager lActionManager = new ActionManager(); dlm = new DefaultListModel<String>(); this.urllist = new JList<String>(dlm); // TODO maybe we add a button to remove added URLs from list? //this.userlist.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION ); this.urllist.setFocusable(false); textarea = new JTextArea(2, 2); textarea.setEditable(true);//from www . ja v a 2s . com textarea.setFocusable(false); JScrollPane leftscrollpane = new JScrollPane(this.urllist); JScrollPane rightscrollpane = new JScrollPane(textarea); this.middlepane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftscrollpane, rightscrollpane); this.middlepane.setOneTouchExpandable(true); this.middlepane.setDividerLocation(150); Dimension minimumSize = new Dimension(25, 25); leftscrollpane.setMinimumSize(minimumSize); rightscrollpane.setMinimumSize(minimumSize); this.directorybutton = new JButton("", createImageIcon("images/open.png", "")); gbc.gridx = 0; gbc.gridy = 0; this.directorybutton.addActionListener(lActionManager); this.panel.add(this.directorybutton, gbc); this.saveconfigcheckbox = new JCheckBox("Save config"); this.saveconfigcheckbox.setSelected(false); this.panel.add(this.saveconfigcheckbox); this.saveconfigcheckbox.setEnabled(false); // TODO check if initial download directory exists // assume that at least the users homedir exists String shomedir = System.getProperty("user.home").concat(File.separator); gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = 2; gbc.fill = GridBagConstraints.HORIZONTAL; this.directorytextfield = new JTextField(shomedir, 20 + (mIsDebug ? 48 : 0)); this.directorytextfield.setEnabled(false); this.directorytextfield.setFocusable(true); this.directorytextfield.addActionListener(lActionManager); this.panel.add(this.directorytextfield, gbc); JLabel dirhint = new JLabel("Download to folder:"); gbc.gridx = 0; gbc.gridy = 1; this.panel.add(dirhint, gbc); this.middlepane.setPreferredSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().width / 3, Toolkit.getDefaultToolkit().getScreenSize().height / 4 + (mIsDebug ? 200 : 0))); gbc.gridx = 0; gbc.gridy = 3; gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 2; gbc.weightx = 2; gbc.gridwidth = 2; this.panel.add(this.middlepane, gbc); // radio buttons for resolution to download mVideoResolutionBtnGrp = new ButtonGroup(); JPanel lRadioPanel = new JPanel(new GridLayout(1, 0)); List<Object> lVidQ = mAppContext.getList("youtube-downloader.video-quality"); JRadioButton lRadioButton = null; for (Object obj : lVidQ) { String lQuality = (String) obj; String lToolTip = mAppContext.getString("youtube-downloader.video-quality." + lQuality + ".tooltip"); boolean lSelected = mAppContext .getBoolean("youtube-downloader.video-quality." + lQuality + ".selected"); boolean lEnabled = mAppContext.getBoolean("youtube-downloader.video-quality." + lQuality + ".enabled"); lRadioButton = new JRadioButton(lQuality); lRadioButton.setName(lQuality); lRadioButton.setActionCommand(lQuality.toLowerCase()); lRadioButton.addActionListener(lActionManager); lRadioButton.setToolTipText(lToolTip); lRadioButton.setSelected(lSelected); lRadioButton.setEnabled(lEnabled); mVideoResolutionBtnGrp.add(lRadioButton); lRadioPanel.add(lRadioButton); } gbc.gridx = 1; gbc.gridy = 0; gbc.gridheight = 0; gbc.gridwidth = 0; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.NORTHEAST; this.panel.add(lRadioPanel, gbc); // radio buttons for video format to download mVideoQualityBtnGrp = new ButtonGroup(); lRadioPanel = new JPanel(new GridLayout(1, 0)); save3dcheckbox = new JCheckBox("3D"); save3dcheckbox.setToolTipText("stereoscopic video"); save3dcheckbox.setSelected(false); save3dcheckbox.setEnabled(true); lRadioPanel.add(save3dcheckbox); List<Object> lVidR = mAppContext.getList("youtube-downloader.video-resolution"); lRadioButton = null; for (Object obj : lVidR) { String lResolution = (String) obj; String lToolTip = mAppContext .getString("youtube-downloader.video-resolution." + lResolution + ".tooltip"); boolean lSelected = mAppContext .getBoolean("youtube-downloader.video-resolution." + lResolution + ".selected"); boolean lEnabled = mAppContext .getBoolean("youtube-downloader.video-resolution." + lResolution + ".enabled"); lRadioButton = new JRadioButton(lResolution); lRadioButton.setName(lResolution); lRadioButton.setActionCommand(lResolution.toLowerCase()); lRadioButton.addActionListener(lActionManager); lRadioButton.setToolTipText(lToolTip); lRadioButton.setSelected(lSelected); lRadioButton.setEnabled(lEnabled); mVideoQualityBtnGrp.add(lRadioButton); lRadioPanel.add(lRadioButton); } gbc.gridx = 1; gbc.gridy = 1; gbc.gridheight = 0; gbc.gridwidth = 0; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.NORTHEAST; this.panel.add(lRadioPanel, gbc); JLabel hint = new JLabel("Type, paste or drag'n drop a YouTube video address:"); gbc.fill = 0; gbc.gridwidth = 0; gbc.gridheight = 1; gbc.weightx = 0; gbc.weighty = 0; gbc.gridx = 0; gbc.gridy = 4; gbc.anchor = GridBagConstraints.WEST; this.panel.add(hint, gbc); textinputfield = new JTextField(20); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = 0; gbc.gridy = 5; gbc.gridwidth = 2; textinputfield.setEnabled(true); textinputfield.setFocusable(true); textinputfield.addActionListener(lActionManager); textinputfield.getDocument().addDocumentListener(new UrlInsertListener()); this.panel.add(textinputfield, gbc); this.quitbutton = new JButton("", createImageIcon("images/exit.png", "")); gbc.gridx = 2; gbc.gridy = 5; gbc.gridwidth = 0; this.quitbutton.addActionListener(lActionManager); this.quitbutton.setActionCommand("quit"); this.quitbutton.setToolTipText("Exit."); this.panel.add(this.quitbutton, gbc); pane.add(this.panel); addWindowListener(new GUIWindowAdapter()); this.setDropTarget(new DropTarget(this, new DragDropListener())); textarea.setTransferHandler(null); // otherwise the dropped text would be inserted }
From source file:org.docx4all.swing.ExternalHyperlinkDialog.java
private void fillRow5(JPanel host, GridBagConstraints c) { c.gridx = 0;//from w w w . ja v a 2 s . c o m c.gridy = 4; c.gridwidth = 2; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.insets = gridCellInsets; c.ipadx = 0; c.ipady = 0; c.anchor = GridBagConstraints.FIRST_LINE_START; c.fill = GridBagConstraints.NONE; JPanel directoryPathPanel = new JPanel(); directoryPathPanel.setBorder(BorderFactory.createEtchedBorder()); this.directoryPathField = new JTextArea(); this.directoryPathField.setEditable(false); this.directoryPathField.setEnabled(false); this.directoryPathField.setLineWrap(true); JScrollPane sp = new JScrollPane(this.directoryPathField); sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); sp.setMinimumSize(new Dimension(350, 100)); sp.setPreferredSize(new Dimension(350, 100)); directoryPathPanel.add(sp); host.add(directoryPathPanel, c); c.gridx = 2; c.gridy = 4; c.gridwidth = 1; c.gridheight = 1; c.weightx = 1.0; c.weighty = 1.0; c.insets = gridCellInsets; c.ipadx = 0; c.ipady = 0; c.anchor = GridBagConstraints.FIRST_LINE_START; c.fill = GridBagConstraints.NONE; this.selectButton = new JButton("Select..."); this.selectButton.addActionListener(new SelectButtonActionListener()); this.selectButton.setSize(100, 50); host.add(this.selectButton, c); }
From source file:net.sf.jabref.gui.ContentSelectorDialog2.java
private void initLayout() { fieldNameField.setEnabled(false);/*from w w w . j av a 2s .com*/ fieldList.setVisibleRowCount(4); wordList.setVisibleRowCount(10); final String VAL = "Uren luren himmelturen, ja Besseggen."; fieldList.setPrototypeCellValue(VAL); wordList.setPrototypeCellValue(VAL); fieldPan.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localization.lang("Field name"))); wordPan.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localization.lang("Keyword"))); fieldPan.setLayout(gbl); wordPan.setLayout(gbl); con.insets = new Insets(2, 2, 2, 2); con.fill = GridBagConstraints.BOTH; con.gridwidth = 2; con.weightx = 1; con.weighty = 1; con.gridx = 0; con.gridy = 0; gbl.setConstraints(fPane, con); fieldPan.add(fPane); gbl.setConstraints(wPane, con); wordPan.add(wPane); con.gridwidth = 1; con.gridx = 2; //con.weightx = 0.7; con.gridheight = 2; gbl.setConstraints(fieldNamePan, con); fieldPan.add(fieldNamePan); gbl.setConstraints(wordEditPan, con); wordPan.add(wordEditPan); con.gridx = 0; con.gridy = 1; con.weightx = 0; con.weighty = 0; con.gridwidth = 1; con.gridheight = 1; con.fill = GridBagConstraints.NONE; con.anchor = GridBagConstraints.WEST; gbl.setConstraints(newField, con); fieldPan.add(newField); gbl.setConstraints(newWord, con); wordPan.add(newWord); con.gridx = 1; //con.anchor = GridBagConstraints.EAST; gbl.setConstraints(removeField, con); fieldPan.add(removeField); gbl.setConstraints(removeWord, con); wordPan.add(removeWord); con.anchor = GridBagConstraints.WEST; con.gridx = 0; con.gridy = 0; gbl.setConstraints(fieldNameField, con); fieldNamePan.add(fieldNameField); gbl.setConstraints(wordEditField, con); wordEditPan.add(wordEditField); // Add buttons: ButtonBarBuilder bsb = new ButtonBarBuilder(buttonPan); bsb.addGlue(); bsb.addButton(ok); bsb.addButton(apply); bsb.addButton(cancel); bsb.addRelatedGap(); bsb.addButton(new HelpAction(HelpFile.CONTENT_SELECTOR).getHelpButton()); bsb.addGlue(); // Add panels to dialog: con.fill = GridBagConstraints.BOTH; getContentPane().setLayout(gbl); con.weightx = 1; con.weighty = 0.5; con.gridwidth = 1; con.gridheight = 1; con.gridx = 0; con.gridy = 0; gbl.setConstraints(fieldPan, con); getContentPane().add(fieldPan); con.gridy = 1; gbl.setConstraints(wordPan, con); getContentPane().add(wordPan); con.weighty = 0; con.gridy = 2; con.insets = new Insets(12, 2, 2, 2); gbl.setConstraints(buttonPan, con); getContentPane().add(buttonPan); }
From source file:com.sec.ose.osi.ui.frm.main.identification.stringmatch.JPanStringMatchMain.java
/** * This method initializes jPanel //from w w w. jav a2 s . c o m * * @return javax.swing.JPanel */ private JPanel getJPanelThisFileIsFolderTitle() { if (jPanelThisFileIsFolderTitle == null) { GridBagConstraints gridBagConstraints9 = new GridBagConstraints(); gridBagConstraints9.gridx = 1; gridBagConstraints9.insets = new Insets(3, 10, 0, 0); gridBagConstraints9.gridy = 0; GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.anchor = GridBagConstraints.WEST; gridBagConstraints.insets = new Insets(3, 0, 0, 0); gridBagConstraints.gridwidth = 1; gridBagConstraints.gridx = -1; gridBagConstraints.gridy = -1; gridBagConstraints.weightx = 0.0; gridBagConstraints.fill = GridBagConstraints.NONE; jPanelThisFileIsFolderTitle = new JPanel(); jPanelThisFileIsFolderTitle.setLayout(new GridBagLayout()); jPanelThisFileIsFolderTitle.add(getJRadioButtonThisFileIs(), gridBagConstraints); jPanelThisFileIsFolderTitle.add(getJButtonLicenseFolder(), gridBagConstraints9); } return jPanelThisFileIsFolderTitle; }
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()); }//from w w w . ja v a 2 s . 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:net.sourceforge.squirrel_sql.client.preferences.UpdatePreferencesPanel.java
/** * Sets the specified GridBagConstraints with the specified grid y coordinate and:<br> * <br>// ww w . java 2 s . c o m * grid x = 0 <br> * grid width = 1 <br> * weight x = 1 <br> * insets = LABEL_INSETS <br> * fill = GridBagConstraints.NONE <br> * anchor = GridBagConstraints.EAST * * @param gbc * the constraints to set * @param gridy * the grid y coordinate */ private void setLabelConstraints(GridBagConstraints gbc, int gridy) { gbc.gridx = 0; gbc.gridy = gridy; gbc.gridwidth = 1; gbc.weightx = 0; gbc.insets = LABEL_INSETS; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.EAST; }