List of usage examples for javax.swing JSplitPane HORIZONTAL_SPLIT
int HORIZONTAL_SPLIT
To view the source code for javax.swing JSplitPane HORIZONTAL_SPLIT.
Click Source Link
Component
s are split along the x axis. From source file:org.orbisgis.sqlconsole.ui.SQLConsolePanel.java
/** * Creates a console for sql./* w w w . java2 s .c om*/ */ public SQLConsolePanel(DataSource dataSource, SQLElement sqlElement) { super(new BorderLayout()); this.dataSource = dataSource; sqlFunctionsPanel = new SQLFunctionsPanel(dataSource); initActions(); split = new DeactivableSplitPane(JSplitPane.HORIZONTAL_SPLIT, getCenterPanel(), sqlFunctionsPanel); add(split, BorderLayout.CENTER); add(getStatusToolBar(), BorderLayout.SOUTH); this.sqlElement = sqlElement; onShowHideFunctionPanel(); }
From source file:org.pdfsam.guiclient.gui.frames.JMainFrame.java
/** * initialization//from ww w . ja v a2 s. co m */ private void initialize() { try { // center(this,800,600); URL iconUrl = this.getClass().getResource("/images/pdf_" + GuiClient.getVersionType() + ".png"); URL iconUrl16 = this.getClass().getResource("/images/pdf_" + GuiClient.getVersionType() + "16.png"); if (iconUrl == null) { iconUrl = this.getClass().getResource(DEFAULT_ICON); } if (iconUrl16 == null) { iconUrl16 = this.getClass().getResource(DEFAULT_ICON_16); } setIconImage(new ImageIcon(iconUrl).getImage()); setTitle(GuiClient.getApplicationName() + " Ver. " + GuiClient.getVersion()); // load plugins setSplashStep(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Loading plugins..")); PlugInsLoader pluginsLoader = new PlugInsLoader(Configuration.getInstance().getPluginAbsolutePath()); pluginsMap = pluginsLoader.loadPlugins(); // Info panel JInfoPanel infoPanel = new JInfoPanel(pluginsMap); PluginDataModel infoDataModel = new PluginDataModel(infoPanel.getPluginName(), infoPanel.getVersion(), infoPanel.getPluginAuthor(), infoPanel.getClass().getName()); mainPanel.add(infoPanel, infoPanel.getPluginName()); // Settings panel JSettingsPanel settingsPanel = new JSettingsPanel(); PluginDataModel settingsDataModel = new PluginDataModel(settingsPanel.getPluginName(), settingsPanel.getVersion(), settingsPanel.getPluginAuthor(), settingsPanel.getClass().getName()); mainPanel.add(settingsPanel, settingsPanel.getPluginName()); // sets main panel mainPanel.setPreferredSize(new Dimension(670, 500)); for (AbstractPlugablePanel instance : pluginsMap.values()) { mainPanel.add(instance, instance.getPluginName()); } // status panel setSplashStep(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Building status bar..")); statusPanel = new JStatusPanel(new ImageIcon(iconUrl16), GuiClient.getApplicationName(), WorkDoneDataModel.MAX_PERGENTAGE); getContentPane().add(statusPanel, BorderLayout.PAGE_END); Configuration.getInstance().getConsoleServicesFacade().addExecutionObserver(statusPanel); // tree panel setSplashStep(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Building tree..")); treePanel = new JTreePanel( new DefaultMutableTreeNode(GuiClient.UNIXNAME + " " + GuiClient.getVersion())); for (PluginDataModel item : pluginsMap.keySet()) { treePanel.addToPlugsNode(item); } treePanel.addToRootNode(settingsDataModel); treePanel.addToRootNode(infoDataModel); treePanel.getTree().addTreeSelectionListener(new TreeMediator(this)); treePanel.expand(); // add info and settings to plugins map pluginsMap.put(settingsDataModel, settingsPanel); pluginsMap.put(infoDataModel, infoPanel); // menu setSplashStep(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Building menus..")); environment = new Environment(pluginsMap, treePanel); SaveEnvironmentAction saveAction = new SaveEnvironmentAction(environment, this); LoadEnvironmentAction loadAction = new LoadEnvironmentAction(environment, this); ApplicationExitMediator exitMediator = new ApplicationExitMediator(new ApplicationCloser(this)); menuBar = new JMainMenuBar(saveAction, loadAction, exitMediator); getRootPane().setJMenuBar(menuBar); environment.addObserver(new EnvironmentLoadObserver()); // buttons bar setSplashStep(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Building buttons bar..")); buttonsPanel = new JButtonsPanel(saveAction, loadAction, exitMediator, new LogActionListener()); getContentPane().add(buttonsPanel, BorderLayout.PAGE_START); initializeUpdateChecker(settingsPanel); // final set up mainScrollPanel = new JScrollPane(mainPanel); mainScrollPanel.setMinimumSize(new Dimension(100, 400)); logPanel = new JLogPanel(); horizSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePanel, mainScrollPanel); horizSplitPane.setOneTouchExpandable(true); horizSplitPane.setDividerLocation(155); verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, horizSplitPane, logPanel); verticalSplitPane.setOneTouchExpandable(true); verticalSplitPane.setResizeWeight(1.0); verticalSplitPane.setDividerLocation(0.75); // load the default env if set String defaultEnvString = Configuration.getInstance().getDefaultEnvironment(); if (defaultEnvString != null && defaultEnvString.length() > 0) { File defaultEnv = new File(defaultEnvString); if (defaultEnv != null && defaultEnv.exists() && defaultEnv.isFile()) { log.info(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Loading default environment.")); environment.loadJobs(defaultEnv); } } getContentPane().add(verticalSplitPane, BorderLayout.CENTER); setSize(640, 480); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(new MainWindowListener(this)); } catch (Exception e) { log.fatal(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Error starting pdfsam."), e); } }
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; }// w w w . jav a2 s . com } 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 Container createDefaultContentPane() { demoContent = new JPanel(); demoContent.setLayout(new BorderLayout()); demoContent.setMinimumSize(new Dimension(100, 100)); demoContent.add(getNoHandlerInfoPane(), BorderLayout.CENTER); JPanel placeHolder = new JPanel(); placeHolder.setMinimumSize(new Dimension(300, 0)); placeHolder.setPreferredSize(new Dimension(300, 0)); placeHolder.setMaximumSize(new Dimension(300, 0)); JPanel rootContent = new JPanel(); rootContent.setLayout(new BorderLayout()); rootContent.add(demoContent, BorderLayout.CENTER); rootContent.add(placeHolder, BorderLayout.NORTH); final DemoSelectorTreeNode root = new DemoSelectorTreeNode(null, demoSelector); final DefaultTreeModel model = new DefaultTreeModel(root); final JTree demoTree = new JTree(model); demoTree.addTreeSelectionListener(new TreeSelectionHandler()); JSplitPane rootSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(demoTree), rootContent);//from w ww .j a va 2s. co m rootSplitPane.setContinuousLayout(true); rootSplitPane.setDividerLocation(200); rootSplitPane.setOneTouchExpandable(true); return rootSplitPane; }
From source file:org.pentaho.reporting.tools.configeditor.ConfigDescriptionEditor.java
private void init() { this.resources = Messages.getInstance(); setTitle(resources.getString("config-description-editor.title")); //$NON-NLS-1$ final JPanel contentPane = new JPanel(); contentPane.setLayout(new BorderLayout()); detailEditorPane = createEditPane(); final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, createEntryList(), detailEditorPane);/*from ww w . j a va2s. com*/ contentPane.add(splitPane, BorderLayout.CENTER); contentPane.add(createButtonPane(), BorderLayout.SOUTH); final JPanel cPaneStatus = new JPanel(); cPaneStatus.setLayout(new BorderLayout()); cPaneStatus.add(contentPane, BorderLayout.CENTER); cPaneStatus.add(createStatusBar(), BorderLayout.SOUTH); setContentPane(cPaneStatus); setEntryType(ConfigDescriptionEditor.TYPE_TEXT); setSelectedEntry(null); fileChooser = new JFileChooser(); fileChooser.addChoosableFileFilter( new FilesystemFilter(".xml", resources.getString("config-description-editor.xml-files"))); //$NON-NLS-1$ //$NON-NLS-2$ fileChooser.setMultiSelectionEnabled(false); setStatusText(resources.getString("config-description-editor.welcome")); //$NON-NLS-1$ addWindowListener(new CloseHandler()); }
From source file:org.pentaho.reporting.ui.datasources.kettle.KettleDataSourceDialog.java
protected Component createContentPane() { final JPanel previewAndParameterPanel = createTransformParameterPanel(); final JPanel queryListPanel = createQueryListPanel(); final JPanel mainPanel = new JPanel(new GridBagLayout()); mainPanel.setBorder(new EmptyBorder(5, 5, 0, 5)); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0;//from ww w . j a va 2s . co m gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; mainPanel.add(new JLabel(Messages.getString("KettleDataSourceDialog.QueryName")), gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.WEST; gbc.weightx = 1; mainPanel.add(nameTextField, gbc); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 3; gbc.gridwidth = 3; gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1; gbc.weighty = 1; gbc.anchor = GridBagConstraints.WEST; mainPanel.add(createDatasourcePanel(), gbc); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 4; gbc.gridwidth = 3; gbc.anchor = GridBagConstraints.WEST; mainPanel.add(previewAndParameterPanel, gbc); final JSplitPane panel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); panel.setLeftComponent(queryListPanel); panel.setRightComponent(mainPanel); panel.setDividerLocation(250); return panel; }
From source file:org.pentaho.ui.xul.swing.SwingElement.java
public void layout() { super.layout(); double totalFlex = 0.0; if (isVisible() == false) { resetContainer();/*from www .j av a2s. co m*/ return; } for (Element comp : getChildNodes()) { // if (comp.getManagedObject() == null) { // continue; // } if (((XulComponent) comp).getFlex() > 0) { flexLayout = true; totalFlex += ((XulComponent) comp).getFlex(); } } double currentFlexTotal = 0.0; Align alignment = (getAlign() != null) ? Align.valueOf(this.getAlign().toUpperCase()) : null; for (int i = 0; i < getChildNodes().size(); i++) { XulComponent comp = (XulComponent) getChildNodes().get(i); gc.fill = GridBagConstraints.BOTH; if (comp instanceof XulSplitter) { JPanel prevContainer = container; container = new ScrollablePanel(new GridBagLayout()); container.setOpaque(false); final JSplitPane splitter = new JSplitPane( (this.getOrientation() == Orient.VERTICAL) ? JSplitPane.VERTICAL_SPLIT : JSplitPane.HORIZONTAL_SPLIT, prevContainer, container); splitter.setContinuousLayout(true); final double splitterSize = currentFlexTotal / totalFlex; splitter.setResizeWeight(splitterSize); if (totalFlex > 0) { splitter.addComponentListener(new ComponentListener() { public void componentHidden(ComponentEvent arg0) { } public void componentMoved(ComponentEvent arg0) { } public void componentShown(ComponentEvent arg0) { } public void componentResized(ComponentEvent arg0) { splitter.setDividerLocation(splitterSize); splitter.removeComponentListener(this); } }); } if (!flexLayout) { if (this.getOrientation() == Orient.VERTICAL) { // VBox and such gc.weighty = 1.0; } else { gc.weightx = 1.0; } prevContainer.add(Box.createGlue(), gc); } setManagedObject(splitter); } Object maybeComponent = comp.getManagedObject(); if (maybeComponent == null || !(maybeComponent instanceof Component)) { continue; } if (this.getOrientation() == Orient.VERTICAL) { // VBox and such gc.gridheight = comp.getFlex() + 1; gc.gridwidth = GridBagConstraints.REMAINDER; gc.weighty = (totalFlex == 0) ? 0 : (comp.getFlex() / totalFlex); } else { gc.gridwidth = comp.getFlex() + 1; gc.gridheight = GridBagConstraints.REMAINDER; gc.weightx = (totalFlex == 0) ? 0 : (comp.getFlex() / totalFlex); } currentFlexTotal += comp.getFlex(); if (this.getOrientation() == Orient.VERTICAL) { // VBox and such if (alignment != null) { gc.fill = GridBagConstraints.NONE; switch (alignment) { case START: gc.anchor = GridBagConstraints.WEST; break; case CENTER: gc.anchor = GridBagConstraints.CENTER; break; case END: gc.anchor = GridBagConstraints.EAST; break; } } } else { if (alignment != null) { gc.fill = GridBagConstraints.NONE; switch (alignment) { case START: gc.anchor = GridBagConstraints.NORTH; break; case CENTER: gc.anchor = GridBagConstraints.CENTER; break; case END: gc.anchor = GridBagConstraints.SOUTH; break; } } } Component component = (Component) maybeComponent; if (comp.getWidth() > 0 || comp.getHeight() > 0) { Dimension minSize = component.getMinimumSize(); Dimension prefSize = component.getPreferredSize(); if (comp.getWidth() > 0) { minSize.width = comp.getWidth(); prefSize.width = comp.getWidth(); } if (comp.getHeight() > 0) { minSize.height = comp.getHeight(); prefSize.height = comp.getHeight(); } component.setMinimumSize(minSize); component.setPreferredSize(prefSize); } container.add(component, gc); if (i + 1 == getChildNodes().size() && !flexLayout) { if (this.getOrientation() == Orient.VERTICAL) { // VBox and such gc.weighty = 1.0; } else { gc.weightx = 1.0; } container.add(Box.createGlue(), gc); } } }
From source file:org.photovault.swingui.BrowserWindow.java
protected void createUI(PhotoCollection collection) { window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); tabPane = new JTabbedPane(); queryPane = new QueryPane(); PhotoFolderTreeController treeCtrl = new PhotoFolderTreeController(window, this); viewCtrl = new PhotoViewController(window, this); treePane = treeCtrl.folderTree;/*from ww w . j a v a 2 s . c om*/ viewPane = viewCtrl.getThumbPane(); previewPane = viewCtrl.getPreviewPane(); tabPane.addTab("Query", queryPane); tabPane.addTab("Folders", treePane); VolumeTreeController volTreeCtrl = new VolumeTreeController(this); JTree volumeTree = volTreeCtrl.getView(); JScrollPane voltreeScrollPane = new JScrollPane(volumeTree); voltreeScrollPane.setPreferredSize(new Dimension(200, 500)); tabPane.add("Volumes", voltreeScrollPane); // TODO: get rid of this!!!! EditSelectionColorsAction colorAction = (EditSelectionColorsAction) viewPane.getEditSelectionColorsAction(); colorAction.setPreviewCtrl(previewPane); // Set listeners to both query and folder tree panes /* If an actionEvent comes from query pane, swich to query results. */ queryPane.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { viewCtrl.setCollection(queryPane.getResultCollection()); } }); /* If the selected folder is changed in treePane, switch to that immediately */ treeCtrl.registerEventListener(PhotoFolderTreeEvent.class, new DefaultEventListener<PhotoCollection>() { public void handleEvent(DefaultEvent<PhotoCollection> event) { PhotoCollection c = event.getPayload(); if (c != null) { viewCtrl.setCollection(c); if (c instanceof PhotoFolder) { PhotoFolder f = (PhotoFolder) c; if (f.getExternalDir() != null) { ExternalDir ed = f.getExternalDir(); folderIndexer.updateDir(ed.getVolume(), ed.getPath()); viewCtrl.setIndexingOngoing(true); } } } } }); volTreeCtrl.registerEventListener(PhotoFolderTreeEvent.class, new DefaultEventListener<PhotoCollection>() { public void handleEvent(DefaultEvent<PhotoCollection> event) { PhotoCollection c = event.getPayload(); if (c != null) { viewCtrl.setCollection(c); if (c instanceof ExtDirPhotos) { ExtDirPhotos photos = (ExtDirPhotos) c; ExternalVolume vol = (ExternalVolume) viewCtrl.getDAOFactory().getVolumeDAO() .getVolume(photos.getVolId()); folderIndexer.updateDir(vol, photos.getDirPath()); viewCtrl.setIndexingOngoing(true); } } } }); collectionPane = viewCtrl.getCollectionPane(); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tabPane, collectionPane); split.putClientProperty(JSplitPane.ONE_TOUCH_EXPANDABLE_PROPERTY, new Boolean(true)); Container cp = window.getContentPane(); cp.setLayout(new BorderLayout()); cp.add(split, BorderLayout.CENTER); statusBar = new StatusBar(); cp.add(statusBar, BorderLayout.SOUTH); // Create actions for BrowserWindow UI ImageIcon indexDirIcon = getIcon("index_dir.png"); DefaultAction indexDirAction = new DefaultAction("Index directory...", indexDirIcon) { public void actionPerformed(ActionEvent e) { indexDir(); } }; indexDirAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_D); indexDirAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Index all images in a directory"); this.registerAction("new_ext_vol", indexDirAction); ImageIcon importIcon = getIcon("import.png"); importAction = new AbstractAction("Import image...", importIcon) { public void actionPerformed(ActionEvent e) { importFile(); } }; importAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_O); importAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); importAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Import new image into database"); ImageIcon updateIcon = getIcon("update_indexed_dirs.png"); UpdateIndexAction updateIndexAction = new UpdateIndexAction(viewCtrl, "Update indexed dirs", updateIcon, "Check for changes in previously indexed directories", KeyEvent.VK_U); this.registerAction("update_indexed_dirs", updateIndexAction); updateIndexAction.addStatusChangeListener(statusBar); ImageIcon previewTopIcon = getIcon("view_preview_top.png"); DefaultAction previewTopAction = new DefaultAction("Preview on top", previewTopIcon) { public void actionPerformed(ActionEvent e) { viewCtrl.setLayout(PhotoViewController.Layout.PREVIEW_HORIZONTAL_THUMBS); } }; previewTopAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Show preview on top of thumbnails"); previewTopAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_T); this.registerAction("view_preview_top", previewTopAction); ImageIcon previewRightIcon = getIcon("view_preview_right.png"); DefaultAction previewRightAction = new DefaultAction("Preview on right", previewRightIcon) { public void actionPerformed(ActionEvent e) { viewCtrl.setLayout(PhotoViewController.Layout.PREVIEW_VERTICAL_THUMBS); } }; previewRightAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Show preview on right of thumbnails"); previewRightAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_R); this.registerAction("view_preview_right", previewRightAction); ImageIcon previewNoneIcon = getIcon("view_no_preview.png"); DefaultAction previewNoneAction = new DefaultAction("No preview", previewNoneIcon) { public void actionPerformed(ActionEvent e) { viewCtrl.setLayout(PhotoViewController.Layout.ONLY_THUMBS); } }; previewNoneAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Show no preview image"); previewNoneAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_O); this.registerAction("view_no_preview", previewNoneAction); DefaultAction previewLargeAction = new DefaultAction("Large", null) { public void actionPerformed(ActionEvent e) { viewCtrl.setPreviewSize(200); } }; DefaultAction previewSmallAction = new DefaultAction("Small", null) { public void actionPerformed(ActionEvent e) { viewCtrl.setPreviewSize(100); } }; JToolBar tb = createToolbar(); cp.add(tb, BorderLayout.NORTH); // Create the menu bar & menus JMenuBar menuBar = new JMenuBar(); window.setJMenuBar(menuBar); // File menu JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu); JMenuItem newWindowItem = new JMenuItem("New window", KeyEvent.VK_N); newWindowItem.setIcon(getIcon("window_new.png")); newWindowItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { BrowserWindow br = new BrowserWindow(getParentController(), null); // br.setVisible( true ); } }); fileMenu.add(newWindowItem); JMenuItem importItem = new JMenuItem(importAction); fileMenu.add(importItem); JMenuItem indexDirItem = new JMenuItem(indexDirAction); fileMenu.add(indexDirItem); fileMenu.add(new JMenuItem(viewCtrl.getActionAdapter("update_indexed_dirs"))); ExportSelectedAction exportAction = (ExportSelectedAction) viewPane.getExportSelectedAction(); JMenuItem exportItem = new JMenuItem(exportAction); exportAction.addStatusChangeListener(statusBar); fileMenu.add(exportItem); JMenu dbMenu = new JMenu("Database"); dbMenu.setMnemonic(KeyEvent.VK_B); dbMenu.setIcon(getIcon("empty_icon.png")); ExportMetadataAction exportMetadata = new ExportMetadataAction("Export as XML...", null, "Export whole database as XML file", KeyEvent.VK_E); dbMenu.add(new JMenuItem(exportMetadata)); ImportXMLAction importMetadata = new ImportXMLAction("Import XML data...", null, "Import data from other Photovault database as XML", KeyEvent.VK_I); importMetadata.addStatusChangeListener(statusBar); dbMenu.add(new JMenuItem(importMetadata)); fileMenu.add(dbMenu); JMenuItem exitItem = new JMenuItem("Exit", KeyEvent.VK_X); exitItem.setIcon(getIcon("exit.png")); exitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); fileMenu.add(exitItem); JMenu viewMenu = new JMenu("View"); viewMenu.setMnemonic(KeyEvent.VK_V); menuBar.add(viewMenu); JMenuItem vertIconsItem = new JMenuItem(previewRightAction); viewMenu.add(vertIconsItem); JMenuItem horzIconsItem = new JMenuItem(previewTopAction); viewMenu.add(horzIconsItem); JMenuItem noPreviewItem = new JMenuItem(previewNoneAction); viewMenu.add(noPreviewItem); JMenuItem nextPhotoItem = new JMenuItem(viewPane.getSelectNextAction()); viewMenu.add(nextPhotoItem); JMenuItem prevPhotoItem = new JMenuItem(viewPane.getSelectPreviousAction()); viewMenu.add(prevPhotoItem); viewMenu.add(new JMenuItem(previewSmallAction)); viewMenu.add(new JMenuItem(previewLargeAction)); JMenu sortMenu = new JMenu("Sort by"); sortMenu.setMnemonic(KeyEvent.VK_S); sortMenu.setIcon(getIcon("empty_icon.png")); JMenuItem byDateItem = new JMenuItem(new SetPhotoOrderAction(viewCtrl, new ShootingDateComparator(), "Date", null, "Order photos by date", KeyEvent.VK_D)); sortMenu.add(byDateItem); JMenuItem byPlaceItem = new JMenuItem(new SetPhotoOrderAction(viewCtrl, new ShootingPlaceComparator(), "Place", null, "Order photos by shooting place", KeyEvent.VK_P)); sortMenu.add(byPlaceItem); JMenuItem byQualityItem = new JMenuItem(new SetPhotoOrderAction(viewCtrl, new QualityComparator(), "Quality", null, "Order photos by quality", KeyEvent.VK_Q)); sortMenu.add(byQualityItem); viewMenu.add(sortMenu); // Set default ordering by date byDateItem.getAction().actionPerformed(new ActionEvent(this, 0, "Setting default")); JMenu imageMenu = new JMenu("Image"); imageMenu.setMnemonic(KeyEvent.VK_I); menuBar.add(imageMenu); imageMenu.add(new JMenuItem(viewPane.getEditSelectionPropsAction())); imageMenu.add(new JMenuItem(viewPane.getShowSelectedPhotoAction())); imageMenu.add(new JMenuItem(viewCtrl.getActionAdapter("rotate_cw"))); imageMenu.add(new JMenuItem(viewCtrl.getActionAdapter("rotate_ccw"))); imageMenu.add(new JMenuItem(viewCtrl.getActionAdapter("rotate_180"))); imageMenu.add(new JMenuItem(previewPane.getCropAction())); imageMenu.add(new JMenuItem(viewPane.getEditSelectionColorsAction())); imageMenu.add(new JMenuItem(viewPane.getDeleteSelectedAction())); // Create the Quality submenu JMenu qualityMenu = new JMenu("Quality"); qualityMenu.setIcon(getIcon("empty_icon.png")); for (int n = 0; n < 6; n++) { Action qualityAction = viewCtrl.getActionAdapter("quality_" + n); JMenuItem qualityMenuItem = new JMenuItem(qualityAction); qualityMenu.add(qualityMenuItem); } imageMenu.add(qualityMenu); JMenu aboutMenu = new JMenu("About"); aboutMenu.setMnemonic(KeyEvent.VK_A); aboutMenu.add(new JMenuItem(new ShowAboutDlgAction("About Photovault...", null, "", null))); menuBar.add(Box.createHorizontalGlue()); menuBar.add(aboutMenu); window.pack(); window.setVisible(true); }
From source file:org.photovault.swingui.PhotoViewController.java
/** Creates a new instance of PhotoViewController */ public PhotoViewController(Container view, AbstractController parentController) { super(view, parentController); photoDAO = getDAOFactory().getPhotoInfoDAO(); folderDAO = getDAOFactory().getPhotoFolderDAO(); ImageIcon rotateCWIcon = getIcon("rotate_cw.png"); ImageIcon rotateCCWIcon = getIcon("rotate_ccw.png"); ImageIcon rotate180DegIcon = getIcon("rotate_180.png"); registerAction("rotate_cw", new RotateSelectedPhotoAction(this, 90, "Rotate CW", rotateCWIcon, "Rotates the selected photo 90 degrees clockwise", KeyEvent.VK_R)); registerAction("rotate_ccw", new RotateSelectedPhotoAction(this, 270, "Rotate CCW", rotateCCWIcon, "Rotates the selected photo 90 degrees counterclockwise", KeyEvent.VK_L)); registerAction("rotate_180", new RotateSelectedPhotoAction(this, 180, "Rotate 180 degrees", rotate180DegIcon, "Rotates the selected photo 180 degrees counterclockwise", KeyEvent.VK_T)); registerAction("rotate_180", new RotateSelectedPhotoAction(this, 180, "Rotate 180 degrees", rotate180DegIcon, "Rotates the selected photo 180 degrees counterclockwise", KeyEvent.VK_T)); String qualityStrings[] = { "Unevaluated", "Top", "Good", "OK", "Poor", "Unusable" }; String qualityIconnames[] = { "quality_unevaluated.png", "quality_top.png", "quality_good.png", "quality_ok.png", "quality_poor.png", "quality_unusable.png" }; KeyStroke qualityAccelerators[] = { null, KeyStroke.getKeyStroke(KeyEvent.VK_5, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), KeyStroke.getKeyStroke(KeyEvent.VK_4, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), KeyStroke.getKeyStroke(KeyEvent.VK_3, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), KeyStroke.getKeyStroke(KeyEvent.VK_2, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), KeyStroke.getKeyStroke(KeyEvent.VK_1, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), }; ImageIcon[] qualityIcons = new ImageIcon[qualityStrings.length]; for (int n = 0; n < qualityStrings.length; n++) { qualityIcons[n] = getIcon(qualityIconnames[n]); DataAccessAction qualityAction = new SetPhotoQualityAction(this, n, qualityStrings[n], qualityIcons[n], "Set quality of selected phots to \"" + qualityStrings[n] + "\"", null); qualityAction.putValue(AbstractAction.ACCELERATOR_KEY, qualityAccelerators[n]); registerAction("quality_" + n, qualityAction); registerEventListener(TaskFinishedEvent.class, new DefaultEventListener<BackgroundTask>() { public void handleEvent(DefaultEvent<BackgroundTask> event) { BackgroundTask task = event.getPayload(); if (task instanceof IndexFileTask) { IndexFileTask ifTask = (IndexFileTask) task; if (ifTask.getResult() == IndexingResult.ERROR || ifTask.getResult() == IndexingResult.NOT_IMAGE) { return; }//from w w w. ja v a 2s . co m UUID volId = ifTask.getVolume().getId(); FileLocation loc = ifTask.getFileLocation(); Set<PhotoInfo> photos = ifTask.getPhotosFound(); log.debug("Found file " + loc.getFile() + " in volume " + volId); for (PhotoInfo p : photos) { log.debug(" linked to photo " + p.getUuid()); } if (collection instanceof ExtDirPhotos) { ExtDirPhotos dir = (ExtDirPhotos) collection; if (loc.getVolume().getId().equals(dir.getVolId()) && loc.getDirName().equals(dir.getDirPath())) { addPhotos(photos); updateThumbView(); } } } } }); } // Create the UI controls thumbPane = new PhotoCollectionThumbView(this, null); thumbPane.addSelectionChangeListener(new SelectionChangeListener() { public void selectionChanged(SelectionChangeEvent e) { thumbSelectionChanged(e); } }); previewPane = new JAIPhotoViewer(this); previewPane.getActionMap().put("hide_fullwindow_preview", new HidePhotoPreviewAction(this)); previewPane.getActionMap().put("move_next", thumbPane.getSelectNextAction()); previewPane.getActionMap().put("move_prev", thumbPane.getSelectPreviousAction()); // Create the split pane to display both of these components thumbScroll = new JScrollPane(thumbPane); thumbPane.setBackground(Color.WHITE); thumbScroll.getViewport().setBackground(Color.WHITE); thumbScroll.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { handleThumbAreaResize(); } }); scrollLayer = new JXLayer<JScrollPane>(thumbScroll); progressLayer = new ProgressIndicatorLayer(); scrollLayer.setUI(progressLayer); collectionPane = new JPanel(); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); layeredPane = new JLayeredPane(); layeredPane.setLayout(new StackLayout()); collectionPane.add(splitPane); collectionPane.add(layeredPane); GridBagLayout layout = new GridBagLayout(); collectionPane.setLayout(layout); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weighty = 1.0; c.weightx = 1.0; c.gridy = 0; // collectionPane.add( scrollLayer ); layout.setConstraints(splitPane, c); layout.setConstraints(layeredPane, c); // collectionPane.add( previewPane ); thumbPane.setRowHeight(200); setLayout(Layout.ONLY_THUMBS); /* Register action so that we are notified of changes to currently displayed folder */ registerEventListener(CommandExecutedEvent.class, new DefaultEventListener<DataAccessCommand>() { public void handleEvent(DefaultEvent<DataAccessCommand> event) { DataAccessCommand cmd = event.getPayload(); if (cmd instanceof ChangePhotoInfoCommand) { photoChangeCommandExecuted((ChangePhotoInfoCommand) cmd); } else if (cmd instanceof CreateCopyImageCommand) { imageCreated((CreateCopyImageCommand) cmd); } else if (cmd instanceof ApplyChangeCommand) { changeApplied((ApplyChangeCommand) cmd); } } }); }
From source file:org.photovault.swingui.PhotoViewController.java
/** * Sets up the window layout so that the collection is displayed as one vertical * column with preview image on right/*from w ww .j a v a2 s .c o m*/ */ private void setupLayoutPreviewWithVerticalIcons() { // Minimum size is the size of one thumbnail int thumbColWidth = thumbPane.getColumnWidth(); int thumbRowHeight = thumbPane.getRowHeight(); scrollLayer.setMinimumSize(new Dimension(thumbColWidth + 20, thumbRowHeight)); scrollLayer.setPreferredSize(new Dimension(thumbColWidth + 20, thumbRowHeight)); thumbScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); thumbScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); scrollLayer.setVisible(true); thumbPane.setColumnCount(1); previewPane.setVisible(true); layeredPane.removeAll(); layeredPane.setVisible(false); splitPane.setVisible(true); splitPane.remove(previewPane); splitPane.remove(scrollLayer); splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT); splitPane.setLeftComponent(scrollLayer); splitPane.setRightComponent(previewPane); // Left component should not be resized splitPane.setResizeWeight(0.0); Dimension minThumbDim = thumbPane.getMinimumSize(); scrollLayer.setMinimumSize(new Dimension((int) minThumbDim.getWidth(), 0)); previewPane.setMinimumSize(new Dimension(splitPane.getWidth() - 250 - splitPane.getInsets().left, 0)); splitPane.validate(); getView().validate(); }