use of java.awt.HeadlessException in project keystore-explorer by kaikramer.
the class JavaFXFileChooser method showFxDialog.
public int showFxDialog(Component parent, final String method) throws HeadlessException {
try {
final Object fileChooser = fileChooserClass.getConstructor().newInstance();
selectedFile = runLater(new Callable<File>() {
@Override
public File call() throws Exception {
// set extension filters
Method getExtensionFiltersMethod = fileChooserClass.getMethod("getExtensionFilters");
List<Object> observableList = (List<Object>) getExtensionFiltersMethod.invoke(fileChooser);
observableList.add(extensionFilterClass.getConstructor(String.class, String[].class).newInstance(res.getString("JavaFXFileChooser.AllFiles"), new String[] { "*.*" }));
for (FileExtFilter fileFilter : filters) {
// convert format for extensions
String[] extensions = fileFilter.getExtensions();
for (int i = 0; i < extensions.length; i++) {
if (!extensions[i].startsWith("*.")) {
extensions[i] = "*." + extensions[i];
}
}
Object extFilter = extensionFilterClass.getConstructor(String.class, String[].class).newInstance(fileFilter.getDescription(), extensions);
observableList.add(extFilter);
}
// set window title
Method setTitleMethod = fileChooserClass.getMethod("setTitle", String.class);
setTitleMethod.invoke(fileChooser, dialogTitle);
// set current directory
Method setInitialDirectory = fileChooserClass.getMethod("setInitialDirectory", File.class);
setInitialDirectory.invoke(fileChooser, currentDirectory);
Method showDialogMethod = fileChooserClass.getMethod(method, windowClass);
Object file = showDialogMethod.invoke(fileChooser, (Object) null);
return (File) file;
}
});
} catch (Exception e) {
return JFileChooser.ERROR_OPTION;
}
if (selectedFile == null) {
return JFileChooser.CANCEL_OPTION;
}
return JFileChooser.APPROVE_OPTION;
}
use of java.awt.HeadlessException in project energy3d by concord-consortium.
the class Foundation method init.
@Override
protected void init() {
super.init();
resizeHouseMode = false;
if (Util.isZero(uValue)) {
uValue = 0.19;
}
if (Util.isZero(volumetricHeatCapacity)) {
volumetricHeatCapacity = 0.5;
}
if (Util.isZero(solarReceiverEfficiency)) {
solarReceiverEfficiency = 0.2;
}
if (Util.isZero(childGridSize)) {
childGridSize = 2.5;
}
if (thermostat == null) {
thermostat = new Thermostat();
}
mesh = new Mesh("Foundation");
mesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
mesh.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(6));
mesh.getMeshData().setTextureBuffer(BufferUtils.createVector2Buffer(6), 0);
mesh.setRenderState(offsetState);
mesh.setModelBound(new BoundingBox());
root.attachChild(mesh);
if (foundationPolygon == null) {
foundationPolygon = new FoundationPolygon(this);
} else {
foundationPolygon.draw();
}
root.attachChild(foundationPolygon.getRoot());
sideMesh = new Mesh[4];
for (int i = 0; i < 4; i++) {
final Mesh mesh_i = new Mesh("Foundation (Side " + i + ")");
mesh_i.setUserData(new UserData(this));
mesh_i.setRenderState(offsetState);
mesh_i.setModelBound(new BoundingBox());
final MeshData meshData = mesh_i.getMeshData();
meshData.setVertexBuffer(BufferUtils.createVector3Buffer(6));
meshData.setNormalBuffer(BufferUtils.createVector3Buffer(6));
mesh_i.getMeshData().setTextureBuffer(BufferUtils.createVector2Buffer(6), 0);
root.attachChild(mesh_i);
sideMesh[i] = mesh_i;
}
boundingMesh = new Line("Foundation (Bounding)");
boundingMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(24));
boundingMesh.setModelBound(new BoundingBox());
Util.disablePickShadowLight(boundingMesh);
boundingMesh.getSceneHints().setCullHint(CullHint.Always);
root.attachChild(boundingMesh);
outlineMesh = new Line("Foundation (Outline)");
outlineMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(24));
outlineMesh.setDefaultColor(ColorRGBA.BLACK);
outlineMesh.setModelBound(new BoundingBox());
Util.disablePickShadowLight(outlineMesh);
root.attachChild(outlineMesh);
linePatternMesh = new Line("Line Pattern");
linePatternMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(2));
linePatternMesh.setDefaultColor(new ColorRGBA(0, 0, 0, 0.75f));
linePatternMesh.setModelBound(null);
final BlendState blendState = new BlendState();
blendState.setBlendEnabled(true);
linePatternMesh.setRenderState(blendState);
linePatternMesh.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
Util.disablePickShadowLight(linePatternMesh);
root.attachChild(linePatternMesh);
setLinePatternVisible(false);
final UserData userData = new UserData(this);
mesh.setUserData(userData);
boundingMesh.setUserData(userData);
setLabelOffset(-0.11);
label = new BMText("Floating Label", "Undefined", FontManager.getInstance().getPartNumberFont(), Align.Center, Justify.Center);
Util.initHousePartLabel(label);
label.setFontScale(0.5);
label.setVisible(false);
root.attachChild(label);
azimuthArrow = new Line("Azimuth Arrow");
azimuthArrow.setLineWidth(2);
azimuthArrow.setModelBound(null);
Util.disablePickShadowLight(azimuthArrow);
azimuthArrow.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
azimuthArrow.setDefaultColor(ColorRGBA.WHITE);
root.attachChild(azimuthArrow);
solarReceiver = new Cylinder("Solar Receiver", 10, 10, 10, 0, true);
solarReceiver.setDefaultColor(ColorRGBA.WHITE);
solarReceiver.setRenderState(offsetState);
solarReceiver.setModelBound(new BoundingBox());
solarReceiver.setVisible(false);
root.attachChild(solarReceiver);
selectedMeshOutline = new Line("Outline of Selected Mesh");
selectedMeshOutline.setLineWidth(2f);
selectedMeshOutline.setStipplePattern((short) 0xf0f0);
selectedMeshOutline.setModelBound(null);
Util.disablePickShadowLight(selectedMeshOutline);
selectedMeshOutline.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(1));
selectedMeshOutline.setDefaultColor(new ColorRGBA(0f, 0f, 0f, 1f));
root.attachChild(selectedMeshOutline);
selectedNodeBoundingBox = new Line("Bounding Box of Selected Mesh");
selectedNodeBoundingBox.setLineWidth(0.01f);
selectedNodeBoundingBox.setStipplePattern((short) 0xf0f0);
selectedNodeBoundingBox.setModelBound(null);
Util.disablePickShadowLight(selectedNodeBoundingBox);
selectedNodeBoundingBox.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(24));
selectedNodeBoundingBox.setDefaultColor(new ColorRGBA(1f, 1f, 0f, 1f));
root.attachChild(selectedNodeBoundingBox);
updateTextureAndColor();
if (points.size() == 8) {
for (int i = 0; i < 4; i++) {
points.add(new Vector3());
}
}
if (importedNodeStates != null) {
try {
for (final Iterator<NodeState> it = importedNodeStates.iterator(); it.hasNext(); ) {
final NodeState ns = it.next();
final Node n = importCollada(ns.getSourceURL(), null);
if (n == null) {
it.remove();
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
try {
JOptionPane.showMessageDialog(MainFrame.getInstance(), Paths.get(ns.getSourceURL().toURI()).toFile() + " was not found!", "File problem", JOptionPane.ERROR_MESSAGE);
} catch (final HeadlessException e) {
e.printStackTrace();
} catch (final URISyntaxException e) {
e.printStackTrace();
}
}
});
} else {
final ArrayList<Integer> reversedFaceMeshes = ns.getMeshesWithReversedNormal();
if (reversedFaceMeshes != null) {
for (final Integer i : reversedFaceMeshes) {
Util.reverseFace(Util.getMesh(n, i));
}
}
final ArrayList<Integer> deletedMeshes = ns.getDeletedMeshes();
if (deletedMeshes != null && !deletedMeshes.isEmpty()) {
final List<Mesh> toDelete = new ArrayList<Mesh>();
for (final Integer i : deletedMeshes) {
toDelete.add(Util.getMesh(n, i));
}
for (final Mesh m : toDelete) {
n.detachChild(m);
}
}
final HashMap<Integer, ReadOnlyColorRGBA> meshColors = ns.getMeshColors();
if (meshColors != null) {
for (final Integer i : meshColors.keySet()) {
Util.getMesh(n, i).setDefaultColor(meshColors.get(i));
}
}
}
}
} catch (final Throwable t) {
BugReporter.report(t);
}
setRotatedNormalsForImportedMeshes();
}
}
use of java.awt.HeadlessException in project entando-core by entando.
the class PNGImageResizer method toBufferedImage.
protected BufferedImage toBufferedImage(Image image) throws ApsSystemException {
if (image instanceof BufferedImage) {
return (BufferedImage) image;
}
// This code ensures that all the pixels in the image are loaded
image = new ImageIcon(image).getImage();
// Determine if the image has transparent pixels.
boolean hasAlpha = this.hasAlpha(image);
// Create a buffered image with a format that's compatible with the
// screen
BufferedImage bimage = null;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
try {
// Determine the type of transparency of the new buffered image
int transparency = Transparency.OPAQUE;
if (hasAlpha) {
transparency = Transparency.BITMASK;
}
// Create the buffered image
GraphicsDevice gs = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gs.getDefaultConfiguration();
bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency);
} catch (HeadlessException e) {
throw new ApsSystemException("The system does not have a screen", e);
}
if (bimage == null) {
// Create a buffered image using the default color model
int type = BufferedImage.TYPE_INT_RGB;
if (hasAlpha) {
type = BufferedImage.TYPE_INT_ARGB;
}
bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type);
}
// Copy image to buffered image
Graphics graphics = bimage.createGraphics();
// Paint the image onto the buffered image
graphics.drawImage(image, 0, 0, null);
graphics.dispose();
return bimage;
}
use of java.awt.HeadlessException in project acceptance-test-harness by jenkinsci.
the class TestRecorderRule method startRecording.
private void startRecording(Description des) {
try {
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
String mimeType = FormatKeys.MIME_QUICKTIME;
String videoFormatName = VideoFormatKeys.ENCODING_QUICKTIME_ANIMATION;
String compressorName = VideoFormatKeys.COMPRESSOR_NAME_QUICKTIME_ANIMATION;
Dimension outputDimension = gc.getBounds().getSize();
int bitDepth = BIT_DEPTH;
float quality = QUALITY_RATIO;
int screenRate = FRAME_RATE_PER_SEC;
Format outputFormatForScreenCapture = getOutputFormatForScreenCapture(videoFormatName, compressorName, outputDimension, bitDepth, quality, screenRate);
this.screenRecorder = new JUnitScreenRecorder(gc, gc.getBounds(), getFileFormat(mimeType), outputFormatForScreenCapture, null, null, diagnostics);
this.screenRecorder.start();
} catch (HeadlessException e) {
logger.warning("Test recorder does not work with Headless mode");
this.headless = true;
} catch (UnsupportedOperationException | IOException | AWTException e) {
logger.log(Level.WARNING, "Exception starting test recording", e);
}
}
use of java.awt.HeadlessException in project specify by rhebecaabreu.
the class MeusProjetos method editarProjetos.
public JPanel editarProjetos() {
panelEditarP = new JPanel();
panelEditarP.setBorder(new LineBorder(SystemColor.inactiveCaption));
panelEditarP.setLayout(null);
JPanel panel = new JPanel();
panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
panel.setFont(new Font("Noto Sans CJK TC Medium", Font.PLAIN, 14));
panel.setBounds(7, 40, 565, 320);
panelEditarP.add(panel);
panel.setLayout(null);
JPanel panel_ultima_mod = new JPanel();
panel_ultima_mod.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
panel_ultima_mod.setFont(new Font("Noto Sans CJK TC Medium", Font.PLAIN, 14));
panel_ultima_mod.setBounds(7, 365, 565, 37);
panelEditarP.add(panel_ultima_mod);
panel_ultima_mod.setLayout(null);
JButton lblCadastrarNovoProjeto = new JButton(" Visualizar ou editar projeto");
lblCadastrarNovoProjeto.setFocusable(false);
lblCadastrarNovoProjeto.setFocusPainted(false);
lblCadastrarNovoProjeto.setFocusTraversalKeysEnabled(false);
lblCadastrarNovoProjeto.setIcon(new ImageIcon(CadastrarProjeto.class.getResource("/images/application_add.png")));
lblCadastrarNovoProjeto.setHorizontalAlignment(SwingConstants.LEFT);
lblCadastrarNovoProjeto.setForeground(SystemColor.control);
lblCadastrarNovoProjeto.setBackground(SystemColor.activeCaptionText);
lblCadastrarNovoProjeto.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 14));
lblCadastrarNovoProjeto.setBounds(5, 8, 569, 30);
panelEditarP.add(lblCadastrarNovoProjeto);
/**
*********** nome do projeto *****************
*/
JLabel lblInsiraONome = new JLabel("Nome do projeto:");
lblInsiraONome.setBounds(30, 17, 130, 25);
panel.add(lblInsiraONome);
lblInsiraONome.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
recebeNomeProjeto = new JTextField();
recebeNomeProjeto.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
recebeNomeProjeto.setBounds(27, 42, 495, 30);
panel.add(recebeNomeProjeto);
/**
*******datas inicio e fim*****************
*/
JLabel lblInsiraAData = new JLabel("Data de inicio: ");
lblInsiraAData.setBounds(30, 81, 100, 20);
panel.add(lblInsiraAData);
lblInsiraAData.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
recebeDataInicio_1_1 = new JFormattedTextField();
try {
// mascara para datas
javax.swing.text.MaskFormatter datax = new javax.swing.text.MaskFormatter("##/##/####");
datax.setPlaceholderCharacter('_');
recebeDataInicio_1_1 = new javax.swing.JFormattedTextField(datax);
recebeDataInicio_1_1.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
// evento de foco
recebeDataInicio_1_1.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent arg0) {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
sdf.setLenient(false);
String dataa = recebeDataInicio_1_1.getText();
try {
Date data = sdf.parse(dataa);
recebeDataInicio_1_1.setBorder(new LineBorder(Color.GRAY));
} catch (ParseException e) {
if (recebeDataInicio_1_1.getText().toString().equals("__/__/____")) {
} else {
JOptionPane.showMessageDialog(null, "Data de início inválida! " + "\nPor favor, insira uma data válida. ", "Erro", JOptionPane.ERROR_MESSAGE);
recebeDataInicio_1_1.setBorder(new LineBorder(Color.RED));
recebeDataInicio_1_1.grabFocus();
}
}
}
});
// fim evento de foco
recebeDataInicio_1_1.setHorizontalAlignment(SwingConstants.CENTER);
recebeDataInicio_1_1.setToolTipText("DD/MM/AAAA");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Erro ao inserir data!");
}
// fim mascara de data
recebeDataInicio_1_1.setBounds(28, 103, 100, 30);
panel.add(recebeDataInicio_1_1);
// data termino ------------------------------------------------------------------------------------------------
JLabel lblDataAproximadaPara = new JLabel("Data aprox. para término:");
lblDataAproximadaPara.setBounds(170, 81, 250, 20);
panel.add(lblDataAproximadaPara);
lblDataAproximadaPara.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
recebeDataTermino_1 = new JFormattedTextField();
try {
javax.swing.text.MaskFormatter data = new javax.swing.text.MaskFormatter("##/##/####");
data.setPlaceholderCharacter('_');
recebeDataTermino_1 = new javax.swing.JFormattedTextField(data);
recebeDataTermino_1.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
recebeDataTermino_1.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent arg0) {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
sdf.setLenient(false);
String dataHoje = recebeDataTermino_1.getText();
String dataini = recebeDataInicio_1_1.getText();
String datafim = recebeDataTermino_1.getText();
try {
if (convData.comparaDatas(datafim, dataini) == false) {
JOptionPane.showMessageDialog(null, "Data inválida! A data de início deve ser menor que a data aproximada de término do projeto.", "Erro", JOptionPane.ERROR_MESSAGE);
recebeDataInicio_1_1.setBorder(new LineBorder(Color.RED));
recebeDataTermino_1.setBorder(new LineBorder(Color.RED));
} else {
try {
Date data = sdf.parse(dataHoje);
recebeDataInicio_1_1.setBorder(new LineBorder(Color.GRAY));
recebeDataTermino_1.setBorder(new LineBorder(Color.GRAY));
} catch (ParseException e) {
if (recebeDataTermino_1.getText().toString().equals("__/__/____")) {
} else {
JOptionPane.showMessageDialog(null, "Data aproximada para término inválida! " + "\nPor favor, insira uma data válida. ", "Erro", JOptionPane.ERROR_MESSAGE);
recebeDataTermino_1.setBorder(new LineBorder(Color.RED));
recebeDataTermino_1.grabFocus();
}
}
}
} catch (HeadlessException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
}
}
});
recebeDataTermino_1.setHorizontalAlignment(SwingConstants.CENTER);
recebeDataTermino_1.setToolTipText("DD/MM/AAAA");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Erro ao inserir data!");
}
recebeDataTermino_1.setBounds(169, 103, 100, 30);
panel.add(recebeDataTermino_1);
/**
*****************************************
*/
/**
*********** DESCRICAO PROJETO **************
*/
lblDescrioDoProjeto = new JLabel("Descrição do projeto:");
lblDescrioDoProjeto.setBounds(30, 147, 200, 15);
panel.add(lblDescrioDoProjeto);
lblDescrioDoProjeto.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
recebeDescricao = new JTextArea();
recebeDescricao.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_TAB) {
recebeRecursoFinanceiro_1.grabFocus();
}
}
});
recebeDescricao.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
JScrollPane scrollPane_1 = new JScrollPane(recebeDescricao);
scrollPane_1.setBounds(27, 165, 495, 70);
panel.add(scrollPane_1);
// só mostra a barra vertical se necessário
scrollPane_1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane_1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
recebeDescricao.setMargin(new Insets(4, 3, 4, 3));
recebeDescricao.setTabSize(10);
recebeDescricao.setWrapStyleWord(true);
recebeDescricao.setLineWrap(true);
recebeDescricao.setBounds(271, 284, 200, 60);
/**
*****************************************************
* recurso financeiro
******************************************************
*/
lblRecursosFinanceiros = new JLabel("Recurso financeiro estimado (R$): ");
lblRecursosFinanceiros.setBounds(30, 247, 250, 25);
panel.add(lblRecursosFinanceiros);
lblRecursosFinanceiros.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
recebeRecursoFinanceiro_1 = new JFormattedTextField();
recebeRecursoFinanceiro_1.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
recebeRecursoFinanceiro_1.setBounds(27, 270, 230, 30);
recebeRecursoFinanceiro_1.setToolTipText("R$");
try {
recebeRecursoFinanceiro_1.setDocument(new ModelMaskMonetary());
} catch (Exception e) {
e.printStackTrace();
}
panel.add(recebeRecursoFinanceiro_1);
/**
*****************Botão ajuda******************
*/
JButton btnAjuda = new JButton("");
btnAjuda.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
btnAjuda.setToolTipText("Ajuda");
btnAjuda.setBounds(531, 6, 28, 25);
panel.add(btnAjuda);
btnAjuda.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
TelaAjudaProjeto tap = new TelaAjudaProjeto();
tap.setVisible(true);
tap.setLocationRelativeTo(null);
}
});
btnAjuda.setForeground(SystemColor.controlHighlight);
btnAjuda.setBackground(SystemColor.textHighlight);
btnAjuda.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
btnAjuda.setIcon(new ImageIcon(CadastrarProjeto.class.getResource("/images/help.png")));
/**
**********************************************
*/
/**
******************ACAO SALVAR*****************
*/
JButton btnSalvar = new JButton("Salvar ");
btnSalvar.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
btnSalvar.setForeground(SystemColor.controlHighlight);
btnSalvar.setBackground(SystemColor.textHighlight);
btnSalvar.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
btnSalvar.setIcon(new ImageIcon(CadastrarProjeto.class.getResource("/images/disk.png")));
btnSalvar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ProjetoDAO dao = new ProjetoDAO();
Projeto cprojeto = new Projeto();
try {
if (recebeNomeProjeto.getText().toString() == null || recebeNomeProjeto.getText().toString().isEmpty()) {
JOptionPane.showMessageDialog(null, "Insira o nome do projeto!", "Erro", JOptionPane.ERROR_MESSAGE);
} else {
cprojeto.setNome(recebeNomeProjeto.getText());
if (convData.comparaDatas(recebeDataTermino_1.getText(), recebeDataInicio_1_1.getText()) == false) {
JOptionPane.showMessageDialog(null, "Datas inválidas! A data de início deve ser menor que a data aproximada de término.", "Erro", JOptionPane.ERROR_MESSAGE);
} else {
cprojeto.setDataInicio(convData.converteDataDB(recebeDataInicio_1_1.getText()));
cprojeto.setDataAproxTermino(convData.converteDataDB(recebeDataTermino_1.getText()));
if (recebeDescricao.getText().toString() == null || recebeDescricao.getText().toString().isEmpty()) {
JOptionPane.showMessageDialog(null, "Insira a descrição do projeto!", "Erro", JOptionPane.ERROR_MESSAGE);
} else {
cprojeto.setDescricao(recebeDescricao.getText());
String texto = recebeRecursoFinanceiro_1.getText();
texto = texto.replace(".", "");
texto = texto.replace(",", ".");
cprojeto.setRecursosFinanceiros(Double.parseDouble(texto));
int codigo = 0;
if (tablep.getSelectedRow() != -1) {
int i = tablep.getSelectedRow();
Object valorSelecionado = tableproj.getValueAt(i, 0);
if (valorSelecionado.equals(true)) {
for (Projeto p : dao.read()) {
if (p.getNome().equals(tablep.getValueAt(i, 1).toString())) {
codigo = p.getCodigo();
}
}
}
}
// System.out.println(codigo);
cprojeto.setCodigo(codigo);
cprojeto.setId_usuario(Login.getId_usuario());
dao.update(cprojeto);
tableproj.limpar();
readJTableProjeto(tableproj);
tabbedPane.remove(tabbedPane.getSelectedIndex());
abrirPanel(0);
}
}
}
} catch (ParseException e1) {
// TODO Auto-generated catch block
JOptionPane.showMessageDialog(null, "Data vazia ou inválida! " + "\nPor favor, insira uma data válida.", "Erro", JOptionPane.ERROR_MESSAGE);
// e1.printStackTrace();
}
MeusProjetos mp = new MeusProjetos();
mp.atualizaArvore(tree);
}
});
btnSalvar.setBounds(456, 403, 117, 30);
panelEditarP.add(btnSalvar);
/**
************** FIM ACAO BOTAO SALVAR**********************
*/
/**
***************** botão cancelar ***************
*/
JButton btnCancelar = new JButton("Voltar");
btnCancelar.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
btnCancelar.setForeground(SystemColor.controlHighlight);
btnCancelar.setBackground(SystemColor.textHighlight);
btnCancelar.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
btnCancelar.setIcon(new ImageIcon(CadastrarProjeto.class.getResource("/images/back.png")));
btnCancelar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// System.out.println(tabbedPane.getSelectedIndex());
tabbedPane.remove(tabbedPane.getSelectedIndex());
abrirPanel(0);
}
});
btnCancelar.setBounds(6, 403, 117, 30);
panelEditarP.add(btnCancelar);
/**
******************************************
*/
UsuarioDAO userDAO = new UsuarioDAO();
JLabel ultimaMod = new JLabel("Ultima modificação");
ultimaMod.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
ultimaMod.setBounds(5, 5, 500, 400);
ultimaMod.setVisible(true);
panel_ultima_mod.add(ultimaMod);
ProjetoDAO pdao = new ProjetoDAO();
if (tablep.getSelectedRow() != -1) {
int i = tablep.getSelectedRow();
Object valorSelecionado = tableproj.getValueAt(i, 0);
if (valorSelecionado.equals(true)) {
for (Projeto p : pdao.read()) {
String nomep = tableproj.getValueAt(i, 1).toString();
if (p.getNome().equals(nomep)) {
recebeNomeProjeto.setText(p.getNome());
DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd");
DateFormat df1 = new SimpleDateFormat("dd/MM/yyyy");
String sdata = p.getDataInicio();
String fdata = p.getDataAproxTermino();
// System.out.println(sdata + " ===== "+ fdata);
Date data, data2;
try {
df1.setLenient(false);
df2.setLenient(false);
data = df2.parse(sdata);
data2 = df2.parse(fdata);
if (p.getUltimaAtualizacao() == null) {
ultimaMod = new JLabel("Ultima modificação: Sem modificações ");
ultimaMod.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
ultimaMod.setBounds(5, 2, 500, 35);
panel_ultima_mod.add(ultimaMod);
} else {
String ultima_mod = convData.converteDataHoraBR(p.getUltimaAtualizacao());
ultimaMod = new JLabel("Última modificação realizada por " + userDAO.buscaNome(p.getId_usuario()) + " em " + ultima_mod);
ultimaMod.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
ultimaMod.setBounds(5, 2, 500, 35);
panel_ultima_mod.add(ultimaMod);
}
// System.out.println(df1.format(data)+"------"+df1.format(data2) );
recebeDataInicio_1_1.setText(df1.format(data));
recebeDataTermino_1.setText(df1.format(data2));
recebeDescricao.setText(p.getDescricao());
String texto = String.valueOf(p.getRecursosFinanceiros());
try {
if (texto.substring(texto.length() - 2, texto.length() - 1).equals(".")) {
recebeRecursoFinanceiro_1.setText(texto.replace(".", "") + "0");
} else {
recebeRecursoFinanceiro_1.setText(texto.replace(".", ""));
}
} catch (StringIndexOutOfBoundsException ex) {
if (texto.substring(texto.length() - 2, texto.length() - 1).equals(".")) {
recebeRecursoFinanceiro_1.setText(texto.replace(".", "") + "0");
} else {
recebeRecursoFinanceiro_1.setText(texto.replace(".", ""));
}
}
// recebeRecursoFinanceiro_1.setText(texto);
} catch (ParseException e1) {
e1.printStackTrace();
}
break;
}
}
}
}
return panelEditarP;
}
Aggregations