public void save() { boolean isNoticed = false; if (!notice.isVisible()) { isNoticed = true; notice.setVisible(true); notice.setText("Saving..."); } if (getOptions() != null) { DB database = null; try { database = factory.open(this.leveldbStore.getSelectedFile(), getOptions()); DBIterator iterator = database.iterator(); HashSet<byte[]> keys = new HashSet<>(); for (iterator.seekToFirst(); iterator.hasNext(); iterator.next()) { keys.add(iterator.peekNext().getKey()); } iterator.close(); for (byte[] key : keys) { database.delete(key); } for (int i = 0; i < dataList.getModel().getSize(); ++i) { DBItem item = dataList.getModel().getElementAt(i); database.put(item.key, item.value); } } catch (Exception e) { JOptionPane.showMessageDialog(pane, "Unable to open database:\n" + e); e.printStackTrace(); } finally { if (database != null) { try { database.close(); } catch (IOException e) { JOptionPane.showMessageDialog(pane, "Unable to close database:\n" + e); e.printStackTrace(); } } saveButton.setEnabled(false); } } if (isNoticed) { try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } notice.setVisible(false); notice.setText(""); } }
public void update(JTextArea area) { DBItem item = dataList.getSelectedValue(); if (item != null && !isSet) { isSet = true; try { if (area == hexKey) { if (area.getText().isEmpty()) { return; } item.key = new BigInteger(area.getText().replaceAll("\n", "").replaceAll("%\\{EOL}", "\n"), 16) .toByteArray(); stringKey.setText(cutToLine(new String(item.key), 64)); dataList.updateUI(); } else if (area == stringKey) { if (area.getText().isEmpty()) { return; } item.key = area.getText().replaceAll("\n", "").replaceAll("%\\{EOL}", "\n").getBytes(); hexKey.setText(cutToLine(LevelDBViewer.toHexString(item.key), 64)); dataList.updateUI(); } else if (area == hexValue) { item.value = new BigInteger(area.getText().replaceAll("\n", "").replaceAll("%\\{EOL}", "\n"), 16) .toByteArray(); stringValue.setText(cutToLine(new String(item.value), 64)); } else if (area == stringValue) { item.value = area.getText().replaceAll("\n", "").replaceAll("%\\{EOL}", "\n").getBytes(); hexValue.setText(cutToLine(LevelDBViewer.toHexString(item.value), 64)); } notice.setVisible(false); notice.setText(""); saveButton.setEnabled(true); } catch (Exception e) { notice.setVisible(true); notice.setText("Invalid number!"); } finally { lengthLabel.setText(String.valueOf(item.value.length + item.key.length)); keyLength.setText(String.valueOf(item.key.length)); valueLength.setText(String.valueOf(item.value.length)); isSet = false; } } }
private void updateCaretPositionText() { if (myErrorMessage != null) { myCaretPositionLabel.setText( IdeBundle.message("label.scope.editor.caret.position", myCaretPosition + 1)); } else { myCaretPositionLabel.setText(""); } myPositionPanel.setVisible(myErrorMessage != null); myCaretPositionLabel.setVisible(myErrorMessage != null); myPanel.revalidate(); }
public void showFrame(final Editor editor, boolean activateErrorPanel, final boolean loading) { this.editor = editor; setLayout(editor, activateErrorPanel, loading); contributionListPanel.setVisible(!loading); loaderLabel.setVisible(loading); errorPanel.setVisible(activateErrorPanel); validate(); repaint(); }
protected void replaceModuleTypeOptions(final Component component) { myModuleTypeLabel.setVisible(false); myDescriptionLabel.setVisible(false); myModuleTypeScrollPane.setVisible(false); myDescriptionScrollPane.setVisible(false); myInternalPanel.add( component, new GridBagConstraints( 0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 0, 0, 0), 0, 0)); }
/** * Create, if needed, and return the component label * * @return component label */ protected JLabel doMakeDisplayLabel() { if (displayLabel == null) { displayLabel = GuiUtils.cLabel(getName()); Font f = displayLabel.getFont(); f = f.deriveFont(18.0f); displayLabel.setFont(f); if (!labelShown) { displayLabel.setVisible(false); } } return displayLabel; }
/** * Set the LabelShown property. * * @param value The new value for LabelShown */ public void setLabelShown(boolean value) { labelShown = value; if (displayLabel != null) { displayLabel.setVisible(value); } }
// // Build installer window // public static void showInstallerWindow() { _installerFrame = new JFrame(Config.getWindowTitle()); Container cont = _installerFrame.getContentPane(); cont.setLayout(new BorderLayout()); // North pane Box topPane = new Box(BoxLayout.X_AXIS); JLabel title = new JLabel(Config.getWindowHeading()); Font titleFont = new Font("SansSerif", Font.BOLD, 22); title.setFont(titleFont); title.setForeground(Color.black); // Create Sun logo URL urlLogo = Main.class.getResource(Config.getWindowLogo()); Image img = Toolkit.getDefaultToolkit().getImage(urlLogo); MediaTracker md = new MediaTracker(_installerFrame); md.addImage(img, 0); try { md.waitForAll(); } catch (Exception ioe) { Config.trace(ioe.toString()); } if (md.isErrorID(0)) Config.trace("Error loading image"); Icon sunLogo = new ImageIcon(img); JLabel logoLabel = new JLabel(sunLogo); logoLabel.setOpaque(true); topPane.add(topPane.createHorizontalStrut(5)); topPane.add(title); topPane.add(topPane.createHorizontalGlue()); topPane.add(logoLabel); topPane.add(topPane.createHorizontalStrut(5)); // West Pane Box westPane = new Box(BoxLayout.X_AXIS); westPane.add(westPane.createHorizontalStrut(10)); // South Pane Box bottomPane = new Box(BoxLayout.X_AXIS); bottomPane.add(bottomPane.createHorizontalGlue()); JButton abortButton = new JButton(Config.getWindowAbortButton()); abortButton.setMnemonic(Config.getWindowAbortMnemonic()); bottomPane.add(abortButton); bottomPane.add(bottomPane.createHorizontalGlue()); bottomPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); // Center Pane Box centerPane = new Box(BoxLayout.Y_AXIS); JLabel hidden = new JLabel(Config.getWindowHiddenLabel()); hidden.setVisible(false); centerPane.add(hidden); _stepLabels = new JLabel[5]; for (int i = 0; i < _stepLabels.length; i++) { _stepLabels[i] = new JLabel(Config.getWindowStep(i)); _stepLabels[i].setEnabled(false); centerPane.add(_stepLabels[i]); // install label's length will expand,so set a longer size. if (i == STEP_INSTALL) { Dimension dim = new JLabel(Config.getWindowStepWait(STEP_INSTALL)).getPreferredSize(); _stepLabels[i].setPreferredSize(dim); } } hidden = new JLabel(Config.getWindowHiddenLabel()); hidden.setVisible(false); centerPane.add(hidden); // Setup box layout cont.add(topPane, "North"); cont.add(westPane, "West"); cont.add(bottomPane, "South"); cont.add(centerPane, "Center"); _installerFrame.pack(); Dimension dim = _installerFrame.getSize(); // hard code to ensure title is completely visible on Sol/lin. if (dim.width < 400) { dim.width = 400; _installerFrame.setSize(dim); } Rectangle size = _installerFrame.getBounds(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); size.width = Math.min(screenSize.width, size.width); size.height = Math.min(screenSize.height, size.height); // Put window at 1/4, 1/4 of screen resoluion _installerFrame.setBounds( (screenSize.width - size.width) / 4, (screenSize.height - size.height) / 4, size.width, size.height); // Setup event listners _installerFrame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent we) { installFailed("Window closed", null); } }); abortButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { installFailed("Abort pressed", null); } }); // Show window _installerFrame.show(); }
public void actionPerformed(ActionEvent event) { if (posicion == -2) posicion = indexaux; // Abrir nueva imagen if (event.getSource() == carpeta) { siguiente.setEnabled(true); atras.setEnabled(true); presentacion.setEnabled(true); grid.setEnabled(true); bcomentario.setEnabled(true); zoom.setEnabled(true); imagenesbean.clear(); if (imagenes != null) { imagenes.clear(); } returnChooser = chooser.showOpenDialog(ArcViewer.this); imagenes = lista.Miranda(chooser, returnChooser); for (int asd1 = 0; asd1 < imagenes.size(); asd1++) { imagenesbean.add(new ImagenBean(imagenes.get(asd1), 0, 0)); } String getImgSelected = chooser.getSelectedFile().getPath(); for (int index = 0; index < imagenesbean.size(); index++) { if (getImgSelected.equals(imagenesbean.get(index).getIcon())) { imagen.setIcon(new ImageIcon(imagenesbean.get(index).getIcon())); indexaux = index; } } } // Imagen siguiente if (event.getSource() == siguiente) { posicion++; if (posicion >= imagenesbean.size()) { posicion = 0; } imagen.setIcon( ajustar.ajusteImg( new ImageIcon(imagenesbean.get(posicion).getIcon()), imagenesbean.get(posicion).getAncho(), imagenesbean.get(posicion).getAlto(), areaventana.getWidth() - 50, areaventana.getHeight())); } // Imagen anterior if (event.getSource() == atras) { posicion--; if (posicion == -1) { posicion = imagenesbean.size() - 1; } imagen.setIcon( ajustar.ajusteImg( new ImageIcon(imagenesbean.get(posicion).getIcon()), imagenesbean.get(posicion).getAncho(), imagenesbean.get(posicion).getAlto(), areaventana.getWidth() - 50, areaventana.getHeight())); } // Presentacion iniciar/detener if (event.getSource() == presentacion) { if (isPresentacion == false) { grid.setVisible(false); atras.setVisible(false); siguiente.setVisible(false); carpeta.setVisible(false); bcomentario.setVisible(false); zoom.setVisible(false); ptiempo.setVisible(true); } if (isPresentacion == true) { grid.setVisible(true); atras.setVisible(true); siguiente.setVisible(true); carpeta.setVisible(true); bcomentario.setVisible(true); zoom.setVisible(true); ptiempo.setVisible(false); } if (presentacion.getIcon() == imgPausa) { slide.detener(); posicion = slide.getPosicion(); presentacion.setIcon(imgPlay); isPresentacion = false; return; } if (presentacion.getIcon() == imgPlay) { slide.setTodo(posicion, imagen, imagenesbean, areaventana, ptiempo); new Thread(slide, "prueba").start(); presentacion.setIcon(imgPausa); isPresentacion = true; return; } } // Modo rejilla if (event.getSource() == grid) { imagen.setVisible(false); siguiente.setVisible(false); atras.setVisible(false); presentacion.setVisible(false); grid.setVisible(false); bcomentario.setVisible(false); zoom.setVisible(false); carpeta.setVisible(false); ptiempo.setVisible(false); // desplazamiento.setVisible(true); if (corrobora == true) { for (int celular = 0; celular < imgButtonArray.length; celular++) { imgButtonArray[celular].setVisible(true); } } if (corrobora == false) { imgButtonArray = new JButton[imagenesbean.size()]; for (int goku = 0; goku < imagenesbean.size(); goku++) { areaventana.add(imgButtonArray[goku] = new JButton()); imgButtonArray[goku].setPreferredSize(new Dimension(200, 200)); imgButtonArray[goku].addActionListener(this); imgButtonArray[goku].setBackground(colorGris); imgButtonArray[goku].setIcon( ajustar.ajusteCuadrado(new ImageIcon(imagenesbean.get(goku).getIcon()))); corrobora = true; } } } // Comentario if (event.getSource() == bcomentario) { new Comentario(imagenesbean.get(posicion), posicion); } // Cuando se apreta un boton de la rejilla if (corrobora == true) { for (int alice = 0; alice < imgButtonArray.length; alice++) { if (event.getSource() == imgButtonArray[alice]) { for (int wonderland = 0; wonderland < imgButtonArray.length; wonderland++) { imgButtonArray[wonderland].setVisible(false); } posicion = alice; imagen.setIcon( ajustar.ajusteImg( new ImageIcon(imagenesbean.get(posicion).getIcon()), imagenesbean.get(posicion).getAncho(), imagenesbean.get(posicion).getAlto(), areaventana.getWidth() - 50, areaventana.getHeight())); imagen.setVisible(true); siguiente.setVisible(true); atras.setVisible(true); presentacion.setVisible(true); grid.setVisible(true); bcomentario.setVisible(true); zoom.setVisible(true); carpeta.setVisible(true); } } } if (event.getSource() == zoom) { System.out.println("Haciendo un ZOOOOOOOOOOOOM"); } }
/** Update the extension label based on the model. */ private void updateExtensionLabel() { _sharedExtLabel.setText(_pim.getSharedMaskExtension() + " "); _tabCompletesLabel.setVisible(_pim.getSharedMaskExtension().length() > 0); }