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.keyboardplaying.xtt.ui.UIController.java
/** Builds and shows the main window. */ public void showMainWindow() { /* Create UI. */ JPanel pane = new JPanel(new GridBagLayout()); /* Arrange the components */ GridBagConstraints c;/*from w w w . j ava 2s . c o m*/ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.gridwidth = 2; c.fill = GridBagConstraints.BOTH; pane.add(makeProjectActionButton("action.construct", "action-construct", ImageSize.W_16, constructAction), c); c = new GridBagConstraints(); c.gridx = 0; c.gridy = 1; c.gridwidth = 2; c.fill = GridBagConstraints.BOTH; pane.add(makeProjectActionButton("action.deconstruct", "action-deconstruct", ImageSize.W_16, deconstructAction), c); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 0; c.gridheight = 2; c.fill = GridBagConstraints.BOTH; pane.add(makeActionButton(null, "icon-settings", ImageSize.W_32, settingsAction), c); Window window = makeWindow("app.name", "icon-timetracker", pane); window.addWindowListener(new WindowAdapter() { /* * (non-Javadoc) * * @see java.awt.event.WindowAdapter#windowClosing(java.awt.event. WindowEvent) */ @Override public void windowClosing(WindowEvent e) { super.windowClosing(e); Frame[] windows = JFrame.getFrames(); for (Frame w : windows) { w.dispose(); } } }); window.setVisible(true); }
From source file:com.sshtools.common.ui.SshToolsConnectionKerberosTab.java
/** * Creates a new SshToolsConnectionKerberosTab object. *//* ww w .j ava 2s.c o m*/ public SshToolsConnectionKerberosTab() { super(); // Create the main connection details panel JPanel mainConnectionDetailsPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.insets = new Insets(0, 2, 2, 2); // enabled option //gbc.fill = GridBagConstraints.NONE; useKerberos = new JCheckBox("Use MyProxy Kerberos support"); UIUtil.jGridBagAdd(mainConnectionDetailsPanel, useKerberos, gbc, GridBagConstraints.REMAINDER); // Host name UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Hostname"), gbc, GridBagConstraints.REMAINDER); //gbc.fill = GridBagConstraints.HORIZONTAL; UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextHostname, gbc, GridBagConstraints.REMAINDER); //gbc.fill = GridBagConstraints.NONE; // Username UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Username"), gbc, GridBagConstraints.REMAINDER); //gbc.fill = GridBagConstraints.HORIZONTAL; UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextUsername, gbc, GridBagConstraints.REMAINDER); JPanel settingsPanel = new JPanel(new GridBagLayout()); settingsPanel .setBorder(BorderFactory.createTitledBorder("Settings if krb5.conf or krb5.ini file not found: ")); GridBagConstraints gbc2 = new GridBagConstraints(); gbc2.fill = GridBagConstraints.HORIZONTAL; gbc2.anchor = GridBagConstraints.NORTHWEST; gbc2.insets = new Insets(0, 2, 2, 2); gbc2.weightx = 1.0; // realm UIUtil.jGridBagAdd(settingsPanel, new JLabel("Realm"), gbc2, GridBagConstraints.REMAINDER); gbc2.fill = GridBagConstraints.HORIZONTAL; UIUtil.jGridBagAdd(settingsPanel, jTextRealm, gbc2, GridBagConstraints.REMAINDER); gbc2.fill = GridBagConstraints.NONE; // kdc UIUtil.jGridBagAdd(settingsPanel, new JLabel("KDC"), gbc2, GridBagConstraints.REMAINDER); gbc2.fill = GridBagConstraints.HORIZONTAL; gbc2.weighty = 1.0; UIUtil.jGridBagAdd(settingsPanel, jTextKDC, gbc2, GridBagConstraints.REMAINDER); gbc2.fill = GridBagConstraints.NONE; // gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.insets = new Insets(4, 2, 2, 2); UIUtil.jGridBagAdd(mainConnectionDetailsPanel, settingsPanel, gbc, GridBagConstraints.REMAINDER); IconWrapperPanel iconMainConnectionDetailsPanel = new IconWrapperPanel( new ResourceIcon(SshToolsConnectionHostTab.class, AUTH_ICON), mainConnectionDetailsPanel); setLayout(new GridBagLayout()); setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(2, 2, 2, 2); gbc.weightx = 1.0; gbc.weighty = 1.0; UIUtil.jGridBagAdd(this, iconMainConnectionDetailsPanel, gbc, GridBagConstraints.REMAINDER); }
From source file:com.intel.stl.ui.main.view.HealthHistoryView.java
@Override protected JPanel getMainComponent() { if (mainPanel != null) { return mainPanel; }//from ww w. jav a2 s . c o m mainPanel = new JPanel(); GridBagLayout gridBag = new GridBagLayout(); mainPanel.setLayout(gridBag); GridBagConstraints gc = new GridBagConstraints(); gc.fill = GridBagConstraints.BOTH; gc.weightx = 1; gc.weighty = 1; gc.gridwidth = GridBagConstraints.REMAINDER; chartPanel = new ChartPanel(null); // chart.PanelsetBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, // UIConstants.INTEL_BORDER_GRAY)); chartPanel.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { chartPanel.setMaximumDrawHeight(e.getComponent().getHeight()); chartPanel.setMaximumDrawWidth(e.getComponent().getWidth()); chartPanel.setMinimumDrawWidth(e.getComponent().getWidth()); chartPanel.setMinimumDrawHeight(e.getComponent().getHeight()); } }); mainPanel.add(chartPanel, gc); gc.gridwidth = 1; gc.insets = new Insets(0, 5, 0, 5); gc.fill = GridBagConstraints.NONE; gc.anchor = GridBagConstraints.WEST; gc.weighty = 0; startTimeLabel = ComponentFactory.getH5Label("start", Font.PLAIN); mainPanel.add(startTimeLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; gc.anchor = GridBagConstraints.EAST; endTimeLabel = ComponentFactory.getH5Label("end", Font.PLAIN); mainPanel.add(endTimeLabel, gc); return mainPanel; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.TextualAnnotationsUI.java
/** Builds and lays out the UI. */ private void buildGUI() { removeAll();//from w w w. j a v a2 s. c om if (!model.isAnnotationLoaded()) return; pane = new JScrollPane(commentArea); pane.setBorder(null); setLayout(new GridBagLayout()); constraints = new GridBagConstraints(); constraints.insets = new Insets(2, 0, 2, 0); constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.gridx = 0; constraints.gridy = 0; constraints.weightx = 1; constraints.weighty = 1; add(pane, constraints); constraints.gridy++; constraints.weightx = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.WEST; add(addButton, constraints); constraints.gridy++; constraints.weightx = 1; constraints.weighty = 0; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.NORTHWEST; }
From source file:it.cnr.icar.eric.client.ui.swing.FindParamsPanel.java
/** * Class Constructor./*from w w w . j ava2 s . c om*/ */ public FindParamsPanel(DiscoveryPanel discoveryPanel) throws JAXRException { this.discoveryPanel = discoveryPanel; GridBagLayout gbl = new GridBagLayout(); setLayout(gbl); //The searchTypeSelectionPanel at the top of the panel JPanel searchTypePanel = createSearchTypePanel(); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTH; c.insets = new Insets(4, 4, 0, 4); gbl.setConstraints(searchTypePanel, c); add(searchTypePanel); //The federated CheckBox federatedCheckBox = new JCheckBox(resourceBundle.getString("label.federatedQuery")); federatedCheckBox.setSelected(false); federatedCheckBox.setEnabled(true); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTH; c.insets = new Insets(4, 4, 0, 4); gbl.setConstraints(federatedCheckBox, c); add(federatedCheckBox); //The actionPanel JPanel actionPanel = createActionPanel(); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTH; c.insets = new Insets(4, 4, 0, 4); gbl.setConstraints(searchTypePanel, c); add(actionPanel); //Next is the panel that is the parent of both adhocQueryPanel and //businessQueryPanel paramEntryParentPanel = createParamEntryParentPanel(); c.gridx = 0; c.gridy = 3; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.5; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.NORTH; c.insets = new Insets(4, 4, 0, 4); gbl.setConstraints(paramEntryParentPanel, c); add(paramEntryParentPanel); //RegistryBrowser.getInstance().getConceptsTreeDialog().addPropertyChangeListener(this); //add listener for 'locale' bound property RegistryBrowser.getInstance().addPropertyChangeListener(RegistryBrowser.PROPERTY_LOCALE, this); }
From source file:com.jostrobin.battleships.view.frames.GameFrame.java
private void addBattleField(int length, int width, String playerName, int gridX, int gridY) { battleFieldPanel = new BattleFieldPanel(playerName); battleFieldPanel.initializeFieldSize(length, width); battleFieldPanel.setSelectable(false); placementHelper = new PlacementHelper(battleFieldPanel); GridBagConstraints battlefieldConstraints = new GridBagConstraints(); battlefieldConstraints.weightx = 1.0; battlefieldConstraints.weighty = 0.8; battlefieldConstraints.anchor = GridBagConstraints.ABOVE_BASELINE_LEADING; battlefieldConstraints.fill = GridBagConstraints.BOTH; battlefieldConstraints.gridy = gridY; battlefieldConstraints.gridx = gridX; add(battleFieldPanel, battlefieldConstraints); }
From source file:com.sec.ose.osi.ui.dialog.setting.JPanProxySetting.java
private JPanel getJPanelValue() { if (jPanelValue == null) { GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); gridBagConstraints3.gridx = 1;/*w w w .ja v a2s. com*/ gridBagConstraints3.weighty = 1.0; gridBagConstraints3.weightx = 0.0; gridBagConstraints3.gridy = 4; jLabelEmpty = new JLabel(); jLabelEmpty.setText(""); GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); gridBagConstraints2.gridx = 0; gridBagConstraints2.gridy = 3; jPanelValue = new JPanel(); jPanelValue.setLayout(new GridBagLayout()); jPanelValue.setBorder(BorderFactory.createTitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51))); jPanelValue.setPreferredSize(new Dimension(400, 200)); jPanelValue.add(jLabelEmpty, gridBagConstraints3); JLabel jLabelProxyHost = new JLabel("Proxy Host : ", JLabel.RIGHT); GridBagConstraints gridBagConstraintsjLabelProxyHost = new GridBagConstraints(); gridBagConstraintsjLabelProxyHost.gridx = 0; gridBagConstraintsjLabelProxyHost.insets = new Insets(10, 20, 5, 0); gridBagConstraintsjLabelProxyHost.fill = GridBagConstraints.HORIZONTAL; gridBagConstraintsjLabelProxyHost.weightx = 0.0; gridBagConstraintsjLabelProxyHost.weighty = 0.0; gridBagConstraintsjLabelProxyHost.gridy = 1; jPanelValue.add(jLabelProxyHost, gridBagConstraintsjLabelProxyHost); GridBagConstraints gridBagConstraintsgetJTextFieldProxyHost = new GridBagConstraints(); gridBagConstraintsgetJTextFieldProxyHost.gridx = 1; gridBagConstraintsgetJTextFieldProxyHost.weightx = 1.0; gridBagConstraintsgetJTextFieldProxyHost.fill = GridBagConstraints.BOTH; gridBagConstraintsgetJTextFieldProxyHost.insets = new Insets(10, 5, 5, 100); gridBagConstraintsgetJTextFieldProxyHost.gridwidth = 2; gridBagConstraintsgetJTextFieldProxyHost.gridy = 1; jPanelValue.add(getJTextFieldProxyHost(), gridBagConstraintsgetJTextFieldProxyHost); JLabel jLabelProxyPort = new JLabel("Proxy Port : ", JLabel.RIGHT); GridBagConstraints gridBagConstraintsjLabelProxyPort = new GridBagConstraints(); gridBagConstraintsjLabelProxyPort.gridx = 0; gridBagConstraintsjLabelProxyPort.insets = new Insets(0, 20, 0, 0); gridBagConstraintsjLabelProxyPort.fill = GridBagConstraints.HORIZONTAL; gridBagConstraintsjLabelProxyPort.weighty = 0.0; gridBagConstraintsjLabelProxyPort.gridy = 2; jPanelValue.add(jLabelProxyPort, gridBagConstraintsjLabelProxyPort); GridBagConstraints gridBagConstraintsgetJTextFieldProxyPort = new GridBagConstraints(); gridBagConstraintsgetJTextFieldProxyPort.gridx = 1; gridBagConstraintsgetJTextFieldProxyPort.weightx = 1.0; gridBagConstraintsgetJTextFieldProxyPort.fill = GridBagConstraints.BOTH; gridBagConstraintsgetJTextFieldProxyPort.insets = new Insets(5, 5, 5, 220); gridBagConstraintsgetJTextFieldProxyPort.weighty = 0.0; gridBagConstraintsgetJTextFieldProxyPort.anchor = GridBagConstraints.CENTER; gridBagConstraintsgetJTextFieldProxyPort.gridy = 2; jPanelValue.add(getJTextFieldProxyPort(), gridBagConstraintsgetJTextFieldProxyPort); JLabel jLabelProxyBypass = new JLabel("Proxy Bypass : ", JLabel.RIGHT); GridBagConstraints gridBagConstraintsjLabelProxyBypass = new GridBagConstraints(); gridBagConstraintsjLabelProxyBypass.gridx = 0; gridBagConstraintsjLabelProxyBypass.insets = new Insets(0, 20, 0, 0); gridBagConstraintsjLabelProxyBypass.fill = GridBagConstraints.HORIZONTAL; gridBagConstraintsjLabelProxyBypass.weighty = 0.0; gridBagConstraintsjLabelProxyBypass.gridy = 3; jPanelValue.add(jLabelProxyBypass, gridBagConstraintsjLabelProxyBypass); GridBagConstraints gridBagConstraintsgetJTextFieldProxyBypass = new GridBagConstraints(); gridBagConstraintsgetJTextFieldProxyBypass.gridx = 1; gridBagConstraintsgetJTextFieldProxyBypass.weightx = 1.0; gridBagConstraintsgetJTextFieldProxyBypass.fill = GridBagConstraints.BOTH; gridBagConstraintsgetJTextFieldProxyBypass.insets = new Insets(5, 5, 5, 100); gridBagConstraintsgetJTextFieldProxyBypass.weighty = 0.0; gridBagConstraintsgetJTextFieldProxyBypass.anchor = GridBagConstraints.CENTER; gridBagConstraintsgetJTextFieldProxyBypass.gridy = 3; jPanelValue.add(getJTextFieldProxyBypass(), gridBagConstraintsgetJTextFieldProxyBypass); //jPanelValue.add(getJPanel(), gridBagConstraints2); } return jPanelValue; }
From source file:com.sec.ose.osi.ui.frm.main.report.JPanBillOfMaterials.java
private JPanel getJPanelOptions() { if (jPanelOptions == null) { GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); gridBagConstraints3.gridx = 1;/*from w ww. j a va 2 s .c om*/ gridBagConstraints3.fill = GridBagConstraints.BOTH; gridBagConstraints3.insets = new Insets(0, 0, 10, 0); gridBagConstraints3.gridy = 1; jLabelSelectedComponent = new JLabel(); jLabelSelectedComponent.setText("Display files for the selected components"); jLabelSelectedComponent.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { eventHandler.handleEvent(EventHandler.RADIO_SELECTED_COMPONENT); } }); GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); gridBagConstraints2.gridx = 0; gridBagConstraints2.insets = new Insets(0, 10, 10, 0); gridBagConstraints2.gridy = 1; GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); gridBagConstraints1.gridx = 1; gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints1.insets = new Insets(10, 0, 10, 0); gridBagConstraints1.gridwidth = 1; gridBagConstraints1.gridy = 0; jLabelAllFiles = new JLabel(); jLabelAllFiles.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { eventHandler.handleEvent(EventHandler.RADIO_ALL_FILES); } }); jLabelAllFiles.setText("Display all files for all components"); GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.insets = new Insets(0, 10, 0, 0); gridBagConstraints.gridy = 0; jPanelOptions = new JPanel(); jPanelOptions.setLayout(new GridBagLayout()); jPanelOptions.add(getJRadioAllFilesForAll(), gridBagConstraints); jPanelOptions.add(jLabelAllFiles, gridBagConstraints1); jPanelOptions.add(getJRadioAllFilesForSelectedComponent(), gridBagConstraints2); jPanelOptions.add(jLabelSelectedComponent, gridBagConstraints3); } return jPanelOptions; }
From source file:org.ngrinder.recorder.ui.RecordingControlPanel.java
/** * Initialize UI.//from www. j a va 2 s .co m * * @param connectionFilter * connection filter */ protected void initUI(ConnectionFilter connectionFilter) { GridBagLayout gbl = new GridBagLayout(); setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(5, 5, 5, 5); gbc.fill = GridBagConstraints.BOTH; addGrid(gbl, gbc, createRecordingButton(), new Rectangle(0, 0, 1, 1), 0, 0); createFilterTables = createFilterTables(connectionFilter); addGrid(gbl, gbc, wrapScroll(createFilterTables), new Rectangle(0, 1, 1, 5), 1, 0.7); addGrid(gbl, gbc, createFilterButtonPanel(), new Rectangle(0, 7, 1, 1), 0, 0); typeFilter = createTypeFilterPanel(); typeFilterPersistentHandler = new OptionPersistencyHandler(typeFilter, "type_filter"); addGrid(gbl, gbc, typeFilter, new Rectangle(0, 8, 1, 3), 0, 0); generationOptions = createGenerationOptionsPanel(); generationOptionsPersistentHandler = new OptionPersistencyHandler(generationOptions, "generation_options"); addGrid(gbl, gbc, generationOptions, new Rectangle(0, 11, 1, 1), 0, 0); }
From source file:org.openconcerto.erp.core.humanresources.payroll.element.FichePayeSQLElement.java
public SQLComponent createComponent() { return new BaseSQLComponent(this) { private FichePayeModel model; private ElementComboBox comboSelProfil, selSalCombo; private EditFrame edit = null; private ElementComboBox selMois; private int dernMois, dernAnnee; private JTextField textAnnee; JDate dateDu, dateAu;/*from w w w .j a v a2s.com*/ private JScrollPane paneTreeLeft; private JPanel pDate; private JButton buttonValider, buttonGenCompta; public void addViews() { this.dernMois = 0; this.dernAnnee = 0; this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); // Tree elt Fiche de Paye On the left c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 1; c.gridheight = GridBagConstraints.REMAINDER; final RubriquePayeTree tree = new RubriquePayeTree(); tree.expandRow(0); this.paneTreeLeft = new JScrollPane(tree); // this.add(this.paneTreeLeft, c); // Panel Fiche paye on the right // Salarie JPanel panelRight = new JPanel(); panelRight.setLayout(new GridBagLayout()); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.weighty = 0; c.gridheight = 1; c.gridwidth = 2; this.selSalCombo = new ElementComboBox(); // c.gridx++; panelRight.add(this.selSalCombo, c); // Mois c.gridy++; // c.gridx++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.weighty = 0; c.gridheight = 1; c.gridwidth = 3; JLabel labelMois = new JLabel("Fiche de paye du mois de"); this.selMois = new ElementComboBox(true, 20); // this.selMois.setEditable(true); // /this.selMois.setEnabled(true); JLabel labelDu = new JLabel("Du"); JLabel labelAu = new JLabel("Au"); this.dateDu = new JDate(); this.dateAu = new JDate(); // JTextField textMois = new JTextField(); JLabel labelAnnee = new JLabel("Anne"); this.textAnnee = new JTextField(); { this.pDate = new JPanel(); this.pDate.setOpaque(false); this.pDate.add(labelMois); this.pDate.add(this.selMois); this.pDate.add(labelAnnee); this.pDate.add(this.textAnnee); this.pDate.add(labelDu); this.pDate.add(this.dateDu); this.pDate.add(labelAu); this.pDate.add(this.dateAu); panelRight.add(this.pDate, c); } c.gridx += 2; c.weightx = 1; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; panelRight.add(new JPanel(), c); // Action Button c.gridx++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.weighty = 0; JPanel pButtons = new JPanel(); pButtons.setOpaque(false); JButton buttonUp = new JNiceButton(IListFrame.class.getResource("fleche_haut.png")); JButton buttonDown = new JNiceButton(IListFrame.class.getResource("fleche_bas.png")); JButton buttonRemove = new JNiceButton(SQLComponent.class.getResource("delete.png")); { pButtons.add(buttonUp); pButtons.add(buttonDown); pButtons.add(buttonRemove); } panelRight.add(pButtons, c); // Table c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 1; c.gridx = 1; c.gridy++; c.gridwidth = GridBagConstraints.REMAINDER; this.model = new FichePayeModel(1); final JTable table = new JTable(this.model); panelRight.add(new JScrollPane(table), c); FichePayeRenderer rend = new FichePayeRenderer(); table.setDefaultRenderer(String.class, rend); table.setDefaultRenderer(Float.class, rend); // Import profil c.gridx = 1; c.gridy++; c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; JLabel labelProfil = new JLabel("Importer depuis un profil prdfini"); panelRight.add(labelProfil, c); c.gridwidth = 1; this.comboSelProfil = new ElementComboBox(); // this.comboSelProfil = new ElementComboBox(); this.comboSelProfil.setListIconVisible(false); c.gridx++; c.gridwidth = 1; // this.comboSelProfil.init(eltProfil.getTable().getField("NOM"), null); panelRight.add(this.comboSelProfil, c); JButton buttonImportProfil = new JButton("Importer"); c.gridx++; panelRight.add(buttonImportProfil, c); // Total Periode JPanel panelTotal = new JPanel(); panelTotal.setBorder(BorderFactory.createTitledBorder("Total priode")); panelTotal.setLayout(new GridBagLayout()); GridBagConstraints cPanel = new DefaultGridBagConstraints(); // Salaire brut JLabel labelBrut = new JLabel(getLabelFor("SAL_BRUT")); panelTotal.add(labelBrut, cPanel); JTextField textSalBrut = new JTextField(10); cPanel.gridx++; cPanel.weightx = 0; panelTotal.add(textSalBrut, cPanel); textSalBrut.setEditable(false); textSalBrut.setEnabled(false); // acompte cPanel.gridx++; JLabel labelAcompte = new JLabel(getLabelFor("ACOMPTE")); panelTotal.add(labelAcompte, cPanel); JTextField textAcompte = new JTextField(10); cPanel.gridx++; panelTotal.add(textAcompte, cPanel); // textAcompte.setEditable(false); // textAcompte.setEnabled(false); // Conges Acquis cPanel.gridx++; JLabel labelCongesAcquis = new JLabel(getLabelFor("CONGES_ACQUIS")); panelTotal.add(labelCongesAcquis, cPanel); JTextField textCongesAcquis = new JTextField(10); cPanel.gridx++; panelTotal.add(textCongesAcquis, cPanel); // cotisation salariale cPanel.gridx = 0; cPanel.gridy++; JLabel labelCotSal = new JLabel(getLabelFor("COT_SAL")); panelTotal.add(labelCotSal, cPanel); JTextField textCotSal = new JTextField(10); cPanel.gridx++; panelTotal.add(textCotSal, cPanel); textCotSal.setEditable(false); textCotSal.setEnabled(false); // cotisation patronale cPanel.gridx++; JLabel labelCotPat = new JLabel(getLabelFor("COT_PAT")); panelTotal.add(labelCotPat, cPanel); JTextField textCotPat = new JTextField(10); cPanel.gridx++; panelTotal.add(textCotPat, cPanel); textCotPat.setEditable(false); textCotPat.setEnabled(false); JLabel labelCSG = new JLabel(getLabelFor("CSG")); cPanel.gridx++; panelTotal.add(labelCSG, cPanel); JTextField textCSG = new JTextField(10); cPanel.gridx++; panelTotal.add(textCSG, cPanel); textCSG.setEditable(false); textCSG.setEnabled(false); // net imposable cPanel.gridx = 0; cPanel.gridy++; JLabel labelNetImp = new JLabel(getLabelFor("NET_IMP")); panelTotal.add(labelNetImp, cPanel); JTextField textNetImp = new JTextField(10); cPanel.gridx++; panelTotal.add(textNetImp, cPanel); textNetImp.setEditable(false); textNetImp.setEnabled(false); cPanel.gridx++; JLabel labelNetAPayer = new JLabel(getLabelFor("NET_A_PAYER")); panelTotal.add(labelNetAPayer, cPanel); JTextField textNetAPayer = new JTextField(10); cPanel.gridx++; panelTotal.add(textNetAPayer, cPanel); textNetAPayer.setEditable(false); textNetAPayer.setEnabled(false); c.gridx = 1; c.gridy++; c.gridwidth = GridBagConstraints.REMAINDER; panelRight.add(panelTotal, c); // Cumuls c.gridx = 1; c.gridy++; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; this.buttonValider = new JButton("Valider"); // panelRight.add(buttonValider, c); c.gridx++; c.gridwidth = 1; this.buttonGenCompta = new JButton("Generer la comptabilit"); // panelRight.add(buttonGenCompta, c); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 1; this.add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.paneTreeLeft, panelRight), c); // Listeners this.buttonGenCompta.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int[] i = new int[1]; i[0] = getSelectedID(); SQLRow rowMois = getTable().getBase().getTable("MOIS").getRow(selMois.getSelectedId()); new GenerationMvtFichePaye(i, rowMois.getString("NOM"), textAnnee.getText()); } }); this.buttonValider.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.err.println("Validation de la fiche de paye"); validationFiche(); } }); buttonUp.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int newRowSelected = model.upRow(table.getSelectedRow()); if (newRowSelected >= 0) { table.setRowSelectionInterval(newRowSelected, newRowSelected); } } }); buttonDown.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int newRowSelected = model.downRow(table.getSelectedRow()); if (newRowSelected >= 0) { table.setRowSelectionInterval(newRowSelected, newRowSelected); } } }); buttonRemove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { model.removeRow(table.getSelectedRow()); } }); tree.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mE) { TreePath path = tree.getClosestPathForLocation(mE.getPoint().x, mE.getPoint().y); final Object obj = path.getLastPathComponent(); if (obj == null) { return; } if (mE.getClickCount() == 2 && mE.getButton() == MouseEvent.BUTTON1) { if (obj instanceof VariableRowTreeNode) { model.addRowAt(((VariableRowTreeNode) obj).getRow(), table.getSelectedRow()); } } else { if (mE.getButton() == 3) { if (obj instanceof VariableRowTreeNode) { final SQLRow row = ((VariableRowTreeNode) obj).getRow(); JPopupMenu menuDroit = new JPopupMenu(); menuDroit.add(new AbstractAction("Editer") { public void actionPerformed(ActionEvent e) { if (edit != null) { edit.dispose(); } edit = new EditFrame(Configuration.getInstance().getDirectory() .getElement(row.getTable()), EditFrame.MODIFICATION); edit.selectionId(row.getID(), 0); edit.pack(); edit.setVisible(true); } }); menuDroit.add(new AbstractAction("Nouvelle rubrique") { public void actionPerformed(ActionEvent e) { if (edit != null) { edit.dispose(); } edit = new EditFrame(Configuration.getInstance().getDirectory() .getElement(row.getTable())); edit.pack(); edit.setVisible(true); } }); menuDroit.show(mE.getComponent(), mE.getPoint().x, mE.getPoint().y); } } } } }); this.dateDu.addValueListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (!dateDu.isEmpty()) { Date d = dateDu.getValue(); if (d != null) { Calendar cal = Calendar.getInstance(); cal.setTime(d); if (selMois.getSelectedId() > 1 && cal.get(Calendar.MONTH) + 2 != selMois.getSelectedId()) { cal.set(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.MONTH, selMois.getSelectedId() - 2); System.err.println("Du " + cal.getTime()); dateDu.setValue(cal.getTime()); } } } } }); this.dateAu.addValueListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (!dateAu.isEmpty()) { Date d = dateAu.getValue(); if (d != null) { Calendar cal = Calendar.getInstance(); cal.setTime(d); if (selMois.getSelectedId() > 1 && cal.get(Calendar.MONTH) + 2 != selMois.getSelectedId()) { // TODO checker l'annee // TODO ajouter dans le isValidated du au compris dans le mois // selectionne // Calendar.getInstance().set(Calendar.DAY_OF_MONTH, maxDay); cal.set(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.MONTH, selMois.getSelectedId() - 2); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); System.err.println("Au " + cal.getTime()); dateAu.setValue(cal.getTime()); } } } } }); this.addRequiredSQLObject(this.textAnnee, "ANNEE"); this.addRequiredSQLObject(this.selMois, "ID_MOIS"); this.addSQLObject(this.comboSelProfil, "ID_PROFIL_PAYE"); this.addSQLObject(textCongesAcquis, "CONGES_ACQUIS"); this.addSQLObject(textCotPat, "COT_PAT"); this.addSQLObject(textCotSal, "COT_SAL"); this.addSQLObject(textCSG, "CSG"); this.addSQLObject(textNetAPayer, "NET_A_PAYER"); this.addSQLObject(textNetImp, "NET_IMP"); this.addSQLObject(textSalBrut, "SAL_BRUT"); this.addSQLObject(textAcompte, "ACOMPTE"); this.addSQLObject(this.selSalCombo, "ID_SALARIE"); this.addRequiredSQLObject(this.dateDu, "DU"); this.addRequiredSQLObject(this.dateAu, "AU"); this.selSalCombo.setEditable(false); this.selSalCombo.setEnabled(false); this.selSalCombo.setButtonsVisible(false); // this.selSalCombo.setVisible(false); buttonImportProfil.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { model.loadFromProfil(comboSelProfil.getSelectedId()); } }); } private boolean isDateValid() { String yearS = this.textAnnee.getText().trim(); int annee = (yearS.length() == 0) ? 0 : Integer.parseInt(yearS); int mois = this.selMois.getSelectedId(); // System.err.println("anne " + annee + " dernAnnee " + this.dernAnnee + " mois " + // mois + " dernMois " + this.dernMois); return ((this.dernAnnee == 0) ? true : annee > this.dernAnnee) || ((this.dernMois == 0 || this.dernMois == 13) ? true : mois > this.dernMois); } @Override public synchronized ValidState getValidState() { // FIXME add fireValidChange() return super.getValidState().and(ValidState.createCached(isDateValid(), "Date invalide")); } public int insert(SQLRow order) { int id = super.insert(order); this.model.updateFields(id); return id; } @Override public void update() { super.update(); this.model.updateFields(this.getSelectedID()); } @Override public void select(SQLRowAccessor r) { // System.err.println("SELECT FICHE ID -> " + r.getID()); super.select(r); if (r != null && r.getID() > 1) { this.model.setFicheID(r.getID()); SQLTable tableSal = getTable().getBase().getTable("SALARIE"); SQLRow rowSal = tableSal.getRow(r.getInt("ID_SALARIE")); this.dernMois = rowSal.getInt("DERNIER_MOIS"); this.dernAnnee = rowSal.getInt("DERNIERE_ANNEE"); this.selSalCombo.setVisible(((Boolean) r.getObject("VALIDE")).booleanValue()); this.paneTreeLeft.setVisible(!((Boolean) r.getObject("VALIDE")).booleanValue()); this.buttonValider.setVisible(!((Boolean) r.getObject("VALIDE")).booleanValue()); setpDateEnabled(!((Boolean) r.getObject("VALIDE")).booleanValue()); } this.selSalCombo.setEditable(false); this.selSalCombo.setEnabled(false); this.selMois.setButtonsVisible(false); this.selSalCombo.setButtonsVisible(false); } private void setpDateEnabled(boolean b) { // System.err.println("Set date enable --> " + b); this.selMois.setEditable(b); // this.selMois.setEnabled(b); this.textAnnee.setEditable(b); this.textAnnee.setEnabled(b); this.dateDu.setEditable(b); this.dateDu.setEnabled(b); this.dateAu.setEditable(b); this.dateAu.setEnabled(b); } private void validationFiche() { this.update(); FichePayeSQLElement.validationFiche(this.getSelectedID()); } protected SQLRowValues createDefaults() { System.err.println("**********Set Defaults on FichePaye.date"); SQLRowValues rowVals = new SQLRowValues(getTable()); Calendar cal = Calendar.getInstance(); rowVals.put("ID_MOIS", cal.get(Calendar.MONTH) + 2); rowVals.put("ANNEE", cal.get(Calendar.YEAR)); cal.set(Calendar.DAY_OF_MONTH, 1); rowVals.put("DU", new java.sql.Date(cal.getTime().getTime())); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); rowVals.put("AU", new java.sql.Date(cal.getTime().getTime())); return rowVals; } }; }