List of usage examples for javax.swing JTabbedPane JTabbedPane
public JTabbedPane()
TabbedPane
with a default tab placement of JTabbedPane.TOP
. From source file:org.zaproxy.zap.extension.customFire.ScanProgressDialog.java
/** * //from w ww.j a va 2 s. c o m */ private void initialize() { this.setSize(new Dimension(580, 504)); if (site != null) { this.setTitle("Scann Progress"); } JTabbedPane tabbedPane = new JTabbedPane(); JPanel tab1 = new JPanel(); tab1.setLayout(new GridBagLayout()); JPanel hostPanel = new JPanel(); hostPanel.setLayout(new GridBagLayout()); hostPanel.add(new JLabel("Host:"), LayoutHelper.getGBC(0, 0, 1, 0.4D)); hostPanel.add(getHostSelect(), LayoutHelper.getGBC(1, 0, 1, 0.6D)); tab1.add(hostPanel, LayoutHelper.getGBC(0, 0, 3, 1.0D, 0.0D)); tab1.add(getJScrollPane(), LayoutHelper.getGBC(0, 1, 3, 1.0D, 1.0D));//* tab1.add(new JLabel(), LayoutHelper.getGBC(0, 1, 1, 1.0D, 0.0D)); // spacer tab1.add(getCloseButton(), LayoutHelper.getGBC(1, 2, 1, 0.0D, 0.0D)); tab1.add(new JLabel(), LayoutHelper.getGBC(2, 1, 1, 1.0D, 0.0D)); // spacer tabbedPane.insertTab("Progress", null, tab1, null, 0); this.add(tabbedPane); int mins = extension.getScannerParam().getMaxChartTimeInMins(); if (mins > 0) { // Treat zero mins as disabled JPanel tab2 = new JPanel(); tab2.setLayout(new GridBagLayout()); this.seriesTotal = new TimeSeries("TotalResponses"); // Name not shown, so no need to i18n final TimeSeriesCollection dataset = new TimeSeriesCollection(this.seriesTotal); this.series100 = new TimeSeries("1xx"); this.series200 = new TimeSeries("2xx"); this.series300 = new TimeSeries("3xx"); this.series400 = new TimeSeries("4xx"); this.series500 = new TimeSeries("5xx"); this.seriesTotal.setMaximumItemAge(mins * 60); this.series100.setMaximumItemAge(mins * 60); this.series200.setMaximumItemAge(mins * 60); this.series300.setMaximumItemAge(mins * 60); this.series400.setMaximumItemAge(mins * 60); this.series500.setMaximumItemAge(mins * 60); dataset.addSeries(series100); dataset.addSeries(series200); dataset.addSeries(series300); dataset.addSeries(series400); dataset.addSeries(series500); chart = createChart(dataset);//* // Set up some vaguesly sensible colours chart.getXYPlot().getRenderer(0).setSeriesPaint(0, Color.BLACK); // Totals chart.getXYPlot().getRenderer(0).setSeriesPaint(1, Color.ORANGE); // 100: Info chart.getXYPlot().getRenderer(0).setSeriesPaint(2, Color.GREEN); // 200: OK chart.getXYPlot().getRenderer(0).setSeriesPaint(3, Color.BLUE); // 300: Info chart.getXYPlot().getRenderer(0).setSeriesPaint(4, Color.YELLOW); // 400: Bad req chart.getXYPlot().getRenderer(0).setSeriesPaint(5, Color.RED); // 500: Internal error chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(5.0f)); // Totals chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(3.0f)); // 100: Info chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(3.0f)); // 200: OK chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(3.0f)); // 300: Info chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(3.0f)); // 400: Bad req chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(3.0f)); // 500: Internal error final ChartPanel chartPanel = new ChartPanel(chart); tab2.add(chartPanel, LayoutHelper.getGBC(0, 0, 1, 1.0D, 1.0D)); tabbedPane.insertTab("ResponseCharts", null, tab2, null, 1); } // Stop the updating thread when the window is closed this.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { stopThread = true; } }); }
From source file:org.uncommons.watchmaker.swing.evolutionmonitor.EvolutionMonitor.java
private void init(Renderer<? super T, JComponent> renderer) { // Make sure all JFreeChart charts are created with the legacy theme // (grey surround and white data area). ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JTabbedPane tabs = new JTabbedPane(); monitorComponent = new JPanel(new BorderLayout()); monitorComponent.add(tabs, BorderLayout.CENTER); FittestCandidateView<T> candidateView = new FittestCandidateView<T>(renderer); tabs.add("Fittest Individual", candidateView); views.add(new SwingIslandEvolutionObserver<T>(candidateView, 300, TimeUnit.MILLISECONDS)); PopulationFitnessView fitnessView = new PopulationFitnessView(islands); tabs.add(islands ? "Global Population" : "Population Fitness", fitnessView); views.add(fitnessView);/*from w w w . java 2 s.c om*/ if (islands) { IslandsView islandsView = new IslandsView(); tabs.add("Island Populations", islandsView); views.add(new SwingIslandEvolutionObserver<Object>(islandsView, 300, TimeUnit.MILLISECONDS)); } JVMView jvmView = new JVMView(); tabs.add("JVM Memory", jvmView); StatusBar statusBar = new StatusBar(islands); monitorComponent.add(statusBar, BorderLayout.SOUTH); views.add(new SwingIslandEvolutionObserver<Object>(statusBar, 300, TimeUnit.MILLISECONDS)); }
From source file:DefaultsDisplay.java
/** Creates a new instance of DefaultsDisplayer */ public DefaultsDisplay() { defaultsTablesMap = new HashMap<String, JComponent>(); try {// w ww . j av a 2s .c o m UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); if (System.getProperty("os.name").equals("Mac OS X")) { OSXLookAndFeelName = UIManager.getLookAndFeel().getName(); } } catch (Exception ex) { // better work :-) } setLayout(new BorderLayout()); JPanel controls = new JPanel(); controls.add(createLookAndFeelControl()); controls.add(createFilterControl()); add(controls, BorderLayout.NORTH); tabPane = new JTabbedPane(); add(tabPane, BorderLayout.CENTER); addDefaultsTab(); }
From source file:org.eumetsat.metop.visat.IasiInfoView.java
@Override protected JComponent createControl() { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.add("Sounder Info", createInfoComponent()); tabbedPane.add("Sounder Spectrum", createSpectrumChartComponent()); tabbedPane.add("Radiance Analysis", createRadianceAnalysisComponent()); tabbedPane.add("Sounder Layer", createSounderLayerComponent()); if (getDescriptor().getHelpId() != null) { HelpSys.enableHelpKey(tabbedPane, getDescriptor().getHelpId()); }/*from w w w .ja v a 2 s. co m*/ InternalFrameListener internalFrameListener = new InternalFrameAdapter() { @Override public void internalFrameActivated(InternalFrameEvent e) { final Container contentPane = e.getInternalFrame().getContentPane(); if (contentPane instanceof ProductSceneView) { final ProductSceneView view = (ProductSceneView) contentPane; final IasiLayer layer = getIasiLayer(); if (layer != null) { modelChanged(layer); } else { final LayerListener layerListener = new AbstractLayerListener() { @Override public void handleLayersAdded(Layer parentLayer, Layer[] childLayers) { final IasiLayer layer = getIasiLayer(); if (layer != null) { modelChanged(layer); view.getRootLayer().removeListener(this); } } }; view.getRootLayer().addListener(layerListener); } } } @Override public void internalFrameDeactivated(InternalFrameEvent e) { if (currentOverlay != null) { currentOverlay.removeListener(overlayListener); } updateUI(null); editor.setModel(null); } }; VisatApp.getApp().addInternalFrameListener(internalFrameListener); if (MetopSounderVPI.isValidAvhrrProductSceneViewSelected()) { final IasiLayer layer = getIasiLayer(); if (layer != null) { modelChanged(layer); } } final AbstractButton helpButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Help24.gif"), false); helpButton.setToolTipText("Help."); /*I18N*/ helpButton.setName("helpButton"); if (getDescriptor().getHelpId() != null) { HelpSys.enableHelpOnButton(helpButton, getDescriptor().getHelpId()); HelpSys.enableHelpKey(tabbedPane, getDescriptor().getHelpId()); } final JPanel containerPanel = new JPanel(new BorderLayout()); containerPanel.add(tabbedPane, BorderLayout.CENTER); final JPanel buttonPanel = new JPanel(new BorderLayout()); buttonPanel.add(helpButton, BorderLayout.EAST); containerPanel.add(buttonPanel, BorderLayout.SOUTH); return containerPanel; }
From source file:org.zaproxy.zap.extension.ascan.ScanProgressDialog.java
/** * // w ww . j a v a 2 s .c om */ private void initialize() { this.setSize(new Dimension(580, 504)); if (site != null) { this.setTitle(MessageFormat.format(Constant.messages.getString("ascan.progress.title"), site)); } JTabbedPane tabbedPane = new JTabbedPane(); JPanel tab1 = new JPanel(); tab1.setLayout(new GridBagLayout()); JPanel hostPanel = new JPanel(); hostPanel.setLayout(new GridBagLayout()); hostPanel.add(new JLabel(Constant.messages.getString("ascan.progress.label.host")), LayoutHelper.getGBC(0, 0, 1, 0.4D)); hostPanel.add(getHostSelect(), LayoutHelper.getGBC(1, 0, 1, 0.6D)); tab1.add(hostPanel, LayoutHelper.getGBC(0, 0, 3, 1.0D, 0.0D)); tab1.add(getJScrollPane(), LayoutHelper.getGBC(0, 1, 3, 1.0D, 1.0D)); tab1.add(new JLabel(), LayoutHelper.getGBC(0, 1, 1, 1.0D, 0.0D)); // spacer tab1.add(getCloseButton(), LayoutHelper.getGBC(1, 2, 1, 0.0D, 0.0D)); tab1.add(new JLabel(), LayoutHelper.getGBC(2, 1, 1, 1.0D, 0.0D)); // spacer tabbedPane.insertTab(Constant.messages.getString("ascan.progress.tab.progress"), null, tab1, null, 0); this.add(tabbedPane); int mins = extension.getScannerParam().getMaxChartTimeInMins(); if (mins > 0) { // Treat zero mins as disabled JPanel tab2 = new JPanel(); tab2.setLayout(new GridBagLayout()); this.seriesTotal = new TimeSeries("TotalResponses"); // Name not shown, so no need to i18n final TimeSeriesCollection dataset = new TimeSeriesCollection(this.seriesTotal); this.series100 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.1xx")); this.series200 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.2xx")); this.series300 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.3xx")); this.series400 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.4xx")); this.series500 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.5xx")); this.seriesTotal.setMaximumItemAge(mins * 60); this.series100.setMaximumItemAge(mins * 60); this.series200.setMaximumItemAge(mins * 60); this.series300.setMaximumItemAge(mins * 60); this.series400.setMaximumItemAge(mins * 60); this.series500.setMaximumItemAge(mins * 60); dataset.addSeries(series100); dataset.addSeries(series200); dataset.addSeries(series300); dataset.addSeries(series400); dataset.addSeries(series500); chart = createChart(dataset); // Set up some vaguesly sensible colours chart.getXYPlot().getRenderer(0).setSeriesPaint(0, Color.BLACK); // Totals chart.getXYPlot().getRenderer(0).setSeriesPaint(1, Color.GRAY); // 100: Info chart.getXYPlot().getRenderer(0).setSeriesPaint(2, Color.GREEN); // 200: OK chart.getXYPlot().getRenderer(0).setSeriesPaint(3, Color.BLUE); // 300: Info chart.getXYPlot().getRenderer(0).setSeriesPaint(4, Color.MAGENTA); // 400: Bad req chart.getXYPlot().getRenderer(0).setSeriesPaint(5, Color.RED); // 500: Internal error final ChartPanel chartPanel = new ChartPanel(chart); tab2.add(chartPanel, LayoutHelper.getGBC(0, 0, 1, 1.0D, 1.0D)); tabbedPane.insertTab(Constant.messages.getString("ascan.progress.tab.chart"), null, tab2, null, 1); } // Stop the updating thread when the window is closed this.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { stopThread = true; } }); }
From source file:inet.CalculationNetworkEditor.visual.view.EditorPane.java
public EditorPane(List<Graph<V, E>> phys, List<Graph<V, E>> virts, HashMap<V, V> stackVertex, HashMap<E, List<E>> stackEdge, HashMap<V, Double> vertexRessources, HashMap<E, Double> edgeRessources, Factory<V> pVertexFactory, Factory<E> pEdgeFactory, Dimension pActDimension) { super();/*from www . j ava 2s.co m*/ actDimension = pActDimension; Dimension tabbedDimensions = new Dimension((int) pActDimension.getWidth() - 200, (int) pActDimension.getHeight()); setSize(pActDimension); setPreferredSize(pActDimension); setLayout(new BorderLayout()); vertexFactory = pVertexFactory; edgeFactory = pEdgeFactory; logic = new Logic<V, E>(); logic.init(phys, virts, stackVertex, stackEdge, vertexRessources, edgeRessources); tabbedPane = new JTabbedPane(); tabbedPane.setSize(tabbedDimensions); tabbedPane.setPreferredSize(tabbedDimensions); add(tabbedPane, BorderLayout.CENTER); rightBetweenPanel = new JPanel(); rightBetweenPanel.setLayout(new BorderLayout()); rightBetweenPanel.setSize(200, 500); rightBetweenPanel.setPreferredSize(new Dimension(200, 500)); add(rightBetweenPanel, BorderLayout.LINE_END); rightPanel = new JPanel(); rightPanel.setSize(200, 500); rightPanel.setPreferredSize(new Dimension(200, 500)); rightBetweenPanel.add(rightPanel, BorderLayout.CENTER); vertexPaintTransformer = new VertexPaintTransformer<V, E>(logic, tabbedPane); vertexPaintTransformerStacking = new VertexPaintTransformerStacking<V, E>(logic, tabbedPane); edgePaintTransformer = new EdgePaintTransformer<V, E>(logic, tabbedPane); edgeStrokeTransformer = new EdgeStrokeTransformer<V, E>(logic, tabbedPane); // init VisualisationViewer visViewPhysical = new VisualizationViewerPhysical<V, E>(logic.getDisplay(IStorage.Type.PHYSICAL), vertexPaintTransformer, edgePaintTransformer, edgeStrokeTransformer, this); visViewVirtual = new VisualizationViewerVirtual<V, E>(logic.getDisplay(IStorage.Type.VIRTUAL), vertexPaintTransformer, edgePaintTransformer, edgeStrokeTransformer, this); visViewBoth = new VisualizationViewerBoth<V, E>(logic.getDisplay(null), vertexPaintTransformer, vertexPaintTransformerStacking, edgePaintTransformer, edgeStrokeTransformer, this); vc = new ViewController<V, E>(this, visViewPhysical, visViewVirtual, visViewBoth); bc = new BackendController<V, E>(logic, pVertexFactory, pEdgeFactory); mouseAbstraction = new MouseAbstraction<V, E>(vc, bc, this); editingPanelsListener = new EditingPanelsListener<V, E>(this, bc); visViewPhysical.setMouseAbstraction(mouseAbstraction); visViewVirtual.setMouseAbstraction(mouseAbstraction); visViewBoth.setMouseAbstraction(mouseAbstraction); /* visViewPhysical.setGraphMouse(mgm); visViewVirtual.setGraphMouse(mgm); visViewBoth.setGraphMouse(mgm); */ vertexPaintTransformer.setVisualizationViewers(visViewPhysical, visViewVirtual, visViewBoth); vertexPaintTransformerStacking.setVisualizationViewers(visViewPhysical, visViewVirtual, visViewBoth); edgePaintTransformer.setVisualizationViewers(visViewPhysical, visViewVirtual, visViewBoth); /* deprecatedMML = new Controller( layoutPhysical, layoutVirtual, layoutBoth, visViewPhysical, visViewVirtual, visViewBoth, tabbedPane, logic, physGraph, virtGraph, vertexFactory, edgeFactory); //, // mousePhysical, mouseVirtual, mouseBoth); */ //visViewStateChangedListener = new VisualViewerStateChangedListener(visViewPhysical, visViewVirtual, visViewBoth); tabSwitchListener = new TabSwitchedListener(this, tabbedPane);//,deprecatedMML); reinitializeTabPane(); addComponentListener(new ComponentResizedListener(tabbedPane, this)); add(tabbedPane, BorderLayout.CENTER); //add(vv); }
From source file:gui.DownloadManagerGUI.java
public DownloadManagerGUI(String name) { super(name);//w w w. ja v a 2 s.com setLayout(new BorderLayout()); preferences = Preferences.userRoot().node("db"); final PreferencesDTO preferencesDTO = getPreferences(); LookAndFeel.setLaf(preferencesDTO.getPreferencesInterfaceDTO().getLookAndFeelName()); createFileHierarchy(); mainToolbar = new MainToolBar(); categoryPanel = new CategoryPanel( preferencesDTO.getPreferencesSaveDTO().getPreferencesDirectoryCategoryDTOs()); downloadPanel = new DownloadPanel(this, preferencesDTO.getPreferencesSaveDTO().getDatabasePath(), preferencesDTO.getPreferencesConnectionDTO().getConnectionTimeOut(), preferencesDTO.getPreferencesConnectionDTO().getReadTimeOut()); messagePanel = new MessagePanel(this); JTabbedPane mainTabPane = new JTabbedPane(); mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, categoryPanel, mainTabPane); mainSplitPane.setOneTouchExpandable(true); statusPanel = new StatusPanel(); addNewDownloadDialog = new AddNewDownloadDialog(this); mainTabPane.addTab(messagesBundle.getString("downloadManagerGUI.mainTabPane.downloadPanel"), downloadPanel); mainTabPane.addTab(messagesBundle.getString("downloadManagerGUI.mainTabPane.messagePanel"), messagePanel); preferenceDialog = new PreferenceDialog(this, preferencesDTO); aboutDialog = new AboutDialog(this); categoryPanel.setCategoryPanelListener((fileExtensions, downloadCategory) -> downloadPanel .setDownloadsByDownloadPath(fileExtensions, downloadCategory)); // preferenceDialog.setDefaults(preferencesDTO); addNewDownloadDialog.setAddNewDownloadListener(textUrl -> { Objects.requireNonNull(textUrl, "textUrl"); if (textUrl.equals("")) throw new IllegalArgumentException("textUrl is empty"); String downloadName; try { downloadName = ConnectionUtil.getRealFileName(textUrl); } catch (IOException e) { logger.error("Can't get real name of file that you want to download." + textUrl); messageLogger.error("Can't get real name of file that you want to download." + textUrl); downloadName = ConnectionUtil.getFileName(textUrl); } String fileExtension = FilenameUtils.getExtension(downloadName); File downloadPathFile = new File( preferencesDTO.getPreferencesSaveDTO().getPathByFileExtension(fileExtension)); File downloadRangeFile = new File(preferencesDTO.getPreferencesSaveDTO().getTempDirectory()); int maxNum = preferencesDTO.getPreferencesConnectionDTO().getMaxConnectionNumber(); Download download = null; List<Download> downloads = downloadPanel.getDownloadList(); String properDownloadName = getProperNameForDownload(downloadName, downloads, downloadPathFile); // todo must set stretegy pattern switch (ProtocolType.valueOfByDesc(textUrl.getProtocol())) { case HTTP: download = new HttpDownload(downloadPanel.getNextDownloadID(), textUrl, properDownloadName, maxNum, downloadPathFile, downloadRangeFile, ProtocolType.HTTP); break; case FTP: // todo must be created ... break; case HTTPS: download = new HttpsDownload(downloadPanel.getNextDownloadID(), textUrl, properDownloadName, maxNum, downloadPathFile, downloadRangeFile, ProtocolType.HTTPS); break; } downloadPanel.addDownload(download); }); // Add panels to display. add(mainToolbar, BorderLayout.PAGE_START); add(mainSplitPane, BorderLayout.CENTER); add(statusPanel, BorderLayout.PAGE_END); setJMenuBar(initMenuBar()); mainToolbar.setMainToolbarListener(new MainToolbarListener() { @Override public void newDownloadEventOccured() { addNewDownloadDialog.setVisible(true); addNewDownloadDialog.onPaste(); } @Override public void pauseEventOccured() { downloadPanel.actionPause(); mainToolbar.setStateOfButtonsControl(false, false, false, false, false, true); // canceled } @Override public void resumeEventOccured() { downloadPanel.actionResume(); } @Override public void pauseAllEventOccured() { downloadPanel.actionPauseAll(); } @Override public void clearEventOccured() { downloadPanel.actionClear(); } @Override public void clearAllCompletedEventOccured() { downloadPanel.actionClearAllCompleted(); } @Override public void reJoinEventOccured() { downloadPanel.actionReJoinFileParts(); } @Override public void reDownloadEventOccured() { downloadPanel.actionReDownload(); } @Override public void propertiesEventOccured() { downloadPanel.actionProperties(); } @Override public void preferencesEventOccured() { preferenceDialog.setVisible(true); } }); downloadPanel.setDownloadPanelListener(new DownloadPanelListener() { @Override public void stateChangedEventOccured(DownloadStatus downloadState) { updateButtons(downloadState); } @Override public void downloadSelected(Download download) { statusPanel.setStatus(download.getDownloadName()); } }); preferenceDialog.setPreferencesListener(new PreferencesListener() { @Override public void preferencesSet(PreferencesDTO preferenceDTO) { setPreferencesOS(preferenceDTO); } @Override public void preferenceReset() { PreferencesDTO resetPreferencesDTO = getPreferences(); preferenceDialog.setPreferencesDTO(resetPreferencesDTO); categoryPanel.setTreeModel( resetPreferencesDTO.getPreferencesSaveDTO().getPreferencesDirectoryCategoryDTOs()); } @Override public void preferenceDefaults() { PreferencesDTO defaultPreferenceDTO = new PreferencesDTO(); resetAndSetPreferencesDTOFromConf(defaultPreferenceDTO); preferenceDialog.setPreferencesDTO(defaultPreferenceDTO); categoryPanel.setTreeModel( defaultPreferenceDTO.getPreferencesSaveDTO().getPreferencesDirectoryCategoryDTOs()); } }); // Handle window closing events. addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent windowEvent) { int action = JOptionPane.showConfirmDialog(DownloadManagerGUI.this, "Do you realy want to exit the application?", "Confirm Exit", JOptionPane.OK_CANCEL_OPTION); if (action == JOptionPane.OK_OPTION) { logger.info("Window Closing"); downloadPanel.actionPauseAll(); dispose(); System.gc(); } } }); Authenticator.setDefault(new DialogAuthenticator(this)); setIconImage( Utils.createIcon(messagesBundle.getString("downloadManagerGUI.mainFrame.iconPath")).getImage()); setMinimumSize(new Dimension(640, 480)); // Set window size. pack(); setSize(900, 580); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setVisible(true); }
From source file:net.schweerelos.parrot.CombinedParrotApp.java
private void initGUI(Properties properties) { try {// w ww .j a v a 2s. c o m this.setTitle(APP_TITLE); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { for (MainViewComponent mainViewComponent : mainViews) { if (mainViewComponent instanceof ParrotStateListener) { ((ParrotStateListener) mainViewComponent).parrotExiting(); } } } }); setSize(920, 690); getContentPane().setLayout(new BorderLayout()); UserInterfaceManager uiManager = new UserInterfaceManager(properties); navigators = new ArrayList<NavigatorComponent>(4); // main view listView = uiManager.createMainViewComponent(Style.TABLE); graphView = uiManager.createMainViewComponent(Style.GRAPH); mainViews.add(listView); mainViews.add(graphView); final JTabbedPane mainPanel = new JTabbedPane(); mainPanel.add(graphView.getTitle(), graphView.asJComponent()); mainPanel.add(listView.getTitle(), listView.asJComponent()); mainPanel.setSelectedIndex(0); activeMainView = graphView; mainPanel.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (e.getSource() != mainPanel) { return; } int selectedIndex = mainPanel.getSelectedIndex(); if (selectedIndex == 0) { activeMainView = graphView; } else if (selectedIndex == 1) { activeMainView = listView; } else { Logger logger = Logger.getLogger(CombinedParrotApp.class); logger.warn("unknown tab index selected: " + selectedIndex); } } }); add(mainPanel, BorderLayout.CENTER); // navigators JToolBar navigatorsBar = new JToolBar(JToolBar.HORIZONTAL); navigatorsBar.setMargin(new Insets(0, 11, 0, 0)); navigatorsBar.setFloatable(false); getContentPane().add(navigatorsBar, BorderLayout.PAGE_START); // timeline NavigatorComponent timelineNavigator = uiManager.createTimelineNavigationComponent(); navigators.add(timelineNavigator); JFrame timelineFrame = new JFrame(timelineNavigator.getNavigatorName() + " " + APP_TITLE); timelineFrame.getContentPane().add(timelineNavigator.asJComponent()); timelineFrame.pack(); Point preferredLocation = new Point(0, 0); preferredFrameLocations.put(timelineFrame, preferredLocation); if (timelineNavigator.hasShowHideListener()) { timelineFrame.addComponentListener(timelineNavigator.getShowHideListener()); } timelineFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); JToggleButton timelineButton = setupNavigatorButton(timelineNavigator.getNavigatorName(), timelineNavigator.getAcceleratorKey(), timelineNavigator); navigatorsBar.add(timelineButton); // map NavigatorComponent mapNavigator = uiManager.createMapNavigationComponent(); navigators.add(mapNavigator); JFrame mapFrame = new JFrame(mapNavigator.getNavigatorName() + " " + APP_TITLE); mapFrame.getContentPane().add(mapNavigator.asJComponent()); mapFrame.pack(); preferredLocation = new Point(0, Toolkit.getDefaultToolkit().getScreenSize().height - mapFrame.getHeight()); preferredFrameLocations.put(mapFrame, preferredLocation); if (mapNavigator.hasShowHideListener()) { mapFrame.addComponentListener(mapNavigator.getShowHideListener()); } mapFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); JToggleButton mapButton = setupNavigatorButton(mapNavigator.getNavigatorName(), mapNavigator.getAcceleratorKey(), mapNavigator); navigatorsBar.add(mapButton); // search NavigatorComponent searchNavigator = uiManager.createSearchComponent(); navigators.add(searchNavigator); JFrame searchFrame = new JFrame(searchNavigator.getNavigatorName() + " " + APP_TITLE); searchFrame.getContentPane().add(searchNavigator.asJComponent()); searchFrame.pack(); preferredLocation = new Point( Toolkit.getDefaultToolkit().getScreenSize().width - searchFrame.getWidth(), 0); preferredFrameLocations.put(searchFrame, preferredLocation); if (searchNavigator.hasShowHideListener()) { searchFrame.addComponentListener(searchNavigator.getShowHideListener()); } searchFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); JToggleButton searchButton = setupNavigatorButton(searchNavigator.getNavigatorName(), searchNavigator.getAcceleratorKey(), searchNavigator); navigatorsBar.add(searchButton); // connections NavigatorComponent chainNavigator = uiManager.createChainNavigationComponent(); navigators.add(chainNavigator); if (chainNavigator instanceof PickListener) { for (MainViewComponent mainViewComponent : mainViews) { mainViewComponent.addPickListener((PickListener) chainNavigator); } } if (chainNavigator.hasShowHideListener()) { chainNavigator.asJComponent().addComponentListener(chainNavigator.getShowHideListener()); } JToggleButton connectionsButton = setupNavigatorButton(chainNavigator.getNavigatorName(), chainNavigator.getAcceleratorKey(), chainNavigator); navigatorsBar.add(connectionsButton); add(chainNavigator.asJComponent(), BorderLayout.PAGE_END); chainNavigator.asJComponent().setVisible(false); } catch (RuntimeException e) { e.printStackTrace(System.err); System.exit(1); } catch (UnknownStyleException e) { e.printStackTrace(System.err); System.exit(1); } }
From source file:org.ash.history.TopActivityDetail.java
/** * Load Top Activity and Detail tabs with data. * // w w w.ja va 2s . c om * @param begin * @param end * @throws DatabaseException */ private void loadPreviewStackedChartP(double begin, double end) throws DatabaseException { try { TopActivityPreview stackedChart = new TopActivityPreview(this.databaseHistory); // Set Max CPU stackedChart.setThresholdMaxCpu(getMaxCPUValue(databaseHistory)); // Set Title stackedChart.setTitle(getTitle(databaseHistory, begin, end)); // Set chart panel this.chartChartPanel = stackedChart.createDemoPanelTopActivity(begin, end); // Set legend to stacked chart stackedChart.addLegend(10); // Set format for x axis stackedChart.setFormat("HH:mm"); /** Initialize Sqls & Sessions JPanel*/ this.sqlsAndSessions = new GanttH(this.mainFrame, this.databaseHistory); this.splitPaneMain.setOrientation(JSplitPane.VERTICAL_SPLIT); this.splitPaneMain.add(this.chartChartPanel, "top"); this.splitPaneMain.add(this.sqlsAndSessions, "bottom"); this.splitPaneMain.setDividerLocation(240); this.splitPaneMain.setOneTouchExpandable(true); this.mainPanelHistory = new JPanel(); this.mainPanelHistory.setLayout(new GridLayout(1, 1, 1, 1)); this.mainPanelHistory.add(splitPaneMain); this.chartChartPanel.addListenerReleaseMouse(this.sqlsAndSessions); this.sqlsAndSessions.repaint(); this.tabsMain = new JTabbedPane(); DetailsPanelH detailJPanelH = new DetailsPanelH(this.databaseHistory, begin, end, getMaxCPUValue(databaseHistory)); this.tabsMain.add(this.mainPanelHistory, Options.getInstance().getResource("tabMain.text")); this.tabsMain.add(detailJPanelH, Options.getInstance().getResource("tabDetail.text")); this.mainPanel.removeAll(); this.mainPanel.add(this.tabsMain); this.validate(); } catch (DatabaseException e) { e.printStackTrace(); } }
From source file:gtu._work.ui.SvnLastestCommitInfoUI.java
private void initGUI() { try {//from ww w. ja v a2 s . c om BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); this.setFocusable(false); this.setTitle("SVN lastest commit wather"); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("svn dir", null, jPanel1, null); { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); { TableModel svnTableModel = new DefaultTableModel(); svnTable = new JTable(); jScrollPane1.setViewportView(svnTable); svnTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { try { if (evt.getButton() == 3) { final List<File> list = new ArrayList<File>(); SvnFile svnFile = null; final StringBuilder sb = new StringBuilder(); for (int row : svnTable.getSelectedRows()) { svnFile = (SvnFile) svnTable.getModel().getValueAt( svnTable.getRowSorter().convertRowIndexToModel(row), SvnTableColumn.SVN_FILE.pos); list.add(svnFile.file); sb.append(svnFile.file.getName() + ","); } if (sb.length() > 200) { sb.delete(200, sb.length() - 1); } JMenuItem copySelectedMeun = new JMenuItem(); copySelectedMeun.setText("copy selected file : " + list.size()); copySelectedMeun.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil .newInstance().iconPlainMessage().confirmButtonYesNo() .showConfirmDialog( "are you sure copy files :\n" + sb + "\n???", "COPY SELECTED FILE : " + list.size())) { return; } final File copyToDir = JFileChooserUtil.newInstance() .selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (copyToDir == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("dir folder is not correct!", "ERROR"); return; } new Thread(Thread.currentThread().getThreadGroup(), new Runnable() { public void run() { StringBuilder errMsg = new StringBuilder(); int errCount = 0; for (File f : list) { try { FileUtil.copyFile(f, new File(copyToDir, f.getName())); } catch (IOException e) { e.printStackTrace(); errCount++; errMsg.append(f + "\n"); } } JOptionPaneUtil.newInstance().iconPlainMessage() .showMessageDialog( "copy completed!\nerror : " + errCount + "\nerror list : \n" + errMsg, "COMPLETED"); } }, "copySelectedFiles_" + hashCode()).start(); } }); JMenuItem copySelectedOringTreeMeun = new JMenuItem(); copySelectedOringTreeMeun .setText("copy selected file (orign tree): " + list.size()); copySelectedOringTreeMeun.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil .newInstance().iconPlainMessage().confirmButtonYesNo() .showConfirmDialog( "are you sure copy files :\n" + sb + "\n???", "COPY SELECTED FILE : " + list.size())) { return; } final File copyToDir = JFileChooserUtil.newInstance() .selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (copyToDir == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("dir folder is not correct!", "ERROR"); return; } new Thread(Thread.currentThread().getThreadGroup(), new Runnable() { public void run() { File srcBaseDir = FileUtil .exportReceiveBaseDir(list); int cutLength = 0; if (srcBaseDir != null) { cutLength = srcBaseDir.getAbsolutePath() .length(); } StringBuilder errMsg = new StringBuilder(); int errCount = 0; File newFile = null; for (File f : list) { try { newFile = new File(copyToDir + "/" + f.getAbsolutePath() .substring(cutLength), f.getName()); newFile.getParentFile().mkdirs(); FileUtil.copyFile(f, newFile); } catch (IOException e) { e.printStackTrace(); errCount++; errMsg.append(f + "\n"); } } JOptionPaneUtil.newInstance().iconPlainMessage() .showMessageDialog( "copy completed!\nerror : " + errCount + "\nerror list : \n" + errMsg, "COMPLETED"); } }, "copySelectedFiles_orignTree_" + hashCode()).start(); } }); JPopupMenuUtil.newInstance(svnTable).applyEvent(evt) .addJMenuItem(copySelectedMeun, copySelectedOringTreeMeun) .show(); } if (!JMouseEventUtil.buttonLeftClick(2, evt)) { return; } int row = JTableUtil.newInstance(svnTable).getSelectedRow(); SvnFile svnFile = (SvnFile) svnTable.getModel().getValueAt(row, SvnTableColumn.SVN_FILE.pos); String command = String.format("cmd /c call \"%s\"", svnFile.file); System.out.println(command); try { Runtime.getRuntime().exec(command); } catch (IOException e) { e.printStackTrace(); } } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); svnTable.setModel(svnTableModel); JTableUtil.defaultSetting(svnTable); } } { jPanel3 = new JPanel(); jPanel1.add(jPanel3, BorderLayout.NORTH); jPanel3.setPreferredSize(new java.awt.Dimension(379, 35)); { filterText = new JTextField(); jPanel3.add(filterText); filterText.setPreferredSize(new java.awt.Dimension(258, 24)); filterText.getDocument() .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() { public void process(DocumentEvent event) { try { String scanText = JCommonUtil.getDocumentText(event); reloadSvnTable(scanText, _defaultScanProcess); } catch (Exception ex) { JCommonUtil.handleException(ex); } } })); } { choiceSvnDir = new JButton(); jPanel3.add(choiceSvnDir); choiceSvnDir.setText("choice svn dir"); choiceSvnDir.setPreferredSize(new java.awt.Dimension(154, 24)); choiceSvnDir.addActionListener(new ActionListener() { Pattern svnOutputPattern = Pattern .compile("\\s*(\\d*)\\s+(\\d+)\\s+(\\w+)\\s+([\\S]+)"); public void actionPerformed(ActionEvent evt) { try { System.out.println("choiceSvnDir.actionPerformed, event=" + evt); final File svnDir = JFileChooserUtil.newInstance().selectDirectoryOnly() .showOpenDialog().getApproveSelectedFile(); if (svnDir == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("dir is not correct!", "ERROR"); return; } Thread thread = new Thread(Thread.currentThread().getThreadGroup(), new Runnable() { public void run() { long startTime = System.currentTimeMillis(); String command = String .format("cmd /c svn status -v \"%s\"", svnDir); Matcher matcher = null; try { long projectLastestVersion = 0; SvnFile svnFile = null; Process process = Runtime.getRuntime().exec(command); BufferedReader reader = new BufferedReader( new InputStreamReader(process.getInputStream(), "BIG5")); for (String line = null; (line = reader .readLine()) != null;) { matcher = svnOutputPattern.matcher(line); if (matcher.find()) { try { if (StringUtils .isNotBlank(matcher.group(1))) { projectLastestVersion = Math.max( projectLastestVersion, Long.parseLong( matcher.group(1))); } svnFile = new SvnFile(); svnFile.lastestVersion = Long .parseLong(matcher.group(2)); svnFile.author = matcher.group(3); svnFile.filePath = matcher.group(4); svnFile.file = new File(svnFile.filePath); svnFile.fileName = svnFile.file.getName(); svnFileSet.add(svnFile); authorSet.add(svnFile.author); String extension = null; if (svnFile.file.isFile() && (extension = getExtension( svnFile.fileName)) != null) { fileExtenstionSet.add(extension); } } catch (Exception ex) { ex.printStackTrace(); } } else { System.out.println("ignore : " + line); } } reader.close(); lastestVersion = projectLastestVersion; projectName = svnDir.getName(); resetUiAndShowMessage(startTime, projectName, projectLastestVersion); } catch (IOException e) { JCommonUtil.handleException(e); } } }, "loadSvnLastest_" + this.hashCode()); thread.setDaemon(true); thread.start(); setTitle("sweeping..."); } catch (Exception ex) { JCommonUtil.handleException(ex); } } String getExtension(String name) { int pos = -1; if ((pos = name.lastIndexOf(".")) != -1) { return name.substring(pos).toLowerCase(); } return null; } }); } { jLabel1 = new JLabel(); jPanel3.add(jLabel1); jLabel1.setText("match :"); jLabel1.setPreferredSize(new java.awt.Dimension(56, 22)); } { matchCount = new JLabel(); jPanel3.add(matchCount); matchCount.setPreferredSize(new java.awt.Dimension(82, 22)); } } } { jPanel2 = new JPanel(); FlowLayout jPanel2Layout = new FlowLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("config", null, jPanel2, null); { DefaultComboBoxModel authorComboBoxModel = new DefaultComboBoxModel(); authorComboBox = new JComboBox(); jPanel2.add(authorComboBox); authorComboBox.setModel(authorComboBoxModel); authorComboBox.setPreferredSize(new java.awt.Dimension(260, 24)); authorComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { Object author = authorComboBox.getSelectedItem(); if (author instanceof Map.Entry) { Map.Entry<?, ?> entry = (Map.Entry<?, ?>) author; reloadSvnTable((String) entry.getKey(), _authorScanProcess); } else { reloadSvnTable((String) author, _authorScanProcess); } } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(); fileExtensionComboBox = new JComboBox(); jPanel2.add(fileExtensionComboBox); fileExtensionComboBox.setModel(jComboBox1Model); fileExtensionComboBox.setPreferredSize(new java.awt.Dimension(186, 24)); fileExtensionComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { String extension = (String) fileExtensionComboBox.getSelectedItem(); reloadSvnTable(extension, _fileExtensionScanProcess); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { jScrollPane2 = new JScrollPane(); jScrollPane2.setPreferredSize(new java.awt.Dimension(130, 200)); jPanel2.add(jScrollPane2); { DefaultListModel model = new DefaultListModel(); fileExtensionFilter = new JList(); jScrollPane2.setViewportView(fileExtensionFilter); fileExtensionFilter.setModel(model); fileExtensionFilter.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { try { System.out .println(Arrays.toString(fileExtensionFilter.getSelectedValues())); String extensionStr = ""; StringBuilder sb = new StringBuilder(); for (Object val : fileExtensionFilter.getSelectedValues()) { sb.append(val + ","); } extensionStr = (sb.length() > 0 ? sb.deleteCharAt(sb.length() - 1) : sb) .toString(); System.out.format("extensionStr = [%s]\n", extensionStr); multiExtendsionFilter.setName(extensionStr); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } } { multiExtendsionFilter = new JButton(); jPanel2.add(multiExtendsionFilter); multiExtendsionFilter.setText("multi extension filter"); multiExtendsionFilter.setPreferredSize(new java.awt.Dimension(166, 34)); multiExtendsionFilter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { reloadSvnTable(multiExtendsionFilter.getName(), _fileExtensionMultiScanProcess); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { loadAuthorReference = new JButton(); jPanel2.add(loadAuthorReference); loadAuthorReference.setText("load author reference"); loadAuthorReference.setPreferredSize(new java.awt.Dimension(188, 35)); loadAuthorReference.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { File file = JFileChooserUtil.newInstance().selectFileOnly().showOpenDialog() .getApproveSelectedFile(); if (file == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("file is not correct!", "ERROR"); return; } authorProps.load(new FileInputStream(file)); reloadAuthorComboBox(); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { saveCurrentData = new JButton(); jPanel2.add(saveCurrentData); saveCurrentData.setText("save current data"); saveCurrentData.setPreferredSize(new java.awt.Dimension(166, 34)); saveCurrentData.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { File saveDataConfig = new File(jarExistLocation, getSaveCurrentDataFileName()); ObjectOutputStream writer = new ObjectOutputStream( new FileOutputStream(saveDataConfig)); writer.writeObject(projectName); writer.writeObject(authorSet); writer.writeObject(fileExtenstionSet); writer.writeObject(svnFileSet); writer.writeObject(authorProps); writer.writeObject(lastestVersion); writer.flush(); writer.close(); JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("current project : " + projectName + " save completed! \n" + saveDataConfig, "SUCCESS"); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { loadDataFromFile = new JButton(); jPanel2.add(loadDataFromFile); loadDataFromFile.setText("load data cfg"); loadDataFromFile.setPreferredSize(new java.awt.Dimension(165, 35)); loadDataFromFile.addActionListener(new ActionListener() { @SuppressWarnings("unchecked") public void actionPerformed(ActionEvent evt) { try { File file = JFileChooserUtil.newInstance().selectFileOnly() .addAcceptFile(".cfg", ".cfg").showOpenDialog() .getApproveSelectedFile(); if (file == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("file is not correct!", "ERROR"); return; } long startTime = System.currentTimeMillis(); ObjectInputStream input = new ObjectInputStream(new FileInputStream(file)); projectName = (String) input.readObject(); authorSet = (Set<String>) input.readObject(); fileExtenstionSet = (Set<String>) input.readObject(); svnFileSet = (Set<SvnFile>) input.readObject(); authorProps = (Properties) input.readObject(); lastestVersion = (Long) input.readObject(); input.close(); resetUiAndShowMessage(startTime, projectName, lastestVersion); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } } } pack(); this.setSize(726, 459); } catch (Exception e) { e.printStackTrace(); } }