List of usage examples for javax.swing JSplitPane setOneTouchExpandable
@BeanProperty(description = "UI widget on the divider to quickly expand/collapse the divider.") public void setOneTouchExpandable(boolean newValue)
oneTouchExpandable
property, which must be true
for the JSplitPane
to provide a UI widget on the divider to quickly expand/collapse the divider. From source file:org.roche.antibody.ui.components.AntibodyEditorPane.java
/** * initates swing component/*from www .java 2 s . c o m*/ */ private void initComponents() { abstractGraphLayouter = AbstractGraphLayoutService.createLayouter(); this.abstractAntibodyView = new Graph2DView(); this.abstractAntibodyView.setFitContentOnResize(true); editMode = new AntibodyEditMode(this); abstractAntibodyView.addViewMode(editMode); // enable bridges for PolyLineEdgeRealizer BridgeCalculator bridgeCalculator = new BridgeCalculator(); bridgeCalculator.setCrossingMode(BridgeCalculator.CROSSING_MODE_HORIZONTAL_CROSSES_VERTICAL); ((DefaultGraph2DRenderer) abstractAntibodyView.getGraph2DRenderer()).setBridgeCalculator(bridgeCalculator); configureKeyboardActions(); this.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { super.componentShown(e); LOG.debug("Call componentShown of: {}", this.getClass().getName()); updateGraphLayout(); } }); this.setLayout(new BorderLayout()); // --- START Graphical Representation of Antybody (Center Panel) JSplitPane pnlSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); pnlSplit.setOneTouchExpandable(true); this.add(pnlSplit, BorderLayout.CENTER); pnlSplit.setLeftComponent(abstractAntibodyView); pnlSplit.setResizeWeight(1); // --- START Property Table, HELM Notation etc. (Right Panel) pnlEast = new JSplitPane(JSplitPane.VERTICAL_SPLIT); pnlEast.setBorder(DEFAULT_BORDER); pnlEast.setResizeWeight(0.65); antibodyPropertyModel = new DomainTableModel(); antibodyPropertyModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { abstractGraph.updateViews(); } }); propertyTable = new JTable(antibodyPropertyModel); propertyTable.setDefaultRenderer(Object.class, new DomainTableCellRenderer()); JScrollPane spnlPropertyTable = new JScrollPane(propertyTable); pnlEast.setTopComponent(spnlPropertyTable); pnlSplit.setRightComponent(pnlEast); // graphical preview graphicsPane = new JPanel(new BorderLayout()); anotherView = new Graph2DView(); graphicsPane.add(anotherView, BorderLayout.CENTER); // Tabcontainer for graphic and helm notation preview tabbedPane = new JTabbedPane(JTabbedPane.TOP); // --- HELM notation Preview Panel helmPreviewPane = new JPanel(); helmPreviewPane.setLayout(new BorderLayout()); tabbedPane.addTab("HELM Notation Preview", null, helmPreviewPane, null); // --- Button Panel for HELM notation preview JPanel pnlButtons = new JPanel(new FlowLayout(FlowLayout.RIGHT)); cmdSaveAsXml = new JButton("Save Antibody", new ImageIcon(ResourceProvider.getInstance().get(ResourceProvider.DISK_IMAGE))); cmdSaveAsXml.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { XmlFileChooser dialog = new XmlFileChooser(); if (dialog.showSaveDialog(mainEditor.getFrame()) == JFileChooser.APPROVE_OPTION) { File abFile = dialog.getSelectedFile(); String newPath = FilenameUtils.removeExtension(abFile.getAbsolutePath()); abFile = new File(newPath + AntibodyFileChooser.XML_EXTENSION); AntibodyContainer abContainer = new AntibodyContainer(); try { antibody.setDomainLibraryPath(ConfigFileService.getInstance().getDomainLibFilename()); // PreferencesService.getInstance().getDomainLibraryFile().getAbsolutePath()); abContainer.setAntibody(antibody); abContainer.setHelmCode(helmTextArea.getText()); xmlService.marshal(abContainer, abFile); } catch (JAXBException e1) { JOptionPane.showMessageDialog(mainEditor.getFrame(), "Could not save Antibody! Please try again", "Error", JOptionPane.ERROR_MESSAGE); LOG.error("Could not save Antibody-XML to disk! {}", e1); } } } }); pnlButtons.add(cmdSaveAsXml); cmdLoadFromXml = new JButton("Load Antibody", new ImageIcon(ResourceProvider.getInstance().get(ResourceProvider.OPEN_FOLDER))); cmdLoadFromXml.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { XmlFileChooser dialog = new XmlFileChooser(); if (dialog.showOpenDialog(mainEditor.getFrame()) == JFileChooser.APPROVE_OPTION) { File abFile = dialog.getSelectedFile(); try { AntibodyContainer newAbContainer = xmlService.unmarshal(abFile); setModel(newAbContainer.getAntibody()); } catch (JAXBException e1) { JOptionPane.showMessageDialog(mainEditor.getFrame(), "Could not load Antibody! Please try again", "Error", JOptionPane.ERROR_MESSAGE); LOG.error("Could not load Antibody-XML to disk! {}", e1); } } } }); pnlButtons.add(cmdLoadFromXml); helmPreviewPane.add(pnlButtons, BorderLayout.SOUTH); pnlEast.setBottomComponent(tabbedPane); // --- HELM Notation Text Area helmTextArea = new JTextArea(); helmTextArea.setLineWrap(true); JScrollPane spnlHELMTextArea = new JScrollPane(helmTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); helmPreviewPane.add(spnlHELMTextArea, BorderLayout.CENTER); }
From source file:phex.gui.tabs.library.LibraryTab.java
public void initComponent(XJBGUISettings guiSettings) { CellConstraints cc = new CellConstraints(); FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "2dlu, fill:p:grow, 2dlu"); //rows PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this); JPanel contentPanel = new JPanel(); FWElegantPanel elegantPanel = new FWElegantPanel(Localizer.getString("Library"), contentPanel); tabBuilder.add(elegantPanel, cc.xy(2, 2)); FormLayout contentLayout = new FormLayout("fill:d:grow", // columns "fill:d:grow"); //rows PanelBuilder contentBuilder = new PanelBuilder(contentLayout, contentPanel); MouseHandler mouseHandler = new MouseHandler(); JPanel treePanel = createTreePanel(mouseHandler); JPanel tablePanel = createTablePanel(guiSettings, mouseHandler); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePanel, tablePanel); splitPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); splitPane.setDividerSize(4);/*from w ww.j a v a2s .c om*/ splitPane.setOneTouchExpandable(false); contentBuilder.add(splitPane, cc.xy(1, 1)); sharedFilesLabel = new JLabel(" "); sharedFilesLabel.setHorizontalAlignment(JLabel.RIGHT); elegantPanel.addHeaderPanelComponent(sharedFilesLabel, BorderLayout.EAST); ShareManager.getInstance().getSharedFilesService() .addSharedFilesChangeListener(new SharedFilesChangeHandler()); fileTreePopup = new FWPopupMenu(); fileTablePopup = new FWPopupMenu(); FWAction action; action = getTabAction(ADD_SHARE_FOLDER_ACTION_KEY); fileTreePopup.addAction(action); action = getTabAction(REMOVE_SHARE_FOLDER_ACTION_KEY); fileTreePopup.addAction(action); if (SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_MAC_OSX) { action = getTabAction(EXPLORE_FOLDER_ACTION_KEY); fileTreePopup.addAction(action); } action = getTabAction(OPEN_FILE_ACTION_KEY); fileTablePopup.addAction(action); action = getTabAction(VIEW_BITZI_ACTION_KEY); fileTablePopup.addAction(action); fileTablePopup.addSeparator(); fileTreePopup.addSeparator(); action = getTabAction(RESCAN_ACTION_KEY); fileTablePopup.addAction(action); fileTreePopup.addAction(action); action = getTabAction(EXPORT_ACTION_KEY); fileTablePopup.addAction(action); fileTreePopup.addAction(action); action = getTabAction(FILTER_ACTION_KEY); fileTablePopup.addAction(action); fileTreePopup.addAction(action); }
From source file:pl.otros.logview.gui.Log4jPatternParserEditor.java
private void createGui() { this.setLayout(new BorderLayout()); heading1Font = new JLabel().getFont().deriveFont(20f).deriveFont(Font.BOLD); heading2Font = new JLabel().getFont().deriveFont(14f).deriveFont(Font.BOLD); loadLog = new JButton("Load log", Icons.FOLDER_OPEN); testParser = new JButton("Test parser", Icons.WRENCH_ARROW); saveParser = new JButton("Save", Icons.DISK); logFileContent = new JTextArea(); DefaultSyntaxKit.initKit();/*from w ww . j a v a 2 s.co m*/ propertyEditor = new JEditorPane(); logFileContent = new JTextArea(); logViewPanel = new LogViewPanel(new LogDataTableModel(), TableColumns.ALL_WITHOUT_LOG_SOURCE, otrosApplication); JPanel panelEditorActions = new JPanel(new BorderLayout(5, 5)); JToolBar actionsToolBar = new JToolBar("Actions"); actionsToolBar.setFloatable(false); actionsToolBar.add(testParser); actionsToolBar.add(saveParser); JToolBar propertyEditorToolbar = new JToolBar(); JLabel labelEditProperties = new JLabel("Edit your properties: and test parser"); labelEditProperties.setFont(heading2Font); propertyEditorToolbar.add(labelEditProperties); panelEditorActions.add(propertyEditorToolbar, BorderLayout.NORTH); panelEditorActions.add(actionsToolBar, BorderLayout.SOUTH); panelEditorActions.add(new JScrollPane(propertyEditor)); logFileContentLabel = new JLabel(" Load your log file, paste from clipboard or drag and drop file. "); JToolBar loadToolbar = new JToolBar(); loadToolbar.add(logFileContentLabel); loadToolbar.add(loadLog); logFileContentLabel.setFont(heading2Font); JPanel logContentPanel = new JPanel(new BorderLayout(5, 5)); logContentPanel.add(new JScrollPane(logFileContent)); logContentPanel.add(loadToolbar, BorderLayout.NORTH); JSplitPane northSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); northSplit.setOneTouchExpandable(true); northSplit.add(logContentPanel); northSplit.add(panelEditorActions); JPanel southPanel = new JPanel(new BorderLayout(5, 5)); JLabel labelParsingResult = new JLabel(" Parsing result:"); labelParsingResult.setFont(heading1Font); southPanel.add(labelParsingResult, BorderLayout.NORTH); southPanel.add(logViewPanel); JSplitPane mainSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT); mainSplit.setOneTouchExpandable(true); mainSplit.add(northSplit); mainSplit.add(southPanel); mainSplit.setDividerLocation(0.5f); add(mainSplit); propertyEditor.setContentType("text/properties"); }
From source file:pl.otros.logview.gui.LogViewPanel.java
public LogViewPanel(final LogDataTableModel dataTableModel, TableColumns[] visibleColumns, final OtrosApplication otrosApplication) { super();//w w w . j a va2s .c om this.dataTableModel = dataTableModel; this.otrosApplication = otrosApplication; this.statusObserver = otrosApplication.getStatusObserver(); configuration = otrosApplication.getConfiguration(); AllPluginables allPluginable = AllPluginables.getInstance(); markersContainer = allPluginable.getMarkersContainser(); markersContainer.addListener(new MarkersMenuReloader()); logFiltersContainer = allPluginable.getLogFiltersContainer(); messageColorizersContainer = allPluginable.getMessageColorizers(); messageFormattersContainer = allPluginable.getMessageFormatters(); selectedMessageColorizersContainer = new PluginableElementsContainer<MessageColorizer>(); selectedMessageFormattersContainer = new PluginableElementsContainer<MessageFormatter>(); for (MessageColorizer messageColorizer : messageColorizersContainer.getElements()) { selectedMessageColorizersContainer.addElement(messageColorizer); } for (MessageFormatter messageFormatter : messageFormattersContainer.getElements()) { selectedMessageFormattersContainer.addElement(messageFormatter); } messageColorizersContainer.addListener( new SynchronizePluginableContainerListener<MessageColorizer>(selectedMessageColorizersContainer)); messageFormattersContainer.addListener( new SynchronizePluginableContainerListener<MessageFormatter>(selectedMessageFormattersContainer)); menuLabelFont = new JLabel().getFont().deriveFont(Font.BOLD); filtersPanel = new JPanel(); logsTablePanel = new JPanel(); logsMarkersPanel = new JPanel(); leftPanel = new JPanel(new MigLayout()); logDetailTextArea = new JTextPane(); logDetailTextArea.setEditable(false); MouseAdapter locationInfo = new LocationClickMouseAdapter(otrosApplication, logDetailTextArea); logDetailTextArea.addMouseMotionListener(locationInfo); logDetailTextArea.addMouseListener(locationInfo); logDetailTextArea.setBorder(BorderFactory.createTitledBorder("Details")); logDetailWithRulerScrollPane = RulerBarHelper.wrapTextComponent(logDetailTextArea); table = new JTableWith2RowHighliting(dataTableModel); // Initialize default column visible before creating context menu table.setColumnControlVisible(true); final ColumnControlButton columnControlButton = new ColumnControlButton(table) { @Override public void togglePopup() { populatePopup(); super.togglePopup(); } @Override protected List<Action> getAdditionalActions() { final List<Action> additionalActions = super.getAdditionalActions(); final AbstractAction saveLayout = new AbstractAction("Save current to new column layout", Icons.DISK) { @Override public void actionPerformed(ActionEvent actionEvent) { String newLayoutName = JOptionPane.showInputDialog(table, "New Layout name"); if (newLayoutName == null) { return; } newLayoutName = newLayoutName.trim(); LOGGER.info(String.format("Saving New column layout '%s'", newLayoutName)); ArrayList<String> visibleColNames = new ArrayList<String>(); for (TableColumn tc : table.getColumns()) { Object o = tc.getIdentifier(); if (!(o instanceof TableColumns)) { LOGGER.severe("TableColumn identifier of unexpected type: " + tc.getIdentifier().getClass().getName()); LOGGER.warning("Throw up a pop-up"); return; } TableColumns tcs = (TableColumns) o; visibleColNames.add(tcs.getName()); } ColumnLayout columnLayout = new ColumnLayout(newLayoutName, visibleColNames); final List<ColumnLayout> columnLayouts = LogTableFormatConfigView .loadColumnLayouts(configuration); columnLayouts.add(columnLayout); LogTableFormatConfigView.saveColumnLayouts(columnLayouts, configuration); populatePopup(); } }; additionalActions.add(saveLayout); final List<ColumnLayout> columnLayoutNames = LogTableFormatConfigView .loadColumnLayouts(configuration); for (final ColumnLayout columnLayout : columnLayoutNames) { final String name = columnLayout.getName(); final AbstractAction applyColumnLayout = new ApplyColumnLayoutAction(name, Icons.EDIT_COLUMNS, columnLayout, table); additionalActions.add(applyColumnLayout); } return additionalActions; } }; table.setColumnControl(columnControlButton); List<TableColumn> columns = table.getColumns(true); for (int i = 0; i < columns.size(); i++) { columns.get(i).setIdentifier(TableColumns.getColumnById(i)); } for (TableColumn tableColumn : columns) { table.getColumnExt(tableColumn.getIdentifier()).setVisible(false); } for (TableColumns tableColumns : visibleColumns) { table.getColumnExt(tableColumns).setVisible(true); } table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); updateColumnsSize(); table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); final Renderers renderers = Renderers.getInstance(otrosApplication); table.setDefaultRenderer(String.class, new TableMarkDecoratorRenderer(renderers.getStringRenderer())); table.setDefaultRenderer(Object.class, new TableMarkDecoratorRenderer(table.getDefaultRenderer(Object.class))); table.setDefaultRenderer(Integer.class, new TableMarkDecoratorRenderer(table.getDefaultRenderer(Object.class))); table.setDefaultRenderer(Level.class, new TableMarkDecoratorRenderer(renderers.getLevelRenderer())); table.setDefaultRenderer(Date.class, new TableMarkDecoratorRenderer(renderers.getDateRenderer())); final TimeDeltaRenderer timeDeltaRenderer = new TimeDeltaRenderer(); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent listSelectionEvent) { final int[] selectedRows = table.getSelectedRows(); if (selectedRows.length > 0) { final int selectedRow = selectedRows[selectedRows.length - 1]; final Date selectedDate = dataTableModel.getLogData(table.convertRowIndexToModel(selectedRow)) .getDate(); timeDeltaRenderer.setSelectedTimestamp(selectedDate); table.repaint(); } } }); table.setDefaultRenderer(TimeDelta.class, new TableMarkDecoratorRenderer(timeDeltaRenderer)); ((EventSource) configuration.getConfiguration()).addConfigurationListener(new ConfigurationListener() { @Override public void configurationChanged(ConfigurationEvent ce) { if (ce.getType() == AbstractConfiguration.EVENT_SET_PROPERTY && !ce.isBeforeUpdate()) { if (ce.getPropertyName().equals(ConfKeys.LOG_TABLE_FORMAT_DATE_FORMAT)) { table.setDefaultRenderer(Date.class, new TableMarkDecoratorRenderer(new DateRenderer( configuration.getString(ConfKeys.LOG_TABLE_FORMAT_DATE_FORMAT, "HH:mm:ss.SSS")))); updateTimeColumnSize(); } else if (ce.getPropertyName().equals(ConfKeys.LOG_TABLE_FORMAT_LEVEL_RENDERER)) { table.setDefaultRenderer(Level.class, new TableMarkDecoratorRenderer(new LevelRenderer(configuration.get( LevelRenderer.Mode.class, ConfKeys.LOG_TABLE_FORMAT_LEVEL_RENDERER, LevelRenderer.Mode.IconsOnly)))); updateLevelColumnSize(); } } } }); table.setDefaultRenderer(Boolean.class, new TableMarkDecoratorRenderer(table.getDefaultRenderer(Boolean.class))); table.setDefaultRenderer(Note.class, new TableMarkDecoratorRenderer(new NoteRenderer())); table.setDefaultRenderer(MarkerColors.class, new TableMarkDecoratorRenderer(new MarkTableRenderer())); table.setDefaultEditor(Note.class, new NoteTableEditor()); table.setDefaultEditor(MarkerColors.class, new MarkTableEditor(otrosApplication)); table.setDefaultRenderer(ClassWrapper.class, new TableMarkDecoratorRenderer(renderers.getClassWrapperRenderer())); sorter = new TableRowSorter<LogDataTableModel>(dataTableModel); for (int i = 0; i < dataTableModel.getColumnCount(); i++) { sorter.setSortable(i, false); } sorter.setSortable(TableColumns.ID.getColumn(), true); sorter.setSortable(TableColumns.TIME.getColumn(), true); table.setRowSorter(sorter); messageDetailListener = new MessageDetailListener(this, dateFormat, selectedMessageFormattersContainer, selectedMessageColorizersContainer); table.getSelectionModel().addListSelectionListener(messageDetailListener); dataTableModel.addNoteObserver(messageDetailListener); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { boolean hasFocus = otrosApplication.getApplicationJFrame().isFocused(); final boolean enabled = otrosApplication.getConfiguration() .getBoolean(ConfKeys.JUMP_TO_CODE_AUTO_JUMP_ENABLED, false); if (hasFocus && enabled && !e.getValueIsAdjusting()) { try { final LogData logData = dataTableModel .getLogData(table.convertRowIndexToModel(e.getFirstIndex())); LocationInfo li = new LocationInfo(logData.getClazz(), logData.getMethod(), logData.getFile(), Integer.valueOf(logData.getLine())); final JumpToCodeService jumpToCodeService = otrosApplication.getServices() .getJumpToCodeService(); final boolean ideAvailable = jumpToCodeService.isIdeAvailable(); if (ideAvailable) { LOGGER.fine("Jumping to " + li); jumpToCodeService.jump(li); } } catch (Exception e1) { LOGGER.warning("Can't perform jump to code " + e1.getMessage()); } } } }); notes = new JTextArea(); notes.setEditable(false); NoteObserver allNotesObserver = new AllNotesTextAreaObserver(notes); dataTableModel.addNoteObserver(allNotesObserver); addFiltersGUIsToPanel(filtersPanel); logsTablePanel.setLayout(new BorderLayout()); logsTablePanel.add(new JScrollPane(table)); JPanel messageDetailsPanel = new JPanel(new BorderLayout()); messageDetailToolbar = new JToolBar("MessageDetail"); messageDetailsPanel.add(messageDetailToolbar, BorderLayout.NORTH); messageDetailsPanel.add(logDetailWithRulerScrollPane); initMessageDetailsToolbar(); jTabbedPane = new JTabbedPane(); jTabbedPane.add("Message detail", messageDetailsPanel); jTabbedPane.add("All notes", new JScrollPane(notes)); leftPanel.add(filtersPanel, "wrap, growx"); leftPanel.add(new JSeparator(SwingConstants.HORIZONTAL), "wrap,growx"); leftPanel.add(logsMarkersPanel, "wrap,growx"); JSplitPane splitPaneLogsTableAndDetails = new JSplitPane(JSplitPane.VERTICAL_SPLIT, logsTablePanel, jTabbedPane); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), splitPaneLogsTableAndDetails); splitPane.setOneTouchExpandable(true); this.setLayout(new BorderLayout()); this.add(splitPane); splitPaneLogsTableAndDetails.setDividerLocation(0.5d); splitPaneLogsTableAndDetails.setOneTouchExpandable(true); splitPane.setDividerLocation(leftPanel.getPreferredSize().width + 10); PopupListener popupListener = new PopupListener(new Callable<JPopupMenu>() { @Override public JPopupMenu call() throws Exception { return initTableContextMenu(); } }); table.addMouseListener(popupListener); table.addKeyListener(popupListener); PopupListener popupListenerMessageDetailMenu = new PopupListener(new Callable<JPopupMenu>() { @Override public JPopupMenu call() throws Exception { return initMessageDetailPopupMenu(); } }); logDetailTextArea.addMouseListener(popupListenerMessageDetailMenu); logDetailTextArea.addKeyListener(popupListenerMessageDetailMenu); dataTableModel.notifyAllNoteObservers(new NoteEvent(EventType.CLEAR, dataTableModel, null, 0)); table.addKeyListener(new MarkRowBySpaceKeyListener(otrosApplication)); initAcceptConditions(); }
From source file:pl.otros.logview.gui.message.editor.MessageColorizerEditor.java
public MessageColorizerEditor(PluginableElementsContainer<MessageColorizer> container, StatusObserver observer) {/*from w ww. j a v a2 s . c om*/ this.container = container; statusObserver = observer; this.setLayout(new BorderLayout()); DefaultSyntaxKit.initKit(); editorPane = new JEditorPane(); JScrollPane comp = new JScrollPane(editorPane); JLabel propertyEditorLabel = new JLabel("Enter you message colorizer properties"); editorPane.setContentType("text/properties"); label = new JLabel(); String defaultContent = getDefaultContent(); try { editorPane.getDocument().insertString(0, defaultContent, null); } catch (BadLocationException e1) { LOGGER.severe(String.format("Can't set text: %s", e1.getMessage())); } deleyedSwingInvoke = new DelayedSwingInvoke() { @Override protected void performActionHook() { refreshView(); } }; DocumentListener documentListener = new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { deleyedSwingInvoke.performAction(); } @Override public void insertUpdate(DocumentEvent e) { deleyedSwingInvoke.performAction(); } @Override public void changedUpdate(DocumentEvent e) { } }; editorPane.getDocument().addDocumentListener(documentListener); JLabel textPaneLabel = new JLabel("Enter log message body"); textPane = new JTextPane(); textPane.getDocument().addDocumentListener(documentListener); JPanel north = new JPanel(new BorderLayout()); north.add(propertyEditorLabel, BorderLayout.NORTH); north.add(comp); JPanel south = new JPanel(new BorderLayout()); south.add(textPaneLabel, BorderLayout.NORTH); south.add(new JScrollPane(textPane)); JSplitPane jSplitPaneEditors = new JSplitPane(SwingConstants.HORIZONTAL, north, south); jSplitPaneEditors.setOneTouchExpandable(true); jSplitPaneEditors.setDividerLocation(0.5d); this.add(jSplitPaneEditors); this.add(label, BorderLayout.SOUTH); }
From source file:pl.otros.vfs.browser.VfsBrowser.java
License:asdf
private void initGui(final String initialPath) { this.setLayout(new BorderLayout()); JLabel pathLabel = new JLabel(Messages.getMessage("browser.location")); pathLabel.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 3)); pathField = new JTextField(80); pathField.setFont(pathLabel.getFont().deriveFont(pathLabel.getFont().getSize() * 1.2f)); pathField.setToolTipText(Messages.getMessage("nav.pathTooltip")); GuiUtils.addBlinkOnFocusGain(pathField); pathLabel.setLabelFor(pathField);//from w w w. ja v a 2 s. c om pathLabel.setDisplayedMnemonic(Messages.getMessage("browser.location.mnemonic").charAt(0)); InputMap inputMapPath = pathField.getInputMap(JComponent.WHEN_FOCUSED); inputMapPath.put(KeyStroke.getKeyStroke("ENTER"), "OPEN_PATH"); inputMapPath.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), ACTION_FOCUS_ON_TABLE); pathField.getActionMap().put("OPEN_PATH", new BaseNavigateAction(this) { @Override protected void performLongOperation(CheckBeforeActionResult actionResult) { try { FileObject resolveFile = VFSUtils.resolveFileObject(pathField.getText().trim()); if (resolveFile != null && resolveFile.getType() == FileType.FILE) { loadAndSelSingleFile(resolveFile); pathField.setText(resolveFile.getURL().toString()); actionApproveDelegate.actionPerformed( // TODO: Does actionResult provide an ID for 2nd param here, // or should use a Random number? new ActionEvent(actionResult, (int) new java.util.Date().getTime(), "SELECTED_FILE")); return; } } catch (FileSystemException fse) { // Intentionally empty } goToUrl(pathField.getText().trim()); } @Override protected boolean canGoUrl() { return true; } @Override protected boolean canExecuteDefaultAction() { return false; } }); actionFocusOnTable = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { tableFiles.requestFocusInWindow(); if (tableFiles.getSelectedRow() < 0 && tableFiles.getRowCount() == 0) { tableFiles.getSelectionModel().setSelectionInterval(0, 0); } } }; pathField.getActionMap().put(ACTION_FOCUS_ON_TABLE, actionFocusOnTable); BaseNavigateActionGoUp goUpAction = new BaseNavigateActionGoUp(this); goUpButton = new JButton(goUpAction); BaseNavigateActionRefresh refreshAction = new BaseNavigateActionRefresh(this); JButton refreshButton = new JButton(refreshAction); JToolBar upperPanel = new JToolBar(Messages.getMessage("nav.ToolBarName")); upperPanel.setRollover(true); upperPanel.add(pathLabel); upperPanel.add(pathField, "growx"); upperPanel.add(goUpButton); upperPanel.add(refreshButton); AddCurrentLocationToFavoriteAction addCurrentLocationToFavoriteAction = new AddCurrentLocationToFavoriteAction( this); JButton addCurrentLocationToFavoriteButton = new JButton(addCurrentLocationToFavoriteAction); addCurrentLocationToFavoriteButton.setText(""); upperPanel.add(addCurrentLocationToFavoriteButton); previewComponent = new PreviewComponent(); vfsTableModel = new VfsTableModel(); tableFiles = new JTable(vfsTableModel); tableFiles.setFillsViewportHeight(true); tableFiles.getColumnModel().getColumn(0).setMinWidth(140); tableFiles.getColumnModel().getColumn(1).setMaxWidth(80); tableFiles.getColumnModel().getColumn(2).setMaxWidth(80); tableFiles.getColumnModel().getColumn(3).setMaxWidth(180); tableFiles.getColumnModel().getColumn(3).setMinWidth(120); sorter = new TableRowSorter<VfsTableModel>(vfsTableModel); final FileNameWithTypeComparator fileNameWithTypeComparator = new FileNameWithTypeComparator(); sorter.addRowSorterListener(new RowSorterListener() { @Override public void sorterChanged(RowSorterEvent e) { RowSorterEvent.Type type = e.getType(); if (type.equals(RowSorterEvent.Type.SORT_ORDER_CHANGED)) { List<? extends RowSorter.SortKey> sortKeys = e.getSource().getSortKeys(); for (RowSorter.SortKey sortKey : sortKeys) { if (sortKey.getColumn() == VfsTableModel.COLUMN_NAME) { fileNameWithTypeComparator.setSortOrder(sortKey.getSortOrder()); } } } } }); sorter.setComparator(VfsTableModel.COLUMN_NAME, fileNameWithTypeComparator); tableFiles.setRowSorter(sorter); tableFiles.setShowGrid(false); tableFiles.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { try { selectionChanged(); } catch (FileSystemException e1) { LOGGER.error("Error during update state", e); } } }); tableFiles.setColumnSelectionAllowed(false); vfsTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { updateStatusText(); } }); tableFiles.setDefaultRenderer(FileSize.class, new FileSizeTableCellRenderer()); tableFiles.setDefaultRenderer(FileNameWithType.class, new FileNameWithTypeTableCellRenderer()); tableFiles.setDefaultRenderer(Date.class, new MixedDateTableCellRenderer()); tableFiles.setDefaultRenderer(FileType.class, new FileTypeTableCellRenderer()); tableFiles.getSelectionModel().addListSelectionListener(new PreviewListener(this, previewComponent)); JPanel favoritesPanel = new JPanel(new MigLayout("wrap, fillx", "[grow]")); favoritesUserListModel = new MutableListModel<Favorite>(); List<Favorite> favSystemLocations = FavoritesUtils.getSystemLocations(); List<Favorite> favUser = FavoritesUtils.loadFromProperties(configuration); List<Favorite> favJVfsFileChooser = FavoritesUtils.getJvfsFileChooserBookmarks(); for (Favorite favorite : favUser) { favoritesUserListModel.add(favorite); } favoritesUserListModel.addListDataListener(new ListDataListener() { @Override public void intervalAdded(ListDataEvent e) { saveFavorites(); } @Override public void intervalRemoved(ListDataEvent e) { saveFavorites(); } @Override public void contentsChanged(ListDataEvent e) { saveFavorites(); } protected void saveFavorites() { FavoritesUtils.storeFavorites(configuration, favoritesUserListModel.getList()); } }); favoritesUserList = new JList(favoritesUserListModel); favoritesUserList.setTransferHandler(new MutableListDropHandler(favoritesUserList)); new MutableListDragListener(favoritesUserList); favoritesUserList.setCellRenderer(new FavoriteListCellRenderer()); favoritesUserList.addFocusListener(new SelectFirstElementFocusAdapter()); addOpenActionToList(favoritesUserList); addEditActionToList(favoritesUserList, favoritesUserListModel); favoritesUserList.getActionMap().put(ACTION_DELETE, new AbstractAction( Messages.getMessage("favorites.deleteButtonText"), Icons.getInstance().getMinusButton()) { @Override public void actionPerformed(ActionEvent e) { Favorite favorite = favoritesUserListModel.getElementAt(favoritesUserList.getSelectedIndex()); if (!Favorite.Type.USER.equals(favorite.getType())) { return; } int response = JOptionPane.showConfirmDialog(VfsBrowser.this, Messages.getMessage("favorites.areYouSureToDeleteConnections"), Messages.getMessage("favorites.confirm"), JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { favoritesUserListModel.remove(favoritesUserList.getSelectedIndex()); } } }); InputMap favoritesListInputMap = favoritesUserList.getInputMap(JComponent.WHEN_FOCUSED); favoritesListInputMap.put(KeyStroke.getKeyStroke("DELETE"), ACTION_DELETE); ActionMap actionMap = tableFiles.getActionMap(); actionMap.put(ACTION_OPEN, new BaseNavigateActionOpen(this)); actionMap.put(ACTION_GO_UP, goUpAction); actionMap.put(ACTION_APPROVE, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (actionApproveButton.isEnabled()) { actionApproveDelegate.actionPerformed(e); } } }); InputMap inputMap = tableFiles.getInputMap(JComponent.WHEN_FOCUSED); inputMap.put(KeyStroke.getKeyStroke("ENTER"), ACTION_OPEN); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_MASK), ACTION_APPROVE); inputMap.put(KeyStroke.getKeyStroke("BACK_SPACE"), ACTION_GO_UP); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), ACTION_GO_UP); addPopupMenu(favoritesUserList, ACTION_OPEN, ACTION_EDIT, ACTION_DELETE); JList favoriteSystemList = new JList(new Vector<Object>(favSystemLocations)); favoriteSystemList.setCellRenderer(new FavoriteListCellRenderer()); addOpenActionToList(favoriteSystemList); addPopupMenu(favoriteSystemList, ACTION_OPEN); favoriteSystemList.addFocusListener(new SelectFirstElementFocusAdapter()); JList favoriteJVfsList = new JList(new Vector<Object>(favJVfsFileChooser)); addOpenActionToList(favoriteJVfsList); favoriteJVfsList.setCellRenderer(new FavoriteListCellRenderer()); addPopupMenu(favoriteJVfsList, ACTION_OPEN); favoriteJVfsList.addFocusListener(new SelectFirstElementFocusAdapter()); JLabel favoritesSystemLocationsLabel = getTitleListLabel(Messages.getMessage("favorites.systemLocations"), COMPUTER_ICON); favoritesSystemLocationsLabel.setLabelFor(favoriteSystemList); favoritesSystemLocationsLabel .setDisplayedMnemonic(Messages.getMessage("favorites.systemLocations.mnemonic").charAt(0)); favoritesPanel.add(favoritesSystemLocationsLabel, "gapleft 16"); favoritesPanel.add(favoriteSystemList, "growx"); JLabel favoritesFavoritesLabel = getTitleListLabel(Messages.getMessage("favorites.favorites"), Icons.getInstance().getStar()); favoritesFavoritesLabel.setLabelFor(favoritesUserList); favoritesFavoritesLabel.setDisplayedMnemonic(Messages.getMessage("favorites.favorites.mnemonic").charAt(0)); favoritesPanel.add(favoritesFavoritesLabel, "gapleft 16"); favoritesPanel.add(favoritesUserList, "growx"); if (favoriteJVfsList.getModel().getSize() > 0) { JLabel favoritesJVfsFileChooser = getTitleListLabel( Messages.getMessage("favorites.JVfsFileChooserBookmarks"), null); favoritesJVfsFileChooser.setDisplayedMnemonic( Messages.getMessage("favorites.JVfsFileChooserBookmarks.mnemonic").charAt(0)); favoritesJVfsFileChooser.setLabelFor(favoriteJVfsList); favoritesPanel.add(favoritesJVfsFileChooser, "gapleft 16"); favoritesPanel.add(favoriteJVfsList, "growx"); } tableFiles.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { tableFiles.getActionMap().get(ACTION_OPEN).actionPerformed(null); } } }); tableFiles.addKeyListener(new QuickSearchKeyAdapter()); cardLayout = new CardLayout(); tablePanel = new JPanel(cardLayout); loadingProgressBar = new JProgressBar(); loadingProgressBar.setStringPainted(true); loadingProgressBar.setString(Messages.getMessage("browser.loading")); loadingProgressBar.setIndeterminate(true); loadingIconLabel = new JLabel(Icons.getInstance().getNetworkStatusOnline()); skipCheckingLinksButton = new JToggleButton(Messages.getMessage("browser.skipCheckingLinks")); skipCheckingLinksButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (taskContext != null) { taskContext.setStop(skipCheckingLinksButton.isSelected()); } } }); showHidCheckBox = new JCheckBox(Messages.getMessage("browser.showHidden.label"), showHidden); showHidCheckBox.setToolTipText(Messages.getMessage("browser.showHidden.tooltip")); showHidCheckBox.setMnemonic(Messages.getMessage("browser.showHidden.mnemonic").charAt(0)); Font tmpFont = showHidCheckBox.getFont(); showHidCheckBox.setFont(tmpFont.deriveFont(tmpFont.getSize() * 0.9f)); showHidCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateUiFilters(); } }); final String defaultFilterText = Messages.getMessage("browser.nameFilter.defaultText"); filterField = new JTextField("", 16); filterField.setForeground(filterField.getDisabledTextColor()); filterField.setToolTipText(Messages.getMessage("browser.nameFilter.tooltip")); PromptSupport.setPrompt(defaultFilterText, filterField); filterField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { documentChanged(); } void documentChanged() { if (filterField.getText().length() == 0) { updateUiFilters(); } } @Override public void removeUpdate(DocumentEvent e) { documentChanged(); } @Override public void changedUpdate(DocumentEvent e) { documentChanged(); } }); filterField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { updateUiFilters(); } }); AbstractAction actionClearRegexFilter = new AbstractAction(Messages.getMessage("browser.nameFilter.clearFilterText")) { @Override public void actionPerformed(ActionEvent e) { filterField.setText(""); } }; filterField.getActionMap().put(ACTION_FOCUS_ON_TABLE, actionFocusOnTable); filterField.getActionMap().put(ACTION_CLEAR_REGEX_FILTER, actionClearRegexFilter); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ACTION_CLEAR_REGEX_FILTER); JLabel nameFilterLabel = new JLabel(Messages.getMessage("browser.nameFilter")); nameFilterLabel.setLabelFor(filterField); nameFilterLabel.setDisplayedMnemonic(Messages.getMessage("browser.nameFilter.mnemonic").charAt(0)); sorter.setRowFilter(createFilter()); statusLabel = new JLabel(); actionApproveButton = new JButton(); actionApproveButton.setFont(actionApproveButton.getFont().deriveFont(Font.BOLD)); actionCancelButton = new JButton(); ActionMap browserActionMap = this.getActionMap(); browserActionMap.put(ACTION_FOCUS_ON_REGEX_FILTER, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { filterField.requestFocus(); filterField.selectAll(); GuiUtils.blinkComponent(filterField); } }); browserActionMap.put(ACTION_FOCUS_ON_PATH, new SetFocusOnAction(pathField)); browserActionMap.put(ACTION_SWITCH_SHOW_HIDDEN, new ClickOnJComponentAction(showHidCheckBox)); browserActionMap.put(ACTION_REFRESH, refreshAction); browserActionMap.put(ACTION_ADD_CURRENT_LOCATION_TO_FAVORITES, addCurrentLocationToFavoriteAction); browserActionMap.put(ACTION_GO_UP, goUpAction); browserActionMap.put(ACTION_FOCUS_ON_TABLE, new SetFocusOnAction(tableFiles)); InputMap browserInputMap = this.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); browserInputMap.put(KeyStroke.getKeyStroke("control F"), ACTION_FOCUS_ON_REGEX_FILTER); browserInputMap.put(KeyStroke.getKeyStroke("control L"), ACTION_FOCUS_ON_PATH); browserInputMap.put(KeyStroke.getKeyStroke("F4"), ACTION_FOCUS_ON_PATH); browserInputMap.put(KeyStroke.getKeyStroke("control H"), ACTION_SWITCH_SHOW_HIDDEN); browserInputMap.put(KeyStroke.getKeyStroke("control R"), ACTION_REFRESH); browserInputMap.put(KeyStroke.getKeyStroke("F5"), ACTION_REFRESH); browserInputMap.put(KeyStroke.getKeyStroke("control D"), ACTION_ADD_CURRENT_LOCATION_TO_FAVORITES); browserInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_DOWN_MASK), ACTION_GO_UP); browserInputMap.put(KeyStroke.getKeyStroke("control T"), ACTION_FOCUS_ON_TABLE); //DO layout // create the layer for the panel using our custom layerUI tableScrollPane = new JScrollPane(tableFiles); JPanel tableScrollPaneWithFilter = new JPanel(new BorderLayout()); tableScrollPaneWithFilter.add(tableScrollPane); JToolBar filtersToolbar = new JToolBar("Filters"); filtersToolbar.setFloatable(false); filtersToolbar.setBorderPainted(true); tableScrollPaneWithFilter.add(filtersToolbar, BorderLayout.SOUTH); filtersToolbar.add(nameFilterLabel); filtersToolbar.add(filterField); filtersToolbar.add(showHidCheckBox); JSplitPane tableWithPreviewPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, tableScrollPaneWithFilter, previewComponent); tableWithPreviewPane.setOneTouchExpandable(true); JPanel loadingPanel = new JPanel(new MigLayout()); loadingPanel.add(loadingIconLabel, "right"); loadingPanel.add(loadingProgressBar, "left, w 420:420:500,wrap"); loadingPanel.add(skipCheckingLinksButton, "span, right"); tablePanel.add(loadingPanel, LOADING); tablePanel.add(tableWithPreviewPane, TABLE); JSplitPane jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(favoritesPanel), tablePanel); jSplitPane.setOneTouchExpandable(true); jSplitPane.setDividerLocation(180); JPanel southPanel = new JPanel(new MigLayout("", "[]push[][]", "")); southPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); southPanel.add(statusLabel); southPanel.add(actionApproveButton); southPanel.add(actionCancelButton); this.add(upperPanel, BorderLayout.NORTH); this.add(jSplitPane, BorderLayout.CENTER); this.add(southPanel, BorderLayout.SOUTH); try { selectionChanged(); } catch (FileSystemException e) { LOGGER.error("Can't initialize default selection mode", e); } // Why this not done in EDT? // Is it assume that constructor is invoked from an EDT? try { if (initialPath == null) { goToUrl(VFSUtils.getUserHome()); } else { try { FileObject resolveFile = VFSUtils.resolveFileObject(initialPath); if (resolveFile != null && resolveFile.getType() == FileType.FILE) { loadAndSelSingleFile(resolveFile); pathField.setText(resolveFile.getURL().toString()); targetFileSelected = true; return; } } catch (FileSystemException fse) { // Intentionally empty } goToUrl(initialPath); } } catch (FileSystemException e1) { LOGGER.error("Can't initialize default location", e1); } showTable(); }
From source file:ro.nextreports.designer.querybuilder.QueryBuilderPanel.java
private void initUI() { JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.setDividerLocation(250);/*www. j av a2 s . c om*/ 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(); }
From source file:ro.nextreports.designer.querybuilder.SQLViewPanel.java
private void initUI() { sqlEditor = new Editor() { public void afterCaretMove() { removeHighlightErrorLine();//from ww w.j a v a 2s .c o m } }; this.queryArea = sqlEditor.getEditorPanel().getEditorPane(); queryArea.setText(DEFAULT_QUERY); errorPainter = new javax.swing.text.Highlighter.HighlightPainter() { @Override public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c) { try { Rectangle r = c.modelToView(c.getCaretPosition()); g.setColor(Color.RED.brighter().brighter()); g.fillRect(0, r.y, c.getWidth(), r.height); } catch (BadLocationException e) { // ignore } } }; ActionMap actionMap = sqlEditor.getEditorPanel().getEditorPane().getActionMap(); // create the toolbar 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 cut action Action cutAction = actionMap.get(BaseEditorKit.cutAction); cutAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("cut")); cutAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.cut")); toolBar.add(cutAction); // add copy action Action copyAction = actionMap.get(BaseEditorKit.copyAction); copyAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("copy")); copyAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.copy")); toolBar.add(copyAction); // add paste action Action pasteAction = actionMap.get(BaseEditorKit.pasteAction); pasteAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("paste")); pasteAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.paste")); toolBar.add(pasteAction); // add separator SwingUtil.addCustomSeparator(toolBar); // add undo action Action undoAction = actionMap.get(BaseEditorKit.undoAction); undoAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("undo")); undoAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("undo")); toolBar.add(undoAction); // add redo action Action redoAction = actionMap.get(BaseEditorKit.redoAction); redoAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("redo")); redoAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("redo")); toolBar.add(redoAction); // add separator SwingUtil.addCustomSeparator(toolBar); // add find action Action findReplaceAction = actionMap.get(BaseEditorKit.findReplaceAction); findReplaceAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("find")); findReplaceAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqleditor.findReplaceActionName")); toolBar.add(findReplaceAction); // add separator SwingUtil.addCustomSeparator(toolBar); // add run action runAction = new SQLRunAction(); runAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("run")); runAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(ShortcutsUtil.getShortcut("query.run.accelerator", "control 4"))); runAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("run.query") + " (" + ShortcutsUtil.getShortcut("query.run.accelerator.display", "Ctrl 4") + ")"); // runAction is globally registered in QueryBuilderPanel ! toolBar.add(runAction); // ro.nextreports.designer.util.SwingUtil.registerButtonsForFocus(buttonsPanel); // create the table resultTable = new JXTable(); resultTable.setDefaultRenderer(Integer.class, new ToStringRenderer()); // to remove thousand separators resultTable.setDefaultRenderer(Long.class, new ToStringRenderer()); resultTable.setDefaultRenderer(Date.class, new DateRenderer()); resultTable.setDefaultRenderer(Double.class, new DoubleRenderer()); resultTable.addMouseListener(new CopyTableMouseAdapter(resultTable)); TableUtil.setRowHeader(resultTable); resultTable.setColumnControlVisible(true); // resultTable.getTableHeader().setReorderingAllowed(false); resultTable.setHorizontalScrollEnabled(true); // highlight table Highlighter alternateHighlighter = HighlighterFactory.createAlternateStriping(Color.WHITE, ColorUtil.PANEL_BACKROUND_COLOR); Highlighter nullHighlighter = new TextHighlighter(ResultSetTableModel.NULL_VALUE, Color.YELLOW.brighter()); Highlighter blobHighlighter = new TextHighlighter(ResultSetTableModel.BLOB_VALUE, Color.GRAY.brighter()); Highlighter clobHighlighter = new TextHighlighter(ResultSetTableModel.CLOB_VALUE, Color.GRAY.brighter()); resultTable.setHighlighters(alternateHighlighter, nullHighlighter, blobHighlighter, clobHighlighter); resultTable.setBackground(ColorUtil.PANEL_BACKROUND_COLOR); resultTable.setGridColor(Color.LIGHT_GRAY); resultTable.setRolloverEnabled(true); resultTable.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.RED)); JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setResizeWeight(0.66); split.setOneTouchExpandable(true); JPanel topPanel = new JPanel(); topPanel.setLayout(new GridBagLayout()); topPanel.add(toolBar, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); topPanel.add(sqlEditor, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new GridBagLayout()); JScrollPane scrPanel = new JScrollPane(resultTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); statusPanel = new SQLStatusPanel(); bottomPanel.add(scrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); bottomPanel.add(statusPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); split.setTopComponent(topPanel); split.setBottomComponent(bottomPanel); split.setDividerLocation(400); setLayout(new BorderLayout()); this.add(split, BorderLayout.CENTER); }
From source file:simplesqlformatter.formatter.SQLFormatterEditor.java
/** * Creates a new instance of a Simple SQL Formatter editor main * window.//w ww .ja v a 2s . c o m * * @param debug * Whether to show the debug window */ public SQLFormatterEditor(final boolean debug) { setTitle("Simple SQL Formatter"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setIconImage(new ImageIcon(SQLFormatterEditor.class.getResource("/sf.png")) //$NON-NLS-1$ .getImage()); panel = getContentPane(); panel.setLayout(new BorderLayout()); // Create menus and toolbars final JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); final JToolBar toolBar = new JToolBar(); toolBar.setRollover(true); add(toolBar, BorderLayout.NORTH); createFileMenu(menuBar, toolBar); createEditMenu(menuBar, toolBar); createHelpMenu(menuBar, toolBar); final Font font = new Font("Monospaced", Font.PLAIN, 12); // create text area textArea.setFont(font); // create debug area debugArea.setFont(font); debugArea.setEditable(false); final JLabel debugTitle = new JLabel("Simple SQL Formatter Debug"); debugTitle.setBorder(BorderFactory.createEtchedBorder()); final JPanel debugPanel = new JPanel(new BorderLayout()); debugPanel.add(debugTitle, BorderLayout.NORTH); debugPanel.add(new JScrollPane(debugArea), BorderLayout.CENTER); if (debug) { // create split pane final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(textArea), debugPanel); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(SPLITPANEWEIGHT); panel.add(splitPane, BorderLayout.CENTER); } else { panel.add(new JScrollPane(textArea), BorderLayout.CENTER); } statusBar.setBorder(BorderFactory.createEtchedBorder()); panel.add(statusBar, BorderLayout.SOUTH); pack(); }
From source file:tk.tomby.tedit.core.Workspace.java
private JSplitPane createSplitPane(int orientation, Component left, Component right) { JSplitPane split = new StrippedSplitPane(orientation, left, right); split.setBorder(BorderFactory.createEmptyBorder()); split.setDividerSize(5);/*from w w w . jav a 2s. c o m*/ split.setOneTouchExpandable(false); return split; }