List of usage examples for javax.swing JSplitPane setBottomComponent
@BeanProperty(bound = false, description = "The component below, or to the right of the divider.") public void setBottomComponent(Component comp)
From source file:com.intuit.tank.tools.debugger.RequestResponsePanel.java
public void init() { JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true); pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); requestTA = new RTextArea(); requestTA.setEditable(false);//from w w w . ja v a2s.c o m requestTA.setAutoscrolls(true); requestTA.setHighlightCurrentLine(false); JScrollPane sp1 = new JScrollPane(requestTA, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp1.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); JPanel reqPane = new JPanel(new BorderLayout()); // JPanel titlePanel = new JPanel(new BorderLayout()); // titlePanel.add(BorderLayout.WEST, new JLabel("Request:")); // JButton saveBT = new JButton(parent.getDebuggerActions().getSaveReqResponseAction()); // saveBT.setText(""); // titlePanel.add(BorderLayout.EAST, saveBT); reqPane.add(BorderLayout.NORTH, new JLabel("Request:")); reqPane.add(BorderLayout.CENTER, sp1); pane.setTopComponent(reqPane); responseTA = new RTextArea(); responseTA.setEditable(false); responseTA.setAutoscrolls(true); responseTA.setHighlightCurrentLine(false); JScrollPane sp2 = new JScrollPane(responseTA, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp2.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); JPanel responsePane = new JPanel(new BorderLayout()); responsePane.add(BorderLayout.NORTH, new JLabel("Response:")); responsePane.add(BorderLayout.CENTER, sp2); pane.setBottomComponent(responsePane); pane.setDividerLocation(0.5D); pane.setResizeWeight(0.5D); add(pane, BorderLayout.CENTER); JPopupMenu popupMenu = new JPopupMenu(); popupMenu.add(parent.getDebuggerActions().getSaveReqResponseAction()); requestTA.setPopupMenu(popupMenu); responseTA.setPopupMenu(popupMenu); }
From source file:net.rptools.maptool.client.ui.MapToolFrame.java
private JComponent createDrawTreePanel() { final JTree tree = new JTree(); drawablesPanel = new DrawablesPanel(); drawPanelTreeModel = new DrawPanelTreeModel(tree); tree.setModel(drawPanelTreeModel);//from ww w . ja v a 2 s. c om tree.setCellRenderer(new DrawPanelTreeCellRenderer()); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setContinuousLayout(true); splitPane.setTopComponent(new JScrollPane(tree)); splitPane.setBottomComponent(drawablesPanel); splitPane.setDividerLocation(100); // Add mouse Event for right click menu tree.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path == null) { return; } Object row = path.getLastPathComponent(); int rowIndex = tree.getRowForLocation(e.getX(), e.getY()); if (SwingUtilities.isLeftMouseButton(e)) { if (!SwingUtil.isShiftDown(e) && !SwingUtil.isControlDown(e)) { tree.clearSelection(); } tree.addSelectionInterval(rowIndex, rowIndex); if (row instanceof DrawnElement) { if (e.getClickCount() == 2) { DrawnElement de = (DrawnElement) row; getCurrentZoneRenderer() .centerOn(new ZonePoint((int) de.getDrawable().getBounds().getCenterX(), (int) de.getDrawable().getBounds().getCenterY())); } } int[] treeRows = tree.getSelectionRows(); java.util.Arrays.sort(treeRows); drawablesPanel.clearSelectedIds(); for (int i = 0; i < treeRows.length; i++) { TreePath p = tree.getPathForRow(treeRows[i]); if (p.getLastPathComponent() instanceof DrawnElement) { DrawnElement de = (DrawnElement) p.getLastPathComponent(); drawablesPanel.addSelectedId(de.getDrawable().getId()); } } } if (SwingUtilities.isRightMouseButton(e)) { if (!isRowSelected(tree.getSelectionRows(), rowIndex) && !SwingUtil.isShiftDown(e)) { tree.clearSelection(); tree.addSelectionInterval(rowIndex, rowIndex); drawablesPanel.clearSelectedIds(); } final int x = e.getX(); final int y = e.getY(); EventQueue.invokeLater(new Runnable() { public void run() { DrawnElement firstElement = null; Set<GUID> selectedDrawSet = new HashSet<GUID>(); for (TreePath path : tree.getSelectionPaths()) { if (path.getLastPathComponent() instanceof DrawnElement) { DrawnElement de = (DrawnElement) path.getLastPathComponent(); if (firstElement == null) { firstElement = de; } selectedDrawSet.add(de.getDrawable().getId()); } } if (!selectedDrawSet.isEmpty()) { try { new DrawPanelPopupMenu(selectedDrawSet, x, y, getCurrentZoneRenderer(), firstElement).showPopup(tree); } catch (IllegalComponentStateException icse) { log.info(tree.toString(), icse); } } } }); } } }); // Add Zone Change event MapTool.getEventDispatcher().addListener(new AppEventListener() { public void handleAppEvent(AppEvent event) { drawPanelTreeModel.setZone((Zone) event.getNewValue()); } }, MapTool.ZoneEvent.Activated); return splitPane; }
From source file:cz.lidinsky.editor.Editor.java
/** * Create main frame of the editor/*w ww . j av a 2 s . co m*/ */ protected void createMainFrame() { // Create and set up the window frame = new JFrame("GUI Editor"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // split the main window split = new JSplitPane(); frame.add(split); // split the right side JSplitPane rightSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setBottomComponent(rightSplit); // Add component tree navigator treeModel = new TreeModel(); guiStructureTree = new Tree(treeModel); guiStructureTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); guiStructureTree.setDragEnabled(true); guiStructureTree.setTransferHandler(new TreeTransferHandler()); JScrollPane treeScroll = new JScrollPane(guiStructureTree); rightSplit.setLeftComponent(treeScroll); treeModel.addTreeModelListener(this); // add screens component split.setLeftComponent(treeModel.createRootVisualComponent()); treeModel.configureRootVisualComponent(); // Create file handling class file = new FileHandling(frame); file.addFileEventListener(treeModel); file.addFileEventListener(this); // Create edit handling class edit = new EditHandling(guiStructureTree); // Create layout handling class //layout = new LayoutHandling(guiStructureTree); // Add property editor table propertyTableModel = new KeyValueTableModel(); propertyTable = new JTable(propertyTableModel); propertyTable.setDefaultRenderer(Object.class, new ObjectPropertiesTableRenderer()); TableCellEditor tableCellEditor = new TableCellEditor(); propertyTable.setDefaultEditor(Object.class, tableCellEditor); guiStructureTree.addTreeSelectionListener(tableCellEditor); JScrollPane tableScroll = new JScrollPane(propertyTable); rightSplit.setBottomComponent(tableScroll); guiStructureTree.addTreeSelectionListener(this); propertyTableModel.addTableModelListener(guiStructureTree); // Add a link component -> tree componentToTreeLink = new ComponentToTreeLink(guiStructureTree); // Add a menu Menu menuBar = new Menu(settings); frame.setJMenuBar(menuBar); // Edit menu edit.addMenu(menuBar); }
From source file:com.intuit.tank.tools.script.ScriptFilterRunner.java
/** * @return//ww w.j a v a2 s . c o m */ private Component createContentPanel() { JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true); scriptEditorTA = new RSyntaxTextArea(); setSyntaxStyle(); RTextScrollPane sp = new RTextScrollPane(scriptEditorTA); pane.setTopComponent(sp); JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); JPanel panel = new JPanel(new BorderLayout()); output = new TextAreaOutputLogger(scrollPane, INITIAL_OUTPUT_CONTENT); output.setEditable(false); output.setAutoscrolls(true); output.setScrollContent(true); output.setWrapStyleWord(true); scrollPane.setViewportView(output); JToolBar toolBar = new JToolBar(); JButton clearBT = new JButton("Clear"); clearBT.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { output.setText(INITIAL_OUTPUT_CONTENT); } }); final JCheckBox scrollCB = new JCheckBox("Auto Scroll Content"); scrollCB.setSelected(true); scrollCB.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { output.setScrollContent(scrollCB.isSelected()); } }); toolBar.add(clearBT); toolBar.add(scrollCB); panel.add(toolBar, BorderLayout.NORTH); panel.add(scrollPane, BorderLayout.CENTER); pane.setBottomComponent(panel); pane.setDividerLocation(300); return pane; }
From source file:src.gui.ItSIMPLE.java
/** * @return Returns the planAnalysisFramePanel. */// w w w .ja v a2s.c om private ItFramePanel getPlanAnalysisFramePanel() { if (planAnalysisFramePanel == null) { planAnalysisFramePanel = new ItFramePanel(":: Plan Analysis", ItFramePanel.NO_MINIMIZE_MAXIMIZE); // tool bar JToolBar chartsToolBar = new JToolBar(); chartsToolBar.add(new JButton(drawChartAction)); // charts panel chartsPanel = new JPanel(); chartsPanel.setLayout(new BoxLayout(chartsPanel, BoxLayout.Y_AXIS)); ItFramePanel variableSelectionPanel = new ItFramePanel(".: Select variables to be tracked", ItFramePanel.NO_MINIMIZE_MAXIMIZE); //variableSelectionPanel.setBackground(new Color(151,151,157)); JSplitPane split = new JSplitPane(); split.setContinuousLayout(true); split.setOrientation(JSplitPane.HORIZONTAL_SPLIT); split.setDividerLocation(2 * screenSize.height / 3); split.setDividerSize(8); //split.setPreferredSize(new Dimension(screenSize.width/4-20, screenSize.height/2 - 50)); //split.setPreferredSize(new Dimension(screenSize.width/4-20, 120)); split.setLeftComponent(new JScrollPane(variablesPlanTree)); split.setRightComponent(new JScrollPane(selectedVariablesPlanTree)); variableSelectionPanel.setContent(split, false); //variableSelectionPanel.setParentSplitPane() //JPanel variableSelectionPanel = new JPanel(new BorderLayout()); //variableSelectionPanel.add(new JScrollPane(variablesPlanTree), BorderLayout.CENTER); //variableSelectionPanel.add(new JScrollPane(selectedVariablesPlanTree), BorderLayout.EAST); ItFramePanel variableGraphPanel = new ItFramePanel(".: Chart", ItFramePanel.NO_MINIMIZE_MAXIMIZE); variableGraphPanel.setContent(chartsPanel, true); JSplitPane mainvariablesplit = new JSplitPane(); mainvariablesplit.setContinuousLayout(true); mainvariablesplit.setOrientation(JSplitPane.VERTICAL_SPLIT); mainvariablesplit.setDividerLocation(150); mainvariablesplit.setDividerSize(8); //mainvariablesplit.setPreferredSize(new Dimension(screenSize.width/4-20, screenSize.height/2 - 50)); mainvariablesplit.setTopComponent(variableSelectionPanel); mainvariablesplit.setBottomComponent(variableGraphPanel); // main charts panel - used to locate the tool bar above the charts panel JPanel mainChartsPanel = new JPanel(new BorderLayout()); mainChartsPanel.add(chartsToolBar, BorderLayout.NORTH); //mainChartsPanel.add(new JScrollPane(chartsPanel), BorderLayout.CENTER); mainChartsPanel.add(mainvariablesplit, BorderLayout.CENTER); //Results planInfoEditorPane = new JEditorPane(); planInfoEditorPane.setContentType("text/html"); planInfoEditorPane.setEditable(false); planInfoEditorPane.setCursor(new Cursor(Cursor.TEXT_CURSOR)); planInfoEditorPane.setBackground(Color.WHITE); JPanel resultsPanel = new JPanel(new BorderLayout()); JToolBar resultsToolBar = new JToolBar(); resultsToolBar.setRollover(true); JButton planReportButton = new JButton("View Full Report", new ImageIcon("resources/images/viewreport.png")); planReportButton.setToolTipText("<html>View full plan report.<br> For multiple plans you will need " + "access to the Internet.<br> The components used in the report require such access (no data is " + "sent through the Internet).</html>"); planReportButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { //Opens html with defaut browser String path = "resources/report/Report.html"; File report = new File(path); path = report.getAbsolutePath(); try { BrowserLauncher launcher = new BrowserLauncher(); launcher.openURLinBrowser("file://" + path); } catch (BrowserLaunchingInitializingException ex) { Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex); appendOutputPanelText("ERROR. Problem while trying to open the default browser. \n"); } catch (UnsupportedOperatingSystemException ex) { Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex); appendOutputPanelText("ERROR. Problem while trying to open the default browser. \n"); } } }); resultsToolBar.add(planReportButton); resultsToolBar.addSeparator(); JButton planReportDataButton = new JButton("Save Report Data", new ImageIcon("resources/images/savePDDL.png")); planReportDataButton.setToolTipText("<html>Save report data to file</html>"); planReportDataButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { //Save report data if (solveResult != null) { Element lastOpenFolderElement = itSettings.getChild("generalSettings") .getChild("lastOpenFolder"); JFileChooser fc = new JFileChooser(lastOpenFolderElement.getText()); fc.setDialogTitle("Save Report Data"); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setFileFilter(new XMLFileFilter()); int returnVal = fc.showSaveDialog(ItSIMPLE.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File selectedFile = fc.getSelectedFile(); String path = selectedFile.getPath(); if (!path.toLowerCase().endsWith(".xml")) { path += ".xml"; } //save file (xml) try { FileWriter file = new FileWriter(path); file.write(XMLUtilities.toString(solveResult)); file.close(); } catch (IOException e1) { e1.printStackTrace(); } //Save as a last open folder String folder = selectedFile.getParent(); //Element lastOpenFolderElement = itSettings.getChild("generalSettings").getChild("lastOpenFolder"); lastOpenFolderElement.setText(folder); XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument()); //Ask if the user wants to save plans individually too. boolean needToSavePlans = false; int option = JOptionPane.showOptionDialog(instance, "<html><center>Do you also want to save the plans" + "<br>in individual files?</center></html>", "Save plans", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); switch (option) { case JOptionPane.YES_OPTION: { needToSavePlans = true; } break; case JOptionPane.NO_OPTION: { needToSavePlans = false; } break; } if (needToSavePlans) { //Close Open tabs List<?> problems = null; try { XPath ppath = new JDOMXPath("project/domains/domain/problems/problem"); problems = ppath.selectNodes(solveResult); } catch (JaxenException e2) { e2.printStackTrace(); } for (int i = 0; i < problems.size(); i++) { Element problem = (Element) problems.get(i); //create a folder for each problem and put all plans inside as xml files String folderName = problem.getChildText("name"); String folderPath = selectedFile.getAbsolutePath() .replace(selectedFile.getName(), folderName); //System.out.println(folderPath); File planfolder = new File(folderPath); boolean canSavePlan = false; try { if (planfolder.mkdir()) { System.out.println("Directory '" + folderPath + "' created."); canSavePlan = true; } else { System.out.println("Directory '" + folderPath + "' was not created."); } } catch (Exception ep) { ep.printStackTrace(); } if (canSavePlan) { Element plans = problem.getChild("plans"); for (Iterator<Element> it = plans.getChildren("xmlPlan").iterator(); it .hasNext();) { Element eaplan = it.next(); Element theplanner = eaplan.getChild("planner"); //save file (xml) String planFileName = "solution" + theplanner.getChildText("name") + "-" + theplanner.getChildText("version") + "-" + Integer.toString(plans.getChildren().indexOf(eaplan)) + ".xml"; String planPath = folderPath + File.separator + planFileName; /* try { FileWriter planfile = new FileWriter(planPath); planfile.write(XMLUtilities.toString(eaplan)); planfile.close(); System.out.println("File '" + planPath + "' created."); } catch (IOException e1) { e1.printStackTrace(); } * */ if (eaplan.getChild("plan").getChildren().size() > 0) { //TODO: save the plan in PDDL too. It should be done through the XPDDL/PDDL classes String pddlplan = ToXPDDL.XMLtoXPDDLPlan(eaplan); String planFileNamePDDL = "solution" + theplanner.getChildText("name") + "-" + theplanner.getChildText("version") + "-" + Integer.toString(plans.getChildren().indexOf(eaplan)) + ".pddl"; String planPathPDDL = folderPath + File.separator + planFileNamePDDL; //String cfolderPath = selectedFile.getAbsolutePath().replace(selectedFile.getName(), ""); //String planFileNamePDDL = theplanner.getChildText("name")+"-"+theplanner.getChildText("version") + "-" + folderName+"-solution.pddl"; //String planPathPDDL = cfolderPath + File.separator + planFileNamePDDL; //if (!theplanner.getChildText("name").contains("MIPS")){ try { FileWriter planfile = new FileWriter(planPathPDDL); planfile.write(pddlplan); planfile.close(); System.out.println("File '" + planPathPDDL + "' created."); } catch (IOException e1) { e1.printStackTrace(); } } //} } } } } } } else { appendOutputPanelText(">> No report data available to save! \n"); } } }); resultsToolBar.add(planReportDataButton); JButton openPlanReportDataButton = new JButton("Open Report Data", new ImageIcon("resources/images/openreport.png")); openPlanReportDataButton.setToolTipText("<html>Open report data to file</html>"); openPlanReportDataButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { planSimStatusBar.setText("Status: Opening File..."); appendOutputPanelText(">> Opening File... \n"); //Open report data Element lastOpenFolderElement = itSettings.getChild("generalSettings") .getChild("lastOpenFolder"); JFileChooser fc = new JFileChooser(lastOpenFolderElement.getText()); fc.setDialogTitle("Open Report Data"); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setFileFilter(new XMLFileFilter()); int returnVal = fc.showOpenDialog(ItSIMPLE.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); // Get itSIMPLE itSettings from itSettings.xml org.jdom.Document resultsDoc = null; try { resultsDoc = XMLUtilities.readFromFile(file.getPath()); solveResult = resultsDoc.getRootElement(); //XMLUtilities.printXML(solveResult); if (solveResult.getName().equals("projects")) { String report = PlanAnalyzer.generatePlannersComparisonReport(solveResult); String comparisonReport = PlanAnalyzer .generateFullPlannersComparisonReport(solveResult); //Save Comparison Report file saveFile("resources/report/Report.html", comparisonReport); setPlanInfoPanelText(report); setPlanEvaluationInfoPanelText(""); appendOutputPanelText(">> Report data read! \n"); //My experiments PlanAnalyzer.myAnalysis(itPlanners.getChild("planners"), solveResult); } } catch (Exception e1) { e1.printStackTrace(); } //Save as a last open folder String folder = fc.getSelectedFile().getParent(); lastOpenFolderElement.setText(folder); XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument()); } else { planSimStatusBar.setText("Status:"); appendOutputPanelText(">> Canceled \n"); } } }); resultsToolBar.add(openPlanReportDataButton); JButton compareProjectReportDataButton = new JButton("Compare Project Data", new ImageIcon("resources/images/compare.png")); compareProjectReportDataButton.setToolTipText( "<html>Compare different project report data <br> This is commonly use to compare diferent domain models with different adjustments.<br>" + "One project data must be chosen as a reference; others will be compared to this referencial one.</html>"); compareProjectReportDataButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { final ProjectComparisonDialog dialog = new ProjectComparisonDialog(); dialog.setVisible(true); final List<String> files = dialog.getFiles(); if (files.size() > 1) { new Thread() { public void run() { appendOutputPanelText(">> Project comparison report requested. Processing... \n"); planSimStatusBar.setText("Status: Reading files ..."); appendOutputPanelText(">> Reading files ... \n"); //base project file String baseFileName = files.get(0); appendOutputPanelText(">> Reading file '" + baseFileName + "' \n"); org.jdom.Document baseProjectDoc = null; try { baseProjectDoc = XMLUtilities.readFromFile(baseFileName); } catch (Exception ec) { ec.printStackTrace(); } Element baseProject = null; if (baseProjectDoc != null) { baseProject = baseProjectDoc.getRootElement().getChild("project"); } //The comparible projects List<Element> comparableProjects = new ArrayList<Element>(); for (int i = 1; i < files.size(); i++) { String eafile = files.get(i); appendOutputPanelText(">> Reading file '" + eafile + "' \n"); org.jdom.Document eaProjectDoc = null; try { eaProjectDoc = XMLUtilities.readFromFile(eafile); } catch (Exception ec) { ec.printStackTrace(); } if (eaProjectDoc != null) { comparableProjects.add(eaProjectDoc.getRootElement().getChild("project")); } } appendOutputPanelText(">> Files read. Building report... \n"); String comparisonReport = PlanAnalyzer.generateProjectComparisonReport(baseProject, comparableProjects); saveFile("resources/report/Report.html", comparisonReport); appendOutputPanelText( ">> Project comparison report generated. Press 'View Full Report'\n"); appendOutputPanelText(" \n"); } }.start(); } } }); resultsToolBar.add(compareProjectReportDataButton); resultsPanel.add(resultsToolBar, BorderLayout.NORTH); resultsPanel.add(new JScrollPane(planInfoEditorPane), BorderLayout.CENTER); JTabbedPane planAnalysisTabbedPane = new JTabbedPane(); planAnalysisTabbedPane.addTab("Results", resultsPanel); planAnalysisTabbedPane.addTab("Variable Tracking", mainChartsPanel); planAnalysisTabbedPane.addTab("Movie Maker", getMovieMakerPanel()); planAnalysisTabbedPane.addTab("Plan Evaluation", getPlanEvaluationPanel()); planAnalysisTabbedPane.addTab("Plan Database", getPlanDatabasePanel()); planAnalysisTabbedPane.addTab("Rationale Database", getRationaleDatabasePanel()); JPanel planAnalysisPanel = new JPanel(new BorderLayout()); //planAnalysisPanel.add(chartsToolBar, BorderLayout.NORTH); planAnalysisPanel.add(planAnalysisTabbedPane, BorderLayout.CENTER); planAnalysisFramePanel.setContent(planAnalysisPanel, false); } return planAnalysisFramePanel; }
From source file:org.apache.jmeter.gui.MainFrame.java
/** * Create the GUI components and layout. */// w ww . j a va 2s.c o m private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final) menuBar = new JMeterMenuBar(); setJMenuBar(menuBar); JPanel all = new JPanel(new BorderLayout()); all.add(createToolBar(), BorderLayout.NORTH); JSplitPane treeAndMain = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); treePanel = createTreePanel(); treeAndMain.setLeftComponent(treePanel); JSplitPane topAndDown = new JSplitPane(JSplitPane.VERTICAL_SPLIT); topAndDown.setOneTouchExpandable(true); topAndDown.setDividerLocation(0.8); topAndDown.setResizeWeight(.8); topAndDown.setContinuousLayout(true); topAndDown.setBorder(null); // see bug jdk 4131528 if (!DISPLAY_LOGGER_PANEL) { topAndDown.setDividerSize(0); } mainPanel = createMainPanel(); logPanel = createLoggerPanel(); errorsAndFatalsCounterLogTarget = new ErrorsAndFatalsCounterLogTarget(); LoggingManager.addLogTargetToRootLogger(new LogTarget[] { logPanel, errorsAndFatalsCounterLogTarget }); topAndDown.setTopComponent(mainPanel); topAndDown.setBottomComponent(logPanel); treeAndMain.setRightComponent(topAndDown); treeAndMain.setResizeWeight(.2); treeAndMain.setContinuousLayout(true); all.add(treeAndMain, BorderLayout.CENTER); getContentPane().add(all); tree.setSelectionRow(1); addWindowListener(new WindowHappenings()); // Building is complete, register as listener GuiPackage.getInstance().registerAsListener(); setTitle(DEFAULT_TITLE); setIconImage(JMeterUtils.getImage("icon-apache.png").getImage());// $NON-NLS-1$ setWindowTitle(); // define AWT WM_CLASS string }
From source file:org.pentaho.reporting.engine.classic.core.modules.gui.base.PreviewPane.java
private void refreshReportController(final ReportController newReportController) { for (int i = 0; i < outerReportControllerHolder.getComponentCount(); i++) { final Component maybeSplitPane = outerReportControllerHolder.getComponent(i); if (maybeSplitPane instanceof JSplitPane) { final JSplitPane splitPane = (JSplitPane) maybeSplitPane; reportControllerSliderSize = splitPane.getDividerLocation(); break; }//from w w w. jav a2 s . co m } if (newReportController == null) { if (reportControllerComponent != null) { // thats relatively easy. outerReportControllerHolder.removeAll(); outerReportControllerHolder.add(toolbarHolder, BorderLayout.NORTH); outerReportControllerHolder.add(reportPaneScrollPane, BorderLayout.CENTER); reportControllerComponent = null; reportControllerInner = false; reportControllerLocation = null; } } else { final JComponent rcp = newReportController.getControlPanel(); if (rcp == null) { if (reportControllerComponent != null) { outerReportControllerHolder.removeAll(); outerReportControllerHolder.add(toolbarHolder, BorderLayout.NORTH); outerReportControllerHolder.add(reportPaneScrollPane, BorderLayout.CENTER); reportControllerComponent = null; reportControllerInner = false; reportControllerLocation = null; } } else if (reportControllerComponent != rcp || reportControllerInner != newReportController.isInnerComponent() || ObjectUtilities.equal(reportControllerLocation, newReportController.getControllerLocation()) == false) { // if either the controller component or its position (inner vs outer) // and border-position has changed, then refresh .. this.reportControllerLocation = newReportController.getControllerLocation(); this.reportControllerInner = newReportController.isInnerComponent(); this.reportControllerComponent = newReportController.getControlPanel(); outerReportControllerHolder.removeAll(); if (reportControllerInner) { final JSplitPane innerHolder = new JSplitPane(); innerHolder.setOpaque(false); if (BorderLayout.SOUTH.equals(reportControllerLocation)) { innerHolder.setOrientation(JSplitPane.VERTICAL_SPLIT); innerHolder.setTopComponent(reportPaneScrollPane); innerHolder.setBottomComponent(reportControllerComponent); } else if (BorderLayout.EAST.equals(reportControllerLocation)) { innerHolder.setOrientation(JSplitPane.HORIZONTAL_SPLIT); innerHolder.setLeftComponent(reportPaneScrollPane); innerHolder.setRightComponent(reportControllerComponent); } else if (BorderLayout.WEST.equals(reportControllerLocation)) { innerHolder.setOrientation(JSplitPane.HORIZONTAL_SPLIT); innerHolder.setRightComponent(reportPaneScrollPane); innerHolder.setLeftComponent(reportControllerComponent); } else { innerHolder.setOrientation(JSplitPane.VERTICAL_SPLIT); innerHolder.setBottomComponent(reportPaneScrollPane); innerHolder.setTopComponent(reportControllerComponent); } if (reportControllerSliderSize > 0) { innerHolder.setDividerLocation(reportControllerSliderSize); } outerReportControllerHolder.add(toolbarHolder, BorderLayout.NORTH); outerReportControllerHolder.add(innerHolder, BorderLayout.CENTER); } else { final JPanel reportPaneHolder = new JPanel(); reportPaneHolder.setOpaque(false); reportPaneHolder.setLayout(new BorderLayout()); reportPaneHolder.add(toolbarHolder, BorderLayout.NORTH); reportPaneHolder.add(reportPaneScrollPane, BorderLayout.CENTER); final JSplitPane innerHolder = new JSplitPane(); if (BorderLayout.SOUTH.equals(reportControllerLocation)) { innerHolder.setOrientation(JSplitPane.VERTICAL_SPLIT); innerHolder.setTopComponent(reportPaneHolder); innerHolder.setBottomComponent(reportControllerComponent); } else if (BorderLayout.EAST.equals(reportControllerLocation)) { innerHolder.setOrientation(JSplitPane.HORIZONTAL_SPLIT); innerHolder.setLeftComponent(reportPaneHolder); innerHolder.setRightComponent(reportControllerComponent); } else if (BorderLayout.WEST.equals(reportControllerLocation)) { innerHolder.setOrientation(JSplitPane.HORIZONTAL_SPLIT); innerHolder.setRightComponent(reportPaneHolder); innerHolder.setLeftComponent(reportControllerComponent); } else { innerHolder.setOrientation(JSplitPane.VERTICAL_SPLIT); innerHolder.setBottomComponent(reportPaneHolder); innerHolder.setTopComponent(reportControllerComponent); } if (reportControllerSliderSize > 0) { innerHolder.setDividerLocation(reportControllerSliderSize); } outerReportControllerHolder.add(innerHolder, BorderLayout.CENTER); } } } }
From source file:org.pentaho.reporting.engine.classic.demo.util.CompoundDemoFrame.java
protected JComponent createDefaultDemoPane(final InternalDemoHandler demoHandler) { final JPanel content = new JPanel(new BorderLayout()); content.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); final URL url = demoHandler.getDemoDescriptionSource(); final JComponent scroll = createDescriptionTextPane(url); final JButton previewButton = new JButton(getPreviewAction()); final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(scroll);//from w ww . ja v a2 s. co m splitPane.setBottomComponent(demoHandler.getPresentationComponent()); splitPane.setDividerLocation(200); splitPane.setOneTouchExpandable(true); content.add(splitPane, BorderLayout.CENTER); content.add(previewButton, BorderLayout.SOUTH); return content; }
From source file:pcgen.gui2.dialog.ChooserDialog.java
private void initComponents() { setTitle(chooser.getName());/*ww w. j ava2s. c om*/ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { //detach listeners from the chooser treeViewModel.setDelegate(null); listModel.setListFacade(null); chooser.getRemainingSelections().removeReferenceListener(ChooserDialog.this); } }); Container pane = getContentPane(); pane.setLayout(new BorderLayout()); JSplitPane split = new JSplitPane(); JPanel leftPane = new JPanel(new BorderLayout()); if (availTable != null) { availTable.setAutoCreateRowSorter(true); availTable.setTreeViewModel(treeViewModel); availTable.getRowSorter().toggleSortOrder(0); availTable.addActionListener(this); leftPane.add(new JScrollPane(availTable), BorderLayout.CENTER); } else { availInput.addActionListener(this); Dimension maxDim = new Dimension(Integer.MAX_VALUE, availInput.getPreferredSize().height); availInput.setMaximumSize(maxDim); JPanel availPanel = new JPanel(); availPanel.setLayout(new BoxLayout(availPanel, BoxLayout.PAGE_AXIS)); availPanel.add(Box.createRigidArea(new Dimension(10, 30))); availPanel.add(Box.createVerticalGlue()); availPanel.add(new JLabel(LanguageBundle.getString("in_uichooser_value"))); availPanel.add(availInput); availPanel.add(Box.createVerticalGlue()); leftPane.add(availPanel, BorderLayout.WEST); } JPanel buttonPane1 = new JPanel(new FlowLayout()); JButton addButton = new JButton(chooser.getAddButtonName()); addButton.setActionCommand("ADD"); addButton.addActionListener(this); buttonPane1.add(addButton); buttonPane1.add(new JLabel(Icons.Forward16.getImageIcon())); leftPane.add(buttonPane1, BorderLayout.SOUTH); split.setLeftComponent(leftPane); JPanel rightPane = new JPanel(new BorderLayout()); JPanel labelPane = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; labelPane.add(new JLabel(chooser.getSelectionCountName()), new GridBagConstraints()); remainingLabel.setText(chooser.getRemainingSelections().get().toString()); labelPane.add(remainingLabel, gbc); labelPane.add(new JLabel(chooser.getSelectedTableTitle()), gbc); rightPane.add(labelPane, BorderLayout.NORTH); list.setModel(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.addActionListener(this); rightPane.add(new JScrollPane(list), BorderLayout.CENTER); JPanel buttonPane2 = new JPanel(new FlowLayout()); buttonPane2.add(new JLabel(Icons.Back16.getImageIcon())); JButton removeButton = new JButton(chooser.getRemoveButtonName()); removeButton.setActionCommand("REMOVE"); removeButton.addActionListener(this); buttonPane2.add(removeButton); rightPane.add(buttonPane2, BorderLayout.SOUTH); split.setRightComponent(rightPane); if (chooser.isInfoAvailable()) { JSplitPane infoSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT); infoSplit.setTopComponent(split); infoSplit.setBottomComponent(infoPane); infoSplit.setResizeWeight(0.8); pane.add(infoSplit, BorderLayout.CENTER); if (availTable != null) { availTable.getSelectionModel().addListSelectionListener(this); } } else { pane.add(split, BorderLayout.CENTER); } JPanel bottomPane = new JPanel(new FlowLayout()); JButton button = new JButton(LanguageBundle.getString("in_ok")); //$NON-NLS-1$ button.setMnemonic(LanguageBundle.getMnemonic("in_mn_ok")); //$NON-NLS-1$ button.setActionCommand("OK"); button.addActionListener(this); bottomPane.add(button); button = new JButton(LanguageBundle.getString("in_cancel")); //$NON-NLS-1$ button.setMnemonic(LanguageBundle.getMnemonic("in_mn_cancel")); //$NON-NLS-1$ button.setActionCommand("CANCEL"); button.addActionListener(this); bottomPane.add(button); pane.add(bottomPane, BorderLayout.SOUTH); }
From source file:ro.nextreports.designer.querybuilder.QueryBuilderPanel.java
private void initUI() { JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.setDividerLocation(250);/*from w w w . j a va 2 s .c o m*/ split.setOneTouchExpandable(true); JToolBar toolBar = new JToolBar(); toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // hide buttons borders toolBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); toolBar.setBorderPainted(false); // add refresh action toolBar.add(new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("refresh"); } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) { return I18NSupport.getString("querybuilder.refresh"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { try { if (Globals.getConnection() == null) { return; } // refresh tables, views, procedures TreeUtil.refreshDatabase(); // add new queries to tree TreeUtil.refreshQueries(); // add new reports to tree TreeUtil.refreshReports(); // add new charts to tree TreeUtil.refreshCharts(); } catch (Exception ex) { Show.error(ex); } } }); // add expand action toolBar.add(new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("expandall"); } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) { return I18NSupport.getString("querybuilder.expand.all"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { TreeUtil.expandAll(dbBrowserTree); } }); // add collapse action toolBar.add(new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("collapseall"); } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) { return I18NSupport.getString("querybuilder.collapse.all"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { TreeUtil.collapseAll(dbBrowserTree); } }); // add properties button /* JButton propButton = new MagicButton(new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("properties"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { DBBrowserPropertiesPanel joinPanel = new DBBrowserPropertiesPanel(); JDialog dlg = new DBBrowserPropertiesDialog(joinPanel); dlg.pack(); dlg.setResizable(false); Show.centrateComponent(Globals.getMainFrame(), dlg); dlg.setVisible(true); } }); propButton.setToolTipText(I18NSupport.getString("querybuilder.properties")); */ //browserButtonsPanel.add(propButton); // ro.nextreports.designer.util.SwingUtil.registerButtonsForFocus(browserButtonsPanel); browserPanel = new JXPanel(new BorderLayout()); browserPanel.add(toolBar, BorderLayout.NORTH); // browser tree JScrollPane scroll = new JScrollPane(dbBrowserTree); browserPanel.add(scroll, BorderLayout.CENTER); split.setLeftComponent(browserPanel); tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM); // tabbedPane.putClientProperty(Options.EMBEDDED_TABS_KEY, Boolean.TRUE); // look like eclipse JSplitPane split2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split2.setResizeWeight(0.66); split2.setOneTouchExpandable(true); // desktop pane desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); desktop.setDropTarget( new DropTarget(desktop, DnDConstants.ACTION_MOVE, new DesktopPaneDropTargetListener(), true)); // create the toolbar JToolBar toolBar2 = new JToolBar(); toolBar2.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // hide buttons borders toolBar2.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); toolBar2.setBorderPainted(false); Action distinctAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (distinctButton.isSelected()) { selectQuery.setDistinct(true); } else { selectQuery.setDistinct(false); } } }; distinctAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("query.distinct")); distinctAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("querybuilder.distinct")); toolBar2.add(distinctButton = new JToggleButton(distinctAction)); Action groupByAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { groupBy = groupByButton.isSelected(); Globals.getEventBus().publish(new GroupByEvent(QueryBuilderPanel.this.desktop, groupBy)); } }; groupByAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("query.group_by")); groupByAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("querybuilder.group.by")); toolBar2.add(groupByButton = new JToggleButton(groupByAction)); Action clearAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { clear(false); } }; clearAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("clear")); clearAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("querybuilder.clear")); toolBar2.add(clearAction); // add separator SwingUtil.addCustomSeparator(toolBar2); // add run button Action runQueryAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { selectSQLViewTab(); sqlView.doRun(); } }; runQueryAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("run")); KeyStroke ks = KeyStroke.getKeyStroke(ShortcutsUtil.getShortcut("query.run.accelerator", "control 4")); runQueryAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("run.query") + " (" + ShortcutsUtil.getShortcut("query.run.accelerator.display", "Ctrl 4") + ")"); runQueryAction.putValue(Action.ACCELERATOR_KEY, ks); toolBar2.add(runQueryAction); // register run query shortcut GlobalHotkeyManager hotkeyManager = GlobalHotkeyManager.getInstance(); InputMap inputMap = hotkeyManager.getInputMap(); ActionMap actionMap = hotkeyManager.getActionMap(); inputMap.put((KeyStroke) runQueryAction.getValue(Action.ACCELERATOR_KEY), "runQueryAction"); actionMap.put("runQueryAction", runQueryAction); JScrollPane scroll2 = new JScrollPane(desktop, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scroll2.setPreferredSize(DBTablesDesktopPane.PREFFERED_SIZE); DecoratedScrollPane.decorate(scroll2); JPanel topPanel = new JPanel(); topPanel.setLayout(new GridBagLayout()); topPanel.add(toolBar2, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); topPanel.add(scroll2, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); split2.setTopComponent(topPanel); designPanel = new DesignerTablePanel(selectQuery); split2.setBottomComponent(designPanel); split2.setDividerLocation(400); tabbedPane.addTab(I18NSupport.getString("querybuilder.query.designer"), ImageUtil.getImageIcon("designer"), split2); tabbedPane.setMnemonicAt(0, 'D'); sqlView = new SQLViewPanel(); sqlView.getEditorPane().setDropTarget(new DropTarget(sqlView.getEditorPane(), DnDConstants.ACTION_MOVE, new SQLViewDropTargetListener(), true)); tabbedPane.addTab(I18NSupport.getString("querybuilder.query.editor"), ImageUtil.getImageIcon("sql"), sqlView); tabbedPane.setMnemonicAt(1, 'E'); split.setRightComponent(tabbedPane); // register a change listener tabbedPane.addChangeListener(new ChangeListener() { // this method is called whenever the selected tab changes public void stateChanged(ChangeEvent ev) { if (ev.getSource() == QueryBuilderPanel.this.tabbedPane) { // get current tab int sel = QueryBuilderPanel.this.tabbedPane.getSelectedIndex(); if (sel == 1) { // sql view String query; if (!synchronizedPanels) { query = sqlView.getQueryString(); synchronizedPanels = true; } else { if (Globals.getConnection() != null) { query = getSelectQuery().toString(); } else { query = ""; } // if (query.equals("")) { // query = sqlView.getQueryString(); // } } if (resetTable) { sqlView.clear(); resetTable = false; } //System.out.println("query="+query); sqlView.setQueryString(query); } else if (sel == 0) { // design view if (queryWasModified(false)) { Object[] options = { I18NSupport.getString("optionpanel.yes"), I18NSupport.getString("optionpanel.no") }; String m1 = I18NSupport.getString("querybuilder.lost"); String m2 = I18NSupport.getString("querybuilder.continue"); int option = JOptionPane.showOptionDialog(Globals.getMainFrame(), "<HTML>" + m1 + "<BR>" + m2 + "</HTML>", I18NSupport.getString("querybuilder.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); if (option != JOptionPane.YES_OPTION) { synchronizedPanels = false; tabbedPane.setSelectedIndex(1); } else { resetTable = true; } } } else if (sel == 2) { // report view } } } }); // this.add(split, BorderLayout.CENTER); parametersPanel = new ParametersPanel(); }