private PreviewSettingsTopComponent() { initComponents(); setName( NbBundle.getMessage(PreviewSettingsTopComponent.class, "CTL_PreviewSettingsTopComponent")); // setToolTipText(NbBundle.getMessage(PreviewSettingsTopComponent.class, // "HINT_PreviewSettingsTopComponent")); setIcon(ImageUtilities.loadImage(ICON_PATH)); if (UIUtils.isAquaLookAndFeel()) { mainPanel.setBackground(UIManager.getColor("NbExplorerView.background")); } // property sheet propertySheet = new PropertySheet(); propertySheet.setNodes(new Node[] {new PreviewNode(propertySheet)}); propertySheet.setDescriptionAreaVisible(false); // Tabs and PreviewUI PreviewUI[] previewUIs = Lookup.getDefault().lookupAll(PreviewUI.class).toArray(new PreviewUI[0]); if (previewUIs.length > 0) { tabbedPane = new JTabbedPane(); tabbedPane.addTab( NbBundle.getMessage( PreviewSettingsTopComponent.class, "PreviewSettingsTopComponent.propertySheetTab"), propertySheet); propertiesPanel.add(tabbedPane, BorderLayout.CENTER); } else { propertiesPanel.add(propertySheet, BorderLayout.CENTER); } // Ratio ratioSlider.addChangeListener( new ChangeListener() { NumberFormat formatter = NumberFormat.getPercentInstance(); public void stateChanged(ChangeEvent e) { float val = ratioSlider.getValue() / 100f; if (val == 0f) { ratioLabel.setText( NbBundle.getMessage( PreviewSettingsTopComponent.class, "PreviewSettingsTopComponent.ratio.minimum")); } else { ratioLabel.setText(formatter.format(val)); } PreviewUIController puic = Lookup.getDefault().lookup(PreviewUIController.class); puic.setVisibilityRatio(getVisibilityRatio()); } }); // Presets presetComboBox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { PreviewUIController pc = Lookup.getDefault().lookup(PreviewUIController.class); PreviewUIModel previewModel = pc.getModel(); if (previewModel != null && presetComboBox.getSelectedItem() instanceof PreviewPreset) { if (previewModel.getCurrentPreset() != presetComboBox.getSelectedItem()) { pc.setCurrentPreset((PreviewPreset) presetComboBox.getSelectedItem()); propertySheet.setNodes(new Node[] {new PreviewNode(propertySheet)}); } } } }); // Export svgExportButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { VectorialFileExporterUI ui = Lookup.getDefault().lookup(VectorialFileExporterUI.class); ui.action(); } }); setup(null); PreviewUIController controller = Lookup.getDefault().lookup(PreviewUIController.class); controller.addPropertyChangeListener(this); PreviewUIModel m = controller.getModel(); if (m != null) { setup(m); enableRefreshButton(); } }
private PreviewTopComponent() { initComponents(); setName(NbBundle.getMessage(PreviewTopComponent.class, "CTL_PreviewTopComponent")); // setToolTipText(NbBundle.getMessage(PreviewTopComponent.class, // "HINT_PreviewTopComponent")); setIcon(ImageUtilities.loadImage(ICON_PATH)); if (UIUtils.isAquaLookAndFeel()) { previewPanel.setBackground(UIManager.getColor("NbExplorerView.background")); } if (UIUtils.isAquaLookAndFeel()) { southToolbar.setBackground(UIManager.getColor("NbExplorerView.background")); } bannerPanel.setVisible(false); // background color ((JColorButton) backgroundButton) .addPropertyChangeListener( JColorButton.EVENT_COLOR, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class); previewController .getModel() .getProperties() .putValue(PreviewProperty.BACKGROUND_COLOR, (Color) evt.getNewValue()); PreviewUIController previewUIController = Lookup.getDefault().lookup(PreviewUIController.class); previewUIController.refreshPreview(); } }); southBusyLabel.setVisible(false); resetZoomButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { target.resetZoom(); } }); plusButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { target.zoomPlus(); } }); minusButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { target.zoomMinus(); } }); PreviewUIController controller = Lookup.getDefault().lookup(PreviewUIController.class); controller.addPropertyChangeListener(this); PreviewUIModel m = controller.getModel(); if (m != null) { this.model = m; initTarget(model); } }