private Component createOptionsPanel() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); onlyShowOutputOnErrorCheckBox = new JCheckBox("Only Show Output When Errors Occur"); onlyShowOutputOnErrorCheckBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { updateShowOutputOnErrorsSetting(); settingsNode.setValueOfChildAsBoolean( SHOW_OUTPUT_ON_ERROR, onlyShowOutputOnErrorCheckBox.isSelected()); } }); // initialize its default value boolean valueAsBoolean = settingsNode.getValueOfChildAsBoolean( SHOW_OUTPUT_ON_ERROR, onlyShowOutputOnErrorCheckBox.isSelected()); onlyShowOutputOnErrorCheckBox.setSelected(valueAsBoolean); updateShowOutputOnErrorsSetting(); panel.add(Utility.addLeftJustifiedComponent(onlyShowOutputOnErrorCheckBox)); return panel; }
private JPanel createCompPanel() { filesets = new Vector(); int count = installer.getIntegerProperty("comp.count"); JPanel panel = new JPanel(new GridLayout(count, 1)); String osClass = OperatingSystem.getOperatingSystem().getClass().getName(); osClass = osClass.substring(osClass.indexOf('$') + 1); for (int i = 0; i < count; i++) { String os = installer.getProperty("comp." + i + ".os"); if (os != null && !osClass.equals(os)) continue; JCheckBox checkBox = new JCheckBox( installer.getProperty("comp." + i + ".name") + " (" + installer.getProperty("comp." + i + ".disk-size") + "Mb)"); checkBox.getModel().setSelected(true); checkBox.addActionListener(this); checkBox.setRequestFocusEnabled(false); filesets.addElement(new Integer(i)); panel.add(checkBox); } Dimension dim = panel.getPreferredSize(); dim.width = Integer.MAX_VALUE; panel.setMaximumSize(dim); return panel; }
/** Show the filter dialog */ public void showDialog() { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); include_panel = new ServiceFilterPanel("Include messages based on target service:", filter_include_list); exclude_panel = new ServiceFilterPanel("Exclude messages based on target service:", filter_exclude_list); status_box = new JCheckBox("Filter messages based on status:"); status_box.addActionListener(this); status_active = new JRadioButton("Active messages only"); status_active.setSelected(true); status_active.setEnabled(false); status_complete = new JRadioButton("Complete messages only"); status_complete.setEnabled(false); status_group = new ButtonGroup(); status_group.add(status_active); status_group.add(status_complete); if (filter_active || filter_complete) { status_box.setSelected(true); status_active.setEnabled(true); status_complete.setEnabled(true); if (filter_complete) { status_complete.setSelected(true); } } status_options = new JPanel(); status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS)); status_options.add(status_active); status_options.add(status_complete); status_options.setBorder(indent_border); status_panel = new JPanel(); status_panel.setLayout(new BorderLayout()); status_panel.add(status_box, BorderLayout.NORTH); status_panel.add(status_options, BorderLayout.CENTER); status_panel.setBorder(empty_border); ok_button = new JButton("Ok"); ok_button.addActionListener(this); cancel_button = new JButton("Cancel"); cancel_button.addActionListener(this); buttons = new JPanel(); buttons.setLayout(new FlowLayout()); buttons.add(ok_button); buttons.add(cancel_button); panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(include_panel); panel.add(exclude_panel); panel.add(status_panel); panel.add(buttons); dialog = new JDialog(); dialog.setTitle("SOAP Monitor Filter"); dialog.setContentPane(panel); dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); dialog.setModal(true); dialog.pack(); Dimension d = dialog.getToolkit().getScreenSize(); dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2); ok_pressed = false; dialog.show(); }
/*-------------------------------------------------------------------------*/ public FoeTypeSelection(int dirtyFlag) { this.dirtyFlag = dirtyFlag; List<String> foeTypesList = new ArrayList<String>(Database.getInstance().getFoeTypes().keySet()); Collections.sort(foeTypesList); int max = foeTypesList.size(); checkBoxes = new HashMap<String, JCheckBox>(); JPanel panel = new JPanel(new GridLayout(max / 2 + 2, 2, 3, 3)); selectAll = new JButton("Select All"); selectAll.addActionListener(this); selectNone = new JButton("Select None"); selectNone.addActionListener(this); panel.add(selectAll); panel.add(selectNone); for (String s : foeTypesList) { JCheckBox cb = new JCheckBox(s); checkBoxes.put(s, cb); cb.addActionListener(this); panel.add(cb); } JScrollPane scroller = new JScrollPane(panel); this.add(scroller); }
/** Constructor */ public ServiceFilterPanel(String text, Vector list) { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); service_box = new JCheckBox(text); service_box.addActionListener(this); service_data = new Vector(); if (list != null) { service_box.setSelected(true); service_data = (Vector) list.clone(); } service_list = new JList(service_data); service_list.setBorder(new EtchedBorder()); service_list.setVisibleRowCount(5); service_list.addListSelectionListener(this); service_list.setEnabled(service_box.isSelected()); service_scroll = new JScrollPane(service_list); service_scroll.setBorder(new EtchedBorder()); remove_service_button = new JButton("Remove"); remove_service_button.addActionListener(this); remove_service_button.setEnabled(false); remove_service_panel = new JPanel(); remove_service_panel.setLayout(new FlowLayout()); remove_service_panel.add(remove_service_button); service_area = new JPanel(); service_area.setLayout(new BorderLayout()); service_area.add(service_scroll, BorderLayout.CENTER); service_area.add(remove_service_panel, BorderLayout.EAST); service_area.setBorder(indent_border); add_service_field = new JTextField(); add_service_field.addActionListener(this); add_service_field.getDocument().addDocumentListener(this); add_service_field.setEnabled(service_box.isSelected()); add_service_button = new JButton("Add"); add_service_button.addActionListener(this); add_service_button.setEnabled(false); add_service_panel = new JPanel(); add_service_panel.setLayout(new BorderLayout()); JPanel dummy = new JPanel(); dummy.setBorder(empty_border); add_service_panel.add(dummy, BorderLayout.WEST); add_service_panel.add(add_service_button, BorderLayout.EAST); add_service_area = new JPanel(); add_service_area.setLayout(new BorderLayout()); add_service_area.add(add_service_field, BorderLayout.CENTER); add_service_area.add(add_service_panel, BorderLayout.EAST); add_service_area.setBorder(indent_border); setLayout(new BorderLayout()); add(service_box, BorderLayout.NORTH); add(service_area, BorderLayout.CENTER); add(add_service_area, BorderLayout.SOUTH); setBorder(empty_border); }
GitManualPushToBranch( @NotNull Collection<GitRepository> repositories, @NotNull final Runnable performOnRefresh) { super(); myRepositories = repositories; myManualPush = new JCheckBox("Push current branch to alternative branch: ", false); myManualPush.setMnemonic('b'); myDestBranchTextField = new JTextField(20); myComment = new JBLabel("This will apply to all selected repositories", UIUtil.ComponentStyle.SMALL); myRefreshAction = new GitPushLogRefreshAction() { @Override public void actionPerformed(AnActionEvent e) { performOnRefresh.run(); } }; myRefreshButton = new ActionButton( myRefreshAction, myRefreshAction.getTemplatePresentation(), myRefreshAction.getTemplatePresentation().getText(), ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE); myRefreshButton.setFocusable(true); final ShortcutSet shortcutSet = ActionManager.getInstance().getAction(IdeActions.ACTION_REFRESH).getShortcutSet(); myRefreshAction.registerCustomShortcutSet(shortcutSet, myRefreshButton); myRemoteSelector = new RemoteSelector(getRemotesWithCommonNames(repositories)); myRemoteSelectorComponent = myRemoteSelector.createComponent(); setDefaultComponentsEnabledState(myManualPush.isSelected()); myManualPush.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean isManualPushSelected = myManualPush.isSelected(); setDefaultComponentsEnabledState(isManualPushSelected); if (isManualPushSelected) { myDestBranchTextField.requestFocus(); myDestBranchTextField.selectAll(); } } }); layoutComponents(); }
public DvcsCommitAdditionalComponent( @NotNull final Project project, @NotNull CheckinProjectPanel panel) { myCheckinPanel = panel; myPanel = new JPanel(new GridBagLayout()); final Insets insets = new Insets(2, 2, 2, 2); // add amend checkbox GridBagConstraints c = new GridBagConstraints(); // todo change to MigLayout c.gridx = 0; c.gridy = 1; c.gridwidth = 2; c.anchor = GridBagConstraints.CENTER; c.insets = insets; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; myAmend = new NonFocusableCheckBox(DvcsBundle.message("commit.amend")); myAmend.setMnemonic('m'); myAmend.setToolTipText(DvcsBundle.message("commit.amend.tooltip")); myPreviousMessage = myCheckinPanel.getCommitMessage(); myAmend.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (myAmend.isSelected()) { if (myPreviousMessage.equals( myCheckinPanel .getCommitMessage())) { // if user has already typed something, don't revert // it if (myMessagesForRoots == null) { loadMessagesInModalTask(project); // load all commit messages for all repositories } String message = constructAmendedMessage(); if (!StringUtil.isEmptyOrSpaces(message)) { myAmendedMessage = message; substituteCommitMessage(myAmendedMessage); } } } else { // there was the amended message, but user has changed it => not reverting if (myCheckinPanel.getCommitMessage().equals(myAmendedMessage)) { myCheckinPanel.setCommitMessage(myPreviousMessage); } } } }); myPanel.add(myAmend, c); }
public MyValueEditor() { final ActionListener itemChoosen = new ActionListener() { @Override public void actionPerformed(@NotNull ActionEvent e) { if (myCurrentNode != null) { myCurrentNode.setValue(getCellEditorValue()); somethingChanged(); } } }; myBooleanEditor.addActionListener(itemChoosen); myOptionsEditor.addActionListener(itemChoosen); myBooleanEditor.putClientProperty("JComponent.sizeVariant", "small"); myOptionsEditor.putClientProperty("JComponent.sizeVariant", "small"); }
private Component createCustomExecutorPanel() { useCustomGradleExecutorCheckBox = new JCheckBox("Use Custom Gradle Executor"); customGradleExecutorField = new JTextField(); customGradleExecutorField.setEditable(false); browseForCustomGradleExecutorButton = new JButton( new AbstractAction("Browse...") { public void actionPerformed(ActionEvent e) { browseForCustomGradleExecutor(); } }); String customExecutorPath = settingsNode.getValueOfChild(CUSTOM_GRADLE_EXECUTOR, null); if (customExecutorPath == null) { setCustomGradleExecutor(null); } else { setCustomGradleExecutor(new File(customExecutorPath)); } JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(Utility.addLeftJustifiedComponent(useCustomGradleExecutorCheckBox)); JComponent sideBySideComponent = createSideBySideComponent(customGradleExecutorField, browseForCustomGradleExecutorButton); sideBySideComponent.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0)); // indent it panel.add(sideBySideComponent); useCustomGradleExecutorCheckBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (useCustomGradleExecutorCheckBox .isSelected()) { // if they checked it, browse for a custom executor immediately browseForCustomGradleExecutor(); } else { setCustomGradleExecutor(null); } } }); return panel; }
public AmendComponent( @NotNull Project project, @NotNull RepositoryManager<? extends Repository> repoManager, @NotNull CheckinProjectPanel panel, @NotNull String title) { myRepoManager = repoManager; myCheckinPanel = panel; myAmend = new NonFocusableCheckBox(title); myAmend.setMnemonic('m'); myAmend.setToolTipText(DvcsBundle.message("commit.amend.tooltip")); myPreviousMessage = myCheckinPanel.getCommitMessage(); myAmend.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (myAmend.isSelected()) { if (myPreviousMessage.equals( myCheckinPanel .getCommitMessage())) { // if user has already typed something, don't revert // it if (myMessagesForRoots == null) { loadMessagesInModalTask(project); // load all commit messages for all repositories } String message = constructAmendedMessage(); if (!StringUtil.isEmptyOrSpaces(message)) { myAmendedMessage = message; substituteCommitMessage(myAmendedMessage); } } } else { // there was the amended message, but user has changed it => not reverting if (myCheckinPanel.getCommitMessage().equals(myAmendedMessage)) { myCheckinPanel.setCommitMessage(myPreviousMessage); } } } }); }
// Sample to test the class public static void main(String[] args) { final LayerManager lm = new LayerManager(); // Schema containing a single Geometry attribute FeatureSchema fs1 = new FeatureSchema(); fs1.addAttribute("GEOMETRY", AttributeType.GEOMETRY); com.vividsolutions.jump.feature.FeatureDataset ds1 = new com.vividsolutions.jump.feature.FeatureDataset(fs1); lm.addLayer("", "LayerWithJustGeometry", ds1); // Schema containing a Geometry and a String attributes FeatureSchema fs2 = new FeatureSchema(); fs2.addAttribute("GEOMETRY", AttributeType.GEOMETRY); fs2.addAttribute("Name", AttributeType.STRING); com.vividsolutions.jump.feature.FeatureDataset ds2 = new com.vividsolutions.jump.feature.FeatureDataset(fs2); lm.addLayer("", "LayerWithStringAttribute", ds2); // Schema containing a Geometry, a String and a Integer attributes FeatureSchema fs3 = new FeatureSchema(); fs3.addAttribute("GEOMETRY", AttributeType.GEOMETRY); fs3.addAttribute("Name", AttributeType.STRING); fs3.addAttribute("Age", AttributeType.INTEGER); com.vividsolutions.jump.feature.FeatureDataset ds3 = new com.vividsolutions.jump.feature.FeatureDataset(fs3); lm.addLayer("", "LayerWithNumericAttribute", ds3); // MultiInputDialog usage demonstration final MultiInputDialog d = new MultiInputDialog(null, "Title!", true); d.setInset(2); d.addSubTitle("Subtitle 1"); d.addLabel("This is just a label"); d.addTextField("Name", "", 24, null, ""); d.addPositiveIntegerField("Age", 0, 6, ""); d.addNonNegativeDoubleField("Salary", 0, 12, ""); d.addComboBox( "Occupation", "Cadre", java.util.Arrays.asList("Manager", "Developper", "Technician", "Secretary"), ""); d.indentLabel("Occupation"); d.addSubTitle("Layer and attribute selection"); AttributeTypeFilter STRING_FILTER = new AttributeTypeFilter(AttributeTypeFilter.STRING); AttributeTypeFilter NUMERIC_FILTER = AttributeTypeFilter.NUMERIC_FILTER; AttributeTypeFilter NOGEOM_FILTER = AttributeTypeFilter.NO_GEOMETRY_FILTER; AttributeTypeFilter ALL_FILTER = AttributeTypeFilter.ALL_FILTER; final JComboBox typeChooser = d.addComboBox( "Choose Attribute Type", "ALL", Arrays.asList(STRING_FILTER, NUMERIC_FILTER, ALL_FILTER, NOGEOM_FILTER), ""); final JComboBox layerChooser = d.addLayerComboBox("LayerField", null, "ToolTip", lm); final JComboBox attributeChooser = d.addAttributeComboBox("Attribute field", "LayerField", NUMERIC_FILTER, ""); typeChooser.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { AttributeTypeFilter atf = (AttributeTypeFilter) typeChooser.getSelectedItem(); layerChooser.setModel(new DefaultComboBoxModel(atf.filter(lm).toArray(new Layer[0]))); } }); d.addSeparator(); final JCheckBox jcb = d.addCheckBox("Display icon", false, ""); JButton button = d.addButton("Switch image panel"); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (d.infoPanel.getDescription().equals("")) { d.infoPanel.setDescription( "Description of the dialog box.\nThis description must be helpful for the user. I must give meaningful information about which parameters are mandatory, optional, what they represent and which value they can take."); d.getConsole().flashMessage("Add description"); } else { d.infoPanel.setDescription(""); d.getConsole().flashMessage("Remove description"); } d.pack(); } }); jcb.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (jcb.isSelected()) { d.infoPanel.setIcon( new ImageIcon( com.vividsolutions.jump.workbench.ui.images.IconLoader.class.getResource( "Butt.gif"))); d.getConsole().flashMessage("Add image"); } else { d.infoPanel.setIcon(null); d.getConsole().flashMessage("Remove image"); } d.pack(); } }); JButton button2 = d.addButton("Second button", "OK", ""); GUIUtil.centreOnScreen(d); d.setVisible(true); // System.out.println(d.getLayer("LayerField")); System.exit(0); }
BeforeRunStepsPanel(StepsBeforeRunListener listener) { myListener = listener; myModel = new CollectionListModel<BeforeRunTask>(); myList = new JBList(myModel); myList.getEmptyText().setText(ExecutionBundle.message("before.launch.panel.empty")); myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); myList.setCellRenderer(new MyListCellRenderer()); myModel.addListDataListener( new ListDataListener() { @Override public void intervalAdded(ListDataEvent e) { adjustVisibleRowCount(); updateText(); } @Override public void intervalRemoved(ListDataEvent e) { adjustVisibleRowCount(); updateText(); } @Override public void contentsChanged(ListDataEvent e) {} private void adjustVisibleRowCount() { myList.setVisibleRowCount(Math.max(4, Math.min(8, myModel.getSize()))); } }); ToolbarDecorator myDecorator = ToolbarDecorator.createDecorator(myList); if (!SystemInfo.isMac) { myDecorator.setAsUsualTopToolbar(); } myDecorator.setEditAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { int index = myList.getSelectedIndex(); if (index == -1) return; Pair<BeforeRunTask, BeforeRunTaskProvider<BeforeRunTask>> selection = getSelection(); if (selection == null) return; BeforeRunTask task = selection.getFirst(); BeforeRunTaskProvider<BeforeRunTask> provider = selection.getSecond(); if (provider.configureTask(myRunConfiguration, task)) { myModel.setElementAt(task, index); } } }); myDecorator.setEditActionUpdater( new AnActionButtonUpdater() { @Override public boolean isEnabled(AnActionEvent e) { Pair<BeforeRunTask, BeforeRunTaskProvider<BeforeRunTask>> selection = getSelection(); return selection != null && selection.getSecond().isConfigurable(); } }); myDecorator.setAddAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { doAddAction(button); } }); myDecorator.setAddActionUpdater( new AnActionButtonUpdater() { @Override public boolean isEnabled(AnActionEvent e) { return checkBeforeRunTasksAbility(true); } }); myShowSettingsBeforeRunCheckBox = new JCheckBox(ExecutionBundle.message("configuration.edit.before.run")); myShowSettingsBeforeRunCheckBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateText(); } }); myPanel = myDecorator.createPanel(); setLayout(new BorderLayout()); add(myPanel, BorderLayout.CENTER); add(myShowSettingsBeforeRunCheckBox, BorderLayout.SOUTH); }
private void createUI() { setThumbnailSubsampling(); final Dimension imageSize = getScaledImageSize(); thumbnailLoader = new ProgressMonitorSwingWorker<BufferedImage, Object>( this, "Loading thumbnail image...") { @Override protected BufferedImage doInBackground(ProgressMonitor pm) throws Exception { return createThumbNailImage(imageSize, pm); } @Override protected void done() { BufferedImage thumbnail = null; try { thumbnail = get(); } catch (Exception e) { if (e instanceof IOException) { showErrorDialog("Failed to load thumbnail image:\n" + e.getMessage()); } } if (thumbnail != null) { imageCanvas.setImage(thumbnail); } } }; thumbnailLoader.execute(); imageCanvas = new SliderBoxImageDisplay(imageSize.width, imageSize.height, this); imageCanvas.setSize(imageSize.width, imageSize.height); setComponentName(imageCanvas, "ImageCanvas"); imageScrollPane = new JScrollPane(imageCanvas); imageScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); imageScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); imageScrollPane .getViewport() .setExtentSize(new Dimension(MAX_THUMBNAIL_WIDTH, 2 * MAX_THUMBNAIL_WIDTH)); setComponentName(imageScrollPane, "ImageScrollPane"); subsetWidthLabel = new JLabel("####", JLabel.RIGHT); subsetHeightLabel = new JLabel("####", JLabel.RIGHT); setToVisibleButton = new JButton("Use Preview"); /*I18N*/ setToVisibleButton.setMnemonic('v'); setToVisibleButton.setToolTipText("Use coordinates of visible thumbnail area"); /*I18N*/ setToVisibleButton.addActionListener(this); setComponentName(setToVisibleButton, "UsePreviewButton"); fixSceneWidthCheck = new JCheckBox("Fix full width"); fixSceneWidthCheck.setMnemonic('w'); fixSceneWidthCheck.setToolTipText("Checks whether or not to fix the full scene width"); fixSceneWidthCheck.addActionListener(this); setComponentName(fixSceneWidthCheck, "FixWidthCheck"); fixSceneHeightCheck = new JCheckBox("Fix full height"); fixSceneHeightCheck.setMnemonic('h'); fixSceneHeightCheck.setToolTipText("Checks whether or not to fix the full scene height"); fixSceneHeightCheck.addActionListener(this); setComponentName(fixSceneHeightCheck, "FixHeightCheck"); JPanel textInputPane = GridBagUtils.createPanel(); setComponentName(textInputPane, "TextInputPane"); final JTabbedPane tabbedPane = new JTabbedPane(); setComponentName(tabbedPane, "coordinatePane"); tabbedPane.addTab("Pixel Coordinates", createPixelCoordinatesPane()); tabbedPane.addTab("Geo Coordinates", createGeoCoordinatesPane()); tabbedPane.setEnabledAt(1, canUseGeoCoordinates(product)); GridBagConstraints gbc = GridBagUtils.createConstraints("insets.left=7,anchor=WEST,fill=HORIZONTAL, weightx=1.0"); GridBagUtils.setAttributes(gbc, "gridwidth=2"); GridBagUtils.addToPanel(textInputPane, tabbedPane, gbc, "gridx=0,gridy=0"); GridBagUtils.setAttributes(gbc, "insets.top=7,gridwidth=1"); GridBagUtils.addToPanel(textInputPane, new JLabel("Scene step X:"), gbc, "gridx=0,gridy=1"); GridBagUtils.addToPanel( textInputPane, UIUtils.createSpinner(paramSX, 1, "#0"), gbc, "gridx=1,gridy=1"); GridBagUtils.setAttributes(gbc, "insets.top=1"); GridBagUtils.addToPanel(textInputPane, new JLabel("Scene step Y:"), gbc, "gridx=0,gridy=2"); GridBagUtils.addToPanel( textInputPane, UIUtils.createSpinner(paramSY, 1, "#0"), gbc, "gridx=1,gridy=2"); GridBagUtils.setAttributes(gbc, "insets.top=4"); GridBagUtils.addToPanel( textInputPane, new JLabel("Subset scene width:"), gbc, "gridx=0,gridy=3"); GridBagUtils.addToPanel(textInputPane, subsetWidthLabel, gbc, "gridx=1,gridy=3"); GridBagUtils.setAttributes(gbc, "insets.top=1"); GridBagUtils.addToPanel( textInputPane, new JLabel("Subset scene height:"), gbc, "gridx=0,gridy=4"); GridBagUtils.addToPanel(textInputPane, subsetHeightLabel, gbc, "gridx=1,gridy=4"); GridBagUtils.setAttributes(gbc, "insets.top=4,gridwidth=1"); GridBagUtils.addToPanel( textInputPane, new JLabel("Source scene width:"), gbc, "gridx=0,gridy=5"); GridBagUtils.addToPanel( textInputPane, new JLabel(String.valueOf(product.getSceneRasterWidth()), JLabel.RIGHT), gbc, "gridx=1,gridy=5"); GridBagUtils.setAttributes(gbc, "insets.top=1"); GridBagUtils.addToPanel( textInputPane, new JLabel("Source scene height:"), gbc, "gridx=0,gridy=6"); GridBagUtils.addToPanel( textInputPane, new JLabel(String.valueOf(product.getSceneRasterHeight()), JLabel.RIGHT), gbc, "gridx=1,gridy=6"); GridBagUtils.setAttributes(gbc, "insets.top=7,gridwidth=1, gridheight=2"); GridBagUtils.addToPanel(textInputPane, setToVisibleButton, gbc, "gridx=0,gridy=7"); GridBagUtils.setAttributes(gbc, "insets.top=7,gridwidth=1, gridheight=1"); GridBagUtils.addToPanel(textInputPane, fixSceneWidthCheck, gbc, "gridx=1,gridy=7"); GridBagUtils.setAttributes(gbc, "insets.top=1,gridwidth=1"); GridBagUtils.addToPanel(textInputPane, fixSceneHeightCheck, gbc, "gridx=1,gridy=8"); setLayout(new BorderLayout(4, 4)); add(imageScrollPane, BorderLayout.WEST); add(textInputPane, BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7)); updateUIState(null); imageCanvas.scrollRectToVisible(imageCanvas.getSliderBoxBounds()); }
private void createUI() { ActionListener productNodeCheckListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateUIState(); } }; checkers = new ArrayList<JCheckBox>(10); JPanel checkersPane = GridBagUtils.createPanel(); setComponentName(checkersPane, "CheckersPane"); GridBagConstraints gbc = GridBagUtils.createConstraints("insets.left=4,anchor=WEST,fill=HORIZONTAL"); for (int i = 0; i < productNodes.length; i++) { ProductNode productNode = (ProductNode) productNodes[i]; String name = productNode.getName(); JCheckBox productNodeCheck = new JCheckBox(name); productNodeCheck.setSelected(selected); productNodeCheck.setFont(SMALL_PLAIN_FONT); productNodeCheck.addActionListener(productNodeCheckListener); if (includeAlways != null && StringUtils.containsIgnoreCase(includeAlways, name)) { productNodeCheck.setSelected(true); productNodeCheck.setEnabled(false); } else if (givenProductSubsetDef != null) { productNodeCheck.setSelected(givenProductSubsetDef.containsNodeName(name)); } checkers.add(productNodeCheck); String description = productNode.getDescription(); JLabel productNodeLabel = new JLabel(description != null ? description : " "); productNodeLabel.setFont(SMALL_ITALIC_FONT); GridBagUtils.addToPanel( checkersPane, productNodeCheck, gbc, "weightx=0,gridx=0,gridy=" + i); GridBagUtils.addToPanel( checkersPane, productNodeLabel, gbc, "weightx=1,gridx=1,gridy=" + i); } // Add a last 'filler' row GridBagUtils.addToPanel( checkersPane, new JLabel(" "), gbc, "gridwidth=2,weightx=1,weighty=1,gridx=0,gridy=" + productNodes.length); ActionListener allCheckListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (e.getSource() == allCheck) { checkAllProductNodes(true); } else if (e.getSource() == noneCheck) { checkAllProductNodes(false); } updateUIState(); } }; allCheck = new JCheckBox("Select all"); allCheck.setName("selectAll"); allCheck.setMnemonic('a'); allCheck.addActionListener(allCheckListener); noneCheck = new JCheckBox("Select none"); noneCheck.setName("SelectNone"); noneCheck.setMnemonic('n'); noneCheck.addActionListener(allCheckListener); JScrollPane scrollPane = new JScrollPane(checkersPane); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); JPanel buttonRow = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 4)); buttonRow.add(allCheck); buttonRow.add(noneCheck); setLayout(new BorderLayout()); add(scrollPane, BorderLayout.CENTER); add(buttonRow, BorderLayout.SOUTH); setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7)); updateUIState(); }
private void componentsInit() { rdoCopyrightReq.setSelected(true); rdoNoAnswerReq.setSelected(true); rdoHasNumber.setSelected(true); cmbDocType.setEnabled(false); txfFromDate.setEnabled(false); txfToDate.setEnabled(false); txfUserName.setEnabled(false); chkAnswerDate.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (chkAnswerDate.isSelected()) { txfFromDate.setEnabled(true); txfToDate.setEnabled(true); } else { if (!chkRequestDate.isSelected() && !chkSetNumberDate.isSelected()) { txfFromDate.setEnabled(false); txfToDate.setEnabled(false); } } } }); chkRequestDate.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (chkRequestDate.isSelected()) { txfFromDate.setEnabled(true); txfToDate.setEnabled(true); } else { if (!chkAnswerDate.isSelected() && !chkSetNumberDate.isSelected()) { txfFromDate.setEnabled(false); txfToDate.setEnabled(false); } } } }); chkSetNumberDate.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (chkSetNumberDate.isSelected()) { txfFromDate.setEnabled(true); txfToDate.setEnabled(true); } else { if (!chkAnswerDate.isSelected() && !chkRequestDate.isSelected()) { txfFromDate.setEnabled(false); txfToDate.setEnabled(false); } } } }); GuiUtils.switchKeyboardOnFocus(txfTitle, LocaleUtils.PERSIAN_LOCALE); GuiUtils.switchKeyboardOnFocus(txfNumber, LocaleUtils.ENGLISH_LOCALE); txfTitle.addKeyListener( new KeyAdapter() { public void keyTyped(KeyEvent e) { if (!(e.getSource() instanceof JTextComponent) || !Character.isDigit(e.getKeyChar())) return; JTextComponent tc = (JTextComponent) e.getSource(); if (tc.getInputContext() == null || tc.getInputContext().getLocale() == null) return; Locale locale = tc.getInputContext().getLocale(); if ("fa".equals(locale.getLanguage())) e.setKeyChar(StringUtils.latinToExtendedArabicDigit(e.getKeyChar())); else if ("ar".equals(locale.getLanguage())) e.setKeyChar(StringUtils.latinToArabicDigit(e.getKeyChar())); } }); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { if (rdoCopyrightReq.isSelected()) { cmbDocType.setEnabled(false); lblNumberSufix.setText( StringConsts.LRM + String.valueOf('\u062D') + " " + StringConsts.LRM + WorkflowConstants.NO_DATA); } if (rdoDepositReq.isSelected()) { cmbDocType.setEnabled(true); lblNumberSufix.setText( StringConsts.LRM + String.valueOf('\u0648') + " " + StringConsts.LRM + WorkflowConstants.NO_DATA); } } }; rdoCopyrightReq.addActionListener(actionListener); rdoDepositReq.addActionListener(actionListener); }
FieldEditorHelper(FieldEditor fieldEditor) { this.fieldEditor = fieldEditor; fieldNameField = fieldEditor.getFieldNameField(); fieldNameField.getDocument().addDocumentListener(new FieldNameChangeListener()); dataTypeCombo = fieldEditor.getDataTypeCombo(); dataTypeCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { dataTypeComboAction(e); } }); calcTypeCombo = fieldEditor.getCalcTypeCombo(); calcTypeCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { calcTypeComboAction(e); } }); lookupViewCombo = fieldEditor.getLookupViewCombo(); lookupViewCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { lookupViewComboAction(e); } }); lookupFieldCombo = fieldEditor.getLookupFieldCombo(); lookupFieldCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { lookupFieldComboAction(e); } }); objRelationshipCombo = fieldEditor.getObjRelationshipCombo(); objRelationshipCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { objRelationshipComboAction(e); } }); objAttributeCombo = fieldEditor.getObjAttributeCombo(); objAttributeCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { objAttributeComboAction(e); } }); defaultValueField = fieldEditor.getDefaultValueField(); defaultValueField.getDocument().addDocumentListener(new DefaultValueChangeListener()); captionField = fieldEditor.getCaptionField(); captionField.getDocument().addDocumentListener(new CaptionChangeListener()); editableCheckBox = fieldEditor.getEditableCheckBox(); editableCheckBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { editableCheckBoxAction(e); } }); visibleCheckBox = fieldEditor.getVisibleCheckBox(); visibleCheckBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { visibleCheckBoxAction(e); } }); displayClassField = fieldEditor.getDisplayClassField(); displayClassField.getDocument().addDocumentListener(new DisplayClassChangeListener()); displayPatternField = fieldEditor.getDisplayPatternField(); displayPatternField.getDocument().addDocumentListener(new DisplayPatternChangeListener()); editClassField = fieldEditor.getEditClassField(); editClassField.getDocument().addDocumentListener(new EditClassChangeListener()); editPatternField = fieldEditor.getEditPatternField(); editPatternField.getDocument().addDocumentListener(new EditPatternChangeListener()); preferredIndexField = fieldEditor.getPreferredIndexField(); preferredIndexField.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { preferredIndexFieldChanged(e); } }); }
protected void initComponents( AirspaceBuilderModel model, final AirspaceBuilderController controller) { final JCheckBox resizeNewShapesCheckBox; final JCheckBox enableEditCheckBox; JPanel newShapePanel = new JPanel(); { JButton newShapeButton = new JButton("New shape"); newShapeButton.setActionCommand(NEW_AIRSPACE); newShapeButton.addActionListener(controller); newShapeButton.setToolTipText("Create a new shape centered in the viewport"); this.factoryComboBox = new JComboBox(defaultAirspaceFactories); this.factoryComboBox.setEditable(false); this.factoryComboBox.setToolTipText("Choose shape type to create"); resizeNewShapesCheckBox = new JCheckBox("Fit new shapes to viewport"); resizeNewShapesCheckBox.setActionCommand(SIZE_NEW_SHAPES_TO_VIEWPORT); resizeNewShapesCheckBox.addActionListener(controller); resizeNewShapesCheckBox.setSelected(controller.isResizeNewShapesToViewport()); resizeNewShapesCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); resizeNewShapesCheckBox.setToolTipText( "New shapes are sized to fit the geographic viewport"); enableEditCheckBox = new JCheckBox("Enable shape editing"); enableEditCheckBox.setActionCommand(ENABLE_EDIT); enableEditCheckBox.addActionListener(controller); enableEditCheckBox.setSelected(controller.isEnableEdit()); enableEditCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); enableEditCheckBox.setToolTipText("Allow modifications to shapes"); Box newShapeBox = Box.createHorizontalBox(); newShapeBox.add(newShapeButton); newShapeBox.add(Box.createHorizontalStrut(5)); newShapeBox.add(this.factoryComboBox); newShapeBox.setAlignmentX(Component.LEFT_ALIGNMENT); JPanel gridPanel = new JPanel(new GridLayout(0, 1, 0, 5)); // rows, cols, hgap, vgap gridPanel.add(newShapeBox); gridPanel.add(resizeNewShapesCheckBox); gridPanel.add(enableEditCheckBox); newShapePanel.setLayout(new BorderLayout()); newShapePanel.add(gridPanel, BorderLayout.NORTH); } JPanel entryPanel = new JPanel(); { this.entryTable = new JTable(model); this.entryTable.setColumnSelectionAllowed(false); this.entryTable.setRowSelectionAllowed(true); this.entryTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); this.entryTable .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!ignoreSelectEvents) { controller.actionPerformed( new ActionEvent(e.getSource(), -1, SELECTION_CHANGED)); } } }); this.entryTable.setToolTipText("<html>Click to select<br>Double-Click to rename</html>"); JScrollPane tablePane = new JScrollPane(this.entryTable); tablePane.setPreferredSize(new Dimension(200, 100)); entryPanel.setLayout(new BorderLayout(0, 0)); // hgap, vgap entryPanel.add(tablePane, BorderLayout.CENTER); } JPanel selectionPanel = new JPanel(); { JButton delselectButton = new JButton("Deselect"); delselectButton.setActionCommand(CLEAR_SELECTION); delselectButton.addActionListener(controller); delselectButton.setToolTipText("Clear the selection"); JButton deleteButton = new JButton("Delete Selected"); deleteButton.setActionCommand(REMOVE_SELECTED); deleteButton.addActionListener(controller); deleteButton.setToolTipText("Delete selected shapes"); JPanel gridPanel = new JPanel(new GridLayout(0, 1, 0, 5)); // rows, cols, hgap, vgap gridPanel.add(delselectButton); gridPanel.add(deleteButton); selectionPanel.setLayout(new BorderLayout()); selectionPanel.add(gridPanel, BorderLayout.NORTH); } this.setLayout(new BorderLayout(30, 0)); // hgap, vgap this.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); // top, left, bottom, right this.add(newShapePanel, BorderLayout.WEST); this.add(entryPanel, BorderLayout.CENTER); this.add(selectionPanel, BorderLayout.EAST); controller.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if (SIZE_NEW_SHAPES_TO_VIEWPORT.equals(e.getPropertyName())) { resizeNewShapesCheckBox.setSelected(controller.isResizeNewShapesToViewport()); } else if (ENABLE_EDIT.equals(e.getPropertyName())) { enableEditCheckBox.setSelected(controller.isEnableEdit()); } } }); }
public void createGUI() { setLayout(new BorderLayout()); toolBar = new JToolBar("options", JToolBar.HORIZONTAL); toolBar.setFloatable(false); toolBar.setOpaque(true); toolBar.setBackground(new Color(154, 12, 12)); toolBar.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); selectAllCB = new JCheckBox("Select All"); selectAllCB.setVisible(false); selectAllCB.setForeground(Color.white); selectAllCB.addActionListener(this); refreshBut = new JButton(new ImageIcon(this.getClass().getResource("/images/reloadIcon.png"))); refreshBut.setVisible(false); refreshBut.setToolTipText("Refresh"); refreshBut.setForeground(new Color(20, 88, 49)); refreshBut.addActionListener(this); backBut = new JButton(new ImageIcon(this.getClass().getResource("/images/backIcon.png"))); backBut.setVisible(false); backBut.setToolTipText("Back"); backBut.setForeground(new Color(20, 88, 49)); backBut.addActionListener(this); deleteBut = new JButton(new ImageIcon(this.getClass().getResource("/images/trashIcon.png"))); deleteBut.setToolTipText("Delete"); deleteBut.setForeground(Color.red); deleteBut.setVisible(false); deleteBut.addActionListener(this); deleteBut.setBackground(Color.red); restoreBut = new JButton(new ImageIcon(this.getClass().getResource("/images/restoreIcon.png"))); restoreBut.setToolTipText("Restore"); restoreBut.setForeground(Color.blue); restoreBut.setVisible(false); restoreBut.addActionListener(this); toolBar.addSeparator(new Dimension(10, 5)); toolBar.add(selectAllCB); toolBar.add(backBut); toolBar.add(refreshBut); toolBar.add(deleteBut); toolBar.add(restoreBut); add(toolBar, "North"); JPanel centPan = new JPanel(new GridBagLayout()); centPan.setBackground(new Color(52, 86, 70)); JLabel label = new JLabel("Select A Category From Left Pane"); label.setFont(new Font("arial", Font.BOLD, 35)); label.setForeground(Color.yellow); centPan.add(label); contentPan = new JScrollPane(centPan); contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); add(contentPan, "Center"); contentPan.repaint(); db = new Database(); // inboxSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id // desc"); // sentmailSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id // desc"); // draftSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id // desc"); // outboxSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id // desc"); // trashSet = db.getData("SELECT * FROM messages,trash WHERE messages.tag='trash' and // messages.msg_id=trash.msg_id ORDER BY deleted_at desc"); }
/** Shows a dialog with input for logs description. */ private void uploadLogs() { ResourceManagementService resources = LoggingUtilsActivator.getResourceService(); final SIPCommDialog dialog = new SIPCommDialog(false) { /** Serial version UID. */ private static final long serialVersionUID = 0L; /** * Dialog is closed. Do nothing. * * @param escaped <tt>true</tt> if this dialog has been closed by pressing */ @Override protected void close(boolean escaped) {} }; dialog.setModal(true); dialog.setTitle(resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON")); Container container = dialog.getContentPane(); container.setLayout(new GridBagLayout()); JLabel descriptionLabel = new JLabel("Add a comment:"); final JTextArea commentTextArea = new JTextArea(); commentTextArea.setRows(4); final JButton uploadButton = new JButton(resources.getI18NString("plugin.loggingutils.UPLOAD_BUTTON")); final SIPCommTextField emailField = new SIPCommTextField(resources.getI18NString("plugin.loggingutils.ARCHIVE_UPREPORT_EMAIL")); final JCheckBox emailCheckBox = new SIPCommCheckBox("Email me when more information is available"); emailCheckBox.setSelected(true); emailCheckBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (!emailCheckBox.isSelected()) { uploadButton.setEnabled(true); emailField.setEnabled(false); } else { emailField.setEnabled(true); if (emailField.getText() != null && emailField.getText().trim().length() > 0) uploadButton.setEnabled(true); else uploadButton.setEnabled(false); } } }); emailField .getDocument() .addDocumentListener( new DocumentListener() { public void insertUpdate(DocumentEvent e) { updateButtonsState(); } public void removeUpdate(DocumentEvent e) { updateButtonsState(); } public void changedUpdate(DocumentEvent e) {} /** Check whether we should enable upload button. */ private void updateButtonsState() { if (emailCheckBox.isSelected() && emailField.getText() != null && emailField.getText().trim().length() > 0) uploadButton.setEnabled(true); else uploadButton.setEnabled(false); } }); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(10, 10, 3, 10); c.weightx = 1.0; c.gridx = 0; c.gridy = 0; container.add(descriptionLabel, c); c.insets = new Insets(0, 10, 10, 10); c.gridy = 1; container.add(new JScrollPane(commentTextArea), c); c.insets = new Insets(0, 10, 0, 10); c.gridy = 2; container.add(emailCheckBox, c); c.insets = new Insets(0, 10, 10, 10); c.gridy = 3; container.add(emailField, c); JButton cancelButton = new JButton(resources.getI18NString("service.gui.CANCEL")); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); uploadButton.setEnabled(false); uploadButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { final ArrayList<String> paramNames = new ArrayList<String>(); final ArrayList<String> paramValues = new ArrayList<String>(); if (emailCheckBox.isSelected()) { paramNames.add("Email"); paramValues.add(emailField.getText()); } paramNames.add("Description"); paramValues.add(commentTextArea.getText()); // don't block the UI thread we may need to show // some ui for password input if protected area on the way new Thread( new Runnable() { public void run() { uploadLogs( getUploadLocation(), LogsCollector.getDefaultFileName(), paramNames.toArray(new String[] {}), paramValues.toArray(new String[] {})); } }) .start(); } finally { dialog.dispose(); } } }); JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)); buttonsPanel.add(uploadButton); buttonsPanel.add(cancelButton); c.anchor = GridBagConstraints.LINE_END; c.weightx = 0; c.gridy = 4; container.add(buttonsPanel, c); dialog.setVisible(true); }
public EditorPaneFrame() { setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); final Stack<String> urlStack = new Stack<>(); final JEditorPane editorPane = new JEditorPane(); final JTextField url = new JTextField(30); // set up hyperlink listener editorPane.setEditable(false); editorPane.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { // remember URL for back button urlStack.push(event.getURL().toString()); // show URL in text field url.setText(event.getURL().toString()); editorPane.setPage(event.getURL()); } catch (IOException e) { editorPane.setText("Exception: " + e); } } } }); // set up checkbox for toggling edit mode final JCheckBox editable = new JCheckBox(); editable.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { editorPane.setEditable(editable.isSelected()); } }); // set up load button for loading URL ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent event) { try { // remember URL for back button urlStack.push(url.getText()); editorPane.setPage(url.getText()); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }; JButton loadButton = new JButton("Load"); loadButton.addActionListener(listener); url.addActionListener(listener); // set up back button and button action JButton backButton = new JButton("Back"); backButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { if (urlStack.size() <= 1) return; try { // get URL from back button urlStack.pop(); // show URL in text field String urlString = urlStack.peek(); url.setText(urlString); editorPane.setPage(urlString); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }); add(new JScrollPane(editorPane), BorderLayout.CENTER); // put all control components in a panel JPanel panel = new JPanel(); panel.add(new JLabel("URL")); panel.add(url); panel.add(loadButton); panel.add(backButton); panel.add(new JLabel("Editable")); panel.add(editable); add(panel, BorderLayout.SOUTH); }
public SceneLayoutApp() { super(); new Pair(); final JFrame frame = new JFrame("Scene Layout"); final JPanel panel = new JPanel(new BorderLayout()); frame.setContentPane(panel); final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setMaximumSize(screenSize); frame.setSize(screenSize); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JMenuBar mb = new JMenuBar(); frame.setJMenuBar(mb); final JMenu jMenu = new JMenu("File"); mb.add(jMenu); mb.add(new JMenu("Edit")); mb.add(new JMenu("Help")); JMenu menu = new JMenu("Look and Feel"); // // Get all the available look and feel that we are going to use for // creating the JMenuItem and assign the action listener to handle // the selection of menu item to change the look and feel. // UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels(); for (int i = 0; i < lookAndFeelInfos.length; i++) { final UIManager.LookAndFeelInfo lookAndFeelInfo = lookAndFeelInfos[i]; JMenuItem item = new JMenuItem(lookAndFeelInfo.getName()); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { // // Set the look and feel for the frame and update the UI // to use a new selected look and feel. // UIManager.setLookAndFeel(lookAndFeelInfo.getClassName()); SwingUtilities.updateComponentTreeUI(frame); } catch (ClassNotFoundException e1) { e1.printStackTrace(); } catch (InstantiationException e1) { e1.printStackTrace(); } catch (IllegalAccessException e1) { e1.printStackTrace(); } catch (UnsupportedLookAndFeelException e1) { e1.printStackTrace(); } } }); menu.add(item); } mb.add(menu); jMenu.add(new JMenuItem(new scene.action.QuitAction())); panel.add(new JScrollPane(desktopPane), BorderLayout.CENTER); final JToolBar bar = new JToolBar(); panel.add(bar, BorderLayout.NORTH); final JComboBox comboNewWindow = new JComboBox( new String[] {"320:180", "320:240", "640:360", "640:480", "1280:720", "1920:1080"}); comboNewWindow.addActionListener(new CreateSceneWindowAction()); comboNewWindow.setBorder(BorderFactory.createTitledBorder("Create New Window")); bar.add(comboNewWindow); bar.add( new AbstractAction("Progress Bars") { /** Invoked when an action occurs. */ @Override public void actionPerformed(ActionEvent e) { new ProgressBarAnimator(); } }); bar.add( new AbstractAction("Sliders") { /** Invoked when an action occurs. */ @Override public void actionPerformed(ActionEvent e) { new SliderBarAnimator(); } }); final JCheckBox permaViz = new JCheckBox(); permaViz.setText("Show the dump window"); permaViz.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); dumpWindow = new JInternalFrame("perma dump window"); dumpWindow.setContentPane(new JScrollPane(permText)); permaViz.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dumpWindow.setVisible(permaViz.isSelected()); } }); comboNewWindow.setMaximumSize(comboNewWindow.getPreferredSize()); permaViz.setSelected(false); bar.add(new CreateWebViewV1Action()); bar.add(new CreateWebViewV2Action()); bar.add(permaViz); desktopPane.add(dumpWindow); dumpWindow.setSize(400, 400); dumpWindow.setResizable(true); dumpWindow.setClosable(false); dumpWindow.setIconifiable(false); final JMenuBar m = new JMenuBar(); final JMenu cmenu = new JMenu("Create"); m.add(cmenu); final JMenuItem menuItem = new JMenuItem( new AbstractAction("new") { @Override public void actionPerformed(ActionEvent e) { Runnable runnable = new Runnable() { public void run() { Object[] in = (Object[]) XSTREAM.fromXML(permText.getText()); final JInternalFrame ff = new JInternalFrame(); final ScenePanel c = new ScenePanel(); ff.setContentPane(c); desktopPane.add(ff); final Dimension d = (Dimension) in[0]; c.setMaximumSize(d); c.setPreferredSize(d); ff.setSize(d.width + 50, d.height + 50); ScenePanel.panes.put(c, (List<Pair<Point, ArrayList<URL>>>) in[1]); c.invalidate(); c.repaint(); ff.pack(); ff.setClosable(true); ff.setMaximizable(false); ff.setIconifiable(false); ff.setResizable(false); ff.show(); } }; SwingUtilities.invokeLater(runnable); } }); cmenu.add(menuItem); // JMenuBar menuBar = new JMenuBar(); // getContentPane().add(menuBar); dumpWindow.setJMenuBar(m); frame.setVisible(true); }
public EditorPaneHTMLHelp(String htmlFile) { if (GlobalValues.useSystemBrowserForHelp) { Desktop d = GlobalValues.desktop; try { // create a temp file GlobalValues.forHTMLHelptempFile = new File("tempHTMLHelpSynthetic.html"); FileWriter fw = new FileWriter(GlobalValues.forHTMLHelptempFile); java.util.List<String> list = readTextFromJar(htmlFile); Iterator<String> it = list.iterator(); while (it.hasNext()) { fw.write(it.next() + "\n"); } String canonicalPathOfFile = GlobalValues.forHTMLHelptempFile.getCanonicalPath(); URL urlFile = new URL("file://" + canonicalPathOfFile); URI uriOfFile = urlFile.toURI(); fw.close(); d.browse(uriOfFile); } catch (Exception e) { e.printStackTrace(); } } else { URL initialURL = getClass().getResource(htmlFile); font = GlobalValues.htmlfont; String title = "HTML Help"; setTitle(title); final Stack<String> urlStack = new Stack<String>(); final JEditorPane editorPane; editorPane = new JEditorPane(new HTMLEditorKit().getContentType(), " "); editorPane.setOpaque(false); editorPane.setBorder(null); editorPane.setEditable(false); JPanel magPanel = new JPanel(); magnificationFactor = GlobalValues.helpMagnificationFactor; magFactor = new JTextField(Double.toString(magnificationFactor)); JButton magButton = new JButton("Set Magnification: "); magButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { magnificationFactor = Double.parseDouble(magFactor.getText()); GlobalValues.helpMagnificationFactor = magnificationFactor; } }); magPanel.setLayout(new GridLayout(1, 2)); magPanel.add(magButton); magPanel.add(magFactor); final JTextField url = new JTextField(initialURL.toString()); // set up hyperlink listener editorPane.setEditable(false); try { // remember URL for back button urlStack.push(initialURL.toString()); // show URL in text field url.setText(initialURL.toString()); // add a CSS rule to force body tags to use the default label font // instead of the value in javax.swing.text.html.default.csss String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() * GlobalValues.helpMagnificationFactor + "pt; }"; ((HTMLDocument) editorPane.getDocument()).getStyleSheet().addRule(bodyRule); editorPane.setPage(initialURL); editorPane.firePropertyChange("dummyProp", true, false); } catch (IOException e) { editorPane.setText("Exception: " + e); } editorPane.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() * GlobalValues.helpMagnificationFactor + "pt; }"; ((HTMLDocument) editorPane.getDocument()).getStyleSheet().addRule(bodyRule); } }); editorPane.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { // remember URL for back button urlStack.push(event.getURL().toString()); // show URL in text field url.setText(event.getURL().toString()); editorPane.setPage(event.getURL()); editorPane.firePropertyChange("dummyProp", true, false); } catch (IOException e) { editorPane.setText("Exception: " + e); } } } }); // set up checkbox for toggling edit mode final JCheckBox editable = new JCheckBox(); editable.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { editorPane.setEditable(editable.isSelected()); } }); // set up load button for loading URL ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent event) { try { // remember URL for back button urlStack.push(url.getText()); editorPane.setPage(url.getText()); editorPane.firePropertyChange("dummyProp", true, false); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }; JButton loadButton = new JButton("Load/Magnify"); loadButton.addActionListener(listener); url.addActionListener(listener); // set up back button and button action JButton backButton = new JButton("Back"); backButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { if (urlStack.size() <= 1) return; try { // get URL from back button urlStack.pop(); // show URL in text field String urlString = urlStack.peek(); url.setText(urlString); editorPane.setPage(urlString); editorPane.firePropertyChange("dummyProp", true, false); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }); JPanel allPanel = new JPanel(new BorderLayout()); // put all control components in a panel JPanel ctrlPanel = new JPanel(new BorderLayout()); JPanel urlPanel = new JPanel(); urlPanel.add(new JLabel("URL")); urlPanel.add(url); JPanel buttonPanel = new JPanel(); buttonPanel.add(loadButton); buttonPanel.add(backButton); buttonPanel.add(new JLabel("Editable")); buttonPanel.add(magPanel); buttonPanel.add(editable); ctrlPanel.add(buttonPanel, BorderLayout.NORTH); ctrlPanel.add(urlPanel, BorderLayout.CENTER); allPanel.add(ctrlPanel, BorderLayout.NORTH); allPanel.add(new JScrollPane(editorPane), BorderLayout.CENTER); add(allPanel); } }
/** Creating the configuration form */ private void init() { ResourceManagementService resources = LoggingUtilsActivator.getResourceService(); enableCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.ENABLE_DISABLE")); enableCheckBox.addActionListener(this); sipProtocolCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.sipaccregwizz.PROTOCOL_NAME")); sipProtocolCheckBox.addActionListener(this); jabberProtocolCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.jabberaccregwizz.PROTOCOL_NAME")); jabberProtocolCheckBox.addActionListener(this); String rtpDescription = resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP_DESCRIPTION"); rtpProtocolCheckBox = new SIPCommCheckBox( resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP") + " " + rtpDescription); rtpProtocolCheckBox.addActionListener(this); rtpProtocolCheckBox.setToolTipText(rtpDescription); ice4jProtocolCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_ICE4J")); ice4jProtocolCheckBox.addActionListener(this); JPanel mainPanel = new TransparentPanel(); add(mainPanel, BorderLayout.NORTH); mainPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); enableCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.gridx = 0; c.gridy = 0; mainPanel.add(enableCheckBox, c); String label = resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_DESCRIPTION"); JLabel descriptionLabel = new JLabel(label); descriptionLabel.setToolTipText(label); enableCheckBox.setToolTipText(label); descriptionLabel.setForeground(Color.GRAY); descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(8)); c.gridy = 1; c.insets = new Insets(0, 25, 10, 0); mainPanel.add(descriptionLabel, c); final JPanel loggersButtonPanel = new TransparentPanel(new GridLayout(0, 1)); loggersButtonPanel.setBorder( BorderFactory.createTitledBorder(resources.getI18NString("service.gui.PROTOCOL"))); loggersButtonPanel.add(sipProtocolCheckBox); loggersButtonPanel.add(jabberProtocolCheckBox); loggersButtonPanel.add(rtpProtocolCheckBox); loggersButtonPanel.add(ice4jProtocolCheckBox); c.insets = new Insets(0, 20, 10, 0); c.gridy = 2; mainPanel.add(loggersButtonPanel, c); final JPanel advancedPanel = new TransparentPanel(new GridLayout(0, 2)); advancedPanel.setBorder( BorderFactory.createTitledBorder(resources.getI18NString("service.gui.ADVANCED"))); fileCountField.getDocument().addDocumentListener(this); fileSizeField.getDocument().addDocumentListener(this); fileCountLabel = new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_COUNT")); advancedPanel.add(fileCountLabel); advancedPanel.add(fileCountField); fileSizeLabel = new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_SIZE")); advancedPanel.add(fileSizeLabel); advancedPanel.add(fileSizeField); c.gridy = 3; mainPanel.add(advancedPanel, c); archiveButton = new JButton(resources.getI18NString("plugin.loggingutils.ARCHIVE_BUTTON")); archiveButton.addActionListener(this); c = new GridBagConstraints(); c.anchor = GridBagConstraints.LINE_START; c.weightx = 0; c.gridx = 0; c.gridy = 4; mainPanel.add(archiveButton, c); if (!StringUtils.isNullOrEmpty(getUploadLocation())) { uploadLogsButton = new JButton(resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON")); uploadLogsButton.addActionListener(this); c.insets = new Insets(10, 0, 0, 0); c.gridy = 5; mainPanel.add(uploadLogsButton, c); } }
/** Constructor (create and layout page) */ public SOAPMonitorPage(String host_name) { host = host_name; // Set up default filter (show all messages) filter = new SOAPMonitorFilter(); // Use borders to help improve appearance etched_border = new EtchedBorder(); // Build top portion of split (list panel) model = new SOAPMonitorTableModel(); table = new JTable(model); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setRowSelectionInterval(0, 0); table.setPreferredScrollableViewportSize(new Dimension(600, 96)); table.getSelectionModel().addListSelectionListener(this); scroll = new JScrollPane(table); remove_button = new JButton("Remove"); remove_button.addActionListener(this); remove_button.setEnabled(false); remove_all_button = new JButton("Remove All"); remove_all_button.addActionListener(this); filter_button = new JButton("Filter ..."); filter_button.addActionListener(this); list_buttons = new JPanel(); list_buttons.setLayout(new FlowLayout()); list_buttons.add(remove_button); list_buttons.add(remove_all_button); list_buttons.add(filter_button); list_panel = new JPanel(); list_panel.setLayout(new BorderLayout()); list_panel.add(scroll, BorderLayout.CENTER); list_panel.add(list_buttons, BorderLayout.SOUTH); list_panel.setBorder(empty_border); // Build bottom portion of split (message details) details_time = new JLabel("Time: ", SwingConstants.RIGHT); details_target = new JLabel("Target Service: ", SwingConstants.RIGHT); details_status = new JLabel("Status: ", SwingConstants.RIGHT); details_time_value = new JLabel(); details_target_value = new JLabel(); details_status_value = new JLabel(); Dimension preferred_size = details_time.getPreferredSize(); preferred_size.width = 1; details_time.setPreferredSize(preferred_size); details_target.setPreferredSize(preferred_size); details_status.setPreferredSize(preferred_size); details_time_value.setPreferredSize(preferred_size); details_target_value.setPreferredSize(preferred_size); details_status_value.setPreferredSize(preferred_size); details_header = new JPanel(); details_header_layout = new GridBagLayout(); details_header.setLayout(details_header_layout); details_header_constraints = new GridBagConstraints(); details_header_constraints.fill = GridBagConstraints.BOTH; details_header_constraints.weightx = 0.5; details_header_layout.setConstraints(details_time, details_header_constraints); details_header.add(details_time); details_header_layout.setConstraints(details_time_value, details_header_constraints); details_header.add(details_time_value); details_header_layout.setConstraints(details_target, details_header_constraints); details_header.add(details_target); details_header_constraints.weightx = 1.0; details_header_layout.setConstraints(details_target_value, details_header_constraints); details_header.add(details_target_value); details_header_constraints.weightx = .5; details_header_layout.setConstraints(details_status, details_header_constraints); details_header.add(details_status); details_header_layout.setConstraints(details_status_value, details_header_constraints); details_header.add(details_status_value); details_header.setBorder(etched_border); request_label = new JLabel("SOAP Request", SwingConstants.CENTER); request_text = new SOAPMonitorTextArea(); request_text.setEditable(false); request_scroll = new JScrollPane(request_text); request_panel = new JPanel(); request_panel.setLayout(new BorderLayout()); request_panel.add(request_label, BorderLayout.NORTH); request_panel.add(request_scroll, BorderLayout.CENTER); response_label = new JLabel("SOAP Response", SwingConstants.CENTER); response_text = new SOAPMonitorTextArea(); response_text.setEditable(false); response_scroll = new JScrollPane(response_text); response_panel = new JPanel(); response_panel.setLayout(new BorderLayout()); response_panel.add(response_label, BorderLayout.NORTH); response_panel.add(response_scroll, BorderLayout.CENTER); details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); details_soap.setTopComponent(request_panel); details_soap.setRightComponent(response_panel); details_soap.setResizeWeight(.5); details_panel = new JPanel(); layout_button = new JButton("Switch Layout"); layout_button.addActionListener(this); reflow_xml = new JCheckBox("Reflow XML text"); reflow_xml.addActionListener(this); details_buttons = new JPanel(); details_buttons.setLayout(new FlowLayout()); details_buttons.add(reflow_xml); details_buttons.add(layout_button); details_panel.setLayout(new BorderLayout()); details_panel.add(details_header, BorderLayout.NORTH); details_panel.add(details_soap, BorderLayout.CENTER); details_panel.add(details_buttons, BorderLayout.SOUTH); details_panel.setBorder(empty_border); // Add the two parts to the age split pane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setTopComponent(list_panel); split.setRightComponent(details_panel); // Build status area start_button = new JButton("Start"); start_button.addActionListener(this); stop_button = new JButton("Stop"); stop_button.addActionListener(this); status_buttons = new JPanel(); status_buttons.setLayout(new FlowLayout()); status_buttons.add(start_button); status_buttons.add(stop_button); status_text = new JLabel(); status_text.setBorder(new BevelBorder(BevelBorder.LOWERED)); status_text_panel = new JPanel(); status_text_panel.setLayout(new BorderLayout()); status_text_panel.add(status_text, BorderLayout.CENTER); status_text_panel.setBorder(empty_border); status_area = new JPanel(); status_area.setLayout(new BorderLayout()); status_area.add(status_buttons, BorderLayout.WEST); status_area.add(status_text_panel, BorderLayout.CENTER); status_area.setBorder(etched_border); // Add the split and status area to page setLayout(new BorderLayout()); add(split, BorderLayout.CENTER); add(status_area, BorderLayout.SOUTH); }
/** * A constructor * * @param project the project * @param roots the list of the roots * @param defaultRoot the default root to select */ public GitUnstashDialog( final Project project, final List<VirtualFile> roots, final VirtualFile defaultRoot) { super(project, true); setModal(false); myProject = project; myVcs = GitVcs.getInstance(project); setTitle(GitBundle.getString("unstash.title")); setOKButtonText(GitBundle.getString("unstash.button.apply")); GitUIUtil.setupRootChooser(project, roots, defaultRoot, myGitRootComboBox, myCurrentBranch); myStashList.setModel(new DefaultListModel()); refreshStashList(); myGitRootComboBox.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { refreshStashList(); updateDialogState(); } }); myStashList.addListSelectionListener( new ListSelectionListener() { public void valueChanged(final ListSelectionEvent e) { updateDialogState(); } }); myBranchTextField .getDocument() .addDocumentListener( new DocumentAdapter() { protected void textChanged(final DocumentEvent e) { updateDialogState(); } }); myPopStashCheckBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { updateDialogState(); } }); myClearButton.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { if (Messages.YES == Messages.showYesNoDialog( GitUnstashDialog.this.getContentPane(), GitBundle.message("git.unstash.clear.confirmation.message"), GitBundle.message("git.unstash.clear.confirmation.title"), Messages.getWarningIcon())) { GitLineHandler h = new GitLineHandler(myProject, getGitRoot(), GitCommand.STASH); h.setNoSSH(true); h.addParameters("clear"); GitHandlerUtil.doSynchronously( h, GitBundle.getString("unstash.clearing.stashes"), h.printableCommandLine()); refreshStashList(); updateDialogState(); } } }); myDropButton.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { final StashInfo stash = getSelectedStash(); if (Messages.YES == Messages.showYesNoDialog( GitUnstashDialog.this.getContentPane(), GitBundle.message( "git.unstash.drop.confirmation.message", stash.getStash(), stash.getMessage()), GitBundle.message("git.unstash.drop.confirmation.title", stash.getStash()), Messages.getQuestionIcon())) { final ModalityState current = ModalityState.current(); ProgressManager.getInstance() .run( new Task.Modal(myProject, "Removing stash " + stash.getStash(), false) { @Override public void run(@NotNull ProgressIndicator indicator) { final GitSimpleHandler h = dropHandler(stash.getStash()); try { h.run(); h.unsilence(); } catch (final VcsException ex) { ApplicationManager.getApplication() .invokeLater( new Runnable() { @Override public void run() { GitUIUtil.showOperationError( myProject, ex, h.printableCommandLine()); } }, current); } } }); refreshStashList(); updateDialogState(); } } private GitSimpleHandler dropHandler(String stash) { GitSimpleHandler h = new GitSimpleHandler(myProject, getGitRoot(), GitCommand.STASH); h.setNoSSH(true); h.addParameters("drop"); addStashParameter(h, stash); return h; } }); myViewButton.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { final VirtualFile root = getGitRoot(); String resolvedStash; String selectedStash = getSelectedStash().getStash(); try { GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.REV_LIST); h.setNoSSH(true); h.setSilent(true); h.addParameters("--timestamp", "--max-count=1"); addStashParameter(h, selectedStash); h.endOptions(); final String output = h.run(); resolvedStash = GitRevisionNumber.parseRevlistOutputAsRevisionNumber(h, output).asString(); } catch (VcsException ex) { GitUIUtil.showOperationError(myProject, ex, "resolving revision"); return; } GitShowAllSubmittedFilesAction.showSubmittedFiles( myProject, resolvedStash, root, true, false); } }); init(); updateDialogState(); }
public DownloadPictures(ArrayList<CardDownloadData> cards) { this.cards = cards; bar = new JProgressBar(this); JPanel p0 = new JPanel(); p0.setLayout(new BoxLayout(p0, BoxLayout.Y_AXIS)); p0.add(Box.createVerticalStrut(5)); jLabel1 = new JLabel(); jLabel1.setText("Please select server:"); jLabel1.setAlignmentX(Component.LEFT_ALIGNMENT); p0.add(jLabel1); p0.add(Box.createVerticalStrut(5)); ComboBoxModel jComboBox1Model = new DefaultComboBoxModel( new String[] { "magiccards.info", "wizards.com", "mtgimage.com (HQ)" /*, "mtgathering.ru HQ", "mtgathering.ru MQ", "mtgathering.ru LQ"*/ }); jComboBox1 = new JComboBox(); cardImageSource = MagicCardsImageSource.getInstance(); jComboBox1.setModel(jComboBox1Model); jComboBox1.setAlignmentX(Component.LEFT_ALIGNMENT); jComboBox1.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); switch (cb.getSelectedIndex()) { case 0: cardImageSource = MagicCardsImageSource.getInstance(); break; case 1: cardImageSource = WizardCardsImageSource.getInstance(); break; case 2: cardImageSource = MtgImageSource.getInstance(); break; } int count = DownloadPictures.this.cards.size(); float mb = (count * cardImageSource.getAverageSize()) / 1024; bar.setString( String.format( cardIndex == count ? "%d of %d cards finished! Please close!" : "%d of %d cards finished! Please wait! [%.1f Mb]", 0, count, mb)); } }); p0.add(jComboBox1); p0.add(Box.createVerticalStrut(5)); // Start startDownloadButton = new JButton("Start download"); startDownloadButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new Thread(DownloadPictures.this).start(); startDownloadButton.setEnabled(false); checkBox.setEnabled(false); } }); p0.add(Box.createVerticalStrut(5)); // Progress p0.add(bar); bar.setStringPainted(true); int count = cards.size(); float mb = (count * cardImageSource.getAverageSize()) / 1024; bar.setString( String.format( cardIndex == cards.size() ? "%d of %d cards finished! Please close!" : "%d of %d cards finished! Please wait! [%.1f Mb]", 0, cards.size(), mb)); Dimension d = bar.getPreferredSize(); d.width = 300; bar.setPreferredSize(d); p0.add(Box.createVerticalStrut(5)); checkBox = new JCheckBox("Download images for Standard (Type2) only"); p0.add(checkBox); p0.add(Box.createVerticalStrut(5)); checkBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ArrayList<CardDownloadData> cardsToDownload = DownloadPictures.this.cards; if (checkBox.isSelected()) { DownloadPictures.this.type2cards = new ArrayList<>(); for (CardDownloadData data : DownloadPictures.this.cards) { if (data.isType2() || data.isToken()) { DownloadPictures.this.type2cards.add(data); } } cardsToDownload = DownloadPictures.this.type2cards; } int count = cardsToDownload.size(); float mb = (count * cardImageSource.getAverageSize()) / 1024; bar.setString( String.format( cardIndex == count ? "%d of %d cards finished! Please close!" : "%d of %d cards finished! Please wait! [%.1f Mb]", 0, count, mb)); } }); // JOptionPane Object[] options = {startDownloadButton, closeButton = new JButton("Cancel")}; dlg = new JOptionPane( p0, JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[1]); }
/** * Initializes the GUI by creating the components, placing them in the dialog, and displaying * them. */ private void init() { setForeground(Color.black); setTitle("Nonlocal Means Filter"); JPanel mainPanel; mainPanel = new JPanel(); mainPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); mainPanel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = 1; gbc.gridheight = 1; gbc.anchor = GridBagConstraints.WEST; gbc.weightx = 1; gbc.insets = new Insets(3, 3, 3, 3); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.HORIZONTAL; paramPanel = new JPanel(new GridBagLayout()); paramPanel.setForeground(Color.black); paramPanel.setBorder(buildTitledBorder("Parameters")); mainPanel.add(paramPanel, gbc); GridBagConstraints gbc2 = new GridBagConstraints(); gbc2.gridwidth = 1; gbc2.gridheight = 1; gbc2.anchor = GridBagConstraints.WEST; gbc2.weightx = 1; gbc2.insets = new Insets(3, 3, 3, 3); gbc2.gridx = 0; gbc2.gridy = 0; gbc2.fill = GridBagConstraints.HORIZONTAL; labelSearchWindowSide = createLabel("Search window side (odd)"); paramPanel.add(labelSearchWindowSide, gbc2); gbc2.gridx = 1; textSearchWindowSide = createTextField("15"); paramPanel.add(textSearchWindowSide, gbc2); gbc2.gridx = 0; gbc2.gridy = 1; labelSimilarityWindowSide = createLabel("Similarity window side (odd) "); paramPanel.add(labelSimilarityWindowSide, gbc2); gbc2.gridx = 1; textSimilarityWindowSide = createTextField("7"); paramPanel.add(textSimilarityWindowSide, gbc2); gbc2.gridx = 0; gbc2.gridy = 2; labelNoiseStandardDeviation = createLabel("Noise standard deviation "); paramPanel.add(labelNoiseStandardDeviation, gbc2); gbc2.gridx = 1; textNoiseStandardDeviation = createTextField("10.0"); paramPanel.add(textNoiseStandardDeviation, gbc2); gbc2.gridx = 0; gbc2.gridy = 3; labelDegree = createLabel("Degree of filtering "); labelDegree.setEnabled(doRician); paramPanel.add(labelDegree, gbc2); gbc2.gridx = 1; textDegree = createTextField("1.414"); textDegree.setEnabled(doRician); paramPanel.add(textDegree, gbc2); gbc2.gridx = 0; gbc2.gridy = 4; doRicianCheckBox = new JCheckBox("Deal with Rician noise in MRI"); doRicianCheckBox.setFont(serif12); doRicianCheckBox.setSelected(false); doRicianCheckBox.addActionListener(this); paramPanel.add(doRicianCheckBox, gbc2); if (image.getNDims() > 2) { gbc2.gridx = 0; gbc2.gridy = 5; gbc2.gridwidth = 2; image25DCheckBox = new JCheckBox("Process each slice independently (2.5D)"); image25DCheckBox.setFont(serif12); paramPanel.add(image25DCheckBox, gbc2); image25DCheckBox.setSelected(false); } // if (image.getNDims > 2) JPanel outputOptPanel = new JPanel(new GridLayout(1, 2)); destinationPanel = new JPanel(new BorderLayout()); destinationPanel.setForeground(Color.black); destinationPanel.setBorder(buildTitledBorder("Destination")); outputOptPanel.add(destinationPanel); destinationGroup = new ButtonGroup(); newImage = new JRadioButton("New image", true); newImage.setBounds(10, 16, 120, 25); newImage.setFont(serif12); destinationGroup.add(newImage); destinationPanel.add(newImage, BorderLayout.NORTH); replaceImage = new JRadioButton("Replace image", false); replaceImage.setFont(serif12); destinationGroup.add(replaceImage); destinationPanel.add(replaceImage, BorderLayout.CENTER); // Only if the image is unlocked can it be replaced. if (image.getLockStatus() == ModelStorageBase.UNLOCKED) { replaceImage.setEnabled(true); } else { replaceImage.setEnabled(false); } gbc.gridx = 0; gbc.gridy = 1; mainPanel.add(outputOptPanel, gbc); mainDialogPanel.add(mainPanel, BorderLayout.CENTER); mainDialogPanel.add(buildButtons(), BorderLayout.SOUTH); getContentPane().add(mainDialogPanel); pack(); setResizable(true); // setVisible(true); System.gc(); }
public SyntaxTab() { super(new BorderLayout(), "Syntax highlighting"); /* * upper checkboxes */ JPanel upper = new JPanel(new GridLayout(2, 1, 0, 0)); upper.setOpaque(false); upper.add(MyPanel.wrap(highlightSyntax)); upper.add(MyPanel.wrap(matchBracket)); highlightSyntax.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { SyntaxTab.this.updateComponentStatus(); } }); this.add(upper, BorderLayout.PAGE_START); /* * upper panel (painters) */ painterComboBox.setSelectedItem(myjava.gui.syntax.Painter.getCurrentInstance()); painterComboBox.setFont(f13); if (isMetal) painterComboBox.setBackground(Color.WHITE); painterComboBox.addItemListener(this.painterChangeListener); JButton addPainter = new MyButton("+") { { if (isMetal) { this.setPreferredSize(new Dimension(28, 28)); } } @Override public void actionPerformed(ActionEvent ev) { String name; do { name = JOptionPane.showInputDialog( SyntaxTab.this, "Enter a name:", "Name", JOptionPane.QUESTION_MESSAGE); } while (!myjava.gui.syntax.Painter.isValidPrompt(name, SyntaxTab.this)); if ((name != null) && (!name.isEmpty())) { // name is valid, neither cancelled nor pressed enter directly myjava.gui.syntax.Painter newPainter = ((myjava.gui.syntax.Painter) (painterComboBox.getSelectedItem())) .newInstance(name); addPainter(newPainter); System.out.println("now set, should call listener"); painterComboBox.setSelectedItem(newPainter); // auto-call ItemListener(s) } } }; JButton removePainter = new MyButton("-") { { if (isMetal) { this.setPreferredSize(new Dimension(28, 28)); } } @Override public void actionPerformed(ActionEvent ev) { myjava.gui.syntax.Painter painter = (myjava.gui.syntax.Painter) (painterComboBox.getSelectedItem()); if (painter.equals(myjava.gui.syntax.Painter.getDefaultInstance())) { JOptionPane.showMessageDialog( SyntaxTab.this, "The default painter cannot be removed.", "Error", JOptionPane.ERROR_MESSAGE); } else { int option = JOptionPane.showConfirmDialog( SyntaxTab.this, "Remove painter \"" + painter.getName() + "\"?", "Confirm", JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { // remove "painter" removedPainters.add(painter); painterComboBox.removeItemListener(painterChangeListener); painterComboBox.setSelectedItem(myjava.gui.syntax.Painter.getDefaultInstance()); painterComboBox.removeItem(painter); for (Iterator<EntryListPanel> it = listPanelSet.iterator(); it.hasNext(); ) { EntryListPanel panel = it.next(); if (panel.getPainter().getName().equals(painter.getName())) { System.out.println("removing, then break"); it.remove(); centerPanel.remove(panel); break; } } painterComboBox.addItemListener(painterChangeListener); cardLayout.show( centerPanel, myjava.gui.syntax.Painter.getDefaultInstance().getName()); } } } }; // lower part JPanel center = new JPanel(new BorderLayout()); JLabel selectLabel = new MyLabel("Selected painter:"); center.add( MyPanel.wrap(MyPanel.CENTER, selectLabel, painterComboBox, addPainter, removePainter), BorderLayout.PAGE_START); componentSet.addAll(Arrays.asList(selectLabel, addPainter, removePainter)); center.add(centerPanel, BorderLayout.CENTER); this.add(center, BorderLayout.CENTER); cardLayout.show(centerPanel, myjava.gui.syntax.Painter.getCurrentInstance().getName()); }
private void addCheckbox(final JPanel panel, final TreeAction action) { String text = action instanceof FileStructureFilter ? ((FileStructureFilter) action).getCheckBoxText() : action instanceof FileStructureNodeProvider ? ((FileStructureNodeProvider) action).getCheckBoxText() : null; if (text == null) return; Shortcut[] shortcuts = action instanceof FileStructureFilter ? ((FileStructureFilter) action).getShortcut() : ((FileStructureNodeProvider) action).getShortcut(); final JCheckBox chkFilter = new JCheckBox(); UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, chkFilter); final boolean selected = getDefaultValue(action); chkFilter.setSelected(selected); myTreeActionsOwner.setActionIncluded( action, action instanceof FileStructureFilter ? !selected : selected); chkFilter.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { final boolean state = chkFilter.isSelected(); if (!myAutoClicked.contains(chkFilter)) { saveState(action, state); } myTreeActionsOwner.setActionIncluded( action, action instanceof FileStructureFilter ? !state : state); // final String filter = mySpeedSearch.isPopupActive() ? // mySpeedSearch.getEnteredPrefix() : null; // mySpeedSearch.hidePopup(); Object selection = ContainerUtil.getFirstItem(myAbstractTreeBuilder.getSelectedElements()); if (selection instanceof FilteringTreeStructure.FilteringNode) { selection = ((FilteringTreeStructure.FilteringNode) selection).getDelegate(); } myTreeStructure.rebuildTree(); myFilteringStructure.rebuild(); final Object sel = selection; final Runnable runnable = new Runnable() { public void run() { ApplicationManager.getApplication() .runReadAction( new Runnable() { @Override public void run() { myAbstractTreeBuilder .refilter(sel, true, false) .doWhenProcessed( new Runnable() { @Override public void run() { if (mySpeedSearch.isPopupActive()) { mySpeedSearch.refreshSelection(); } } }); } }); } }; if (ApplicationManager.getApplication().isUnitTestMode()) { runnable.run(); } else { ApplicationManager.getApplication().invokeLater(runnable); } } }); chkFilter.setFocusable(false); if (shortcuts.length > 0) { text += " (" + KeymapUtil.getShortcutText(shortcuts[0]) + ")"; new AnAction() { public void actionPerformed(final AnActionEvent e) { chkFilter.doClick(); } }.registerCustomShortcutSet(new CustomShortcutSet(shortcuts), myTree); } chkFilter.setText(text); panel.add(chkFilter); myCheckBoxes.put(action.getClass(), chkFilter); }
/** Draw the contents of the dialog. */ private void drawDialog() { JPanel oCenterPanel = new JPanel(); GridBagLayout gb = new GridBagLayout(); GridBagConstraints gc = new GridBagConstraints(); gc.anchor = GridBagConstraints.WEST; oCenterPanel.setLayout(gb); gc.insets = new Insets(5, 5, 5, 5); int y = 0; cbIncludeKeywords = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importKeywordData")); //$NON-NLS-1$ cbIncludeKeywords.setSelected(true); cbIncludeKeywords.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeKeywords, gc); oCenterPanel.add(cbIncludeKeywords); cbIncludePlayList = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importPlayListData")); //$NON-NLS-1$ cbIncludePlayList.setSelected(true); cbIncludePlayList.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludePlayList, gc); oCenterPanel.add(cbIncludePlayList); cbIncludeURLs = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importURLData")); //$NON-NLS-1$ cbIncludeURLs.setSelected(true); cbIncludeURLs.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeURLs, gc); oCenterPanel.add(cbIncludeURLs); cbIncludeAttendees = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importAttendeeData")); //$NON-NLS-1$ cbIncludeAttendees.setSelected(true); cbIncludeAttendees.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeAttendees, gc); oCenterPanel.add(cbIncludeAttendees); cbIncludeChats = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.imortChatData")); //$NON-NLS-1$ cbIncludeChats.setSelected(true); cbIncludeChats.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeChats, gc); oCenterPanel.add(cbIncludeChats); cbIncludeWhiteboard = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importWhiteBoardData")); //$NON-NLS-1$ cbIncludeWhiteboard.setSelected(true); cbIncludeWhiteboard.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeWhiteboard, gc); oCenterPanel.add(cbIncludeWhiteboard); cbIncludeAnnotations = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importAnnotationData")); //$NON-NLS-1$ cbIncludeAnnotations.setSelected(true); cbIncludeAnnotations.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeAnnotations, gc); oCenterPanel.add(cbIncludeAnnotations); cbIncludeFileData = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importFileData")); //$NON-NLS-1$ cbIncludeFileData.setSelected(true); cbIncludeFileData.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeFileData, gc); oCenterPanel.add(cbIncludeFileData); cbIncludeVotes = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importVotingData")); //$NON-NLS-1$ cbIncludeVotes.setSelected(true); cbIncludeVotes.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeVotes, gc); oCenterPanel.add(cbIncludeVotes); // Add spacer label JLabel spacer = new JLabel(" "); // $NON-NLS-1$ gc.gridy = y; y++; gb.setConstraints(spacer, gc); oCenterPanel.add(spacer); // flag to mark seen/unseen on import cbMarkSeen = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.markSeen")); //$NON-NLS-1$ cbMarkSeen.setSelected(true); cbMarkSeen.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbMarkSeen, gc); oCenterPanel.add(cbMarkSeen); // Add spacer label spacer = new JLabel(" "); // $NON-NLS-1$ gc.gridy = y; y++; gb.setConstraints(spacer, gc); oCenterPanel.add(spacer); gc.gridwidth = 1; UIButtonPanel oButtonPanel = new UIButtonPanel(); pbImport = new UIButton( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importMainButton")); //$NON-NLS-1$ pbImport.setMnemonic( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importMainButtonMnemonic") .charAt(0)); pbImport.addActionListener(this); getRootPane().setDefaultButton(pbImport); oButtonPanel.addButton(pbImport); pbClose = new UIButton( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.cancelButton")); //$NON-NLS-1$ pbClose.setMnemonic( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.cancelButtonMnemonic") .charAt(0)); pbClose.addActionListener(this); oButtonPanel.addButton(pbClose); pbHelp = new UIButton( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.helpButton")); //$NON-NLS-1$ pbHelp.setMnemonic( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.helpButtonMnemonic") .charAt(0)); ProjectCompendium.APP.mainHB.enableHelpOnButton( pbHelp, "io.import_flashmeeting_xml", ProjectCompendium.APP.mainHS); // $NON-NLS-1$ oButtonPanel.addHelpButton(pbHelp); // other initializations oContentPane.setLayout(new BorderLayout()); oContentPane.add(oCenterPanel, BorderLayout.CENTER); oContentPane.add(oButtonPanel, BorderLayout.SOUTH); pack(); setResizable(false); return; }