/** * Tests the combination of a default size spec with an upper bound that shall ensure a maximum * size. */ public void testDefaultWithUpperBound() { TestComponent c1 = new TestComponent(10, 10, 50, 50); FormLayout layout = new FormLayout("[default,20px]", "[default,20px]"); JPanel panel = new JPanel(layout); panel.add(c1, cc.xy(1, 1)); Dimension minimumLayoutSize = layout.minimumLayoutSize(panel); Dimension preferredLayoutSize = layout.preferredLayoutSize(panel); assertEquals("Minimum layout width", 10, minimumLayoutSize.width); assertEquals("Minimum layout height", 10, minimumLayoutSize.height); assertEquals("Preferred layout width", 20, preferredLayoutSize.width); assertEquals("Preferred layout height", 20, preferredLayoutSize.height); panel.setSize(minimumLayoutSize); panel.doLayout(); int columnWidth = c1.getWidth(); int rowHeight = c1.getHeight(); assertEquals("Column width (container min)", 10, columnWidth); assertEquals("Row height (container min)", 10, rowHeight); panel.setSize(preferredLayoutSize); panel.doLayout(); columnWidth = c1.getWidth(); rowHeight = c1.getHeight(); assertEquals("Column width (container pref)", 20, columnWidth); assertEquals("Row height (container pref)", 20, rowHeight); }
/** Checks whether components are aligned according to the row specs. */ public void testVerticalAlignments() { TestComponent top = new TestComponent(7, 2, 9, 4); TestComponent center = new TestComponent(7, 2, 9, 4); TestComponent bottom = new TestComponent(7, 2, 9, 4); TestComponent fill = new TestComponent(7, 2, 9, 4); TestComponent def = new TestComponent(7, 2, 9, 4); FormLayout layout = new FormLayout("pref", "top:10px, center:10px, bottom:10px, fill:10px, 10px"); JPanel panel = new JPanel(layout); panel.add(top, cc.xy(1, 1)); panel.add(center, cc.xy(1, 2)); panel.add(bottom, cc.xy(1, 3)); panel.add(fill, cc.xy(1, 4)); panel.add(def, cc.xy(1, 5)); panel.doLayout(); assertEquals("Top.y", 0, top.getY()); assertEquals("Top.height", 4, top.getHeight()); assertEquals("Center.y", 13, center.getY()); assertEquals("Center.height", 4, center.getHeight()); assertEquals("Bottom.y", 26, bottom.getY()); assertEquals("Bottom.height", 4, bottom.getHeight()); assertEquals("Fill.y", 30, fill.getY()); assertEquals("Fill.height", 10, fill.getHeight()); assertEquals("Default.y", 43, def.getY()); assertEquals("Default.height", 4, def.getHeight()); }
/** Checks whether components are aligned according to the column specs. */ public void testHorizontalAlignments() { TestComponent left = new TestComponent(2, 7, 4, 9); TestComponent center = new TestComponent(2, 7, 4, 9); TestComponent right = new TestComponent(2, 7, 4, 9); TestComponent fill = new TestComponent(2, 7, 4, 9); TestComponent def = new TestComponent(2, 7, 4, 9); FormLayout layout = new FormLayout("left:10px, center:10px, right:10px, fill:10px, 10px", "pref"); JPanel panel = new JPanel(layout); panel.add(left, cc.xy(1, 1)); panel.add(center, cc.xy(2, 1)); panel.add(right, cc.xy(3, 1)); panel.add(fill, cc.xy(4, 1)); panel.add(def, cc.xy(5, 1)); panel.doLayout(); assertEquals("Left.x", 0, left.getX()); assertEquals("Left.width", 4, left.getWidth()); assertEquals("Center.x", 13, center.getX()); assertEquals("Center.width", 4, center.getWidth()); assertEquals("Right.x", 26, right.getX()); assertEquals("Right.width", 4, right.getWidth()); assertEquals("Fill.x", 30, fill.getX()); assertEquals("Fill.width", 10, fill.getWidth()); assertEquals("Default.x", 40, def.getX()); assertEquals("Default.width", 10, def.getWidth()); }
// documentation inherited public void doLayout() { super.doLayout(); // compute our translation coordinates based on our size _tx = (getWidth() - TILE_WIDTH * _width) / 2; _ty = (getHeight() - TILE_HEIGHT * _height) / 2; }
@Override public void doLayout() { if (workspace.kioskLevel == GUIWorkspace.KioskLevel.NONE) { sizeControlXY.setVisible(true); sizeControlX.setVisible(true); sizeControlY.setVisible(true); } super.doLayout(); }
/** Remove panel from top of MapView by class */ public void removeTopPanel(Class<?> type) { int n = leftPanel.getComponentCount(); for (int i = 0; i < n; i++) { Component c = leftPanel.getComponent(i); if (type.isInstance(c)) { leftPanel.remove(i); leftPanel.doLayout(); return; } } }
private JPanel createPreviewPanel() { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); _screenshot = new PatternPaneScreenshot(_simg); createMarginBox(p, _screenshot); p.add(Box.createVerticalStrut(5)); p.add(_screenshot.createControls()); p.add(Box.createVerticalStrut(5)); p.add(msgApplied[tabSequence]); p.doLayout(); return p; }
private JPanel createTargetPanel() { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); _tarOffsetPane = new PatternPaneTargetOffset(_simg, _imgBtn.getFilename(), _imgBtn.getTargetOffset()); createMarginBox(p, _tarOffsetPane); p.add(Box.createVerticalStrut(5)); p.add(_tarOffsetPane.createControls()); p.add(Box.createVerticalStrut(5)); p.add(msgApplied[tabSequence]); p.doLayout(); return p; }
private void showHelp(String help[]) { txtCommand.setText(help[0]); bHelp = true; pResult.removeAll(); pResult.add(txtResultScroll, BorderLayout.CENTER); pResult.doLayout(); txtResult.setText(help[1]); pResult.repaint(); txtCommand.requestFocus(); txtCommand.setCaretPosition(help[0].length()); }
/** Checks basic layout functions. */ public void testBasic() { FormLayout layout = new FormLayout("1px, 2px, 3px, 5px, 7px", "1px, 2px, 3px"); JPanel panel = new JPanel(layout); panel.doLayout(); FormLayout.LayoutInfo info = layout.getLayoutInfo(panel); assertEquals("Columns", 6, info.columnOrigins.length); assertEquals("Rows", 4, info.rowOrigins.length); assertEquals("Column 0", 0, info.columnOrigins[0]); assertEquals("Column 1", 1, info.columnOrigins[1]); assertEquals("Column 2", 3, info.columnOrigins[2]); assertEquals("Column 3", 6, info.columnOrigins[3]); assertEquals("Column 4", 11, info.columnOrigins[4]); assertEquals("Column 5", 18, info.columnOrigins[5]); }
public MyValidatableComponent() { myNameLabel.setLabelFor(myNameText); myNameText.setDocument(myNameDocument); getEditor() .addSettingsEditorListener( new SettingsEditorListener() { public void stateChanged(SettingsEditor settingsEditor) { updateWarning(); } }); myWarningLabel.setIcon(IconLoader.getIcon("/runConfigurations/configurationWarning.png")); myComponentPlace.setLayout(new GridBagLayout()); myComponentPlace.add( getEditorComponent(), new GridBagConstraints( 0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); myComponentPlace.doLayout(); myFixButton.setIcon(IconLoader.getIcon("/actions/quickfixBulb.png")); updateWarning(); myFixButton.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { if (myQuickFix == null) { return; } myQuickFix.run(); myValidationResultValid = false; updateWarning(); } }); }
private void updateResult() { if (iResult == 0) { // in case 'help' has removed the grid if (bHelp) { pResult.removeAll(); pResult.add(gScrollPane, BorderLayout.CENTER); pResult.doLayout(); gResult.fireTableChanged(null); pResult.repaint(); bHelp = false; } } else { showResultInText(); } txtCommand.selectAll(); txtCommand.requestFocus(); }
public void testVisibility(boolean containerHonorsVisibility) { TestComponent visible = new TestComponent(10, 10, 10, 10); TestComponent invisible = new TestComponent(10, 10, 10, 10); invisible.setVisible(false); TestComponent invisibleHonorsVisibility = new TestComponent(10, 10, 10, 10); invisibleHonorsVisibility.setVisible(false); TestComponent invisibleIgnoresVisibility = new TestComponent(10, 10, 10, 10); invisibleIgnoresVisibility.setVisible(false); FormLayout layout = new FormLayout("pref, pref, pref, pref", "pref, pref, pref, pref"); layout.setHonorsVisibility(containerHonorsVisibility); JPanel panel = new JPanel(layout); panel.add(visible, cc.xy(1, 1)); panel.add(invisible, cc.xy(2, 2)); panel.add(invisibleHonorsVisibility, cc.xy(3, 3)); panel.add(invisibleIgnoresVisibility, cc.xy(4, 4)); layout.setHonorsVisibility(invisibleHonorsVisibility, Boolean.TRUE); layout.setHonorsVisibility(invisibleIgnoresVisibility, Boolean.FALSE); panel.doLayout(); FormLayout.LayoutInfo info = layout.getLayoutInfo(panel); int size1 = 10; int size2 = containerHonorsVisibility ? 0 : 10; int size3 = 0; int size4 = 10; int origin1 = size1; int origin2 = origin1 + size2; int origin3 = origin2 + size3; int origin4 = origin3 + size4; assertEquals("Column 0", 0, info.columnOrigins[0]); assertEquals("Column 1", origin1, info.columnOrigins[1]); assertEquals("Column 2", origin2, info.columnOrigins[2]); assertEquals("Column 3", origin3, info.columnOrigins[3]); assertEquals("Column 4", origin4, info.columnOrigins[4]); assertEquals("Row 0", 0, info.rowOrigins[0]); assertEquals("Row 1", origin1, info.rowOrigins[1]); assertEquals("Row 2", origin2, info.rowOrigins[2]); assertEquals("Row 3", origin3, info.rowOrigins[3]); assertEquals("Row 4", origin4, info.rowOrigins[4]); }
public void doLayout() { if (getLayout() != null) { // A layout manager has been set, so delegate to it super.doLayout(); return; } Dimension d = getSize(); Insets i = getInsets(); if (collapsed) { if (label != null) { Dimension p = label.getPreferredSize(); label.setBounds( i.left, i.top + (d.height - i.top - i.bottom - p.height) / 2, p.width, p.height); } } else { if (comp != null) { comp.setBounds(i.left, i.top, d.width - i.left - i.right, d.height - i.top - i.bottom); } } }
/** Tests bounded min and pref widths. */ public void testBoundedWidth() { TestComponent c1 = new TestComponent(2, 7, 4, 9); TestComponent c2 = new TestComponent(20, 7, 40, 9); TestComponent c3 = new TestComponent(2, 7, 4, 9); TestComponent c4 = new TestComponent(20, 7, 40, 9); TestComponent c5 = new TestComponent(2, 7, 4, 9); TestComponent c6 = new TestComponent(20, 7, 40, 9); TestComponent c7 = new TestComponent(2, 7, 4, 9); TestComponent c8 = new TestComponent(20, 7, 40, 9); FormLayout layout = new FormLayout( "[10px,min], [10px,min], " + "[10px,pref], [10px,pref], " + "[min,10px], [min,10px], " + "[pref,10px], [pref,10px]", "pref"); JPanel panel = new JPanel(layout); panel.add(c1, cc.xy(1, 1)); panel.add(c2, cc.xy(2, 1)); panel.add(c3, cc.xy(3, 1)); panel.add(c4, cc.xy(4, 1)); panel.add(c5, cc.xy(5, 1)); panel.add(c6, cc.xy(6, 1)); panel.add(c7, cc.xy(7, 1)); panel.add(c8, cc.xy(8, 1)); panel.doLayout(); assertEquals("max(10px;c1_min).width", 10, c1.getWidth()); assertEquals("max(10px;c2_min).width", 20, c2.getWidth()); assertEquals("max(10px;c3_pref).width", 10, c3.getWidth()); assertEquals("max(10px;c4_pref).width", 40, c4.getWidth()); assertEquals("min(10px;c5_min).width", 2, c5.getWidth()); assertEquals("min(10px;c6_min).width", 10, c6.getWidth()); assertEquals("min(10px;c7_pref).width", 4, c7.getWidth()); assertEquals("min(10px;c8_pref).width", 10, c8.getWidth()); }
/** Tests bounded min and pref widths. */ public void testBoundedHeight() { TestComponent c1 = new TestComponent(7, 2, 9, 4); TestComponent c2 = new TestComponent(7, 20, 9, 40); TestComponent c3 = new TestComponent(7, 2, 9, 4); TestComponent c4 = new TestComponent(7, 20, 9, 40); TestComponent c5 = new TestComponent(7, 2, 9, 4); TestComponent c6 = new TestComponent(7, 20, 9, 40); TestComponent c7 = new TestComponent(7, 2, 9, 4); TestComponent c8 = new TestComponent(7, 20, 9, 40); FormLayout layout = new FormLayout( "pref", "f:[10px,min], f:[10px,min], " + "f:[10px,pref], f:[10px,pref], " + "f:[min,10px], f:[min,10px], " + "f:[pref,10px], f:[pref,10px]"); JPanel panel = new JPanel(layout); panel.add(c1, cc.xy(1, 1)); panel.add(c2, cc.xy(1, 2)); panel.add(c3, cc.xy(1, 3)); panel.add(c4, cc.xy(1, 4)); panel.add(c5, cc.xy(1, 5)); panel.add(c6, cc.xy(1, 6)); panel.add(c7, cc.xy(1, 7)); panel.add(c8, cc.xy(1, 8)); panel.doLayout(); assertEquals("[10px, c1_min].height", 10, c1.getHeight()); assertEquals("[10px, c2_min].height", 20, c2.getHeight()); assertEquals("[10px,c3_pref].height", 10, c3.getHeight()); assertEquals("[10px,c4_pref].height", 40, c4.getHeight()); assertEquals("[c5_min, 10px].height", 2, c5.getHeight()); assertEquals("[c6_min, 10px].height", 10, c6.getHeight()); assertEquals("[c7_pref,10px].height", 4, c7.getHeight()); assertEquals("[c8_pref,10px].height", 10, c8.getHeight()); }
/** * Checks and verifies that components that span multiple columns do not expand the container of * no column grows. */ public void testExtraExpansionIfSpannedColumnsGrow() { TestComponent c1 = new TestComponent(10, 1, 50, 1); TestComponent c2 = new TestComponent(10, 1, 50, 1); TestComponent c3 = new TestComponent(10, 1, 50, 1); TestComponent c4 = new TestComponent(10, 1, 50, 1); FormLayout layout = new FormLayout("10px, 15px:grow, 20px", "pref, pref"); JPanel panel = new JPanel(layout); panel.add(c1, cc.xy(1, 1)); panel.add(c2, cc.xy(2, 1)); panel.add(c3, cc.xy(3, 1)); panel.add(c4, cc.xyw(1, 2, 2)); Dimension preferredLayoutSize = layout.preferredLayoutSize(panel); panel.setSize(preferredLayoutSize); panel.doLayout(); int col1And2Width = c2.getX() + c2.getWidth(); int gridWidth = c3.getX() + c3.getWidth(); int totalWidth = preferredLayoutSize.width; assertEquals("Col1+2 width", 50, col1And2Width); assertEquals("Grid width", 70, gridWidth); assertEquals("Total width", 70, totalWidth); }
private void initializeComponent() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); getRootPane().setLayout(new BorderLayout()); getRootPane().add(panel, BorderLayout.CENTER); JButton createButton = new JButton("New..."); createButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { create(); } }); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(5, 5, 5, 5); c.anchor = GridBagConstraints.WEST; panel.add(createButton, c); contexts = new JComboBox(new DefaultComboBoxModel()); contexts.setPreferredSize(new Dimension(80, 24)); contexts.setSize(new Dimension(80, 24)); c = new GridBagConstraints(); c.weightx = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(5, 5, 5, 5); panel.add(contexts, c); contexts.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { refresh(); } }); JButton refreshButton = new JButton("Refresh"); refreshButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { refresh(); } }); c = new GridBagConstraints(); c.insets = new Insets(5, 5, 5, 5); panel.add(refreshButton, c); itemTable = new JTable(1, 6); itemTable.setRowHeight(35); itemTable.setShowHorizontalLines(false); itemTable.setShowVerticalLines(false); itemTable.addKeyListener( new KeyListener() { public void keyTyped(KeyEvent e) {} public void keyReleased(KeyEvent e) { ctrl = false; } public void keyPressed(KeyEvent e) { if (e.isControlDown()) { ctrl = true; } } }); itemTable .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int index = e.getFirstIndex(); if (index >= 0 && index < items.size()) { ChecklistItem item = items.get(index); if (item.getStatus() == Status.Created) { String actorId = getActorId(); try { checklistManager.claimTask(actorId, item.getTaskId()); if (ctrl) { checklistManager.abortTask(actorId, item.getTaskId()); } else { checklistManager.completeTask(actorId, item.getTaskId()); } } catch (Throwable t) { // Do nothing } refresh(); } else if (item.getStatus() == Status.Reserved) { String actorId = getActorId(); if (item.getActors().equals(actorId)) { try { if (ctrl) { checklistManager.abortTask(actorId, item.getTaskId()); } else { checklistManager.completeTask(actorId, item.getTaskId()); } } catch (Throwable t) { // Do nothing } refresh(); } } else if (item.getStatus() == Status.Optional) { try { checklistManager.selectOptionalTask( item.getName(), Long.valueOf((String) contexts.getSelectedItem())); } catch (Throwable t) { // Do nothing t.printStackTrace(); } refresh(); } } } }); // TODO: // default width of columns // icons for state // not-editable // no selection // (scratch for aborted?) // replace refresh, create, etc. by icon c = new GridBagConstraints(); c.gridy = 1; c.weightx = 1; c.weighty = 1; c.gridwidth = 3; c.fill = GridBagConstraints.BOTH; c.insets = new Insets(5, 5, 5, 5); panel.add(itemTable, c); JLabel nameLabel = new JLabel("Logged in as:"); c = new GridBagConstraints(); c.gridy = 2; c.insets = new Insets(5, 5, 5, 5); c.anchor = GridBagConstraints.WEST; panel.add(nameLabel, c); userNameTextField = new JTextField("krisv"); userNameTextField.setPreferredSize(new Dimension(80, 20)); userNameTextField.setSize(new Dimension(80, 20)); c = new GridBagConstraints(); c.gridy = 2; c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.insets = new Insets(5, 5, 5, 5); c.anchor = GridBagConstraints.WEST; panel.add(userNameTextField, c); JButton createItemButton = new JButton("+"); createItemButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { createNewItem(); } }); c = new GridBagConstraints(); c.gridy = 2; c.insets = new Insets(5, 5, 5, 5); c.anchor = GridBagConstraints.EAST; panel.add(createItemButton, c); panel.doLayout(); }
/** @see java.awt.Container#doLayout() */ public void doLayout() { updateComponentsUI(); super.doLayout(); }
/** Create the frame. */ public PreferencesWindow( final Preferences prefs, MetadataInfo defaultMetadata, final Frame owner) { super(owner, true); setLocationRelativeTo(owner); long startTime = System.nanoTime(); final Future<HttpResponse> status = checkForUpdates(); isWindows = System.getProperty("os.name").startsWith("Windows"); this.prefs = prefs; if (defaultMetadata != null) { this.defaultMetadata = defaultMetadata; } else { this.defaultMetadata = new MetadataInfo(); } addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent arg0) { save(); if (onSave != null) { onSave.run(); } } }); setTitle("Preferences"); setMinimumSize(new Dimension(640, 480)); contentPane = new JPanel(); setContentPane(contentPane); GridBagLayout gbl_contentPane = new GridBagLayout(); gbl_contentPane.columnWidths = new int[] {725, 0}; gbl_contentPane.rowHeights = new int[] {389, 29, 0}; gbl_contentPane.columnWeights = new double[] {0.0, Double.MIN_VALUE}; gbl_contentPane.rowWeights = new double[] {0.0, 0.0, Double.MIN_VALUE}; contentPane.setLayout(gbl_contentPane); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); GridBagConstraints gbc_tabbedPane = new GridBagConstraints(); gbc_tabbedPane.weighty = 1.0; gbc_tabbedPane.weightx = 1.0; gbc_tabbedPane.fill = GridBagConstraints.BOTH; gbc_tabbedPane.insets = new Insets(0, 0, 5, 0); gbc_tabbedPane.gridx = 0; gbc_tabbedPane.gridy = 0; contentPane.add(tabbedPane, gbc_tabbedPane); JPanel panelGeneral = new JPanel(); tabbedPane.addTab("General", null, panelGeneral, null); panelGeneral.setLayout(new MigLayout("", "[grow]", "[][]")); JPanel panel_1 = new JPanel(); panel_1.setBorder( new TitledBorder( new LineBorder(new Color(184, 207, 229)), "On Save ...", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(51, 51, 51))); panel_1.setLayout(new MigLayout("", "[]", "[][]")); onsaveCopyDocumentTo = new JCheckBox("Copy Document To XMP"); onsaveCopyDocumentTo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (onsaveCopyDocumentTo.isSelected()) { onsaveCopyXmpTo.setSelected(false); } copyBasicToXmp = onsaveCopyDocumentTo.isSelected(); copyXmpToBasic = onsaveCopyXmpTo.isSelected(); } }); panel_1.add(onsaveCopyDocumentTo, "cell 0 0,alignx left,aligny top"); onsaveCopyDocumentTo.setSelected(false); onsaveCopyXmpTo = new JCheckBox("Copy XMP To Document"); onsaveCopyXmpTo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (onsaveCopyXmpTo.isSelected()) { onsaveCopyDocumentTo.setSelected(false); } copyBasicToXmp = onsaveCopyDocumentTo.isSelected(); copyXmpToBasic = onsaveCopyXmpTo.isSelected(); } }); panel_1.add(onsaveCopyXmpTo, "cell 0 1"); onsaveCopyXmpTo.setSelected(false); panelGeneral.add(panel_1, "flowx,cell 0 0,alignx left,aligny top"); onsaveCopyXmpTo.setSelected(prefs.getBoolean("onsaveCopyXmpTo", false)); onsaveCopyDocumentTo.setSelected(prefs.getBoolean("onsaveCopyBasicTo", false)); JPanel panel = new JPanel(); panel.setBorder( new TitledBorder( new LineBorder(new Color(184, 207, 229)), "Rename template", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(51, 51, 51))); panelGeneral.add(panel, "cell 0 1,grow"); panel.setLayout(new MigLayout("", "[grow]", "[][][]")); lblNewLabel = new JLabel("Preview:"); panel.add(lblNewLabel, "cell 0 1"); JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportBorder(null); panel.add(scrollPane, "cell 0 2,grow"); JTextPane txtpnAaa = new JTextPane(); txtpnAaa.setBackground(UIManager.getColor("Panel.background")); txtpnAaa.setEditable(false); scrollPane.setViewportView(txtpnAaa); txtpnAaa.setContentType("text/html"); txtpnAaa.setText( "Supported fields:<br>\n<pre>\n<i>" + CommandLine.mdFieldsHelpMessage(60, " {", "}", false) + "</i></pre>"); txtpnAaa.setFont(UIManager.getFont("TextPane.font")); txtpnAaa.setCaretPosition(0); comboBox = new JComboBox(); comboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { showPreview((String) getRenameTemplateCombo().getModel().getSelectedItem()); } }); comboBox.setEditable(true); comboBox.setModel( new DefaultComboBoxModel( new String[] { "", "{doc.author} - {doc.title}.pdf", "{doc.author} - {doc.creationDate}.pdf" })); panel.add(comboBox, "cell 0 0,growx"); JPanel saveActionPanel = new JPanel(); saveActionPanel.setBorder( new TitledBorder( null, "Default save action", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panelGeneral.add(saveActionPanel, "cell 0 0"); saveActionPanel.setLayout(new MigLayout("", "[][]", "[][]")); final JRadioButton rdbtnSave = new JRadioButton("Save"); buttonGroup.add(rdbtnSave); saveActionPanel.add(rdbtnSave, "flowy,cell 0 0,alignx left,aligny top"); final JRadioButton rdbtnSaveAndRename = new JRadioButton("Save & rename"); rdbtnSaveAndRename.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) {} }); buttonGroup.add(rdbtnSaveAndRename); final JRadioButton rdbtnSaveAs = new JRadioButton("Save as ..."); buttonGroup.add(rdbtnSaveAs); saveActionPanel.add(rdbtnSaveAndRename, "cell 0 0,alignx left,aligny top"); saveActionPanel.add(rdbtnSaveAs, "cell 1 0,aligny top"); final JTextComponent tcA = (JTextComponent) comboBox.getEditor().getEditorComponent(); JPanel panelDefaults = new JPanel(); tabbedPane.addTab("Defaults", null, panelDefaults, null); GridBagLayout gbl_panelDefaults = new GridBagLayout(); gbl_panelDefaults.columnWidths = new int[] {555, 0}; gbl_panelDefaults.rowHeights = new int[] {32, 100, 0}; gbl_panelDefaults.columnWeights = new double[] {0.0, Double.MIN_VALUE}; gbl_panelDefaults.rowWeights = new double[] {0.0, Double.MIN_VALUE}; panelDefaults.setLayout(gbl_panelDefaults); JLabel lblDefineHereDefault = new JLabel( "Define here default values for the fields you would like prefilled if not set in the PDF document "); GridBagConstraints gbc_lblDefineHereDefault = new GridBagConstraints(); gbc_lblDefineHereDefault.insets = new Insets(5, 5, 0, 0); gbc_lblDefineHereDefault.weightx = 1.0; gbc_lblDefineHereDefault.anchor = GridBagConstraints.NORTH; gbc_lblDefineHereDefault.fill = GridBagConstraints.HORIZONTAL; gbc_lblDefineHereDefault.gridx = 0; gbc_lblDefineHereDefault.gridy = 0; panelDefaults.add(lblDefineHereDefault, gbc_lblDefineHereDefault); GridBagConstraints gbc_lblDefineHereDefault1 = new GridBagConstraints(); gbc_lblDefineHereDefault1.weightx = 1.0; gbc_lblDefineHereDefault1.weighty = 1.0; gbc_lblDefineHereDefault1.anchor = GridBagConstraints.NORTH; gbc_lblDefineHereDefault1.fill = GridBagConstraints.BOTH; gbc_lblDefineHereDefault1.gridx = 0; gbc_lblDefineHereDefault1.gridy = 1; defaultMetadataPane = new MetadataEditPane(); panelDefaults.add(defaultMetadataPane.tabbedaPane, gbc_lblDefineHereDefault1); JPanel panelOsIntegration = new JPanel(); tabbedPane.addTab("Os Integration", null, panelOsIntegration, null); panelOsIntegration.setLayout(new MigLayout("", "[grow]", "[grow]")); JPanel panel_2 = new JPanel(); panel_2.setBorder( new TitledBorder( new EtchedBorder(EtchedBorder.LOWERED, null, null), "Explorer context menu (Windows only)", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); panelOsIntegration.add(panel_2, "cell 0 0,grow"); panel_2.setLayout(new MigLayout("", "[][]", "[growprio 50,grow][growprio 50,grow]")); JButton btnRegister = new JButton("Add to context menu"); btnRegister.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { WindowsRegisterContextMenu.register(); } catch (Exception e1) { // StringWriter sw = new StringWriter(); // PrintWriter pw = new PrintWriter(sw); // e1.printStackTrace(pw); // JOptionPane.showMessageDialog(owner, // "Failed to register context menu:\n" + e1.toString() // +"\n" +sw.toString()); JOptionPane.showMessageDialog( owner, "Failed to register context menu:\n" + e1.toString()); e1.printStackTrace(); } } }); panel_2.add(btnRegister, "cell 0 0,growx,aligny center"); JButton btnUnregister = new JButton("Remove from context menu"); btnUnregister.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { WindowsRegisterContextMenu.unregister(); } }); final JLabel lblNewLabel_1 = new JLabel(""); panel_2.add(lblNewLabel_1, "cell 1 0 1 2"); panel_2.add(btnUnregister, "cell 0 1,growx,aligny center"); btnRegister.setEnabled(isWindows); btnUnregister.setEnabled(isWindows); JPanel panelBatchLicense = new JPanel(); tabbedPane.addTab("License", null, panelBatchLicense, null); GridBagLayout gbl_panelBatchLicense = new GridBagLayout(); gbl_panelBatchLicense.columnWidths = new int[] {0, 0, 0}; gbl_panelBatchLicense.rowHeights = new int[] {0, 0, 0, 0, 0}; gbl_panelBatchLicense.columnWeights = new double[] {0.0, 1.0, Double.MIN_VALUE}; gbl_panelBatchLicense.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; panelBatchLicense.setLayout(gbl_panelBatchLicense); JTextPane txtpnEnterLicenseInformation = new JTextPane(); txtpnEnterLicenseInformation.setEditable(false); txtpnEnterLicenseInformation.setBackground(UIManager.getColor("Panel.background")); txtpnEnterLicenseInformation.setContentType("text/html"); txtpnEnterLicenseInformation.setText( "<h3 align='center'>Enter license information below to use batch operations.</h3><p align='center'>You can get license at <a href=\"" + Constants.batchLicenseUrl + "\">" + Constants.batchLicenseUrl + "</a></p>"); GridBagConstraints gbc_txtpnEnterLicenseInformation = new GridBagConstraints(); gbc_txtpnEnterLicenseInformation.gridwidth = 2; gbc_txtpnEnterLicenseInformation.insets = new Insets(15, 0, 5, 0); gbc_txtpnEnterLicenseInformation.fill = GridBagConstraints.HORIZONTAL; gbc_txtpnEnterLicenseInformation.gridx = 0; gbc_txtpnEnterLicenseInformation.gridy = 0; panelBatchLicense.add(txtpnEnterLicenseInformation, gbc_txtpnEnterLicenseInformation); txtpnEnterLicenseInformation.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) { return; } if (!java.awt.Desktop.isDesktopSupported()) { return; } java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) { return; } try { java.net.URI uri = e.getURL().toURI(); desktop.browse(uri); } catch (Exception e1) { } } }); JLabel lblNewLabel_2 = new JLabel("Email"); GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints(); gbc_lblNewLabel_2.insets = new Insets(15, 15, 5, 5); gbc_lblNewLabel_2.anchor = GridBagConstraints.EAST; gbc_lblNewLabel_2.gridx = 0; gbc_lblNewLabel_2.gridy = 1; panelBatchLicense.add(lblNewLabel_2, gbc_lblNewLabel_2); emailField = new JTextField(); GridBagConstraints gbc_emailField = new GridBagConstraints(); gbc_emailField.insets = new Insets(15, 0, 5, 15); gbc_emailField.fill = GridBagConstraints.HORIZONTAL; gbc_emailField.gridx = 1; gbc_emailField.gridy = 1; panelBatchLicense.add(emailField, gbc_emailField); emailField.setColumns(10); emailField.setText(Main.getPreferences().get("email", "")); emailField .getDocument() .addDocumentListener( new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { updateLicense(); } @Override public void insertUpdate(DocumentEvent e) { updateLicense(); } @Override public void changedUpdate(DocumentEvent e) {} }); JLabel lblLicenseKey = new JLabel("License key"); GridBagConstraints gbc_lblLicenseKey = new GridBagConstraints(); gbc_lblLicenseKey.anchor = GridBagConstraints.EAST; gbc_lblLicenseKey.insets = new Insets(0, 15, 5, 5); gbc_lblLicenseKey.gridx = 0; gbc_lblLicenseKey.gridy = 2; panelBatchLicense.add(lblLicenseKey, gbc_lblLicenseKey); keyField = new JTextField(); GridBagConstraints gbc_keyField = new GridBagConstraints(); gbc_keyField.insets = new Insets(0, 0, 5, 15); gbc_keyField.fill = GridBagConstraints.HORIZONTAL; gbc_keyField.gridx = 1; gbc_keyField.gridy = 2; panelBatchLicense.add(keyField, gbc_keyField); keyField.setColumns(10); keyField.setText(Main.getPreferences().get("key", "")); keyField .getDocument() .addDocumentListener( new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { updateLicense(); } @Override public void insertUpdate(DocumentEvent e) { updateLicense(); } @Override public void changedUpdate(DocumentEvent e) {} }); labelLicenseStatus = new JLabel("No License"); GridBagConstraints gbc_labelLicenseStatus = new GridBagConstraints(); gbc_labelLicenseStatus.gridwidth = 2; gbc_labelLicenseStatus.insets = new Insets(30, 15, 0, 15); gbc_labelLicenseStatus.gridx = 0; gbc_labelLicenseStatus.gridy = 3; panelBatchLicense.add(labelLicenseStatus, gbc_labelLicenseStatus); JScrollPane scrollPane_1 = new JScrollPane(); tabbedPane.addTab("About", null, scrollPane_1, null); txtpnDf = new JTextPane(); txtpnDf.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) { return; } if (!java.awt.Desktop.isDesktopSupported()) { return; } java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) { return; } try { java.net.URI uri = e.getURL().toURI(); desktop.browse(uri); } catch (Exception e1) { } } }); txtpnDf.setContentType("text/html"); txtpnDf.setEditable(false); txtpnDf.setText( aboutMsg = "<h1 align=center>Pdf Metadata editor</h1>\n\n<p align=center><a href=\"http://broken-by.me/pdf-metadata-editor/\">http://broken-by.me/pdf-metadata-editor/</a></p>\n<br>\n<p align=center>If you have suggestions, found bugs or just want to share some idea about it you can write me at : <a href=\"mailto:[email protected]\"/>[email protected]</a></p>\n<br>"); scrollPane_1.setViewportView(txtpnDf); JPanel panel_3 = new JPanel(); GridBagConstraints gbc_panel_3 = new GridBagConstraints(); gbc_panel_3.insets = new Insets(0, 5, 0, 5); gbc_panel_3.fill = GridBagConstraints.BOTH; gbc_panel_3.gridx = 0; gbc_panel_3.gridy = 1; contentPane.add(panel_3, gbc_panel_3); panel_3.setLayout(new BorderLayout(0, 0)); JButton btnClose = new JButton("Close"); panel_3.add(btnClose, BorderLayout.EAST); updateStatusLabel = new JLabel("..."); panel_3.add(updateStatusLabel, BorderLayout.WEST); btnClose.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); save(); } }); ActionListener onDefaultSaveAction = new ActionListener() { public void actionPerformed(ActionEvent e) { if (rdbtnSave.isSelected()) { defaultSaveAction = "save"; } else if (rdbtnSaveAndRename.isSelected()) { defaultSaveAction = "saveRename"; } else if (rdbtnSaveAs.isSelected()) { defaultSaveAction = "saveAs"; } } }; rdbtnSave.addActionListener(onDefaultSaveAction); rdbtnSaveAndRename.addActionListener(onDefaultSaveAction); rdbtnSaveAs.addActionListener(onDefaultSaveAction); tcA.getDocument() .addDocumentListener( new DocumentListener() { @Override public void changedUpdate(DocumentEvent arg0) { showPreview((String) comboBox.getEditor().getItem()); } @Override public void insertUpdate(DocumentEvent arg0) { showPreview((String) comboBox.getEditor().getItem()); } @Override public void removeUpdate(DocumentEvent arg0) { showPreview((String) comboBox.getEditor().getItem()); } }); String defaultSaveAction = prefs.get("defaultSaveAction", "save"); if (defaultSaveAction.equals("saveRename")) { rdbtnSaveAndRename.setSelected(true); } else if (defaultSaveAction.equals("saveAs")) { rdbtnSaveAndRename.setSelected(true); } else { rdbtnSave.setSelected(true); } SwingUtilities.invokeLater( new Runnable() { @Override public void run() { lblNewLabel_1.setIcon( new ImageIcon( PreferencesWindow.class.getResource("/pmedit/os_integration_hint.png"))); } }); load(); refresh(); contentPane.doLayout(); if (status.isDone()) { showUpdatesStatus(status); } else { (new Thread( new Runnable() { @Override public void run() { showUpdatesStatus(status); } })) .start(); } updateLicense(); }
public void actionPerformed(ActionEvent ev) { String s = ev.getActionCommand(); if (s == null) { if (ev.getSource() instanceof JMenuItem) { JMenuItem i; s = ((JMenuItem) ev.getSource()).getText(); } } /* // button replace by toolbar if (s.equals("Execute")) { execute(); } else */ if (s.equals("Exit")) { windowClosing(null); } else if (s.equals("Transfer")) { Transfer.work(null); } else if (s.equals("Dump")) { Transfer.work(new String[] {"-d"}); } else if (s.equals("Restore")) { Transfer.work(new String[] {"-r"}); } else if (s.equals("Logging on")) { javaSystem.setLogToSystem(true); } else if (s.equals("Logging off")) { javaSystem.setLogToSystem(false); } else if (s.equals("Refresh Tree")) { refreshTree(); } else if (s.startsWith("#")) { int i = Integer.parseInt(s.substring(1)); txtCommand.setText(sRecent[i]); } else if (s.equals("Connect...")) { connect(ConnectionDialogSwing.createConnection(fMain, "Connect")); refreshTree(); } else if (s.equals("Results in Grid")) { iResult = 0; pResult.removeAll(); pResult.add(gScrollPane, BorderLayout.CENTER); pResult.doLayout(); gResult.fireTableChanged(null); pResult.repaint(); } else if (s.equals("Open Script...")) { JFileChooser f = new JFileChooser("."); f.setDialogTitle("Open Script..."); // (ulrivo): set default directory if set from command line if (defDirectory != null) { f.setCurrentDirectory(new File(defDirectory)); } int option = f.showOpenDialog(fMain); if (option == JFileChooser.APPROVE_OPTION) { File file = f.getSelectedFile(); if (file != null) { StringBuffer buf = new StringBuffer(); ifHuge = DatabaseManagerCommon.readFile(file.getAbsolutePath()); if (4096 <= ifHuge.length()) { buf.append("This huge file cannot be edited. Please execute\n"); txtCommand.setText(buf.toString()); } else { txtCommand.setText(ifHuge); } } } } else if (s.equals("Save Script...")) { JFileChooser f = new JFileChooser("."); f.setDialogTitle("Save Script"); // (ulrivo): set default directory if set from command line if (defDirectory != null) { f.setCurrentDirectory(new File(defDirectory)); } int option = f.showSaveDialog(fMain); if (option == JFileChooser.APPROVE_OPTION) { File file = f.getSelectedFile(); if (file != null) { DatabaseManagerCommon.writeFile(file.getAbsolutePath(), txtCommand.getText()); } } } else if (s.equals("Save Result...")) { JFileChooser f = new JFileChooser("."); f.setDialogTitle("Save Result..."); // (ulrivo): set default directory if set from command line if (defDirectory != null) { f.setCurrentDirectory(new File(defDirectory)); } int option = f.showSaveDialog(fMain); if (option == JFileChooser.APPROVE_OPTION) { File file = f.getSelectedFile(); if (file != null) { showResultInText(); DatabaseManagerCommon.writeFile(file.getAbsolutePath(), txtResult.getText()); } } } else if (s.equals("Results in Text")) { iResult = 1; pResult.removeAll(); pResult.add(txtResultScroll, BorderLayout.CENTER); pResult.doLayout(); showResultInText(); pResult.repaint(); } else if (s.equals("AutoCommit on")) { try { cConn.setAutoCommit(true); } catch (SQLException e) { } } else if (s.equals("AutoCommit off")) { try { cConn.setAutoCommit(false); } catch (SQLException e) { } } else if (s.equals("Commit")) { try { cConn.commit(); } catch (SQLException e) { } } else if (s.equals("Insert test data")) { insertTestData(); } else if (s.equals("Rollback")) { try { cConn.rollback(); } catch (SQLException e) { } } else if (s.equals("Disable MaxRows")) { try { sStatement.setMaxRows(0); } catch (SQLException e) { } } else if (s.equals("Set MaxRows to 100")) { try { sStatement.setMaxRows(100); } catch (SQLException e) { } } else if (s.equals("SELECT")) { showHelp(DatabaseManagerCommon.selectHelp); } else if (s.equals("INSERT")) { showHelp(DatabaseManagerCommon.insertHelp); } else if (s.equals("UPDATE")) { showHelp(DatabaseManagerCommon.updateHelp); } else if (s.equals("DELETE")) { showHelp(DatabaseManagerCommon.deleteHelp); } else if (s.equals("CREATE TABLE")) { showHelp(DatabaseManagerCommon.createTableHelp); } else if (s.equals("DROP TABLE")) { showHelp(DatabaseManagerCommon.dropTableHelp); } else if (s.equals("CREATE INDEX")) { showHelp(DatabaseManagerCommon.createIndexHelp); } else if (s.equals("DROP INDEX")) { showHelp(DatabaseManagerCommon.dropIndexHelp); } else if (s.equals("CHECKPOINT")) { showHelp(DatabaseManagerCommon.checkpointHelp); } else if (s.equals("SCRIPT")) { showHelp(DatabaseManagerCommon.scriptHelp); } else if (s.equals("SHUTDOWN")) { showHelp(DatabaseManagerCommon.shutdownHelp); } else if (s.equals("SET")) { showHelp(DatabaseManagerCommon.setHelp); } else if (s.equals("Test Script")) { showHelp(DatabaseManagerCommon.testHelp); } }
/** Add component @param c on top of MapView */ public void addTopPanel(Component c) { leftPanel.add(c, GBC.eol().fill(GBC.HORIZONTAL), leftPanel.getComponentCount() - 1); leftPanel.doLayout(); c.doLayout(); }
public void doLayout() { RootPanel rootPanel = frame.getRoot(); if (rootPanel != null && isWindowResizing()) { rootPanel.doLayout(); } else super.doLayout(); }