/** * Cr�e une nouvelle instance de CreeTrans * * @param mf fenetre principale de l'application * @param zg Zone graphique * @param auto automate * @param be barre d'�tat */ public TransCreator(MainFrame mf, GraphicZone g, Automate auto, StateBar be) { super(JOptionPane.getFrameForComponent(mf), "Creating interaction", true); this.setResizable(false); this.gz = g; this.auto = auto; this.bar = be; this.mf = mf; be.displayInfo("Creating interaction"); tfJPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); tfJPanel1.setBackground(Color.lightGray); tfJPanel1.add(new JLabel("Type : ")); groupe = new CheckboxGroup(); plus = new Checkbox("activator", groupe, true); tfJPanel1.add(plus); minus = new Checkbox("inhibitor", groupe, false); tfJPanel1.add(minus); tfJPanel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); tfJPanel2.setBackground(Color.lightGray); tfJPanel2.add(new JLabel("Threshold = ")); tf = new JTextField(auto.nbrCharTransLabel); tf.setText("1"); tfJPanel2.add(tf); btJPanel = new JPanel(new GridLayout(1, 2, 0, 0)); btJPanel.setBackground(Color.lightGray); ok = new Button("Ok"); ok.setBackground(Color.lightGray); ok.addActionListener(this); cancel = new Button("Cancel"); cancel.setBackground(Color.lightGray); cancel.addActionListener(this); btJPanel.add(ok); btJPanel.add(cancel); content = this.getContentPane(); content.setLayout(new BorderLayout()); content.setBackground(Color.lightGray); content.add(tfJPanel1, BorderLayout.NORTH); content.add(tfJPanel2, BorderLayout.CENTER); content.add(btJPanel, BorderLayout.SOUTH); this.pack(); this.setLocationRelativeTo(this.mf); tf.requestFocusInWindow(); // rendre la fenetre visible setVisible(true); }
protected void createExeCancDefGroup(final QueryOptionsPack opt, int horizontalSpan) { // Group for execute, cancel and default buttons exeCancelDefaultGroup = new Group(shell, SWT.NONE); GridData gridData = new GridData(GridData.FILL, GridData.CENTER, false, false); gridData.horizontalSpan = horizontalSpan; exeCancelDefaultGroup.setLayoutData(gridData); exeCancelDefaultGroup.setLayout(new GridLayout(4, true)); if (forSIF) { sifTypeButton = new Button(exeCancelDefaultGroup, SWT.NONE); sifTypeButton.setBackground(new Color(null, 255, 255, 255)); gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false); sifTypeButton.setLayoutData(gridData); sifTypeButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { ArrayList<SIFType> selection = new ArrayList<SIFType>(selectedTypes); ExportToSIFL3Dialog dialog = new ExportToSIFL3Dialog( main.getShell(), org.gvt.model.sifl3.SIFGraph.getPossibleRuleTypes(), selection); if (dialog.open()) { selectedTypes.clear(); selectedTypes.addAll(selection); updateSIFTypeButtonText(); } } }); if (selectedTypes == null) selectedTypes = new ArrayList<SIFType>(); updateSIFTypeButtonText(); } // Execute Button executeButton = new Button(exeCancelDefaultGroup, SWT.NONE); executeButton.setText("Execute"); gridData = new GridData(GridData.END, GridData.CENTER, true, false); executeButton.setLayoutData(gridData); executeButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { // if no entity is added, show error if ((sourceElg != null && getAddedSourceEntities().isEmpty()) || (sourceST != null && sourceST.getSymbols().isEmpty())) { MessageDialog.openError(main.getShell(), "Error!", "Add Source Molecule!"); return; } if ((targetElg != null && getAddedTargetEntities().isEmpty()) || (targetST != null && targetST.getSymbols().isEmpty())) { MessageDialog.openError(main.getShell(), "Error!", "Add Target Molecule!"); return; } if (forSIF && selectedTypes.isEmpty()) { MessageDialog.openError( main.getShell(), "Error!", "Please select at least one interaction type."); return; } // Check for unknown gene symbols java.util.List<String> unkwn = getUnknownSymbols(); if (!unkwn.isEmpty()) { String s = ""; for (String us : unkwn) s += " " + us; MessageDialog.openError( main.getShell(), "Error!", "Unknown symbol" + (unkwn.size() > 1 ? "s" : "") + ": " + s); return; } // store values in dialog to optionsPack storeValuesToOptionsPack(opt); // execute is selected opt.setCancel(false); shell.close(); } }); // Cancel Button cancelButton = new Button(exeCancelDefaultGroup, SWT.NONE); gridData = new GridData(GridData.CENTER, GridData.CENTER, true, false); createCancelButton(gridData); // Default Button defaultButton = new Button(exeCancelDefaultGroup, SWT.NONE); defaultButton.setText("Default"); gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false); defaultButton.setLayoutData(gridData); defaultButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { // set default values of dialog setDefaultQueryDialogOptions(); } }); }