List of usage examples for javax.swing Box createHorizontalGlue
public static Component createHorizontalGlue()
From source file:org.jajuk.ui.widgets.JajukJMenuBar.java
/** * Instantiates a new jajuk j menu bar.// w ww .j a va2 s . c o m */ private JajukJMenuBar() { setAlignmentX(0.0f); // File menu file = new JMenu(Messages.getString("JajukJMenuBar.0")); jmiFileExit = new JMenuItem(ActionManager.getAction(JajukActions.EXIT)); file.add(jmiFileExit); // Properties menu properties = new JMenu(Messages.getString("JajukJMenuBar.5")); jmiNewProperty = new JMenuItem(ActionManager.getAction(CUSTOM_PROPERTIES_ADD)); jmiRemoveProperty = new JMenuItem(ActionManager.getAction(CUSTOM_PROPERTIES_REMOVE)); jmiActivateTags = new JMenuItem(ActionManager.getAction(EXTRA_TAGS_WIZARD)); properties.add(jmiNewProperty); properties.add(jmiRemoveProperty); properties.add(jmiActivateTags); // View menu views = new JMenu(Messages.getString("JajukJMenuBar.8")); jmiRestoreDefaultViews = new JMenuItem(ActionManager.getAction(VIEW_RESTORE_DEFAULTS)); jmiRestoreDefaultViewsAllPerpsectives = new JMenuItem( ActionManager.getAction(JajukActions.ALL_VIEW_RESTORE_DEFAULTS)); views.add(jmiRestoreDefaultViews); views.add(jmiRestoreDefaultViewsAllPerpsectives); views.addSeparator(); // Add the list of available views parsed in XML files at startup JMenu jmViews = new JMenu(Messages.getString("JajukJMenuBar.25")); for (final Class<? extends IView> view : ViewFactory.getKnownViews()) { JMenuItem jmi = null; try { jmi = new JMenuItem(view.newInstance().getDesc(), IconLoader.getIcon(JajukIcons.LOGO_FRAME)); } catch (Exception e1) { Log.error(e1); continue; } jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // Simply add the new view in the current perspective PerspectiveAdapter current = (PerspectiveAdapter) PerspectiveManager.getCurrentPerspective(); IView newView = ViewFactory.createView(view, current, Math.abs(UtilSystem.getRandom().nextInt())); newView.initUI(); newView.setPopulated(); current.addDockable(newView); } }); jmViews.add(jmi); } views.add(jmViews); // Mode menu String modeText = Messages.getString("JajukJMenuBar.9"); mode = new JMenu(ActionUtil.strip(modeText)); jcbmiRepeat = new JCheckBoxMenuItem(ActionManager.getAction(REPEAT_MODE)); jcbmiRepeat.setSelected(Conf.getBoolean(Const.CONF_STATE_REPEAT)); jcbmiRepeatAll = new JCheckBoxMenuItem(ActionManager.getAction(REPEAT_ALL_MODE)); jcbmiRepeatAll.setSelected(Conf.getBoolean(Const.CONF_STATE_REPEAT_ALL)); jcbmiShuffle = new JCheckBoxMenuItem(ActionManager.getAction(SHUFFLE_MODE)); jcbmiShuffle.setSelected(Conf.getBoolean(Const.CONF_STATE_SHUFFLE)); jcbmiContinue = new JCheckBoxMenuItem(ActionManager.getAction(CONTINUE_MODE)); jcbmiContinue.setSelected(Conf.getBoolean(Const.CONF_STATE_CONTINUE)); jcbmiIntro = new JCheckBoxMenuItem(ActionManager.getAction(INTRO_MODE)); jcbmiIntro.setSelected(Conf.getBoolean(Const.CONF_STATE_INTRO)); jcbmiKaraoke = new JCheckBoxMenuItem(ActionManager.getAction(JajukActions.KARAOKE_MODE)); if (Conf.getBoolean(Const.CONF_BIT_PERFECT)) { jcbmiKaraoke.setEnabled(false); jcbmiKaraoke.setSelected(false); Conf.setProperty(Const.CONF_STATE_KARAOKE, Const.FALSE); } else { jcbmiKaraoke.setSelected(Conf.getBoolean(Const.CONF_STATE_KARAOKE)); } mode.add(jcbmiRepeat); mode.add(jcbmiRepeatAll); mode.add(jcbmiShuffle); mode.add(jcbmiContinue); mode.add(jcbmiIntro); mode.add(jcbmiKaraoke); // Smart Menu smart = new JMenu(Messages.getString("JajukJMenuBar.29")); jmiShuffle = new SizedJMenuItem(ActionManager.getAction(JajukActions.SHUFFLE_GLOBAL)); jmiBestof = new SizedJMenuItem(ActionManager.getAction(JajukActions.BEST_OF)); jmiNovelties = new SizedJMenuItem(ActionManager.getAction(JajukActions.NOVELTIES)); jmiFinishAlbum = new SizedJMenuItem(ActionManager.getAction(JajukActions.FINISH_ALBUM)); smart.add(jmiShuffle); smart.add(jmiBestof); smart.add(jmiNovelties); smart.add(jmiFinishAlbum); // Tools Menu tools = new JMenu(Messages.getString("JajukJMenuBar.28")); jmiduplicateFinder = new JMenuItem(ActionManager.getAction(JajukActions.FIND_DUPLICATE_FILES)); jmialarmClock = new JMenuItem(ActionManager.getAction(JajukActions.ALARM_CLOCK)); jmiprepareParty = new JMenuItem(ActionManager.getAction(JajukActions.PREPARE_PARTY)); tools.add(jmiduplicateFinder); tools.add(jmialarmClock); tools.add(jmiprepareParty); // tools.addSeparator(); // Configuration menu configuration = new JMenu(Messages.getString("JajukJMenuBar.21")); jmiDJ = new JMenuItem(ActionManager.getAction(CONFIGURE_DJS)); // Overwrite default icon jmiDJ.setIcon(IconLoader.getIcon(JajukIcons.DIGITAL_DJ_16X16)); jmiAmbience = new JMenuItem(ActionManager.getAction(CONFIGURE_AMBIENCES)); jmiWizard = new JMenuItem(ActionManager.getAction(SIMPLE_DEVICE_WIZARD)); jmiOptions = new JMenuItem(ActionManager.getAction(OPTIONS)); jmiUnmounted = new JCheckBoxMenuItem(ActionManager.getAction(JajukActions.UNMOUNTED)); jmiUnmounted.setSelected(Conf.getBoolean(Const.CONF_OPTIONS_HIDE_UNMOUNTED)); jmiUnmounted.putClientProperty(Const.DETAIL_ORIGIN, jmiUnmounted); jcbShowPopups = new JCheckBoxMenuItem(Messages.getString("ParameterView.228")); jcbShowPopups.setSelected(Conf.getBoolean(Const.CONF_SHOW_POPUPS)); jcbShowPopups.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Conf.setProperty(Const.CONF_SHOW_POPUPS, Boolean.toString(jcbShowPopups.isSelected())); // force parameter view to take this into account ObservationManager.notify(new JajukEvent(JajukEvents.PARAMETERS_CHANGE)); } }); jcbNoneInternetAccess = new JCheckBoxMenuItem(Messages.getString("ParameterView.264")); jcbNoneInternetAccess.setToolTipText(Messages.getString("ParameterView.265")); jcbNoneInternetAccess.setSelected(Conf.getBoolean(Const.CONF_NETWORK_NONE_INTERNET_ACCESS)); jcbNoneInternetAccess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Conf.setProperty(Const.CONF_NETWORK_NONE_INTERNET_ACCESS, Boolean.toString(jcbNoneInternetAccess.isSelected())); // force parameter view to take this into account ObservationManager.notify(new JajukEvent(JajukEvents.PARAMETERS_CHANGE)); } }); configuration.add(jmiUnmounted); configuration.add(jcbShowPopups); configuration.add(jcbNoneInternetAccess); configuration.addSeparator(); configuration.add(jmiDJ); configuration.add(jmiAmbience); configuration.add(jmiWizard); configuration.add(jmiOptions); // Help menu String helpText = Messages.getString("JajukJMenuBar.14"); help = new JMenu(ActionUtil.strip(helpText)); jmiHelp = new JMenuItem(ActionManager.getAction(HELP_REQUIRED)); jmiDonate = new JMenuItem(ActionManager.getAction(SHOW_DONATE)); jmiAbout = new JMenuItem(ActionManager.getAction(SHOW_ABOUT)); jmiTraces = new JMenuItem(ActionManager.getAction(SHOW_TRACES)); jmiTraces = new JMenuItem(ActionManager.getAction(SHOW_TRACES)); jmiCheckforUpdates = new JMenuItem(ActionManager.getAction(JajukActions.CHECK_FOR_UPDATES)); jmiTipOfTheDay = new JMenuItem(ActionManager.getAction(TIP_OF_THE_DAY)); help.add(jmiHelp); help.add(jmiTipOfTheDay); // Install this action only if Desktop class is supported, it is used to // open default mail client if (UtilSystem.isBrowserSupported()) { jmiQualityAgent = new JMenuItem(ActionManager.getAction(QUALITY)); help.add(jmiQualityAgent); } help.add(jmiTraces); help.add(jmiCheckforUpdates); help.add(jmiDonate); help.add(jmiAbout); mainmenu = new JMenuBar(); mainmenu.add(file); mainmenu.add(views); mainmenu.add(properties); mainmenu.add(mode); mainmenu.add(smart); mainmenu.add(tools); mainmenu.add(configuration); mainmenu.add(help); // Apply mnemonics (Alt + first char of the menu keystroke) applyMnemonics(); if (SessionService.isTestMode()) { jbGC = new JajukButton(ActionManager.getAction(JajukActions.GC)); } jbSlim = new JajukButton(ActionManager.getAction(JajukActions.SLIM_JAJUK)); jbFull = new JajukButton(ActionManager.getAction(JajukActions.FULLSCREEN_JAJUK)); JMenuBar eastmenu = new JMenuBar(); // only show GC-button in test-mode if (SessionService.isTestMode()) { eastmenu.add(jbGC); } eastmenu.add(jbSlim); eastmenu.add(jbFull); setLayout(new BorderLayout()); add(mainmenu, BorderLayout.WEST); add(eastmenu, BorderLayout.EAST); // Check for new release and display the icon if a new release is available SwingWorker<Void, Void> sw = new SwingWorker<Void, Void>() { @Override public Void doInBackground() { UpgradeManager.checkForUpdate(); return null; } @Override public void done() { // add the new release label if required if (UpgradeManager.getNewVersionName() != null) { jlUpdate = new JLabel(" ", IconLoader.getIcon(JajukIcons.UPDATE_MANAGER), SwingConstants.RIGHT); String newRelease = UpgradeManager.getNewVersionName(); if (newRelease != null) { jlUpdate.setToolTipText(Messages.getString("UpdateManager.0") + newRelease + Messages.getString("UpdateManager.1")); } add(Box.createHorizontalGlue()); add(jlUpdate); } } }; // Search online for upgrade if the option is set and if the none Internet // access option is not set if (Conf.getBoolean(Const.CONF_CHECK_FOR_UPDATE) && !Conf.getBoolean(Const.CONF_NETWORK_NONE_INTERNET_ACCESS)) { sw.execute(); } ObservationManager.register(this); }
From source file:org.rimudb.editor.RimuDBEditor.java
/** * Create and return a toolbar.//from w ww .j a va 2 s . c o m */ protected JToolBar createToolbar() { log.debug("createToolbar()"); JToolBar toolbar = new JToolBar(); // Open openBtn = new ToolbarButton(new OpenDescriptorAction(this, loadIcon("/images/famfamfam/folder.png")), "Open Table Descriptor"); openBtn.setText("Open"); openBtn.setName("openBtn"); toolbar.add(openBtn); // Save saveBtn = new ToolbarButton(new SaveDescriptorAction(this, loadIcon("/images/famfamfam/disk.png")), "Save Table Descriptor"); saveBtn.setText("Save"); saveBtn.setName("saveBtn"); toolbar.add(saveBtn); // A space // toolbar.add(Box.createHorizontalStrut(5)); // Clear clearBtn = new ToolbarButton(new ClearTableAction(this, loadIcon("/images/famfamfam/bin_closed.png")), "Clear"); clearBtn.setText("Clear"); clearBtn.setName("clearBtn"); toolbar.add(clearBtn); // Save as // saveAsBtn = new ToolbarButton(new SaveAsDescriptorAction(this, loadIcon("/images/sun/SaveAs24.gif")), "Save Table Descriptor as"); // saveAsBtn.setName("saveAsBtn"); // toolbar.add(saveAsBtn); // A space toolbar.addSeparator(); // Import from a database importBtn = new ToolbarButton(new ImportAction(this, loadIcon("/images/famfamfam/database_go.png")), "Import from database"); importBtn.setText("Import"); importBtn.setName("importBtn"); importBtn.setEnabled(false); toolbar.add(importBtn); // A space toolbar.add(Box.createHorizontalStrut(5)); // Create classes createBtn = new ToolbarButton( new GenerateJavaAction(this, loadIcon("/images/famfamfam/page_white_cup.png")), "Create classes"); createBtn.setText("Create"); createBtn.setName("createBtn"); toolbar.add(createBtn); // Finish up the tool bar toolbar.add(Box.createHorizontalGlue()); toolbar.setFloatable(false); return toolbar; }
From source file:es.emergya.ui.gis.CustomMapView.java
@Override public void addLayer(Layer layer, boolean showOnButtonList, String icon) { if (layer instanceof MapViewerLayer) { minZoom = Math.max(((MapViewerLayer) layer).getMinZoomLevel(), getMinZoom()); maxZoom = Math.min(((MapViewerLayer) layer).getMaxZoomLevel(), getMaxZoom()); if (zoomFactor > maxZoom || zoomFactor < minZoom) { zoomFactor = (maxZoom + minZoom) / 2; }//from w ww .j av a 2 s . c om zoomTo(center, zoom2Scale(zoomFactor)); } if (showOnButtonList) { JToggleButton b = new JToggleButton(layer.name, LogicConstants.getIcon(icon), layer.visible); // b.setVerticalTextPosition(SwingConstants.BOTTOM); // b.setHorizontalTextPosition(SwingConstants.CENTER); b.setActionCommand(layer.name); b.addActionListener(layerControlListener); layerControls.add(b); layerControlPanel.removeAll(); layerControlPanel.add(Box.createHorizontalStrut(10)); for (JToggleButton bt : layerControls) { layerControlPanel.add(bt); layerControlPanel.add(Box.createHorizontalGlue()); } layerControlPanel.updateUI(); } super.addLayer(layer); }
From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java
private JPanel createLocationsPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 0.5;//from www. j ava 2s . c o m JPanel folderPanel = new JPanel(); folderPanel.setLayout(new BoxLayout(folderPanel, BoxLayout.X_AXIS)); folderPanel.setBorder(BorderFactory.createTitledBorder("Working folder")); folderField = new JTextField(); folderField.setText((new File("").getAbsolutePath())); folderField.setToolTipText("The folder where all output will be written"); folderPanel.add(folderField); JButton pickButton = new JButton("Pick folder"); pickButton.setToolTipText("Pick a different working folder"); folderPanel.add(pickButton); pickButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pickFolder(); } }); componentsToDisableWhenRunning.add(pickButton); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; panel.add(folderPanel, c); JPanel sourcePanel = new JPanel(); sourcePanel.setLayout(new GridLayout(0, 2)); sourcePanel.setBorder(BorderFactory.createTitledBorder("Source data location")); sourcePanel.add(new JLabel("Data type")); sourceType = new JComboBox<String>(new String[] { "Delimited text files", "MySQL", "Oracle", "SQL Server", "PostgreSQL", "MS Access", "PDW", "Redshift", "Teradata" }); sourceType.setToolTipText("Select the type of source data available"); sourceType.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent arg0) { sourceIsFiles = arg0.getItem().toString().equals("Delimited text files"); sourceServerField.setEnabled(!sourceIsFiles); sourceUserField.setEnabled(!sourceIsFiles); sourcePasswordField.setEnabled(!sourceIsFiles); sourceDatabaseField.setEnabled(!sourceIsFiles); sourceDelimiterField.setEnabled(sourceIsFiles); addAllButton.setEnabled(!sourceIsFiles); if (!sourceIsFiles && arg0.getItem().toString().equals("Oracle")) { sourceServerField.setToolTipText( "For Oracle servers this field contains the SID, servicename, and optionally the port: '<host>/<sid>', '<host>:<port>/<sid>', '<host>/<service name>', or '<host>:<port>/<service name>'"); sourceUserField.setToolTipText( "For Oracle servers this field contains the name of the user used to log in"); sourcePasswordField.setToolTipText( "For Oracle servers this field contains the password corresponding to the user"); sourceDatabaseField.setToolTipText( "For Oracle servers this field contains the schema (i.e. 'user' in Oracle terms) containing the source tables"); } else if (!sourceIsFiles && arg0.getItem().toString().equals("PostgreSQL")) { sourceServerField.setToolTipText( "For PostgreSQL servers this field contains the host name and database name (<host>/<database>)"); sourceUserField.setToolTipText("The user used to log in to the server"); sourcePasswordField.setToolTipText("The password used to log in to the server"); sourceDatabaseField.setToolTipText( "For PostgreSQL servers this field contains the schema containing the source tables"); } else if (!sourceIsFiles) { sourceServerField .setToolTipText("This field contains the name or IP address of the database server"); if (arg0.getItem().toString().equals("SQL Server")) sourceUserField.setToolTipText( "The user used to log in to the server. Optionally, the domain can be specified as <domain>/<user> (e.g. 'MyDomain/Joe')"); else sourceUserField.setToolTipText("The user used to log in to the server"); sourcePasswordField.setToolTipText("The password used to log in to the server"); sourceDatabaseField.setToolTipText("The name of the database containing the source tables"); } } }); sourcePanel.add(sourceType); sourcePanel.add(new JLabel("Server location")); sourceServerField = new JTextField("127.0.0.1"); sourceServerField.setEnabled(false); sourcePanel.add(sourceServerField); sourcePanel.add(new JLabel("User name")); sourceUserField = new JTextField(""); sourceUserField.setEnabled(false); sourcePanel.add(sourceUserField); sourcePanel.add(new JLabel("Password")); sourcePasswordField = new JPasswordField(""); sourcePasswordField.setEnabled(false); sourcePanel.add(sourcePasswordField); sourcePanel.add(new JLabel("Database name")); sourceDatabaseField = new JTextField(""); sourceDatabaseField.setEnabled(false); sourcePanel.add(sourceDatabaseField); sourcePanel.add(new JLabel("Delimiter")); sourceDelimiterField = new JTextField(","); sourceDelimiterField.setToolTipText("The delimiter that separates values. Enter 'tab' for tab."); sourcePanel.add(sourceDelimiterField); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; panel.add(sourcePanel, c); JPanel testConnectionButtonPanel = new JPanel(); testConnectionButtonPanel.setLayout(new BoxLayout(testConnectionButtonPanel, BoxLayout.X_AXIS)); testConnectionButtonPanel.add(Box.createHorizontalGlue()); JButton testConnectionButton = new JButton("Test connection"); testConnectionButton.setBackground(new Color(151, 220, 141)); testConnectionButton.setToolTipText("Test the connection"); testConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { testConnection(getSourceDbSettings()); } }); componentsToDisableWhenRunning.add(testConnectionButton); testConnectionButtonPanel.add(testConnectionButton); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; panel.add(testConnectionButtonPanel, c); return panel; }
From source file:com.diversityarrays.kdxplore.trials.SampleGroupExportDialog.java
public SampleGroupExportDialog(Window owner, String title, Trial trial, KdxploreDatabase kdxploreDatabase, DeviceType deviceType, DeviceIdentifier devid, SampleGroup sampleGroup, Set<Integer> excludeTheseTraitIds, Map<Integer, Trait> allTraitIds, Set<Integer> excludeThesePlotIds) { super(owner, title, ModalityType.APPLICATION_MODAL); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setGlassPane(backgroundRunner.getBlockingPane()); this.allTraits = allTraitIds; this.trial = trial; this.kdxploreDatabase = kdxploreDatabase; this.sampleGroup = sampleGroup; this.excludeTheseTraitIds = excludeTheseTraitIds; this.excludeThesePlotIds = excludeThesePlotIds; String deviceName = devid == null ? "Unknown_" + deviceType.name() : devid.getDeviceName(); if (DeviceType.FOR_SCORING.equals(deviceType)) { if (!Check.isEmpty(sampleGroup.getOperatorName())) { deviceName = sampleGroup.getOperatorName(); }/*from ww w .j a v a2s . c o m*/ } File directory = KdxplorePreferences.getInstance().getOutputDirectory(); if (directory == null) { directory = new File(System.getProperty("user.home")); } String filename = Util.getTimestampedOutputFileName(trial.getTrialName(), deviceName); File outfile = new File(directory, filename); filepathText.setText(outfile.getPath()); filepathText.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { updateButtons(); } @Override public void insertUpdate(DocumentEvent e) { updateButtons(); } @Override public void changedUpdate(DocumentEvent e) { updateButtons(); } }); updateButtons(); boolean developer = RunMode.getRunMode().isDeveloper(); oldKdsmartOption.setForeground(Color.BLUE); oldKdsmartOption.setToolTipText("For ElapsedDays value compatiblity with older versions of KDSmart"); Box exportForOptionsBox = Box.createHorizontalBox(); for (JComponent comp : exportForOptions) { if (developer || comp != oldKdsmartOption) { exportForOptionsBox.add(comp); } } Map<JRadioButton, OutputOption> optionByRb = new HashMap<>(); ActionListener rbListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectedOutputOption = optionByRb.get(e.getSource()); boolean enb = selectedOutputOption.exportFor != null; for (JComponent comp : exportForOptions) { if (comp == wantMediaFilesOption) { comp.setEnabled(enb && selectedOutputOption.supportsMediaFiles()); } else if (comp == kdsmartVersion3option) { comp.setEnabled(enb && selectedOutputOption.usesWorkPackage()); } else { comp.setEnabled(enb); } } } }; boolean anySamplesForIndividuals = true; try { anySamplesForIndividuals = kdxploreDatabase.getAnySamplesForIndividuals(sampleGroup); } catch (IOException e) { Shared.Log.w("SampleGroupExportDialog", "getAnySamplesForIndividuals", e); } ButtonGroup bg = new ButtonGroup(); Box radioButtons = Box.createHorizontalBox(); List<OutputOption> options = new ArrayList<>(); Collections.addAll(options, OutputOption.values()); if (!anySamplesForIndividuals) { // No relevant samples so don't bother offering the option. options.remove(OutputOption.CSV_FULL); } for (OutputOption oo : options) { if (!developer && OutputOption.JSON == oo) { continue; } JRadioButton rb = new JRadioButton(oo.displayName); if (OutputOption.KDX == oo) { kdxExportButton = rb; } if (OutputOption.ZIP == oo) { zipExportButton = rb; } rb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { exportExclusionBox.selectAndDeactivateButtons( kdxExportButton.isSelected() || zipExportButton.isSelected()); } }); if (OutputOption.JSON == oo) { rb.setForeground(Color.BLUE); rb.setToolTipText("Developer Only"); } bg.add(rb); optionByRb.put(rb, oo); radioButtons.add(rb); rb.addActionListener(rbListener); if (bg.getButtonCount() == 1) { rb.doClick(); } } Box additionalOptionsBox = Box.createHorizontalBox(); additionalOptionsBox.add(this.wantMediaFilesOption); additionalOptionsBox.add(this.kdsmartVersion3option); dbVersionLabel.setToolTipText(TTT_DATABASE_VERSION_FOR_EXPORT); databaseVersionChoices.setToolTipText(TTT_DATABASE_VERSION_FOR_EXPORT); JPanel panel = new JPanel(); GBH gbh = new GBH(panel); int y = 0; gbh.add(0, y, 1, 1, GBH.NONE, 0, 1, GBH.EAST, "Output File:"); gbh.add(1, y, 1, 1, GBH.HORZ, 1, 1, GBH.CENTER, filepathText); gbh.add(2, y, 1, 1, GBH.NONE, 1, 1, GBH.WEST, new JButton(browseFileAction)); ++y; gbh.add(0, y, 1, 1, GBH.NONE, 0, 1, GBH.EAST, "Options:"); gbh.add(1, y, 2, 1, GBH.HORZ, 1, 1, GBH.CENTER, radioButtons); ++y; gbh.add(0, y, 3, 1, GBH.HORZ, 1, 1, GBH.CENTER, exportExclusionBox); ++y; gbh.add(0, y, 3, 1, GBH.HORZ, 1, 1, GBH.CENTER, additionalOptionsBox); ++y; gbh.add(0, y, 1, 1, GBH.NONE, 0, 1, GBH.EAST, dbVersionLabel); gbh.add(1, y, 2, 1, GBH.HORZ, 1, 1, GBH.CENTER, BoxBuilder.horizontal().add(databaseVersionChoices).get()); gbh.add(1, y, 2, 1, GBH.HORZ, 1, 1, GBH.CENTER, exportForOptionsBox); ++y; Box buttons = Box.createHorizontalBox(); buttons.add(Box.createHorizontalGlue()); buttons.add(new JButton(cancelAction)); buttons.add(new JButton(exportAction)); buttons.add(new JButton(exportAndCloseAction)); Container cp = getContentPane(); cp.add(panel, BorderLayout.CENTER); cp.add(buttons, BorderLayout.SOUTH); pack(); }
From source file:com.net2plan.gui.utils.topologyPane.TopologyPanel.java
/** * Default constructor./*from w w w . ja v a 2s.c om*/ * * @param callback Topology callback listening plugin events * @param defaultDesignDirectory Default location for design {@code .n2p} files (it may be null, then default is equal to {@code net2planFolder/workspace/data/networkTopologies}) * @param defaultDemandDirectory Default location for design {@code .n2p} files (it may be null, then default is equal to {@code net2planFolder/workspace/data/trafficMatrices}) * @param canvasType Canvas type (i.e. JUNG) * @param plugins List of plugins to be included (it may be null) */ public TopologyPanel(final IVisualizationCallback callback, File defaultDesignDirectory, File defaultDemandDirectory, Class<? extends ITopologyCanvas> canvasType, List<ITopologyCanvasPlugin> plugins) { File currentDir = SystemUtils.getCurrentDir(); this.callback = callback; this.defaultDesignDirectory = defaultDesignDirectory == null ? new File( currentDir + SystemUtils.getDirectorySeparator() + "workspace" + SystemUtils.getDirectorySeparator() + "data" + SystemUtils.getDirectorySeparator() + "networkTopologies") : defaultDesignDirectory; this.defaultDemandDirectory = defaultDemandDirectory == null ? new File( currentDir + SystemUtils.getDirectorySeparator() + "workspace" + SystemUtils.getDirectorySeparator() + "data" + SystemUtils.getDirectorySeparator() + "trafficMatrices") : defaultDemandDirectory; this.multilayerControlPanel = new MultiLayerControlPanel(callback); try { canvas = canvasType.getDeclaredConstructor(IVisualizationCallback.class, TopologyPanel.class) .newInstance(callback, this); } catch (Exception e) { throw new RuntimeException(e); } if (plugins != null) for (ITopologyCanvasPlugin plugin : plugins) addPlugin(plugin); setLayout(new BorderLayout()); JToolBar toolbar = new JToolBar(); toolbar.setRollover(true); toolbar.setFloatable(false); toolbar.setOpaque(false); toolbar.setBorderPainted(false); JPanel topPanel = new JPanel(new BorderLayout()); topPanel.add(toolbar, BorderLayout.NORTH); add(topPanel, BorderLayout.NORTH); JComponent canvasComponent = canvas.getCanvasComponent(); canvasPanel = new JPanel(new BorderLayout()); canvasComponent.setBorder(LineBorder.createBlackLineBorder()); JToolBar multiLayerToolbar = new JToolBar(JToolBar.VERTICAL); multiLayerToolbar.setRollover(true); multiLayerToolbar.setFloatable(false); multiLayerToolbar.setOpaque(false); canvasPanel.add(canvasComponent, BorderLayout.CENTER); canvasPanel.add(multiLayerToolbar, BorderLayout.WEST); add(canvasPanel, BorderLayout.CENTER); btn_load = new JButton(); btn_load.setToolTipText("Load a network design"); btn_loadDemand = new JButton(); btn_loadDemand.setToolTipText("Load a traffic demand set"); btn_save = new JButton(); btn_save.setToolTipText("Save current state to a file"); btn_zoomIn = new JButton(); btn_zoomIn.setToolTipText("Zoom in"); btn_zoomOut = new JButton(); btn_zoomOut.setToolTipText("Zoom out"); btn_zoomAll = new JButton(); btn_zoomAll.setToolTipText("Zoom all"); btn_takeSnapshot = new JButton(); btn_takeSnapshot.setToolTipText("Take a snapshot of the canvas"); btn_showNodeNames = new JToggleButton(); btn_showNodeNames.setToolTipText("Show/hide node names"); btn_showLinkIds = new JToggleButton(); btn_showLinkIds.setToolTipText( "Show/hide link utilization, measured as the ratio between the total traffic in the link (including that in protection segments) and total link capacity (including that reserved by protection segments)"); btn_showNonConnectedNodes = new JToggleButton(); btn_showNonConnectedNodes.setToolTipText("Show/hide non-connected nodes"); btn_increaseNodeSize = new JButton(); btn_increaseNodeSize.setToolTipText("Increase node size"); btn_decreaseNodeSize = new JButton(); btn_decreaseNodeSize.setToolTipText("Decrease node size"); btn_increaseFontSize = new JButton(); btn_increaseFontSize.setToolTipText("Increase font size"); btn_decreaseFontSize = new JButton(); btn_decreaseFontSize.setToolTipText("Decrease font size"); /* Multilayer buttons */ btn_increaseInterLayerDistance = new JButton(); btn_increaseInterLayerDistance .setToolTipText("Increase the distance between layers (when more than one layer is visible)"); btn_decreaseInterLayerDistance = new JButton(); btn_decreaseInterLayerDistance .setToolTipText("Decrease the distance between layers (when more than one layer is visible)"); btn_showLowerLayerInfo = new JToggleButton(); btn_showLowerLayerInfo .setToolTipText("Shows the links in lower layers that carry traffic of the picked element"); btn_showLowerLayerInfo.setSelected(getVisualizationState().isShowInCanvasLowerLayerPropagation()); btn_showUpperLayerInfo = new JToggleButton(); btn_showUpperLayerInfo.setToolTipText( "Shows the links in upper layers that carry traffic that appears in the picked element"); btn_showUpperLayerInfo.setSelected(getVisualizationState().isShowInCanvasUpperLayerPropagation()); btn_showThisLayerInfo = new JToggleButton(); btn_showThisLayerInfo.setToolTipText( "Shows the links in the same layer as the picked element, that carry traffic that appears in the picked element"); btn_showThisLayerInfo.setSelected(getVisualizationState().isShowInCanvasThisLayerPropagation()); btn_npChangeUndo = new JButton(); btn_npChangeUndo.setToolTipText( "Navigate back to the previous state of the network (last time the network design was changed)"); btn_npChangeRedo = new JButton(); btn_npChangeRedo.setToolTipText( "Navigate forward to the next state of the network (when network design was changed"); btn_osmMap = new JToggleButton(); btn_osmMap.setToolTipText( "Toggle between on/off the OSM support. An internet connection is required in order for this to work."); btn_tableControlWindow = new JButton(); btn_tableControlWindow.setToolTipText("Show the network topology control window."); // MultiLayer control window JPopupMenu multiLayerPopUp = new JPopupMenu(); multiLayerPopUp.add(multilayerControlPanel); JPopUpButton btn_multilayer = new JPopUpButton("", multiLayerPopUp); btn_reset = new JButton("Reset"); btn_reset.setToolTipText("Reset the user interface"); btn_reset.setMnemonic(KeyEvent.VK_R); btn_load.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/loadDesign.png"))); btn_loadDemand.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/loadDemand.png"))); btn_save.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/saveDesign.png"))); btn_showNodeNames .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNodeName.png"))); btn_showLinkIds .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLinkUtilization.png"))); btn_showNonConnectedNodes.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNonConnectedNodes.png"))); //btn_whatIfActivated.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNonConnectedNodes.png"))); btn_zoomIn.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomIn.png"))); btn_zoomOut.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomOut.png"))); btn_zoomAll.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomAll.png"))); btn_takeSnapshot.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/takeSnapshot.png"))); btn_increaseNodeSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseNode.png"))); btn_decreaseNodeSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseNode.png"))); btn_increaseFontSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseFont.png"))); btn_decreaseFontSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseFont.png"))); btn_increaseInterLayerDistance.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseLayerDistance.png"))); btn_decreaseInterLayerDistance.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseLayerDistance.png"))); btn_multilayer .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerControl.png"))); btn_showThisLayerInfo .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerPropagation.png"))); btn_showUpperLayerInfo.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerUpperPropagation.png"))); btn_showLowerLayerInfo.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerLowerPropagation.png"))); btn_tableControlWindow .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showControl.png"))); btn_osmMap.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showOSM.png"))); btn_npChangeUndo.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/undoButton.png"))); btn_npChangeRedo.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/redoButton.png"))); btn_load.addActionListener(this); btn_loadDemand.addActionListener(this); btn_save.addActionListener(this); btn_showNodeNames.addActionListener(this); btn_showLinkIds.addActionListener(this); btn_showNonConnectedNodes.addActionListener(this); btn_zoomIn.addActionListener(this); btn_zoomOut.addActionListener(this); btn_zoomAll.addActionListener(this); btn_takeSnapshot.addActionListener(this); btn_reset.addActionListener(this); btn_increaseInterLayerDistance.addActionListener(this); btn_decreaseInterLayerDistance.addActionListener(this); btn_showLowerLayerInfo.addActionListener(this); btn_showUpperLayerInfo.addActionListener(this); btn_showThisLayerInfo.addActionListener(this); btn_increaseNodeSize.addActionListener(this); btn_decreaseNodeSize.addActionListener(this); btn_increaseFontSize.addActionListener(this); btn_decreaseFontSize.addActionListener(this); btn_npChangeUndo.addActionListener(this); btn_npChangeRedo.addActionListener(this); btn_osmMap.addActionListener(this); btn_tableControlWindow.addActionListener(this); toolbar.add(btn_load); toolbar.add(btn_loadDemand); toolbar.add(btn_save); toolbar.add(new JToolBar.Separator()); toolbar.add(btn_zoomIn); toolbar.add(btn_zoomOut); toolbar.add(btn_zoomAll); toolbar.add(btn_takeSnapshot); toolbar.add(new JToolBar.Separator()); toolbar.add(btn_showNodeNames); toolbar.add(btn_showLinkIds); toolbar.add(btn_showNonConnectedNodes); toolbar.add(new JToolBar.Separator()); toolbar.add(btn_increaseNodeSize); toolbar.add(btn_decreaseNodeSize); toolbar.add(btn_increaseFontSize); toolbar.add(btn_decreaseFontSize); toolbar.add(new JToolBar.Separator()); toolbar.add(Box.createHorizontalGlue()); toolbar.add(btn_osmMap); toolbar.add(btn_tableControlWindow); toolbar.add(btn_reset); multiLayerToolbar.add(new JToolBar.Separator()); multiLayerToolbar.add(btn_multilayer); multiLayerToolbar.add(btn_increaseInterLayerDistance); multiLayerToolbar.add(btn_decreaseInterLayerDistance); multiLayerToolbar.add(btn_showLowerLayerInfo); multiLayerToolbar.add(btn_showUpperLayerInfo); multiLayerToolbar.add(btn_showThisLayerInfo); multiLayerToolbar.add(Box.createVerticalGlue()); multiLayerToolbar.add(btn_npChangeUndo); multiLayerToolbar.add(btn_npChangeRedo); this.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { if (e.getComponent().getSize().getHeight() != 0 && e.getComponent().getSize().getWidth() != 0) { canvas.zoomAll(); } } }); List<Component> children = SwingUtils.getAllComponents(this); for (Component component : children) if (component instanceof AbstractButton) component.setFocusable(false); if (ErrorHandling.isDebugEnabled()) { canvas.getCanvasComponent().addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { Point point = e.getPoint(); position.setText("view = " + point + ", NetPlan coord = " + canvas.getCanvasPointFromNetPlanPoint(point)); } }); position = new JLabel(); add(position, BorderLayout.SOUTH); } else { position = null; } new FileDrop(canvasComponent, new LineBorder(Color.BLACK), new FileDrop.Listener() { @Override public void filesDropped(File[] files) { for (File file : files) { try { if (!file.getName().toLowerCase(Locale.getDefault()).endsWith(".n2p")) return; loadDesignFromFile(file); break; } catch (Throwable e) { break; } } } }); btn_showNodeNames.setSelected(getVisualizationState().isCanvasShowNodeNames()); btn_showLinkIds.setSelected(getVisualizationState().isCanvasShowLinkLabels()); btn_showNonConnectedNodes.setSelected(getVisualizationState().isCanvasShowNonConnectedNodes()); final ITopologyCanvasPlugin popupPlugin = new PopupMenuPlugin(callback, this.canvas); addPlugin(new PanGraphPlugin(callback, canvas, MouseEvent.BUTTON1_MASK)); if (callback.getVisualizationState().isNetPlanEditable() && getCanvas() instanceof JUNGCanvas) addPlugin(new AddLinkGraphPlugin(callback, canvas, MouseEvent.BUTTON1_MASK, MouseEvent.BUTTON1_MASK | MouseEvent.SHIFT_MASK)); addPlugin(popupPlugin); if (callback.getVisualizationState().isNetPlanEditable()) addPlugin(new MoveNodePlugin(callback, canvas, MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK)); setBorder(BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "Network topology")); // setAllowLoadTrafficDemand(callback.allowLoadTrafficDemands()); }
From source file:com.intuit.tank.proxy.ProxyApp.java
private JToolBar createToolBar() { JToolBar ret = new JToolBar(); // ret.setBackground(new Color(111,167,209)); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(openAction));//from w ww. j av a2s . c o m ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(saveAction)); ret.addSeparator(); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(startAction)); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(stopAction)); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(pauseAction)); ret.add(Box.createHorizontalStrut(5)); ret.addSeparator(); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(filterAction)); ret.add(createButton(settingsAction)); ret.addSeparator(); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(showHostsAction)); ret.add(Box.createHorizontalGlue()); return ret; }
From source file:com.diversityarrays.kdxplore.trials.AddScoringSetDialog.java
public AddScoringSetDialog(Window owner, KdxploreDatabase kdxdb, Trial trial, Map<Trait, List<TraitInstance>> instancesByTrait, SampleGroup curatedSampleGroup) { super(owner, Msg.TITLE_ADD_SCORING_SET(), ModalityType.APPLICATION_MODAL); setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.kdxploreDatabase = kdxdb; this.trial = trial; this.curatedSampleGroupId = curatedSampleGroup == null ? 0 : curatedSampleGroup.getSampleGroupId(); Map<Trait, List<TraitInstance>> noCalcs = instancesByTrait.entrySet().stream() .filter(e -> TraitDataType.CALC != e.getKey().getTraitDataType()) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); Map<Trait, List<TraitInstance>> noCalcsSorted = new TreeMap<>(TRAIT_COMPARATOR); noCalcsSorted.putAll(noCalcs);/*from w ww. j av a 2 s . co m*/ BiFunction<Trait, TraitInstance, String> parentNameProvider = new BiFunction<Trait, TraitInstance, String>() { @Override public String apply(Trait t, TraitInstance ti) { if (ti == null) { List<TraitInstance> list = noCalcsSorted.get(t); if (list == null || list.size() != 1) { OptionalInt opt = traitInstanceChoiceTreeModel.getChildChosenCountIfNotAllChosen(t); StringBuilder sb = new StringBuilder(t.getTraitName()); if (opt.isPresent()) { // only some of the children are chosen int childChosenCount = opt.getAsInt(); if (childChosenCount > 0) { sb.append(" (").append(childChosenCount).append(" of ").append(list.size()) .append(")"); } } else { // all of the children are chosen if (list != null) { sb.append(" (").append(list.size()).append(")"); } } return sb.toString(); } } return t.getTraitName(); } }; Optional<List<TraitInstance>> opt = noCalcsSorted.values().stream().filter(list -> list.size() > 1) .findFirst(); String heading1 = opt.isPresent() ? "Trait/Instance" : "Trait"; traitInstanceChoiceTreeModel = new ChoiceTreeTableModel<>(heading1, "Use?", //$NON-NLS-1$ noCalcsSorted, parentNameProvider, childNameProvider); // traitInstanceChoiceTreeModel = new TTChoiceTreeTableModel(instancesByTrait); traitInstanceChoiceTreeModel.addChoiceChangedListener(new ChoiceChangedListener() { @Override public void choiceChanged(Object source, ChoiceNode[] changedNodes) { updateCreateAction("choiceChanged"); treeTable.repaint(); } }); traitInstanceChoiceTreeModel.addTreeModelListener(new TreeModelListener() { @Override public void treeStructureChanged(TreeModelEvent e) { } @Override public void treeNodesRemoved(TreeModelEvent e) { } @Override public void treeNodesInserted(TreeModelEvent e) { } @Override public void treeNodesChanged(TreeModelEvent e) { updateCreateAction("treeNodesChanged"); } }); warningMsg.setText(PLEASE_PROVIDE_A_DESCRIPTION); warningMsg.setForeground(Color.RED); Container cp = getContentPane(); Box sampleButtons = null; if (curatedSampleGroup != null && curatedSampleGroup.getAnyScoredSamples()) { sampleButtons = createWantSampleButtons(curatedSampleGroup); } Box top = Box.createVerticalBox(); if (sampleButtons == null) { top.add(new JLabel(Msg.MSG_THERE_ARE_NO_CURATED_SAMPLES())); } else { top.add(sampleButtons); } top.add(descriptionField); cp.add(top, BorderLayout.NORTH); descriptionField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { updateCreateAction("documentListener"); } @Override public void insertUpdate(DocumentEvent e) { updateCreateAction("documentListener"); } @Override public void changedUpdate(DocumentEvent e) { updateCreateAction("documentListener"); } }); updateCreateAction("init"); // KDClientUtils.initAction(ImageId.`CHECK_ALL, useAllAction, "Click to Use All"); treeTable = new JXTreeTable(traitInstanceChoiceTreeModel); treeTable.setAutoResizeMode(JXTreeTable.AUTO_RESIZE_ALL_COLUMNS); TableCellRenderer renderer = treeTable.getDefaultRenderer(Integer.class); if (renderer instanceof JLabel) { ((JLabel) renderer).setHorizontalAlignment(JLabel.CENTER); } Box buttons = Box.createHorizontalBox(); buttons.add(new JButton(useAllAction)); buttons.add(new JButton(useNoneAction)); buttons.add(Box.createHorizontalGlue()); buttons.add(warningMsg); buttons.add(new JButton(cancelAction)); buttons.add(Box.createHorizontalStrut(10)); buttons.add(new JButton(createAction)); cp.add(new JScrollPane(treeTable), BorderLayout.CENTER); cp.add(buttons, BorderLayout.SOUTH); pack(); }
From source file:medsavant.uhn.cancer.UserCommentApp.java
@Override public void setVariantRecord(final VariantRecord variantRecord) { try {//from w w w . j a v a2s .c o m //Get comment group associated with this variant. UserCommentGroup lcg = MedSavantClient.VariantManager.getUserCommentGroup( LoginController.getSessionID(), ProjectController.getInstance().getCurrentProjectID(), ReferenceController.getInstance().getCurrentReferenceID(), variantRecord); boolean hasComments = false; JPanel innerPanel = null; if (lcg != null) { //Build a mapping from ontology terms to all comments pertaining to that ontology term. //Iterating through this map will return the ontology terms in alphabetical order, and the comments //within each ontology will be ordered by their insertion id. Map<OntologyTerm, Collection<UserComment>> otCommentMap = new TreeMap<OntologyTerm, Collection<UserComment>>(); for (Iterator<UserComment> li = lcg.iterator(); li.hasNext();) { UserComment lc = li.next(); Collection<UserComment> ontologyComments = otCommentMap.get(lc.getOntologyTerm()); if (ontologyComments == null) { ontologyComments = new ArrayList<UserComment>(); hasComments = true; } ontologyComments.add(lc); otCommentMap.put(lc.getOntologyTerm(), ontologyComments); } if (hasComments) { innerPanel = getMainCommentPanel(otCommentMap, lcg, variantRecord); } } if (innerPanel == null) { innerPanel = getNoCommentsPanel(); } JButton newCommentButton = new JButton("New Comment"); newCommentButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { newComment(variantRecord); } }); JPanel cp = new JPanel(); cp.setLayout(new BoxLayout(cp, BoxLayout.X_AXIS)); cp.add(Box.createHorizontalGlue()); if (roleManager.checkRole(GENETIC_COUNSELLOR_ROLENAME) || roleManager.checkRole(RESIDENT_ROLENAME)) { cp.add(newCommentButton); } cp.add(Box.createHorizontalGlue()); innerPanel.add(cp); final JScrollPane jsp = new JScrollPane(innerPanel); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { panel.removeAll(); panel.add(jsp); panel.revalidate(); panel.repaint(); } }); } catch (SessionExpiredException see) { LOG.error(see.getMessage(), see); } catch (SQLException sqe) { LOG.error(sqe.getMessage(), sqe); } catch (RemoteException rex) { LOG.error(rex.getMessage(), rex); } }
From source file:com.diversityarrays.kdxplore.trials.TrialSelectionDialog.java
@SuppressWarnings("rawtypes") @Override// ww w. j a va 2 s. com protected Component createMainPanel() { CheckSelectionButtonsPanel csbp = new CheckSelectionButtonsPanel(CheckSelectionButtonsPanel.ALL, trialRecordTable); csbp.addUncheckAllActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { trialRecordTableModel.clearChosen(); } }); csbp.addCheckAllActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { trialRecordTableModel.chooseAll(); } }); csbp.addCheckSelectedActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { List<Integer> selectedModelRows = GuiUtil.getSelectedModelRows(trialRecordTable); trialRecordTableModel.addChosenRows(selectedModelRows); } }); csbp.addCheckUnselectedActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Set<Integer> selectedModelRows = new HashSet<>(GuiUtil.getSelectedModelRows(trialRecordTable)); if (selectedModelRows.isEmpty()) { trialRecordTableModel.chooseAll(); } else { List<Integer> rowsToChoose = new ArrayList<>(); for (int mrow = trialRecordTable.getRowCount(); --mrow >= 0;) { if (!selectedModelRows.contains(mrow)) { rowsToChoose.add(mrow); } } trialRecordTableModel.addChosenRows(rowsToChoose); } } }); Box buttons = Box.createHorizontalBox(); buttons.add(Box.createHorizontalGlue()); buttons.add(new JLabel("Select one or more and click '" + USE_TRIALS + "'")); buttons.add(csbp); buttons.add(Box.createHorizontalGlue()); List<TableColumn> columns = DartEntityTableModel.collectNamedColumns(trialRecordTable, trialRecordTableModel, true, "TrialName", "Site", "# Plots", "# Measurements", "Design", "Manager", "TrialType", "Project", "Start Date"); // List<TableColumn> columns = DartEntityTableModel.collectNonExpertColumns(trialRecordTable, trialRecordTableModel, true); Map<String, TableColumn[]> choices = new HashMap<>(); choices.put(INITIAL_COLUMNS_TAGNAME, columns.toArray(new TableColumn[columns.size()])); TableColumnSelectionButton tcsb = new TableColumnSelectionButton(trialRecordTable, choices); tcsb.setSelectedColumns(INITIAL_COLUMNS_TAGNAME); trialRecordTable.setRowSorter(new TableRowSorter<DartEntityTableModel>(trialRecordTableModel)); JScrollPane scrollPane = new JScrollPane(trialRecordTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, tcsb); JPanel trialsPanel = new JPanel(new BorderLayout()); trialsPanel.add(messageLabel, BorderLayout.NORTH); trialsPanel.add(scrollPane, BorderLayout.CENTER); trialsPanel.add(buttons, BorderLayout.SOUTH); cardPanel.add(helpInstructions, CARD_HELP); cardPanel.add(trialsPanel, CARD_TRIALS); cardLayout.show(cardPanel, CARD_HELP); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, searchOptionsPanel.getViewComponent(), cardPanel); return splitPane; }