List of usage examples for javax.swing BoxLayout X_AXIS
int X_AXIS
To view the source code for javax.swing BoxLayout X_AXIS.
Click Source Link
From source file:richtercloud.document.scanner.gui.DocumentScanner.java
/** * Creates new DocumentScanner which does nothing unless * * @throws richtercloud.document.scanner.gui.TesseractNotFoundException *//* ww w. j a v a 2 s. c om*/ /* internal implementation notes: - resources are opened in init methods only (see https://richtercloud.de:446/doku.php?id=programming:java#resource_handling for details) */ public DocumentScanner() throws BinaryNotFoundException { this.parseArguments(); assert HOME_DIR.exists(); if (!CONFIG_DIR.exists()) { CONFIG_DIR.mkdir(); LOGGER.info("created inexisting configuration directory '{}'", CONFIG_DIR_NAME); } try { this.tesseractOCREngineConfPanel = new TesseractOCREngineConfPanel(); } catch (IOException | InterruptedException ex) { throw new RuntimeException(ex); } this.initComponents(); //loading properties depends on initComponents because exceptions are //handled with GUI elements this.configFile = new File(CONFIG_DIR, CONFIG_FILE_NAME); if (this.configFile.exists()) { this.loadProperties(); //initializes this.conf } else { try { this.documentScannerConf = new DocumentScannerConf(entityManager, messageHandler, ENTITY_CLASSES, derbyPersistenceStorageSchemeChecksumFile, xMLStorageFile); } catch (IOException ex) { throw new RuntimeException(ex); } LOGGER.info("no previous configuration found in configuration directry '{}', using default values", CONFIG_DIR.getAbsolutePath()); //new configuration will be persisted in shutdownHook } //after loading DocumentScannerConf for (StorageConf<?, ?> availableStorageConf : this.documentScannerConf.getAvailableStorageConfs()) { this.storageListModel.addElement(availableStorageConf); } this.onDeviceUnset(); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { LOGGER.info("running {} shutdown hooks", DocumentScanner.class); DocumentScanner.this.shutdownHook(); } }); this.oCREngineConfPanelMap.put(TesseractOCREngineConf.class, this.tesseractOCREngineConfPanel); this.oCREngineComboBoxModel.addElement(TesseractOCREngineConf.class); this.oCRDialogEngineComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { Class<? extends OCREngineConf<?>> clazz = (Class<? extends OCREngineConf<?>>) e.getItem(); OCREngineConfPanel<?> cREngineConfPanel = DocumentScanner.this.oCREngineConfPanelMap.get(clazz); DocumentScanner.this.oCRDialogPanel.removeAll(); DocumentScanner.this.oCRDialogPanel.add(cREngineConfPanel); DocumentScanner.this.oCRDialogPanel.revalidate(); DocumentScanner.this.pack(); DocumentScanner.this.oCRDialogPanel.repaint(); } }); this.oCRDialogPanel.setLayout(new BoxLayout(this.oCRDialogPanel, BoxLayout.X_AXIS)); //set initial panel state this.oCRDialogPanel.removeAll(); this.oCRDialogPanel.add(this.tesseractOCREngineConfPanel); this.oCRDialogPanel.revalidate(); this.pack(); this.oCRDialogPanel.repaint(); this.storageCreateDialogTypeComboBoxModel.addElement(DerbyPersistenceStorageConf.class); this.storageCreateDialogTypeComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { Class<? extends StorageConf<?, ?>> clazz = (Class<? extends StorageConf<?, ?>>) e.getItem(); StorageConfPanel<?> storageConfPanel = DocumentScanner.this.storageConfPanelMap.get(clazz); DocumentScanner.this.storageCreateDialogPanel.removeAll(); DocumentScanner.this.storageCreateDialogPanel.add(storageConfPanel); DocumentScanner.this.storageCreateDialogPanel.revalidate(); DocumentScanner.this.pack(); DocumentScanner.this.storageCreateDialogPanel.repaint(); } }); this.storageList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { DocumentScanner.this.storageDialogSelectButton .setEnabled(DocumentScanner.this.storageListModel.getSize() > 0 && DocumentScanner.this.storageList.getSelectedIndices().length > 0); } }); File amountMoneyUsageStatisticsStorageFile = new File(CONFIG_DIR, AMOUNT_MONEY_USAGE_STATISTICS_STORAGE_FILE_NAME); File amountMoneyCurrencyStorageFile = new File(CONFIG_DIR, AMOUNT_MONEY_CURRENCY_STORAGE_FILE_NAME); try { this.amountMoneyUsageStatisticsStorage = new FileAmountMoneyUsageStatisticsStorage( amountMoneyUsageStatisticsStorageFile); } catch (IOException ex) { throw new RuntimeException(ex); } this.amountMoneyCurrencyStorage = new FileAmountMoneyCurrencyStorage(amountMoneyCurrencyStorageFile); JPAAmountMoneyMappingTypeHandlerFactory fieldHandlerFactory = new JPAAmountMoneyMappingTypeHandlerFactory( entityManager, INITIAL_QUERY_LIMIT_DEFAULT, messageHandler, BIDIRECTIONAL_HELP_DIALOG_TITLE); this.typeHandlerMapping = fieldHandlerFactory.generateTypeHandlerMapping(); //after entity manager creation this.typeHandlerMapping.put(new TypeToken<List<AnyType>>() { }.getType(), new JPAEntityListTypeHandler(entityManager, messageHandler, BIDIRECTIONAL_HELP_DIALOG_TITLE)); }
From source file:ro.nextreports.designer.datasource.ConnectionDialog.java
private void create() { this.getContentPane().setLayout(new GridBagLayout()); this.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { resize();//from w ww .ja v a 2 s. c o m } }); JPanel p = new JPanel(new GridBagLayout()); backColor = p.getBackground(); mName = new JTextField(); mDriver = new JTextField(); //mDriver.setBackground(backColor); mURL = new JTextField(); //mURL.setBackground(backColor); mUser = new JTextField(); //mUser.setBackground(backColor); mPassword = new JPasswordField(); mPassword.setEchoChar('*'); //mPassword.setBackground(backColor); txaStatus = new JTextArea(); txaStatus.setEditable(false); txaStatus.setBackground(backColor); scr = new JScrollPane(txaStatus); scr.setSize(220, 50); scr.setBorder(new TitledBorder(STATUS)); types = new JComboBox(); types.addItemListener(this); urlFormatLabel = new JLabel(); Font font = urlFormatLabel.getFont().deriveFont(Font.BOLD, 10); urlFormatLabel.setFont(font); urlButton = new JButton(); urlButton.setPreferredSize(buttonDim); urlButton.setMinimumSize(buttonDim); urlButton.setMaximumSize(buttonDim); urlButton.setIcon(ImageUtil.getImageIcon("url_edit")); urlButton.setToolTipText(I18NSupport.getString("connection.dialog.tags.tooltip")); urlButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { editUrl(); } }); for (DriverTemplate template : templates) { types.addItem(template.getType()); } types.setSelectedItem(DEFAULT_DRIVER_TYPE); auto = new JCheckBox(I18NSupport.getString("connection.dialog.auto")); if (viewOnly) { mName.setEditable(false); types.setEnabled(false); mDriver.setEditable(false); mURL.setEditable(false); mUser.setEditable(false); mPassword.setEditable(false); urlButton.setEnabled(false); } p.add(new JLabel(I18NSupport.getString("connection.dialog.name")), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mName, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JLabel(I18NSupport.getString("connection.dialog.type")), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(types, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JLabel(I18NSupport.getString("connection.dialog.driver")), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mDriver, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JLabel(I18NSupport.getString("connection.dialog.url")), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mURL, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 0), 0, 0)); p.add(urlButton, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); if (!viewOnly) { p.add(urlFormatLabel, new GridBagConstraints(1, 4, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0)); } p.add(new JLabel(I18NSupport.getString("connection.dialog.user")), new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mUser, new GridBagConstraints(1, 5, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JLabel(I18NSupport.getString("connection.dialog.password")), new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mPassword, new GridBagConstraints(1, 6, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); if (!viewOnly) { p.add(auto, new GridBagConstraints(1, 7, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); } JButton okBtn, disBtn, drvBtn, addBtn, propBtn; okBtn = new JButton(I18NSupport.getString("connection.dialog.test"), ImageUtil.getImageIcon("database_connect")); okBtn.setMnemonic('T'); okBtn.setActionCommand("ConnectOk"); okBtn.setToolTipText(I18NSupport.getString("connection.dialog.test.tooltip")); okBtn.addActionListener(this); disBtn = new JButton(I18NSupport.getString("connection.dialog.disconnect"), ImageUtil.getImageIcon("database")); disBtn.setMnemonic('D'); disBtn.setActionCommand("Disconnect"); disBtn.setToolTipText(I18NSupport.getString("connection.dialog.disconnect")); disBtn.addActionListener(this); drvBtn = new JButton(I18NSupport.getString("connection.dialog.add.driver"), ImageUtil.getImageIcon("add_driver")); drvBtn.setMnemonic('A'); drvBtn.setActionCommand("AddDriver"); drvBtn.setToolTipText(I18NSupport.getString("connection.dialog.add.driver.tooltip")); drvBtn.addActionListener(this); propBtn = new JButton(I18NSupport.getString("connection.dialog.properties"), ImageUtil.getImageIcon("properties")); propBtn.setMnemonic('P'); propBtn.setActionCommand("Properties"); propBtn.setToolTipText(I18NSupport.getString("connection.dialog.properties.tooltip")); propBtn.addActionListener(this); addBtn = new JButton(ImageUtil.getImageIcon("database_export")); if (oldDataSource == null) { addBtn.setText(I18NSupport.getString("connection.dialog.save")); addBtn.setToolTipText(I18NSupport.getString("connection.dialog.save.tooltip")); addBtn.setMnemonic('S'); } else { addBtn.setText(I18NSupport.getString("connection.dialog.modify")); addBtn.setToolTipText(I18NSupport.getString("connection.dialog.modify.tooltip")); addBtn.setMnemonic('M'); } addBtn.setActionCommand("AddDataSource"); addBtn.addActionListener(this); JPanel btnPanel = new JPanel(); btnPanel.setLayout(new BoxLayout(btnPanel, BoxLayout.X_AXIS)); btnPanel.add(Box.createHorizontalGlue()); btnPanel.add(propBtn); btnPanel.add(Box.createRigidArea(new Dimension(5, 5))); btnPanel.add(okBtn); btnPanel.add(Box.createRigidArea(new Dimension(5, 5))); //btnPanel.add(disBtn); //btnPanel.add(Box.createRigidArea(new Dimension(5, 5))); btnPanel.add(addBtn); // btnPanel.add(Box.createRigidArea(new Dimension(5, 5))); // btnPanel.add(drvBtn); SwingUtil.equalizeButtonSizes(btnPanel); if (!viewOnly) { p.add(btnPanel, new GridBagConstraints(0, 8, 3, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(scr, new GridBagConstraints(0, 9, 3, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); } this.getContentPane().add(p, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); if (oldDataSource != null) { mName.setText(oldDataSource.getName()); types.setSelectedItem(oldDataSource.getType()); mDriver.setText(oldDataSource.getDriver()); mURL.setText(oldDataSource.getUrl()); mUser.setText(oldDataSource.getUser()); mPassword.setText(oldDataSource.getPassword()); } }
From source file:ro.nextreports.designer.NextReports.java
public static void showStartDialog(boolean test) { JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS)); final JCheckBox chk = new JCheckBox(I18NSupport.getString("start.panel.show.startup"), true); bottomPanel.add(chk);// w w w . j ava 2 s . c o m bottomPanel.add(Box.createHorizontalGlue()); String start = ReporterPreferencesManager.getInstance() .loadParameter(ReporterPreferencesManager.SHOW_AT_STARTUP + "_" + ReleaseInfo.getVersion()); if (test && "false".equals(start)) { return; } HelpMovieAction helpAction = new HelpMovieAction(); VistaButton buttonHelp = new VistaButton(helpAction, I18NSupport.getString("start.panel.help")); ImportAction importAction = new ImportAction(); VistaButton buttonImport = new VistaButton(importAction, I18NSupport.getString("start.panel.import")); AddDataSourceAction dataSourceAction = new AddDataSourceAction(); VistaButton buttonDataSource = new VistaButton(dataSourceAction, I18NSupport.getString("start.panel.datasource")); WizardAction wizardAction = new WizardAction(Globals.getMainFrame().getQueryBuilderPanel().getTree()); VistaButton buttonWizard = new VistaButton(wizardAction, I18NSupport.getString("start.panel.wizard")); List<VistaButton> list = new ArrayList<VistaButton>(); list.add(buttonHelp); list.add(buttonImport); list.add(buttonDataSource); list.add(buttonWizard); VistaDialogContent content = new VistaDialogContent(list, I18NSupport.getString("start.panel.title"), I18NSupport.getString("start.panel.subtitle")); VistaDialog dialog = new VistaDialog(content, bottomPanel, Globals.getMainFrame(), true) { private static final long serialVersionUID = 1L; @Override protected void beforeDispose() { String show = chk.isSelected() ? "true" : "false"; ReporterPreferencesManager.getInstance().storeParameter( ReporterPreferencesManager.SHOW_AT_STARTUP + "_" + ReleaseInfo.getVersion(), show); } }; dialog.setTitle(I18NSupport.getString("menu.startup")); dialog.selectButton(buttonHelp); dialog.setDispose(true); dialog.setEscapeOption(true); dialog.pack(); dialog.setResizable(false); Show.centrateComponent(Globals.getMainFrame(), dialog); dialog.setVisible(true); }
From source file:ro.nextreports.designer.querybuilder.SelectionColumnPanel.java
private void buildUI() { setLayout(new GridBagLayout()); final DBViewer viewer = Globals.getDBViewer(); schemaCombo = new JComboBox(); schemaCombo.setPreferredSize(comboDim); schemaCombo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { String schema = (String) e.getItem(); shownColumnModel.clear();//from w ww. ja v a 2s .c o m columnModel.clear(); tableModel.clear(); try { DBInfo dbInfo = viewer.getDBInfo(schema, DBInfo.TABLES | DBInfo.VIEWS); List<DBTable> tables = dbInfo.getTables(); Collections.sort(tables); for (DBTable table : tables) { tableModel.addElement(table); } } catch (NextSqlException ex) { LOG.error(ex.getMessage(), ex); ex.printStackTrace(); } } }); try { List<String> schemas = viewer.getSchemas(); String schemaName = viewer.getUserSchema(); Collections.sort(schemas); boolean added = false; for (String schema : schemas) { if (DefaultSchemaManager.getInstance().isVisible( DefaultDataSourceManager.getInstance().getConnectedDataSource().getName(), schema)) { added = true; schemaCombo.addItem(schema); } } if ((schema == null) || schema.equals(DefaultDBViewer.NO_SCHEMA_NAME)) { schema = DefaultDBViewer.NO_SCHEMA_NAME;//viewer.getUserSchema(); } if (!added) { schemaCombo.addItem(schema); } schemaCombo.setSelectedItem(schema); } catch (NextSqlException e) { LOG.error(e.getMessage(), e); e.printStackTrace(); } // create table list tableList = new JXList(tableModel); tableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tableList.setCellRenderer(new DBTableCellRenderer()); // create column list columnList = new JXList(columnModel); if (singleSelection) { columnList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else { columnList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } columnList.setCellRenderer(new DBColumnCellRenderer()); shownColumnList = new JXList(shownColumnModel); if (singleSelection) { shownColumnList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else { columnList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } addDoubleClick(); shownColumnList.setCellRenderer(new DBColumnCellRenderer()); shownColumnList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent mouseEvent) { if ((mouseEvent.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) { JPopupMenu popupMenu = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(new DeselectListAction(shownColumnList)); popupMenu.add(menuItem); popupMenu.show((Component) mouseEvent.getSource(), mouseEvent.getX(), mouseEvent.getY()); } } }); tableList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting() == false) { int index = tableList.getSelectedIndex(); if (index == -1) { return; } DBTable table = (DBTable) tableModel.getElementAt(index); try { List<DBColumn> columns = null; try { columns = viewer.getColumns(table.getSchema(), table.getName()); } catch (MalformedTableNameException e1) { Show.error("Malformed table name : " + table.getName()); return; } Collections.sort(columns); columnModel.clear(); shownColumnModel.clear(); for (DBColumn column : columns) { columnModel.addElement(column); shownColumnModel.addElement(column); } } catch (NextSqlException e1) { LOG.error(e1.getMessage(), e1); e1.printStackTrace(); Show.error(e1); } } } }); columnList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { shownColumnList.clearSelection(); } }); scrTable = new JScrollPane(tableList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrTable.setPreferredSize(scrDim); scrTable.setMinimumSize(scrDim); scrTable.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.tables"))); scrColumn = new JScrollPane(columnList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrColumn.setPreferredSize(scrDim); scrColumn.setMinimumSize(scrDim); scrColumn.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.columns"))); scrShownColumn = new JScrollPane(shownColumnList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrShownColumn.setPreferredSize(scrDim); scrShownColumn.setMinimumSize(scrDim); scrShownColumn.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.shown.columns"))); JPanel schemaPanel = new JPanel(); schemaPanel.setLayout(new BoxLayout(schemaPanel, BoxLayout.X_AXIS)); schemaPanel.add(new JLabel("Schema")); schemaPanel.add(Box.createHorizontalStrut(5)); schemaPanel.add(schemaCombo); add(schemaPanel, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(scrTable, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0)); add(scrColumn, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0)); if (show) { add(scrShownColumn, new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } }
From source file:ro.nextreports.designer.wizrep.QueryWizardPanel.java
private void init() { setLayout(new BorderLayout()); ButtonGroup bg = new ButtonGroup(); bg.add(selectionRB);// w w w .j av a 2 s.c om bg.add(queryRB); bg.add(editRB); selectionRB.setSelected(true); selectionRB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selection(); } }); queryRB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selection(); } }); editRB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selection(); } }); editor = new EditorPanel(); parametersPanel = new ParametersPanel(); parametersPanel.setPreferredSize(new Dimension(120, 200)); queryPanel = new QueryBrowserPanel() { protected void selection() { String name = queryPanel.getSelectedFilePath(); if (queryPanel.querySelected()) { ReportPersistence repPersist = ReportPersistenceFactory .createReportPersistence(Globals.getReportPersistenceType()); Report report = repPersist.loadReport(name); context.setAttribute(WizardConstants.LOAD_REPORT, report); String sql = report.getSql(); if (sql == null) { sql = report.getQuery().toString(); } editor.setText(sql); parametersPanel.set(report.getParameters()); } else { context.setAttribute(WizardConstants.LOAD_REPORT, null); editor.setText(""); parametersPanel.set(new ArrayList<QueryParameter>()); } } }; sqlLabel = new JLabel("<html><b>Sql</b></html>"); easyPanel = new EasySelectColumnsPanel(); JPanel qPanel = new JPanel(new GridBagLayout()); JPanel radioPanel = new JPanel(); radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.X_AXIS)); radioPanel.add(selectionRB); radioPanel.add(Box.createHorizontalStrut(5)); radioPanel.add(queryRB); radioPanel.add(Box.createHorizontalStrut(5)); radioPanel.add(editRB); qPanel.add(radioPanel, new GridBagConstraints(0, 0, 4, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); queryLabel = new JLabel(I18NSupport.getString("query.name")); qPanel.add(queryLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); qPanel.add(queryPanel, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 0, 0), 0, 0)); qPanel.add(sqlLabel, new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); qPanel.add(editor, new GridBagConstraints(0, 3, 3, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); qPanel.add(parametersPanel, new GridBagConstraints(3, 2, 1, 2, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 5, 5, 5), 0, 0)); qPanel.add(emptyLabel, new GridBagConstraints(0, 4, 4, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); qPanel.add(easyPanel, new GridBagConstraints(0, 2, 4, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); selection(); add(qPanel, BorderLayout.CENTER); }
From source file:ru.medved.json.wssoap.WebServiceSamplerGui.java
private final JPanel createTopPanel() { JPanel topPanel = new JPanel(); topPanel.setLayout(new VerticalLayout(5, VerticalLayout.BOTH)); JPanel wsdlHelper = new JPanel(); wsdlHelper.setLayout(new BoxLayout(wsdlHelper, BoxLayout.Y_AXIS)); wsdlHelper.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils.getResString("webservice_configuration_wizard"))); // $NON-NLS-1$ // Button for browsing webservice wsdl JPanel wsdlEntry = new JPanel(); wsdlEntry.setLayout(new BoxLayout(wsdlEntry, BoxLayout.X_AXIS)); Border margin = new EmptyBorder(0, 5, 0, 5); wsdlEntry.setBorder(margin);//from www . jav a 2s . c om wsdlHelper.add(wsdlEntry); wsdlEntry.add(wsdlField); wsdlEntry.add(wsdlButton); wsdlButton.addActionListener(this); // Web Methods JPanel listPanel = new JPanel(); listPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); JLabel selectLabel = new JLabel(JMeterUtils.getResString("webservice_methods")); // $NON-NLS-1$ wsdlMethods = new JLabeledChoice(); wsdlHelper.add(listPanel); listPanel.add(selectLabel); listPanel.add(wsdlMethods); listPanel.add(selectButton); selectButton.addActionListener(this); topPanel.add(wsdlHelper); JPanel urlPane = new JPanel(); urlPane.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); urlPane.add(protocol); urlPane.add(Box.createRigidArea(new Dimension(5, 0))); urlPane.add(domain); urlPane.add(Box.createRigidArea(new Dimension(5, 0))); urlPane.add(port); urlPane.add(Box.createRigidArea(new Dimension(5, 0))); urlPane.add(connectTimeout); topPanel.add(urlPane); topPanel.add(path); topPanel.add(soapAction); topPanel.add(jsonConfigFile); topPanel.add(configSection); return topPanel; }
From source file:savant.view.swing.BookmarkSheet.java
public BookmarkSheet(Container c) { // set the layout of the data sheet c.setLayout(new BorderLayout()); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); /**/*w w w . ja v a 2 s . com*/ * Create a toolbar. */ JMenuBar toolbar = new JMenuBar(); toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS)); c.add(toolbar, BorderLayout.NORTH); JButton previousButton = new JButton(); previousButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.UP)); previousButton.setToolTipText("Go to previous bookmark [ Ctrl+( ]"); previousButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); previousButton.putClientProperty("JButton.segmentPosition", "first"); previousButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToPreviousBookmark(); } }); toolbar.add(previousButton); JButton nextButton = new JButton(); nextButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.DOWN)); nextButton.setToolTipText("Go to next bookmark [ Ctrl+) ]"); nextButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); nextButton.putClientProperty("JButton.segmentPosition", "last"); nextButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToNextBookmark(); } }); toolbar.add(nextButton); JButton goButton = new JButton("Go"); goButton.setToolTipText("Go to selected bookmark"); goButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); goButton.putClientProperty("JButton.segmentPosition", "only"); goButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToSelectedBookmark(); } }); toolbar.add(goButton); toolbar.add(Box.createGlue()); addButton = new JButton(); addButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.BKMK_ADD)); addButton.setToolTipText("Add bookmark for current range"); addButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); addButton.putClientProperty("JButton.segmentPosition", "first"); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { BookmarkController fc = BookmarkController.getInstance(); fc.addCurrentRangeToBookmarks(); } }); toolbar.add(addButton); JButton deleteButton = new JButton(); deleteButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.BKMK_RM)); deleteButton.setToolTipText("Delete selected bookmarks"); deleteButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); deleteButton.putClientProperty("JButton.segmentPosition", "last"); deleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { BookmarkController fc = BookmarkController.getInstance(); int[] selectedRows = table.getSelectedRows(); Arrays.sort(selectedRows); boolean delete = false; if (selectedRows.length > 0 && confirmDelete) { Object[] options = { "Yes", "No", "Yes, don't ask again" }; JLabel message = new JLabel( "Are you sure you want to delete " + selectedRows.length + " item(s)?"); message.setPreferredSize(new Dimension(300, 20)); int confirmDeleteDialog = JOptionPane.showOptionDialog(DialogUtils.getMainWindow(), message, "Confirm Delete", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (confirmDeleteDialog == 0) { delete = true; } else if (confirmDeleteDialog == 2) { delete = true; confirmDelete = false; } } else if (selectedRows.length > 0 && !confirmDelete) { delete = true; } if (delete) { for (int i = selectedRows.length - 1; i >= 0; i--) { fc.removeBookmark(selectedRows[i]); } } } }); toolbar.add(deleteButton); toolbar.add(Box.createGlue()); JButton loadButton = new JButton(); loadButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.OPEN)); loadButton.setToolTipText("Load bookmarks from file"); loadButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); loadButton.putClientProperty("JButton.segmentPosition", "first"); loadButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loadBookmarks(table); } }); toolbar.add(loadButton); JButton saveButton = new JButton(); saveButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SAVE)); saveButton.setToolTipText("Save bookmarks to file"); saveButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); saveButton.putClientProperty("JButton.segmentPosition", "last"); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveBookmarks(table); } }); toolbar.add(saveButton); // create a table (the most important component) table = new JTable(new BookmarksTableModel()); table.setAutoCreateRowSorter(true); table.setFillsViewportHeight(true); table.setShowGrid(true); table.setGridColor(Color.gray); //table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); // add the table and its header to the subpanel c.add(table.getTableHeader()); add(table); final JScrollPane sp = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp.setWheelScrollingEnabled(false); sp.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { sp.getVerticalScrollBar().setValue(sp.getVerticalScrollBar().getValue() + e.getUnitsToScroll() * 2); } }); c.add(sp); // add glue to fill the remaining space add(Box.createGlue()); }
From source file:savant.view.swing.NavigationBar.java
NavigationBar() { this.setOpaque(false); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); String buttonStyle = "segmentedCapsule"; String shortcutMod = MiscUtils.MAC ? "Cmd" : "Ctrl"; add(getRigidPadding());/* w ww .j a va 2s . c o m*/ JButton loadGenomeButton = (JButton) add(new JButton("")); loadGenomeButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.GENOME)); loadGenomeButton.setToolTipText("Load or change genome"); loadGenomeButton.setFocusable(false); loadGenomeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Savant.getInstance().showOpenGenomeDialog(); } }); loadGenomeButton.putClientProperty("JButton.buttonType", buttonStyle); loadGenomeButton.putClientProperty("JButton.segmentPosition", "first"); loadGenomeButton.setPreferredSize(ICON_SIZE); loadGenomeButton.setMinimumSize(ICON_SIZE); loadGenomeButton.setMaximumSize(ICON_SIZE); JButton loadTrackButton = (JButton) add(new JButton("")); loadTrackButton.setFocusable(false); loadTrackButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.TRACK)); loadTrackButton.setToolTipText("Load a track"); loadTrackButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Savant.getInstance().openTrack(); } }); loadTrackButton.putClientProperty("JButton.buttonType", buttonStyle); loadTrackButton.putClientProperty("JButton.segmentPosition", "last"); loadTrackButton.setPreferredSize(ICON_SIZE); loadTrackButton.setMinimumSize(ICON_SIZE); loadTrackButton.setMaximumSize(ICON_SIZE); if (!Savant.getInstance().isStandalone()) { add(loadGenomeButton); add(loadTrackButton); add(getRigidPadding()); add(getRigidPadding()); } else { loadGenomeButton.setVisible(false); loadTrackButton.setVisible(false); } JLabel rangeText = new JLabel("Location "); add(rangeText); String[] a = { " ", " ", " ", " ", " ", " ", " ", " ", " ", " " }; locationField = new JComboBox(a); locationField.setEditable(true); locationField.setRenderer(new ReferenceListRenderer()); // When the item is chosen from the menu, navigate to the given feature/reference. locationField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (!currentlyPopulating) { if (ae.getActionCommand().equals("comboBoxChanged")) { // Assumes that combo-box items created by populateCombo() are of the form "GENE (chrX:1-1000)". String itemText = locationField.getSelectedItem().toString(); int lastBracketPos = itemText.lastIndexOf('('); if (lastBracketPos > 0) { itemText = itemText.substring(lastBracketPos + 1, itemText.length() - 1); } setRangeFromText(itemText); } } } }); // When the combo-box is popped open, we may want to repopulate the menu. locationField.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent pme) { String text = (String) locationField.getEditor().getItem(); if (!text.equals(lastPoppedUp)) { try { // Building the menu could take a while. setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); populateCombo(); } finally { setCursor(Cursor.getDefaultCursor()); } } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent pme) { } @Override public void popupMenuCanceled(PopupMenuEvent pme) { } }); // Add our special keystroke-handling to the JComboBox' text-field. // We have to turn off default tab-handling so that tab can pop up our list. Component textField = locationField.getEditor().getEditorComponent(); textField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET); textField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_TAB) { locationField.showPopup(); } else if (evt.getModifiers() == KeyEvent.SHIFT_MASK) { switch (evt.getKeyCode()) { case KeyEvent.VK_LEFT: locationController.shiftRangeLeft(); evt.consume(); break; case KeyEvent.VK_RIGHT: locationController.shiftRangeRight(); evt.consume(); break; case KeyEvent.VK_UP: locationController.zoomIn(); evt.consume(); break; case KeyEvent.VK_DOWN: locationController.zoomOut(); evt.consume(); break; case KeyEvent.VK_HOME: locationController.shiftRangeFarLeft(); evt.consume(); break; case KeyEvent.VK_END: locationController.shiftRangeFarRight(); evt.consume(); break; } } } }); add(locationField); locationField.setToolTipText("Current display range"); locationField.setPreferredSize(LOCATION_SIZE); locationField.setMaximumSize(LOCATION_SIZE); locationField.setMinimumSize(LOCATION_SIZE); add(getRigidPadding()); JButton goButton = (JButton) add(new JButton(" Go ")); goButton.putClientProperty("JButton.buttonType", buttonStyle); goButton.putClientProperty("JButton.segmentPosition", "only"); goButton.setToolTipText("Go to specified range (Enter)"); goButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setRangeFromText(locationField.getEditor().getItem().toString()); } }); add(getRigidPadding()); JLabel l = new JLabel("Length: "); add(l); lengthLabel = (JLabel) add(new JLabel()); lengthLabel.setToolTipText("Length of the current range"); lengthLabel.setPreferredSize(LENGTH_SIZE); lengthLabel.setMaximumSize(LENGTH_SIZE); lengthLabel.setMinimumSize(LENGTH_SIZE); add(Box.createGlue()); double screenwidth = Toolkit.getDefaultToolkit().getScreenSize().getWidth(); JButton afterGo = null; //if (screenwidth > 800) { final JButton undoButton = (JButton) add(new JButton("")); afterGo = undoButton; undoButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.UNDO)); undoButton.setToolTipText("Undo range change (" + shortcutMod + "+Z)"); undoButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.undoLocationChange(); } }); undoButton.putClientProperty("JButton.buttonType", buttonStyle); undoButton.putClientProperty("JButton.segmentPosition", "first"); undoButton.setPreferredSize(ICON_SIZE); undoButton.setMinimumSize(ICON_SIZE); undoButton.setMaximumSize(ICON_SIZE); final JButton redo = (JButton) add(new JButton("")); redo.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.REDO)); redo.setToolTipText("Redo range change (" + shortcutMod + "+Y)"); redo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.redoLocationChange(); } }); redo.putClientProperty("JButton.buttonType", buttonStyle); redo.putClientProperty("JButton.segmentPosition", "last"); redo.setPreferredSize(ICON_SIZE); redo.setMinimumSize(ICON_SIZE); redo.setMaximumSize(ICON_SIZE); //} add(getRigidPadding()); add(getRigidPadding()); final JButton zoomInButton = (JButton) add(new JButton()); if (afterGo == null) { afterGo = zoomInButton; } zoomInButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMIN)); zoomInButton.putClientProperty("JButton.buttonType", buttonStyle); zoomInButton.putClientProperty("JButton.segmentPosition", "first"); zoomInButton.setPreferredSize(ICON_SIZE); zoomInButton.setMinimumSize(ICON_SIZE); zoomInButton.setMaximumSize(ICON_SIZE); zoomInButton.setToolTipText("Zoom in (Shift+Up)"); zoomInButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.zoomIn(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "zoomed"), new NameValuePair("navigation-direction", "in"), new NameValuePair("navigation-modality", "navbar") }); } }); final JButton zoomOut = (JButton) add(new JButton("")); zoomOut.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMOUT)); zoomOut.setToolTipText("Zoom out (Shift+Down)"); zoomOut.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.zoomOut(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "zoomed"), new NameValuePair("navigation-direction", "out"), new NameValuePair("navigation-modality", "navbar") }); } }); zoomOut.putClientProperty("JButton.buttonType", buttonStyle); zoomOut.putClientProperty("JButton.segmentPosition", "last"); zoomOut.setPreferredSize(ICON_SIZE); zoomOut.setMinimumSize(ICON_SIZE); zoomOut.setMaximumSize(ICON_SIZE); add(getRigidPadding()); add(getRigidPadding()); final JButton shiftFarLeft = (JButton) add(new JButton()); shiftFarLeft.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_FARLEFT)); shiftFarLeft.putClientProperty("JButton.buttonType", buttonStyle); shiftFarLeft.putClientProperty("JButton.segmentPosition", "first"); shiftFarLeft.setToolTipText("Move to the beginning of the genome (Shift+Home)"); shiftFarLeft.setPreferredSize(ICON_SIZE); shiftFarLeft.setMinimumSize(ICON_SIZE); shiftFarLeft.setMaximumSize(ICON_SIZE); shiftFarLeft.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.shiftRangeFarLeft(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"), new NameValuePair("navigation-direction", "left"), new NameValuePair("navigation-modality", "navbar") }); } }); final JButton shiftLeft = (JButton) add(new JButton()); shiftLeft.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_LEFT)); shiftLeft.putClientProperty("JButton.buttonType", buttonStyle); shiftLeft.putClientProperty("JButton.segmentPosition", "middle"); shiftLeft.setToolTipText("Move left (Shift+Left)"); shiftLeft.setPreferredSize(ICON_SIZE); shiftLeft.setMinimumSize(ICON_SIZE); shiftLeft.setMaximumSize(ICON_SIZE); shiftLeft.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.shiftRangeLeft(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"), new NameValuePair("navigation-direction", "left"), new NameValuePair("navigation-modality", "navbar") }); } }); final JButton shiftRight = (JButton) add(new JButton()); shiftRight.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_RIGHT)); shiftRight.putClientProperty("JButton.buttonType", buttonStyle); shiftRight.putClientProperty("JButton.segmentPosition", "middle"); shiftRight.setToolTipText("Move right (Shift+Right)"); shiftRight.setPreferredSize(ICON_SIZE); shiftRight.setMinimumSize(ICON_SIZE); shiftRight.setMaximumSize(ICON_SIZE); shiftRight.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.shiftRangeRight(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"), new NameValuePair("navigation-direction", "right"), new NameValuePair("navigation-modality", "navbar") }); } }); final JButton shiftFarRight = (JButton) add(new JButton()); shiftFarRight .setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_FARRIGHT)); shiftFarRight.putClientProperty("JButton.buttonType", buttonStyle); shiftFarRight.putClientProperty("JButton.segmentPosition", "last"); shiftFarRight.setToolTipText("Move to the end of the genome (Shift+End)"); shiftFarRight.setPreferredSize(ICON_SIZE); shiftFarRight.setMinimumSize(ICON_SIZE); shiftFarRight.setMaximumSize(ICON_SIZE); shiftFarRight.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.shiftRangeFarRight(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"), new NameValuePair("navigation-direction", "right"), new NameValuePair("navigation-modality", "navbar") }); } }); add(getRigidPadding()); locationController.addListener(new Listener<LocationChangedEvent>() { @Override public void handleEvent(LocationChangedEvent event) { updateLocation(event.getReference(), (Range) event.getRange()); } }); // When the genome changes, we may need to invalidate our menu. GenomeController.getInstance().addListener(new Listener<GenomeChangedEvent>() { @Override public void handleEvent(GenomeChangedEvent event) { lastPoppedUp = "INVALID"; } }); this.addComponentListener(new ComponentListener() { @Override public void componentResized(ComponentEvent ce) { int width = ce.getComponent().getWidth(); undoButton.setVisible(true); redo.setVisible(true); zoomInButton.setVisible(true); zoomOut.setVisible(true); shiftFarLeft.setVisible(true); shiftLeft.setVisible(true); shiftRight.setVisible(true); shiftFarRight.setVisible(true); // hide some components if the window isn't wide enough if (width < 1200) { undoButton.setVisible(false); redo.setVisible(false); } if (width < 1000) { shiftFarLeft.setVisible(false); shiftFarRight.setVisible(false); shiftRight.putClientProperty("JButton.segmentPosition", "last"); shiftLeft.putClientProperty("JButton.segmentPosition", "first"); } else { shiftRight.putClientProperty("JButton.segmentPosition", "middle"); shiftLeft.putClientProperty("JButton.segmentPosition", "middle"); } } public void componentMoved(ComponentEvent ce) { } @Override public void componentShown(ComponentEvent ce) { } @Override public void componentHidden(ComponentEvent ce) { } }); }
From source file:typoscript.TypoScriptPluginOptions.java
protected void _init() { // Take a copy of the current sites config localSitesConfig = (Vector) TypoScriptPlugin.siteConfig.clone(); listModel = new DefaultListModel(); Iterator iter = localSitesConfig.iterator(); while (iter.hasNext()) { listModel.addElement(iter.next()); }/*from w ww. jav a 2s .c om*/ setLayout(new BorderLayout()); add(BorderLayout.NORTH, new JLabel("TYPO3 Sites")); JPanel sites = new JPanel(new BorderLayout()); siteList = new JList(listModel); siteList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); siteList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { updateButtons(); } }); siteList.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { // Edit if doubleclick if (e.getClickCount() == 2) { new AddEditSiteDialog(TypoScriptPluginOptions.this, (T3Site) localSitesConfig.get(siteList.getSelectedIndex())); } } public void mouseEntered(MouseEvent e) { ; } public void mousePressed(MouseEvent e) { ; } public void mouseReleased(MouseEvent e) { ; } public void mouseExited(MouseEvent e) { ; } }); JScrollPane scrollPane = new JScrollPane(siteList); sites.add(scrollPane); this.add(sites); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS)); buttons.setBorder(new EmptyBorder(6, 0, 0, 0)); add = new RolloverButton(GUIUtilities.loadIcon("Plus.png")); add.setToolTipText("Add Site"); add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // Open the add/edit dialog in add mode new AddEditSiteDialog(TypoScriptPluginOptions.this, null); } }); buttons.add(add); remove = new RolloverButton(GUIUtilities.loadIcon("Minus.png")); remove.setToolTipText("Remove Site"); remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { localSitesConfig.remove(siteList.getSelectedIndex()); listModel.removeElementAt(siteList.getSelectedIndex()); } }); buttons.add(remove); edit = new RolloverButton(GUIUtilities.loadIcon("ButtonProperties.png")); edit.setToolTipText("Edit Site"); edit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // Open add/edit dialog in edit mode new AddEditSiteDialog(TypoScriptPluginOptions.this, (T3Site) localSitesConfig.get(siteList.getSelectedIndex())); } }); buttons.add(edit); buttons.add(Box.createGlue()); updateButtons(); add(BorderLayout.SOUTH, buttons); }
From source file:uk.ac.abdn.csd.p2p.server.ServerGUI.java
/** * This method prepares all the graphical components that are contained with P2P Visualisation Server. *//*w w w. ja v a 2s.c om*/ // <editor-fold defaultstate="collapsed" desc="...GUI"> private void initializeComponent() { listeningPort = 0; JFrame frame = new JFrame(); BorderLayout layout = new BorderLayout(); //create a graph overlay = new UndirectedSparseGraph<Vertex, Edge>(); ObservableGraph<Vertex, Edge> og = new ObservableGraph<Vertex, Edge>(overlay); /* og.addGraphEventListener(new GraphEventListener<Vertex, Edge>() { @Override public void handleGraphEvent( GraphEvent<Vertex, Edge> evt) { System.err.println("got " + evt); } });*/ this.overlay = og; layout1 = new FRLayout2<Vertex, Edge>(overlay); vv = new VisualizationViewer<Vertex, Edge>(layout1, new Dimension(700, 200)); vv.setGraphMouse(new DefaultModalGraphMouse<Vertex, Edge>()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Vertex>()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<Edge>()); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); vv.getRenderContext().setVertexFillPaintTransformer(new VertexPainter()); DefaultModalGraphMouse gm1 = new DefaultModalGraphMouse(); gm1.setMode(ModalGraphMouse.Mode.TRANSFORMING); gm1.setMode(ModalGraphMouse.Mode.PICKING); gm1.add(new MyPopupGraphMousePlugin()); vv.setGraphMouse(gm1); vv.addKeyListener(gm1.getModeKeyListener()); contentPane = new JPanel(layout); displayPanel = new javax.swing.JPanel(); consoleTextArea = new JTextArea(); jScrollPane2 = new JScrollPane(); clearButton = new JButton(); consolePanel = new JPanel(); clearButton = new javax.swing.JButton(); nodeTextArea = new JTextArea(); jScrollPane1 = new JScrollPane(); nodePanel = new JPanel(); linkTextArea = new JTextArea(); jScrollPane3 = new JScrollPane(); linkPanel = new JPanel(); menuBar = new javax.swing.JMenuBar(); serverMenu = new javax.swing.JMenu(); startServerMenuItem = new javax.swing.JMenuItem(); jSeparator1 = new javax.swing.JPopupMenu.Separator(); exitMenuItem = new javax.swing.JMenuItem(); editMenu = new javax.swing.JMenu(); settingMenuItem = new javax.swing.JMenuItem(); colorSettingMenuItem = new javax.swing.JMenuItem(); toolMenuItem = new javax.swing.JMenu(); clearMenuItem = new javax.swing.JMenuItem(); helpMenu = new javax.swing.JMenu(); aboutMenuItem = new javax.swing.JMenuItem(); zoominMenuItem = new javax.swing.JMenuItem(); zoomoutMenuItem = new javax.swing.JMenuItem(); layoutSettingMenuItem = new javax.swing.JMenuItem(); labelPositionMenuItem = new javax.swing.JMenuItem(); speedSettingMenuItem = new javax.swing.JMenuItem(); topologySettingMenuItem = new javax.swing.JMenuItem(); findNodeMenuItem = new javax.swing.JMenuItem(); serverMenu.setText("Server"); serverMenu.setToolTipText("Server"); startServerMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK)); startServerMenuItem.setText("Start Server"); startServerMenuItem.setToolTipText("Start Server"); startServerMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { startServerMenuItemActionPerformed(evt); } }); serverMenu.add(startServerMenuItem); serverMenu.add(jSeparator1); exitMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.ALT_MASK)); exitMenuItem.setText("Exit"); exitMenuItem.setToolTipText("Exit"); exitMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { exitMenuItemActionPerformed(evt); } }); serverMenu.add(exitMenuItem); menuBar.add(serverMenu); editMenu.setText("Edit"); editMenu.setToolTipText("Edit"); settingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK)); settingMenuItem.setText("Server Settings"); settingMenuItem.setToolTipText("Server Settings"); settingMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { settingMenuItemActionPerformed(evt); } }); editMenu.add(settingMenuItem); colorSettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.ALT_MASK)); colorSettingMenuItem.setText("Colour Settings"); colorSettingMenuItem.setToolTipText("Colour Settings"); colorSettingMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { colorSettingMenuItemActionPerformed(evt); } }); editMenu.add(colorSettingMenuItem); layoutSettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.ALT_MASK)); layoutSettingMenuItem.setText("Layout Settings"); layoutSettingMenuItem.setToolTipText("Layout Settings"); layoutSettingMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { layoutSettingMenuItemActionPerformed(evt); } }); editMenu.add(layoutSettingMenuItem); speedSettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.ALT_MASK)); speedSettingMenuItem.setText("Speed Settings"); speedSettingMenuItem.setToolTipText("Speed Settings"); speedSettingMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { speedSettingMenuItemActionPerformed(evt); } }); editMenu.add(speedSettingMenuItem); topologySettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.ALT_MASK)); topologySettingMenuItem.setText("Topology Settings"); topologySettingMenuItem.setToolTipText("Topology Settings"); topologySettingMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { topologySettingMenuItemActionPerformed(evt); } }); editMenu.add(topologySettingMenuItem); menuBar.add(editMenu); toolMenuItem.setText("Tools"); toolMenuItem.setToolTipText("Tools"); labelPositionMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.ALT_MASK)); labelPositionMenuItem.setText("Vertex Label Position"); labelPositionMenuItem.setToolTipText("Vertex Label Position"); toolMenuItem.add(labelPositionMenuItem); labelPositionMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { labelPositionMenuItemActionPerformed(evt); } }); final ScalingControl scaler = new CrossoverScalingControl(); zoominMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.ALT_MASK)); zoominMenuItem.setText("Zoom-In"); zoominMenuItem.setToolTipText("Zoom-In"); toolMenuItem.add(zoominMenuItem); zoominMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); zoomoutMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.ALT_MASK)); zoomoutMenuItem.setText("Zoom-Out"); zoomoutMenuItem.setToolTipText("Zoom-Out"); toolMenuItem.add(zoomoutMenuItem); zoomoutMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { scaler.scale(vv, 0.9f, vv.getCenter()); } }); findNodeMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, java.awt.event.InputEvent.ALT_MASK)); findNodeMenuItem.setText("Find Node on Overlay"); findNodeMenuItem.setToolTipText("Find Node"); toolMenuItem.add(findNodeMenuItem); findNodeMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { findNodeMenuItemMenuItemActionPerformed(evt); } }); menuBar.add(toolMenuItem); helpMenu.setText("Help"); helpMenu.setToolTipText("Help"); aboutMenuItem.setText("About"); aboutMenuItem.setToolTipText("About"); aboutMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { aboutMenuItemActionPerformed(evt); } }); helpMenu.add(aboutMenuItem); menuBar.add(helpMenu); displayPanel.setLayout(new BorderLayout()); displayPanel.setBorder(new TitledBorder("P2P Overlay")); displayPanel.add(vv); validate(); // // nodeTextArea // nodeTextArea.setEditable(false); nodeTextArea.setLineWrap(true); // // jScrollPane1 // jScrollPane1.setViewportView(nodeTextArea); //jScrollPane1.setsi // // nodePanel // nodePanel.setLayout(new BoxLayout(nodePanel, BoxLayout.X_AXIS)); nodePanel.add(jScrollPane1, 0); nodePanel.setBorder(new TitledBorder("Nodes Active")); // // linkTextArea // linkTextArea.setEditable(false); linkTextArea.setLineWrap(true); // // jScrollPane3 // jScrollPane3.setViewportView(linkTextArea); // // linkPanel // linkPanel.setLayout(new BoxLayout(linkPanel, BoxLayout.X_AXIS)); linkPanel.add(jScrollPane3, 0); linkPanel.setBorder(new TitledBorder("Node Links")); // // consoleTextArea // consoleTextArea.setEditable(false); consoleTextArea.setLineWrap(true); // // jScrollPane2 // jScrollPane2.setViewportView(consoleTextArea); // // clearButton // clearButton.setText("Clear"); clearButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { clearButton_actionPerformed(e); } }); // // consolePanel // consolePanel.setLayout(new BoxLayout(consolePanel, BoxLayout.X_AXIS)); consolePanel.add(jScrollPane2, 0); consolePanel.add(clearButton, 1); consolePanel.setBorder(new TitledBorder("Console")); // // ServerGUI // Dimension panelD = new Dimension(700, 330); // display Panel Dimension panelD1 = new Dimension(700, 134); // control Panel Dimension panelD2 = new Dimension(350, 140); // nodepanel and linkpanel Dimension panelD3 = new Dimension(700, 140); // nodepanel and linkpanel togther consolePanel.setPreferredSize(panelD1); displayPanel.setPreferredSize(panelD); nodePanel.setPreferredSize(panelD2); linkPanel.setPreferredSize(panelD2); Box box = new Box(BoxLayout.X_AXIS); // put nodepanel and linkpanel in one box box.add(nodePanel); box.add(linkPanel); box.setSize(panelD3); //contentPane.add(BorderLayout.NORTH,displayPanel); //contentPane.add(BorderLayout.CENTER,box); contentPane.add(BorderLayout.NORTH, box); contentPane.add(BorderLayout.CENTER, displayPanel); contentPane.add(BorderLayout.SOUTH, consolePanel); frame.setJMenuBar(menuBar); frame.getContentPane().add(contentPane); frame.setTitle("P2P Visualisation Server"); frame.setSize(new Dimension(800, 600)); frame.setResizable(true); // This code has been adapted from http://lookass.ch/?id=4&area=art&art=47 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension size = frame.getSize(); screenSize.height = screenSize.height / 2; screenSize.width = screenSize.width / 2; size.height = size.height / 2; size.width = size.width / 2; int y = screenSize.height - size.height; int x = screenSize.width - size.width; frame.setLocation(x, y); frame.setVisible(true); frame.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); }