List of usage examples for java.beans PropertyChangeEvent getNewValue
public Object getNewValue()
From source file:org.squidy.designer.model.NodeShape.java
/** * //from ww w . j a v a2 s .co m */ private void buildPropertiesForPropertiesTable() { propertiesTable.clearEntries(); Field[] fields = ReflectionUtil.getFieldsInObjectHierarchy(getProcessable().getClass()); for (Field field : fields) { if (field.isAnnotationPresent(Property.class)) { final String fieldName = field.getName(); Object value = MVEL.getProperty(field.getName(), getProcessable()); final AbstractBasicControl<Object, ?> control; if (field.isAnnotationPresent(TextField.class)) { control = (AbstractBasicControl<Object, ?>) ControlUtils .createControl(field.getAnnotation(TextField.class), value); } else if (field.isAnnotationPresent(CheckBox.class)) { control = (AbstractBasicControl<Object, ?>) ControlUtils .createControl(field.getAnnotation(CheckBox.class), value); } else if (field.isAnnotationPresent(ComboBox.class)) { control = (AbstractBasicControl<Object, ?>) ControlUtils .createControl(field.getAnnotation(ComboBox.class), value); } else if (field.isAnnotationPresent(Slider.class)) { control = (AbstractBasicControl<Object, ?>) ControlUtils .createControl(field.getAnnotation(Slider.class), value); } else if (field.isAnnotationPresent(Spinner.class)) { control = (AbstractBasicControl<Object, ?>) ControlUtils .createControl(field.getAnnotation(Spinner.class), value); } else if (field.isAnnotationPresent(ImagePanel.class)) { control = (AbstractBasicControl<Object, ?>) ControlUtils .createControl(field.getAnnotation(ImagePanel.class), value); } else if (field.isAnnotationPresent(Gauge.class)) { control = (AbstractBasicControl<Object, ?>) ControlUtils .createControl(field.getAnnotation(Gauge.class), value); } else if (field.isAnnotationPresent(FileChooser.class)) { control = (AbstractBasicControl<Object, ?>) ControlUtils .createControl(field.getAnnotation(FileChooser.class), value); } else { throw new SquidyException("Couldn't add property " + fieldName + " to properties table because of a not existing control annotation."); } Property property = field.getAnnotation(Property.class); String name = property.name(); String description = property.description(); String prefix = property.prefix(); String suffix = property.suffix(); // Add property change listener to receive processing updates. getProcessable().addStatusChangeListener(fieldName, new PropertyChangeListener() { /* * (non-Javadoc) * * @see * java.beans.PropertyChangeListener#propertyChange(java * .beans.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent evt) { try { control.setValueWithoutPropertyUpdate(evt.getNewValue()); } catch (Exception e) { control.setValueWithoutPropertyUpdate( control.valueFromString(evt.getNewValue().toString())); } control.getComponent().repaint(); propertiesTable.firePropertyChange(CropScroll.CROP_SCROLLER_UPDATE, null, null); } }); // Add property update change listener to inform the processable // about UI update events. control.addPropertyUpdateListener(new PropertyUpdateListener<Object>() { /* * (non-Javadoc) * * @see org.squidy.designer.components. * PropertyUpdateListener #propertyUpdate(java.lang.Object) */ public void propertyUpdate(Object value) { try { // Notify manager about property changes. Manager.get().propertyChanged(getProcessable(), fieldName, value); control.firePropertyChange(PROPERTY_BINDING_OK, null, null); } catch (Exception e) { control.firePropertyChange(PROPERTY_BINDING_EXCEPTION, null, null); publishFailure(new SquidyException("Could not set property " + fieldName + ". Please check setter of this property for any Exceptions such as NullPointerException.", e)); } propertiesTable.firePropertyChange(CropScroll.CROP_SCROLLER_UPDATE, null, null); } }); TableEntry entry = new TableEntry<IBasicControl<?, ?>>(name, description, control, prefix, suffix); if (field.isAnnotationPresent(ImagePanel.class)) { entry.addInputEventListener(new PBasicInputEventHandler() { @Override public void mouseClicked(PInputEvent event) { control.customPInputEvent(event); } }); } propertiesTable.addEntryToGroup(entry, property.group()); } } }
From source file:org.talend.designer.core.ui.editor.update.cmd.UpdateJobletNodeCommand.java
/** * qzhang Comment method "updateGraphicalNodesSchema". * //from w ww. jav a 2 s .c o m * this method is moved from class AbstractTalendEditor. * * @param evt */ @SuppressWarnings("unchecked") private void updateGraphicalNodesSchema(Process process, PropertyChangeEvent evt) { if (!(evt.getSource() instanceof INode)) { return; } INode sourceNode = (INode) evt.getSource(); String componentName = sourceNode.getComponent().getName(); IComponent newComponent = ComponentsFactoryProvider.getInstance().get(componentName, ComponentCategory.CATEGORY_4_DI.getName()); if (newComponent == null) { return; } Object[] newMetadataTables = (Object[]) evt.getNewValue(); List<IMetadataTable> newInputTableList = (List<IMetadataTable>) newMetadataTables[0]; List<IMetadataTable> newOutputTableList = (List<IMetadataTable>) newMetadataTables[1]; for (Node node : (List<Node>) process.getGraphicalNodes()) { if (node.getComponent().getName().equals(componentName)) { List<IElementParameter> outputElemParams = new ArrayList<IElementParameter>(); IElementParameter outputElemParam = null; List<? extends IElementParameter> elementParameters = node.getElementParameters(); for (IElementParameter elementParameter : elementParameters) { if (EParameterFieldType.SCHEMA_TYPE.equals(elementParameter.getFieldType())) { outputElemParams.add(elementParameter); } } ChangeMetadataCommand command; List<? extends IConnection> incomingConnections = node.getIncomingConnections(); if (incomingConnections.size() <= 1) { for (int i = 0; i < incomingConnections.size(); i++) { IConnection connection = incomingConnections.get(i); Node source = (Node) connection.getSource(); IMetadataTable metadataTable = connection.getMetadataTable(); IMetadataTable newInputMetadataTable = UpdateManagerUtils.getNewInputTableForConnection( newInputTableList, metadataTable.getAttachedConnector()); if (newInputMetadataTable != null && !metadataTable.sameMetadataAs(newInputMetadataTable)) { IElementParameter elementParam = source .getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE); command = new ChangeMetadataCommand(source, elementParam, metadataTable, newInputMetadataTable); command.execute(Boolean.FALSE); } } } else { for (IElementParameter param : node.getElementParameters()) { if (param.isShow(node.getElementParameters()) && param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)) { IMetadataTable table = node.getMetadataFromConnector(param.getContext()); IElementParameter connParam = param.getChildParameters() .get(EParameterName.CONNECTION.getName()); if (table != null && connParam != null && !StringUtils.isEmpty((String) connParam.getValue())) { for (IConnection connection : incomingConnections) { if (connection.isActivate() && connection.getName().equals(connParam.getValue())) { if (!table.sameMetadataAs(connection.getMetadataTable(), IMetadataColumn.OPTIONS_IGNORE_KEY | IMetadataColumn.OPTIONS_IGNORE_NULLABLE | IMetadataColumn.OPTIONS_IGNORE_COMMENT | IMetadataColumn.OPTIONS_IGNORE_PATTERN | IMetadataColumn.OPTIONS_IGNORE_DBCOLUMNNAME | IMetadataColumn.OPTIONS_IGNORE_DBTYPE | IMetadataColumn.OPTIONS_IGNORE_DEFAULT | IMetadataColumn.OPTIONS_IGNORE_BIGGER_SIZE)) { Node source = (Node) connection.getSource(); IMetadataTable metadataTable = connection.getMetadataTable(); IElementParameter elementParam = source .getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE); command = new ChangeMetadataCommand(source, elementParam, metadataTable, table); command.execute(Boolean.FALSE); } } } } } } } List<? extends IConnection> outgoingConnections = node.getOutgoingConnections(); for (int i = 0; i < outgoingConnections.size(); i++) { IConnection connection = outgoingConnections.get(i); Node target = (Node) connection.getTarget(); IMetadataTable metadataTable = connection.getMetadataTable(); if (metadataTable != null) { IMetadataTable newOutputMetadataTable = UpdateManagerUtils.getNewOutputTableForConnection( newOutputTableList, metadataTable.getAttachedConnector()); if (newOutputMetadataTable != null && !metadataTable.sameMetadataAs(newOutputMetadataTable)) { IElementParameter elementParam = target .getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE); command = new ChangeMetadataCommand(target, elementParam, target.getMetadataFromConnector(metadataTable.getAttachedConnector()), newOutputMetadataTable); command.execute(Boolean.FALSE); } } } List<IMetadataTable> metadataList = node.getMetadataList(); for (IMetadataTable metadataTable : metadataList) { IMetadataTable newInputMetadataTable = UpdateManagerUtils .getNewInputTableForConnection(newInputTableList, metadataTable.getAttachedConnector()); IMetadataTable newOutputMetadataTable = UpdateManagerUtils.getNewOutputTableForConnection( newOutputTableList, metadataTable.getAttachedConnector()); outputElemParam = UpdateManagerUtils.getElemParam(outputElemParams, metadataTable.getAttachedConnector()); if (outputElemParam != null && newInputMetadataTable != null) { command = new ChangeMetadataCommand(node, outputElemParam, (IMetadataTable) outputElemParam.getValue(), newInputMetadataTable); command.execute(Boolean.FALSE); IMetadataTable metadataFromConnector = node .getMetadataFromConnector(outputElemParam.getContext()); MetadataToolHelper.copyTable(newInputMetadataTable, metadataFromConnector); } else if (outputElemParam != null && newOutputMetadataTable != null) { command = new ChangeMetadataCommand(node, outputElemParam, (IMetadataTable) outputElemParam.getValue(), newOutputMetadataTable); command.execute(Boolean.FALSE); IMetadataTable metadataFromConnector = node .getMetadataFromConnector(outputElemParam.getContext()); MetadataToolHelper.copyTable(newOutputMetadataTable, metadataFromConnector); } } } } }
From source file:edu.ku.brc.specify.config.FixAttachments.java
/** * //w ww . j a va 2 s . com */ public void checkForBadAttachments() { int count = getNumberofBadAttachments(); if (count == 0) { AppPreferences.getGlobalPrefs().putBoolean("CHECK_ATTCH_ERR", false); return; } URL url = null; JEditorPane htmlPane; try { url = new URL("http://files.specifysoftware.org/attachment_recovery.html"); htmlPane = new JEditorPane(url); } catch (Exception e) { e.printStackTrace(); htmlPane = new JEditorPane("text/html", //$NON-NLS-1$ "<html><body><h1>Network Error - You must have a network conneciton to get the instructions.</H1></body>"); } JScrollPane scrollPane = UIHelper.createScrollPane(htmlPane); htmlPane.setEditable(false); JPanel panel = new JPanel(new BorderLayout()); panel.add(scrollPane, BorderLayout.CENTER); panel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); CustomDialog infoDlg = new CustomDialog((Dialog) null, "Recovery Information", true, CustomDialog.OKCANCEL, panel); infoDlg.setCancelLabel("Close"); infoDlg.setOkLabel("Print in Browser"); infoDlg.createUI(); infoDlg.setSize(1024, 600); try { hookupAction(infoDlg.getOkBtn(), url != null ? url.toURI() : null); infoDlg.setVisible(true); } catch (Exception ex) { } final String CNT = "CNT"; final SwingWorker<Integer, Integer> worker = new SwingWorker<Integer, Integer>() { int totalFiles = 0; HashMap<Integer, Vector<Object[]>> resultsHashMap = new HashMap<Integer, Vector<Object[]>>(); HashMap<Integer, String> tblTypeHash = new HashMap<Integer, String>(); HashMap<Integer, String> agentHash = new HashMap<Integer, String>(); HashMap<Integer, AttchTableModel> tableHash = new HashMap<Integer, AttchTableModel>(); ArrayList<JTable> tableList = new ArrayList<JTable>(); ArrayList<Integer> tableIdList = new ArrayList<Integer>(); @Override protected Integer doInBackground() throws Exception { DataProviderSessionIFace session = null; try { // This doesn't need to include the new attachments int[] tableIds = { AccessionAttachment.getClassTableId(), AgentAttachment.getClassTableId(), CollectingEventAttachment.getClassTableId(), CollectionObjectAttachment.getClassTableId(), ConservDescriptionAttachment.getClassTableId(), ConservEventAttachment.getClassTableId(), DNASequencingRunAttachment.getClassTableId(), FieldNotebookAttachment.getClassTableId(), FieldNotebookPageAttachment.getClassTableId(), FieldNotebookPageSetAttachment.getClassTableId(), LoanAttachment.getClassTableId(), LocalityAttachment.getClassTableId(), PermitAttachment.getClassTableId(), PreparationAttachment.getClassTableId(), RepositoryAgreementAttachment.getClassTableId(), TaxonAttachment.getClassTableId() }; Agent userAgent = AppContextMgr.getInstance().getClassObject(Agent.class); int totFiles = 0; firePropertyChange(CNT, 0, 0); int cnt = 0; for (int tableId : tableIds) { Vector<Object[]> results = getImageData(userAgent.getId(), tableId, tblTypeHash); if (results != null && results.size() > 0) { resultsHashMap.put(tableId, results); totFiles += results.size(); //System.out.println(tableId+" -> "+results.size()); } firePropertyChange(CNT, 0, (int) ((double) cnt / (double) tableIds.length * 100.0)); cnt++; } if (resultsHashMap.size() == 0) // Shouldn't happen { return null; } session = DataProviderFactory.getInstance().createSession(); firePropertyChange(CNT, 0, 0); int i = 1; for (int tblId : resultsHashMap.keySet()) { DBTableInfo ti = DBTableIdMgr.getInstance().getInfoById(tblId); Vector<Object[]> dataRows = new Vector<Object[]>(); Vector<Object[]> results = resultsHashMap.get(tblId); for (Object[] row : results) { Integer agentId = (Integer) row[3]; String userName = agentHash.get(agentId); if (userName == null) { userName = BasicSQLUtils.querySingleObj( "SELECT su.Name FROM agent a INNER JOIN specifyuser su ON a.SpecifyUserID = su.SpecifyUserID WHERE a.AgentID = " + row[3]); agentHash.put(agentId, userName); } //userName = i == 1 ? "bill.johnson" : "joe.smith"; int attachJoinID = (Integer) row[4]; String identTitle = getIdentityTitle(session, ti, attachJoinID); String fullPath = (String) row[2]; //fullPath = StringUtils.replace(fullPath, "darwin\\", "darwin2\\"); //boolean doesExist = (new File(fullPath)).exists() && i != 1; boolean doesExist = (new File(fullPath)).exists(); //String str = i != 1 ? "/Users/joe/Desktop/xxx.png" : "/Users/bill/Desktop/xxx.png"; //String fullPath = FilenameUtils.getFullPath(str) + String.format("DSC_%05d.png", i); Object[] rowObjs = new Object[8]; rowObjs[0] = StringUtils.isEmpty(identTitle) ? "" : (identTitle.length() > 30 ? identTitle.substring(0, 30) + "..." : identTitle); rowObjs[1] = FilenameUtils.getName(fullPath); rowObjs[2] = fullPath; rowObjs[3] = userName; rowObjs[4] = doesExist; rowObjs[5] = Boolean.FALSE; rowObjs[6] = row[0]; rowObjs[7] = attachJoinID; dataRows.add(rowObjs); if (doesExist) { totalFiles++; } firePropertyChange(CNT, 0, (int) ((double) i / (double) totFiles * 100.0)); i++; } AttchTableModel model = new AttchTableModel(dataRows); JTable table = new JTable(model); tableHash.put(tblId, model); tableList.add(table); tableIdList.add(tblId); } } catch (Exception ex) { ex.printStackTrace(); } finally { session.close(); } return null; } @Override protected void done() { UIRegistry.clearSimpleGlassPaneMsg(); if (tableList.size() > 0) { displayBadAttachments(tableList, tableIdList, resultsHashMap, tblTypeHash, tableHash, totalFiles); } super.done(); } }; final SimpleGlassPane glassPane = UIRegistry .writeSimpleGlassPaneMsg("Verifying attachments in the repository...", 24); glassPane.setProgress(0); worker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if (CNT.equals(evt.getPropertyName())) { glassPane.setProgress((Integer) evt.getNewValue()); } } }); worker.execute(); }
From source file:org.isatools.isacreatorconfigurator.configui.FieldInterface.java
/** * Create an DropDownComponent field./* w w w.j a va2s . c om*/ * * @param field - JTextField to be associated with the OntologySelectionTool. * @param allowsMultiple - Should the OntologySelectionTool allow multiple terms to be selected. * @param recommendedOntologySource - A recommended ontology source. * @return DropDownComponent object. */ protected DropDownComponent createOntologyDropDown(final JTextField field, boolean allowsMultiple, Map<String, RecommendedOntology> recommendedOntologySource) { final OntologySelectionTool ost = new OntologySelectionTool(allowsMultiple, false, recommendedOntologySource); ost.createGUI(); final DropDownComponent dropdown = new DropDownComponent(field, ost, DropDownComponent.ONTOLOGY); ost.addPropertyChangeListener("selectedOntology", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { dropdown.hidePopup(ost); String value = evt.getNewValue().toString(); // for this section, we are only storing the term at the minute, not the entire unique id // returned from the ontology lookup tool! value = value.contains(":") ? value.substring(value.indexOf(":") + 1) : value; field.setText(value); } }); ost.addPropertyChangeListener("noSelectedOntology", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { dropdown.hidePopup(ost); } }); return dropdown; }
From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptingDialog.java
/** * Checks if the user can run the script. * @see PropertyChangeListener#propertyChange(PropertyChangeEvent) *//*from www. ja v a2 s . com*/ public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (RowPane.MODIFIED_CONTENT_PROPERTY.equals(name)) canRunScript(); else if (IdentifierParamPane.DISPLAY_INFO_PROPERTY.equals(name)) { displayIdentifierInformation((Point) evt.getNewValue()); } }
From source file:ca.sqlpower.sqlobject.SQLDatabase.java
/** * Listens for changes in DBCS properties, and resets this * SQLDatabase if a critical property (url, driver, username) * changes./* www .j a v a 2s . c om*/ */ public void propertyChange(PropertyChangeEvent e) { String pn = e.getPropertyName(); if ((e.getOldValue() == null && e.getNewValue() != null) || (e.getOldValue() != null && e.getNewValue() == null) || (e.getOldValue() != null && e.getNewValue() != null && !e.getOldValue().equals(e.getNewValue()))) { if ("url".equals(pn) || "driverClass".equals(pn) || "user".equals(pn)) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ reset(); } else if ("name".equals(pn)) { //$NON-NLS-1$ firePropertyChange("shortDisplayName", e.getOldValue(), e.getNewValue()); //$NON-NLS-1$ } } }
From source file:edu.ucla.stat.SOCR.chart.SuperPieChart.java
/** * Creates a panel for the demo (used by SuperDemo.java). * // ww w. j a va 2 s .c o m * @return A panel. */ /* public static JPanel createDemoPanel() { JFreeChart chart = createChart(createDataset()); return new ChartPanel(chart); }*/ public void propertyChange(PropertyChangeEvent e) { String propertyName = e.getPropertyName(); System.out.println("From RegCorrAnal:: propertyName =" + propertyName + "!!!"); if (propertyName.equals("DataUpdate")) { //update the local version of the dataTable by outside source dataTable = (JTable) (e.getNewValue()); dataPanel.removeAll(); dataPanel.add(new JScrollPane(dataTable)); dataTable.doLayout(); System.out.println("From RegCorrAnal:: data UPDATED!!!"); } }
From source file:uk.ac.lkl.cram.ui.ModuleFrame.java
/** * Creates new form ModuleFrame/* w w w . ja va 2 s . com*/ * @param module the module that this window displays * @param file */ public ModuleFrame(final Module module, File file) { this.module = module; this.moduleFile = file; this.setTitle(module.getModuleName()); initComponents(); //Add undo mechanism undoHandler = new UndoHandler(); JMenuItem undoMI = editMenu.add(undoHandler.getUndoAction()); JMenuItem redoMI = editMenu.add(undoHandler.getRedoAction()); //Listen to the undo handler for when there is something to undo undoHandler.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { //We're assuming there's only one property //If the new value is true, then there's something to undo //And thus the save menu item should be enabled Boolean newValue = (Boolean) evt.getNewValue(); if (moduleFile != null) { saveMI.setEnabled(newValue); } } }); editMenu.addSeparator(); //Add cut, copy & paste menu items JMenuItem cutMI = editMenu.add(new JMenuItem(new DefaultEditorKit.CutAction())); cutMI.setText("Cut"); JMenuItem copyMI = editMenu.add(new JMenuItem(new DefaultEditorKit.CopyAction())); copyMI.setText("Copy"); JMenuItem pasteMI = editMenu.add(new JMenuItem(new DefaultEditorKit.PasteAction())); pasteMI.setText("Paste"); //Listen for changes to the shared selection model sharedSelectionModel.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { //Update the menu items modifyLineItemMI.setEnabled(evt.getNewValue() != null); removeLineItemMI.setEnabled(evt.getNewValue() != null); } }); doubleClickListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { //If the user double clicks, then treat this as a shortcut to modify the selected line item if (e.getClickCount() == 2) { modifySelectedLineItem(); } } }; //Set Accelerator keys undoMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); redoMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_Y, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); cutMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); copyMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); pasteMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); newMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); openMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); saveMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); quitMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); //Remove quit menu item and separator from file menu on Mac if (Utilities.isMac()) { fileMenu.remove(quitSeparator); fileMenu.remove(quitMI); } leftTaskPaneContainer.add(createCourseDataPane()); leftTaskPaneContainer.add(createLineItemPane()); leftTaskPaneContainer.add(createTutorHoursPane()); leftTaskPaneContainer.add(createTutorCostPane()); rightTaskPaneContainer.add(createLearningTypeChartPane()); rightTaskPaneContainer.add(createLearningExperienceChartPane()); rightTaskPaneContainer.add(createLearnerFeedbackChartPane()); rightTaskPaneContainer.add(createHoursChartPane()); rightTaskPaneContainer.add(createTotalCostsPane()); }
From source file:org.isatools.isacreator.gui.formelements.SubForm.java
private void removalConfirmation(final FieldTypes whatIsBeingRemoved) { // delete reference to protocol in subform // add one to take into account the model and the initial column which contains fields names. final int selectedItem = scrollTable.getSelectedColumn() + 1; // check to ensure the value isn't 0, if it is, nothing is selected in the table since -1 (value returned by model if // no column is selected + 1 = 0!) if ((selectedItem != 0) && (dataEntryForm != null)) { String displayText;/*from ww w .j a va 2 s . co m*/ if ((whatIsBeingRemoved == FieldTypes.FACTOR) || (whatIsBeingRemoved == FieldTypes.PROTOCOL)) { displayText = "<html>" + "<b>Confirm deletion of " + fieldType + "</b>" + "<p>Deleting this " + fieldType + " will result in all " + fieldType + "s of this type in subsequent assays</p>" + "<p>being deleted too! Do you wish to continue?</p>" + "</html>"; } else { displayText = "<html>" + "<b>Confirm deletion of " + fieldType + "</b>" + "<p>Deleting this " + fieldType + " will result in its complete removal from this experiment annotation!</p>" + "<p>Do you wish to continue?</p>" + "</html>"; } JOptionPane optionPane = new JOptionPane(displayText, JOptionPane.INFORMATION_MESSAGE, JOptionPane.YES_NO_OPTION); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) { int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString()); if (lastOptionAnswer == JOptionPane.YES_OPTION) { removeItem(selectedItem); ApplicationManager.getCurrentApplicationInstance().hideSheet(); } else { // just hide the sheet and cancel further actions! ApplicationManager.getCurrentApplicationInstance().hideSheet(); } } } }); optionPane.setIcon(confirmRemoveColumn); UIHelper.applyOptionPaneBackground(optionPane, UIHelper.BG_COLOR); ApplicationManager.getCurrentApplicationInstance() .showJDialogAsSheet(optionPane.createDialog(this, "Confirm Delete")); } else { removeColumn(selectedItem); } }
From source file:org.company.processmaker.TreeFilesTopComponent.java
public TreeFilesTopComponent() { initComponents();/*from w ww. j a v a2s . com*/ setName(Bundle.CTL_TreeFilesTopComponent()); setToolTipText(Bundle.HINT_TreeFilesTopComponent()); // new codes instance = this; MouseListener ml = new MouseAdapter() { public void mousePressed(MouseEvent e) { int selRow = jTree1.getRowForLocation(e.getX(), e.getY()); TreePath selPath = jTree1.getPathForLocation(e.getX(), e.getY()); if (selRow != -1) { if (e.getClickCount() == 1) { //mySingleClick(selRow, selPath); } else if (e.getClickCount() == 2) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1 .getLastSelectedPathComponent(); if (node == null) { return; } Object nodeInfo = node.getUserObject(); int node_level = node.getLevel(); if (node_level < 2) { return; } // for each dyna form if (node_level == 2) { Global gl_obj = Global.getInstance(); //myDoubleClick(selRow, selPath); conf = Config.getInstance(); DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); String parentName = (String) parent.getUserObject(); // handle triggers if (parentName.equals("Triggers")) { String filePath = ""; for (String[] s : res_trigger) { if (s[0].equals(nodeInfo.toString())) { // get path of dyna in xml forms filePath = conf.tmp + "triggers/" + s[3] + "/" + s[2] + ".php"; break; } } File toAdd = new File(filePath); try { DataObject dObject = DataObject.find(FileUtil.toFileObject(toAdd)); dObject.getLookup().lookup(OpenCookie.class).open(); // dont listen for exist listen files if (existFile(filePath)) { return; } dObject.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (DataObject.PROP_MODIFIED.equals(evt.getPropertyName())) { //fire a dummy event if (!Boolean.TRUE.equals(evt.getNewValue())) { /*String msg = "Saved to" + evt.toString(); NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE); DialogDisplayer.getDefault().notify(nd);*/ TopComponent activeTC = TopComponent.getRegistry() .getActivated(); DataObject dataLookup = activeTC.getLookup() .lookup(DataObject.class); String filePath = FileUtil.toFile(dataLookup.getPrimaryFile()) .getAbsolutePath(); File userFile = new File(filePath); String fileName = userFile.getName(); fileName = fileName.substring(0, fileName.lastIndexOf(".")); try { String content = new String( Files.readAllBytes(Paths.get(filePath))); // remote php tag and info "<?php //don't remove this tag! \n" content = content.substring(6, content.length()); String query = "update triggers set TRI_WEBBOT = '" + StringEscapeUtils.escapeSql(content) + "' where TRI_UID = '" + fileName + "'"; GooglePanel.updateQuery(query); } catch (Exception e) { //Exceptions.printStackTrace(e); String msg = "Can not update trigger"; NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE); DialogDisplayer.getDefault().notify(nd); } } } } }); } catch (DataObjectNotFoundException ex) { //Exceptions.printStackTrace(ex); String msg = "Trigger not found"; NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE); DialogDisplayer.getDefault().notify(nd); } return; } List<String[]> res_dyna = gl_obj.getDyna(); String FileDir = ""; for (String[] s : res_dyna) { if (s[1].equals(nodeInfo.toString())) { // get path of dyna in xml forms FileDir = s[3]; break; } } //String msg = "selRow" + nodeInfo.toString() + "|" + conf.getXmlForms() + FileDir; String filePath = conf.getXmlForms() + FileDir + ".xml"; if (conf.isRemote()) { String[] res = FileDir.split("/"); filePath = conf.get("local_tmp_for_remote") + "/" + FileDir + "/" + res[1] + ".xml"; } File toAdd = new File(filePath); //Result will be null if the user clicked cancel or closed the dialog w/o OK if (toAdd != null) { try { DataObject dObject = DataObject.find(FileUtil.toFileObject(toAdd)); dObject.getLookup().lookup(OpenCookie.class).open(); // dont listen for exist listen files if (existFile(filePath)) { return; } dObject.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (DataObject.PROP_MODIFIED.equals(evt.getPropertyName())) { //fire a dummy event if (!Boolean.TRUE.equals(evt.getNewValue())) { /*String msg = "Saved to" + evt.toString(); NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE); DialogDisplayer.getDefault().notify(nd);*/ TopComponent activeTC = TopComponent.getRegistry() .getActivated(); DataObject dataLookup = activeTC.getLookup() .lookup(DataObject.class); String filePath = FileUtil.toFile(dataLookup.getPrimaryFile()) .getAbsolutePath(); File userFile = new File(filePath); String fileName = userFile.getName(); fileName = fileName.substring(0, fileName.lastIndexOf(".")); Global gl_obj = Global.getInstance(); List<String[]> res_dyna = gl_obj.getDyna(); String FileDir = ""; for (String[] s : res_dyna) { if (filePath.contains(s[0])) { FileDir = s[3]; break; } } if (conf.isRemote()) { boolean res_Upload = SSH.getInstance().uplaodFile(FileDir); if (res_Upload) { String msg = "file upload Successfully!"; NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE); DialogDisplayer.getDefault().notify(nd); } else { String msg = "error in uploading file!"; NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE); DialogDisplayer.getDefault().notify(nd); } } } } } }); } catch (DataObjectNotFoundException ex) { //Exceptions.printStackTrace(ex); String msg = "Can not find xml file"; NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE); DialogDisplayer.getDefault().notify(nd); } } } // for each js file if (node_level == 3) { TreeNode parentInfo = node.getParent(); Global gl_obj = Global.getInstance(); List<String[]> res_dyna = gl_obj.getDyna(); String FileDir = ""; for (String[] s : res_dyna) { if (s[1].equals(parentInfo.toString())) { // get path of dyna in xml forms FileDir = s[3]; break; } } //myDoubleClick(selRow, selPath); conf = Config.getInstance(); String filePath = conf.tmp + "xmlForms/" + FileDir + "/" + nodeInfo.toString() + ".js"; if (conf.isRemote()) { filePath = conf.get("local_tmp_for_remote") + FileDir + "/" + nodeInfo.toString() + ".js"; } File toAdd = new File(filePath); //Result will be null if the user clicked cancel or closed the dialog w/o OK if (toAdd != null) { try { DataObject dObject = DataObject.find(FileUtil.toFileObject(toAdd)); dObject.getLookup().lookup(OpenCookie.class).open(); // dont listen for exist listen files if (existFile(filePath)) { return; } dObject.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (DataObject.PROP_MODIFIED.equals(evt.getPropertyName())) { //fire a dummy event if (!Boolean.TRUE.equals(evt.getNewValue())) { JTextComponent ed = EditorRegistry.lastFocusedComponent(); String jsDoc = ""; try { jsDoc = ed.getText(); } catch (Exception ex) { //Exceptions.printStackTrace(ex); String msg = "Can not get text from editor"; NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE); DialogDisplayer.getDefault().notify(nd); } TopComponent activeTC = TopComponent.getRegistry() .getActivated(); DataObject dataLookup = activeTC.getLookup() .lookup(DataObject.class); String filePath = FileUtil.toFile(dataLookup.getPrimaryFile()) .getAbsolutePath(); File userFile = new File(filePath); String fileName = userFile.getName(); fileName = fileName.substring(0, fileName.lastIndexOf(".")); Global gl_obj = Global.getInstance(); List<String[]> res_dyna = gl_obj.getDyna(); String FileDir = ""; for (String[] s : res_dyna) { if (filePath.contains(s[0])) { FileDir = s[3]; break; } } String fullPath = conf.getXmlForms() + FileDir + ".xml"; if (conf.isRemote()) { String[] res = FileDir.split("/"); fullPath = conf.get("local_tmp_for_remote") + FileDir + "/" + res[1] + ".xml"; } try { DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document mainDoc = builder.parse(fullPath); XPath xPath = XPathFactory.newInstance().newXPath(); Node startDateNode = (Node) xPath .compile("//dynaForm/" + fileName) .evaluate(mainDoc, XPathConstants.NODE); Node cdata = mainDoc.createCDATASection(jsDoc); startDateNode.setTextContent(""); startDateNode.appendChild(cdata); /*String msg = evt.getPropertyName() + "-" + fileName; NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE); DialogDisplayer.getDefault().notify(nd);*/ // write the content into xml file TransformerFactory transformerFactory = TransformerFactory .newInstance(); Transformer transformer = transformerFactory .newTransformer(); DOMSource source = new DOMSource(mainDoc); StreamResult result = new StreamResult(new File(fullPath)); transformer.transform(source, result); if (conf.isRemote()) { boolean res_Upload = SSH.getInstance() .uplaodFile(FileDir); if (res_Upload) { String msg = "file upload Successfully!"; NotifyDescriptor nd = new NotifyDescriptor.Message( msg, NotifyDescriptor.INFORMATION_MESSAGE); DialogDisplayer.getDefault().notify(nd); } else { String msg = "error in uploading file!"; NotifyDescriptor nd = new NotifyDescriptor.Message( msg, NotifyDescriptor.INFORMATION_MESSAGE); DialogDisplayer.getDefault().notify(nd); } } } catch (Exception ex) { //Exceptions.printStackTrace(ex); String msg = "Can not save to xml form"; NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE); DialogDisplayer.getDefault().notify(nd); } } } } }); } catch (DataObjectNotFoundException ex) { //Exceptions.printStackTrace(ex); String msg = "Can not save to xml form"; NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE); DialogDisplayer.getDefault().notify(nd); } } } } } } }; jTree1.addMouseListener(ml); jTree1.setModel(null); }