List of usage examples for java.awt Component getParent
public Container getParent()
From source file:org.jets3t.apps.cockpitlite.CockpitLite.java
/** * Prepares application to run as a GUI by finding/creating a root owner JFrame, creating an * un-authenticated {@link RestS3Service} and loading properties files. *//*from ww w . j av a 2 s . c o m*/ @Override public void init() { super.init(); // Find or create a Frame to own modal dialog boxes. if (this.ownerFrame == null) { Component c = this; while (!(c instanceof Frame) && c.getParent() != null) { c = c.getParent(); } if (!(c instanceof Frame)) { this.ownerFrame = new JFrame(); } else { this.ownerFrame = (Frame) c; } } cockpitLiteProperties = Jets3tProperties.getInstance(PROPERTIES_FILENAME); boolean isMissingRequiredInitProperty = false; if (isRunningAsApplet) { // Read parameters for Applet, based on names specified in the uploader properties. String appletParamNames = cockpitLiteProperties.getStringProperty("applet.params", ""); StringTokenizer st = new StringTokenizer(appletParamNames, ","); while (st.hasMoreTokens()) { String paramName = st.nextToken(); String paramValue = this.getParameter(paramName); // Fatal error if a parameter is missing. if (null == paramValue) { log.error("Missing required applet parameter: " + paramName); isMissingRequiredInitProperty = true; } else { log.debug("Found applet parameter: " + paramName + "='" + paramValue + "'"); // Set params as properties in the central properties source for this application. // Note that parameter values will over-write properties with the same name. cockpitLiteProperties.setProperty(paramName, paramValue); } } } else { // Add application parameters properties. if (standAloneArgumentProperties != null) { Enumeration e = standAloneArgumentProperties.keys(); while (e.hasMoreElements()) { String propName = (String) e.nextElement(); String propValue = standAloneArgumentProperties.getProperty(propName); // Fatal error if a parameter is missing. if (null == propValue) { log.error("Missing required command-line property: " + propName); isMissingRequiredInitProperty = true; } else { log.debug("Using command-line property: " + propName + "='" + propValue + "'"); // Set arguments as properties in the central properties source for this application. // Note that argument values will over-write properties with the same name. cockpitLiteProperties.setProperty(propName, propValue); } } } } // Initialise the GUI. initGui(); if (isMissingRequiredInitProperty) { String message = "Missing one or more required application properties"; log.error(message); ErrorDialog.showDialog(ownerFrame, this, cockpitLiteProperties.getProperties(), message, null); System.exit(1); } String gatekeeperUrl = cockpitLiteProperties.getStringProperty("gatekeeperUrl", null); if (gatekeeperUrl == null) { String message = "Application properties file '" + PROPERTIES_FILENAME + "' is not available"; log.error(message); ErrorDialog.showDialog(ownerFrame, this, cockpitLiteProperties.getProperties(), message, null); System.exit(1); } gkClient = new GatekeeperClientUtils(gatekeeperUrl, APPLICATION_DESCRIPTION, MAX_CONNECTION_RETRIES, HTTP_CONNECTION_TIMEOUT, this); // Initialise a non-authenticated service. // Revert to anonymous service. s3ServiceMulti = new S3ServiceMulti(new RestS3Service(null, APPLICATION_DESCRIPTION, this), this); }
From source file:edu.ku.brc.ui.UIHelper.java
public static Dialog getDialog(final Component comp) { Component parent = comp.getParent(); do {//from ww w.java2s . c o m if (parent instanceof Dialog) { return (Dialog) parent; } parent = parent.getParent(); } while (parent != null); return null; }
From source file:edu.ku.brc.ui.UIHelper.java
/** * Walks parents until it gets to a Window * @param comp the current component whiching for its parent * @return the parent frame//from w w w. j a v a 2 s .co m */ public static Window getWindow(final Component comp) { Component parent = comp.getParent(); do { if (parent instanceof Window) { return (Window) parent; } parent = parent.getParent(); } while (parent != null); return null; }
From source file:edu.purdue.cc.bionet.ui.CorrelationDisplayPanel.java
/** * The actionPerformed method of the ActionListener interface. * //from w ww. j av a2s . co m * @param event The event which triggered this action. */ public void actionPerformed(ActionEvent event) { Component item = (Component) event.getSource(); PickedState<Molecule> pickedVertexState = this.graph.getPickedVertexState(); PickedState<Correlation> pickedEdgeState = this.graph.getPickedEdgeState(); Collection<Molecule> vertices = new Vector(this.graph.getVertices()); Collection<Correlation> edges = new Vector(this.graph.getEdges()); if (item == this.selectAllViewMenuItem) { this.graph.selectAll(); } else if (item == this.clearSelectionViewMenuItem) { this.graph.clearSelection(); } else if (item == this.zoomInViewMenuItem) { this.visibleGraph.scale(1.25f); } else if (item == this.zoomOutViewMenuItem) { this.visibleGraph.scale(0.8f); } else if (item == this.fitToWindowViewMenuItem) { this.visibleGraph.scaleTo(0.99f); } else if (item == this.invertSelectionViewMenuItem) { for (Molecule m : vertices) pickedVertexState.pick(m, !pickedVertexState.isPicked(m)); for (Correlation c : edges) pickedEdgeState.pick(c, !pickedEdgeState.isPicked(c)); } else if (item == this.selectCorrelatedViewMenuItem) { Collection<Molecule> picked = new Vector(pickedVertexState.getPicked()); for (Molecule m : picked) { for (Correlation c : graph.getIncidentEdges(m)) { pickedEdgeState.pick(c, true); pickedVertexState.pick(c.getOpposite(m), true); } } } else if (item == this.hideSelectedViewMenuItem) { for (Molecule m : new Vector<Molecule>(pickedVertexState.getPicked())) this.graph.removeVertex(m); } else if (item == this.hideUnselectedViewMenuItem) { for (Molecule m : vertices) { if (!pickedVertexState.isPicked(m)) this.graph.removeVertex(m); } } else if (item == this.hideUncorrelatedViewMenuItem) { boolean keep; for (Molecule m : vertices) { keep = false; for (Correlation c : graph.getIncidentEdges(m)) { keep = keep || pickedVertexState.isPicked(m) || pickedVertexState.isPicked(c.getOpposite(m)); } if (!keep) { this.graph.removeVertex(m); } } } else if (item == this.hideOrphansViewMenuItem) { for (Molecule m : vertices) { if (this.graph.getNeighborCount(m) == 0) this.graph.removeVertex(m); } } else if (item == this.showCorrelatedViewMenuItem) { this.graph.setIgnoreRepaint(true); for (Correlation c : this.correlations) { if (this.getCorrelationRange().contains(c.getValue(this.correlationMethod)) && (vertices.contains(c.getFirst()) || vertices.contains(c.getSecond()))) { this.graph.addVertex(c.getFirst()); this.graph.addVertex(c.getSecond()); } } this.graph.setIgnoreRepaint(false); } else if (item == this.chooseSampleGroupsMenuItem) { Component frame = this; while (!(frame instanceof Frame) && frame != null) { frame = frame.getParent(); } this.setSampleGroups(SampleGroupDialog.showInputDialog((Frame) frame, Settings.getLanguage().get("Choose groups"), this.samples)); if (this.getSampleGroups().size() > 1) { this.infoPanel.repaint(); Logger logger = Logger.getLogger(getClass()); Iterator<SampleGroup> iterator = this.getSampleGroups().iterator(); SampleGroup group = iterator.next(); logger.debug(group.toString()); for (Sample sample : group) { logger.debug("\t" + sample.toString()); } group = iterator.next(); logger.debug(group.toString()); for (Sample sample : group) { logger.debug("\t" + sample.toString()); } } } else if (item == this.resetSampleGroupsMenuItem) { Collection<SampleGroup> sampleGroups = new ArrayList<SampleGroup>(); sampleGroups.add(new SampleGroup(Settings.getLanguage().get("All samples"), this.samples)); this.setSampleGroups(sampleGroups); this.infoPanel.repaint(); } }
From source file:org.jets3t.apps.cockpit.Cockpit.java
/** * Prepares application to run as a GUI by finding/creating a root owner JFrame, creating an * un-authenticated {@link RestS3Service} and loading properties files. *//*from w w w .j av a 2 s. c o m*/ @Override public void init() { super.init(); // Find or create a Frame to own modal dialog boxes. if (this.ownerFrame == null) { Component c = this; while (!(c instanceof Frame) && c.getParent() != null) { c = c.getParent(); } if (!(c instanceof JFrame)) { this.ownerFrame = new JFrame(); } else { this.ownerFrame = (JFrame) c; } } // Initialise the GUI. initGui(); // Load Cockpit configuration files from cockpit's home directory. File mimeTypesFile = new File(cockpitHomeDirectory, "mime.types"); if (mimeTypesFile.exists()) { try { Mimetypes.getInstance().loadAndReplaceMimetypes(new FileInputStream(mimeTypesFile)); } catch (IOException e) { String message = "Unable to load mime.types file: " + mimeTypesFile; log.error(message, e); ErrorDialog.showDialog(ownerFrame, this, message, e); } } File jets3tPropertiesFile = new File(cockpitHomeDirectory, "jets3t.properties"); if (jets3tPropertiesFile.exists()) { try { Jets3tProperties.getInstance(Constants.JETS3T_PROPERTIES_FILENAME).loadAndReplaceProperties( new FileInputStream(jets3tPropertiesFile), "jets3t.properties in Cockpit's home folder " + cockpitHomeDirectory); } catch (IOException e) { String message = "Unable to load jets3t.properties file: " + jets3tPropertiesFile; log.error(message, e); ErrorDialog.showDialog(ownerFrame, this, message, e); } } // Initialise the user's preferences. this.cockpitPreferences = new CockpitPreferences(); File cockpitPreferencesPropertiesFile = new File(cockpitHomeDirectory, Constants.COCKPIT_PROPERTIES_FILENAME); if (cockpitPreferencesPropertiesFile.exists()) { try { Properties properties = new Properties(); properties.load(new FileInputStream(cockpitPreferencesPropertiesFile)); this.cockpitPreferences.fromProperties(properties); } catch (IOException e) { String message = "Unable to load your preferences"; log.error(message, e); ErrorDialog.showDialog(ownerFrame, this, message, e); } } cockpitProperties = Jets3tProperties.getInstance(Constants.JETS3T_PROPERTIES_FILENAME); skinsFactory = SkinsFactory.getInstance(cockpitProperties.getProperties()); SwingUtilities.invokeLater(new Runnable() { public void run() { loginEvent(null); } }); }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.Cockpit.java
/** * Prepares application to run as a GUI by finding/creating a root owner JFrame, creating an * un-authenticated {@link RestS3Service} and loading properties files. *//*from w w w .j a v a2 s. c om*/ public void init() { super.init(); // Find or create a Frame to own modal dialog boxes. if (this.ownerFrame == null) { Component c = this; while (!(c instanceof Frame) && c.getParent() != null) { c = c.getParent(); } if (!(c instanceof JFrame)) { this.ownerFrame = new JFrame(); } else { this.ownerFrame = (JFrame) c; } } // Initialise the GUI. initGui(); // Initialise a non-authenticated service. try { // Revert to anonymous service. s3ServiceMulti = new S3ServiceMulti(new RestS3Service(null, APPLICATION_DESCRIPTION, this), this); cloudFrontService = null; } catch (S3ServiceException e) { String message = "Unable to start anonymous service"; log.error(message, e); ErrorDialog.showDialog(ownerFrame, this, message, e); } // Load Cockpit configuration files from cockpit's home directory. File mimeTypesFile = new File(cockpitHomeDirectory, "mime.types"); if (mimeTypesFile.exists()) { try { Mimetypes.getInstance().loadAndReplaceMimetypes(new FileInputStream(mimeTypesFile)); } catch (IOException e) { String message = "Unable to load mime.types file: " + mimeTypesFile; log.error(message, e); ErrorDialog.showDialog(ownerFrame, this, message, e); } } File jets3tPropertiesFile = new File(cockpitHomeDirectory, "jets3t.properties"); if (jets3tPropertiesFile.exists()) { try { Jets3tProperties.getInstance(Constants.JETS3T_PROPERTIES_FILENAME).loadAndReplaceProperties( new FileInputStream(jets3tPropertiesFile), "jets3t.properties in Cockpit's home folder " + cockpitHomeDirectory); } catch (IOException e) { String message = "Unable to load jets3t.properties file: " + jets3tPropertiesFile; log.error(message, e); ErrorDialog.showDialog(ownerFrame, this, message, e); } } // Initialise the user's preferences. this.cockpitPreferences = new CockpitPreferences(); File cockpitPreferencesPropertiesFile = new File(cockpitHomeDirectory, Constants.COCKPIT_PROPERTIES_FILENAME); if (cockpitPreferencesPropertiesFile.exists()) { try { Properties properties = new Properties(); properties.load(new FileInputStream(cockpitPreferencesPropertiesFile)); this.cockpitPreferences.fromProperties(properties); } catch (IOException e) { String message = "Unable to load your preferences"; log.error(message, e); ErrorDialog.showDialog(ownerFrame, this, message, e); } } cockpitProperties = Jets3tProperties.getInstance(Constants.JETS3T_PROPERTIES_FILENAME); skinsFactory = SkinsFactory.getInstance(cockpitProperties.getProperties()); //SwingUtilities.invokeLater(new Runnable() { // public void run() { // loginEvent(null); // } //}); }
From source file:com.mxgraph.examples.swing.editor.EditorActions.java
/** * /*w ww .java 2s . c o m*/ * @param e * @return Returns the graph for the given action event. */ public static final BasicGraphEditor getEditor(ActionEvent e) { if (e.getSource() instanceof Component) { Component component = (Component) e.getSource(); while (component != null && !(component instanceof BasicGraphEditor)) { component = component.getParent(); if (component instanceof MyInternalFrame) { return ((MyInternalFrame) component).getEditor(); //break; } } return (BasicGraphEditor) component; } return null; }
From source file:org.kuali.test.utils.Utils.java
public static JDialog getParentDialog(Component c) { JDialog retval = null;/*from w w w . ja va 2 s . c o m*/ Component p = c.getParent(); while (p != null) { if (p instanceof JDialog) { retval = (JDialog) p; break; } p = p.getParent(); } return retval; }
From source file:self.philbrown.javaQuery.$.java
/** * Adds a subview to the first view in the selection * @param v the subview to add//from w ww . java2s . co m * @return this */ public $ add(Component v) { if (v == null || v.getParent() != null) { Log.w("javaQuery", "Cannot add View"); return this; } if (view(0) instanceof Container) { ((Container) view(0)).add(v); } return this; }
From source file:self.philbrown.javaQuery.$.java
/** * Removes each view in the current selection from the layout *///from w w w. j a v a 2 s. c o m public void remove() { for (Component view : this.views) { Component parent = view.getParent(); if (parent != null && parent instanceof Container) { ((Container) parent).remove(view); } } }