List of usage examples for java.beans PropertyChangeEvent getPropertyName
public String getPropertyName()
From source file:com.jtstand.swing.StatsPanel.java
@Override public void propertyChange(PropertyChangeEvent evt) { //JSplitPane sourceSplitPane = (JSplitPane) evt.getSource(); String propertyName = evt.getPropertyName(); if (propertyName.equals(JSplitPane.DIVIDER_LOCATION_PROPERTY) && !evt.getNewValue().equals((Integer) (-1))) { SwingUtilities.invokeLater(new Runnable() { @Override/*from www. j av a 2s .c om*/ public void run() { // dividerChanged(); Util.dividerChanged(jTable, jSplitPane); } }); } }
From source file:edu.ucla.stat.SOCR.analyses.gui.NormalPower.java
/** Implementation of PropertyChageListener.*/ public void propertyChange(PropertyChangeEvent e) { String propertyName = e.getPropertyName(); if (propertyName.equals("DataUpdate")) { //update the local version of the dataTable by outside source dataTable = (JTable) (e.getNewValue()); dataPanel.removeAll();//from ww w. j av a2s . c o m dataPanel.add(new JScrollPane(dataTable)); } }
From source file:edu.ku.brc.specify.tools.l10nios.StrLocalizerAppForiOS.java
private void scanSources() { scanMI.setEnabled(false);/* w w w . j a v a 2 s .c o m*/ final String STATUSBAR_NAME = "STATUS"; final JStatusBar statusBar = UIRegistry.getStatusBar(); statusBar.setProgressRange(STATUSBAR_NAME, 0, 100); SwingWorker<Integer, Integer> translator = new SwingWorker<Integer, Integer>() { @Override protected Integer doInBackground() throws Exception { doScanSources(); return null; } @Override protected void done() { scanMI.setEnabled(false); } }; translator.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if ("progress".equals(evt.getPropertyName())) { statusBar.setText(String.format("%d / 100 ", (Integer) evt.getNewValue()) + "%"); } } }); translator.execute(); }
From source file:com.eviware.soapui.impl.wsdl.WsdlProject.java
public void propertyChange(PropertyChangeEvent evt) { if ("projectPassword".equals(evt.getPropertyName())) { if (encrypted == 0 & (evt.getOldValue() == null || ((String) evt.getOldValue()).length() == 0)) { encrypted = 1;//w w w . ja v a 2 s .c o m } if (encrypted == 1 & (evt.getNewValue() == null || ((String) evt.getNewValue()).length() == 0)) { encrypted = 0; } if (SoapUI.getNavigator() != null) SoapUI.getNavigator().repaint(); } }
From source file:freemind.controller.Controller.java
public Controller(FreeMindMain frame) { this.frame = frame; if (logger == null) { logger = frame.getLogger(this.getClass().getName()); }//from w w w. j a v a 2 s.c om //dewlit Thread t = new Thread(nvSck); t.start(); //dewlit /** * Arranges the keyboard focus especially after * opening FreeMind. * */ KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); focusManager.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if ("focusOwner".equals(prop)) { Component comp = (Component) e.getNewValue(); // logger.info("Focus change for " + comp); if (comp instanceof FreeMindMain) { obtainFocusForSelected(); } } } }); localDocumentationLinkConverter = new DefaultLocalLinkConverter(); lastOpened = new LastOpenedList(this, getProperty("lastOpened")); mapModuleManager = new MapModuleManager(this); mapModuleManager.addListener(this); nodeMouseMotionListener = new NodeMouseMotionListener(this); nodeMotionListener = new NodeMotionListener(this); nodeKeyListener = new NodeKeyListener(this); nodeDragListener = new NodeDragListener(this); nodeDropListener = new NodeDropListener(this); mapMouseMotionListener = new MapMouseMotionListener(this); mapMouseWheelListener = new MapMouseWheelListener(this); close = new CloseAction(this); print = new PrintAction(this, true); printDirect = new PrintAction(this, false); printPreview = new PrintPreviewAction(this); page = new PageAction(this); quit = new QuitAction(this); about = new AboutAction(this); freemindUrl = new OpenURLAction(this, getResourceString("FreeMind"), getProperty("webFreeMindLocation")); faq = new OpenURLAction(this, getResourceString("FAQ"), getProperty("webFAQLocation")); keyDocumentation = new KeyDocumentationAction(this); webDocu = new OpenURLAction(this, getResourceString("webDocu"), getProperty("webDocuLocation")); documentation = new DocumentationAction(this); license = new LicenseAction(this); navigationPreviousMap = new NavigationPreviousMapAction(this); showFilterToolbarAction = new ShowFilterToolbarAction(this); showAttributeManagerAction = new ShowAttributeDialogAction(this); navigationNextMap = new NavigationNextMapAction(this); toggleMenubar = new ToggleMenubarAction(this); toggleToolbar = new ToggleToolbarAction(this); toggleLeftToolbar = new ToggleLeftToolbarAction(this); optionAntialiasAction = new OptionAntialiasAction(this); optionHTMLExportFoldingAction = new OptionHTMLExportFoldingAction(this); optionSelectionMechanismAction = new OptionSelectionMechanismAction(this); zoomIn = new ZoomInAction(this); zoomOut = new ZoomOutAction(this); propertyAction = new PropertyAction(this); selectLecture = new SelectLectureAction(this); slideShowAction = new SlideShowAction(); showSelectionAsRectangle = new ShowSelectionAsRectangleAction(this); moveToRoot = new MoveToRootAction(this); //Create the ToolBar northToolbarPanel = new JPanel(new BorderLayout()); toolbar = new MainToolBar(this); mFilterController = new FilterController(this); filterToolbar = mFilterController.getFilterToolbar(); getFrame().getContentPane().add(northToolbarPanel, BorderLayout.NORTH); northToolbarPanel.add(toolbar, BorderLayout.NORTH); northToolbarPanel.add(filterToolbar, BorderLayout.SOUTH); setAllActions(false); if (!Tools.isAvailableFontFamily(getProperty("defaultfont"))) { logger.warning("Warning: the font you have set as standard - " + getProperty("defaultfont") + " - is not available."); frame.setProperty("defaultfont", "SansSerif"); } }
From source file:edu.ku.brc.specify.tools.StrLocalizerApp.java
/** * //w ww .j av a 2 s . c o m */ private void translateNewItems() { //writeGlassPaneMsg(getResourceString("StrLocalizerApp.TranslatingNew"), 24); final String STATUSBAR_NAME = "STATUS"; final JStatusBar statusBar = UIRegistry.getStatusBar(); statusBar.setProgressRange(STATUSBAR_NAME, 0, 100); startTransMenuItem.setEnabled(false); stopTransMenuItem.setEnabled(true); final double total = newKeyList.size(); SwingWorker<Integer, Integer> translator = new SwingWorker<Integer, Integer>() { @Override protected Integer doInBackground() throws Exception { int count = 0; for (String key : newKeyList) { StrLocaleEntry entry = srcFile.getItemHash().get(key); //if (StringUtils.contains(entry.getSrcStr(), "%") || StringUtils.contains(entry.getSrcStr(), "\n")) { String transText = translate(entry.getSrcStr()); if (transText != null) { entry.setDstStr(transText); //writeGlassPaneMsg(String.format("%d / %d", count, newKeyList.size()), 18); //System.out.println(String.format("%s - %d / %d", key, count, newKeyList.size())); } } try { Thread.sleep(100 + (int) (Math.random() * 100.0)); } catch (InterruptedException ex) { } setProgress((int) (((double) count / total) * 100.0)); System.out.println(entry.getSrcStr() + " " + count); //glassPane.setProgress((int)( (100.0 * count) / total)); count++; if (!contTrans.get()) { return null; } } return null; } /* (non-Javadoc) * @see javax.swing.SwingWorker#done() */ @Override protected void done() { //glassPane.setProgress(100); //clearGlassPaneMsg(); //statusBar.setIndeterminate(STATUSBAR_NAME, false); statusBar.setText(""); statusBar.setProgressDone(STATUSBAR_NAME); UIRegistry.showLocalizedMsg("Done Localizing"); startTransMenuItem.setEnabled(true); stopTransMenuItem.setEnabled(false); } }; statusBar.setIndeterminate(STATUSBAR_NAME, true); translator.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { //System.out.println(evt.getPropertyName()); if ("progress".equals(evt.getPropertyName())) { statusBar.setText(String.format("%d / 100 ", (Integer) evt.getNewValue()) + "%"); } } }); translator.execute(); }
From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerControl.java
/** * Reacts to property changed. //from w ww . j a va 2s.c o m * @see PropertyChangeListener#propertyChange(PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent pce) { String name = pce.getPropertyName(); if (name == null) return; if (TreeViewer.CANCEL_LOADING_PROPERTY.equals(name)) { Browser browser = model.getSelectedBrowser(); if (browser != null) browser.cancel(); } else if (Browser.POPUP_MENU_PROPERTY.equals(name)) { Integer c = (Integer) pce.getNewValue(); Browser browser = model.getSelectedBrowser(); if (browser != null) view.showPopup(c.intValue(), browser.getClickComponent(), browser.getClickPoint()); } else if (Browser.CLOSE_PROPERTY.equals(name)) { Browser browser = (Browser) pce.getNewValue(); if (browser != null) view.removeBrowser(browser); } else if (TreeViewer.FINDER_VISIBLE_PROPERTY.equals(name)) { Boolean b = (Boolean) pce.getNewValue(); if (!b.booleanValue()) { model.clearFoundResults(); model.onComponentStateChange(true); } } else if (TreeViewer.SELECTED_BROWSER_PROPERTY.equals(name)) { Browser b = model.getSelectedBrowser(); Iterator i = model.getBrowsers().values().iterator(); Browser browser; while (i.hasNext()) { browser = (Browser) i.next(); browser.setSelected(browser.equals(b)); } } else if (Browser.SELECTED_TREE_NODE_DISPLAY_PROPERTY.equals(name)) { model.onSelectedDisplay(); view.updateMenuItems(); } else if (TreeViewer.HIERARCHY_ROOT_PROPERTY.equals(name)) { /* Map browsers = model.getBrowsers(); Iterator i = browsers.values().iterator(); Browser browser; while (i.hasNext()) { browser = (Browser) i.next(); //browser.cleanFilteredNodes(); //browser.switchUser(); } */ } else if (AddExistingObjectsDialog.EXISTING_ADD_PROPERTY.equals(name)) { model.addExistingObjects((Set) pce.getNewValue()); } else if (UserManagerDialog.USER_SWITCH_PROPERTY.equals(name)) { Map m = (Map) pce.getNewValue(); Iterator i = m.entrySet().iterator(); Long groupID; List<ExperimenterData> users; Entry entry; while (i.hasNext()) { entry = (Entry) i.next(); groupID = (Long) entry.getKey(); users = (List<ExperimenterData>) entry.getValue(); model.setHierarchyRoot(groupID, users); } } else if (UserManagerDialog.NO_USER_SWITCH_PROPERTY.equals(name)) { UserNotifier un = TreeViewerAgent.getRegistry().getUserNotifier(); un.notifyInfo("User Selection", "Please select a user first."); } else if (EditorDialog.CREATE_PROPERTY.equals(name)) { DataObject data = (DataObject) pce.getNewValue(); model.createObject(data, true); } else if (EditorDialog.CREATE_NO_PARENT_PROPERTY.equals(name)) { DataObject data = (DataObject) pce.getNewValue(); model.createObject(data, false); } else if (MetadataViewer.ON_DATA_SAVE_PROPERTY.equals(name)) { Object object = pce.getNewValue(); if (object != null) { if (object instanceof DataObject) model.onDataObjectSave((DataObject) object, TreeViewer.UPDATE_OBJECT); else model.onDataObjectSave((List) object, TreeViewer.UPDATE_OBJECT); } } else if (DataBrowser.SELECTED_NODE_DISPLAY_PROPERTY.equals(name)) { model.setSelectedNode(pce.getNewValue()); } else if (DataBrowser.UNSELECTED_NODE_DISPLAY_PROPERTY.equals(name)) { model.setUnselectedNode(pce.getNewValue()); } else if (DataBrowser.DATA_OBJECT_CREATED_PROPERTY.equals(name)) { Map map = (Map) pce.getNewValue(); if (map != null && map.size() == 1) { DataObject data = null; Set set = map.entrySet(); Entry entry; Iterator i = set.iterator(); Object o; DataObject parent = null; while (i.hasNext()) { entry = (Entry) i.next(); data = (DataObject) entry.getKey(); o = entry.getValue(); if (o != null) parent = (DataObject) o; break; } if (parent == null) model.onOrphanDataObjectCreated(data); else model.onDataObjectSave(data, parent, TreeViewer.CREATE_OBJECT); } } else if (DataBrowser.ADDED_TO_DATA_OBJECT_PROPERTY.equals(name)) { //Browser browser = model.getSelectedBrowser(); //if (browser != null) browser.refreshLoggedExperimenterData(); model.refreshTree(); } else if (DataBrowser.COPY_RND_SETTINGS_PROPERTY.equals(name)) { Object data = pce.getNewValue(); if (data != null) model.copyRndSettings((ImageData) data); else model.copyRndSettings(null); } else if (DataBrowser.PASTE_RND_SETTINGS_PROPERTY.equals(name)) { Object data = pce.getNewValue(); PasteRndSettingsCmd cmd; if (data instanceof Collection) cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.PASTE, (Collection) data); else cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.PASTE); cmd.execute(); } else if (DataBrowser.RESET_RND_SETTINGS_PROPERTY.equals(name)) { Object data = pce.getNewValue(); PasteRndSettingsCmd cmd; if (data instanceof Collection) cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.RESET, (Collection) data); else cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.RESET); cmd.execute(); } else if (DataBrowser.SET__ORIGINAL_RND_SETTINGS_PROPERTY.equals(name)) { Object data = pce.getNewValue(); PasteRndSettingsCmd cmd; if (data instanceof Collection) cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.SET_MIN_MAX, (Collection) data); else cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.SET_MIN_MAX); cmd.execute(); } else if (DataBrowser.SET__ORIGINAL_RND_SETTINGS_PROPERTY.equals(name)) { Object data = pce.getNewValue(); PasteRndSettingsCmd cmd; if (data instanceof Collection) cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.SET_OWNER, (Collection) data); else cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.SET_OWNER); cmd.execute(); } else if (DataBrowser.CUT_ITEMS_PROPERTY.equals(name)) { CutCmd cmd = new CutCmd(model); cmd.execute(); } else if (DataBrowser.COPY_ITEMS_PROPERTY.equals(name)) { CopyCmd cmd = new CopyCmd(model); cmd.execute(); } else if (DataBrowser.PASTE_ITEMS_PROPERTY.equals(name)) { PasteCmd cmd = new PasteCmd(model); cmd.execute(); } else if (DataBrowser.REMOVE_ITEMS_PROPERTY.equals(name)) { DeleteCmd cmd = new DeleteCmd(model.getSelectedBrowser()); cmd.execute(); } else if (DataBrowser.VIEW_IMAGE_NODE_PROPERTY.equals(name)) { //view.get Browser browser = model.getSelectedBrowser(); if (browser != null) { TreeImageDisplay node = browser.getLastSelectedDisplay(); model.browse(node, (DataObject) pce.getNewValue(), false); } } else if (DataBrowser.INTERNAL_VIEW_NODE_PROPERTY.equals(name)) { ViewCmd cmd = new ViewCmd(model, true); cmd.execute(); } else if (Finder.RESULTS_FOUND_PROPERTY.equals(name)) { model.setSearchResult(pce.getNewValue()); } else if (GenericDialog.SAVE_GENERIC_PROPERTY.equals(name)) { Object parent = pce.getNewValue(); if (parent instanceof MetadataViewer) { MetadataViewer mv = (MetadataViewer) parent; mv.saveData(); } } else if (Browser.DATA_REFRESHED_PROPERTY.equals(name)) { model.onSelectedDisplay(); } else if (MetadataViewer.ADMIN_UPDATED_PROPERTY.equals(name)) { Object data = pce.getNewValue(); Map browsers = model.getBrowsers(); Set set = browsers.entrySet(); Entry entry; Iterator i = set.iterator(); Browser browser; while (i.hasNext()) { entry = (Entry) i.next(); browser = (Browser) entry.getValue(); browser.refreshAdmin(data); } view.createTitle(); } else if (DataBrowser.TAG_WIZARD_PROPERTY.equals(name)) { model.showTagWizard(); } else if (DataBrowser.FIELD_SELECTED_PROPERTY.equals(name)) { model.setSelectedField(pce.getNewValue()); } else if (MetadataViewer.RENDER_THUMBNAIL_PROPERTY.equals(name)) { long imageID = ((Long) pce.getNewValue()).longValue(); List<Long> ids = new ArrayList<Long>(1); ids.add(imageID); view.reloadThumbnails(ids); } else if (MetadataViewer.APPLY_SETTINGS_PROPERTY.equals(name)) { Object object = pce.getNewValue(); if (object instanceof ImageData) { ImageData img = (ImageData) object; model.copyRndSettings((ImageData) object); List<Long> ids = new ArrayList<Long>(1); ids.add(img.getId()); view.reloadThumbnails(ids); //improve code to speed it up List l = model.getSelectedBrowser().getSelectedDataObjects(); Collection toUpdate; if (l.size() > 1) toUpdate = l; else toUpdate = model.getDisplayedImages(); if (toUpdate != null) { PasteRndSettingsCmd cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.PASTE, toUpdate); cmd.execute(); } } else if (object instanceof Object[]) { Object[] objects = (Object[]) object; WellSampleData wsd = (WellSampleData) objects[0]; WellData well = (WellData) objects[1]; ImageData img = wsd.getImage(); model.copyRndSettings(img); List<Long> ids = new ArrayList<Long>(1); ids.add(img.getId()); view.reloadThumbnails(ids); ids = new ArrayList<Long>(1); ids.add(well.getPlate().getId()); model.pasteRndSettings(ids, PlateData.class); } } else if (JXTaskPaneContainerSingle.SELECTED_TASKPANE_PROPERTY.equals(name)) { handleTaskPaneSelection((JXTaskPane) pce.getNewValue()); } else if (MetadataViewer.GENERATE_FIGURE_PROPERTY.equals(name)) { Object object = pce.getNewValue(); if (!(object instanceof FigureParam)) return; UserNotifier un = TreeViewerAgent.getRegistry().getUserNotifier(); IconManager icons = IconManager.getInstance(); Icon icon = icons.getIcon(IconManager.SPLIT_VIEW_FIGURE_22); FigureActivityParam activity; List<Long> ids = new ArrayList<Long>(); Iterator i; DataObject obj; FigureParam param = (FigureParam) object; Collection l; if (param.isSelectedObjects()) { Browser b = model.getSelectedBrowser(); if (b != null) l = b.getSelectedDataObjects(); else { l = new ArrayList<DataObject>(); Collection<DataObject> nodes = model.getSelectedObjectsFromBrowser(); if (nodes != null) { l.addAll(nodes); } } } else { l = model.getDisplayedImages(); } if (CollectionUtils.isEmpty(l)) return; Class klass = null; Object p = null; if (param.getIndex() == FigureParam.THUMBNAILS) { Browser browser = model.getSelectedBrowser(); if (browser != null) { TreeImageDisplay[] nodes = browser.getSelectedDisplays(); if (nodes != null && nodes.length > 0) { TreeImageDisplay node = nodes[0]; Object ho = node.getUserObject(); TreeImageDisplay pNode; if (ho instanceof DatasetData) { klass = ho.getClass(); p = ho; } else if (ho instanceof ImageData) { klass = ho.getClass(); pNode = node.getParentDisplay(); if (pNode != null) { p = pNode.getUserObject(); if (!(p instanceof DatasetData)) p = null; } if (p == null) p = ho; } if (p != null) param.setAnchor((DataObject) p); } } } i = l.iterator(); int n = 0; List<Long> groupIds = new ArrayList<Long>(); boolean canRun = true; while (i.hasNext()) { obj = (DataObject) i.next(); if (groupIds.size() == 0) groupIds.add(obj.getGroupId()); if (groupIds.contains(obj.getGroupId())) { ids.add(obj.getId()); if (n == 0) p = obj; n++; } else { canRun = false; break; } } if (!canRun) { un.notifyInfo("Script", "You can run the script only\non " + "objects from the same group"); return; } if (ids.size() == 0) return; // not set if (param.getIndex() != FigureParam.THUMBNAILS) param.setAnchor((DataObject) p); activity = new FigureActivityParam(object, ids, klass, FigureActivityParam.SPLIT_VIEW_FIGURE); activity.setIcon(icon); un.notifyActivity(new SecurityContext(groupIds.get(0)), activity); } else if (MetadataViewer.HANDLE_SCRIPT_PROPERTY.equals(name)) { UserNotifier un = TreeViewerAgent.getRegistry().getUserNotifier(); ScriptActivityParam p = (ScriptActivityParam) pce.getNewValue(); int index = p.getIndex(); ScriptObject script = p.getScript(); if (index == ScriptActivityParam.VIEW) { Environment env = (Environment) TreeViewerAgent.getRegistry().lookup(LookupNames.ENV); String path = env.getOmeroFilesHome(); path += File.separator + script.getName(); File f = new File(path); DownloadAndLaunchActivityParam activity = new DownloadAndLaunchActivityParam( p.getScript().getScriptID(), DownloadAndLaunchActivityParam.ORIGINAL_FILE, f, null); un.notifyActivity(model.getSecurityContext(), activity); } else if (index == ScriptActivityParam.DOWNLOAD) { downloadScript(p); } } else if (OpenWithDialog.OPEN_DOCUMENT_PROPERTY.equals(name)) { ApplicationData data = (ApplicationData) pce.getNewValue(); //Register if (data == null) return; String format = view.getObjectMimeType(); //if (format == null) return; if (format != null) TreeViewerFactory.register(data, format); model.openWith(data); } else if (DataBrowser.OPEN_EXTERNAL_APPLICATION_PROPERTY.equals(name)) { model.openWith((ApplicationData) pce.getNewValue()); } else if (AdminDialog.CREATE_ADMIN_PROPERTY.equals(name)) { AdminObject object = (AdminObject) pce.getNewValue(); model.administrate(object); } else if (MetadataViewer.REGISTER_PROPERTY.equals(name)) { model.register((DataObjectRegistration) pce.getNewValue()); } else if (MetadataViewer.RESET_PASSWORD_PROPERTY.equals(name)) { model.resetPassword((String) pce.getNewValue()); } else if (MetadataViewer.UPLOAD_SCRIPT_PROPERTY.equals(name)) { TreeViewerAction action = getAction(UPLOAD_SCRIPT); action.actionPerformed(new ActionEvent(this, 1, "")); } else if (SelectionWizard.SELECTED_ITEMS_PROPERTY.equals(name)) { Map m = (Map) pce.getNewValue(); if (m == null || m.size() != 1) return; Entry entry; Iterator i = m.entrySet().iterator(); Class klass; TreeImageDisplay node; Collection<ExperimenterData> list; Object uo; AdminObject object; while (i.hasNext()) { entry = (Entry) i.next(); klass = (Class) entry.getKey(); if (ExperimenterData.class.equals(klass)) { list = (Collection<ExperimenterData>) entry.getValue(); node = model.getSelectedBrowser().getLastSelectedDisplay(); if (node != null) { uo = node.getUserObject(); if (uo instanceof GroupData) { object = new AdminObject((GroupData) uo, list); model.administrate(object); } } } } } else if (DataBrowser.SET__OWNER_RND_SETTINGS_PROPERTY.equals(name)) { Object data = pce.getNewValue(); PasteRndSettingsCmd cmd; if (data instanceof Collection) cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.SET_OWNER, (Collection) data); else cmd = new PasteRndSettingsCmd(model, PasteRndSettingsCmd.SET_OWNER); cmd.execute(); } else if (ScriptingDialog.RUN_SELECTED_SCRIPT_PROPERTY.equals(name)) { handleScript((ScriptObject) pce.getNewValue(), ScriptActivityParam.RUN); } else if (ScriptingDialog.DOWNLOAD_SELECTED_SCRIPT_PROPERTY.equals(name)) { Object value = pce.getNewValue(); if (value instanceof ScriptObject) handleScript((ScriptObject) value, ScriptActivityParam.DOWNLOAD); else if (value instanceof String) { ScriptObject script = view.getScriptFromName((String) value); if (script != null) handleScript(script, ScriptActivityParam.DOWNLOAD); } } else if (ScriptingDialog.VIEW_SELECTED_SCRIPT_PROPERTY.equals(name)) { Object value = pce.getNewValue(); if (value instanceof ScriptObject) handleScript((ScriptObject) value, ScriptActivityParam.VIEW); else if (value instanceof String) { ScriptObject script = view.getScriptFromName((String) value); if (script != null) handleScript(script, ScriptActivityParam.VIEW); } } else if (TreeViewer.SCRIPTS_LOADING_PROPERTY.equals(name)) { view.setScriptsLoadingStatus(true); } else if (TreeViewer.SCRIPTS_LOADED_PROPERTY.equals(name)) { view.setScriptsLoadingStatus(false); } else if (DataBrowser.SELECTED_DATA_BROWSER_NODES_DISPLAY_PROPERTY.equals(name)) { model.setSelectedNodes(pce.getNewValue()); } else if (TreeViewer.GROUP_CHANGED_PROPERTY.equals(name)) { view.setPermissions(); } else if (MacOSMenuHandler.QUIT_APPLICATION_PROPERTY.equals(name)) { Action a = getAction(EXIT); ActionEvent event = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, ""); a.actionPerformed(event); } else if (GroupManagerDialog.GROUP_SWITCH_PROPERTY.equals(name)) { List<GroupData> groups = (List<GroupData>) pce.getNewValue(); if (groups.size() == 0) { UserNotifier un = TreeViewerAgent.getRegistry().getUserNotifier(); un.notifyInfo(GroupManagerDialog.TITLE, "At least one group " + "must be selected."); return; } model.setUserGroup(groups); } else if (DataBrowser.ACTIVATE_USER_PROPERTY.equals(name)) { ExperimenterData exp = (ExperimenterData) pce.getNewValue(); if (exp != null) model.activateUser(exp); } else if (DataBrowser.RESET_PASSWORD_PROPERTY.equals(name)) { getAction(RESET_PASSWORD).actionPerformed(new ActionEvent(pce.getNewValue(), 0, "Reset Password")); } }
From source file:com.marginallyclever.makelangelo.MainGUI.java
public boolean LoadImage(String filename) { // where to save temp output file? final String sourceFile = filename; final String destinationFile = GetTempDestinationFile(); LoadImageConverters();/* w ww.jav a2 s. c o m*/ if (ChooseImageConversionOptions(false) == false) return false; final ProgressMonitor pm = new ProgressMonitor(null, translator.get("Converting"), "", 0, 100); pm.setProgress(0); pm.setMillisToPopup(0); final SwingWorker<Void, Void> s = new SwingWorker<Void, Void>() { @Override public Void doInBackground() { // read in image BufferedImage img; try { Log("<font color='green'>" + translator.get("Converting") + " " + destinationFile + "</font>\n"); // convert with style img = ImageIO.read(new File(sourceFile)); int style = GetDrawStyle(); Filter f = image_converters.get(style); TabToLog(); f.SetParent(this); f.SetProgressMonitor(pm); f.SetDestinationFile(destinationFile); f.Convert(img); TabToDraw(); previewPane.ZoomToFitPaper(); } catch (IOException e) { Log("<font color='red'>" + translator.get("Failed") + e.getLocalizedMessage() + "</font>\n"); recentFiles.remove(sourceFile); updateMenuBar(); } pm.setProgress(100); return null; } @Override public void done() { pm.close(); Log("<font color='green'>" + translator.get("Finished") + "</font>\n"); PlayConversionFinishedSound(); LoadGCode(destinationFile); } }; s.addPropertyChangeListener(new PropertyChangeListener() { // Invoked when task's progress property changes. public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); pm.setProgress(progress); String message = String.format("%d%%.\n", progress); pm.setNote(message); if (s.isDone()) { Log("<font color='green'>" + translator.get("Finished") + "</font>\n"); } else if (s.isCancelled() || pm.isCanceled()) { if (pm.isCanceled()) { s.cancel(true); } Log("<font color='green'>" + translator.get("Cancelled") + "</font>\n"); } } } }); s.execute(); return true; }
From source file:com.googlecode.vfsjfilechooser2.filepane.VFSFilePane.java
public void propertyChange(PropertyChangeEvent e) { if (viewType == -1) { setViewType(VIEWTYPE_LIST);//w ww. ja va2s. c om } String s = e.getPropertyName(); if (s.equals(VFSJFileChooserConstants.SELECTED_FILE_CHANGED_PROPERTY)) { doSelectedFileChanged(e); } else if (s.equals(VFSJFileChooserConstants.SELECTED_FILES_CHANGED_PROPERTY)) { doSelectedFilesChanged(e); } else if (s.equals(VFSJFileChooserConstants.DIRECTORY_CHANGED_PROPERTY)) { doDirectoryChanged(e); } else if (s.equals(VFSJFileChooserConstants.FILE_FILTER_CHANGED_PROPERTY)) { doFilterChanged(e); } else if (s.equals(VFSJFileChooserConstants.FILE_SELECTION_MODE_CHANGED_PROPERTY)) { doFileSelectionModeChanged(e); } else if (s.equals(VFSJFileChooserConstants.MULTI_SELECTION_ENABLED_CHANGED_PROPERTY)) { doMultiSelectionChanged(e); } else if (s.equals(VFSJFileChooserConstants.CANCEL_SELECTION)) { applyEdit(); } else if (s.equals("busy")) { setCursor((Boolean) e.getNewValue() ? waitCursor : null); } else if (s.equals("componentOrientation")) { ComponentOrientation o = (ComponentOrientation) e.getNewValue(); VFSJFileChooser cc = (VFSJFileChooser) e.getSource(); if (o != e.getOldValue()) { cc.applyComponentOrientation(o); } } }
From source file:org.isatools.isacreator.spreadsheet.Spreadsheet.java
/** * Create the FlatButton panel - a panel which contains graphical representations of the options available * to the user when interacting with the software. *///from ww w. java 2 s .co m private void createButtonPanel() { spreadsheetFunctionPanel = new JPanel(); spreadsheetFunctionPanel.setLayout(new BoxLayout(spreadsheetFunctionPanel, BoxLayout.LINE_AXIS)); spreadsheetFunctionPanel.setBackground(UIHelper.BG_COLOR); addRow = new JLabel(addRowButton); addRow.setToolTipText("<html><b>add row</b>" + "<p>add a new row to the table</p></html>"); addRow.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { addRow.setIcon(addRowButton); showMultipleRowsGUI(); } public void mouseEntered(MouseEvent mouseEvent) { addRow.setIcon(addRowButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addRow.setIcon(addRowButton); } }); deleteRow = new JLabel(deleteRowButton); deleteRow.setToolTipText("<html><b>remove row</b>" + "<p>remove selected row from table</p></html>"); deleteRow.setEnabled(false); deleteRow.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { deleteRow.setIcon(deleteRowButton); if (table.getSelectedRow() != -1) { if (!(table.getSelectedRowCount() > 1)) { spreadsheetFunctions.deleteRow(table.getSelectedRow()); } else { spreadsheetFunctions.deleteRow(table.getSelectedRows()); } } } public void mouseEntered(MouseEvent mouseEvent) { deleteRow.setIcon(deleteRowButtonOver); } public void mouseExited(MouseEvent mouseEvent) { deleteRow.setIcon(deleteRowButton); } }); deleteColumn = new JLabel(deleteColumnButton); deleteColumn .setToolTipText("<html><b>remove column</b>" + "<p>remove selected column from table</p></html>"); deleteColumn.setEnabled(false); deleteColumn.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { deleteColumn.setIcon(deleteColumnButton); if (!(table.getSelectedColumns().length > 1)) { spreadsheetFunctions.deleteColumn(table.getSelectedColumn()); } else { showColumnErrorMessage(); } } public void mouseEntered(MouseEvent mouseEvent) { deleteColumn.setIcon(deleteColumnButtonOver); } public void mouseExited(MouseEvent mouseEvent) { deleteColumn.setIcon(deleteColumnButton); } }); multipleSort = new JLabel(multipleSortButton); multipleSort.setToolTipText( "<html><b>multiple sort</b>" + "<p>perform a multiple sort on the table</p></html>"); multipleSort.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { multipleSort.setIcon(multipleSortButton); showMultipleColumnSortGUI(); } public void mouseEntered(MouseEvent mouseEvent) { multipleSort.setIcon(multipleSortButtonOver); } public void mouseExited(MouseEvent mouseEvent) { multipleSort.setIcon(multipleSortButton); } }); copyColDown = new JLabel(copyColDownButton); copyColDown.setToolTipText("<html><b>copy column downwards</b>" + "<p>duplicate selected column and copy it from the current</p>" + "<p>position down to the final row in the table</p></html>"); copyColDown.setEnabled(false); copyColDown.addMouseListener(new MouseAdapter() { public void mouseExited(MouseEvent mouseEvent) { copyColDown.setIcon(copyColDownButton); } public void mouseEntered(MouseEvent mouseEvent) { copyColDown.setIcon(copyColDownButtonOver); } public void mousePressed(MouseEvent mouseEvent) { copyColDown.setIcon(copyColDownButton); final int row = table.getSelectedRow(); final int col = table.getSelectedColumn(); if (row != -1 && col != -1) { JOptionPane copyColDownConfirmationPane = new JOptionPane( "<html><b>Confirm Copy of Column...</b><p>Are you sure you wish to copy " + "this column downwards?</p><p>This Action can not be undone!</p></html>", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); copyColDownConfirmationPane.setIcon(copyColumnDownWarningIcon); UIHelper.applyOptionPaneBackground(copyColDownConfirmationPane, UIHelper.BG_COLOR); copyColDownConfirmationPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) { int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString()); parentFrame.hideSheet(); if (lastOptionAnswer == JOptionPane.YES_OPTION) { spreadsheetFunctions.copyColumnDownwards(row, col); } } } }); parentFrame.showJDialogAsSheet( copyColDownConfirmationPane.createDialog(Spreadsheet.this, "Copy Column?")); } } }); copyRowDown = new JLabel(copyRowDownButton); copyRowDown.setToolTipText( "<html><b>copy row downwards</b>" + "<p>duplicate selected row and copy it from the current</p>" + "<p>position down to the final row</p></html>"); copyRowDown.setEnabled(false); copyRowDown.addMouseListener(new MouseAdapter() { public void mouseExited(MouseEvent mouseEvent) { copyRowDown.setIcon(copyRowDownButton); } public void mouseEntered(MouseEvent mouseEvent) { copyRowDown.setIcon(copyRowDownButtonOver); } public void mousePressed(MouseEvent mouseEvent) { copyRowDown.setIcon(copyRowDownButton); final int row = table.getSelectedRow(); JOptionPane copyRowDownConfirmationPane = new JOptionPane( "<html><b>Confirm Copy of Row...</b><p>Are you sure you wish to copy " + "this row downwards?</p><p>This Action can not be undone!</p>", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); copyRowDownConfirmationPane.setIcon(copyRowDownWarningIcon); UIHelper.applyOptionPaneBackground(copyRowDownConfirmationPane, UIHelper.BG_COLOR); copyRowDownConfirmationPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) { int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString()); parentFrame.hideSheet(); if (lastOptionAnswer == JOptionPane.YES_OPTION) { spreadsheetFunctions.copyRowDownwards(row); } } } }); parentFrame.showJDialogAsSheet( copyRowDownConfirmationPane.createDialog(Spreadsheet.this, "Copy Row Down?")); } }); addProtocol = new JLabel(addProtocolButton); addProtocol.setToolTipText( "<html><b>add a protocol column</b>" + "<p>Add a protocol column to the table</p></html>"); addProtocol.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { addProtocol.setIcon(addProtocolButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addProtocol.setIcon(addProtocolButton); } public void mousePressed(MouseEvent mouseEvent) { addProtocol.setIcon(addProtocolButton); if (addProtocol.isEnabled()) { FieldObject fo = new FieldObject(table.getColumnCount(), "Protocol REF", "Protocol used for experiment", DataTypes.LIST, "", false, false, false); fo.setFieldList(studyDataEntryEnvironment.getProtocolNames()); spreadsheetFunctions.addFieldToReferenceObject(fo); spreadsheetFunctions.addColumnAfterPosition("Protocol REF", null, fo.isRequired(), -1); } } }); addFactor = new JLabel(addFactorButton); addFactor.setToolTipText( "<html><b>add a factor column</b>" + "<p>Add a factor column to the table</p></html>"); addFactor.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { addFactor.setIcon(addFactorButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addFactor.setIcon(addFactorButton); } public void mousePressed(MouseEvent mouseEvent) { addFactor.setIcon(addFactorButton); if (addFactor.isEnabled()) { showAddColumnsGUI(AddColumnGUI.ADD_FACTOR_COLUMN); } } }); addCharacteristic = new JLabel(addCharacteristicButton); addCharacteristic.setToolTipText("<html><b>add a characteristic column</b>" + "<p>Add a characteristic column to the table</p></html>"); addCharacteristic.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { addCharacteristic.setIcon(addCharacteristicButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addCharacteristic.setIcon(addCharacteristicButton); } public void mousePressed(MouseEvent mouseEvent) { addCharacteristic.setIcon(addCharacteristicButton); if (addCharacteristic.isEnabled()) { showAddColumnsGUI(AddColumnGUI.ADD_CHARACTERISTIC_COLUMN); } } }); addParameter = new JLabel(addParameterButton); addParameter.setToolTipText( "<html><b>add a parameter column</b>" + "<p>Add a parameter column to the table</p></html>"); addParameter.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { addParameter.setIcon(addParameterButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addParameter.setIcon(addParameterButton); } public void mousePressed(MouseEvent mouseEvent) { addParameter.setIcon(addParameterButton); if (addParameter.isEnabled()) { showAddColumnsGUI(AddColumnGUI.ADD_PARAMETER_COLUMN); } } }); undo = new JLabel(undoButton); undo.setToolTipText("<html><b>undo previous action<b></html>"); undo.setEnabled(undoManager.canUndo()); undo.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { undo.setIcon(undoButton); undoManager.undo(); if (highlightActive) { setRowsToDefaultColor(); } table.addNotify(); } public void mouseEntered(MouseEvent mouseEvent) { undo.setIcon(undoButtonOver); } public void mouseExited(MouseEvent mouseEvent) { undo.setIcon(undoButton); } }); redo = new JLabel(redoButton); redo.setToolTipText("<html><b>redo action<b></html>"); redo.setEnabled(undoManager.canRedo()); redo.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { redo.setIcon(redoButton); undoManager.redo(); if (highlightActive) { setRowsToDefaultColor(); } table.addNotify(); } public void mouseEntered(MouseEvent mouseEvent) { redo.setIcon(redoButtonOver); } public void mouseExited(MouseEvent mouseEvent) { redo.setIcon(redoButton); } }); transpose = new JLabel(transposeIcon); transpose.setToolTipText("<html>View a transposed version of this spreadsheet</html>"); transpose.addMouseListener(new MouseAdapter() { public void mouseExited(MouseEvent mouseEvent) { transpose.setIcon(transposeIcon); } public void mouseEntered(MouseEvent mouseEvent) { transpose.setIcon(transposeIconOver); } public void mousePressed(MouseEvent mouseEvent) { showTransposeSpreadsheetGUI(); } }); addButtons(); if (studyDataEntryEnvironment != null) { JPanel labelContainer = new JPanel(new GridLayout(1, 1)); labelContainer.setBackground(UIHelper.BG_COLOR); JLabel lab = UIHelper.createLabel(spreadsheetTitle, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, JLabel.RIGHT); lab.setBackground(UIHelper.BG_COLOR); lab.setVerticalAlignment(JLabel.CENTER); lab.setPreferredSize(new Dimension(200, 30)); labelContainer.add(lab); spreadsheetFunctionPanel.add(labelContainer); spreadsheetFunctionPanel.add(Box.createHorizontalStrut(10)); } add(spreadsheetFunctionPanel, BorderLayout.NORTH); }