List of usage examples for javax.swing JSplitPane HORIZONTAL_SPLIT
int HORIZONTAL_SPLIT
To view the source code for javax.swing JSplitPane HORIZONTAL_SPLIT.
Click Source Link
Component
s are split along the x axis. From source file:org.n52.ifgicopter.spf.gui.FrameworkCorePanel.java
/** * default constructor to create the framework core panel. *///ww w. j a va 2s.com public FrameworkCorePanel() { /* * INPUT PLUGIN LIST */ this.pluginsPanel = new JPanel(); this.pluginsPanel.setLayout(new GridBagLayout()); this.pluginsPanel.setBackground(DEFAULT_COLOR); this.globalGBC = new GridBagConstraints(); this.globalGBC.gridx = 0; this.globalGBC.gridy = 0; this.globalGBC.weightx = 0.0; this.globalGBC.weighty = 0.0; this.globalGBC.anchor = GridBagConstraints.NORTHWEST; this.globalGBC.fill = GridBagConstraints.HORIZONTAL; this.pluginsPanel.add( new JLabel("<html><body><div><strong>" + "Active Plugins</strong></div></body></html>"), this.globalGBC); this.globalGBC.gridy++; this.globalGBC.gridwidth = GridBagConstraints.REMAINDER; this.globalGBC.insets = new Insets(0, 0, 5, 0); this.pluginsPanel.add(new JSeparator(), this.globalGBC); this.globalGBC.insets = new Insets(0, 0, 0, 0); this.globalGBC.weightx = 1.0; this.globalGBC.gridy = 0; this.globalGBC.gridx = 1; this.pluginsPanel.add(Box.createHorizontalGlue(), this.globalGBC); this.globalGBC.weightx = 0.0; this.globalGBC.gridx = 0; this.globalGBC.gridy = 1; /* * the contentpanel */ this.contentPanel = new JPanel(); this.contentPanel.setLayout(new CardLayout()); this.contentPanel.setBorder(BorderFactory.createEtchedBorder()); this.contentPanel.add(WelcomePanel.getInstance(), WELCOME_PANEL); // ((CardLayout) contentPanel.getLayout()).show(contentPanel, WELCOME_PANEL); JScrollPane startupS = new JScrollPane(this.contentPanel); startupS.setViewportBorder(null); /* * wrap the plugins to ensure top alignment */ JPanel pluginsPanelWrapper = new JPanel(new BorderLayout()); pluginsPanelWrapper.add(this.pluginsPanel, BorderLayout.NORTH); pluginsPanelWrapper.add(Box.createVerticalGlue(), BorderLayout.CENTER); pluginsPanelWrapper.setBorder(BorderFactory.createEtchedBorder()); pluginsPanelWrapper.setBackground(this.pluginsPanel.getBackground()); JScrollPane wrapperS = new JScrollPane(pluginsPanelWrapper); wrapperS.setViewportBorder(null); /* * add both scroll panes to the split pane */ JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, wrapperS, startupS); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(250); splitPane.setContinuousLayout(true); Dimension minimumSize = new Dimension(100, 100); startupS.setMinimumSize(minimumSize); this.setLayout(new BorderLayout()); this.add(splitPane); }
From source file:org.ngrinder.recorder.Recorder.java
/** * Create a split pane with the give left and right components. * //www . j a va 2 s . c om * @param left * component located in left * @param right * component located in right * @return JSplitPane instance */ protected JSplitPane createSplitPane(final JComponent left, final JComponent right) { JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, left, right); splitPane.setDividerLocation( splitPane.getSize().width - splitPane.getInsets().right - splitPane.getDividerSize() - 200); splitPane.setResizeWeight(1); splitPane.setMinimumSize(new Dimension(600, 600)); splitPane.setOneTouchExpandable(true); splitPane.setDividerSize(10); return splitPane; }
From source file:org.notebook.gui.MainFrame.java
public void initGui() { setLayout(new BorderLayout()); menu = new MenuToolbar(events); this.getRootPane().setJMenuBar(menu.getMenuBar()); //editor = new DocumentEditor(); //menu.addExtraToolBar(editor.getToolBar()); //JScrollPane leftTree = new JScrollPane(tree); Dimension minSize = new Dimension(150, 400); mainPanel = new SimplePrintPanel(); events.registerAction(mainPanel.getEventsHandler()); _panel = new JScrollPane(mainPanel); _panel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); JSplitPane splitPanel;/*from w w w. j a v a 2s.co m*/ splitPanel = new JSplitPane(); splitPanel.setOrientation(JSplitPane.HORIZONTAL_SPLIT); //splitPanel.setAutoscrolls(true); splitPanel.setDividerLocation(0.35); splitPanel.setOneTouchExpandable(true); splitPanel.setLeftComponent(getNavigationBar()); splitPanel.setRightComponent(_panel); statusBar = new StatusBar(); mainPanel.bar = statusBar; Container contentPane = getContentPane(); contentPane.add(menu.getToolBar(), BorderLayout.NORTH); contentPane.add(splitPanel, BorderLayout.CENTER); //contentPane.add(_panel, BorderLayout.CENTER); contentPane.add(statusBar, BorderLayout.SOUTH); //controller = createPrivilegedProxy(new DefaultBookController(this)); //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setIconImage(appIcon16()); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); final MainFrame mainFrame = this; addWindowListener(new WindowAdapter() { //? public void windowClosing(WindowEvent e) { events.fireEvent(MenuToolbar.EXIT, mainFrame); } //??? public void windowOpened(WindowEvent e) { events.fireEvent(MenuToolbar.LOADED, mainFrame); } }); //???????? events.fireEvent(MenuToolbar.GUI_INITED, this); events.registerAction(this); pack(); setSize(670, 548); }
From source file:org.omegat.gui.scripting.ScriptingWindow.java
private void initWindowLayout() { // set default size and position frame.setBounds(50, 80, 1150, 650);/* w w w .j ava 2 s . c o m*/ StaticUIUtils.persistGeometry(frame, Preferences.SCRIPTWINDOW_GEOMETRY_PREFIX); frame.getContentPane().setLayout(new BorderLayout(0, 0)); m_scriptList = new JList<>(); JScrollPane scrollPaneList = new JScrollPane(m_scriptList); m_scriptList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { onListSelectionChanged(); } } }); m_scriptList.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { ListModel<ScriptItem> lm = m_scriptList.getModel(); int index = m_scriptList.locationToIndex(e.getPoint()); if (index > -1) { m_scriptList.setToolTipText(lm.getElementAt(index).getFile().getName()); } } }); m_txtResult = new JEditorPane(); JScrollPane scrollPaneResults = new JScrollPane(m_txtResult); //m_txtScriptEditor = new StandardScriptEditor(); m_txtScriptEditor = getScriptEditor(); m_txtScriptEditor.initLayout(this); JSplitPane splitPane1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, m_txtScriptEditor.getPanel(), scrollPaneResults); splitPane1.setOneTouchExpandable(true); splitPane1.setDividerLocation(430); Dimension minimumSize1 = new Dimension(100, 50); //scrollPaneEditor.setMinimumSize(minimumSize1); scrollPaneResults.setMinimumSize(minimumSize1); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPaneList, splitPane1); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(250); Dimension minimumSize = new Dimension(100, 50); scrollPaneList.setMinimumSize(minimumSize); scrollPaneResults.setMinimumSize(minimumSize); frame.getContentPane().add(splitPane, BorderLayout.CENTER); JPanel panelSouth = new JPanel(); FlowLayout fl_panelSouth = (FlowLayout) panelSouth.getLayout(); fl_panelSouth.setAlignment(FlowLayout.LEFT); frame.getContentPane().add(panelSouth, BorderLayout.SOUTH); setupRunButtons(panelSouth); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.setJMenuBar(createMenuBar()); }
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 . jav a 2 s . c om*/ 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; } }; }
From source file:org.openconcerto.erp.core.humanresources.payroll.element.VariablePayeSQLElement.java
public SQLComponent createComponent() { return new BaseSQLComponent(this) { private ValidState validVarName; private JRadioButton radioVal = new JRadioButton("Valeur"); private JRadioButton radioFormule = new JRadioButton("Formule"); private final JTextField textValeur = new JTextField(); // private final ITextArea textFormule = new ITextArea(); private final VariableTree treeVariable = new VariableTree(); private final JTextField textNom = new JTextField(); private final JLabel labelWarningBadVar = new JLabelWarning(); private ElementComboBox comboSelSal; private EditFrame edit = null; private final SQLJavaEditor textFormule = new SQLJavaEditor(getMapTree()); public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); this.validVarName = null; this.textFormule.setEditable(false); // Arbre des variables JScrollPane sc = new JScrollPane(this.treeVariable); sc.setPreferredSize(new Dimension(150, sc.getPreferredSize().height)); this.treeVariable.addMouseListener(new MouseAdapter() { public void mousePressed(final MouseEvent mE) { if (mE.getButton() == MouseEvent.BUTTON3) { JPopupMenu menuDroit = new JPopupMenu(); TreePath path = treeVariable.getClosestPathForLocation(mE.getPoint().x, mE.getPoint().y); final Object obj = path.getLastPathComponent(); if ((obj == null) || !(obj instanceof VariableRowTreeNode)) { return; }/* ww w .j av a 2 s .c om*/ menuDroit.add(new AbstractAction("Editer") { public void actionPerformed(ActionEvent e) { if (edit == null) { edit = new EditFrame(getElement(), EditFrame.MODIFICATION); } System.err.println("Action performed"); if (obj != null) { System.err.println("Object not null --> " + obj.toString()); if (obj instanceof VariableRowTreeNode) { System.err.println("Object VariableRowTreeNode"); VariableRowTreeNode varNode = (VariableRowTreeNode) obj; edit.selectionId(varNode.getID(), 1); edit.setVisible(true); } } } }); menuDroit.show((Component) mE.getSource(), mE.getPoint().x, mE.getPoint().y); } else { if (mE.getClickCount() == 2) { TreePath path = treeVariable.getClosestPathForLocation(mE.getPoint().x, mE.getPoint().y); Object obj = path.getLastPathComponent(); if (obj != null) { if (obj instanceof FormuleTreeNode) { final FormuleTreeNode n = (FormuleTreeNode) obj; int start = textFormule.getSelectionStart(); String tmp = textFormule.getText(); textFormule.setText(tmp.substring(0, start) + n.getTextValue() + tmp.substring(start, tmp.length())); } } } } } }); JPanel panelDroite = new JPanel(); panelDroite.setLayout(new GridBagLayout()); // Categorie JTextField textCategorie = new JTextField(); c.fill = GridBagConstraints.HORIZONTAL; c.gridheight = 1; c.gridx = 1; c.gridy = 0; JLabel labelCategorie = new JLabel("Catgorie"); panelDroite.add(labelCategorie, c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; panelDroite.add(textCategorie, c); c.gridwidth = 1; // Nom c.fill = GridBagConstraints.HORIZONTAL; c.gridheight = 1; c.gridx = 1; c.gridy++; JLabel labelNom = new JLabel("Nom"); panelDroite.add(labelNom, c); c.gridx++; c.weightx = 1; panelDroite.add(this.textNom, c); this.textNom.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent e) { updateValidVarName(); } }); c.gridx++; c.weightx = 0; panelDroite.add(this.labelWarningBadVar, c); // Description JLabel labelInfos = new JLabel(getLabelFor("INFOS")); ITextArea textInfos = new ITextArea(); c.gridy++; c.gridx = 1; c.gridwidth = 1; c.weightx = 0; panelDroite.add(labelInfos, c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; c.weighty = 0; panelDroite.add(textInfos, c); // Valeur c.gridx = 1; c.gridy++; c.gridwidth = 1; c.weightx = 0; panelDroite.add(this.radioVal, c); c.gridx++; c.weightx = 1; c.gridwidth = GridBagConstraints.REMAINDER; panelDroite.add(this.textValeur, c); c.gridwidth = 1; c.gridx = 1; c.gridy++; panelDroite.add(this.radioFormule, c); c.gridx++; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; panelDroite.add(this.textFormule, c); c.gridwidth = 1; ButtonGroup group = new ButtonGroup(); group.add(this.radioVal); group.add(this.radioFormule); this.radioVal.setSelected(true); setFormuleEnabled(false); this.radioVal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setFormuleEnabled(false); } }); this.radioFormule.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setFormuleEnabled(true); } }); c.gridy++; c.gridx = 1; c.weighty = 0; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.comboSelSal = new ElementComboBox(false); this.comboSelSal.init(getDirectory().getElement(SalarieSQLElement.class)); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 0; panelDroite.add(this.comboSelSal, c); c.gridwidth = 1; JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sc, panelDroite); c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 0; c.weightx = 1; c.weighty = 1; this.add(split, c); this.addRequiredSQLObject(this.textNom, "NOM"); this.addSQLObject(this.textValeur, "VALEUR"); this.addSQLObject(this.textFormule, "FORMULE"); this.addSQLObject(textCategorie, "CATEGORIE"); this.addSQLObject(textInfos, "INFOS"); this.comboSelSal.addValueListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { // TODO Auto-generated method stub textFormule.setSalarieID(comboSelSal.getSelectedId()); } }); } @Override public synchronized ValidState getValidState() { return super.getValidState().and(this.validVarName); } private void setFormuleEnabled(boolean b) { if (b) { this.textValeur.setText(""); } else { this.textFormule.setText(""); } this.textValeur.setEditable(!b); this.textValeur.setEnabled(!b); this.textFormule.setEditable(b); this.textFormule.setEnabled(b); this.treeVariable.setEnabled(b); this.treeVariable.setEditable(b); } private void setValidVarName(ValidState s) { if (!s.equals(this.validVarName)) { this.validVarName = s; final boolean warningVisible = !s.isValid(); if (warningVisible) this.labelWarningBadVar.setText(s.getValidationText()); this.labelWarningBadVar.setVisible(warningVisible); this.fireValidChange(); } } private void updateValidVarName() { this.setValidVarName(this.computeValidVarName()); } private ValidState computeValidVarName() { // on vrifie si la syntaxe de la variable est correct (chiffre lettre et _) final String varName = this.textNom.getText().trim(); System.err.println("Verification de la validit du nom de la variable."); if (varName.length() == 0) { return VAR_NO_NAME; } // ne contient que des chiffre lettre et _ et ne commence pas par un chiffre if (!isJavaVar(varName)) { return VAR_NAME_NOT_CORRECT; } // on vrifie que la variable n'existe pas dja SQLSelect selAllVarName = new SQLSelect(getTable().getBase()); selAllVarName.addSelect(VariablePayeSQLElement.this.getTable().getField("ID")); Where w = new Where(VariablePayeSQLElement.this.getTable().getField("NOM"), "=", varName); w = w.and(new Where(VariablePayeSQLElement.this.getTable().getKey(), "!=", getSelectedID())); selAllVarName.setWhere(w); String reqAllVarName = selAllVarName.asString();// + " AND '" + varName.trim() + "' // REGEXP VARIABLE_PAYE.NOM"; Object[] objKeysRowName = ((List) getTable().getBase().getDataSource().execute(reqAllVarName, new ArrayListHandler())).toArray(); if (objKeysRowName.length > 0) { return VAR_ALREADY_EXIST; } else { // Impossible de crer une variable du meme nom qu'un champ du salarie if (isForbidden(varName)) return VAR_ALREADY_EXIST; this.textFormule.setVarAssign(varName); return ValidState.getTrueInstance(); } } private boolean isJavaVar(String s) { if ((s.charAt(0) >= '0') && ((s.charAt(0) <= '9'))) { System.err.println("Erreur la variable commence par un chiffre!!"); return false; } else { for (int i = 0; i < s.length(); i++) { if (!(((s.charAt(i) >= '0') && (s.charAt(i) <= '9')) || (s.charAt(i) >= 'a') && (s.charAt(i) <= 'z') || (s.charAt(i) >= 'A') && (s.charAt(i) <= 'Z') || (s.charAt(i) == '_'))) { System.err.println("Erreur la variable contient un caractere incorrect!!"); return false; } } return (!CTokenMarker.getKeywords().isExisting(s)); } } @Override public void select(SQLRowAccessor r) { super.select(r); // System.err.println("Select RowAccess -------> " + r.getID() + " For Object " + // this.hashCode()); if (r != null) { if (r.getString("FORMULE").trim().length() == 0) { this.radioVal.setSelected(true); setFormuleEnabled(false); } else { this.radioFormule.setSelected(true); setFormuleEnabled(true); } this.textFormule.setVarAssign(r.getString("NOM")); } this.updateValidVarName(); } }; }
From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.ImportDialog.java
/** Builds and lays out the UI. */ private void buildGUI() { setLayout(new BorderLayout(0, 0)); JPanel p = new JPanel(); p.setBorder(null);/* ww w .ja v a2 s.c o m*/ p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.add(buildQuotaPane()); p.add(table); tabbedPane.add("Files to import", p); tabbedPane.add("Options", buildOptionsPane()); double[][] tablePanelDesign = { { TableLayout.PREFERRED, 10, 5, TableLayout.FILL }, { TableLayout.PREFERRED, TableLayout.FILL } }; JPanel tablePanel = new JPanel(new TableLayout(tablePanelDesign)); tablePanel.add(table.buildControls(), "0, 1, LEFT, CENTER"); tablePanel.add(tabbedPane, "2, 1, 3, 1"); int plugin = ImporterAgent.runAsPlugin(); JSplitPane pane; if (plugin == LookupNames.IMAGE_J_IMPORT || plugin == LookupNames.IMAGE_J) { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); JLabel label = UIUtilities.setTextFont("Select where to import the image(s)."); panel.add(UIUtilities.buildComponentPanel(label)); panel.add(locationDialog.getContentPane()); pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel, tablePanel); } else { pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, chooser, tablePanel); } JPanel mainPanel = new JPanel(); double[][] mainPanelDesign = { { TableLayout.FILL }, { TableLayout.PREFERRED, TableLayout.FILL } }; mainPanel.setLayout(new TableLayout(mainPanelDesign)); mainPanel.setBackground(UIUtilities.BACKGROUND); mainPanel.add(pane, "0, 1"); this.add(mainPanel, BorderLayout.CENTER); JPanel controls = new JPanel(); controls.setLayout(new BoxLayout(controls, BoxLayout.Y_AXIS)); // Lays out the buttons. JPanel bar = new JPanel(); bar.setLayout(new BoxLayout(bar, BoxLayout.X_AXIS)); bar.add(buildToolBarLeft()); bar.add(buildToolBarRight()); controls.add(new JSeparator()); controls.add(bar); add(controls, BorderLayout.SOUTH); if (JDialog.isDefaultLookAndFeelDecorated()) { boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations(); if (supportsWindowDecorations) getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG); } }
From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java
/** * Initializes and returns a split pane, either vertical or horizontal * depending on the passed parameter./* w ww . ja v a2 s .c om*/ * * @param orientation The orientation of the split pane. * @return See above. */ private JSplitPane initSplitPane(int orientation) { int type; switch (orientation) { case JSplitPane.HORIZONTAL_SPLIT: case JSplitPane.VERTICAL_SPLIT: type = orientation; break; default: type = JSplitPane.HORIZONTAL_SPLIT; } JSplitPane pane = new JSplitPane(type); pane.setOneTouchExpandable(true); pane.setContinuousLayout(true); pane.setDividerLocation(-1); pane.setResizeWeight(0.0); return pane; }
From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java
/** Initializes the split panes. */ private void initSplitPanes() { if (historyUI == null) historyUI = new HistoryUI(this, model, controller); //historySplit = new SplitPanel(SplitPanel.HORIZONTAL); historySplit = initSplitPane(JSplitPane.VERTICAL_SPLIT); rendererSplit = initSplitPane(JSplitPane.HORIZONTAL_SPLIT); }
From source file:org.optaplanner.mes.common.swingui.SolverAndPersistenceFrame.java
private JComponent createContentPane() { // JComponent quickOpenPanel = createQuickOpenPanel(); JComponent quickOpenPanel = createQuickOpenScorePanel(); JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(createToolBar(), BorderLayout.NORTH); mainPanel.add(createMiddlePanel(), BorderLayout.CENTER); mainPanel.add(createScorePanel(), BorderLayout.SOUTH); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, quickOpenPanel, mainPanel); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.2);//from w w w . j a v a 2 s .c o m return splitPane; }